Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,6 @@ ion-picker,event,ionInputModeChange,PickerChangeEventDetail,true
ion-picker-column,shadow
ion-picker-column,prop,color,"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record<never, never> | undefined,'primary',false,true
ion-picker-column,prop,disabled,boolean,false,false,false
ion-picker-column,prop,items,PickerColumnItem[],[],false,false
ion-picker-column,prop,mode,"ios" | "md",undefined,false,false
ion-picker-column,prop,value,number | string | undefined,undefined,false,false
ion-picker-column,method,setFocus,setFocus() => Promise<void>
Expand Down
12 changes: 2 additions & 10 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { ModalBreakpointChangeEventDetail, ModalHandleBehavior } from "./compone
import { NavComponent, NavComponentWithProps, NavOptions, RouterOutletOptions, SwipeGestureHandler, TransitionDoneFn, TransitionInstruction } from "./components/nav/nav-interface";
import { ViewController } from "./components/nav/view-controller";
import { PickerChangeEventDetail } from "./components/picker/picker-interfaces";
import { PickerColumnChangeEventDetail, PickerColumnItem, PickerColumnValue } from "./components/picker-column/picker-column-interfaces";
import { PickerColumnChangeEventDetail, PickerColumnValue } from "./components/picker-column/picker-column-interfaces";
import { PickerButton, PickerColumn } from "./components/picker-legacy/picker-interface";
import { PopoverSize, PositionAlign, PositionReference, PositionSide, TriggerAction } from "./components/popover/popover-interface";
import { RadioGroupChangeEventDetail } from "./components/radio-group/radio-group-interface";
Expand Down Expand Up @@ -60,7 +60,7 @@ export { ModalBreakpointChangeEventDetail, ModalHandleBehavior } from "./compone
export { NavComponent, NavComponentWithProps, NavOptions, RouterOutletOptions, SwipeGestureHandler, TransitionDoneFn, TransitionInstruction } from "./components/nav/nav-interface";
export { ViewController } from "./components/nav/view-controller";
export { PickerChangeEventDetail } from "./components/picker/picker-interfaces";
export { PickerColumnChangeEventDetail, PickerColumnItem, PickerColumnValue } from "./components/picker-column/picker-column-interfaces";
export { PickerColumnChangeEventDetail, PickerColumnValue } from "./components/picker-column/picker-column-interfaces";
export { PickerButton, PickerColumn } from "./components/picker-legacy/picker-interface";
export { PopoverSize, PositionAlign, PositionReference, PositionSide, TriggerAction } from "./components/popover/popover-interface";
export { RadioGroupChangeEventDetail } from "./components/radio-group/radio-group-interface";
Expand Down Expand Up @@ -1964,10 +1964,6 @@ export namespace Components {
* If `true`, the user cannot interact with the picker.
*/
"disabled": boolean;
/**
* A list of options to be displayed in the picker
*/
"items": PickerColumnItem[];
/**
* The mode determines which platform styles to use.
*/
Expand Down Expand Up @@ -6620,10 +6616,6 @@ declare namespace LocalJSX {
* If `true`, the user cannot interact with the picker.
*/
"disabled"?: boolean;
/**
* A list of options to be displayed in the picker
*/
"items"?: PickerColumnItem[];
/**
* The mode determines which platform styles to use.
*/
Expand Down
14 changes: 7 additions & 7 deletions core/src/components/datetime/datetime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { caretDownSharp, caretUpSharp, chevronBack, chevronDown, chevronForward

import { getIonMode } from '../../global/ionic-global';
import type { Color, Mode, StyleEventDetail } from '../../interface';
import type { PickerColumnItem } from '../picker-column/picker-column-interfaces';

import type {
DatetimePresentation,
Expand All @@ -22,6 +21,7 @@ import type {
DatetimeHourCycle,
} from './datetime-interface';
import { isSameDay, warnIfValueOutOfBounds, isBefore, isAfter } from './utils/comparison';
import type { WheelColumnOption } from './utils/data';
import {
generateMonths,
getDaysOfMonth,
Expand Down Expand Up @@ -1733,7 +1733,7 @@ export class Datetime implements ComponentInterface {
return renderArray;
}

private renderDayPickerColumn(days: PickerColumnItem[]) {
private renderDayPickerColumn(days: WheelColumnOption[]) {
if (days.length === 0) {
return [];
}
Expand Down Expand Up @@ -1789,7 +1789,7 @@ export class Datetime implements ComponentInterface {
);
}

private renderMonthPickerColumn(months: PickerColumnItem[]) {
private renderMonthPickerColumn(months: WheelColumnOption[]) {
if (months.length === 0) {
return [];
}
Expand Down Expand Up @@ -1843,7 +1843,7 @@ export class Datetime implements ComponentInterface {
</ion-picker-column>
);
}
private renderYearPickerColumn(years: PickerColumnItem[]) {
private renderYearPickerColumn(years: WheelColumnOption[]) {
if (years.length === 0) {
return [];
}
Expand Down Expand Up @@ -1931,7 +1931,7 @@ export class Datetime implements ComponentInterface {
];
}

private renderHourPickerColumn(hoursData: PickerColumnItem[]) {
private renderHourPickerColumn(hoursData: WheelColumnOption[]) {
const { disabled, workingParts } = this;
if (hoursData.length === 0) return [];

Expand Down Expand Up @@ -1970,7 +1970,7 @@ export class Datetime implements ComponentInterface {
</ion-picker-column>
);
}
private renderMinutePickerColumn(minutesData: PickerColumnItem[]) {
private renderMinutePickerColumn(minutesData: WheelColumnOption[]) {
const { disabled, workingParts } = this;
if (minutesData.length === 0) return [];

Expand Down Expand Up @@ -2009,7 +2009,7 @@ export class Datetime implements ComponentInterface {
</ion-picker-column>
);
}
private renderDayPeriodPickerColumn(dayPeriodData: PickerColumnItem[]) {
private renderDayPeriodPickerColumn(dayPeriodData: WheelColumnOption[]) {
const { disabled, workingParts } = this;
if (dayPeriodData.length === 0) {
return [];
Expand Down
21 changes: 13 additions & 8 deletions core/src/components/datetime/utils/data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Mode } from '../../../interface';
import type { PickerColumnItem } from '../../picker-column/picker-column-interfaces';
import type { DatetimeParts, DatetimeHourCycle } from '../datetime-interface';

import { isAfter, isBefore, isSameDay } from './comparison';
Expand All @@ -14,6 +13,12 @@ import {
import { getNumDaysInMonth, is24Hour, getHourCycle } from './helpers';
import { getNextMonth, getPreviousMonth, getInternalHourValue } from './manipulation';

export interface WheelColumnOption {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface used to live in picker-column-interfaces. However, it's now really only used for datetime so I decided to move it to the datetime directory. I opted not to include it in datetime/datetime-interfaces since this is a private interface.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also decided to call it "Wheel" since that's the terminology we use with datetime. No functionality has changed though.

text: string;
value: string | number;
disabled?: boolean;
}

/**
* Returns the current date as
* an ISO string in the user's
Expand Down Expand Up @@ -313,7 +318,7 @@ export const getMonthColumnData = (
formatOptions: Intl.DateTimeFormatOptions = {
month: 'long',
}
): PickerColumnItem[] => {
): WheelColumnOption[] => {
const { year } = refParts;
const months = [];

Expand Down Expand Up @@ -391,7 +396,7 @@ export const getDayColumnData = (
formatOptions: Intl.DateTimeFormatOptions = {
day: 'numeric',
}
): PickerColumnItem[] => {
): WheelColumnOption[] => {
const { month, year } = refParts;
const days = [];

Expand Down Expand Up @@ -438,7 +443,7 @@ export const getYearColumnData = (
minParts?: DatetimeParts,
maxParts?: DatetimeParts,
yearValues?: number[]
): PickerColumnItem[] => {
): WheelColumnOption[] => {
let processedYears = [];
if (yearValues !== undefined) {
processedYears = yearValues;
Expand Down Expand Up @@ -466,7 +471,7 @@ export const getYearColumnData = (

interface CombinedDateColumnData {
parts: DatetimeParts[];
items: PickerColumnItem[];
items: WheelColumnOption[];
}

/**
Expand Down Expand Up @@ -495,7 +500,7 @@ export const getCombinedDateColumnData = (
dayValues?: number[],
monthValues?: number[]
): CombinedDateColumnData => {
let items: PickerColumnItem[] = [];
let items: WheelColumnOption[] = [];
let parts: DatetimeParts[] = [];

/**
Expand Down Expand Up @@ -528,7 +533,7 @@ export const getCombinedDateColumnData = (
});

const dateParts: DatetimeParts[] = [];
const dateColumnItems: PickerColumnItem[] = [];
const dateColumnItems: WheelColumnOption[] = [];

monthDays.forEach((dayObject) => {
const isToday = isSameDay({ ...referenceMonth, day: dayObject.value as number }, todayParts);
Expand Down Expand Up @@ -576,7 +581,7 @@ export const getTimeColumnsData = (
maxParts?: DatetimeParts,
allowedHourValues?: number[],
allowedMinuteValues?: number[]
): { [key: string]: PickerColumnItem[] } => {
): { [key: string]: WheelColumnOption[] } => {
const computedHourCycle = getHourCycle(locale, hourCycle);
const use24Hour = is24Hour(computedHourCycle);
const { hours, minutes, am, pm } = generateTime(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { newSpecPage } from '@stencil/core/testing';

import { PickerColumnOption } from '../picker-column-option';

describe('picker column option', () => {
it('button should be enabled by default', async () => {
const page = await newSpecPage({
components: [PickerColumnOption],
html: `
<ion-picker-column-option value="test">Test</ion-picker-column-otion>
`,
});

const option = page.body.querySelector('ion-picker-column-option')!;
const button = option.shadowRoot!.querySelector('button')!;

await expect(button.hasAttribute('disabled')).toEqual(false);
});

it('button should be disabled if specified', async () => {
const page = await newSpecPage({
components: [PickerColumnOption],
html: `
<ion-picker-column-option disabled="true" value="test">Test</ion-picker-column-otion>
`,
});

const option = page.body.querySelector('ion-picker-column-option')!;
const button = option.shadowRoot!.querySelector('button')!;

await expect(button.hasAttribute('disabled')).toEqual(true);
});
});
7 changes: 0 additions & 7 deletions core/src/components/picker-column/picker-column-interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
// TODO FW-5580 remove this
export interface PickerColumnItem {
text: string;
value: string | number;
disabled?: boolean;
}

export interface PickerColumnChangeEventDetail {
value: PickerColumnValue;
}
Expand Down
1 change: 0 additions & 1 deletion core/src/components/picker-column/picker-column.ios.scss

This file was deleted.

7 changes: 0 additions & 7 deletions core/src/components/picker-column/picker-column.md.scss

This file was deleted.

94 changes: 33 additions & 61 deletions core/src/components/picker-column/picker-column.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,39 @@
scrollbar-width: none;
}

.picker-item-empty {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally thought the old .picker-item CSS wasn't needed. Turns out it's still needed but just for the spacer elements. I updated the selector to make that more clear.

@include padding(0);
@include margin(0);

display: block;

width: 100%;

height: 34px;

border: 0px;

outline: none;

background: transparent;

color: inherit;

font-family: $font-family-base;

font-size: inherit;

line-height: 34px;

text-align: inherit;

text-overflow: ellipsis;

white-space: nowrap;

overflow: hidden;
}

/**
* Hide scrollbars on Chrome and Safari
*/
Expand Down Expand Up @@ -112,66 +145,10 @@
justify-content: start;
}

// TODO FW-5580 remove this
:host .picker-item {
@include padding(0);
@include margin(0);

display: block;

width: 100%;

height: 34px;

border: 0px;

outline: none;

background: transparent;

color: inherit;

font-family: $font-family-base;

font-size: inherit;

line-height: 34px;

text-align: inherit;

text-overflow: ellipsis;

white-space: nowrap;

cursor: pointer;

overflow: hidden;

scroll-snap-align: center;
}

// TODO FW-5580 remove this.
// Figure out if we still need the .picker-item-empty selector
:host .picker-item-empty,
:host .picker-item[disabled] {
cursor: default;
}

// TODO FW-5580 remove this
:host .picker-item-empty,
:host(:not([disabled])) .picker-item[disabled] {
scroll-snap-align: none;
}
Comment thread
averyrousseau marked this conversation as resolved.
Resolved

:host(.picker-column-disabled) .picker-opts {
overflow-y: hidden;
}

// TODO FW-5580 remove this
:host .picker-item[disabled] {
opacity: 0.4;
}

/**
* When the column is disabled, none of the options
* should be interactive. However, we do not disable
Expand All @@ -186,11 +163,6 @@
pointer-events: none;
}

// TODO FW-5580 remove this
:host(.picker-column-active) .picker-item.picker-item-active {
color: current-color(base);
}

@media (any-hover: hover) {
:host(:focus) .picker-opts {
outline: none;
Expand Down
Loading