frontile 0.18.0 → 0.18.2
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/get-config.d.ts.map +1 -1
- package/declarations/-private/timer.d.ts +3 -3
- package/declarations/-private/timer.d.ts.map +1 -1
- package/declarations/components/buttons/chip.d.ts +1 -1
- package/declarations/components/buttons/chip.d.ts.map +1 -1
- package/declarations/components/buttons/close-button.d.ts +2 -2
- package/declarations/components/buttons/close-button.d.ts.map +1 -1
- package/declarations/components/collections/listbox/item.d.ts +2 -2
- package/declarations/components/collections/listbox/item.d.ts.map +1 -1
- package/declarations/components/collections/simple-table/column.d.ts +6 -0
- package/declarations/components/collections/simple-table/column.d.ts.map +1 -1
- package/declarations/components/collections/simple-table/footer.d.ts +2 -1
- package/declarations/components/collections/simple-table/footer.d.ts.map +1 -1
- package/declarations/components/collections/simple-table/header.d.ts +2 -1
- package/declarations/components/collections/simple-table/header.d.ts.map +1 -1
- package/declarations/components/collections/simple-table/index.d.ts +1 -1
- package/declarations/components/collections/simple-table/index.d.ts.map +1 -1
- package/declarations/components/collections/table/checkbox.d.ts +1 -1
- package/declarations/components/collections/table/checkbox.d.ts.map +1 -1
- package/declarations/components/collections/table/column-visibility.d.ts +2 -2
- package/declarations/components/collections/table/column-visibility.d.ts.map +1 -1
- package/declarations/components/collections/table/table.d.ts +9 -7
- package/declarations/components/collections/table/table.d.ts.map +1 -1
- package/declarations/components/forms/autocomplete.d.ts +12 -12
- package/declarations/components/forms/checkbox.d.ts +2 -2
- package/declarations/components/forms/checkbox.d.ts.map +1 -1
- package/declarations/components/forms/date-input/clipboard.d.ts +34 -0
- package/declarations/components/forms/date-input/clipboard.d.ts.map +1 -0
- package/declarations/components/forms/date-input/date-input.d.ts +93 -0
- package/declarations/components/forms/date-input/date-input.d.ts.map +1 -0
- package/declarations/components/forms/date-input/segment-group.d.ts +132 -0
- package/declarations/components/forms/date-input/segment-group.d.ts.map +1 -0
- package/declarations/components/forms/date-input/segments.d.ts +163 -0
- package/declarations/components/forms/date-input/segments.d.ts.map +1 -0
- package/declarations/components/forms/date-input/types.d.ts +175 -0
- package/declarations/components/forms/date-input/types.d.ts.map +1 -0
- package/declarations/components/forms/date-input.d.ts +6 -0
- package/declarations/components/forms/date-input.d.ts.map +1 -0
- package/declarations/components/forms/date-picker/date-picker.d.ts +263 -15
- package/declarations/components/forms/date-picker/date-picker.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/end-content.d.ts +33 -3
- package/declarations/components/forms/date-picker/end-content.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/types.d.ts +45 -2
- package/declarations/components/forms/date-picker/types.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/value.d.ts +21 -5
- package/declarations/components/forms/date-picker/value.d.ts.map +1 -1
- package/declarations/components/forms/field.d.ts +7 -5
- package/declarations/components/forms/field.d.ts.map +1 -1
- package/declarations/components/forms/form.d.ts +5 -5
- package/declarations/components/forms/form.d.ts.map +1 -1
- package/declarations/components/forms/index.d.ts +1 -0
- package/declarations/components/forms/index.d.ts.map +1 -1
- package/declarations/components/forms/input-otp.d.ts +5 -5
- package/declarations/components/forms/input-otp.d.ts.map +1 -1
- package/declarations/components/forms/input.d.ts +15 -15
- package/declarations/components/forms/input.d.ts.map +1 -1
- package/declarations/components/forms/native-select.d.ts +10 -10
- package/declarations/components/forms/native-select.d.ts.map +1 -1
- package/declarations/components/forms/radio.d.ts +2 -2
- package/declarations/components/forms/radio.d.ts.map +1 -1
- package/declarations/components/forms/select/select.d.ts +16 -16
- package/declarations/components/forms/textarea.d.ts +10 -10
- package/declarations/components/forms/textarea.d.ts.map +1 -1
- package/declarations/components/navigation/pagination/pagination.d.ts +32 -1
- package/declarations/components/navigation/pagination/pagination.d.ts.map +1 -1
- package/declarations/components/overlays/overlay.d.ts +4 -4
- package/declarations/components/overlays/overlay.d.ts.map +1 -1
- package/declarations/components/utilities/avatar.d.ts +35 -2
- package/declarations/components/utilities/avatar.d.ts.map +1 -1
- package/declarations/components/utilities/collapsible.d.ts +16 -0
- package/declarations/components/utilities/collapsible.d.ts.map +1 -1
- package/declarations/test-support.d.ts +30 -0
- package/declarations/test-support.d.ts.map +1 -1
- package/declarations/utils/forms-utils-index.d.ts +1 -1
- package/declarations/utils/forms-utils-index.d.ts.map +1 -1
- package/declarations/utils/nested-data.d.ts +17 -0
- package/declarations/utils/nested-data.d.ts.map +1 -1
- package/dist/components/buttons/chip.js.map +1 -1
- package/dist/components/buttons/close-button.js +5 -12
- package/dist/components/buttons/close-button.js.map +1 -1
- package/dist/components/collections/listbox/item.js +4 -11
- package/dist/components/collections/listbox/item.js.map +1 -1
- package/dist/components/collections/simple-table/column.js +2 -2
- package/dist/components/collections/simple-table/column.js.map +1 -1
- package/dist/components/collections/simple-table/footer.js +1 -1
- package/dist/components/collections/simple-table/footer.js.map +1 -1
- package/dist/components/collections/simple-table/header.js +1 -1
- package/dist/components/collections/simple-table/header.js.map +1 -1
- package/dist/components/collections/simple-table/index.js +1 -1
- package/dist/components/collections/simple-table/index.js.map +1 -1
- package/dist/components/collections/table/checkbox.js +2 -7
- package/dist/components/collections/table/checkbox.js.map +1 -1
- package/dist/components/collections/table/column-visibility.js +2 -7
- package/dist/components/collections/table/column-visibility.js.map +1 -1
- package/dist/components/forms/checkbox.js +4 -12
- package/dist/components/forms/checkbox.js.map +1 -1
- package/dist/components/forms/date-input/clipboard.js +231 -0
- package/dist/components/forms/date-input/clipboard.js.map +1 -0
- package/dist/components/forms/date-input/date-input.js +204 -0
- package/dist/components/forms/date-input/date-input.js.map +1 -0
- package/dist/components/forms/date-input/segment-group.js +292 -0
- package/dist/components/forms/date-input/segment-group.js.map +1 -0
- package/dist/components/forms/date-input/segments.js +562 -0
- package/dist/components/forms/date-input/segments.js.map +1 -0
- package/dist/components/forms/date-input/types.js +2 -0
- package/dist/components/forms/date-input/types.js.map +1 -0
- package/dist/components/forms/date-input.js +4 -0
- package/dist/components/forms/date-input.js.map +1 -0
- package/dist/components/forms/date-picker/date-picker.js +361 -20
- package/dist/components/forms/date-picker/date-picker.js.map +1 -1
- package/dist/components/forms/date-picker/end-content.js +17 -4
- package/dist/components/forms/date-picker/end-content.js.map +1 -1
- package/dist/components/forms/date-picker/value.js +44 -6
- package/dist/components/forms/date-picker/value.js.map +1 -1
- package/dist/components/forms/field.js +12 -20
- package/dist/components/forms/field.js.map +1 -1
- package/dist/components/forms/form.js +11 -27
- package/dist/components/forms/form.js.map +1 -1
- package/dist/components/forms/index.js +5 -2
- package/dist/components/forms/index.js.map +1 -1
- package/dist/components/forms/input-otp.js +10 -26
- package/dist/components/forms/input-otp.js.map +1 -1
- package/dist/components/forms/input.js +9 -22
- package/dist/components/forms/input.js.map +1 -1
- package/dist/components/forms/native-select.js +5 -12
- package/dist/components/forms/native-select.js.map +1 -1
- package/dist/components/forms/radio.js +4 -12
- package/dist/components/forms/radio.js.map +1 -1
- package/dist/components/forms/textarea.js +6 -17
- package/dist/components/forms/textarea.js.map +1 -1
- package/dist/components/navigation/pagination/pagination.js +18 -2
- package/dist/components/navigation/pagination/pagination.js.map +1 -1
- package/dist/components/notifications/index.js +1 -1
- package/dist/components/overlays/overlay.js +8 -21
- package/dist/components/overlays/overlay.js.map +1 -1
- package/dist/components/utilities/avatar.js +26 -5
- package/dist/components/utilities/avatar.js.map +1 -1
- package/dist/components/utilities/collapsible.js +47 -3
- package/dist/components/utilities/collapsible.js.map +1 -1
- package/dist/forms.js +5 -2
- package/dist/forms.js.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/{manager-jDaRVZ5o.js → manager-Dge4r8Vn.js} +9 -19
- package/dist/manager-Dge4r8Vn.js.map +1 -0
- package/dist/notifications.js +1 -1
- package/dist/services/notifications.js +1 -1
- package/dist/test-support.js +903 -389
- package/dist/test-support.js.map +1 -1
- package/dist/utils/forms-utils-index.js +1 -1
- package/dist/utils/forms-utils-index.js.map +1 -1
- package/dist/utils/nested-data.js +28 -1
- package/dist/utils/nested-data.js.map +1 -1
- package/package.json +10 -10
- package/dist/manager-jDaRVZ5o.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.js","sources":["../../../../src/components/forms/date-picker/date-picker.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached, tracked } from '@glimmer/tracking';\nimport { modifier } from 'ember-modifier';\nimport { concat, hash } from '@ember/helper';\nimport { useStyles } from '@frontile/theme';\nimport { FormControl } from '../form-control';\nimport { DatePickerTrigger } from './trigger';\nimport { DatePickerEndContent } from './end-content';\nimport { Popover } from '../../overlays/popover';\nimport { Calendar } from '../../collections/calendar/calendar';\nimport { ref } from '../../../utils/ref';\nimport { ControlBlurTracker } from '../../../-private/control-blur';\nimport { triggerFormInputEvent } from '../../../utils/forms-utils-index';\nimport {\n formatValue,\n isEmptyValue,\n parseDate,\n parseRange,\n toWire\n} from './value';\nimport type {\n CalendarMode,\n CalendarValue,\n DateRange\n} from '../../collections/calendar/types';\nimport type {\n DatePickerArgs,\n DatePickerValueBlockArg,\n DatePickerCalendarArgs,\n DatePickerFooterArg\n} from './types';\n\ninterface DatePickerSignature<M extends CalendarMode = 'single'> {\n Args: DatePickerArgs<M>;\n Blocks: {\n value: [DatePickerValueBlockArg<M>];\n calendar: [DatePickerCalendarArgs<M>];\n footer: [DatePickerFooterArg<M>];\n };\n Element: HTMLDivElement;\n}\n\n/**\n * A date field: a button trigger showing the formatted value, and a calendar\n * in a popover. `@mode=\"range\"` switches both the calendar and the value shape\n * to a `{ start, end }` range.\n */\nclass DatePicker<M extends CalendarMode = 'single'> extends Component<\n DatePickerSignature<M>\n> {\n triggerRef = ref<HTMLButtonElement>();\n containerRef = ref<HTMLElement>();\n\n /**\n * The selection. Seeded from `@defaultValue`, updated by the user, and\n * synced from `@value` by {@link syncValue} whenever that argument changes.\n *\n * Everything renders from here rather than from `@value` directly -- see\n * {@link value} for why a read-through cannot work inside a `Form`.\n */\n @tracked internalValue: CalendarValue<M> | null = null;\n\n @tracked isOpen = false;\n\n constructor(owner: unknown, args: DatePickerArgs<M>) {\n super(owner as never, args as never);\n\n const seed = (args as { defaultValue?: unknown }).defaultValue;\n if (seed !== undefined) {\n this.internalValue = this.parseIncoming(seed);\n }\n }\n\n get mode(): M {\n return (this.args as { mode?: M }).mode ?? ('single' as M);\n }\n\n get locale(): string {\n return this.args.locale ?? navigator.language;\n }\n\n /**\n * The rendered value is always internal state, never a read-through to\n * `@value`; {@link syncValue} pushes `@value` into it whenever the argument\n * changes. This is the pattern `Select` uses, and reading through instead\n * deadlocks the component inside a `Form`: `Field` binds `@value` to the\n * form's data, the form's data comes from hidden inputs this component\n * renders, and those inputs would then render the very value they source.\n * Nothing could ever change it, so every pick after the first submit was\n * silently discarded.\n */\n get value(): CalendarValue<M> | null {\n return this.internalValue;\n }\n\n /** Normalizes whatever `@value` / `@defaultValue` was given to `Date`s. */\n private parseIncoming(raw: unknown): CalendarValue<M> | null {\n if (this.mode === 'range') {\n return parseRange(raw as never) as CalendarValue<M> | null;\n }\n return parseDate(raw as never) as CalendarValue<M> | null;\n }\n\n /**\n * Pushes `@value` into internal state when the argument changes. `undefined`\n * is ignored so that an uncontrolled picker -- and one bound by `Field`\n * before the form holds anything for it -- keeps whatever the user chose.\n */\n syncValue = modifier((_: HTMLDivElement, [raw]: [unknown]) => {\n if (raw !== undefined) {\n this.internalValue = this.parseIncoming(raw);\n }\n });\n\n get formatted(): string {\n return formatValue(this.value, this.locale, this.args.formatOptions);\n }\n\n get isEmpty(): boolean {\n return isEmptyValue(this.value);\n }\n\n @cached\n get valueBlockArg(): DatePickerValueBlockArg<M> {\n return {\n value: this.value,\n formatted: this.formatted,\n isEmpty: this.isEmpty\n };\n }\n\n /**\n * Names the trigger when a `:value` block owns its content. Falls back to\n * the formatted value alone rather than prefixing a hardcoded English\n * string when there is no `@label`. `undefined` (not `''`) when neither is\n * present, so the trigger omits `aria-label` entirely rather than setting\n * it to an empty string -- some assistive tech treats a present-but-empty\n * `aria-label` as overriding the visible text with nothing, leaving the\n * button unnamed.\n */\n get accessibleName(): string | undefined {\n const name = [this.args.label, this.formatted].filter(Boolean).join(', ');\n return name === '' ? undefined : name;\n }\n\n /**\n * Reports focus leaving the *whole* control -- the field and its portaled\n * popover -- rather than the trigger, which blurs on the way into the\n * calendar and on every day click.\n */\n blurTracker = new ControlBlurTracker({\n trigger: () => this.triggerRef.current,\n container: () => this.containerRef.current,\n isOpen: () => this.isOpen,\n isDestroyed: () => this.isDestroyed || this.isDestroying,\n onBlur: () => this.args.onBlur?.()\n });\n\n willDestroy(): void {\n super.willDestroy();\n // Nothing may resolve against a destroyed component.\n this.blurTracker.cancel();\n }\n\n /**\n * Whether the clear button takes the calendar icon's place. A disabled or\n * read-only field never shows it: the end-content cluster is not\n * pointer-transparent to it and it carries no disabled/read-only state of\n * its own, so it would otherwise be a live button that clears a field the\n * user may not change -- the same contract `Calendar` enforces for day\n * selection under `@isReadOnly`.\n */\n get isClearable(): boolean {\n return (\n Boolean(this.args.isClearable) &&\n !this.isEmpty &&\n !this.args.isDisabled &&\n !this.args.isReadOnly\n );\n }\n\n /**\n * Clearing removes the clear button from the DOM (`isClearable` flips\n * false the instant the value is gone), so -- like `close()` -- focus must\n * be handed back to the trigger explicitly or it falls to `<body>`.\n *\n * Unlike `close()`, clearing deliberately leaves an open popover open: the\n * clear button lives outside the popover entirely, so there is no\n * dangling-focus reason to dismiss the calendar, and a user who just\n * cleared the field is a user who likely wants to pick a new date right\n * away -- closing would just make them reopen it.\n */\n clear = (): void => {\n this.internalValue = null;\n (this.args.onChange as ((v: null) => void) | undefined)?.(null);\n this.notifyForm();\n this.triggerRef.current?.focus();\n };\n\n /**\n * Whether the selection is finished, and the popover should therefore close.\n * A range with only its anchor set is not: the user still owes a second\n * click, and closing would throw away the half they just made.\n */\n private isComplete(value: CalendarValue<M> | null): boolean {\n if (!value) return false;\n if (this.mode !== 'range') return true;\n return (value as DateRange).end !== null;\n }\n\n handleChange = (value: CalendarValue<M>): void => {\n // Internal state updates even when controlled, so the calendar's own\n // rendering stays responsive; the `value` getter ignores it in that case,\n // so the consumer still has the last word.\n this.internalValue = value;\n (this.args.onChange as ((v: CalendarValue<M>) => void) | undefined)?.(\n value\n );\n this.notifyForm();\n\n if (this.isComplete(value)) this.close();\n };\n\n /**\n * Tells an enclosing `Form` the value moved.\n *\n * The hidden inputs are written programmatically, and a programmatic value\n * change fires no `input` event -- so without this the form never learns\n * anything happened. That is worse than stale data: as soon as `Form` holds\n * any data for this field, `Field` binds `@value` back to it -- so without\n * this the form's copy of the value silently diverges from the field's, and\n * a later `@data` change would sync the stale value back in. `Select`\n * dispatches the same event for the same reason.\n */\n private notifyForm(): void {\n triggerFormInputEvent(this.containerRef.current);\n }\n\n /**\n * Wired to the popover's `@onOpenChange`, which also fires for Escape and\n * an outside click -- not only the explicit paths that already call\n * `close()` below. Routing every close through `close()` matters because\n * `Overlay`'s own focus-restore captures `document.activeElement` at the\n * moment its content mounts, which by then is already the day `@autofocus`\n * moved focus onto (that modifier runs before the overlay's own), not the\n * trigger. Left to it, closing would try to restore focus onto a day\n * button that has just been removed from the DOM -- a no-op -- and focus\n * would fall to `<body>`.\n */\n onOpenChange = (isOpen: boolean): void => {\n if (isOpen) {\n this.isOpen = true;\n return;\n }\n this.close();\n };\n\n /**\n * Closing removes the focused day from the DOM, so focus must be handed back\n * explicitly or it falls to `<body>` and the keyboard user loses their place.\n */\n close = (): void => {\n this.isOpen = false;\n this.triggerRef.current?.focus();\n };\n\n @cached\n get classes() {\n const { datePicker } = useStyles();\n return datePicker({ size: this.args.inputSize });\n }\n\n get isRangeMode(): boolean {\n return this.mode === 'range';\n }\n\n /**\n * The single-mode wire value, or `''` when there is nothing selected. Only\n * read from the single-mode branch of the template, so it does not repeat\n * that branch's mode check.\n */\n get wireValue(): string {\n return toWire(this.value as Date | null);\n }\n\n get wireRangeStart(): string {\n return toWire((this.value as DateRange | null)?.start ?? null);\n }\n\n get wireRangeEnd(): string {\n return toWire((this.value as DateRange | null)?.end ?? null);\n }\n\n @cached\n get calendarBlockArg(): DatePickerCalendarArgs<M> {\n return {\n mode: this.mode,\n color: this.args.color,\n value: this.value,\n onChange: this.handleChange,\n locale: this.locale,\n weekStartsOn: this.args.weekStartsOn,\n minValue: this.args.minValue,\n maxValue: this.args.maxValue,\n isDateUnavailable: this.args.isDateUnavailable,\n visibleMonths: this.args.visibleMonths,\n captionLayout: this.args.captionLayout,\n labelledBy: this.args.id,\n autofocus: true\n };\n }\n\n @cached\n get footerBlockArg(): DatePickerFooterArg<M> {\n return {\n // Deliberately `handleChange`, not a bare assignment: a preset must be\n // indistinguishable from a click, so it fires `@onChange` and closes on\n // a complete value exactly the way picking a day does.\n setValue: this.handleChange,\n close: this.close,\n value: this.value,\n isOpen: this.isOpen\n };\n }\n\n <template>\n <div\n {{this.syncValue @value}}\n {{this.containerRef.setup}}\n class={{this.classes.base class=@classes.base}}\n data-component=\"date-picker\"\n data-part=\"base\"\n ...attributes\n >\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\n type=\"hidden\"\n name={{concat @name \".start\"}}\n value={{this.wireRangeStart}}\n />\n <input\n type=\"hidden\"\n name={{concat @name \".end\"}}\n value={{this.wireRangeEnd}}\n />\n {{else}}\n <input type=\"hidden\" name={{@name}} value={{this.wireValue}} />\n {{/if}}\n {{/if}}\n <FormControl\n @id={{@id}}\n @size={{@inputSize}}\n @label={{@label}}\n @isRequired={{@isRequired}}\n @description={{@description}}\n @errors={{@errors}}\n @isInvalid={{@isInvalid}}\n @isDisabled={{@isDisabled}}\n as |c|\n >\n <Popover\n @placement={{@placement}}\n @flipOptions={{@flipOptions}}\n @middleware={{@middleware}}\n @shiftOptions={{@shiftOptions}}\n @offsetOptions={{@offsetOptions}}\n @strategy={{@strategy}}\n @didClose={{@didClose}}\n @isOpen={{this.isOpen}}\n @onOpenChange={{this.onOpenChange}}\n as |p|\n >\n <div\n {{p.anchor}}\n class={{this.classes.innerContainer class=@classes.innerContainer}}\n data-part=\"inner-container\"\n >\n <DatePickerTrigger\n @id={{c.id}}\n @trigger={{p.trigger}}\n @placeholder={{@placeholder}}\n @formatted={{this.formatted}}\n @isEmpty={{this.isEmpty}}\n @isDisabled={{@isDisabled}}\n @isInvalid={{c.isInvalid}}\n @hasCustomContent={{has-block \"value\"}}\n @accessibleName={{this.accessibleName}}\n @triggerRef={{this.triggerRef.setup}}\n @classes={{this.classes}}\n @userClasses={{@classes}}\n @onFocusOut={{this.blurTracker.handleFocusOut}}\n >\n <:value>\n {{#if (has-block \"value\")}}\n {{yield this.valueBlockArg to=\"value\"}}\n {{/if}}\n </:value>\n </DatePickerTrigger>\n\n <DatePickerEndContent\n @classes={{this.classes}}\n @userClasses={{@classes}}\n @endContentPointerEvents={{@endContentPointerEvents}}\n @isClearable={{this.isClearable}}\n @onClear={{this.clear}}\n />\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\n @size={{if @popoverSize @popoverSize \"auto\"}}\n @target={{@target}}\n @renderInPlace={{@renderInPlace}}\n @closeOnOutsideClick={{@closeOnOutsideClick}}\n @closeOnEscapeKey={{@closeOnEscapeKey}}\n @transitionDuration={{@transitionDuration}}\n @disableTransitions={{@disableTransitions}}\n @blockScroll={{false}}\n @preventAutoFocus={{true}}\n role=\"dialog\"\n aria-label={{@label}}\n >\n {{#if (has-block \"calendar\")}}\n {{yield this.calendarBlockArg to=\"calendar\"}}\n {{else}}\n <Calendar\n @mode={{this.mode}}\n @color={{@color}}\n @value={{this.value}}\n @onChange={{this.handleChange}}\n @locale={{@locale}}\n @weekStartsOn={{@weekStartsOn}}\n @minValue={{@minValue}}\n @maxValue={{@maxValue}}\n @isDateUnavailable={{@isDateUnavailable}}\n @visibleMonths={{@visibleMonths}}\n @captionLayout={{@captionLayout}}\n @fixedWeeks={{@fixedWeeks}}\n @showOutsideDays={{@showOutsideDays}}\n @isReadOnly={{@isReadOnly}}\n @isDisabled={{@isDisabled}}\n @labelledBy={{c.id}}\n @autofocus={{true}}\n @classes={{hash\n base=(this.classes.calendar class=@classes.calendar)\n }}\n data-part=\"calendar\"\n />\n {{/if}}\n\n {{#if (has-block \"footer\")}}\n <div\n data-part=\"footer\"\n class={{this.classes.footer class=@classes.footer}}\n >\n {{yield this.footerBlockArg to=\"footer\"}}\n </div>\n {{/if}}\n </p.Content>\n </Popover>\n </FormControl>\n </div>\n </template>\n}\n\nexport { DatePicker, type DatePickerSignature };\nexport default DatePicker;\n"],"names":["DatePicker","Component","triggerRef","ref","containerRef","g","prototype","tracked","i","constructor","owner","args","seed","defaultValue","undefined","internalValue","parseIncoming","mode","locale","navigator","language","value","raw","parseRange","parseDate","syncValue","modifier","_","formatted","formatValue","formatOptions","isEmpty","isEmptyValue","valueBlockArg","n","cached","accessibleName","name","label","filter","Boolean","join","blurTracker","ControlBlurTracker","trigger","current","container","isOpen","isDestroyed","isDestroying","onBlur","willDestroy","cancel","isClearable","isDisabled","isReadOnly","clear","onChange","notifyForm","focus","isComplete","end","handleChange","close","triggerFormInputEvent","onOpenChange","classes","datePicker","useStyles","size","inputSize","isRangeMode","wireValue","toWire","wireRangeStart","start","wireRangeEnd","calendarBlockArg","color","weekStartsOn","minValue","maxValue","isDateUnavailable","visibleMonths","captionLayout","labelledBy","id","autofocus","footerBlockArg","setValue","setComponentTemplate","precompileTemplate","strictMode","scope","concat","FormControl","Popover","DatePickerTrigger","DatePickerEndContent","Calendar","hash"],"mappings":";;;;;;;;;;;;;;;;;;AA0CA;;;;AAIC;AACD,MAAMA,UAAA,SAAsDC,UACtC;EAEpBC,UAAA,GAAaC,KAAI;EACjBC,YAAA,GAAeD,KAAI;AAEnB;;;;;;AAMC;AAND,EAAA;IAAAE,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,eA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AAA;QAAAC,iBAAA;QAAAC,oBAAA;QAAAC,QAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
1
|
+
{"version":3,"file":"date-picker.js","sources":["../../../../src/components/forms/date-picker/date-picker.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached, tracked } from '@glimmer/tracking';\nimport { modifier } from 'ember-modifier';\nimport { concat, hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nimport { FormControl } from '../form-control';\nimport { DatePickerTrigger } from './trigger';\nimport { DatePickerEndContent } from './end-content';\nimport { SegmentGroup } from '../date-input/segment-group';\nimport {\n buildParts,\n toDate,\n fromDate,\n carryOver,\n resolveSegmentFormat,\n hasDateChanged,\n timeOf\n} from '../date-input/segments';\nimport { Popover } from '../../overlays/popover';\nimport { Calendar } from '../../collections/calendar/calendar';\nimport { ref } from '../../../utils/ref';\nimport { ControlBlurTracker } from '../../../-private/control-blur';\nimport { triggerFormInputEvent } from '../../../utils/forms-utils-index';\nimport {\n formatValue,\n isEmptyValue,\n parseDate,\n parseRange,\n toWire,\n withTimeOf,\n DEFAULT_TIME_FORMAT\n} from './value';\nimport type {\n CalendarMode,\n CalendarValue,\n DateRange\n} from '../../collections/calendar/types';\nimport type { Part, TimeOptions } from '../date-input/types';\nimport type {\n DatePickerArgs,\n DatePickerValueBlockArg,\n DatePickerCalendarArgs,\n DatePickerFooterArg\n} from './types';\n\ninterface DatePickerSignature<M extends CalendarMode = 'single'> {\n Args: DatePickerArgs<M>;\n Blocks: {\n value: [DatePickerValueBlockArg<M>];\n calendar: [DatePickerCalendarArgs<M>];\n footer: [DatePickerFooterArg<M>];\n };\n Element: HTMLDivElement;\n}\n\n/**\n * A date field: segments the value can be typed into, a calendar button that\n * opens a calendar in a popover, and -- under `@isEditable={{false}}` -- the\n * older button trigger showing the formatted value instead. `@mode=\"range\"`\n * switches both the calendar and the value shape to a `{ start, end }` range,\n * and -- when editable -- renders two groups of segments with a separator\n * between them.\n */\nclass DatePicker<M extends CalendarMode = 'single'> extends Component<\n DatePickerSignature<M>\n> {\n triggerRef = ref<HTMLButtonElement>();\n containerRef = ref<HTMLElement>();\n\n /**\n * The selection. Seeded from `@defaultValue`, updated by the user, and\n * synced from `@value` by {@link syncValue} whenever that argument changes.\n *\n * Everything renders from here rather than from `@value` directly -- see\n * {@link value} for why a read-through cannot work inside a `Form`.\n */\n @tracked internalValue: CalendarValue<M> | null = null;\n\n @tracked isOpen = false;\n\n /**\n * The segments, on the editable path. They are not a second source of truth\n * for the value -- {@link internalValue} is -- but they cannot be derived\n * from it either: mid-entry they hold digits that compose to no date at all,\n * which no `Date` can represent. The calendar writes here through\n * {@link commitValue}; typing writes there through {@link handlePartsChange}.\n */\n @tracked private trackedParts: Part[] = [];\n\n /**\n * The second group, in `@mode=\"range\"` only. {@link trackedParts} is that\n * mode's *start* group, so every path that writes one writes both.\n */\n @tracked private trackedEndParts: Part[] = [];\n\n /**\n * An untracked mirror of {@link parts}. The sync modifiers below rebuild the\n * segments from the current ones, and reading the tracked field inside a\n * modifier would put it in that modifier's own tracking frame -- which the\n * same modifier then writes to, re-running itself forever. `DateInput`\n * carries the same pair for the same reason.\n */\n #currentParts: Part[] = [];\n\n /** The same mirror, for {@link trackedEndParts}. */\n #currentEndParts: Part[] = [];\n\n constructor(owner: unknown, args: DatePickerArgs<M>) {\n super(owner as never, args as never);\n\n const seed = (args as { defaultValue?: unknown }).defaultValue;\n if (seed !== undefined) {\n this.internalValue = this.parseIncoming(seed);\n }\n\n this.writeParts(this.internalValue, () =>\n buildParts(this.locale, this.segmentFormat, this.timeOptions)\n );\n }\n\n get parts(): Part[] {\n return this.trackedParts;\n }\n\n get endParts(): Part[] {\n return this.trackedEndParts;\n }\n\n private setParts(parts: Part[]): void {\n this.#currentParts = parts;\n this.trackedParts = parts;\n }\n\n private setEndParts(parts: Part[]): void {\n this.#currentEndParts = parts;\n this.trackedEndParts = parts;\n }\n\n /**\n * Writes a value across the segments, whichever mode is in play.\n *\n * `onto` supplies the list each group is written into -- the current\n * segments when a value moved, a freshly built row when the locale or the\n * format changed. It is a function because range mode needs two independent\n * lists and must not hand the same array to both groups.\n */\n private writeParts(\n value: CalendarValue<M> | null,\n onto: (edge: 'start' | 'end') => Part[]\n ): void {\n if (!this.isRangeMode) {\n this.setParts(fromDate(onto('start'), value as Date | null));\n return;\n }\n\n const range = value as DateRange | null;\n this.setParts(fromDate(onto('start'), range?.start ?? null));\n this.setEndParts(fromDate(onto('end'), range?.end ?? null));\n }\n\n /** Whether the value is typed rather than only picked. */\n get isSegmented(): boolean {\n return this.args.isEditable ?? true;\n }\n\n /**\n * The format the segments are built from. The editable default is numeric;\n * `{ dateStyle: 'medium' }` -- this component's own button default --\n * renders \"Jan\" and has no numeric segment to type into, so a textual\n * format falls back to the numeric default rather than rendering a field\n * nobody can type in.\n */\n get segmentFormat(): Intl.DateTimeFormatOptions | undefined {\n // Only the month is replaced; any other field the consumer named stands.\n return resolveSegmentFormat(this.args.formatOptions, {\n message:\n 'An editable <DatePicker> needs numeric segments; ' +\n 'a textual @formatOptions month falls back to a numeric one. ' +\n 'Pass @isEditable={{false}} for the formatted button trigger.',\n id: 'frontile.date-picker.textual-format'\n });\n }\n\n get placeholderValue(): Date {\n return this.args.placeholderValue ?? new Date();\n }\n\n /** The time segments the field adds to the date, if any. */\n @cached\n get timeOptions(): TimeOptions {\n return {\n granularity: this.args.granularity,\n hourCycle: this.args.hourCycle\n };\n }\n\n get hasTime(): boolean {\n return (this.args.granularity ?? 'day') !== 'day';\n }\n\n get mode(): M {\n return (this.args as { mode?: M }).mode ?? ('single' as M);\n }\n\n get locale(): string {\n return this.args.locale ?? navigator.language;\n }\n\n /**\n * The rendered value is always internal state, never a read-through to\n * `@value`; {@link syncValue} pushes `@value` into it whenever the argument\n * changes. This is the pattern `Select` uses, and reading through instead\n * deadlocks the component inside a `Form`: `Field` binds `@value` to the\n * form's data, the form's data comes from hidden inputs this component\n * renders, and those inputs would then render the very value they source.\n * Nothing could ever change it, so every pick after the first submit was\n * silently discarded.\n */\n get value(): CalendarValue<M> | null {\n return this.internalValue;\n }\n\n /** Normalizes whatever `@value` / `@defaultValue` was given to `Date`s. */\n private parseIncoming(raw: unknown): CalendarValue<M> | null {\n if (this.mode === 'range') {\n return parseRange(raw as never) as CalendarValue<M> | null;\n }\n return parseDate(raw as never) as CalendarValue<M> | null;\n }\n\n /**\n * Pushes `@value` into internal state when the argument changes. `undefined`\n * is ignored so that an uncontrolled picker -- and one bound by `Field`\n * before the form holds anything for it -- keeps whatever the user chose.\n */\n syncValue = modifier((_: HTMLDivElement, [raw]: [unknown]) => {\n if (raw === undefined) return;\n\n const parsed = this.parseIncoming(raw);\n this.internalValue = parsed;\n // The segments are a second rendering of the same value, so an argument\n // change has to reach them too; without this a `@value`-controlled picker\n // shows empty segments. `#currentParts` rather than `this.parts` -- see\n // the field's own comment.\n //\n // Unless the argument is merely the echo of our own `@onChange`: a\n // controlled consumer writes back what we just reported, and rewriting the\n // segments from it would destroy a partial entry. Backspacing one digit of\n // the year un-commits it, so the field composes `null`, reports `null`, and\n // is handed `null` straight back -- and `writeParts` would spend that on\n // clearing every other segment, both groups in range mode. One keystroke\n // would empty the field.\n if (this.isSegmented && this.segmentsWouldChange(parsed)) {\n this.writeParts(parsed, (edge) =>\n edge === 'start' ? this.#currentParts : this.#currentEndParts\n );\n }\n });\n\n /**\n * Rebuilds the segment order when the locale or format changes, carrying the\n * current value across so switching en-US to en-GB reorders the field\n * without emptying it. Reads no tracked state, so it runs on an argument\n * change and never on a keystroke.\n */\n syncSegmentFormat = modifier(\n (\n _: HTMLDivElement,\n [locale, format, time]: [\n string,\n Intl.DateTimeFormatOptions | undefined,\n TimeOptions\n ]\n ) => {\n if (!this.isSegmented) return;\n\n // One `Intl.DateTimeFormat` for both edges: the arguments are identical,\n // and the constructor is the expensive part. `carryOver` copies rather\n // than mutates, so the two groups cannot share structure by accident.\n const fresh = buildParts(locale, format, time);\n\n // Segment by segment rather than through the composed value, so a\n // half-typed entry survives the rebuild.\n this.setParts(carryOver(fresh, this.#currentParts));\n if (this.isRangeMode) {\n this.setEndParts(carryOver(fresh, this.#currentEndParts));\n }\n }\n );\n\n get formatted(): string {\n return formatValue(\n this.value,\n this.locale,\n this.args.formatOptions ??\n (this.hasTime ? DEFAULT_TIME_FORMAT : undefined)\n );\n }\n\n get isEmpty(): boolean {\n return isEmptyValue(this.value);\n }\n\n @cached\n get valueBlockArg(): DatePickerValueBlockArg<M> {\n return {\n value: this.value,\n formatted: this.formatted,\n isEmpty: this.isEmpty\n };\n }\n\n /**\n * Names the trigger when a `:value` block owns its content. Falls back to\n * the formatted value alone rather than prefixing a hardcoded English\n * string when there is no `@label`. `undefined` (not `''`) when neither is\n * present, so the trigger omits `aria-label` entirely rather than setting\n * it to an empty string -- some assistive tech treats a present-but-empty\n * `aria-label` as overriding the visible text with nothing, leaving the\n * button unnamed.\n */\n get accessibleName(): string | undefined {\n const name = [this.args.label, this.formatted].filter(Boolean).join(', ');\n return name === '' ? undefined : name;\n }\n\n /**\n * Reports focus leaving the *whole* control -- the field and its portaled\n * popover -- rather than the trigger, which blurs on the way into the\n * calendar and on every day click.\n */\n blurTracker = new ControlBlurTracker({\n // Resolved through whichever element the popover's `trigger` modifier sits\n // on, because the tracker finds the portaled content by that element's\n // `aria-controls`. On the segmented path there is no button trigger: the\n // calendar button in the end content opens the popover instead, and\n // pointing this at nothing would make a click into the open calendar read\n // as a blur.\n trigger: () =>\n this.triggerRef.current ??\n this.containerRef.current?.querySelector<HTMLElement>(\n '[data-part=\"calendar-button\"]'\n ),\n container: () => this.containerRef.current,\n isOpen: () => this.isOpen,\n isDestroyed: () => this.isDestroyed || this.isDestroying,\n onBlur: () => this.args.onBlur?.()\n });\n\n willDestroy(): void {\n super.willDestroy();\n // Nothing may resolve against a destroyed component.\n this.blurTracker.cancel();\n }\n\n /**\n * Whether the clear button takes the calendar icon's place. A disabled or\n * read-only field never shows it: the end-content cluster is not\n * pointer-transparent to it and it carries no disabled/read-only state of\n * its own, so it would otherwise be a live button that clears a field the\n * user may not change -- the same contract `Calendar` enforces for day\n * selection under `@isReadOnly`.\n */\n get isClearable(): boolean {\n return (\n Boolean(this.args.isClearable) &&\n !this.isEmpty &&\n !this.args.isDisabled &&\n !this.args.isReadOnly\n );\n }\n\n /**\n * Clearing removes the clear button from the DOM (`isClearable` flips\n * false the instant the value is gone), so -- like `close()` -- focus must\n * be handed back to the trigger explicitly or it falls to `<body>`.\n *\n * Unlike `close()`, clearing deliberately leaves an open popover open: the\n * clear button lives outside the popover entirely, so there is no\n * dangling-focus reason to dismiss the calendar, and a user who just\n * cleared the field is a user who likely wants to pick a new date right\n * away -- closing would just make them reopen it.\n */\n clear = (): void => {\n this.commitValue(null, { writeParts: true });\n this.focusField();\n };\n\n /**\n * Whatever the field's own focusable thing is: the button trigger, or --\n * when segmented -- the segment the user was last in, falling back to the\n * first one. A recorded segment that has left the DOM is not one focus can\n * go back to.\n */\n private focusTarget(): HTMLElement | null | undefined {\n if (!this.isSegmented) return this.triggerRef.current;\n\n const last = this.lastFocusedSegment;\n if (last && last.isConnected) return last;\n\n return this.containerRef.current?.querySelector<HTMLElement>(\n '[data-part=\"segment\"]'\n );\n }\n\n private focusField(): void {\n this.focusTarget()?.focus();\n }\n\n /**\n * Whether the selection is finished, and the popover should therefore close.\n * A range with only its anchor set is not: the user still owes a second\n * click, and closing would throw away the half they just made.\n */\n private isComplete(value: CalendarValue<M> | null): boolean {\n if (!value) return false;\n if (this.mode !== 'range') return true;\n return (value as DateRange).end !== null;\n }\n\n /**\n * The one path a value change takes, whichever editor produced it.\n *\n * `writeParts` says whether the segments are that editor's output or its\n * input. The calendar, the `:footer` block and the clear button are all\n * *other* editors, and the segments have to be rewritten to show what they\n * did. Typing is the segments themselves: rewriting them there would\n * overwrite the buffer the user is still typing into, turning a half-typed\n * year back into a padded one on every completed keystroke.\n */\n private commitValue(\n value: CalendarValue<M> | null,\n { writeParts }: { writeParts: boolean }\n ): void {\n // Internal state updates even when controlled, so the calendar's own\n // rendering stays responsive; the `value` getter ignores it in that case,\n // so the consumer still has the last word.\n this.internalValue = value;\n\n if (writeParts && this.isSegmented) {\n this.writeParts(value, (edge) =>\n edge === 'start' ? this.#currentParts : this.#currentEndParts\n );\n }\n\n (\n this.args.onChange as ((v: CalendarValue<M> | null) => void) | undefined\n )?.(value);\n this.notifyForm();\n }\n\n handleChange = (value: CalendarValue<M>): void => {\n this.commitValue(value, { writeParts: true });\n\n if (this.isComplete(value)) this.close();\n };\n\n /**\n * A day picked in the calendar. The calendar knows days only, so under an\n * `hour` or `minute` granularity the pick takes the time the field already\n * shows -- each end of a range its own -- or midnight when there is none.\n */\n handleCalendarChange = (value: CalendarValue<M>): void => {\n if (!this.hasTime || !value) {\n this.handleChange(value);\n return;\n }\n\n if (!this.isRangeMode) {\n this.handleChange(\n withTimeOf(value as Date, this.timeAt('start')) as never\n );\n return;\n }\n\n const range = value as DateRange;\n this.handleChange({\n start: withTimeOf(range.start, this.timeAt('start')),\n end: range.end ? withTimeOf(range.end, this.timeAt('end')) : null\n } as never);\n };\n\n /**\n * The time one end of the field holds: what its segments show -- typed in\n * even before any day was -- or, on the button trigger, which has no\n * segments, the current value's. Midnight when there is none.\n */\n private timeAt(edge: 'start' | 'end'): { hours: number; minutes: number } {\n const midnight = { hours: 0, minutes: 0 };\n\n if (this.isSegmented) {\n const parts =\n edge === 'start' ? this.#currentParts : this.#currentEndParts;\n return timeOf(parts) ?? midnight;\n }\n\n const value = this.value;\n const date = this.isRangeMode\n ? (value as DateRange | null)?.[edge]\n : (value as Date | null);\n return date\n ? { hours: date.getHours(), minutes: date.getMinutes() }\n : midnight;\n }\n\n /**\n * Whether an incoming value differs from what the segments already compose.\n *\n * Compared edge by edge in range mode rather than by identity: the two are\n * distinct objects on every report, so an object comparison would always\n * say \"changed\" and defeat the guard entirely.\n */\n private segmentsWouldChange(incoming: CalendarValue<M> | null): boolean {\n if (!this.isRangeMode) {\n return hasDateChanged(\n toDate(this.#currentParts),\n incoming as Date | null\n );\n }\n\n const composed = this.rangeFromParts();\n const next = incoming as DateRange | null;\n\n return (\n hasDateChanged(composed?.start ?? null, next?.start ?? null) ||\n hasDateChanged(composed?.end ?? null, next?.end ?? null)\n );\n }\n\n /**\n * The segments changed. Only value *transitions* are reported: the four\n * keystrokes that fill a month and a day compose no date at all, and report\n * nothing. The popover is deliberately left alone -- typing never opened it,\n * so completing a date by typing has nothing to close.\n */\n handlePartsChange = (parts: Part[]): void => {\n const before = toDate(this.#currentParts);\n this.setParts(parts);\n const after = toDate(parts);\n\n if (!hasDateChanged(before, after)) return;\n\n this.commitValue(after as CalendarValue<M> | null, { writeParts: false });\n };\n\n /**\n * The two range groups report separately, but a range is one value: each\n * one recomposes the whole thing and reports only what moved.\n */\n handleStartParts = (parts: Part[]): void => {\n const before = this.rangeFromParts();\n this.setParts(parts);\n this.reportRange(before);\n };\n\n handleEndParts = (parts: Part[]): void => {\n const before = this.rangeFromParts();\n this.setEndParts(parts);\n this.reportRange(before);\n };\n\n /** Two dates pasted into the start group, which fill both. */\n handleRangePaste = (start: Part[], end: Part[]): void => {\n const before = this.rangeFromParts();\n this.setParts(start);\n this.setEndParts(end);\n this.reportRange(before);\n };\n\n /**\n * The range the two groups currently compose, or `null`.\n *\n * `DateRange.start` is a `Date`, not `Date | null`: a range is anchored at\n * its start, and the half-open shape the calendar produces mid-selection is\n * `{ start, end: null }` -- never the other way round. So segments that\n * compose no start compose no range at all, however complete the end group\n * is. That is what makes clearing the start report `null` rather than\n * leaving a consumer holding a range the field no longer shows; the end's\n * digits stay on screen, exactly as a half-typed single date's do.\n */\n private rangeFromParts(): DateRange | null {\n const start = toDate(this.#currentParts);\n if (!start) return null;\n\n return { start, end: toDate(this.#currentEndParts) };\n }\n\n /**\n * Reports the range only if it moved, which is the single-mode contract\n * applied to two ends: the keystrokes that fill a month and a day compose\n * nothing and report nothing, and either end changing is a change.\n */\n private reportRange(before: DateRange | null): void {\n const after = this.rangeFromParts();\n\n const moved =\n hasDateChanged(before?.start ?? null, after?.start ?? null) ||\n hasDateChanged(before?.end ?? null, after?.end ?? null);\n if (!moved) return;\n\n this.commitValue(after as CalendarValue<M> | null, { writeParts: false });\n }\n\n /**\n * The start and end groups' accessible names. Two `role=\"group\"`s cannot\n * share one id or one name, and `FormControl`'s label can only be\n * associated with one element -- so each group names itself, deriving from\n * `@label` so that the visible label is contained in both names.\n */\n get startLabel(): string {\n return this.args.label ? `${this.args.label} start` : 'start date';\n }\n\n get endLabel(): string {\n return this.args.label ? `${this.args.label} end` : 'end date';\n }\n\n /**\n * The segment that last held focus, so that closing the calendar can hand\n * focus back to where the user was. Recorded from the group's `focusin`\n * rather than captured when the popover opens, because the calendar button\n * is clicked *after* focus has already left the segment.\n */\n private lastFocusedSegment: HTMLElement | null = null;\n\n handleSegmentFocusIn = (event: FocusEvent): void => {\n const target = event.target;\n if (\n target instanceof HTMLElement &&\n target.getAttribute('data-part') === 'segment'\n ) {\n this.lastFocusedSegment = target;\n }\n };\n\n /**\n * Tells an enclosing `Form` the value moved.\n *\n * The hidden inputs are written programmatically, and a programmatic value\n * change fires no `input` event -- so without this the form never learns\n * anything happened. That is worse than stale data: as soon as `Form` holds\n * any data for this field, `Field` binds `@value` back to it -- so without\n * this the form's copy of the value silently diverges from the field's, and\n * a later `@data` change would sync the stale value back in. `Select`\n * dispatches the same event for the same reason.\n */\n private notifyForm(): void {\n triggerFormInputEvent(this.containerRef.current);\n }\n\n /**\n * Wired to the popover's `@onOpenChange`, which also fires for Escape and\n * an outside click -- not only the explicit paths that already call\n * `close()` below. Routing every close through `close()` matters because\n * `Overlay`'s own focus-restore captures `document.activeElement` at the\n * moment its content mounts, which by then is already the day `@autofocus`\n * moved focus onto (that modifier runs before the overlay's own), not the\n * trigger. Left to it, closing would try to restore focus onto a day\n * button that has just been removed from the DOM -- a no-op -- and focus\n * would fall to `<body>`.\n */\n onOpenChange = (isOpen: boolean): void => {\n if (isOpen) {\n this.isOpen = true;\n return;\n }\n this.close();\n };\n\n /**\n * Closing removes the focused day from the DOM, so focus must be handed back\n * explicitly or it falls to `<body>` and the keyboard user loses their place.\n */\n close = (): void => {\n this.isOpen = false;\n this.focusField();\n };\n\n @cached\n get classes() {\n const { datePicker } = useStyles();\n return datePicker({\n size: this.args.inputSize,\n isSegmented: this.isSegmented,\n isRange: this.isSegmented && this.isRangeMode\n });\n }\n\n get isRangeMode(): boolean {\n return this.mode === 'range';\n }\n\n /**\n * The segmented field has no button trigger for a click to fall through to,\n * and its calendar icon is a real button, so the cluster has to take pointer\n * events. An explicit argument still wins.\n */\n get endContentPointerEvents(): 'none' | 'auto' {\n return (\n this.args.endContentPointerEvents ?? (this.isSegmented ? 'auto' : 'none')\n );\n }\n\n /**\n * The single-mode wire value, or `''` when there is nothing selected. Only\n * read from the single-mode branch of the template, so it does not repeat\n * that branch's mode check.\n */\n get wireValue(): string {\n return toWire(this.value as Date | null, this.args.granularity);\n }\n\n get wireRangeStart(): string {\n return toWire(\n (this.value as DateRange | null)?.start ?? null,\n this.args.granularity\n );\n }\n\n get wireRangeEnd(): string {\n return toWire(\n (this.value as DateRange | null)?.end ?? null,\n this.args.granularity\n );\n }\n\n @cached\n get calendarBlockArg(): DatePickerCalendarArgs<M> {\n return {\n mode: this.mode,\n color: this.args.color,\n value: this.value,\n onChange: this.handleCalendarChange,\n locale: this.locale,\n weekStartsOn: this.args.weekStartsOn,\n minValue: this.args.minValue,\n maxValue: this.args.maxValue,\n isDateUnavailable: this.args.isDateUnavailable,\n visibleMonths: this.args.visibleMonths,\n captionLayout: this.args.captionLayout,\n labelledBy: this.args.id,\n autofocus: true\n };\n }\n\n @cached\n get footerBlockArg(): DatePickerFooterArg<M> {\n return {\n // Deliberately `handleChange`, not a bare assignment: a preset must be\n // indistinguishable from a click, so it fires `@onChange` and closes on\n // a complete value exactly the way picking a day does.\n setValue: this.handleChange,\n close: this.close,\n value: this.value,\n isOpen: this.isOpen\n };\n }\n\n <template>\n <div\n {{this.syncSegmentFormat this.locale this.segmentFormat this.timeOptions}}\n {{this.syncValue @value}}\n {{this.containerRef.setup}}\n class={{this.classes.base class=@classes.base}}\n data-component=\"date-picker\"\n data-part=\"base\"\n ...attributes\n >\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\n type=\"hidden\"\n name={{concat @name \".start\"}}\n value={{this.wireRangeStart}}\n />\n <input\n type=\"hidden\"\n name={{concat @name \".end\"}}\n value={{this.wireRangeEnd}}\n />\n {{else}}\n <input type=\"hidden\" name={{@name}} value={{this.wireValue}} />\n {{/if}}\n {{/if}}\n <FormControl\n @id={{@id}}\n @size={{@inputSize}}\n @label={{@label}}\n @isRequired={{@isRequired}}\n @description={{@description}}\n @errors={{@errors}}\n @isInvalid={{@isInvalid}}\n @isDisabled={{@isDisabled}}\n as |c|\n >\n <Popover\n @placement={{@placement}}\n @flipOptions={{@flipOptions}}\n @middleware={{@middleware}}\n @shiftOptions={{@shiftOptions}}\n @offsetOptions={{@offsetOptions}}\n @strategy={{@strategy}}\n @didClose={{@didClose}}\n @isOpen={{this.isOpen}}\n @onOpenChange={{this.onOpenChange}}\n as |p|\n >\n <div\n {{p.anchor}}\n class={{this.classes.innerContainer class=@classes.innerContainer}}\n data-part=\"inner-container\"\n {{! 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. }}\n data-invalid={{if c.isInvalid \"true\" \"false\"}}\n data-disabled={{if @isDisabled \"true\" \"false\"}}\n >\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\n @parts={{this.parts}}\n @onPartsChange={{this.handleStartParts}}\n @onRangePaste={{this.handleRangePaste}}\n @locale={{this.locale}}\n @placeholderValue={{this.placeholderValue}}\n @isDisabled={{@isDisabled}}\n @isReadOnly={{@isReadOnly}}\n @isInvalid={{c.isInvalid}}\n @id={{concat c.id \"-start\"}}\n @label={{this.startLabel}}\n @describedBy={{c.describedBy @description c.isInvalid}}\n @segmentLabels={{@segmentLabels}}\n @classes={{this.classes}}\n @userClasses={{@classes}}\n {{on \"focusin\" this.handleSegmentFocusIn}}\n {{on \"focusout\" this.blurTracker.handleFocusOut}}\n />\n <span\n data-part=\"separator\"\n aria-hidden=\"true\"\n class={{this.classes.separator class=@classes.separator}}\n >–</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\n @parts={{this.endParts}}\n @onPartsChange={{this.handleEndParts}}\n @locale={{this.locale}}\n @placeholderValue={{this.placeholderValue}}\n @isDisabled={{@isDisabled}}\n @isReadOnly={{@isReadOnly}}\n @isInvalid={{c.isInvalid}}\n @id={{concat c.id \"-end\"}}\n @label={{this.endLabel}}\n @describedBy={{c.describedBy @description c.isInvalid}}\n @segmentLabels={{@segmentLabels}}\n @classes={{this.classes}}\n @userClasses={{@classes}}\n {{on \"focusin\" this.handleSegmentFocusIn}}\n {{on \"focusout\" this.blurTracker.handleFocusOut}}\n />\n {{else}}\n <SegmentGroup\n @parts={{this.parts}}\n @onPartsChange={{this.handlePartsChange}}\n @locale={{this.locale}}\n @placeholderValue={{this.placeholderValue}}\n @isDisabled={{@isDisabled}}\n @isReadOnly={{@isReadOnly}}\n @isInvalid={{c.isInvalid}}\n @id={{c.id}}\n @label={{@label}}\n @describedBy={{c.describedBy @description c.isInvalid}}\n @segmentLabels={{@segmentLabels}}\n @classes={{this.classes}}\n @userClasses={{@classes}}\n {{on \"focusin\" this.handleSegmentFocusIn}}\n {{on \"focusout\" this.blurTracker.handleFocusOut}}\n />\n {{/if}}\n {{else}}\n <DatePickerTrigger\n @id={{c.id}}\n @trigger={{p.trigger}}\n @placeholder={{@placeholder}}\n @formatted={{this.formatted}}\n @isEmpty={{this.isEmpty}}\n @isDisabled={{@isDisabled}}\n @isInvalid={{c.isInvalid}}\n @hasCustomContent={{has-block \"value\"}}\n @accessibleName={{this.accessibleName}}\n @triggerRef={{this.triggerRef.setup}}\n @classes={{this.classes}}\n @userClasses={{@classes}}\n @onFocusOut={{this.blurTracker.handleFocusOut}}\n >\n <:value>\n {{#if (has-block \"value\")}}\n {{yield this.valueBlockArg to=\"value\"}}\n {{/if}}\n </:value>\n </DatePickerTrigger>\n {{/if}}\n\n <DatePickerEndContent\n @classes={{this.classes}}\n @userClasses={{@classes}}\n @endContentPointerEvents={{this.endContentPointerEvents}}\n @isClearable={{this.isClearable}}\n @onClear={{this.clear}}\n @isEditable={{this.isSegmented}}\n @trigger={{p.trigger}}\n @label={{@label}}\n @isDisabled={{@isDisabled}}\n />\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\n @size={{if @popoverSize @popoverSize \"auto\"}}\n @target={{@target}}\n @renderInPlace={{@renderInPlace}}\n @closeOnOutsideClick={{@closeOnOutsideClick}}\n @closeOnEscapeKey={{@closeOnEscapeKey}}\n @transitionDuration={{@transitionDuration}}\n @disableTransitions={{@disableTransitions}}\n @blockScroll={{false}}\n @preventAutoFocus={{true}}\n {{! 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. }}\n @preventFocusRestore={{this.isSegmented}}\n role=\"dialog\"\n aria-label={{@label}}\n >\n {{#if (has-block \"calendar\")}}\n {{yield this.calendarBlockArg to=\"calendar\"}}\n {{else}}\n <Calendar\n @mode={{this.mode}}\n @color={{@color}}\n @value={{this.value}}\n @onChange={{this.handleCalendarChange}}\n @locale={{@locale}}\n @weekStartsOn={{@weekStartsOn}}\n @minValue={{@minValue}}\n @maxValue={{@maxValue}}\n @isDateUnavailable={{@isDateUnavailable}}\n @visibleMonths={{@visibleMonths}}\n @captionLayout={{@captionLayout}}\n @fixedWeeks={{@fixedWeeks}}\n @showOutsideDays={{@showOutsideDays}}\n @isReadOnly={{@isReadOnly}}\n @isDisabled={{@isDisabled}}\n @labelledBy={{c.id}}\n @autofocus={{true}}\n @classes={{hash\n base=(this.classes.calendar class=@classes.calendar)\n }}\n data-part=\"calendar\"\n />\n {{/if}}\n\n {{#if (has-block \"footer\")}}\n <div\n data-part=\"footer\"\n class={{this.classes.footer class=@classes.footer}}\n >\n {{yield this.footerBlockArg to=\"footer\"}}\n </div>\n {{/if}}\n </p.Content>\n </Popover>\n </FormControl>\n </div>\n </template>\n}\n\nexport { DatePicker, type DatePickerSignature };\nexport default DatePicker;\n"],"names":["DatePicker","Component","triggerRef","ref","containerRef","g","prototype","tracked","i","constructor","owner","args","seed","defaultValue","undefined","internalValue","parseIncoming","writeParts","buildParts","locale","segmentFormat","timeOptions","parts","trackedParts","endParts","trackedEndParts","setParts","setEndParts","value","onto","isRangeMode","fromDate","range","start","end","isSegmented","isEditable","resolveSegmentFormat","formatOptions","message","id","placeholderValue","Date","granularity","hourCycle","n","cached","hasTime","mode","navigator","language","raw","parseRange","parseDate","syncValue","modifier","_","parsed","segmentsWouldChange","edge","syncSegmentFormat","format","time","fresh","carryOver","formatted","formatValue","DEFAULT_TIME_FORMAT","isEmpty","isEmptyValue","valueBlockArg","accessibleName","name","label","filter","Boolean","join","blurTracker","ControlBlurTracker","trigger","current","querySelector","container","isOpen","isDestroyed","isDestroying","onBlur","willDestroy","cancel","isClearable","isDisabled","isReadOnly","clear","commitValue","focusField","focusTarget","last","lastFocusedSegment","isConnected","focus","isComplete","onChange","notifyForm","handleChange","close","handleCalendarChange","withTimeOf","timeAt","midnight","hours","minutes","timeOf","date","getHours","getMinutes","incoming","hasDateChanged","toDate","composed","rangeFromParts","next","handlePartsChange","before","after","handleStartParts","reportRange","handleEndParts","handleRangePaste","moved","startLabel","endLabel","handleSegmentFocusIn","event","target","HTMLElement","getAttribute","triggerFormInputEvent","onOpenChange","classes","datePicker","useStyles","size","inputSize","isRange","endContentPointerEvents","wireValue","toWire","wireRangeStart","wireRangeEnd","calendarBlockArg","color","weekStartsOn","minValue","maxValue","isDateUnavailable","visibleMonths","captionLayout","labelledBy","autofocus","footerBlockArg","setValue","setComponentTemplate","precompileTemplate","strictMode","scope","concat","FormControl","Popover","SegmentGroup","on","DatePickerTrigger","DatePickerEndContent","Calendar","hash"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwDA;;;;;;;AAOC;AACD,MAAMA,UAAA,SAAsDC,UACtC;EAEpBC,UAAA,GAAaC,KAAI;EACjBC,YAAA,GAAeD,KAAI;AAEnB;;;;;;AAMC;AAND,EAAA;IAAAE,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,eAAA,EAAA,CAOCC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAiD,IAAA;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,cAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,eAAA,CAAA,EAAA,MAAA;AAAA,EAAA;IAAAH,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CAEjDC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAiB,KAAA;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,OAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,QAAA,CAAA,EAAA,MAAA;AAAA,EAAA;IAAAH,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CASjBC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAuC,EAAE;AAAA,IAAA,CAAA,CAAA;AAAA;EA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../buttons/close-button.js';
|
|
2
3
|
import { e as IconCalendar } from '../../../icons-DZ61nCzv.js';
|
|
3
4
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
@@ -5,14 +6,26 @@ import { setComponentTemplate } from '@ember/component';
|
|
|
5
6
|
import templateOnly from '@ember/component/template-only';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
|
-
* The cluster at the end of the field
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* The cluster at the end of the field.
|
|
10
|
+
*
|
|
11
|
+
* The segmented field shows the clear button *and* the calendar button: the
|
|
12
|
+
* calendar button is the only way to open the popover on that path, so
|
|
13
|
+
* swapping it out for a clear button would mean a clearable picker holding a
|
|
14
|
+
* value could not be picked from at all.
|
|
15
|
+
*
|
|
16
|
+
* The button-trigger path keeps the either/or it shipped with. There the
|
|
17
|
+
* trigger itself opens the popover and the calendar icon is decorative, so the
|
|
18
|
+
* clear button takes its place with nothing lost.
|
|
19
|
+
*
|
|
20
|
+
* Pointer events are off on that path so a click anywhere in the field still
|
|
21
|
+
* reaches the trigger; the clear button opts back in per element, and the
|
|
22
|
+
* segmented field turns them on for the whole cluster.
|
|
11
23
|
*/
|
|
12
|
-
const DatePickerEndContent = setComponentTemplate(precompileTemplate("<div data-part=\"end-content\" class={{@classes.endContent class=@userClasses.endContent endContentPointerEvents=(if @endContentPointerEvents @endContentPointerEvents \"none\")}} ...attributes>\n {{#if @isClearable}}\n <CloseButton @title=\"Clear\" @variant=\"soft\" @size=\"xs\" @class={{@classes.clearButton class=@userClasses.clearButton}} data-part=\"clear-button\" @onPress={{@onClear}} />\n {{else}}\n <IconCalendar data-part=\"icon\" class={{@classes.icon class=@userClasses.icon}} />\n {{/if}}\n</div>", {
|
|
24
|
+
const DatePickerEndContent = setComponentTemplate(precompileTemplate("<div data-part=\"end-content\" class={{@classes.endContent class=@userClasses.endContent endContentPointerEvents=(if @endContentPointerEvents @endContentPointerEvents \"none\")}} ...attributes>\n {{#if @isClearable}}\n <CloseButton @title=\"Clear\" @variant=\"soft\" @size=\"xs\" @class={{@classes.clearButton class=@userClasses.clearButton}} data-part=\"clear-button\" @onPress={{@onClear}} />\n {{/if}}\n\n {{#if @isEditable}}\n <button type=\"button\" data-part=\"calendar-button\" aria-haspopup=\"dialog\" aria-label={{if @label (concat \"Choose date, \" @label) \"Choose date\"}} disabled={{@isDisabled}} class={{@classes.calendarButton class=@userClasses.calendarButton}} {{@trigger}}>\n <IconCalendar data-part=\"icon\" class={{@classes.icon class=@userClasses.icon}} />\n </button>\n {{else}}\n {{!-- On the button-trigger path the icon is decorative and the clear\n button takes its place, so it only renders when there is no clear\n button to show. --}}\n {{#unless @isClearable}}\n <IconCalendar data-part=\"icon\" class={{@classes.icon class=@userClasses.icon}} />\n {{/unless}}\n {{/if}}\n</div>", {
|
|
13
25
|
strictMode: true,
|
|
14
26
|
scope: () => ({
|
|
15
27
|
CloseButton,
|
|
28
|
+
concat,
|
|
16
29
|
IconCalendar
|
|
17
30
|
})
|
|
18
31
|
}), templateOnly());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"end-content.js","sources":["../../../../src/components/forms/date-picker/end-content.gts"],"sourcesContent":["import type { TOC } from '@ember/component/template-only';\nimport type { SlotsToClasses, DatePickerSlots } from '@frontile/theme';\nimport type { DatePickerClasses } from './types';\nimport { CloseButton } from '../../buttons/close-button';\nimport { IconCalendar } from '../../../-private/icons';\n\ninterface DatePickerEndContentSignature {\n Args: {\n classes: DatePickerClasses;\n userClasses?: SlotsToClasses<DatePickerSlots>;\n isClearable: boolean;\n onClear: () => void;\n\n /**\n * Defaults to `none` so clicks fall through to the trigger; content that\n * needs its own events opts back in per element.\n *\n * The theme declares no default for this variant, so leaving it unset\n * yields neither class and the browser default (`auto`) wins -- which\n * makes the cluster sit over the right edge of the field and swallow\n * clicks on the calendar icon.\n */\n endContentPointerEvents?: 'none' | 'auto';\n };\n Element: HTMLDivElement;\n}\n\n/**\n * The cluster at the end of the field:
|
|
1
|
+
{"version":3,"file":"end-content.js","sources":["../../../../src/components/forms/date-picker/end-content.gts"],"sourcesContent":["import type { TOC } from '@ember/component/template-only';\nimport { concat } from '@ember/helper';\nimport type { ModifierLike } from '@glint/template';\nimport type { SlotsToClasses, DatePickerSlots } from '@frontile/theme';\nimport type { DatePickerClasses } from './types';\nimport { CloseButton } from '../../buttons/close-button';\nimport { IconCalendar } from '../../../-private/icons';\n\ninterface DatePickerEndContentSignature {\n Args: {\n classes: DatePickerClasses;\n userClasses?: SlotsToClasses<DatePickerSlots>;\n isClearable: boolean;\n onClear: () => void;\n\n /**\n * Whether the field is segmented. There is no button trigger on that path,\n * so the calendar icon becomes the button that opens the popover -- the\n * one thing a segmented field cannot do by clicking the value itself,\n * because clicking a segment has to put the caret in it.\n */\n isEditable?: boolean;\n\n /**\n * The popover's `trigger` modifier, for the calendar button. Required\n * rather than optional because the calendar button is unreachable without\n * it, and an unapplied modifier is a silent dead control.\n */\n trigger: ModifierLike<{ Element: HTMLElement }>;\n\n /** Names the calendar button, which has no text of its own. */\n label?: string;\n isDisabled?: boolean;\n\n /**\n * Defaults to `none` so clicks fall through to the trigger; content that\n * needs its own events opts back in per element.\n *\n * The theme declares no default for this variant, so leaving it unset\n * yields neither class and the browser default (`auto`) wins -- which\n * makes the cluster sit over the right edge of the field and swallow\n * clicks on the calendar icon.\n */\n endContentPointerEvents?: 'none' | 'auto';\n };\n Element: HTMLDivElement;\n}\n\n/**\n * The cluster at the end of the field.\n *\n * The segmented field shows the clear button *and* the calendar button: the\n * calendar button is the only way to open the popover on that path, so\n * swapping it out for a clear button would mean a clearable picker holding a\n * value could not be picked from at all.\n *\n * The button-trigger path keeps the either/or it shipped with. There the\n * trigger itself opens the popover and the calendar icon is decorative, so the\n * clear button takes its place with nothing lost.\n *\n * Pointer events are off on that path so a click anywhere in the field still\n * reaches the trigger; the clear button opts back in per element, and the\n * segmented field turns them on for the whole cluster.\n */\nconst DatePickerEndContent: TOC<DatePickerEndContentSignature> = <template>\n <div\n data-part=\"end-content\"\n class={{@classes.endContent\n class=@userClasses.endContent\n endContentPointerEvents=(if\n @endContentPointerEvents @endContentPointerEvents \"none\"\n )\n }}\n ...attributes\n >\n {{#if @isClearable}}\n <CloseButton\n @title=\"Clear\"\n @variant=\"soft\"\n @size=\"xs\"\n @class={{@classes.clearButton class=@userClasses.clearButton}}\n data-part=\"clear-button\"\n @onPress={{@onClear}}\n />\n {{/if}}\n\n {{#if @isEditable}}\n <button\n type=\"button\"\n data-part=\"calendar-button\"\n aria-haspopup=\"dialog\"\n aria-label={{if @label (concat \"Choose date, \" @label) \"Choose date\"}}\n disabled={{@isDisabled}}\n class={{@classes.calendarButton class=@userClasses.calendarButton}}\n {{@trigger}}\n >\n <IconCalendar\n data-part=\"icon\"\n class={{@classes.icon class=@userClasses.icon}}\n />\n </button>\n {{else}}\n {{! On the button-trigger path the icon is decorative and the clear\n button takes its place, so it only renders when there is no clear\n button to show. }}\n {{#unless @isClearable}}\n <IconCalendar\n data-part=\"icon\"\n class={{@classes.icon class=@userClasses.icon}}\n />\n {{/unless}}\n {{/if}}\n </div>\n</template>;\n\nexport { DatePickerEndContent, type DatePickerEndContentSignature };\n"],"names":["DatePickerEndContent","setComponentTemplate","precompileTemplate","strictMode","scope","CloseButton","concat","IconCalendar","templateOnly"],"mappings":";;;;;;;AAgDA;;;;;;;;;;;;;;;AAeC;AACD,MAAMA,oBAA0B,GAAAC,oBAAA,CAAiCC,kBAAA,CAAA,qoCAAA,EAiDjE;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,WAAA;IAAAC,MAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA;;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { fromDayKey, toDayKey } from '../../collections/calendar/utils.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* A date as accepted from a consumer: a `Date`, or the same `yyyy-MM-dd`
|
|
5
|
-
* string this component writes to its
|
|
4
|
+
* A date as accepted from a consumer: a `Date`, or the same `yyyy-MM-dd` (or,
|
|
5
|
+
* with a time, local `yyyy-MM-ddTHH:mm`) string this component writes to its
|
|
6
|
+
* hidden inputs.
|
|
6
7
|
*
|
|
7
8
|
* Strings are accepted because `Field` feeds form data — which is always
|
|
8
9
|
* strings — straight back into `@value`. It also means a value hydrated from
|
|
@@ -12,6 +13,14 @@ import { fromDayKey, toDayKey } from '../../collections/calendar/utils.js';
|
|
|
12
13
|
|
|
13
14
|
const ISO_DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* A day with a local wall-clock time, as `<input type="datetime-local">`
|
|
18
|
+
* writes it: `T` or a space between, seconds optional. No offset -- a time
|
|
19
|
+
* here is the user's own, never converted.
|
|
20
|
+
*/
|
|
21
|
+
const ISO_DATE_TIME = /^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?$/;
|
|
22
|
+
const pad = n => String(n).padStart(2, '0');
|
|
23
|
+
|
|
15
24
|
/**
|
|
16
25
|
* Normalizes one end of a value to a `Date`, or `null` when there is nothing
|
|
17
26
|
* usable there.
|
|
@@ -25,6 +34,13 @@ function parseDate(value) {
|
|
|
25
34
|
if (value instanceof Date) {
|
|
26
35
|
return Number.isNaN(value.getTime()) ? null : value;
|
|
27
36
|
}
|
|
37
|
+
const withTime = ISO_DATE_TIME.exec(value);
|
|
38
|
+
if (withTime?.[1]) {
|
|
39
|
+
const [,, hours, minutes, seconds] = withTime;
|
|
40
|
+
const parsed = fromDayKey(withTime[1]);
|
|
41
|
+
parsed.setHours(Number(hours), Number(minutes), Number(seconds ?? 0));
|
|
42
|
+
return Number.isNaN(parsed.getTime()) ? null : parsed;
|
|
43
|
+
}
|
|
28
44
|
|
|
29
45
|
// `fromDayKey` splits on `-` and would happily turn anything into a Date of
|
|
30
46
|
// NaN parts, so the shape is checked before it is trusted.
|
|
@@ -50,14 +66,36 @@ function parseRange(value) {
|
|
|
50
66
|
};
|
|
51
67
|
}
|
|
52
68
|
|
|
53
|
-
/**
|
|
54
|
-
|
|
69
|
+
/**
|
|
70
|
+
* The value as it is submitted: `yyyy-MM-dd` from local calendar fields, and
|
|
71
|
+
* under an `hour` or `minute` granularity the local `yyyy-MM-ddTHH:mm` that
|
|
72
|
+
* `datetime-local` uses too.
|
|
73
|
+
*/
|
|
74
|
+
function toWire(date, granularity = 'day') {
|
|
55
75
|
if (!date || Number.isNaN(date.getTime())) return '';
|
|
56
|
-
|
|
76
|
+
const day = toDayKey(date);
|
|
77
|
+
if (granularity === 'day') return day;
|
|
78
|
+
return `${day}T${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Copies the wall-clock time of `from` onto the day of `day`. Picking a day in
|
|
83
|
+
* the calendar keeps the time the field already holds.
|
|
84
|
+
*/
|
|
85
|
+
function withTimeOf(day, from) {
|
|
86
|
+
const next = new Date(day);
|
|
87
|
+
next.setHours(from.hours, from.minutes, 0, 0);
|
|
88
|
+
return next;
|
|
57
89
|
}
|
|
58
90
|
const DEFAULT_FORMAT = {
|
|
59
91
|
dateStyle: 'medium'
|
|
60
92
|
};
|
|
93
|
+
|
|
94
|
+
/** The button trigger's default once the value carries a time. */
|
|
95
|
+
const DEFAULT_TIME_FORMAT = {
|
|
96
|
+
dateStyle: 'medium',
|
|
97
|
+
timeStyle: 'short'
|
|
98
|
+
};
|
|
61
99
|
function formatDate(date, locale, options) {
|
|
62
100
|
return new Intl.DateTimeFormat(locale, options ?? DEFAULT_FORMAT).format(date);
|
|
63
101
|
}
|
|
@@ -93,5 +131,5 @@ function isEmptyValue(value) {
|
|
|
93
131
|
return true;
|
|
94
132
|
}
|
|
95
133
|
|
|
96
|
-
export { formatValue, isEmptyValue, parseDate, parseRange, toWire };
|
|
134
|
+
export { DEFAULT_TIME_FORMAT, formatValue, isEmptyValue, parseDate, parseRange, toWire, withTimeOf };
|
|
97
135
|
//# sourceMappingURL=value.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value.js","sources":["../../../../src/components/forms/date-picker/value.ts"],"sourcesContent":["import { toDayKey, fromDayKey } from '../../collections/calendar/utils';\nimport type {\n CalendarMode,\n CalendarValue,\n DateRange\n} from '../../collections/calendar/types';\n\n/**\n * A date as accepted from a consumer: a `Date`, or the same `yyyy-MM-dd`\n * string this component writes to its hidden inputs.\n *\n * Strings are accepted because `Field` feeds form data — which is always\n * strings — straight back into `@value`. It also means a value hydrated from\n * JSON or an API needs no adapter. Output is always a `Date`: strings are an\n * accepted input, never an output mode.\n */\ntype DatePickerInput = Date | string;\n\ninterface DatePickerRangeInput {\n start: DatePickerInput;\n end: DatePickerInput | null;\n}\n\nconst ISO_DAY = /^\\d{4}-\\d{2}-\\d{2}$/;\n\n/**\n * Normalizes one end of a value to a `Date`, or `null` when there is nothing\n * usable there.\n *\n * An `Invalid Date` is treated as absent rather than passed along: it would\n * otherwise reach `Intl.DateTimeFormat` and render the literal text\n * \"Invalid Date\" inside the trigger.\n */\nfunction parseDate(value: DatePickerInput | null | undefined): Date | null {\n if (value === null || value === undefined || value === '') return null;\n\n if (value instanceof Date) {\n return Number.isNaN(value.getTime()) ? null : value;\n }\n\n // `fromDayKey` splits on `-` and would happily turn anything into a Date of\n // NaN parts, so the shape is checked before it is trusted.\n if (!ISO_DAY.test(value)) return null;\n\n const parsed = fromDayKey(value);\n return Number.isNaN(parsed.getTime()) ? null : parsed;\n}\n\n/**\n * Normalizes a range. A `null` end is preserved rather than collapsed — that\n * is a range mid-selection, with its anchor set and the second click pending,\n * and the trigger must still show the anchor.\n */\nfunction parseRange(\n value: DatePickerRangeInput | null | undefined\n): DateRange | null {\n if (!value) return null;\n\n const start = parseDate(value.start);\n // Without a usable start there is no range at all: a `{ start: null }` would\n // not satisfy `DateRange`, whose start is non-nullable.\n if (!start) return null;\n\n return { start, end: parseDate(value.end) };\n}\n\n/** The value as it is submitted: `yyyy-MM-dd`, from local calendar fields. */\nfunction toWire(date: Date | null | undefined): string {\n if (!date || Number.isNaN(date.getTime())) return '';\n return toDayKey(date);\n}\n\nconst DEFAULT_FORMAT: Intl.DateTimeFormatOptions = { dateStyle: 'medium' };\n\nfunction formatDate(\n date: Date,\n locale: string,\n options?: Intl.DateTimeFormatOptions\n): string {\n return new Intl.DateTimeFormat(locale, options ?? DEFAULT_FORMAT).format(\n date\n );\n}\n\nfunction isRange(value: unknown): value is DateRange {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'start' in value &&\n (value as DateRange).start instanceof Date\n );\n}\n\n/**\n * The trigger's text for a value in either mode. An en dash (not a hyphen)\n * joins a range, matching how date ranges are set in running text.\n */\nfunction formatValue<M extends CalendarMode>(\n value: CalendarValue<M> | null | undefined,\n locale: string,\n options?: Intl.DateTimeFormatOptions\n): string {\n if (!value) return '';\n\n if (isRange(value)) {\n const start = formatDate(value.start, locale, options);\n // A half-open range renders as the anchor alone: \"Jan 20, 2026 – \" would\n // read as an unfinished sentence while the user picks the second end.\n if (!value.end) return start;\n return `${start} – ${formatDate(value.end, locale, options)}`;\n }\n\n if (value instanceof Date) return formatDate(value, locale, options);\n\n return '';\n}\n\n/**\n * Whether the trigger should show its placeholder. An anchored range is *not*\n * empty — its start is already chosen and must be visible.\n */\nfunction isEmptyValue(value: unknown): boolean {\n if (value === null || value === undefined) return true;\n if (value instanceof Date) return Number.isNaN(value.getTime());\n if (isRange(value)) return false;\n return true;\n}\n\nexport {\n parseDate,\n parseRange,\n toWire,\n formatValue,\n isEmptyValue,\n type DatePickerInput,\n type DatePickerRangeInput\n};\n"],"names":["ISO_DAY","parseDate","value","undefined","Date","Number","isNaN","getTime","test","parsed","fromDayKey","parseRange","start","end","toWire","date","toDayKey","DEFAULT_FORMAT","dateStyle","formatDate","locale","options","Intl","DateTimeFormat","format","isRange","formatValue","isEmptyValue"],"mappings":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ACC,KAAK,CAACJ,KAAK,CAACK,OAAO,EAAE,CAAC;AAC/D,EAAA,IAAIkB,OAAO,CAACvB,KAAK,CAAC,EAAE,OAAO,KAAK;AAChC,EAAA,OAAO,IAAI;AACb;;"}
|
|
1
|
+
{"version":3,"file":"value.js","sources":["../../../../src/components/forms/date-picker/value.ts"],"sourcesContent":["import { toDayKey, fromDayKey } from '../../collections/calendar/utils';\nimport type { Granularity } from '../date-input/types';\nimport type {\n CalendarMode,\n CalendarValue,\n DateRange\n} from '../../collections/calendar/types';\n\n/**\n * A date as accepted from a consumer: a `Date`, or the same `yyyy-MM-dd` (or,\n * with a time, local `yyyy-MM-ddTHH:mm`) string this component writes to its\n * hidden inputs.\n *\n * Strings are accepted because `Field` feeds form data — which is always\n * strings — straight back into `@value`. It also means a value hydrated from\n * JSON or an API needs no adapter. Output is always a `Date`: strings are an\n * accepted input, never an output mode.\n */\ntype DatePickerInput = Date | string;\n\ninterface DatePickerRangeInput {\n start: DatePickerInput;\n end: DatePickerInput | null;\n}\n\nconst ISO_DAY = /^\\d{4}-\\d{2}-\\d{2}$/;\n\n/**\n * A day with a local wall-clock time, as `<input type=\"datetime-local\">`\n * writes it: `T` or a space between, seconds optional. No offset -- a time\n * here is the user's own, never converted.\n */\nconst ISO_DATE_TIME =\n /^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.\\d+)?)?$/;\n\nconst pad = (n: number): string => String(n).padStart(2, '0');\n\n/**\n * Normalizes one end of a value to a `Date`, or `null` when there is nothing\n * usable there.\n *\n * An `Invalid Date` is treated as absent rather than passed along: it would\n * otherwise reach `Intl.DateTimeFormat` and render the literal text\n * \"Invalid Date\" inside the trigger.\n */\nfunction parseDate(value: DatePickerInput | null | undefined): Date | null {\n if (value === null || value === undefined || value === '') return null;\n\n if (value instanceof Date) {\n return Number.isNaN(value.getTime()) ? null : value;\n }\n\n const withTime = ISO_DATE_TIME.exec(value);\n if (withTime?.[1]) {\n const [, , hours, minutes, seconds] = withTime;\n const parsed = fromDayKey(withTime[1]);\n parsed.setHours(Number(hours), Number(minutes), Number(seconds ?? 0));\n return Number.isNaN(parsed.getTime()) ? null : parsed;\n }\n\n // `fromDayKey` splits on `-` and would happily turn anything into a Date of\n // NaN parts, so the shape is checked before it is trusted.\n if (!ISO_DAY.test(value)) return null;\n\n const parsed = fromDayKey(value);\n return Number.isNaN(parsed.getTime()) ? null : parsed;\n}\n\n/**\n * Normalizes a range. A `null` end is preserved rather than collapsed — that\n * is a range mid-selection, with its anchor set and the second click pending,\n * and the trigger must still show the anchor.\n */\nfunction parseRange(\n value: DatePickerRangeInput | null | undefined\n): DateRange | null {\n if (!value) return null;\n\n const start = parseDate(value.start);\n // Without a usable start there is no range at all: a `{ start: null }` would\n // not satisfy `DateRange`, whose start is non-nullable.\n if (!start) return null;\n\n return { start, end: parseDate(value.end) };\n}\n\n/**\n * The value as it is submitted: `yyyy-MM-dd` from local calendar fields, and\n * under an `hour` or `minute` granularity the local `yyyy-MM-ddTHH:mm` that\n * `datetime-local` uses too.\n */\nfunction toWire(\n date: Date | null | undefined,\n granularity: Granularity = 'day'\n): string {\n if (!date || Number.isNaN(date.getTime())) return '';\n const day = toDayKey(date);\n if (granularity === 'day') return day;\n return `${day}T${pad(date.getHours())}:${pad(date.getMinutes())}`;\n}\n\n/**\n * Copies the wall-clock time of `from` onto the day of `day`. Picking a day in\n * the calendar keeps the time the field already holds.\n */\nfunction withTimeOf(day: Date, from: { hours: number; minutes: number }): Date {\n const next = new Date(day);\n next.setHours(from.hours, from.minutes, 0, 0);\n return next;\n}\n\nconst DEFAULT_FORMAT: Intl.DateTimeFormatOptions = { dateStyle: 'medium' };\n\n/** The button trigger's default once the value carries a time. */\nconst DEFAULT_TIME_FORMAT: Intl.DateTimeFormatOptions = {\n dateStyle: 'medium',\n timeStyle: 'short'\n};\n\nfunction formatDate(\n date: Date,\n locale: string,\n options?: Intl.DateTimeFormatOptions\n): string {\n return new Intl.DateTimeFormat(locale, options ?? DEFAULT_FORMAT).format(\n date\n );\n}\n\nfunction isRange(value: unknown): value is DateRange {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'start' in value &&\n (value as DateRange).start instanceof Date\n );\n}\n\n/**\n * The trigger's text for a value in either mode. An en dash (not a hyphen)\n * joins a range, matching how date ranges are set in running text.\n */\nfunction formatValue<M extends CalendarMode>(\n value: CalendarValue<M> | null | undefined,\n locale: string,\n options?: Intl.DateTimeFormatOptions\n): string {\n if (!value) return '';\n\n if (isRange(value)) {\n const start = formatDate(value.start, locale, options);\n // A half-open range renders as the anchor alone: \"Jan 20, 2026 – \" would\n // read as an unfinished sentence while the user picks the second end.\n if (!value.end) return start;\n return `${start} – ${formatDate(value.end, locale, options)}`;\n }\n\n if (value instanceof Date) return formatDate(value, locale, options);\n\n return '';\n}\n\n/**\n * Whether the trigger should show its placeholder. An anchored range is *not*\n * empty — its start is already chosen and must be visible.\n */\nfunction isEmptyValue(value: unknown): boolean {\n if (value === null || value === undefined) return true;\n if (value instanceof Date) return Number.isNaN(value.getTime());\n if (isRange(value)) return false;\n return true;\n}\n\nexport {\n parseDate,\n parseRange,\n toWire,\n withTimeOf,\n DEFAULT_TIME_FORMAT,\n formatValue,\n isEmptyValue,\n type DatePickerInput,\n type DatePickerRangeInput\n};\n"],"names":["ISO_DAY","ISO_DATE_TIME","pad","n","String","padStart","parseDate","value","undefined","Date","Number","isNaN","getTime","withTime","exec","hours","minutes","seconds","parsed","fromDayKey","setHours","test","parseRange","start","end","toWire","date","granularity","day","toDayKey","getHours","getMinutes","withTimeOf","from","next","DEFAULT_FORMAT","dateStyle","DEFAULT_TIME_FORMAT","timeStyle","formatDate","locale","options","Intl","DateTimeFormat","format","isRange","formatValue","isEmptyValue"],"mappings":";;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,MAAMA,OAAO,GAAG,qBAAqB;;AAErC;AACA;AACA;AACA;AACA;AACA,MAAMC,aAAa,GACjB,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YE,IAAI,EAAE,OAAOC,MAAM,CAACC,KAAK,CAACJ,KAAK,CAACK,OAAO,EAAE,CAAC;AAC/D,EAAA,IAAIiC,OAAO,CAACtC,KAAK,CAAC,EAAE,OAAO,KAAK;AAChC,EAAA,OAAO,IAAI;AACb;;"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { hash } from '@ember/helper';
|
|
3
|
-
import { get, action } from '@ember/object';
|
|
4
3
|
import { debounce } from '@ember/runloop';
|
|
4
|
+
import { getPath } from '../../utils/nested-data.js';
|
|
5
5
|
import { Checkbox } from './checkbox.js';
|
|
6
6
|
import { CheckboxGroup } from './checkbox-group.js';
|
|
7
|
+
import '@ember/debug';
|
|
8
|
+
import { DateInput } from './date-input/date-input.js';
|
|
7
9
|
import { DatePicker } from './date-picker/date-picker.js';
|
|
8
10
|
import { Input } from './input.js';
|
|
9
11
|
import { InputOtp } from './input-otp.js';
|
|
@@ -14,7 +16,6 @@ import { Switch } from './switch.js';
|
|
|
14
16
|
import { Textarea } from './textarea.js';
|
|
15
17
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
16
18
|
import { setComponentTemplate } from '@ember/component';
|
|
17
|
-
import { a as decorateMethodV2 } from '../../runtime--fcdnjmJ-BOdRhmsS.js';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Field is a component wrapper that provides conveniences for form fields.
|
|
@@ -36,11 +37,10 @@ class Field extends Component {
|
|
|
36
37
|
/**
|
|
37
38
|
* Returns the current value for the field from formData.
|
|
38
39
|
* Supports both flat and dotted field names (e.g., 'email' or 'profile.email').
|
|
39
|
-
* Uses Ember's get() which handles both flat keys and dotted paths.
|
|
40
40
|
*/
|
|
41
41
|
get fieldValue() {
|
|
42
42
|
if (!this.args.formData) return undefined;
|
|
43
|
-
return
|
|
43
|
+
return getPath(this.args.formData, this.args.name);
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Validates the field by calling the validateField function passed in args.
|
|
@@ -51,39 +51,30 @@ class Field extends Component {
|
|
|
51
51
|
/**
|
|
52
52
|
* Validates the field on change if change validation is enabled.
|
|
53
53
|
*/
|
|
54
|
-
handleChange() {
|
|
54
|
+
handleChange = () => {
|
|
55
55
|
if (this.validateOn?.includes('change')) {
|
|
56
56
|
this.validateField();
|
|
57
57
|
}
|
|
58
|
-
}
|
|
58
|
+
};
|
|
59
59
|
/**
|
|
60
60
|
* Validates the field on input if input validation is enabled.
|
|
61
61
|
* Debounces validation to avoid excessive validation calls on every keystroke.
|
|
62
62
|
*/
|
|
63
|
-
|
|
64
|
-
decorateMethodV2(this.prototype, "handleChange", [action]);
|
|
65
|
-
}
|
|
66
|
-
handleInput() {
|
|
63
|
+
handleInput = () => {
|
|
67
64
|
if (this.validateOn?.includes('input')) {
|
|
68
65
|
debounce(this, this.validateField, 300);
|
|
69
66
|
}
|
|
70
|
-
}
|
|
67
|
+
};
|
|
71
68
|
/**
|
|
72
69
|
* Validates the field on blur if blur validation is enabled.
|
|
73
70
|
*/
|
|
74
|
-
|
|
75
|
-
decorateMethodV2(this.prototype, "handleInput", [action]);
|
|
76
|
-
}
|
|
77
|
-
handleBlur() {
|
|
71
|
+
handleBlur = () => {
|
|
78
72
|
if (this.validateOn.includes('blur')) {
|
|
79
73
|
this.validateField();
|
|
80
74
|
}
|
|
81
|
-
}
|
|
82
|
-
static {
|
|
83
|
-
decorateMethodV2(this.prototype, "handleBlur", [action]);
|
|
84
|
-
}
|
|
75
|
+
};
|
|
85
76
|
static {
|
|
86
|
-
setComponentTemplate(precompileTemplate("{{!-- @glint-nocheck component generics (radio, radio-group, select) trigger: type instantiation is excessively deep and possibly infinite --}}\n{{yield (hash Checkbox=(component Checkbox name=@name errors=this.fieldErrors checked=this.fieldValue isDisabled=@disabled onChange=this.handleChange onBlur=this.handleBlur) CheckboxGroup=(component CheckboxGroup name=@name errors=this.fieldErrors isDisabled=@disabled) Input=(component Input name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange onInput=this.handleInput onBlur=this.handleBlur) InputOtp=(component InputOtp name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange onInput=this.handleInput onBlur=this.handleBlur) Radio=(component Radio name=@name errors=this.fieldErrors checkedValue=this.fieldValue isDisabled=@disabled onChange=this.handleChange onBlur=this.handleBlur) RadioGroup=(component RadioGroup name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange) SingleSelect=(component Select name=@name errors=this.fieldErrors selectedKey=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) MultiSelect=(component Select selectionMode=\"multiple\" name=@name errors=this.fieldErrors selectedKeys=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) DatePicker=(component DatePicker name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) DateRangePicker=(component DatePicker mode=\"range\" name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) Switch=(component Switch name=@name errors=this.fieldErrors isSelected=this.fieldValue isDisabled=@disabled onChange=this.handleChange onBlur=this.handleBlur) Textarea=(component Textarea name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange onInput=this.handleInput onBlur=this.handleBlur)) to=\"default\"}}", {
|
|
77
|
+
setComponentTemplate(precompileTemplate("{{!-- @glint-nocheck component generics (radio, radio-group, select) trigger: type instantiation is excessively deep and possibly infinite --}}\n{{yield (hash Checkbox=(component Checkbox name=@name errors=this.fieldErrors checked=this.fieldValue isDisabled=@disabled onChange=this.handleChange onBlur=this.handleBlur) CheckboxGroup=(component CheckboxGroup name=@name errors=this.fieldErrors isDisabled=@disabled) Input=(component Input name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange onInput=this.handleInput onBlur=this.handleBlur) InputOtp=(component InputOtp name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange onInput=this.handleInput onBlur=this.handleBlur) Radio=(component Radio name=@name errors=this.fieldErrors checkedValue=this.fieldValue isDisabled=@disabled onChange=this.handleChange onBlur=this.handleBlur) RadioGroup=(component RadioGroup name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange) SingleSelect=(component Select name=@name errors=this.fieldErrors selectedKey=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) MultiSelect=(component Select selectionMode=\"multiple\" name=@name errors=this.fieldErrors selectedKeys=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) DatePicker=(component DatePicker name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) DateRangePicker=(component DatePicker mode=\"range\" name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) DateInput=(component DateInput name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) Switch=(component Switch name=@name errors=this.fieldErrors isSelected=this.fieldValue isDisabled=@disabled onChange=this.handleChange onBlur=this.handleBlur) Textarea=(component Textarea name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange onInput=this.handleInput onBlur=this.handleBlur)) to=\"default\"}}", {
|
|
87
78
|
strictMode: true,
|
|
88
79
|
scope: () => ({
|
|
89
80
|
hash,
|
|
@@ -95,6 +86,7 @@ class Field extends Component {
|
|
|
95
86
|
RadioGroup,
|
|
96
87
|
Select,
|
|
97
88
|
DatePicker,
|
|
89
|
+
DateInput,
|
|
98
90
|
Switch,
|
|
99
91
|
Textarea
|
|
100
92
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.js","sources":["../../../src/components/forms/field.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { action, get } from '@ember/object';\nimport { debounce } from '@ember/runloop';\nimport Checkbox from './checkbox';\nimport CheckboxGroup from './checkbox-group';\nimport DatePicker from './date-picker';\nimport Input from './input';\nimport InputOtp from './input-otp';\nimport Radio from './radio';\nimport RadioGroup from './radio-group';\nimport Select from './select';\nimport Switch from './switch';\nimport Textarea from './textarea';\n\nimport type { WithBoundArgs } from '@glint/template';\nimport type { FormDataCompiled, FormErrors } from './form';\nimport type { DatePickerSignature } from './date-picker';\nimport type { SelectSignature } from './select';\nimport type { WithBoundArgsForSignature } from './field-types';\n\ntype BoundSingleSelect<S = unknown> = WithBoundArgsForSignature<\n SelectSignature<S>,\n 'name' | 'errors' | 'selectedKey' | 'onBlur' | 'isDisabled'\n>;\n\ntype BoundMultiSelect<S = unknown> = WithBoundArgsForSignature<\n SelectSignature<S>,\n 'selectionMode' | 'name' | 'errors' | 'selectedKeys' | 'onBlur' | 'isDisabled'\n>;\n\ntype BoundDatePicker = WithBoundArgsForSignature<\n DatePickerSignature<'single'>,\n 'name' | 'errors' | 'value' | 'onBlur' | 'isDisabled'\n>;\n\ntype BoundDateRangePicker = WithBoundArgsForSignature<\n DatePickerSignature<'range'>,\n 'mode' | 'name' | 'errors' | 'value' | 'onBlur' | 'isDisabled'\n>;\n\ninterface FieldSignature<T extends Record<string, unknown> = FormDataCompiled> {\n Element: HTMLElement;\n Args: {\n /** The name of the form field. */\n name: string;\n /** The validation errors for the form, keyed by field name. */\n errors?: FormErrors;\n /** The form data as key/value pairs. */\n formData?: T;\n /** Whether the field should be disabled. */\n disabled?: boolean;\n /** When to run validation. */\n validateOn?: ('change' | 'input' | 'blur')[];\n /** Function to validate a single field by name. */\n validateField?: (data: T, name: string) => Promise<FormErrors | undefined>;\n };\n Blocks: {\n default: [\n {\n Checkbox: WithBoundArgs<\n typeof Checkbox,\n 'name' | 'errors' | 'checked' | 'onChange' | 'onBlur' | 'isDisabled'\n >;\n CheckboxGroup: WithBoundArgs<\n typeof CheckboxGroup,\n 'name' | 'errors' | 'isDisabled'\n >;\n Input: WithBoundArgs<\n typeof Input,\n | 'name'\n | 'errors'\n | 'value'\n | 'onChange'\n | 'onInput'\n | 'onBlur'\n | 'isDisabled'\n >;\n InputOtp: WithBoundArgs<\n typeof InputOtp,\n | 'name'\n | 'errors'\n | 'value'\n | 'onChange'\n | 'onInput'\n | 'onBlur'\n | 'isDisabled'\n >;\n Radio: WithBoundArgs<\n typeof Radio,\n | 'name'\n | 'errors'\n | 'checkedValue'\n | 'onChange'\n | 'onBlur'\n | 'isDisabled'\n >;\n RadioGroup: WithBoundArgs<\n typeof RadioGroup,\n 'name' | 'errors' | 'value' | 'onChange' | 'isDisabled'\n >;\n SingleSelect: BoundSingleSelect;\n MultiSelect: BoundMultiSelect;\n DatePicker: BoundDatePicker;\n DateRangePicker: BoundDateRangePicker;\n Switch: WithBoundArgs<\n typeof Switch,\n | 'name'\n | 'errors'\n | 'isSelected'\n | 'onChange'\n | 'onBlur'\n | 'isDisabled'\n >;\n Textarea: WithBoundArgs<\n typeof Textarea,\n | 'name'\n | 'errors'\n | 'value'\n | 'onChange'\n | 'onInput'\n | 'onBlur'\n | 'isDisabled'\n >;\n }\n ];\n };\n}\n\n/**\n * Field is a component wrapper that provides conveniences for form fields.\n * It automatically binds the appropriate form errors by name to yielded\n * components.\n */\nclass Field<\n T extends Record<string, unknown> = FormDataCompiled\n> extends Component<FieldSignature<T>> {\n /**\n * Returns the validation errors for the field.\n * Supports dotted field names (e.g., 'profile.email').\n */\n get fieldErrors() {\n return this.args.errors?.[this.args.name];\n }\n\n /** The events on which validation should run. Defaults to ['change']. */\n get validateOn(): ('change' | 'input' | 'blur')[] {\n return this.args.validateOn ?? ['change'];\n }\n\n /**\n * Returns the current value for the field from formData.\n * Supports both flat and dotted field names (e.g., 'email' or 'profile.email').\n * Uses Ember's get() which handles both flat keys and dotted paths.\n */\n get fieldValue() {\n if (!this.args.formData) return undefined;\n\n return get(this.args.formData, this.args.name);\n }\n\n /**\n * Validates the field by calling the validateField function passed in args.\n */\n validateField() {\n this.args.validateField?.(this.args.formData as T, this.args.name);\n }\n\n /**\n * Validates the field on change if change validation is enabled.\n */\n @action\n handleChange() {\n if (this.validateOn?.includes('change')) {\n this.validateField();\n }\n }\n\n /**\n * Validates the field on input if input validation is enabled.\n * Debounces validation to avoid excessive validation calls on every keystroke.\n */\n @action\n handleInput() {\n if (this.validateOn?.includes('input')) {\n debounce(this, this.validateField, 300);\n }\n }\n\n /**\n * Validates the field on blur if blur validation is enabled.\n */\n @action\n handleBlur() {\n if (this.validateOn.includes('blur')) {\n this.validateField();\n }\n }\n\n <template>\n {{! @glint-nocheck component generics (radio, radio-group, select) trigger: type instantiation is excessively deep and possibly infinite }}\n {{yield\n (hash\n Checkbox=(component\n Checkbox\n name=@name\n errors=this.fieldErrors\n checked=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onBlur=this.handleBlur\n )\n CheckboxGroup=(component\n CheckboxGroup name=@name errors=this.fieldErrors isDisabled=@disabled\n )\n Input=(component\n Input\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onInput=this.handleInput\n onBlur=this.handleBlur\n )\n InputOtp=(component\n InputOtp\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onInput=this.handleInput\n onBlur=this.handleBlur\n )\n Radio=(component\n Radio\n name=@name\n errors=this.fieldErrors\n checkedValue=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onBlur=this.handleBlur\n )\n RadioGroup=(component\n RadioGroup\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n )\n SingleSelect=(component\n Select\n name=@name\n errors=this.fieldErrors\n selectedKey=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n MultiSelect=(component\n Select\n selectionMode=\"multiple\"\n name=@name\n errors=this.fieldErrors\n selectedKeys=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n DatePicker=(component\n DatePicker\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n DateRangePicker=(component\n DatePicker\n mode=\"range\"\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n Switch=(component\n Switch\n name=@name\n errors=this.fieldErrors\n isSelected=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onBlur=this.handleBlur\n )\n Textarea=(component\n Textarea\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onInput=this.handleInput\n onBlur=this.handleBlur\n )\n )\n to=\"default\"\n }}\n </template>\n}\n\nexport { Field, type FieldSignature };\nexport default Field;\n"],"names":["Field","Component","fieldErrors","args","errors","name","validateOn","fieldValue","formData","undefined","get","validateField","handleChange","includes","n","prototype","action","handleInput","debounce","handleBlur","setComponentTemplate","precompileTemplate","strictMode","scope","hash","Checkbox","CheckboxGroup","Input","InputOtp","Radio","RadioGroup","Select","DatePicker","Switch","Textarea"],"mappings":";;;;;;;;;;;;;;;;;;AAiIA;;;;;AAKA,MAAMA,KAAA,SAEIC,SAAA,CAAyB;AACjC;;;AAGC;EACD,IAAIC,WAAAA,GAAc;IAChB,OAAO,IAAI,CAACC,IAAI,CAACC,MAAM,GAAG,IAAI,CAACD,IAAI,CAACE,IAAI,CAAC;AAC3C,EAAA;AAEA;EACA,IAAIC,UAAAA,GAA8C;IAChD,OAAO,IAAI,CAACH,IAAI,CAACG,UAAU,IAAI,CAAC,QAAA,CAAS;AAC3C,EAAA;AAEA;;;;AAIC;EACD,IAAIC,UAAAA,GAAa;IACf,IAAI,CAAC,IAAI,CAACJ,IAAI,CAACK,QAAQ,EAAE,OAAOC,SAAA;AAEhC,IAAA,OAAOC,GAAA,CAAI,IAAI,CAACP,IAAI,CAACK,QAAQ,EAAE,IAAI,CAACL,IAAI,CAACE,IAAI,CAAA;AAC/C,EAAA;AAEA;;AAEC;AACDM,EAAAA,aAAAA,GAAgB;AACd,IAAA,IAAI,CAACR,IAAI,CAACQ,aAAa,G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1
|
+
{"version":3,"file":"field.js","sources":["../../../src/components/forms/field.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { debounce } from '@ember/runloop';\nimport { getPath } from '../../utils/nested-data';\nimport Checkbox from './checkbox';\nimport CheckboxGroup from './checkbox-group';\nimport DateInput from './date-input';\nimport DatePicker from './date-picker';\nimport Input from './input';\nimport InputOtp from './input-otp';\nimport Radio from './radio';\nimport RadioGroup from './radio-group';\nimport Select from './select';\nimport Switch from './switch';\nimport Textarea from './textarea';\n\nimport type { WithBoundArgs } from '@glint/template';\nimport type { FormDataCompiled, FormErrors } from './form';\nimport type { DateInputSignature } from './date-input';\nimport type { DatePickerSignature } from './date-picker';\nimport type { SelectSignature } from './select';\nimport type { WithBoundArgsForSignature } from './field-types';\n\ntype BoundSingleSelect<S = unknown> = WithBoundArgsForSignature<\n SelectSignature<S>,\n 'name' | 'errors' | 'selectedKey' | 'onBlur' | 'isDisabled'\n>;\n\ntype BoundMultiSelect<S = unknown> = WithBoundArgsForSignature<\n SelectSignature<S>,\n 'selectionMode' | 'name' | 'errors' | 'selectedKeys' | 'onBlur' | 'isDisabled'\n>;\n\ntype BoundDatePicker = WithBoundArgsForSignature<\n DatePickerSignature<'single'>,\n 'name' | 'errors' | 'value' | 'onBlur' | 'isDisabled'\n>;\n\ntype BoundDateInput = WithBoundArgsForSignature<\n DateInputSignature,\n 'name' | 'errors' | 'value' | 'onBlur' | 'isDisabled'\n>;\n\ntype BoundDateRangePicker = WithBoundArgsForSignature<\n DatePickerSignature<'range'>,\n 'mode' | 'name' | 'errors' | 'value' | 'onBlur' | 'isDisabled'\n>;\n\ninterface FieldSignature<T extends Record<string, unknown> = FormDataCompiled> {\n Element: HTMLElement;\n Args: {\n /** The name of the form field. */\n name: string;\n /** The validation errors for the form, keyed by field name. */\n errors?: FormErrors;\n /** The form data as key/value pairs. */\n formData?: T;\n /** Whether the field should be disabled. */\n disabled?: boolean;\n /** When to run validation. */\n validateOn?: ('change' | 'input' | 'blur')[];\n /** Function to validate a single field by name. */\n validateField?: (data: T, name: string) => Promise<FormErrors | undefined>;\n };\n Blocks: {\n default: [\n {\n Checkbox: WithBoundArgs<\n typeof Checkbox,\n 'name' | 'errors' | 'checked' | 'onChange' | 'onBlur' | 'isDisabled'\n >;\n CheckboxGroup: WithBoundArgs<\n typeof CheckboxGroup,\n 'name' | 'errors' | 'isDisabled'\n >;\n Input: WithBoundArgs<\n typeof Input,\n | 'name'\n | 'errors'\n | 'value'\n | 'onChange'\n | 'onInput'\n | 'onBlur'\n | 'isDisabled'\n >;\n InputOtp: WithBoundArgs<\n typeof InputOtp,\n | 'name'\n | 'errors'\n | 'value'\n | 'onChange'\n | 'onInput'\n | 'onBlur'\n | 'isDisabled'\n >;\n Radio: WithBoundArgs<\n typeof Radio,\n | 'name'\n | 'errors'\n | 'checkedValue'\n | 'onChange'\n | 'onBlur'\n | 'isDisabled'\n >;\n RadioGroup: WithBoundArgs<\n typeof RadioGroup,\n 'name' | 'errors' | 'value' | 'onChange' | 'isDisabled'\n >;\n SingleSelect: BoundSingleSelect;\n MultiSelect: BoundMultiSelect;\n DatePicker: BoundDatePicker;\n DateRangePicker: BoundDateRangePicker;\n DateInput: BoundDateInput;\n Switch: WithBoundArgs<\n typeof Switch,\n | 'name'\n | 'errors'\n | 'isSelected'\n | 'onChange'\n | 'onBlur'\n | 'isDisabled'\n >;\n Textarea: WithBoundArgs<\n typeof Textarea,\n | 'name'\n | 'errors'\n | 'value'\n | 'onChange'\n | 'onInput'\n | 'onBlur'\n | 'isDisabled'\n >;\n }\n ];\n };\n}\n\n/**\n * Field is a component wrapper that provides conveniences for form fields.\n * It automatically binds the appropriate form errors by name to yielded\n * components.\n */\nclass Field<\n T extends Record<string, unknown> = FormDataCompiled\n> extends Component<FieldSignature<T>> {\n /**\n * Returns the validation errors for the field.\n * Supports dotted field names (e.g., 'profile.email').\n */\n get fieldErrors() {\n return this.args.errors?.[this.args.name];\n }\n\n /** The events on which validation should run. Defaults to ['change']. */\n get validateOn(): ('change' | 'input' | 'blur')[] {\n return this.args.validateOn ?? ['change'];\n }\n\n /**\n * Returns the current value for the field from formData.\n * Supports both flat and dotted field names (e.g., 'email' or 'profile.email').\n */\n get fieldValue() {\n if (!this.args.formData) return undefined;\n\n return getPath(this.args.formData, this.args.name);\n }\n\n /**\n * Validates the field by calling the validateField function passed in args.\n */\n validateField() {\n this.args.validateField?.(this.args.formData as T, this.args.name);\n }\n\n /**\n * Validates the field on change if change validation is enabled.\n */\n handleChange = () => {\n if (this.validateOn?.includes('change')) {\n this.validateField();\n }\n };\n\n /**\n * Validates the field on input if input validation is enabled.\n * Debounces validation to avoid excessive validation calls on every keystroke.\n */\n handleInput = () => {\n if (this.validateOn?.includes('input')) {\n debounce(this, this.validateField, 300);\n }\n };\n\n /**\n * Validates the field on blur if blur validation is enabled.\n */\n handleBlur = () => {\n if (this.validateOn.includes('blur')) {\n this.validateField();\n }\n };\n\n <template>\n {{! @glint-nocheck component generics (radio, radio-group, select) trigger: type instantiation is excessively deep and possibly infinite }}\n {{yield\n (hash\n Checkbox=(component\n Checkbox\n name=@name\n errors=this.fieldErrors\n checked=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onBlur=this.handleBlur\n )\n CheckboxGroup=(component\n CheckboxGroup name=@name errors=this.fieldErrors isDisabled=@disabled\n )\n Input=(component\n Input\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onInput=this.handleInput\n onBlur=this.handleBlur\n )\n InputOtp=(component\n InputOtp\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onInput=this.handleInput\n onBlur=this.handleBlur\n )\n Radio=(component\n Radio\n name=@name\n errors=this.fieldErrors\n checkedValue=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onBlur=this.handleBlur\n )\n RadioGroup=(component\n RadioGroup\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n )\n SingleSelect=(component\n Select\n name=@name\n errors=this.fieldErrors\n selectedKey=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n MultiSelect=(component\n Select\n selectionMode=\"multiple\"\n name=@name\n errors=this.fieldErrors\n selectedKeys=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n DatePicker=(component\n DatePicker\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n DateRangePicker=(component\n DatePicker\n mode=\"range\"\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n DateInput=(component\n DateInput\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n Switch=(component\n Switch\n name=@name\n errors=this.fieldErrors\n isSelected=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onBlur=this.handleBlur\n )\n Textarea=(component\n Textarea\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onInput=this.handleInput\n onBlur=this.handleBlur\n )\n )\n to=\"default\"\n }}\n </template>\n}\n\nexport { Field, type FieldSignature };\nexport default Field;\n"],"names":["Field","Component","fieldErrors","args","errors","name","validateOn","fieldValue","formData","undefined","getPath","validateField","handleChange","includes","handleInput","debounce","handleBlur","setComponentTemplate","precompileTemplate","strictMode","scope","hash","Checkbox","CheckboxGroup","Input","InputOtp","Radio","RadioGroup","Select","DatePicker","DateInput","Switch","Textarea"],"mappings":";;;;;;;;;;;;;;;;;;;AAyIA;;;;;AAKA,MAAMA,KAAA,SAEIC,SAAA,CAAyB;AACjC;;;AAGC;EACD,IAAIC,WAAAA,GAAc;IAChB,OAAO,IAAI,CAACC,IAAI,CAACC,MAAM,GAAG,IAAI,CAACD,IAAI,CAACE,IAAI,CAAC;AAC3C,EAAA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