frontile 0.18.5 → 0.18.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/-private/icons.d.ts +4 -0
- package/declarations/-private/icons.d.ts.map +1 -1
- package/declarations/-private/reveal-within.d.ts +19 -0
- package/declarations/-private/reveal-within.d.ts.map +1 -0
- package/declarations/components/collections/calendar/year-grid.d.ts.map +1 -1
- package/declarations/components/collections/dropdown/dropdown.d.ts +50 -53
- package/declarations/components/collections/dropdown/dropdown.d.ts.map +1 -1
- package/declarations/components/collections/listbox/item.d.ts +52 -1
- package/declarations/components/collections/listbox/item.d.ts.map +1 -1
- package/declarations/components/forms/date-input/segment-group.d.ts +2 -1
- package/declarations/components/forms/date-input/segment-group.d.ts.map +1 -1
- package/declarations/components/forms/date-input/segments.d.ts +3 -1
- package/declarations/components/forms/date-input/segments.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/date-picker.d.ts +119 -1
- package/declarations/components/forms/date-picker/date-picker.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/time-columns.d.ts +87 -0
- package/declarations/components/forms/date-picker/time-columns.d.ts.map +1 -0
- package/declarations/components/forms/date-picker/types.d.ts +28 -0
- package/declarations/components/forms/date-picker/types.d.ts.map +1 -1
- package/declarations/components/forms/select/native-mirror.d.ts +3 -2
- package/declarations/components/forms/select/native-mirror.d.ts.map +1 -1
- package/declarations/components/forms/select/select.d.ts +31 -2
- package/declarations/components/forms/select/select.d.ts.map +1 -1
- package/declarations/components/forms/select/types.d.ts +3 -2
- package/declarations/components/forms/select/types.d.ts.map +1 -1
- package/declarations/components/layout/app-layout-state.d.ts +32 -0
- package/declarations/components/layout/app-layout-state.d.ts.map +1 -0
- package/declarations/components/layout/app-layout.d.ts +954 -0
- package/declarations/components/layout/app-layout.d.ts.map +1 -0
- package/declarations/components/layout/aside-toggle.d.ts +55 -0
- package/declarations/components/layout/aside-toggle.d.ts.map +1 -0
- package/declarations/components/layout/aside.d.ts +761 -0
- package/declarations/components/layout/aside.d.ts.map +1 -0
- package/declarations/components/layout/bottom-nav-more.d.ts +123 -0
- package/declarations/components/layout/bottom-nav-more.d.ts.map +1 -0
- package/declarations/components/layout/bottom-nav.d.ts +60 -0
- package/declarations/components/layout/bottom-nav.d.ts.map +1 -0
- package/declarations/components/layout/context.d.ts +134 -0
- package/declarations/components/layout/context.d.ts.map +1 -0
- package/declarations/components/layout/index.d.ts +14 -0
- package/declarations/components/layout/index.d.ts.map +1 -0
- package/declarations/components/layout/main.d.ts +28 -0
- package/declarations/components/layout/main.d.ts.map +1 -0
- package/declarations/components/layout/menu-toggle.d.ts +58 -0
- package/declarations/components/layout/menu-toggle.d.ts.map +1 -0
- package/declarations/components/layout/nav-context.d.ts +45 -0
- package/declarations/components/layout/nav-context.d.ts.map +1 -0
- package/declarations/components/layout/nav-folder.d.ts +216 -0
- package/declarations/components/layout/nav-folder.d.ts.map +1 -0
- package/declarations/components/layout/nav-item.d.ts +220 -0
- package/declarations/components/layout/nav-item.d.ts.map +1 -0
- package/declarations/components/layout/nav-link.d.ts +67 -0
- package/declarations/components/layout/nav-link.d.ts.map +1 -0
- package/declarations/components/layout/navbar.d.ts +27 -0
- package/declarations/components/layout/navbar.d.ts.map +1 -0
- package/declarations/components/layout/page-header.d.ts +40 -0
- package/declarations/components/layout/page-header.d.ts.map +1 -0
- package/declarations/components/layout/sidebar-group.d.ts +41 -0
- package/declarations/components/layout/sidebar-group.d.ts.map +1 -0
- package/declarations/components/layout/sidebar-toggle.d.ts +71 -0
- package/declarations/components/layout/sidebar-toggle.d.ts.map +1 -0
- package/declarations/components/layout/sidebar.d.ts +904 -0
- package/declarations/components/layout/sidebar.d.ts.map +1 -0
- package/declarations/components/navigation/index.d.ts +1 -0
- package/declarations/components/navigation/index.d.ts.map +1 -1
- package/declarations/components/navigation/stepper/collapse-menu.d.ts +42 -0
- package/declarations/components/navigation/stepper/collapse-menu.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/list.d.ts +24 -0
- package/declarations/components/navigation/stepper/list.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/panel.d.ts +42 -0
- package/declarations/components/navigation/stepper/panel.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/step.d.ts +123 -0
- package/declarations/components/navigation/stepper/step.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/stepper.d.ts +947 -0
- package/declarations/components/navigation/stepper/stepper.d.ts.map +1 -0
- package/declarations/components/navigation/stepper.d.ts +6 -0
- package/declarations/components/navigation/stepper.d.ts.map +1 -0
- package/declarations/components/navigation/tab-nav/item.d.ts +2 -2
- package/declarations/components/navigation/tab-nav/item.d.ts.map +1 -1
- package/declarations/components/overlays/overlay.d.ts +17 -2
- package/declarations/components/overlays/overlay.d.ts.map +1 -1
- package/declarations/components/overlays/portal.d.ts.map +1 -1
- package/declarations/components/utilities/collapsible.d.ts +19 -2
- package/declarations/components/utilities/collapsible.d.ts.map +1 -1
- package/declarations/index.d.ts +1 -0
- package/declarations/index.d.ts.map +1 -1
- package/declarations/layout.d.ts +2 -0
- package/declarations/layout.d.ts.map +1 -0
- package/declarations/test-support.d.ts.map +1 -1
- package/declarations/utils/breakpoint.d.ts +16 -0
- package/declarations/utils/breakpoint.d.ts.map +1 -0
- package/declarations/utils/document-listener.d.ts +6 -0
- package/declarations/utils/document-listener.d.ts.map +1 -0
- package/declarations/utils/listManager.d.ts +7 -1
- package/declarations/utils/listManager.d.ts.map +1 -1
- package/declarations/utils/route-active.d.ts +34 -0
- package/declarations/utils/route-active.d.ts.map +1 -0
- package/declarations/utils/selection-indicator.d.ts +7 -4
- package/declarations/utils/selection-indicator.d.ts.map +1 -1
- package/dist/components/collections/calendar/header.js +1 -1
- package/dist/components/collections/calendar/year-grid.js +1 -30
- package/dist/components/collections/calendar/year-grid.js.map +1 -1
- package/dist/components/collections/dropdown/dropdown.js +172 -48
- package/dist/components/collections/dropdown/dropdown.js.map +1 -1
- package/dist/components/collections/listbox/item.js +36 -2
- package/dist/components/collections/listbox/item.js.map +1 -1
- package/dist/components/collections/table/column-visibility.js +1 -1
- package/dist/components/collections/table/sort-button.js +1 -1
- package/dist/components/disclosure/accordion/item.js +1 -1
- package/dist/components/forms/autocomplete.js +1 -1
- package/dist/components/forms/date-input/segment-group.js +1 -1
- package/dist/components/forms/date-input/segment-group.js.map +1 -1
- package/dist/components/forms/date-input/segments.js +1 -1
- package/dist/components/forms/date-input/segments.js.map +1 -1
- package/dist/components/forms/date-input.js +1 -1
- package/dist/components/forms/date-picker/date-picker.js +57 -6
- package/dist/components/forms/date-picker/date-picker.js.map +1 -1
- package/dist/components/forms/date-picker/end-content.js +1 -1
- package/dist/components/forms/date-picker/time-columns.js +238 -0
- package/dist/components/forms/date-picker/time-columns.js.map +1 -0
- package/dist/components/forms/index.js +1 -1
- package/dist/components/forms/native-select.js +1 -1
- package/dist/components/forms/select/end-content.js +1 -1
- package/dist/components/forms/select/native-mirror.js.map +1 -1
- package/dist/components/forms/select/select.js +24 -5
- package/dist/components/forms/select/select.js.map +1 -1
- package/dist/components/layout/app-layout-state.js +64 -0
- package/dist/components/layout/app-layout-state.js.map +1 -0
- package/dist/components/layout/app-layout.js +416 -0
- package/dist/components/layout/app-layout.js.map +1 -0
- package/dist/components/layout/aside-toggle.js +55 -0
- package/dist/components/layout/aside-toggle.js.map +1 -0
- package/dist/components/layout/aside.js +100 -0
- package/dist/components/layout/aside.js.map +1 -0
- package/dist/components/layout/bottom-nav-more.js +150 -0
- package/dist/components/layout/bottom-nav-more.js.map +1 -0
- package/dist/components/layout/bottom-nav.js +65 -0
- package/dist/components/layout/bottom-nav.js.map +1 -0
- package/dist/components/layout/context.js +89 -0
- package/dist/components/layout/context.js.map +1 -0
- package/dist/components/layout/index.js +14 -0
- package/dist/components/layout/index.js.map +1 -0
- package/dist/components/layout/main.js +34 -0
- package/dist/components/layout/main.js.map +1 -0
- package/dist/components/layout/menu-toggle.js +61 -0
- package/dist/components/layout/menu-toggle.js.map +1 -0
- package/dist/components/layout/nav-context.js +85 -0
- package/dist/components/layout/nav-context.js.map +1 -0
- package/dist/components/layout/nav-folder.js +271 -0
- package/dist/components/layout/nav-folder.js.map +1 -0
- package/dist/components/layout/nav-item.js +192 -0
- package/dist/components/layout/nav-item.js.map +1 -0
- package/dist/components/layout/nav-link.js +58 -0
- package/dist/components/layout/nav-link.js.map +1 -0
- package/dist/components/layout/navbar.js +30 -0
- package/dist/components/layout/navbar.js.map +1 -0
- package/dist/components/layout/page-header.js +45 -0
- package/dist/components/layout/page-header.js.map +1 -0
- package/dist/components/layout/sidebar-group.js +41 -0
- package/dist/components/layout/sidebar-group.js.map +1 -0
- package/dist/components/layout/sidebar-toggle.js +82 -0
- package/dist/components/layout/sidebar-toggle.js.map +1 -0
- package/dist/components/layout/sidebar.js +249 -0
- package/dist/components/layout/sidebar.js.map +1 -0
- package/dist/components/navigation/breadcrumbs/separator.js +1 -1
- package/dist/components/navigation/index.js +4 -0
- package/dist/components/navigation/index.js.map +1 -1
- package/dist/components/navigation/pagination/pagination.js +1 -1
- package/dist/components/navigation/stepper/collapse-menu.js +128 -0
- package/dist/components/navigation/stepper/collapse-menu.js.map +1 -0
- package/dist/components/navigation/stepper/list.js +17 -0
- package/dist/components/navigation/stepper/list.js.map +1 -0
- package/dist/components/navigation/stepper/panel.js +26 -0
- package/dist/components/navigation/stepper/panel.js.map +1 -0
- package/dist/components/navigation/stepper/step.js +130 -0
- package/dist/components/navigation/stepper/step.js.map +1 -0
- package/dist/components/navigation/stepper/stepper.js +475 -0
- package/dist/components/navigation/stepper/stepper.js.map +1 -0
- package/dist/components/navigation/stepper.js +5 -0
- package/dist/components/navigation/stepper.js.map +1 -0
- package/dist/components/navigation/tab-nav/item.js +6 -40
- package/dist/components/navigation/tab-nav/item.js.map +1 -1
- package/dist/components/notifications/index.js +1 -1
- package/dist/components/notifications/notification-card.js +2 -2
- package/dist/components/notifications/notifications-container.js +1 -1
- package/dist/components/overlays/overlay.js +55 -7
- package/dist/components/overlays/overlay.js.map +1 -1
- package/dist/components/overlays/portal.js +11 -2
- package/dist/components/overlays/portal.js.map +1 -1
- package/dist/components/status/alert.js +1 -1
- package/dist/components/utilities/collapsible.js +33 -5
- package/dist/components/utilities/collapsible.js.map +1 -1
- package/dist/forms.js +1 -1
- package/dist/{icons-DZ61nCzv.js → icons-55dthVFk.js} +14 -2
- package/dist/{icons-DZ61nCzv.js.map → icons-55dthVFk.js.map} +1 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/layout.js +14 -0
- package/dist/layout.js.map +1 -0
- package/dist/navigation.js +4 -0
- package/dist/navigation.js.map +1 -1
- package/dist/{notification-card-dz-eE6z9.js → notification-card-BPfDo-Gf.js} +2 -2
- package/dist/{notification-card-dz-eE6z9.js.map → notification-card-BPfDo-Gf.js.map} +1 -1
- package/dist/notifications.js +1 -1
- package/dist/reveal-within-BcqpOmSI.js +33 -0
- package/dist/reveal-within-BcqpOmSI.js.map +1 -0
- package/dist/test-support.js +3 -1
- package/dist/test-support.js.map +1 -1
- package/dist/utils/breakpoint.js +56 -0
- package/dist/utils/breakpoint.js.map +1 -0
- package/dist/utils/document-listener.js +10 -0
- package/dist/utils/document-listener.js.map +1 -0
- package/dist/utils/listManager.js +12 -2
- package/dist/utils/listManager.js.map +1 -1
- package/dist/utils/route-active.js +70 -0
- package/dist/utils/route-active.js.map +1 -0
- package/dist/utils/selection-indicator.js +25 -5
- package/dist/utils/selection-indicator.js.map +1 -1
- package/package.json +7 -3
|
@@ -2,7 +2,7 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { useStyles } from '@frontile/theme';
|
|
3
3
|
import { Dropdown } from '../dropdown/dropdown.js';
|
|
4
4
|
import { isVisible, show, hide } from '@universal-ember/table/plugins/column-visibility';
|
|
5
|
-
import { C as ColumnVisibilityIcon } from '../../../icons-
|
|
5
|
+
import { C as ColumnVisibilityIcon } from '../../../icons-55dthVFk.js';
|
|
6
6
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
7
7
|
import { setComponentTemplate } from '@ember/component';
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { useStyles } from '@frontile/theme';
|
|
3
3
|
import press from '../../../modifiers/press.js';
|
|
4
|
-
import { a as ChevronDownIcon, b as ChevronUpIcon } from '../../../icons-
|
|
4
|
+
import { a as ChevronDownIcon, b as ChevronUpIcon } from '../../../icons-55dthVFk.js';
|
|
5
5
|
import { SortDirection } from '@universal-ember/table/plugins/data-sorting';
|
|
6
6
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
7
7
|
import { setComponentTemplate } from '@ember/component';
|
|
@@ -4,7 +4,7 @@ import { on } from '@ember/modifier';
|
|
|
4
4
|
import { guidFor } from '@ember/object/internals';
|
|
5
5
|
import { element } from 'ember-element-helper';
|
|
6
6
|
import { Collapsible } from '../../utilities/collapsible.js';
|
|
7
|
-
import { a as ChevronDownIcon } from '../../../icons-
|
|
7
|
+
import { a as ChevronDownIcon } from '../../../icons-55dthVFk.js';
|
|
8
8
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
9
9
|
import { setComponentTemplate } from '@ember/component';
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ import { Popover } from '../overlays/popover.js';
|
|
|
12
12
|
import { FormControl } from './form-control.js';
|
|
13
13
|
import { triggerFormInputEvent } from '../../utils/forms-utils-index.js';
|
|
14
14
|
import { CloseButton } from '../buttons/close-button.js';
|
|
15
|
-
import { I as IconChevronUpDown } from '../../icons-
|
|
15
|
+
import { I as IconChevronUpDown } from '../../icons-55dthVFk.js';
|
|
16
16
|
import { keyAndLabelForItem } from '../../utils/listManager.js';
|
|
17
17
|
import { filterAndRankItems, limitItems } from '../../utils/filter.js';
|
|
18
18
|
import { cancel, debounce } from '@ember/runloop';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segment-group.js","sources":["../../../../src/components/forms/date-input/segment-group.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached } from '@glimmer/tracking';\nimport { fn } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport {\n isSegment,\n applyDigit,\n applyLetter,\n commitSegment,\n step,\n clearSegment,\n deleteDigit,\n displaySegment\n} from './segments';\nimport { parsePasted, formatForClipboard, splitRange } from './clipboard';\nimport type {\n Part,\n Segment,\n SegmentType,\n SegmentGroupClasses,\n SegmentGroupUserClasses\n} from './types';\n\ninterface SegmentGroupSignature {\n Args: {\n parts: Part[];\n /** Hands the whole list back; the group holds no state of its own. */\n onPartsChange: (parts: Part[]) => void;\n /**\n * Offered text that reads as two dates rather than one. Only `DatePicker`\n * in `@mode=\"range\"` supplies it, and only to its *start* group: pasting\n * a range into the end of a field and having it rewrite the start would\n * be surprising. Without it, such text is simply declined.\n */\n onRangePaste?: (start: Part[], end: Part[]) => void;\n locale: string;\n placeholderValue: Date;\n isDisabled?: boolean;\n isReadOnly?: boolean;\n isInvalid?: boolean;\n /** Rendered as the group's own id, so a `<label for>` can target it. */\n id?: string;\n /**\n * The field's name. A `role=\"group\"` is not a labelable element, so a\n * sibling `<label for>` does not name it on its own -- this does.\n */\n label?: string;\n labelledBy?: string;\n describedBy?: string;\n segmentLabels?: Partial<Record<SegmentType, string>>;\n /**\n * Only the three slots this group renders, so that `DateInput`'s\n * `dateInput` recipe and `DatePicker`'s `datePicker` recipe both satisfy\n * it. See {@link SegmentGroupClasses}.\n */\n classes: SegmentGroupClasses;\n userClasses?: SegmentGroupUserClasses;\n };\n Element: HTMLDivElement;\n}\n\nconst DEFAULT_LABELS: Record<SegmentType, string> = {\n year: 'year',\n month: 'month',\n day: 'day',\n hour: 'hour',\n minute: 'minute',\n dayPeriod: 'AM/PM'\n};\n\n/** How much PageUp/PageDown moves, per segment. */\nconst PAGE_STEP: Record<SegmentType, number> = {\n day: 7,\n month: 3,\n year: 10,\n hour: 2,\n minute: 15,\n dayPeriod: 1\n};\n\n/**\n * Everything one rendered part needs, resolved to primitives.\n *\n * The template cannot narrow the `Part` union -- `eq` is unavailable and Glint\n * does not carry a type predicate through `{{#if}}` -- so the narrowing happens\n * here, in TypeScript, and the template only ever reads optional primitives.\n * That keeps `part.type` off a `LiteralPart` without a cast anywhere.\n */\ninterface Cell {\n index: number;\n isSegment: boolean;\n /** The segment's display text, or the literal's text. */\n text: string;\n type?: SegmentType;\n isEmpty: boolean;\n label?: string;\n /** `text` for AM/PM, typed by letter; `numeric` for everything else. */\n inputMode: 'numeric' | 'text';\n valueNow?: number;\n valueMin?: number;\n valueMax?: number;\n valueText?: string;\n}\n\n/**\n * One row of date segments. Private: `DateInput` and `DatePicker` both render\n * it, and neither wants the other's `FormControl` wrapper.\n */\nclass SegmentGroup extends Component<SegmentGroupSignature> {\n get isEditable(): boolean {\n return !this.args.isDisabled && !this.args.isReadOnly;\n }\n\n labelFor = (type: SegmentType): string =>\n this.args.segmentLabels?.[type] ?? DEFAULT_LABELS[type];\n\n /**\n * Built once per locale rather than inside {@link valueTextFor}: `cells`\n * recomputes on every keystroke, and an `Intl` constructor is expensive\n * enough that building one per keypress is the costliest thing this\n * component would otherwise do.\n */\n @cached\n get monthNames(): Intl.DateTimeFormat {\n return new Intl.DateTimeFormat(this.args.locale, { month: 'long' });\n }\n\n /**\n * What a screen reader reads instead of the raw number. A month is read by\n * name -- \"January\", not \"1\" -- which is the whole point of `aria-valuetext`.\n */\n valueTextFor = (segment: Segment): string | undefined => {\n if (segment.value === null) return undefined;\n if (segment.labels) return segment.labels[segment.value];\n if (segment.type !== 'month') return String(segment.value);\n\n // Any year and day will do; only the month is read back out.\n return this.monthNames.format(new Date(2026, segment.value - 1, 1));\n };\n\n @cached\n get cells(): Cell[] {\n return this.args.parts.map((part, index) => {\n if (!isSegment(part)) {\n return {\n index,\n isSegment: false,\n isEmpty: false,\n text: part.text,\n inputMode: 'numeric'\n };\n }\n\n return {\n index,\n isSegment: true,\n text: displaySegment(part),\n type: part.type,\n isEmpty: part.value === null,\n label: this.labelFor(part.type),\n inputMode: part.labels ? 'text' : 'numeric',\n // `undefined` rather than `null`: an empty segment has no current\n // value, and `aria-valuenow=\"null\"` would be a value of sorts.\n valueNow: part.value ?? undefined,\n valueMin: part.min,\n valueMax: part.max,\n valueText: this.valueTextFor(part)\n };\n });\n }\n\n /** The segment elements, in document order -- the focus order too. */\n private segmentElements(from: HTMLElement): HTMLElement[] {\n const group = from.closest('[data-part=\"group\"]');\n return group\n ? Array.from(group.querySelectorAll<HTMLElement>('[data-part=\"segment\"]'))\n : [];\n }\n\n /**\n * Left and right are *visual* directions, so in an RTL locale they run\n * against document order: pressing the left arrow in `yyyy/mm/dd` laid out\n * right-to-left should move to the segment drawn to the left, which is the\n * later one in the DOM.\n */\n private focusSibling(from: HTMLElement, delta: number): void {\n const all = this.segmentElements(from);\n const step = this.isRtl(from) ? -delta : delta;\n const next = all[all.indexOf(from) + step];\n next?.focus();\n }\n\n private isRtl(from: HTMLElement): boolean {\n const group = from.closest<HTMLElement>('[data-part=\"group\"]') ?? from;\n return getComputedStyle(group).direction === 'rtl';\n }\n\n private focusEdge(from: HTMLElement, edge: 'first' | 'last'): void {\n const all = this.segmentElements(from);\n (edge === 'first' ? all[0] : all[all.length - 1])?.focus();\n }\n\n /** Replaces one segment by index and reports the new list. */\n private replace(index: number, segment: Segment): void {\n const next = this.args.parts.map((part, i) =>\n i === index ? segment : part\n );\n this.args.onPartsChange(next);\n }\n\n handleKeyDown = (index: number, event: KeyboardEvent): void => {\n const part = this.args.parts[index];\n if (!part || !isSegment(part)) return;\n\n const element = event.target as HTMLElement;\n const { key } = event;\n\n // Navigation works even when the field is read-only; editing does not.\n if (key === 'ArrowRight') {\n event.preventDefault();\n this.focusSibling(element, 1);\n return;\n }\n if (key === 'ArrowLeft') {\n event.preventDefault();\n this.focusSibling(element, -1);\n return;\n }\n if (key === 'Home') {\n event.preventDefault();\n this.focusEdge(element, 'first');\n return;\n }\n if (key === 'End') {\n event.preventDefault();\n this.focusEdge(element, 'last');\n return;\n }\n\n if (!this.isEditable) return;\n\n if (key === 'ArrowUp' || key === 'ArrowDown') {\n event.preventDefault();\n const delta = key === 'ArrowUp' ? 1 : -1;\n this.replace(index, step(part, delta, this.args.placeholderValue));\n return;\n }\n\n if (key === 'PageUp' || key === 'PageDown') {\n event.preventDefault();\n const magnitude = PAGE_STEP[part.type];\n const delta = key === 'PageUp' ? magnitude : -magnitude;\n this.replace(index, step(part, delta, this.args.placeholderValue));\n return;\n }\n\n if (key === 'Backspace') {\n event.preventDefault();\n this.replace(index, deleteDigit(part));\n return;\n }\n\n if (key === 'Delete') {\n event.preventDefault();\n this.replace(index, clearSegment(part));\n return;\n }\n\n if (/^\\d$/.test(key)) {\n event.preventDefault();\n // AM/PM has no digits to take.\n if (part.labels) return;\n const { segment, isFull } = applyDigit(part, key);\n this.replace(index, segment);\n // Advancing before the DOM has caught up is safe: the segment elements\n // are keyed by index and are updated, never re-created.\n if (isFull) this.focusSibling(element, 1);\n return;\n }\n\n if (part.labels && key.length === 1 && !event.metaKey && !event.ctrlKey) {\n event.preventDefault();\n const { segment, isFull } = applyLetter(part, key);\n if (segment !== part) this.replace(index, segment);\n if (isFull) this.focusSibling(element, 1);\n return;\n }\n\n // Everything else -- letters, symbols -- would otherwise be inserted into\n // the contenteditable span as literal text.\n if (key.length === 1 && !event.metaKey && !event.ctrlKey) {\n event.preventDefault();\n }\n };\n\n /**\n * Leaving a segment finishes it: the digits in it stop being something the\n * user is still typing and become their answer, which is what turns a typed\n * `26` into 2026. Tab, arrow-key navigation and a click elsewhere all arrive\n * here, because moving focus is the one thing they have in common.\n */\n handleFocusOut = (index: number): void => {\n if (!this.isEditable) return;\n\n const part = this.args.parts[index];\n if (!part || !isSegment(part) || part.isCommitted) return;\n\n const committed = commitSegment(part);\n // An empty segment commits to itself; reporting it would be churn.\n if (committed !== part) this.replace(index, committed);\n };\n\n /**\n * `contenteditable`'s hazard: anything not handled above arrives here and\n * would be written into the span's DOM, desynchronising the display from the\n * model. Every input type is refused; the model is the only writer.\n */\n handleBeforeInput = (event: Event): void => {\n event.preventDefault();\n };\n\n /**\n * Always `preventDefault`: the browser would otherwise write the pasted text\n * into the contenteditable span, and the model would no longer describe what\n * is on screen. Unparseable text is dropped silently -- a date field that\n * guessed would be worse than one that declined.\n */\n handlePaste = (event: ClipboardEvent): void => {\n event.preventDefault();\n if (!this.isEditable) return;\n\n const text = event.clipboardData?.getData('text/plain') ?? '';\n const parsed = parsePasted(text, this.args.parts);\n if (parsed) {\n this.args.onPartsChange(parsed);\n return;\n }\n\n this.tryRangePaste(text);\n };\n\n /**\n * A second reading of text a single date could not be made of.\n *\n * Both halves are parsed against *this* group's parts, which is sound\n * because the two groups of a range are built from the same locale and\n * format and so have identical shape, and because a half only counts when\n * it parses in full -- nothing of this group's own state survives into the\n * list handed to the other one.\n */\n private tryRangePaste(text: string): void {\n const onRangePaste = this.args.onRangePaste;\n if (!onRangePaste) return;\n\n const halves = splitRange(text);\n if (!halves) return;\n\n const start = parsePasted(halves[0], this.args.parts);\n const end = parsePasted(halves[1], this.args.parts);\n if (start && end) onRangePaste(start, end);\n }\n\n handleCopy = (event: ClipboardEvent): void => {\n event.preventDefault();\n event.clipboardData?.setData(\n 'text/plain',\n formatForClipboard(this.args.parts)\n );\n };\n\n handleCut = (event: ClipboardEvent): void => {\n this.handleCopy(event);\n if (!this.isEditable) return;\n\n this.args.onPartsChange(\n this.args.parts.map((p) => (isSegment(p) ? clearSegment(p) : p))\n );\n };\n\n <template>\n <div\n role=\"group\"\n data-part=\"group\"\n id={{@id}}\n aria-label={{@label}}\n aria-labelledby={{@labelledBy}}\n aria-describedby={{@describedBy}}\n aria-disabled={{if @isDisabled \"true\"}}\n {{! `role=\"group\"` supports neither aria-readonly nor aria-invalid --\n neither is global in ARIA 1.2, and ember-template-lint's\n no-unsupported-role-attributes is right to reject them here (its\n autofixer deletes them silently, which is how they went missing\n once already). Both live on the spinbuttons below instead, where\n the role does support them and where assistive technology actually\n lands. These data attributes carry the same state for styling and\n for tests. }}\n data-readonly={{if @isReadOnly \"true\" \"false\"}}\n data-invalid={{if @isInvalid \"true\" \"false\"}}\n class={{@classes.group class=@userClasses.group}}\n {{on \"paste\" this.handlePaste}}\n {{on \"copy\" this.handleCopy}}\n {{on \"cut\" this.handleCut}}\n ...attributes\n >\n {{#each this.cells key=\"index\" as |cell|}}\n {{#if cell.isSegment}}\n <span\n role=\"spinbutton\"\n tabindex={{unless @isDisabled \"0\"}}\n contenteditable={{if this.isEditable \"true\" \"false\"}}\n inputmode={{cell.inputMode}}\n spellcheck=\"false\"\n autocorrect=\"off\"\n data-part=\"segment\"\n data-type={{cell.type}}\n data-placeholder={{if cell.isEmpty \"true\" \"false\"}}\n data-disabled={{if @isDisabled \"true\" \"false\"}}\n aria-readonly={{if @isReadOnly \"true\"}}\n aria-invalid={{if @isInvalid \"true\"}}\n aria-label={{cell.label}}\n aria-valuenow={{cell.valueNow}}\n aria-valuemin={{cell.valueMin}}\n aria-valuemax={{cell.valueMax}}\n aria-valuetext={{cell.valueText}}\n class={{@classes.segment class=@userClasses.segment}}\n {{on \"keydown\" (fn this.handleKeyDown cell.index)}}\n {{on \"focusout\" (fn this.handleFocusOut cell.index)}}\n {{on \"beforeinput\" this.handleBeforeInput}}\n >{{cell.text}}</span>\n {{else}}\n <span\n data-part=\"literal\"\n aria-hidden=\"true\"\n class={{@classes.literal class=@userClasses.literal}}\n >{{cell.text}}</span>\n {{/if}}\n {{/each}}\n </div>\n </template>\n}\n\nexport { SegmentGroup, type SegmentGroupSignature };\nexport default SegmentGroup;\n"],"names":["DEFAULT_LABELS","year","month","day","hour","minute","dayPeriod","PAGE_STEP","SegmentGroup","Component","isEditable","args","isDisabled","isReadOnly","labelFor","type","segmentLabels","monthNames","Intl","DateTimeFormat","locale","n","prototype","cached","valueTextFor","segment","value","undefined","labels","String","format","Date","cells","parts","map","part","index","isSegment","isEmpty","text","inputMode","displaySegment","label","valueNow","valueMin","min","valueMax","max","valueText","segmentElements","from","group","closest","Array","querySelectorAll","focusSibling","delta","all","step","isRtl","next","indexOf","focus","getComputedStyle","direction","focusEdge","edge","length","replace","i","onPartsChange","handleKeyDown","event","element","target","key","preventDefault","placeholderValue","magnitude","deleteDigit","clearSegment","test","isFull","applyDigit","metaKey","ctrlKey","applyLetter","handleFocusOut","isCommitted","committed","commitSegment","handleBeforeInput","handlePaste","clipboardData","getData","parsed","parsePasted","tryRangePaste","onRangePaste","halves","splitRange","start","end","handleCopy","setData","formatForClipboard","handleCut","p","setComponentTemplate","precompileTemplate","strictMode","scope","on","fn"],"mappings":";;;;;;;;;;AA6DA,MAAMA,cAA0C,GAAI;AAClDC,EAAAA,IAAA,EAAM,MAAA;AACNC,EAAAA,KAAA,EAAO,OAAA;AACPC,EAAAA,GAAA,EAAK,KAAA;AACLC,EAAAA,IAAA,EAAM,MAAA;AACNC,EAAAA,MAAA,EAAQ,QAAA;AACRC,EAAAA,SAAA,EAAW;AACb,CAAA;AAEA;AACA,MAAMC,SAAqC,GAAI;AAC7CJ,EAAAA,GAAA,EAAK,CAAA;AACLD,EAAAA,KAAA,EAAO,CAAA;AACPD,EAAAA,IAAA,EAAM,EAAA;AACNG,EAAAA,IAAA,EAAM,CAAA;AACNC,EAAAA,MAAA,EAAQ,EAAA;AACRC,EAAAA,SAAA,EAAW;AACb,CAAA;AAEA;;;;;;;;;AAwBA;;;;AAIA,MAAME,qBAAqBC,SAAA,CAAU;EACnC,IAAIC,UAAAA,GAAsB;AACxB,IAAA,OAAO,CAAC,IAAI,CAACC,IAAI,CAACC,UAAU,IAAI,CAAC,IAAI,CAACD,IAAI,CAACE,UAAU;AACvD,EAAA;AAEAC,EAAAA,QAAA,GAAYC,IAAM,IAChB,IAAI,CAACJ,IAAI,CAACK,aAAa,GAAGD,IAAA,CAAK,IAAIf,cAAc,CAACe,KAAK;AAEzD;;;;;AAKC;EACD,IACIE,UAAAA,GAAkC;IACpC,OAAO,IAAIC,KAAKC,cAAc,CAAC,IAAI,CAACR,IAAI,CAACS,MAAM,EAAE;AAAElB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AM,CAAC,CAAA,CAAE,EAAE,IAAI,CAACxF,IAAI,CAACsB,KAAK,CAAA;AACpD,IAAA,MAAMqE,GAAA,GAAMN,WAAA,CAAYG,MAAM,CAAC,CAAA,CAAE,EAAE,IAAI,CAACxF,IAAI,CAACsB,KAAK,CAAA;IAClD,IAAIoE,KAAA,IAASC,GAAA,EAAKJ,YAAA,CAAaG,KAAA,EAAOC,GAAA,CAAA;AACxC,EAAA;EAEAC,UAAA,GAAc/B,KAAO,IAAqB;IACxCA,KAAA,CAAMI,cAAc,EAAA;AACpBJ,IAAAA,KAAA,CAAMqB,aAAa,EAAEW,OAAA,CACnB,YAAA,EACAC,mBAAmB,IAAI,CAAC9F,IAAI,CAACsB,KAAK,CAAA,CAAA;EAEtC,CAAA;EAEAyE,SAAA,GAAalC,KAAO,IAAqB;AACvC,IAAA,IAAI,CAAC+B,UAAU,CAAC/B,KAAA,CAAA;AAChB,IAAA,IAAI,CAAC,IAAI,CAAC9D,UAAU,EAAE;IAEtB,IAAI,CAACC,IAAI,CAAC2D,aAAa,CACrB,IAAI,CAAC3D,IAAI,CAACsB,KAAK,CAACC,GAAG,CAAEyE,CAAA,IAAOtE,UAAUsE,CAAA,CAAA,GAAK3B,YAAA,CAAa2B,KAAKA,CAAC,CAAA,CAAA;EAElE,CAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,6/DAAA,EA2DA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,EAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
1
|
+
{"version":3,"file":"segment-group.js","sources":["../../../../src/components/forms/date-input/segment-group.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached } from '@glimmer/tracking';\nimport { fn } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport {\n isSegment,\n applyDigit,\n applyLetter,\n commitSegment,\n step,\n clearSegment,\n deleteDigit,\n displaySegment\n} from './segments';\nimport { parsePasted, formatForClipboard, splitRange } from './clipboard';\nimport type {\n Part,\n Segment,\n SegmentType,\n SegmentGroupClasses,\n SegmentGroupUserClasses\n} from './types';\n\ninterface SegmentGroupSignature {\n Args: {\n parts: Part[];\n /** Hands the whole list back; the group holds no state of its own. */\n onPartsChange: (parts: Part[]) => void;\n /**\n * Offered text that reads as two dates rather than one. Only `DatePicker`\n * in `@mode=\"range\"` supplies it, and only to its *start* group: pasting\n * a range into the end of a field and having it rewrite the start would\n * be surprising. Without it, such text is simply declined.\n */\n onRangePaste?: (start: Part[], end: Part[]) => void;\n locale: string;\n placeholderValue: Date;\n isDisabled?: boolean;\n isReadOnly?: boolean;\n isInvalid?: boolean;\n /** Rendered as the group's own id, so a `<label for>` can target it. */\n id?: string;\n /**\n * The field's name. A `role=\"group\"` is not a labelable element, so a\n * sibling `<label for>` does not name it on its own -- this does.\n */\n label?: string;\n labelledBy?: string;\n describedBy?: string;\n segmentLabels?: Partial<Record<SegmentType, string>>;\n /**\n * Only the three slots this group renders, so that `DateInput`'s\n * `dateInput` recipe and `DatePicker`'s `datePicker` recipe both satisfy\n * it. See {@link SegmentGroupClasses}.\n */\n classes: SegmentGroupClasses;\n userClasses?: SegmentGroupUserClasses;\n };\n Element: HTMLDivElement;\n}\n\nconst DEFAULT_LABELS: Record<SegmentType, string> = {\n year: 'year',\n month: 'month',\n day: 'day',\n hour: 'hour',\n minute: 'minute',\n dayPeriod: 'AM/PM'\n};\n\n/** How much PageUp/PageDown moves, per segment. */\nconst PAGE_STEP: Record<SegmentType, number> = {\n day: 7,\n month: 3,\n year: 10,\n hour: 2,\n minute: 15,\n dayPeriod: 1\n};\n\n/**\n * Everything one rendered part needs, resolved to primitives.\n *\n * The template cannot narrow the `Part` union -- `eq` is unavailable and Glint\n * does not carry a type predicate through `{{#if}}` -- so the narrowing happens\n * here, in TypeScript, and the template only ever reads optional primitives.\n * That keeps `part.type` off a `LiteralPart` without a cast anywhere.\n */\ninterface Cell {\n index: number;\n isSegment: boolean;\n /** The segment's display text, or the literal's text. */\n text: string;\n type?: SegmentType;\n isEmpty: boolean;\n label?: string;\n /** `text` for AM/PM, typed by letter; `numeric` for everything else. */\n inputMode: 'numeric' | 'text';\n valueNow?: number;\n valueMin?: number;\n valueMax?: number;\n valueText?: string;\n}\n\n/**\n * One row of date segments. Private: `DateInput` and `DatePicker` both render\n * it, and neither wants the other's `FormControl` wrapper.\n */\nclass SegmentGroup extends Component<SegmentGroupSignature> {\n get isEditable(): boolean {\n return !this.args.isDisabled && !this.args.isReadOnly;\n }\n\n labelFor = (type: SegmentType): string =>\n this.args.segmentLabels?.[type] ?? DEFAULT_LABELS[type];\n\n /**\n * Built once per locale rather than inside {@link valueTextFor}: `cells`\n * recomputes on every keystroke, and an `Intl` constructor is expensive\n * enough that building one per keypress is the costliest thing this\n * component would otherwise do.\n */\n @cached\n get monthNames(): Intl.DateTimeFormat {\n return new Intl.DateTimeFormat(this.args.locale, { month: 'long' });\n }\n\n /**\n * What a screen reader reads instead of the raw number. A month is read by\n * name -- \"January\", not \"1\" -- which is the whole point of `aria-valuetext`.\n */\n valueTextFor = (segment: Segment): string | undefined => {\n if (segment.value === null) return undefined;\n if (segment.labels) return segment.labels[segment.value];\n if (segment.type !== 'month') return String(segment.value);\n\n // Any year and day will do; only the month is read back out.\n return this.monthNames.format(new Date(2026, segment.value - 1, 1));\n };\n\n @cached\n get cells(): Cell[] {\n return this.args.parts.map((part, index) => {\n if (!isSegment(part)) {\n return {\n index,\n isSegment: false,\n isEmpty: false,\n text: part.text,\n inputMode: 'numeric'\n };\n }\n\n return {\n index,\n isSegment: true,\n text: displaySegment(part),\n type: part.type,\n isEmpty: part.value === null,\n label: this.labelFor(part.type),\n inputMode: part.labels ? 'text' : 'numeric',\n // `undefined` rather than `null`: an empty segment has no current\n // value, and `aria-valuenow=\"null\"` would be a value of sorts.\n valueNow: part.value ?? undefined,\n valueMin: part.min,\n valueMax: part.max,\n valueText: this.valueTextFor(part)\n };\n });\n }\n\n /** The segment elements, in document order -- the focus order too. */\n private segmentElements(from: HTMLElement): HTMLElement[] {\n const group = from.closest('[data-part=\"group\"]');\n return group\n ? Array.from(group.querySelectorAll<HTMLElement>('[data-part=\"segment\"]'))\n : [];\n }\n\n /**\n * Left and right are *visual* directions, so in an RTL locale they run\n * against document order: pressing the left arrow in `yyyy/mm/dd` laid out\n * right-to-left should move to the segment drawn to the left, which is the\n * later one in the DOM.\n */\n private focusSibling(from: HTMLElement, delta: number): void {\n const all = this.segmentElements(from);\n const step = this.isRtl(from) ? -delta : delta;\n const next = all[all.indexOf(from) + step];\n next?.focus();\n }\n\n private isRtl(from: HTMLElement): boolean {\n const group = from.closest<HTMLElement>('[data-part=\"group\"]') ?? from;\n return getComputedStyle(group).direction === 'rtl';\n }\n\n private focusEdge(from: HTMLElement, edge: 'first' | 'last'): void {\n const all = this.segmentElements(from);\n (edge === 'first' ? all[0] : all[all.length - 1])?.focus();\n }\n\n /** Replaces one segment by index and reports the new list. */\n private replace(index: number, segment: Segment): void {\n const next = this.args.parts.map((part, i) =>\n i === index ? segment : part\n );\n this.args.onPartsChange(next);\n }\n\n handleKeyDown = (index: number, event: KeyboardEvent): void => {\n const part = this.args.parts[index];\n if (!part || !isSegment(part)) return;\n\n const element = event.target as HTMLElement;\n const { key } = event;\n\n // Navigation works even when the field is read-only; editing does not.\n if (key === 'ArrowRight') {\n event.preventDefault();\n this.focusSibling(element, 1);\n return;\n }\n if (key === 'ArrowLeft') {\n event.preventDefault();\n this.focusSibling(element, -1);\n return;\n }\n if (key === 'Home') {\n event.preventDefault();\n this.focusEdge(element, 'first');\n return;\n }\n if (key === 'End') {\n event.preventDefault();\n this.focusEdge(element, 'last');\n return;\n }\n\n if (!this.isEditable) return;\n\n if (key === 'ArrowUp' || key === 'ArrowDown') {\n event.preventDefault();\n const delta = key === 'ArrowUp' ? 1 : -1;\n this.replace(index, step(part, delta, this.args.placeholderValue));\n return;\n }\n\n if (key === 'PageUp' || key === 'PageDown') {\n event.preventDefault();\n const magnitude = PAGE_STEP[part.type];\n const delta = key === 'PageUp' ? magnitude : -magnitude;\n this.replace(index, step(part, delta, this.args.placeholderValue));\n return;\n }\n\n if (key === 'Backspace') {\n event.preventDefault();\n this.replace(index, deleteDigit(part));\n return;\n }\n\n if (key === 'Delete') {\n event.preventDefault();\n this.replace(index, clearSegment(part));\n return;\n }\n\n if (/^\\d$/.test(key)) {\n event.preventDefault();\n // AM/PM has no digits to take.\n if (part.labels) return;\n const { segment, isFull } = applyDigit(part, key);\n this.replace(index, segment);\n // Advancing before the DOM has caught up is safe: the segment elements\n // are keyed by index and are updated, never re-created.\n if (isFull) this.focusSibling(element, 1);\n return;\n }\n\n if (part.labels && key.length === 1 && !event.metaKey && !event.ctrlKey) {\n event.preventDefault();\n const { segment, isFull } = applyLetter(part, key);\n if (segment !== part) this.replace(index, segment);\n if (isFull) this.focusSibling(element, 1);\n return;\n }\n\n // Everything else -- letters, symbols -- would otherwise be inserted into\n // the contenteditable span as literal text.\n if (key.length === 1 && !event.metaKey && !event.ctrlKey) {\n event.preventDefault();\n }\n };\n\n /**\n * Leaving a segment finishes it: the digits in it stop being something the\n * user is still typing and become their answer, which is what turns a typed\n * `26` into 2026. Tab, arrow-key navigation and a click elsewhere all arrive\n * here, because moving focus is the one thing they have in common.\n */\n handleFocusOut = (index: number): void => {\n if (!this.isEditable) return;\n\n const part = this.args.parts[index];\n if (!part || !isSegment(part) || part.isCommitted) return;\n\n const committed = commitSegment(part);\n // An empty segment commits to itself; reporting it would be churn.\n if (committed !== part) this.replace(index, committed);\n };\n\n /**\n * `contenteditable`'s hazard: anything not handled above arrives here and\n * would be written into the span's DOM, desynchronising the display from the\n * model. Every input type is refused; the model is the only writer.\n */\n handleBeforeInput = (event: Event): void => {\n event.preventDefault();\n };\n\n /**\n * Always `preventDefault`: the browser would otherwise write the pasted text\n * into the contenteditable span, and the model would no longer describe what\n * is on screen. Unparseable text is dropped silently -- a date field that\n * guessed would be worse than one that declined.\n */\n handlePaste = (event: ClipboardEvent): void => {\n event.preventDefault();\n if (!this.isEditable) return;\n\n const text = event.clipboardData?.getData('text/plain') ?? '';\n const parsed = parsePasted(text, this.args.parts);\n if (parsed) {\n this.args.onPartsChange(parsed);\n return;\n }\n\n this.tryRangePaste(text);\n };\n\n /**\n * A second reading of text a single date could not be made of.\n *\n * Both halves are parsed against *this* group's parts, which is sound\n * because the two groups of a range are built from the same locale and\n * format and so have identical shape, and because a half only counts when\n * it parses in full -- nothing of this group's own state survives into the\n * list handed to the other one.\n */\n private tryRangePaste(text: string): void {\n const onRangePaste = this.args.onRangePaste;\n if (!onRangePaste) return;\n\n const halves = splitRange(text);\n if (!halves) return;\n\n const start = parsePasted(halves[0], this.args.parts);\n const end = parsePasted(halves[1], this.args.parts);\n if (start && end) onRangePaste(start, end);\n }\n\n handleCopy = (event: ClipboardEvent): void => {\n event.preventDefault();\n event.clipboardData?.setData(\n 'text/plain',\n formatForClipboard(this.args.parts)\n );\n };\n\n handleCut = (event: ClipboardEvent): void => {\n this.handleCopy(event);\n if (!this.isEditable) return;\n\n this.args.onPartsChange(\n this.args.parts.map((p) => (isSegment(p) ? clearSegment(p) : p))\n );\n };\n\n <template>\n <div\n role=\"group\"\n data-part=\"group\"\n id={{@id}}\n aria-label={{@label}}\n aria-labelledby={{@labelledBy}}\n aria-describedby={{@describedBy}}\n aria-disabled={{if @isDisabled \"true\"}}\n {{! `role=\"group\"` supports neither aria-readonly nor aria-invalid --\n neither is global in ARIA 1.2, and ember-template-lint's\n no-unsupported-role-attributes is right to reject them here (its\n autofixer deletes them silently, which is how they went missing\n once already). Both live on the spinbuttons below instead, where\n the role does support them and where assistive technology actually\n lands. These data attributes carry the same state for styling and\n for tests. }}\n data-readonly={{if @isReadOnly \"true\" \"false\"}}\n data-invalid={{if @isInvalid \"true\" \"false\"}}\n class={{@classes.group class=@userClasses.group}}\n {{on \"paste\" this.handlePaste}}\n {{on \"copy\" this.handleCopy}}\n {{on \"cut\" this.handleCut}}\n ...attributes\n >\n {{#each this.cells key=\"index\" as |cell|}}\n {{#if cell.isSegment}}\n <span\n role=\"spinbutton\"\n tabindex={{unless @isDisabled \"0\"}}\n contenteditable={{if this.isEditable \"true\" \"false\"}}\n inputmode={{cell.inputMode}}\n spellcheck=\"false\"\n autocorrect=\"off\"\n data-part=\"segment\"\n data-type={{cell.type}}\n data-placeholder={{if cell.isEmpty \"true\" \"false\"}}\n data-disabled={{if @isDisabled \"true\" \"false\"}}\n aria-readonly={{if @isReadOnly \"true\"}}\n aria-invalid={{if @isInvalid \"true\"}}\n aria-label={{cell.label}}\n aria-valuenow={{cell.valueNow}}\n aria-valuemin={{cell.valueMin}}\n aria-valuemax={{cell.valueMax}}\n aria-valuetext={{cell.valueText}}\n class={{@classes.segment class=@userClasses.segment}}\n {{on \"keydown\" (fn this.handleKeyDown cell.index)}}\n {{on \"focusout\" (fn this.handleFocusOut cell.index)}}\n {{on \"beforeinput\" this.handleBeforeInput}}\n >{{cell.text}}</span>\n {{else}}\n <span\n data-part=\"literal\"\n aria-hidden=\"true\"\n class={{@classes.literal class=@userClasses.literal}}\n >{{cell.text}}</span>\n {{/if}}\n {{/each}}\n </div>\n </template>\n}\n\nexport {\n SegmentGroup,\n DEFAULT_LABELS as DEFAULT_SEGMENT_LABELS,\n type SegmentGroupSignature\n};\nexport default SegmentGroup;\n"],"names":["DEFAULT_LABELS","year","month","day","hour","minute","dayPeriod","PAGE_STEP","SegmentGroup","Component","isEditable","args","isDisabled","isReadOnly","labelFor","type","segmentLabels","monthNames","Intl","DateTimeFormat","locale","n","prototype","cached","valueTextFor","segment","value","undefined","labels","String","format","Date","cells","parts","map","part","index","isSegment","isEmpty","text","inputMode","displaySegment","label","valueNow","valueMin","min","valueMax","max","valueText","segmentElements","from","group","closest","Array","querySelectorAll","focusSibling","delta","all","step","isRtl","next","indexOf","focus","getComputedStyle","direction","focusEdge","edge","length","replace","i","onPartsChange","handleKeyDown","event","element","target","key","preventDefault","placeholderValue","magnitude","deleteDigit","clearSegment","test","isFull","applyDigit","metaKey","ctrlKey","applyLetter","handleFocusOut","isCommitted","committed","commitSegment","handleBeforeInput","handlePaste","clipboardData","getData","parsed","parsePasted","tryRangePaste","onRangePaste","halves","splitRange","start","end","handleCopy","setData","formatForClipboard","handleCut","p","setComponentTemplate","precompileTemplate","strictMode","scope","on","fn"],"mappings":";;;;;;;;;;AA6DA,MAAMA,cAA0C,GAAI;AAClDC,EAAAA,IAAA,EAAM,MAAA;AACNC,EAAAA,KAAA,EAAO,OAAA;AACPC,EAAAA,GAAA,EAAK,KAAA;AACLC,EAAAA,IAAA,EAAM,MAAA;AACNC,EAAAA,MAAA,EAAQ,QAAA;AACRC,EAAAA,SAAA,EAAW;AACb;AAEA;AACA,MAAMC,SAAqC,GAAI;AAC7CJ,EAAAA,GAAA,EAAK,CAAA;AACLD,EAAAA,KAAA,EAAO,CAAA;AACPD,EAAAA,IAAA,EAAM,EAAA;AACNG,EAAAA,IAAA,EAAM,CAAA;AACNC,EAAAA,MAAA,EAAQ,EAAA;AACRC,EAAAA,SAAA,EAAW;AACb,CAAA;AAEA;;;;;;;;;AAwBA;;;;AAIA,MAAME,qBAAqBC,SAAA,CAAU;EACnC,IAAIC,UAAAA,GAAsB;AACxB,IAAA,OAAO,CAAC,IAAI,CAACC,IAAI,CAACC,UAAU,IAAI,CAAC,IAAI,CAACD,IAAI,CAACE,UAAU;AACvD,EAAA;AAEAC,EAAAA,QAAA,GAAYC,IAAM,IAChB,IAAI,CAACJ,IAAI,CAACK,aAAa,GAAGD,IAAA,CAAK,IAAIf,cAAc,CAACe,KAAK;AAEzD;;;;;AAKC;EACD,IACIE,UAAAA,GAAkC;IACpC,OAAO,IAAIC,KAAKC,cAAc,CAAC,IAAI,CAACR,IAAI,CAACS,MAAM,EAAE;AAAElB,MAAAA,KAAA,EAAO;AAAO,KAAA,CAAA;AACnE,EAAA;AAEA;;;AAGC;AAHD,EAAA;IAAAmB,gB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AAA,GAAMN,WAAA,CAAYG,MAAM,CAAC,CAAA,CAAE,EAAE,IAAI,CAACxF,IAAI,CAACsB,KAAK,CAAA;IAClD,IAAIoE,KAAA,IAASC,GAAA,EAAKJ,YAAA,CAAaG,KAAA,EAAOC,GAAA,CAAA;AACxC,EAAA;EAEAC,UAAA,GAAc/B,KAAO,IAAqB;IACxCA,KAAA,CAAMI,cAAc,EAAA;AACpBJ,IAAAA,KAAA,CAAMqB,aAAa,EAAEW,OAAA,CACnB,YAAA,EACAC,mBAAmB,IAAI,CAAC9F,IAAI,CAACsB,KAAK,CAAA,CAAA;EAEtC,CAAA;EAEAyE,SAAA,GAAalC,KAAO,IAAqB;AACvC,IAAA,IAAI,CAAC+B,UAAU,CAAC/B,KAAA,CAAA;AAChB,IAAA,IAAI,CAAC,IAAI,CAAC9D,UAAU,EAAE;IAEtB,IAAI,CAACC,IAAI,CAAC2D,aAAa,CACrB,IAAI,CAAC3D,IAAI,CAACsB,KAAK,CAACC,GAAG,CAAEyE,CAAA,IAAOtE,UAAUsE,CAAA,CAAA,GAAK3B,YAAA,CAAa2B,KAAKA,CAAC,CAAA,CAAA;EAElE,CAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,6/DAAA,EA2DA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,EAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -558,5 +558,5 @@ function fromDate(parts, date) {
|
|
|
558
558
|
});
|
|
559
559
|
}
|
|
560
560
|
|
|
561
|
-
export { BOUNDS, DEFAULT_FORMAT, applyDigit, applyLetter, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, hourOfDay, hourOnCycle, isSegment, resolveSegmentFormat, resolveTwoDigitYear, step, timeOf, toDate, toNumericFormat, withTime, withValue };
|
|
561
|
+
export { BOUNDS, DEFAULT_FORMAT, applyDigit, applyLetter, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, hourOfDay, hourOnCycle, isSegment, resolveSegmentFormat, resolveTwoDigitYear, seedFrom, step, timeOf, toDate, toNumericFormat, withTime, withValue };
|
|
562
562
|
//# sourceMappingURL=segments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segments.js","sources":["../../../../src/components/forms/date-input/segments.ts"],"sourcesContent":["import { warn } from '@ember/debug';\nimport type {\n HourCycle,\n Part,\n Segment,\n SegmentType,\n TimeOptions\n} from './types';\n\n/**\n * The format an editable field uses when the consumer supplies none.\n * Deliberately not `{ dateStyle: 'medium' }` -- DatePicker's button default --\n * which renders a month name and has no numeric segment to type into.\n */\nconst DEFAULT_FORMAT: Intl.DateTimeFormatOptions = {\n year: 'numeric',\n month: '2-digit',\n day: '2-digit'\n};\n\nconst BOUNDS: Record<\n SegmentType,\n { min: number; max: number; width: number; placeholder: string }\n> = {\n // Upper bound for the day is the widest any month gets; `toDate` clamps to\n // the real length of the chosen month, which is not known segment-locally.\n day: { min: 1, max: 31, width: 2, placeholder: 'dd' },\n month: { min: 1, max: 12, width: 2, placeholder: 'mm' },\n year: { min: 1, max: 9999, width: 4, placeholder: 'yyyy' },\n // A 24-hour clock's bounds; `hourBounds` gives the other cycles'.\n hour: { min: 0, max: 23, width: 2, placeholder: 'hh' },\n minute: { min: 0, max: 59, width: 2, placeholder: 'mm' },\n // AM is 0 and PM is 1. Its placeholder is the locale's AM, set by\n // `buildParts`, which is the only place the locale is known.\n dayPeriod: { min: 0, max: 1, width: 2, placeholder: 'AM' }\n};\n\nconst HOUR_BOUNDS: Record<HourCycle, { min: number; max: number }> = {\n h11: { min: 0, max: 11 },\n h12: { min: 1, max: 12 },\n h23: { min: 0, max: 23 },\n h24: { min: 1, max: 24 }\n};\n\n/** Whether a cycle counts the hours twice a day, and so needs AM/PM. */\nfunction isTwelveHour(cycle: HourCycle): boolean {\n return cycle === 'h11' || cycle === 'h12';\n}\n\nfunction isSegment(part: Part): part is Segment {\n return part.kind === 'segment';\n}\n\nfunction emptySegment(\n type: SegmentType,\n overrides: Partial<Segment> = {}\n): Segment {\n const { min, max, width, placeholder } = BOUNDS[type];\n return {\n kind: 'segment',\n type,\n value: null,\n min,\n max,\n width,\n placeholder,\n buffer: '',\n isCommitted: false,\n ...overrides\n };\n}\n\n/**\n * The format the segments are built from: the date format, plus the time\n * fields a granularity asks for. Seconds are out of scope.\n */\nfunction withTime(\n format: Intl.DateTimeFormatOptions,\n { granularity = 'day', hourCycle }: TimeOptions\n): Intl.DateTimeFormatOptions {\n if (granularity === 'day') return format;\n\n return {\n ...format,\n hour: '2-digit',\n ...(granularity === 'minute' ? { minute: '2-digit' } : {}),\n ...(hourCycle ? { hourCycle: hourCycle === 12 ? 'h12' : 'h23' } : {})\n };\n}\n\n/** The locale's names for AM and PM, in that order. */\nfunction dayPeriodLabels(locale: string): string[] {\n const formatter = new Intl.DateTimeFormat(locale, {\n hour: 'numeric',\n hourCycle: 'h12'\n });\n return [1, 13].map(\n (hour) =>\n formatter\n .formatToParts(new Date(2026, 0, 20, hour))\n .find((p) => p.type === 'dayPeriod')?.value ?? (hour < 12 ? 'AM' : 'PM')\n );\n}\n\n/**\n * Derives the segments and their separators from the locale, so `mm/dd/yyyy`,\n * `dd/mm/yyyy` and `yyyy年mm月dd日` all fall out of `Intl` rather than being\n * hardcoded.\n *\n * A format producing a textual month ('Jan') has no editable numeric\n * representation, so that part becomes a numeric month segment anyway. The\n * component warns; this function stays pure.\n */\nfunction buildParts(\n locale: string,\n formatOptions: Intl.DateTimeFormatOptions = DEFAULT_FORMAT,\n time: TimeOptions = {}\n): Part[] {\n const formatter = new Intl.DateTimeFormat(\n locale,\n withTime(formatOptions, time)\n );\n // A reference date, only ever used to make the formatter emit its parts.\n const parts = formatter.formatToParts(new Date(2026, 0, 20));\n // `Intl` settles the cycle -- the locale's, or the one asked for -- and the\n // hour's bounds, and whether there is an AM/PM at all, follow from it.\n const hourCycle = formatter.resolvedOptions().hourCycle ?? 'h23';\n\n const out: Part[] = [];\n for (const part of parts) {\n if (part.type === 'year' || part.type === 'month' || part.type === 'day') {\n out.push(emptySegment(part.type));\n } else if (part.type === 'hour') {\n out.push(emptySegment('hour', { ...HOUR_BOUNDS[hourCycle], hourCycle }));\n } else if (part.type === 'minute') {\n out.push(emptySegment('minute'));\n } else if (part.type === 'dayPeriod') {\n const labels = dayPeriodLabels(locale);\n out.push(emptySegment('dayPeriod', { labels, placeholder: labels[0] }));\n } else if (part.type === 'literal') {\n out.push({ kind: 'literal', text: part.value });\n }\n // Everything else -- era, weekday, relatedYear -- is dropped: there is no\n // segment for it.\n }\n\n return withoutDateTimeComma(out);\n}\n\nconst DATE_TYPES: SegmentType[] = ['year', 'month', 'day'];\n\n/**\n * `Intl` joins the date and the time with a comma in many locales\n * (`01/20/2026, 09:05 PM`), which reads like a sentence rather than a field.\n * The separator between the last date segment and the first time one keeps\n * whatever else the locale put there, minus the comma.\n */\nfunction withoutDateTimeComma(parts: Part[]): Part[] {\n return parts.map((part, i) => {\n if (part.kind !== 'literal') return part;\n const before = parts[i - 1];\n const after = parts[i + 1];\n const joinsDateAndTime =\n before?.kind === 'segment' &&\n DATE_TYPES.includes(before.type) &&\n after?.kind === 'segment' &&\n !DATE_TYPES.includes(after.type);\n if (!joinsDateAndTime) return part;\n const text = part.text.replace(/[,،,]/g, '').replace(/\\s+/g, ' ');\n return { kind: 'literal', text: text.trim() === '' ? ' ' : text };\n });\n}\n\n/**\n * A bare `yy` resolves into the hundred years running from 80 back to 19\n * forward -- so a birth date reaches the past while a card expiry reaches the\n * near future. Three or four digits are a year the user spelled out and are\n * taken literally.\n */\nfunction resolveTwoDigitYear(digits: string, now: Date = new Date()): number {\n const n = Number(digits);\n if (digits.length > 2) return n;\n\n const currentYear = now.getFullYear();\n const start = currentYear - 80;\n const century = Math.floor(start / 100) * 100;\n const candidate = century + n;\n return candidate < start ? candidate + 100 : candidate;\n}\n\n/**\n * The numeric value a buffer represents, or null when it represents none.\n *\n * A buffer is always its literal number, including a year's: `26` is the year\n * 26 here, not 2026. The two-digit window is applied once, by `commitSegment`,\n * at the moment the user is finished with the segment -- applying it per\n * keystroke would make the first digit of `2026` compose the year 2002 and\n * push a date nobody typed out to `@onChange` and the calendar.\n */\nfunction bufferValue(segment: Segment, buffer: string): number | null {\n if (buffer === '') return null;\n const n = Number(buffer);\n return n < segment.min ? null : n;\n}\n\n/**\n * Appends one typed digit.\n *\n * `isFull` is the signal to advance focus. It is true when the segment cannot\n * take another digit -- either it has reached its width, or any further digit\n * would exceed `max`. That is what makes typing `5` into a month jump straight\n * to the day, while typing `1` waits to see whether `12` is coming.\n */\nfunction applyDigit(\n segment: Segment,\n digit: string\n): { segment: Segment; isFull: boolean } {\n // A textual segment (AM/PM) is typed by letter; see `applyLetter`.\n if (!/^\\d$/.test(digit) || segment.labels) {\n return { segment, isFull: false };\n }\n\n let buffer = segment.buffer + digit;\n let value = bufferValue(segment, buffer);\n\n // The accumulated digits no longer fit the segment, so this keystroke starts\n // a fresh entry instead of being discarded. Width is checked as well as the\n // bound because leading zeros pile up without ever exceeding it: `00` then\n // `1` in a month is the buffer `001`, which is still only January and would\n // render three characters wide in a two-character segment.\n if (\n buffer.length > segment.width ||\n (value !== null && value > segment.max)\n ) {\n buffer = digit;\n value = bufferValue(segment, buffer);\n // A single digit that still overflows cannot be entered at all.\n if (value !== null && value > segment.max)\n return { segment, isFull: false };\n }\n\n const atWidth = buffer.length >= segment.width;\n // Would any digit 0-9 appended here still fit? If not, there is nothing\n // left to wait for. `bufferValue` returning null (below `min`) behaves like\n // 0 here, same as the original non-null-assertion-based comparison did.\n const extended = bufferValue(segment, buffer + '0') ?? 0;\n const isFull = atWidth || extended > segment.max;\n\n // A segment that can take no further digit is finished, so it commits here\n // rather than waiting for focus to leave.\n const next: Segment = { ...segment, buffer, value, isCommitted: isFull };\n\n return { segment: next, isFull };\n}\n\n/**\n * Marks a segment as the user's finished answer, expanding a one- or\n * two-digit year through the sliding window on the way: typing `26` and\n * moving on means 2026, while `0026` typed in full means the year 26.\n *\n * An empty segment has nothing to commit and stays uncommitted, so leaving a\n * blank field does not invent a value for it.\n */\nfunction commitSegment(segment: Segment): Segment {\n if (segment.value === null) return segment;\n\n if (\n segment.type === 'year' &&\n segment.buffer.length > 0 &&\n segment.buffer.length <= 2\n ) {\n return withValue(segment, resolveTwoDigitYear(segment.buffer));\n }\n\n return { ...segment, isCommitted: true };\n}\n\n/**\n * A segment holding `value` as a finished answer.\n *\n * The zero-padded buffer is the paired invariant of `displaySegment`, which\n * reads the buffer back out -- so every path that sets a value goes through\n * here rather than restating the padding and risking the two drifting.\n */\nfunction withValue(segment: Segment, value: number): Segment {\n return {\n ...segment,\n value,\n buffer: String(value).padStart(segment.width, '0'),\n isCommitted: true\n };\n}\n\n/**\n * Types into a textual segment: a letter picks the first label starting with\n * it, so `a` and `p` set AM and PM in English. A letter that starts no label\n * is ignored, and the segment is finished either way it is set.\n */\nfunction applyLetter(\n segment: Segment,\n key: string\n): { segment: Segment; isFull: boolean } {\n const letter = key.toLocaleLowerCase();\n const index = (segment.labels ?? []).findIndex((label) =>\n label.toLocaleLowerCase().startsWith(letter)\n );\n if (index === -1) return { segment, isFull: false };\n\n return { segment: withValue(segment, index), isFull: true };\n}\n\n/** Clears both the value and the digits behind it. */\nfunction clearSegment(segment: Segment): Segment {\n return { ...segment, value: null, buffer: '', isCommitted: false };\n}\n\n/** Drops the last digit typed, for Backspace. */\nfunction deleteDigit(segment: Segment): Segment {\n const buffer = segment.buffer.slice(0, -1);\n // Un-commits: a year being backspaced through is being typed again, and the\n // 202 it passes through must not compose a date.\n return {\n ...segment,\n buffer,\n value: bufferValue(segment, buffer),\n isCommitted: false\n };\n}\n\n/** A 0-23 hour as the given cycle counts it. */\nfunction hourOnCycle(hours: number, cycle: HourCycle): number {\n if (cycle === 'h11') return hours % 12;\n if (cycle === 'h12') return hours % 12 || 12;\n if (cycle === 'h24') return hours || 24;\n return hours;\n}\n\n/** The 0-23 hour an hour segment and an AM/PM (0 or 1) stand for. */\nfunction hourOfDay(hour: number, cycle: HourCycle, dayPeriod: number): number {\n if (isTwelveHour(cycle)) return (hour % 12) + (dayPeriod === 1 ? 12 : 0);\n return hour % 24;\n}\n\n/** The unit of `date` this segment holds: what it seeds from, or is set to. */\nfunction seedFrom(segment: Segment, date: Date): number {\n switch (segment.type) {\n case 'year':\n return date.getFullYear();\n case 'month':\n return date.getMonth() + 1;\n case 'day':\n return date.getDate();\n case 'hour':\n return hourOnCycle(date.getHours(), segment.hourCycle ?? 'h23');\n case 'minute':\n return date.getMinutes();\n case 'dayPeriod':\n return date.getHours() < 12 ? 0 : 1;\n }\n}\n\n/**\n * Arrow and page keys. An empty segment does not step from zero -- it adopts\n * `placeholderValue`, so ArrowUp on a blank year offers this year rather than\n * the year 1.\n */\nfunction step(\n segment: Segment,\n delta: number,\n placeholderValue: Date\n): Segment {\n if (segment.value === null) {\n return withValue(segment, seedFrom(segment, placeholderValue));\n }\n\n const span = segment.max - segment.min + 1;\n const offset = segment.value - segment.min + delta;\n // Modulo twice: JavaScript's % keeps the sign of the dividend, so a\n // decrement past the floor would otherwise land on a negative value.\n const wrapped = ((offset % span) + span) % span;\n\n return withValue(segment, wrapped + segment.min);\n}\n\n/**\n * The segment's display text: the digits behind it, or its placeholder when\n * empty. A year still being typed shows exactly what has been typed --\n * `26` on the way to `2026` -- because padding it would claim digits the\n * user has not entered. Every other segment, and a committed year, is padded\n * to its full width.\n *\n * This is the single source of truth for \"what does this segment read as\n * right now\" -- both the rendered cell text and `formatForClipboard` call\n * it, so a mid-entry copy always matches what is on screen.\n */\nfunction displaySegment(segment: Segment): string {\n if (segment.value === null) return segment.placeholder;\n if (segment.labels) return segment.labels[segment.value] ?? '';\n\n const digits = segment.buffer;\n\n return segment.type === 'year' && !segment.isCommitted\n ? digits\n : digits.padStart(segment.width, '0');\n}\n\nfunction findSegment(parts: Part[], type: SegmentType): Segment | undefined {\n return parts.find((p): p is Segment => isSegment(p) && p.type === type);\n}\n\n/** Days in a month, via the zeroth day of the next one. */\nfunction daysInMonth(year: number, month: number): number {\n return new Date(year, month, 0).getDate();\n}\n\n/** A segment holding a finished value, as opposed to one mid-entry. */\nfunction isReady(\n segment: Segment | undefined\n): segment is Segment & { value: number } {\n return segment !== undefined && segment.value !== null && segment.isCommitted;\n}\n\n/**\n * The time the time segments hold, as a 0-23 hour and a minute; midnight when\n * there are none, and `null` while any of them is empty or still being typed.\n */\nfunction timeOf(parts: Part[]): { hours: number; minutes: number } | null {\n const hour = findSegment(parts, 'hour');\n if (!hour) return { hours: 0, minutes: 0 };\n\n const minute = findSegment(parts, 'minute');\n const dayPeriod = findSegment(parts, 'dayPeriod');\n if (!isReady(hour)) return null;\n if (minute && !isReady(minute)) return null;\n if (dayPeriod && !isReady(dayPeriod)) return null;\n\n return {\n hours: hourOfDay(\n hour.value,\n hour.hourCycle ?? 'h23',\n dayPeriod?.value ?? 0\n ),\n minutes: minute?.value ?? 0\n };\n}\n\n/**\n * The composed value, or `null` while any segment is still empty or still\n * being typed. The day is clamped to the chosen month's real length: a 31 left\n * over from January must resolve to the 28th in February, not roll forward\n * into March the way the `Date` constructor would.\n */\nfunction toDate(parts: Part[]): Date | null {\n const year = findSegment(parts, 'year');\n const month = findSegment(parts, 'month');\n const day = findSegment(parts, 'day');\n\n // Uncommitted counts as empty: half a year is not a date.\n if (!isReady(year) || !isReady(month) || !isReady(day)) return null;\n\n const time = timeOf(parts);\n if (!time) return null;\n\n const clamped = Math.min(day.value, daysInMonth(year.value, month.value));\n return new Date(\n year.value,\n month.value - 1,\n clamped,\n time.hours,\n time.minutes\n );\n}\n\n/**\n * Carries the segments' state onto a freshly built list, matching by type.\n *\n * Used when the locale or the format changes under a field that is already\n * holding something. Going via `toDate` instead would discard a half-typed\n * entry, because a partial entry composes no date -- and losing the user's\n * digits to a locale switch is exactly the failure this component exists to\n * avoid. A segment the new format has no place for is simply dropped.\n */\nfunction carryOver(next: Part[], previous: Part[]): Part[] {\n return next.map((part) => {\n if (!isSegment(part)) return part;\n\n const was = findSegment(previous, part.type);\n if (!was || was.value === null) return part;\n\n return {\n ...part,\n value: was.value,\n buffer: was.buffer,\n isCommitted: was.isCommitted\n };\n });\n}\n\n/**\n * Whether a format would render a month no one can type into -- either a\n * textual month outright, or a `dateStyle` preset, which picks its own and\n * cannot be reasoned about field by field.\n */\nfunction hasTextualMonth(options: Intl.DateTimeFormatOptions): boolean {\n return (\n options.dateStyle !== undefined ||\n options.month === 'long' ||\n options.month === 'short' ||\n options.month === 'narrow'\n );\n}\n\n/**\n * The nearest typeable format to the one asked for.\n *\n * A textual month is swapped for a numeric one and *everything else is left\n * alone*: a format asking for month and day keeps exactly those two segments\n * rather than growing a year the consumer never requested. A `dateStyle`\n * preset names no fields at all, so there is nothing to preserve and the\n * default numeric format stands in for the whole thing.\n */\nfunction toNumericFormat(\n options: Intl.DateTimeFormatOptions\n): Intl.DateTimeFormatOptions {\n if (options.dateStyle !== undefined) return DEFAULT_FORMAT;\n return { ...options, month: 'numeric' };\n}\n\n/**\n * The format the segments should actually be built from, warning when that is\n * not the one asked for.\n *\n * Both hosts need the identical policy and differ only in what they call\n * themselves, so the message is passed in rather than the rule being written\n * out twice and left to drift.\n */\nfunction resolveSegmentFormat(\n given: Intl.DateTimeFormatOptions | undefined,\n warning: { message: string; id: string }\n): Intl.DateTimeFormatOptions | undefined {\n if (!given || !hasTextualMonth(given)) return given;\n\n warn(warning.message, false, { id: warning.id });\n\n return toNumericFormat(given);\n}\n\n/** Whether two composed values differ -- `null` (no date) included. */\nfunction hasDateChanged(before: Date | null, after: Date | null): boolean {\n if (before === null || after === null) return before !== after;\n return before.getTime() !== after.getTime();\n}\n\n/** Writes a value across the segments, leaving literals untouched. */\nfunction fromDate(parts: Part[], date: Date | null): Part[] {\n return parts.map((part) => {\n if (!isSegment(part)) return part;\n if (!date) return clearSegment(part);\n\n return withValue(part, seedFrom(part, date));\n });\n}\n\nexport {\n buildParts,\n withTime,\n applyLetter,\n timeOf,\n hourOnCycle,\n hourOfDay,\n isSegment,\n emptySegment,\n DEFAULT_FORMAT,\n BOUNDS,\n applyDigit,\n commitSegment,\n clearSegment,\n deleteDigit,\n step,\n toDate,\n fromDate,\n findSegment,\n resolveTwoDigitYear,\n daysInMonth,\n displaySegment,\n withValue,\n carryOver,\n hasTextualMonth,\n toNumericFormat,\n resolveSegmentFormat,\n hasDateChanged\n};\n"],"names":["DEFAULT_FORMAT","year","month","day","BOUNDS","min","max","width","placeholder","hour","minute","dayPeriod","HOUR_BOUNDS","h11","h12","h23","h24","isTwelveHour","cycle","isSegment","part","kind","emptySegment","type","overrides","value","buffer","isCommitted","withTime","format","granularity","hourCycle","dayPeriodLabels","locale","formatter","Intl","DateTimeFormat","map","formatToParts","Date","find","p","buildParts","formatOptions","time","parts","resolvedOptions","out","push","labels","text","withoutDateTimeComma","DATE_TYPES","i","before","after","joinsDateAndTime","includes","replace","trim","resolveTwoDigitYear","digits","now","n","Number","length","currentYear","getFullYear","start","century","Math","floor","candidate","bufferValue","segment","applyDigit","digit","test","isFull","atWidth","extended","next","commitSegment","withValue","String","padStart","applyLetter","key","letter","toLocaleLowerCase","index","findIndex","label","startsWith","clearSegment","deleteDigit","slice","hourOnCycle","hours","hourOfDay","seedFrom","date","getMonth","getDate","getHours","getMinutes","step","delta","placeholderValue","span","offset","wrapped","displaySegment","findSegment","daysInMonth","isReady","undefined","timeOf","minutes","toDate","clamped","carryOver","previous","was","hasTextualMonth","options","dateStyle","toNumericFormat","resolveSegmentFormat","given","warning","warn","message","id","hasDateChanged","getTime","fromDate"],"mappings":";;AASA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAA0C,GAAG;AACjDC,EAAAA,IAAI,EAAE,SAAS;AACfC,EAAAA,KAAK,EAAE,SAAS;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AAC;IAEpC,OAAO+D,SAAS,CAAC/D,IAAI,EAAEgF,QAAQ,CAAChF,IAAI,EAAEiF,IAAI,CAAC,CAAC;AAC9C,EAAA,CAAC,CAAC;AACJ;;"}
|
|
1
|
+
{"version":3,"file":"segments.js","sources":["../../../../src/components/forms/date-input/segments.ts"],"sourcesContent":["import { warn } from '@ember/debug';\nimport type {\n HourCycle,\n Part,\n Segment,\n SegmentType,\n TimeOptions\n} from './types';\n\n/**\n * The format an editable field uses when the consumer supplies none.\n * Deliberately not `{ dateStyle: 'medium' }` -- DatePicker's button default --\n * which renders a month name and has no numeric segment to type into.\n */\nconst DEFAULT_FORMAT: Intl.DateTimeFormatOptions = {\n year: 'numeric',\n month: '2-digit',\n day: '2-digit'\n};\n\nconst BOUNDS: Record<\n SegmentType,\n { min: number; max: number; width: number; placeholder: string }\n> = {\n // Upper bound for the day is the widest any month gets; `toDate` clamps to\n // the real length of the chosen month, which is not known segment-locally.\n day: { min: 1, max: 31, width: 2, placeholder: 'dd' },\n month: { min: 1, max: 12, width: 2, placeholder: 'mm' },\n year: { min: 1, max: 9999, width: 4, placeholder: 'yyyy' },\n // A 24-hour clock's bounds; `hourBounds` gives the other cycles'.\n hour: { min: 0, max: 23, width: 2, placeholder: 'hh' },\n minute: { min: 0, max: 59, width: 2, placeholder: 'mm' },\n // AM is 0 and PM is 1. Its placeholder is the locale's AM, set by\n // `buildParts`, which is the only place the locale is known.\n dayPeriod: { min: 0, max: 1, width: 2, placeholder: 'AM' }\n};\n\nconst HOUR_BOUNDS: Record<HourCycle, { min: number; max: number }> = {\n h11: { min: 0, max: 11 },\n h12: { min: 1, max: 12 },\n h23: { min: 0, max: 23 },\n h24: { min: 1, max: 24 }\n};\n\n/** Whether a cycle counts the hours twice a day, and so needs AM/PM. */\nfunction isTwelveHour(cycle: HourCycle): boolean {\n return cycle === 'h11' || cycle === 'h12';\n}\n\nfunction isSegment(part: Part): part is Segment {\n return part.kind === 'segment';\n}\n\nfunction emptySegment(\n type: SegmentType,\n overrides: Partial<Segment> = {}\n): Segment {\n const { min, max, width, placeholder } = BOUNDS[type];\n return {\n kind: 'segment',\n type,\n value: null,\n min,\n max,\n width,\n placeholder,\n buffer: '',\n isCommitted: false,\n ...overrides\n };\n}\n\n/**\n * The format the segments are built from: the date format, plus the time\n * fields a granularity asks for. Seconds are out of scope.\n */\nfunction withTime(\n format: Intl.DateTimeFormatOptions,\n { granularity = 'day', hourCycle }: TimeOptions\n): Intl.DateTimeFormatOptions {\n if (granularity === 'day') return format;\n\n return {\n ...format,\n hour: '2-digit',\n ...(granularity === 'minute' ? { minute: '2-digit' } : {}),\n ...(hourCycle ? { hourCycle: hourCycle === 12 ? 'h12' : 'h23' } : {})\n };\n}\n\n/** The locale's names for AM and PM, in that order. */\nfunction dayPeriodLabels(locale: string): string[] {\n const formatter = new Intl.DateTimeFormat(locale, {\n hour: 'numeric',\n hourCycle: 'h12'\n });\n return [1, 13].map(\n (hour) =>\n formatter\n .formatToParts(new Date(2026, 0, 20, hour))\n .find((p) => p.type === 'dayPeriod')?.value ?? (hour < 12 ? 'AM' : 'PM')\n );\n}\n\n/**\n * Derives the segments and their separators from the locale, so `mm/dd/yyyy`,\n * `dd/mm/yyyy` and `yyyy年mm月dd日` all fall out of `Intl` rather than being\n * hardcoded.\n *\n * A format producing a textual month ('Jan') has no editable numeric\n * representation, so that part becomes a numeric month segment anyway. The\n * component warns; this function stays pure.\n */\nfunction buildParts(\n locale: string,\n formatOptions: Intl.DateTimeFormatOptions = DEFAULT_FORMAT,\n time: TimeOptions = {}\n): Part[] {\n const formatter = new Intl.DateTimeFormat(\n locale,\n withTime(formatOptions, time)\n );\n // A reference date, only ever used to make the formatter emit its parts.\n const parts = formatter.formatToParts(new Date(2026, 0, 20));\n // `Intl` settles the cycle -- the locale's, or the one asked for -- and the\n // hour's bounds, and whether there is an AM/PM at all, follow from it.\n const hourCycle = formatter.resolvedOptions().hourCycle ?? 'h23';\n\n const out: Part[] = [];\n for (const part of parts) {\n if (part.type === 'year' || part.type === 'month' || part.type === 'day') {\n out.push(emptySegment(part.type));\n } else if (part.type === 'hour') {\n out.push(emptySegment('hour', { ...HOUR_BOUNDS[hourCycle], hourCycle }));\n } else if (part.type === 'minute') {\n out.push(emptySegment('minute'));\n } else if (part.type === 'dayPeriod') {\n const labels = dayPeriodLabels(locale);\n out.push(emptySegment('dayPeriod', { labels, placeholder: labels[0] }));\n } else if (part.type === 'literal') {\n out.push({ kind: 'literal', text: part.value });\n }\n // Everything else -- era, weekday, relatedYear -- is dropped: there is no\n // segment for it.\n }\n\n return withoutDateTimeComma(out);\n}\n\nconst DATE_TYPES: SegmentType[] = ['year', 'month', 'day'];\n\n/**\n * `Intl` joins the date and the time with a comma in many locales\n * (`01/20/2026, 09:05 PM`), which reads like a sentence rather than a field.\n * The separator between the last date segment and the first time one keeps\n * whatever else the locale put there, minus the comma.\n */\nfunction withoutDateTimeComma(parts: Part[]): Part[] {\n return parts.map((part, i) => {\n if (part.kind !== 'literal') return part;\n const before = parts[i - 1];\n const after = parts[i + 1];\n const joinsDateAndTime =\n before?.kind === 'segment' &&\n DATE_TYPES.includes(before.type) &&\n after?.kind === 'segment' &&\n !DATE_TYPES.includes(after.type);\n if (!joinsDateAndTime) return part;\n const text = part.text.replace(/[,،,]/g, '').replace(/\\s+/g, ' ');\n return { kind: 'literal', text: text.trim() === '' ? ' ' : text };\n });\n}\n\n/**\n * A bare `yy` resolves into the hundred years running from 80 back to 19\n * forward -- so a birth date reaches the past while a card expiry reaches the\n * near future. Three or four digits are a year the user spelled out and are\n * taken literally.\n */\nfunction resolveTwoDigitYear(digits: string, now: Date = new Date()): number {\n const n = Number(digits);\n if (digits.length > 2) return n;\n\n const currentYear = now.getFullYear();\n const start = currentYear - 80;\n const century = Math.floor(start / 100) * 100;\n const candidate = century + n;\n return candidate < start ? candidate + 100 : candidate;\n}\n\n/**\n * The numeric value a buffer represents, or null when it represents none.\n *\n * A buffer is always its literal number, including a year's: `26` is the year\n * 26 here, not 2026. The two-digit window is applied once, by `commitSegment`,\n * at the moment the user is finished with the segment -- applying it per\n * keystroke would make the first digit of `2026` compose the year 2002 and\n * push a date nobody typed out to `@onChange` and the calendar.\n */\nfunction bufferValue(segment: Segment, buffer: string): number | null {\n if (buffer === '') return null;\n const n = Number(buffer);\n return n < segment.min ? null : n;\n}\n\n/**\n * Appends one typed digit.\n *\n * `isFull` is the signal to advance focus. It is true when the segment cannot\n * take another digit -- either it has reached its width, or any further digit\n * would exceed `max`. That is what makes typing `5` into a month jump straight\n * to the day, while typing `1` waits to see whether `12` is coming.\n */\nfunction applyDigit(\n segment: Segment,\n digit: string\n): { segment: Segment; isFull: boolean } {\n // A textual segment (AM/PM) is typed by letter; see `applyLetter`.\n if (!/^\\d$/.test(digit) || segment.labels) {\n return { segment, isFull: false };\n }\n\n let buffer = segment.buffer + digit;\n let value = bufferValue(segment, buffer);\n\n // The accumulated digits no longer fit the segment, so this keystroke starts\n // a fresh entry instead of being discarded. Width is checked as well as the\n // bound because leading zeros pile up without ever exceeding it: `00` then\n // `1` in a month is the buffer `001`, which is still only January and would\n // render three characters wide in a two-character segment.\n if (\n buffer.length > segment.width ||\n (value !== null && value > segment.max)\n ) {\n buffer = digit;\n value = bufferValue(segment, buffer);\n // A single digit that still overflows cannot be entered at all.\n if (value !== null && value > segment.max)\n return { segment, isFull: false };\n }\n\n const atWidth = buffer.length >= segment.width;\n // Would any digit 0-9 appended here still fit? If not, there is nothing\n // left to wait for. `bufferValue` returning null (below `min`) behaves like\n // 0 here, same as the original non-null-assertion-based comparison did.\n const extended = bufferValue(segment, buffer + '0') ?? 0;\n const isFull = atWidth || extended > segment.max;\n\n // A segment that can take no further digit is finished, so it commits here\n // rather than waiting for focus to leave.\n const next: Segment = { ...segment, buffer, value, isCommitted: isFull };\n\n return { segment: next, isFull };\n}\n\n/**\n * Marks a segment as the user's finished answer, expanding a one- or\n * two-digit year through the sliding window on the way: typing `26` and\n * moving on means 2026, while `0026` typed in full means the year 26.\n *\n * An empty segment has nothing to commit and stays uncommitted, so leaving a\n * blank field does not invent a value for it.\n */\nfunction commitSegment(segment: Segment): Segment {\n if (segment.value === null) return segment;\n\n if (\n segment.type === 'year' &&\n segment.buffer.length > 0 &&\n segment.buffer.length <= 2\n ) {\n return withValue(segment, resolveTwoDigitYear(segment.buffer));\n }\n\n return { ...segment, isCommitted: true };\n}\n\n/**\n * A segment holding `value` as a finished answer.\n *\n * The zero-padded buffer is the paired invariant of `displaySegment`, which\n * reads the buffer back out -- so every path that sets a value goes through\n * here rather than restating the padding and risking the two drifting.\n */\nfunction withValue(segment: Segment, value: number): Segment {\n return {\n ...segment,\n value,\n buffer: String(value).padStart(segment.width, '0'),\n isCommitted: true\n };\n}\n\n/**\n * Types into a textual segment: a letter picks the first label starting with\n * it, so `a` and `p` set AM and PM in English. A letter that starts no label\n * is ignored, and the segment is finished either way it is set.\n */\nfunction applyLetter(\n segment: Segment,\n key: string\n): { segment: Segment; isFull: boolean } {\n const letter = key.toLocaleLowerCase();\n const index = (segment.labels ?? []).findIndex((label) =>\n label.toLocaleLowerCase().startsWith(letter)\n );\n if (index === -1) return { segment, isFull: false };\n\n return { segment: withValue(segment, index), isFull: true };\n}\n\n/** Clears both the value and the digits behind it. */\nfunction clearSegment(segment: Segment): Segment {\n return { ...segment, value: null, buffer: '', isCommitted: false };\n}\n\n/** Drops the last digit typed, for Backspace. */\nfunction deleteDigit(segment: Segment): Segment {\n const buffer = segment.buffer.slice(0, -1);\n // Un-commits: a year being backspaced through is being typed again, and the\n // 202 it passes through must not compose a date.\n return {\n ...segment,\n buffer,\n value: bufferValue(segment, buffer),\n isCommitted: false\n };\n}\n\n/** A 0-23 hour as the given cycle counts it. */\nfunction hourOnCycle(hours: number, cycle: HourCycle): number {\n if (cycle === 'h11') return hours % 12;\n if (cycle === 'h12') return hours % 12 || 12;\n if (cycle === 'h24') return hours || 24;\n return hours;\n}\n\n/** The 0-23 hour an hour segment and an AM/PM (0 or 1) stand for. */\nfunction hourOfDay(hour: number, cycle: HourCycle, dayPeriod: number): number {\n if (isTwelveHour(cycle)) return (hour % 12) + (dayPeriod === 1 ? 12 : 0);\n return hour % 24;\n}\n\n/** The unit of `date` this segment holds: what it seeds from, or is set to. */\nfunction seedFrom(segment: Segment, date: Date): number {\n switch (segment.type) {\n case 'year':\n return date.getFullYear();\n case 'month':\n return date.getMonth() + 1;\n case 'day':\n return date.getDate();\n case 'hour':\n return hourOnCycle(date.getHours(), segment.hourCycle ?? 'h23');\n case 'minute':\n return date.getMinutes();\n case 'dayPeriod':\n return date.getHours() < 12 ? 0 : 1;\n }\n}\n\n/**\n * Arrow and page keys. An empty segment does not step from zero -- it adopts\n * `placeholderValue`, so ArrowUp on a blank year offers this year rather than\n * the year 1.\n */\nfunction step(\n segment: Segment,\n delta: number,\n placeholderValue: Date\n): Segment {\n if (segment.value === null) {\n return withValue(segment, seedFrom(segment, placeholderValue));\n }\n\n const span = segment.max - segment.min + 1;\n const offset = segment.value - segment.min + delta;\n // Modulo twice: JavaScript's % keeps the sign of the dividend, so a\n // decrement past the floor would otherwise land on a negative value.\n const wrapped = ((offset % span) + span) % span;\n\n return withValue(segment, wrapped + segment.min);\n}\n\n/**\n * The segment's display text: the digits behind it, or its placeholder when\n * empty. A year still being typed shows exactly what has been typed --\n * `26` on the way to `2026` -- because padding it would claim digits the\n * user has not entered. Every other segment, and a committed year, is padded\n * to its full width.\n *\n * This is the single source of truth for \"what does this segment read as\n * right now\" -- both the rendered cell text and `formatForClipboard` call\n * it, so a mid-entry copy always matches what is on screen.\n */\nfunction displaySegment(segment: Segment): string {\n if (segment.value === null) return segment.placeholder;\n if (segment.labels) return segment.labels[segment.value] ?? '';\n\n const digits = segment.buffer;\n\n return segment.type === 'year' && !segment.isCommitted\n ? digits\n : digits.padStart(segment.width, '0');\n}\n\nfunction findSegment(parts: Part[], type: SegmentType): Segment | undefined {\n return parts.find((p): p is Segment => isSegment(p) && p.type === type);\n}\n\n/** Days in a month, via the zeroth day of the next one. */\nfunction daysInMonth(year: number, month: number): number {\n return new Date(year, month, 0).getDate();\n}\n\n/** A segment holding a finished value, as opposed to one mid-entry. */\nfunction isReady(\n segment: Segment | undefined\n): segment is Segment & { value: number } {\n return segment !== undefined && segment.value !== null && segment.isCommitted;\n}\n\n/**\n * The time the time segments hold, as a 0-23 hour and a minute; midnight when\n * there are none, and `null` while any of them is empty or still being typed.\n */\nfunction timeOf(parts: Part[]): { hours: number; minutes: number } | null {\n const hour = findSegment(parts, 'hour');\n if (!hour) return { hours: 0, minutes: 0 };\n\n const minute = findSegment(parts, 'minute');\n const dayPeriod = findSegment(parts, 'dayPeriod');\n if (!isReady(hour)) return null;\n if (minute && !isReady(minute)) return null;\n if (dayPeriod && !isReady(dayPeriod)) return null;\n\n return {\n hours: hourOfDay(\n hour.value,\n hour.hourCycle ?? 'h23',\n dayPeriod?.value ?? 0\n ),\n minutes: minute?.value ?? 0\n };\n}\n\n/**\n * The composed value, or `null` while any segment is still empty or still\n * being typed. The day is clamped to the chosen month's real length: a 31 left\n * over from January must resolve to the 28th in February, not roll forward\n * into March the way the `Date` constructor would.\n */\nfunction toDate(parts: Part[]): Date | null {\n const year = findSegment(parts, 'year');\n const month = findSegment(parts, 'month');\n const day = findSegment(parts, 'day');\n\n // Uncommitted counts as empty: half a year is not a date.\n if (!isReady(year) || !isReady(month) || !isReady(day)) return null;\n\n const time = timeOf(parts);\n if (!time) return null;\n\n const clamped = Math.min(day.value, daysInMonth(year.value, month.value));\n return new Date(\n year.value,\n month.value - 1,\n clamped,\n time.hours,\n time.minutes\n );\n}\n\n/**\n * Carries the segments' state onto a freshly built list, matching by type.\n *\n * Used when the locale or the format changes under a field that is already\n * holding something. Going via `toDate` instead would discard a half-typed\n * entry, because a partial entry composes no date -- and losing the user's\n * digits to a locale switch is exactly the failure this component exists to\n * avoid. A segment the new format has no place for is simply dropped.\n */\nfunction carryOver(next: Part[], previous: Part[]): Part[] {\n return next.map((part) => {\n if (!isSegment(part)) return part;\n\n const was = findSegment(previous, part.type);\n if (!was || was.value === null) return part;\n\n return {\n ...part,\n value: was.value,\n buffer: was.buffer,\n isCommitted: was.isCommitted\n };\n });\n}\n\n/**\n * Whether a format would render a month no one can type into -- either a\n * textual month outright, or a `dateStyle` preset, which picks its own and\n * cannot be reasoned about field by field.\n */\nfunction hasTextualMonth(options: Intl.DateTimeFormatOptions): boolean {\n return (\n options.dateStyle !== undefined ||\n options.month === 'long' ||\n options.month === 'short' ||\n options.month === 'narrow'\n );\n}\n\n/**\n * The nearest typeable format to the one asked for.\n *\n * A textual month is swapped for a numeric one and *everything else is left\n * alone*: a format asking for month and day keeps exactly those two segments\n * rather than growing a year the consumer never requested. A `dateStyle`\n * preset names no fields at all, so there is nothing to preserve and the\n * default numeric format stands in for the whole thing.\n */\nfunction toNumericFormat(\n options: Intl.DateTimeFormatOptions\n): Intl.DateTimeFormatOptions {\n if (options.dateStyle !== undefined) return DEFAULT_FORMAT;\n return { ...options, month: 'numeric' };\n}\n\n/**\n * The format the segments should actually be built from, warning when that is\n * not the one asked for.\n *\n * Both hosts need the identical policy and differ only in what they call\n * themselves, so the message is passed in rather than the rule being written\n * out twice and left to drift.\n */\nfunction resolveSegmentFormat(\n given: Intl.DateTimeFormatOptions | undefined,\n warning: { message: string; id: string }\n): Intl.DateTimeFormatOptions | undefined {\n if (!given || !hasTextualMonth(given)) return given;\n\n warn(warning.message, false, { id: warning.id });\n\n return toNumericFormat(given);\n}\n\n/** Whether two composed values differ -- `null` (no date) included. */\nfunction hasDateChanged(before: Date | null, after: Date | null): boolean {\n if (before === null || after === null) return before !== after;\n return before.getTime() !== after.getTime();\n}\n\n/** Writes a value across the segments, leaving literals untouched. */\nfunction fromDate(parts: Part[], date: Date | null): Part[] {\n return parts.map((part) => {\n if (!isSegment(part)) return part;\n if (!date) return clearSegment(part);\n\n return withValue(part, seedFrom(part, date));\n });\n}\n\nexport {\n buildParts,\n withTime,\n applyLetter,\n timeOf,\n hourOnCycle,\n hourOfDay,\n seedFrom,\n isSegment,\n emptySegment,\n DEFAULT_FORMAT,\n BOUNDS,\n applyDigit,\n commitSegment,\n clearSegment,\n deleteDigit,\n step,\n toDate,\n fromDate,\n findSegment,\n resolveTwoDigitYear,\n daysInMonth,\n displaySegment,\n withValue,\n carryOver,\n hasTextualMonth,\n toNumericFormat,\n resolveSegmentFormat,\n hasDateChanged\n};\n"],"names":["DEFAULT_FORMAT","year","month","day","BOUNDS","min","max","width","placeholder","hour","minute","dayPeriod","HOUR_BOUNDS","h11","h12","h23","h24","isTwelveHour","cycle","isSegment","part","kind","emptySegment","type","overrides","value","buffer","isCommitted","withTime","format","granularity","hourCycle","dayPeriodLabels","locale","formatter","Intl","DateTimeFormat","map","formatToParts","Date","find","p","buildParts","formatOptions","time","parts","resolvedOptions","out","push","labels","text","withoutDateTimeComma","DATE_TYPES","i","before","after","joinsDateAndTime","includes","replace","trim","resolveTwoDigitYear","digits","now","n","Number","length","currentYear","getFullYear","start","century","Math","floor","candidate","bufferValue","segment","applyDigit","digit","test","isFull","atWidth","extended","next","commitSegment","withValue","String","padStart","applyLetter","key","letter","toLocaleLowerCase","index","findIndex","label","startsWith","clearSegment","deleteDigit","slice","hourOnCycle","hours","hourOfDay","seedFrom","date","getMonth","getDate","getHours","getMinutes","step","delta","placeholderValue","span","offset","wrapped","displaySegment","findSegment","daysInMonth","isReady","undefined","timeOf","minutes","toDate","clamped","carryOver","previous","was","hasTextualMonth","options","dateStyle","toNumericFormat","resolveSegmentFormat","given","warning","warn","message","id","hasDateChanged","getTime","fromDate"],"mappings":";;AASA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAA0C,GAAG;AACjDC,EAAAA,IAAI,EAAE,SAAS;AACfC,EAAAA,KAAK,EAAE,SAAS;AAChBC,EAAAA,GAAG,EAAE;AACP;AAEA,MAAMC,MAGL,GAAG;AACF;AACA;AACAD,EAAAA,GAAG,EAAE;AAAEE,IAAAA,GAAG,EAAE,CAAC;AAAEC,IAAAA,GAAG,EAAE,EAAE;A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
|
|
1
|
-
export { BOUNDS, DEFAULT_FORMAT, applyDigit, applyLetter, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, hourOfDay, hourOnCycle, isSegment, resolveSegmentFormat, resolveTwoDigitYear, step, timeOf, toDate, toNumericFormat, withTime, withValue } from './date-input/segments.js';
|
|
1
|
+
export { BOUNDS, DEFAULT_FORMAT, applyDigit, applyLetter, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, hourOfDay, hourOnCycle, isSegment, resolveSegmentFormat, resolveTwoDigitYear, seedFrom, step, timeOf, toDate, toNumericFormat, withTime, withValue } from './date-input/segments.js';
|
|
2
2
|
export { formatForClipboard, parsePasted, splitRange } from './date-input/clipboard.js';
|
|
3
3
|
export { DateInput, DateInput as default } from './date-input/date-input.js';
|
|
4
4
|
//# sourceMappingURL=date-input.js.map
|
|
@@ -7,8 +7,9 @@ import { useStyles } from '@frontile/theme';
|
|
|
7
7
|
import { FormControl } from '../form-control.js';
|
|
8
8
|
import { DatePickerTrigger } from './trigger.js';
|
|
9
9
|
import { DatePickerEndContent } from './end-content.js';
|
|
10
|
-
import { SegmentGroup } from '../date-input/segment-group.js';
|
|
11
|
-
import {
|
|
10
|
+
import { DEFAULT_SEGMENT_LABELS as DEFAULT_LABELS$1, SegmentGroup } from '../date-input/segment-group.js';
|
|
11
|
+
import { DatePickerTimeColumns } from './time-columns.js';
|
|
12
|
+
import { buildParts, fromDate, resolveSegmentFormat, carryOver, timeOf, hasDateChanged, toDate, isSegment, withValue, commitSegment, seedFrom } from '../date-input/segments.js';
|
|
12
13
|
import { Popover } from '../../overlays/popover.js';
|
|
13
14
|
import { Calendar } from '../../collections/calendar/calendar.js';
|
|
14
15
|
import { ref } from '../../../utils/ref.js';
|
|
@@ -21,8 +22,10 @@ import { d as decorateFieldV2, i as initializeDeferredDecorator, a as decorateMe
|
|
|
21
22
|
|
|
22
23
|
const DEFAULT_LABELS = {
|
|
23
24
|
clear: 'Clear',
|
|
24
|
-
chooseDate: label => label ? `Choose date, ${label}` : 'Choose date'
|
|
25
|
+
chooseDate: label => label ? `Choose date, ${label}` : 'Choose date',
|
|
26
|
+
time: 'Time'
|
|
25
27
|
};
|
|
28
|
+
const TIME_TYPES = ['hour', 'minute', 'dayPeriod'];
|
|
26
29
|
/**
|
|
27
30
|
* A date field: segments the value can be typed into, a calendar button that
|
|
28
31
|
* opens a calendar in a popover, and -- under `@isEditable={{false}}` -- the
|
|
@@ -159,6 +162,23 @@ class DatePicker extends Component {
|
|
|
159
162
|
get hasTime() {
|
|
160
163
|
return (this.args.granularity ?? 'day') !== 'day';
|
|
161
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Whether the popover lists the time beside the calendar. The columns edit
|
|
167
|
+
* the segments, so there have to be segments, and only one group of them:
|
|
168
|
+
* a range would need two sets of columns, and which end they edit would be
|
|
169
|
+
* one more thing to get across.
|
|
170
|
+
*/
|
|
171
|
+
get showsTimeColumns() {
|
|
172
|
+
return this.hasTime && this.isSegmented && !this.isRangeMode && (this.args.showTimeColumns ?? true);
|
|
173
|
+
}
|
|
174
|
+
get minuteStep() {
|
|
175
|
+
const step = this.args.minuteStep ?? 5;
|
|
176
|
+
return Number.isInteger(step) && step >= 1 && step <= 60 ? step : 5;
|
|
177
|
+
}
|
|
178
|
+
get timeLabel() {
|
|
179
|
+
return this.args.labels?.time ?? DEFAULT_LABELS.time;
|
|
180
|
+
}
|
|
181
|
+
columnLabel = type => this.args.segmentLabels?.[type] ?? DEFAULT_LABELS$1[type];
|
|
162
182
|
get mode() {
|
|
163
183
|
return this.args.mode ?? 'single';
|
|
164
184
|
}
|
|
@@ -380,7 +400,16 @@ class DatePicker extends Component {
|
|
|
380
400
|
return;
|
|
381
401
|
}
|
|
382
402
|
if (!this.isRangeMode) {
|
|
383
|
-
|
|
403
|
+
const picked = withTimeOf(value, this.timeAt('start'));
|
|
404
|
+
// With the time columns beside it, a day is half the answer: the
|
|
405
|
+
// popover stays open for the time.
|
|
406
|
+
if (this.showsTimeColumns) {
|
|
407
|
+
this.commitValue(picked, {
|
|
408
|
+
writeParts: true
|
|
409
|
+
});
|
|
410
|
+
} else {
|
|
411
|
+
this.handleChange(picked);
|
|
412
|
+
}
|
|
384
413
|
return;
|
|
385
414
|
}
|
|
386
415
|
const range = value;
|
|
@@ -441,6 +470,26 @@ class DatePicker extends Component {
|
|
|
441
470
|
});
|
|
442
471
|
};
|
|
443
472
|
/**
|
|
473
|
+
* An option picked in the time columns. It is written into the segments,
|
|
474
|
+
* the one place the time lives, and reported the way typing is -- so a
|
|
475
|
+
* time picked before any day waits for one, exactly as a typed time does.
|
|
476
|
+
*
|
|
477
|
+
* The other time segments are filled in if they are empty, so that one
|
|
478
|
+
* pick is a time: minutes start on the hour (10 reads as 10:00), the hour
|
|
479
|
+
* and AM/PM at `@placeholderValue`'s, as ArrowUp on an empty segment does.
|
|
480
|
+
* A segment still being typed is committed as it reads.
|
|
481
|
+
*/
|
|
482
|
+
handleTimeSelect = (type, value, commit) => {
|
|
483
|
+
const parts = this.#currentParts.map(part => {
|
|
484
|
+
if (!isSegment(part) || !TIME_TYPES.includes(part.type)) return part;
|
|
485
|
+
if (part.type === type) return withValue(part, value);
|
|
486
|
+
if (part.value !== null) return commitSegment(part);
|
|
487
|
+
return withValue(part, part.type === 'minute' ? 0 : seedFrom(part, this.placeholderValue));
|
|
488
|
+
});
|
|
489
|
+
this.handlePartsChange(parts);
|
|
490
|
+
if (commit) this.close();
|
|
491
|
+
};
|
|
492
|
+
/**
|
|
444
493
|
* The two range groups report separately, but a range is one value: each
|
|
445
494
|
* one recomposes the whole thing and reports only what moved.
|
|
446
495
|
*/
|
|
@@ -564,6 +613,7 @@ class DatePicker extends Component {
|
|
|
564
613
|
} = useStyles();
|
|
565
614
|
return datePicker({
|
|
566
615
|
size: this.args.inputSize,
|
|
616
|
+
color: this.args.color,
|
|
567
617
|
isSegmented: this.isSegmented,
|
|
568
618
|
isRange: this.isSegmented && this.isRangeMode
|
|
569
619
|
});
|
|
@@ -632,7 +682,7 @@ class DatePicker extends Component {
|
|
|
632
682
|
decorateMethodV2(this.prototype, "footerBlockArg", [cached]);
|
|
633
683
|
}
|
|
634
684
|
static {
|
|
635
|
-
setComponentTemplate(precompileTemplate("<div {{this.syncSegmentFormat this.locale this.segmentFormat this.timeOptions}} {{this.syncValue @value}} {{this.containerRef.setup}} class={{this.classes.base class=@classes.base}} data-component=\"date-picker\" data-part=\"base\" ...attributes>\n {{!-- A range's two names use dot notation, the convention Form documents\n for nested data -- so it arrives at a validator and at onSubmit as one\n { start, end } object rather than two loose keys. --}}\n {{#if @name}}\n {{#if this.isRangeMode}}\n <input type=\"hidden\" name={{concat @name \".start\"}} value={{this.wireRangeStart}} />\n <input type=\"hidden\" name={{concat @name \".end\"}} value={{this.wireRangeEnd}} />\n {{else}}\n <input type=\"hidden\" name={{@name}} value={{this.wireValue}} />\n {{/if}}\n {{/if}}\n <FormControl @id={{@id}} @size={{@inputSize}} @label={{@label}} @isRequired={{@isRequired}} @description={{@description}} @errors={{@errors}} @isInvalid={{@isInvalid}} @isDisabled={{@isDisabled}} as |c|>\n <Popover @placement={{@placement}} @flipOptions={{@flipOptions}} @middleware={{@middleware}} @shiftOptions={{@shiftOptions}} @offsetOptions={{@offsetOptions}} @strategy={{@strategy}} @didClose={{@didClose}} @isOpen={{this.isOpen}} @onOpenChange={{this.onOpenChange}} as |p|>\n <div {{p.anchor}} class={{this.classes.innerContainer class=@classes.innerContainer}} data-part=\"inner-container\" {{!-- The shell is on this element when segmented, so its invalid and\n disabled styling has to read from here. `role=\"group\"` inside\n cannot carry aria-invalid, which is why these are data\n attributes. --}} data-invalid={{if c.isInvalid \"true\" \"false\"}} data-disabled={{if @isDisabled \"true\" \"false\"}}>\n {{#if this.isSegmented}}\n {{!-- Blur tracking and focus recording ride on splattributes:\n the group renders `...attributes` on its `role=\"group\"` element,\n and both events bubble there from the segments. --}}\n {{#if this.isRangeMode}}\n {{!-- Two groups, so neither can take `c.id` or `@label`: ids\n must be unique and a name shared by both would leave a screen\n reader unable to tell the ends apart. Each derives its own\n from the field's. --}}\n <SegmentGroup @parts={{this.parts}} @onPartsChange={{this.handleStartParts}} @onRangePaste={{this.handleRangePaste}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{concat c.id \"-start\"}} @label={{this.startLabel}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} {{on \"focusin\" this.handleSegmentFocusIn}} {{on \"focusout\" this.blurTracker.handleFocusOut}} />\n <span data-part=\"separator\" aria-hidden=\"true\" class={{this.classes.separator class=@classes.separator}}>–</span>\n {{!-- No `@onRangePaste`: pasting \"20 Jan - 25 Jan\" into the end\n of a range and having it rewrite the start would be\n surprising. --}}\n <SegmentGroup @parts={{this.endParts}} @onPartsChange={{this.handleEndParts}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{concat c.id \"-end\"}} @label={{this.endLabel}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} {{on \"focusin\" this.handleSegmentFocusIn}} {{on \"focusout\" this.blurTracker.handleFocusOut}} />\n {{else}}\n <SegmentGroup @parts={{this.parts}} @onPartsChange={{this.handlePartsChange}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{c.id}} @label={{@label}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} {{on \"focusin\" this.handleSegmentFocusIn}} {{on \"focusout\" this.blurTracker.handleFocusOut}} />\n {{/if}}\n {{else}}\n <DatePickerTrigger @id={{c.id}} @trigger={{p.trigger}} @placeholder={{@placeholder}} @formatted={{this.formatted}} @isEmpty={{this.isEmpty}} @isDisabled={{@isDisabled}} @isInvalid={{c.isInvalid}} @hasCustomContent={{has-block \"value\"}} @accessibleName={{this.accessibleName}} @triggerRef={{this.triggerRef.setup}} @classes={{this.classes}} @userClasses={{@classes}} @onFocusOut={{this.blurTracker.handleFocusOut}}>\n <:value>\n {{#if (has-block \"value\")}}\n {{yield this.valueBlockArg to=\"value\"}}\n {{/if}}\n </:value>\n </DatePickerTrigger>\n {{/if}}\n\n <DatePickerEndContent @classes={{this.classes}} @userClasses={{@classes}} @endContentPointerEvents={{this.endContentPointerEvents}} @isClearable={{this.isClearable}} @onClear={{this.clear}} @isEditable={{this.isSegmented}} @trigger={{p.trigger}} @calendarButtonLabel={{this.calendarButtonLabel}} @clearLabel={{this.clearLabel}} @isDisabled={{@isDisabled}} />\n </div>\n\n {{!-- preventAutoFocus: overlay's default focus grab runs later()\n after Calendar's autofocus already focused the day; turned off so\n Calendar's autofocus is the only thing moving focus into the grid. --}}\n <p.Content @size={{if @popoverSize @popoverSize \"auto\"}} @target={{@target}} @renderInPlace={{@renderInPlace}} @closeOnOutsideClick={{@closeOnOutsideClick}} @closeOnEscapeKey={{@closeOnEscapeKey}} @transitionDuration={{@transitionDuration}} @disableTransitions={{@disableTransitions}} @blockScroll={{false}} @preventAutoFocus={{true}} {{!-- Overlay captures document.activeElement when the content\n mounts -- the calendar button, on the segmented path -- and\n refocuses it on teardown, after close() has already put focus back\n on the segment. `close()` is the one answer; this stops the\n overlay giving a second. --}} @preventFocusRestore={{this.isSegmented}} role=\"dialog\" aria-label={{@label}}>\n {{#if (has-block \"calendar\")}}\n
|
|
685
|
+
setComponentTemplate(precompileTemplate("<div {{this.syncSegmentFormat this.locale this.segmentFormat this.timeOptions}} {{this.syncValue @value}} {{this.containerRef.setup}} class={{this.classes.base class=@classes.base}} data-component=\"date-picker\" data-part=\"base\" ...attributes>\n {{!-- A range's two names use dot notation, the convention Form documents\n for nested data -- so it arrives at a validator and at onSubmit as one\n { start, end } object rather than two loose keys. --}}\n {{#if @name}}\n {{#if this.isRangeMode}}\n <input type=\"hidden\" name={{concat @name \".start\"}} value={{this.wireRangeStart}} />\n <input type=\"hidden\" name={{concat @name \".end\"}} value={{this.wireRangeEnd}} />\n {{else}}\n <input type=\"hidden\" name={{@name}} value={{this.wireValue}} />\n {{/if}}\n {{/if}}\n <FormControl @id={{@id}} @size={{@inputSize}} @label={{@label}} @isRequired={{@isRequired}} @description={{@description}} @errors={{@errors}} @isInvalid={{@isInvalid}} @isDisabled={{@isDisabled}} as |c|>\n <Popover @placement={{@placement}} @flipOptions={{@flipOptions}} @middleware={{@middleware}} @shiftOptions={{@shiftOptions}} @offsetOptions={{@offsetOptions}} @strategy={{@strategy}} @didClose={{@didClose}} @isOpen={{this.isOpen}} @onOpenChange={{this.onOpenChange}} as |p|>\n <div {{p.anchor}} class={{this.classes.innerContainer class=@classes.innerContainer}} data-part=\"inner-container\" {{!-- The shell is on this element when segmented, so its invalid and\n disabled styling has to read from here. `role=\"group\"` inside\n cannot carry aria-invalid, which is why these are data\n attributes. --}} data-invalid={{if c.isInvalid \"true\" \"false\"}} data-disabled={{if @isDisabled \"true\" \"false\"}}>\n {{#if this.isSegmented}}\n {{!-- Blur tracking and focus recording ride on splattributes:\n the group renders `...attributes` on its `role=\"group\"` element,\n and both events bubble there from the segments. --}}\n {{#if this.isRangeMode}}\n {{!-- Two groups, so neither can take `c.id` or `@label`: ids\n must be unique and a name shared by both would leave a screen\n reader unable to tell the ends apart. Each derives its own\n from the field's. --}}\n <SegmentGroup @parts={{this.parts}} @onPartsChange={{this.handleStartParts}} @onRangePaste={{this.handleRangePaste}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{concat c.id \"-start\"}} @label={{this.startLabel}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} {{on \"focusin\" this.handleSegmentFocusIn}} {{on \"focusout\" this.blurTracker.handleFocusOut}} />\n <span data-part=\"separator\" aria-hidden=\"true\" class={{this.classes.separator class=@classes.separator}}>–</span>\n {{!-- No `@onRangePaste`: pasting \"20 Jan - 25 Jan\" into the end\n of a range and having it rewrite the start would be\n surprising. --}}\n <SegmentGroup @parts={{this.endParts}} @onPartsChange={{this.handleEndParts}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{concat c.id \"-end\"}} @label={{this.endLabel}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} {{on \"focusin\" this.handleSegmentFocusIn}} {{on \"focusout\" this.blurTracker.handleFocusOut}} />\n {{else}}\n <SegmentGroup @parts={{this.parts}} @onPartsChange={{this.handlePartsChange}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{c.id}} @label={{@label}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} {{on \"focusin\" this.handleSegmentFocusIn}} {{on \"focusout\" this.blurTracker.handleFocusOut}} />\n {{/if}}\n {{else}}\n <DatePickerTrigger @id={{c.id}} @trigger={{p.trigger}} @placeholder={{@placeholder}} @formatted={{this.formatted}} @isEmpty={{this.isEmpty}} @isDisabled={{@isDisabled}} @isInvalid={{c.isInvalid}} @hasCustomContent={{has-block \"value\"}} @accessibleName={{this.accessibleName}} @triggerRef={{this.triggerRef.setup}} @classes={{this.classes}} @userClasses={{@classes}} @onFocusOut={{this.blurTracker.handleFocusOut}}>\n <:value>\n {{#if (has-block \"value\")}}\n {{yield this.valueBlockArg to=\"value\"}}\n {{/if}}\n </:value>\n </DatePickerTrigger>\n {{/if}}\n\n <DatePickerEndContent @classes={{this.classes}} @userClasses={{@classes}} @endContentPointerEvents={{this.endContentPointerEvents}} @isClearable={{this.isClearable}} @onClear={{this.clear}} @isEditable={{this.isSegmented}} @trigger={{p.trigger}} @calendarButtonLabel={{this.calendarButtonLabel}} @clearLabel={{this.clearLabel}} @isDisabled={{@isDisabled}} />\n </div>\n\n {{!-- preventAutoFocus: overlay's default focus grab runs later()\n after Calendar's autofocus already focused the day; turned off so\n Calendar's autofocus is the only thing moving focus into the grid. --}}\n <p.Content @size={{if @popoverSize @popoverSize \"auto\"}} @target={{@target}} @renderInPlace={{@renderInPlace}} @closeOnOutsideClick={{@closeOnOutsideClick}} @closeOnEscapeKey={{@closeOnEscapeKey}} @transitionDuration={{@transitionDuration}} @disableTransitions={{@disableTransitions}} @blockScroll={{false}} @preventAutoFocus={{true}} {{!-- Overlay captures document.activeElement when the content\n mounts -- the calendar button, on the segmented path -- and\n refocuses it on teardown, after close() has already put focus back\n on the segment. `close()` is the one answer; this stops the\n overlay giving a second. --}} @preventFocusRestore={{this.isSegmented}} role=\"dialog\" aria-label={{@label}}>\n <div data-part=\"panels\" class={{this.classes.panels class=@classes.panels}}>\n {{#if (has-block \"calendar\")}}\n {{yield this.calendarBlockArg to=\"calendar\"}}\n {{else}}\n <Calendar @mode={{this.mode}} @color={{@color}} @value={{this.value}} @onChange={{this.handleCalendarChange}} @locale={{@locale}} @weekStartsOn={{@weekStartsOn}} @minValue={{@minValue}} @maxValue={{@maxValue}} @isDateUnavailable={{@isDateUnavailable}} @visibleMonths={{@visibleMonths}} @captionLayout={{@captionLayout}} @labels={{@labels}} @fixedWeeks={{@fixedWeeks}} @showOutsideDays={{@showOutsideDays}} @isReadOnly={{@isReadOnly}} @isDisabled={{@isDisabled}} @labelledBy={{c.id}} @autofocus={{true}} @classes={{hash base=(this.classes.calendar class=@classes.calendar)}} data-part=\"calendar\" />\n {{/if}}\n {{#if this.showsTimeColumns}}\n <DatePickerTimeColumns @parts={{this.parts}} @minuteStep={{this.minuteStep}} @placeholderValue={{this.placeholderValue}} @label={{this.timeLabel}} @columnLabel={{this.columnLabel}} @idPrefix={{concat c.id \"-time\"}} @isReadOnly={{@isReadOnly}} @onSelect={{this.handleTimeSelect}} @classes={{this.classes}} @userClasses={{@classes}} />\n {{/if}}\n </div>\n\n {{#if (has-block \"footer\")}}\n <div data-part=\"footer\" class={{this.classes.footer class=@classes.footer}}>\n {{yield this.footerBlockArg to=\"footer\"}}\n </div>\n {{/if}}\n </p.Content>\n </Popover>\n </FormControl>\n</div>", {
|
|
636
686
|
strictMode: true,
|
|
637
687
|
scope: () => ({
|
|
638
688
|
concat,
|
|
@@ -643,7 +693,8 @@ class DatePicker extends Component {
|
|
|
643
693
|
DatePickerTrigger,
|
|
644
694
|
DatePickerEndContent,
|
|
645
695
|
Calendar,
|
|
646
|
-
hash
|
|
696
|
+
hash,
|
|
697
|
+
DatePickerTimeColumns
|
|
647
698
|
})
|
|
648
699
|
}), this);
|
|
649
700
|
}
|