frontile 0.18.0-beta.0 → 0.18.0-beta.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/deprecated-args.d.ts +18 -0
- package/declarations/-private/notification.d.ts +4 -4
- package/declarations/-private/types.d.ts +10 -8
- package/declarations/components/buttons/button-group.d.ts +3 -1
- package/declarations/components/buttons/button.d.ts +12 -3
- package/declarations/components/buttons/chip.d.ts +15 -8
- package/declarations/components/buttons/close-button.d.ts +5 -2
- package/declarations/components/buttons/segmented-control/segmented-control.d.ts +9 -9
- package/declarations/components/buttons/toggle-button.d.ts +9 -1
- package/declarations/components/collections/calendar/calendar.d.ts +49 -49
- package/declarations/components/collections/calendar/utils.d.ts +1 -0
- package/declarations/components/collections/dropdown/dropdown.d.ts +13 -2
- package/declarations/components/collections/dropdown/menu-context.d.ts +3 -3
- package/declarations/components/collections/listbox/group.d.ts +7 -2
- package/declarations/components/collections/listbox/item.d.ts +27 -6
- package/declarations/components/collections/listbox/listbox.d.ts +31 -4
- package/declarations/components/collections/simple-table/body.d.ts +72 -72
- package/declarations/components/collections/simple-table/cell.d.ts +72 -72
- package/declarations/components/collections/simple-table/column.d.ts +72 -72
- package/declarations/components/collections/simple-table/footer.d.ts +72 -72
- package/declarations/components/collections/simple-table/header.d.ts +72 -72
- package/declarations/components/collections/simple-table/index.d.ts +84 -72
- package/declarations/components/collections/simple-table/row.d.ts +72 -72
- package/declarations/components/collections/table/column-visibility.d.ts +72 -72
- package/declarations/components/collections/table/sort-button.d.ts +72 -72
- package/declarations/components/collections/table/table.d.ts +73 -72
- package/declarations/components/disclosure/accordion/accordion.d.ts +23 -23
- package/declarations/components/forms/autocomplete.d.ts +24 -12
- package/declarations/components/forms/date-picker/date-picker.d.ts +268 -0
- package/declarations/components/forms/date-picker/end-content.d.ts +29 -0
- package/declarations/components/forms/date-picker/trigger.d.ts +40 -0
- package/declarations/components/forms/date-picker/types.d.ts +149 -0
- package/declarations/components/forms/date-picker/value.d.ts +43 -0
- package/declarations/components/forms/date-picker.d.ts +3 -0
- package/declarations/components/forms/field.d.ts +5 -0
- package/declarations/components/forms/form-control.d.ts +1 -1
- package/declarations/components/forms/form-feedback.d.ts +17 -2
- package/declarations/components/forms/icons.d.ts +4 -1
- package/declarations/components/forms/index.d.ts +2 -0
- package/declarations/components/forms/input.d.ts +10 -10
- package/declarations/components/forms/native-select.d.ts +7 -7
- package/declarations/components/forms/select/select.d.ts +30 -17
- package/declarations/components/forms/select/trigger.d.ts +5 -3
- package/declarations/components/forms/select/types.d.ts +42 -12
- package/declarations/components/forms/switch.d.ts +22 -18
- package/declarations/components/forms/textarea.d.ts +6 -6
- package/declarations/components/navigation/pagination/pagination.d.ts +21 -20
- package/declarations/components/navigation/tab-nav/tab-nav.d.ts +12 -12
- package/declarations/components/navigation/tabs/tabs.d.ts +12 -12
- package/declarations/components/notifications/index.d.ts +2 -2
- package/declarations/components/notifications/notification-card.d.ts +5 -5
- package/declarations/components/notifications/notifications-container.d.ts +2 -2
- package/declarations/components/overlays/drawer.d.ts +32 -32
- package/declarations/components/overlays/popover.d.ts +1 -1
- package/declarations/components/overlays/tooltip.d.ts +2 -2
- package/declarations/components/status/alert.d.ts +10 -10
- package/declarations/components/status/progress-bar.d.ts +5 -1
- package/declarations/components/utilities/kbd.d.ts +4 -4
- package/declarations/components/utilities/spinner.d.ts +14 -7
- package/declarations/index.d.ts +1 -1
- package/declarations/template-registry.d.ts +2 -1
- package/declarations/test-support.d.ts +22 -0
- package/declarations/utils/selection-indicator.d.ts +4 -0
- package/dist/components/buttons/button-group.js +26 -1
- package/dist/components/buttons/button-group.js.map +1 -1
- package/dist/components/buttons/button.js +23 -4
- package/dist/components/buttons/button.js.map +1 -1
- package/dist/components/buttons/chip.js +20 -3
- package/dist/components/buttons/chip.js.map +1 -1
- package/dist/components/buttons/close-button.js +18 -2
- package/dist/components/buttons/close-button.js.map +1 -1
- package/dist/components/buttons/segmented-control/item.js +1 -1
- package/dist/components/buttons/segmented-control/item.js.map +1 -1
- package/dist/components/buttons/segmented-control/segmented-control.js +2 -2
- package/dist/components/buttons/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/buttons/toggle-button.js +37 -3
- package/dist/components/buttons/toggle-button.js.map +1 -1
- package/dist/components/collections/calendar/calendar.js +43 -6
- package/dist/components/collections/calendar/calendar.js.map +1 -1
- package/dist/components/collections/calendar/day-cell.js +1 -1
- package/dist/components/collections/calendar/day-cell.js.map +1 -1
- package/dist/components/collections/calendar/header.js +1 -1
- package/dist/components/collections/calendar/header.js.map +1 -1
- package/dist/components/collections/calendar/month-grid.js +1 -1
- package/dist/components/collections/calendar/month-grid.js.map +1 -1
- package/dist/components/collections/calendar/utils.js +1 -1
- package/dist/components/collections/calendar/utils.js.map +1 -1
- package/dist/components/collections/calendar/year-grid.js +15 -3
- package/dist/components/collections/calendar/year-grid.js.map +1 -1
- package/dist/components/collections/command/command.js +1 -1
- package/dist/components/collections/command/command.js.map +1 -1
- package/dist/components/collections/command/dialog.js +1 -1
- package/dist/components/collections/command/dialog.js.map +1 -1
- package/dist/components/collections/command/footer.js +3 -3
- package/dist/components/collections/command/footer.js.map +1 -1
- package/dist/components/collections/command/input.js +1 -1
- package/dist/components/collections/command/input.js.map +1 -1
- package/dist/components/collections/command/list.js +1 -1
- package/dist/components/collections/command/list.js.map +1 -1
- package/dist/components/collections/dropdown/dropdown.js +45 -7
- package/dist/components/collections/dropdown/dropdown.js.map +1 -1
- package/dist/components/collections/dropdown/menu-context.js.map +1 -1
- package/dist/components/collections/listbox/group.js +1 -1
- package/dist/components/collections/listbox/group.js.map +1 -1
- package/dist/components/collections/listbox/item.js +47 -8
- package/dist/components/collections/listbox/item.js.map +1 -1
- package/dist/components/collections/listbox/listbox.js +53 -2
- package/dist/components/collections/listbox/listbox.js.map +1 -1
- package/dist/components/collections/simple-table/body.js +1 -1
- package/dist/components/collections/simple-table/body.js.map +1 -1
- package/dist/components/collections/simple-table/cell.js +1 -1
- package/dist/components/collections/simple-table/cell.js.map +1 -1
- package/dist/components/collections/simple-table/column.js +1 -1
- 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 +5 -3
- package/dist/components/collections/simple-table/index.js.map +1 -1
- package/dist/components/collections/simple-table/row.js +1 -1
- package/dist/components/collections/simple-table/row.js.map +1 -1
- package/dist/components/collections/table/checkbox.js +1 -1
- package/dist/components/collections/table/checkbox.js.map +1 -1
- package/dist/components/collections/table/column-visibility.js +1 -1
- package/dist/components/collections/table/column-visibility.js.map +1 -1
- package/dist/components/collections/table/sort-button.js +1 -1
- package/dist/components/collections/table/sort-button.js.map +1 -1
- package/dist/components/collections/table/table.js +7 -3
- package/dist/components/collections/table/table.js.map +1 -1
- package/dist/components/disclosure/accordion/accordion.js +3 -2
- package/dist/components/disclosure/accordion/accordion.js.map +1 -1
- package/dist/components/disclosure/accordion/item.js +1 -1
- package/dist/components/disclosure/accordion/item.js.map +1 -1
- package/dist/components/forms/autocomplete.js +47 -2
- package/dist/components/forms/autocomplete.js.map +1 -1
- package/dist/components/forms/checkbox-group.js +1 -1
- package/dist/components/forms/checkbox-group.js.map +1 -1
- package/dist/components/forms/checkbox.js +1 -1
- package/dist/components/forms/checkbox.js.map +1 -1
- package/dist/components/forms/date-picker/date-picker.js +301 -0
- package/dist/components/forms/date-picker/date-picker.js.map +1 -0
- package/dist/components/forms/date-picker/end-content.js +21 -0
- package/dist/components/forms/date-picker/end-content.js.map +1 -0
- package/dist/components/forms/date-picker/trigger.js +14 -0
- package/dist/components/forms/date-picker/trigger.js.map +1 -0
- package/dist/components/forms/date-picker/types.js +2 -0
- package/dist/components/forms/date-picker/types.js.map +1 -0
- package/dist/components/forms/date-picker/value.js +97 -0
- package/dist/components/forms/date-picker/value.js.map +1 -0
- package/dist/components/forms/date-picker.js +2 -0
- package/dist/components/forms/date-picker.js.map +1 -0
- package/dist/components/forms/field.js +3 -1
- package/dist/components/forms/field.js.map +1 -1
- package/dist/components/forms/form-control.js +1 -1
- package/dist/components/forms/form-control.js.map +1 -1
- package/dist/components/forms/form-description.js +1 -1
- package/dist/components/forms/form-description.js.map +1 -1
- package/dist/components/forms/form-feedback.js +26 -3
- package/dist/components/forms/form-feedback.js.map +1 -1
- package/dist/components/forms/icons.js +4 -1
- package/dist/components/forms/icons.js.map +1 -1
- package/dist/components/forms/index.js +2 -0
- package/dist/components/forms/index.js.map +1 -1
- package/dist/components/forms/input-otp.js +1 -1
- package/dist/components/forms/input-otp.js.map +1 -1
- package/dist/components/forms/input.js +1 -1
- package/dist/components/forms/input.js.map +1 -1
- package/dist/components/forms/label.js +1 -1
- package/dist/components/forms/label.js.map +1 -1
- package/dist/components/forms/native-select.js +2 -2
- package/dist/components/forms/native-select.js.map +1 -1
- package/dist/components/forms/radio-group.js +1 -1
- package/dist/components/forms/radio-group.js.map +1 -1
- package/dist/components/forms/radio.js +1 -1
- package/dist/components/forms/radio.js.map +1 -1
- package/dist/components/forms/select/end-content.js +1 -1
- package/dist/components/forms/select/end-content.js.map +1 -1
- package/dist/components/forms/select/select.js +61 -7
- package/dist/components/forms/select/select.js.map +1 -1
- package/dist/components/forms/select/selected-items.js +1 -1
- package/dist/components/forms/select/selected-items.js.map +1 -1
- package/dist/components/forms/select/trigger.js +6 -4
- package/dist/components/forms/select/trigger.js.map +1 -1
- package/dist/components/forms/switch.js +10 -2
- package/dist/components/forms/switch.js.map +1 -1
- package/dist/components/forms/textarea.js +1 -1
- package/dist/components/forms/textarea.js.map +1 -1
- package/dist/components/navigation/external-link.js +2 -2
- package/dist/components/navigation/external-link.js.map +1 -1
- package/dist/components/navigation/pagination/pagination.js +2 -2
- package/dist/components/navigation/pagination/pagination.js.map +1 -1
- package/dist/components/navigation/tab-nav/item.js +1 -1
- package/dist/components/navigation/tab-nav/item.js.map +1 -1
- package/dist/components/navigation/tab-nav/tab-nav.js +2 -2
- package/dist/components/navigation/tab-nav/tab-nav.js.map +1 -1
- package/dist/components/navigation/tabs/panel.js +1 -1
- package/dist/components/navigation/tabs/panel.js.map +1 -1
- package/dist/components/navigation/tabs/tab.js +1 -1
- package/dist/components/navigation/tabs/tab.js.map +1 -1
- package/dist/components/navigation/tabs/tabs.js +3 -3
- package/dist/components/navigation/tabs/tabs.js.map +1 -1
- package/dist/components/notifications/index.js +2 -2
- package/dist/components/notifications/notification-card.js +1 -1
- package/dist/components/notifications/notifications-container.js +2 -2
- package/dist/components/notifications/notifications-container.js.map +1 -1
- package/dist/components/overlays/drawer/body.js +1 -1
- package/dist/components/overlays/drawer/body.js.map +1 -1
- package/dist/components/overlays/drawer/drag-handle.js +1 -1
- package/dist/components/overlays/drawer/drag-handle.js.map +1 -1
- package/dist/components/overlays/drawer/footer.js +1 -1
- package/dist/components/overlays/drawer/footer.js.map +1 -1
- package/dist/components/overlays/drawer/header.js +4 -4
- package/dist/components/overlays/drawer/header.js.map +1 -1
- package/dist/components/overlays/drawer.js +4 -4
- package/dist/components/overlays/drawer.js.map +1 -1
- package/dist/components/overlays/modal/body.js +1 -1
- package/dist/components/overlays/modal/body.js.map +1 -1
- package/dist/components/overlays/modal/footer.js +1 -1
- package/dist/components/overlays/modal/footer.js.map +1 -1
- package/dist/components/overlays/modal/header.js +1 -1
- package/dist/components/overlays/modal/header.js.map +1 -1
- package/dist/components/overlays/modal.js +1 -1
- package/dist/components/overlays/modal.js.map +1 -1
- package/dist/components/overlays/overlay.js +1 -1
- package/dist/components/overlays/overlay.js.map +1 -1
- package/dist/components/overlays/popover.js.map +1 -1
- package/dist/components/overlays/tooltip.js +14 -2
- package/dist/components/overlays/tooltip.js.map +1 -1
- package/dist/components/status/alert.js +19 -15
- package/dist/components/status/alert.js.map +1 -1
- package/dist/components/status/progress-bar.js +10 -2
- package/dist/components/status/progress-bar.js.map +1 -1
- package/dist/components/utilities/avatar.js +1 -1
- package/dist/components/utilities/avatar.js.map +1 -1
- package/dist/components/utilities/divider.js +1 -1
- package/dist/components/utilities/divider.js.map +1 -1
- package/dist/components/utilities/kbd.js +3 -3
- package/dist/components/utilities/kbd.js.map +1 -1
- package/dist/components/utilities/skeleton.js +1 -1
- package/dist/components/utilities/skeleton.js.map +1 -1
- package/dist/components/utilities/spinner.js +26 -7
- package/dist/components/utilities/spinner.js.map +1 -1
- package/dist/deprecated-args-BIUjLA8y.js +32 -0
- package/dist/deprecated-args-BIUjLA8y.js.map +1 -0
- package/dist/forms.js +2 -0
- package/dist/forms.js.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/{manager-CDIZzrQ9.js → manager-B-PnYqDs.js} +28 -22
- package/dist/manager-B-PnYqDs.js.map +1 -0
- package/dist/{notification-card-D5fd-Sxa.js → notification-card-CYmWQ35W.js} +25 -22
- package/dist/notification-card-CYmWQ35W.js.map +1 -0
- package/dist/notifications.js +2 -2
- package/dist/services/notifications.js +1 -1
- package/dist/test-support.js +40 -2
- package/dist/test-support.js.map +1 -1
- package/dist/utils/selection-indicator.js +30 -2
- package/dist/utils/selection-indicator.js.map +1 -1
- package/package.json +3 -3
- package/dist/manager-CDIZzrQ9.js.map +0 -1
- package/dist/notification-card-D5fd-Sxa.js.map +0 -1
|
@@ -0,0 +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,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;AAElBC,EAAAA,WAAAA,CAAYC,KAAc,EAAEC,IAAuB,EAAE;AACnD,IAAA,KAAK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AAI,CAACwE,aAAa;AACtCC,MAAAA,aAAA,EAAe,IAAI,CAACzE,IAAI,CAACyE,aAAa;AACtCC,MAAAA,UAAA,EAAY,IAAI,CAAC1E,IAAI,CAAC2E,EAAE;AACxBC,MAAAA,SAAA,EAAW;KACb;AACF,EAAA;AAAA,EAAA;IAAArD,gBAAA,CAAA,IAAA,CAAA5B,SAAA,EAAA,kBAAA,EAAA,CAjBC6B,MAAA,CAAA,CAAA;AAAA;EAmBD,IACIqD,cAAAA,GAAyC;IAC3C,OAAO;AACL;AACA;AACA;MACAC,QAAA,EAAU,IAAI,CAAC3B,YAAY;MAC3BC,KAAA,EAAO,IAAI,CAACA,KAAK;MACjB1C,KAAA,EAAO,IAAI,CAACA,KAAK;MACjB0B,MAAA,EAAQ,IAAI,CAACA;KACf;AACF,EAAA;AAAA,EAAA;IAAAb,gBAAA,CAAA,IAAA,CAAA5B,SAAA,EAAA,gBAAA,EAAA,CAXC6B,MAAA,CAAA,CAAA;AAAA;AAaD,EAAA;IAAAuD,oBAAA,CAAAC,kBAAA,CAAA,0sHAAA,EA+IA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,MAAA;QAAAC,WAAA;QAAAC,OAAA;QAAAC,iBAAA;QAAAC,oBAAA;QAAAC,QAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CloseButton } from '../../buttons/close-button.js';
|
|
2
|
+
import { IconCalendar } from '../icons.js';
|
|
3
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
4
|
+
import { setComponentTemplate } from '@ember/component';
|
|
5
|
+
import templateOnly from '@ember/component/template-only';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The cluster at the end of the field: exactly one of the clear button or the
|
|
9
|
+
* calendar icon. Pointer events are off so a click anywhere in the field still
|
|
10
|
+
* reaches the trigger; the clear button opts back in.
|
|
11
|
+
*/
|
|
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>", {
|
|
13
|
+
strictMode: true,
|
|
14
|
+
scope: () => ({
|
|
15
|
+
CloseButton,
|
|
16
|
+
IconCalendar
|
|
17
|
+
})
|
|
18
|
+
}), templateOnly());
|
|
19
|
+
|
|
20
|
+
export { DatePickerEndContent };
|
|
21
|
+
//# sourceMappingURL=end-content.js.map
|
|
@@ -0,0 +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 '../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: exactly one of the clear button or the\n * calendar icon. Pointer events are off so a click anywhere in the field still\n * reaches the trigger; the clear button opts back in.\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 {{else}}\n <IconCalendar\n data-part=\"icon\"\n class={{@classes.icon class=@userClasses.icon}}\n />\n {{/if}}\n </div>\n</template>;\n\nexport { DatePickerEndContent, type DatePickerEndContentSignature };\n"],"names":["DatePickerEndContent","setComponentTemplate","precompileTemplate","strictMode","scope","CloseButton","IconCalendar","templateOnly"],"mappings":";;;;;;AA2BA;;;;AAIC;AACD,MAAMA,oBAA0B,GAAAC,oBAAA,CAAiCC,kBAAA,CAAA,wgBAAA,EA2BjE;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,WAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { on } from '@ember/modifier';
|
|
2
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
3
|
+
import { setComponentTemplate } from '@ember/component';
|
|
4
|
+
import templateOnly from '@ember/component/template-only';
|
|
5
|
+
|
|
6
|
+
const DatePickerTrigger = setComponentTemplate(precompileTemplate("<button type=\"button\" id={{@id}} {{@trigger}} {{@triggerRef}} disabled={{@isDisabled}} data-part=\"input\" data-invalid={{if @isInvalid \"true\" \"false\"}} data-disabled={{if @isDisabled \"true\" \"false\"}} aria-label={{if @hasCustomContent @accessibleName}} aria-haspopup=\"dialog\" class={{@classes.input class=@userClasses.input hasEndContent=true}} {{on \"focusout\" @onFocusOut}} ...attributes>\n {{#if @hasCustomContent}}\n {{yield to=\"value\"}}\n {{else if @isEmpty}}\n <span data-part=\"placeholder\" class={{@classes.placeholder class=@userClasses.placeholder}}>{{@placeholder}}</span>\n {{else}}\n {{@formatted}}\n {{/if}}\n</button>", {
|
|
7
|
+
strictMode: true,
|
|
8
|
+
scope: () => ({
|
|
9
|
+
on
|
|
10
|
+
})
|
|
11
|
+
}), templateOnly());
|
|
12
|
+
|
|
13
|
+
export { DatePickerTrigger, DatePickerTrigger as default };
|
|
14
|
+
//# sourceMappingURL=trigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigger.js","sources":["../../../../src/components/forms/date-picker/trigger.gts"],"sourcesContent":["import type { TOC } from '@ember/component/template-only';\nimport { on } from '@ember/modifier';\nimport type { ModifierLike } from '@glint/template';\nimport type { SlotsToClasses, DatePickerSlots } from '@frontile/theme';\nimport type { DatePickerClasses } from './types';\n\ninterface DatePickerTriggerSignature {\n Args: {\n /** Records the element, for focus restoration and blur tracking. */\n triggerRef: ModifierLike<{ Element: HTMLButtonElement }>;\n\n /** The popover's `trigger` modifier: what opens the calendar. */\n trigger: ModifierLike<{ Element: HTMLElement }>;\n\n id?: string;\n placeholder?: string;\n formatted: string;\n isEmpty: boolean;\n isDisabled?: boolean;\n isInvalid?: boolean;\n hasCustomContent: boolean;\n\n /**\n * Names the trigger when a `:value` block owns its content — that block\n * may render nothing readable at all, which would leave an unnamed\n * button. `undefined` when there is nothing to name it with, so\n * `aria-label` is omitted entirely rather than set to `\"\"`.\n */\n accessibleName: string | undefined;\n\n classes: DatePickerClasses;\n userClasses?: SlotsToClasses<DatePickerSlots>;\n onFocusOut: (event: FocusEvent) => void;\n };\n Blocks: { value: [] };\n Element: HTMLButtonElement;\n}\n\nconst DatePickerTrigger: TOC<DatePickerTriggerSignature> = <template>\n <button\n type=\"button\"\n id={{@id}}\n {{@trigger}}\n {{@triggerRef}}\n disabled={{@isDisabled}}\n data-part=\"input\"\n data-invalid={{if @isInvalid \"true\" \"false\"}}\n data-disabled={{if @isDisabled \"true\" \"false\"}}\n aria-label={{if @hasCustomContent @accessibleName}}\n aria-haspopup=\"dialog\"\n class={{@classes.input class=@userClasses.input hasEndContent=true}}\n {{on \"focusout\" @onFocusOut}}\n ...attributes\n >\n {{#if @hasCustomContent}}\n {{yield to=\"value\"}}\n {{else if @isEmpty}}\n <span\n data-part=\"placeholder\"\n class={{@classes.placeholder class=@userClasses.placeholder}}\n >{{@placeholder}}</span>\n {{else}}\n {{@formatted}}\n {{/if}}\n </button>\n</template>;\n\nexport { DatePickerTrigger, type DatePickerTriggerSignature };\nexport default DatePickerTrigger;\n"],"names":["DatePickerTrigger","setComponentTemplate","precompileTemplate","strictMode","scope","on","templateOnly"],"mappings":";;;;;AAsCA,MAAMA,iBAAuB,GAAAC,oBAAA,CAA8BC,kBAAA,CAAA,upBAAA,EA2B3D;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { fromDayKey, toDayKey } from '../../collections/calendar/utils.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A date as accepted from a consumer: a `Date`, or the same `yyyy-MM-dd`
|
|
5
|
+
* string this component writes to its hidden inputs.
|
|
6
|
+
*
|
|
7
|
+
* Strings are accepted because `Field` feeds form data — which is always
|
|
8
|
+
* strings — straight back into `@value`. It also means a value hydrated from
|
|
9
|
+
* JSON or an API needs no adapter. Output is always a `Date`: strings are an
|
|
10
|
+
* accepted input, never an output mode.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const ISO_DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Normalizes one end of a value to a `Date`, or `null` when there is nothing
|
|
17
|
+
* usable there.
|
|
18
|
+
*
|
|
19
|
+
* An `Invalid Date` is treated as absent rather than passed along: it would
|
|
20
|
+
* otherwise reach `Intl.DateTimeFormat` and render the literal text
|
|
21
|
+
* "Invalid Date" inside the trigger.
|
|
22
|
+
*/
|
|
23
|
+
function parseDate(value) {
|
|
24
|
+
if (value === null || value === undefined || value === '') return null;
|
|
25
|
+
if (value instanceof Date) {
|
|
26
|
+
return Number.isNaN(value.getTime()) ? null : value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// `fromDayKey` splits on `-` and would happily turn anything into a Date of
|
|
30
|
+
// NaN parts, so the shape is checked before it is trusted.
|
|
31
|
+
if (!ISO_DAY.test(value)) return null;
|
|
32
|
+
const parsed = fromDayKey(value);
|
|
33
|
+
return Number.isNaN(parsed.getTime()) ? null : parsed;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Normalizes a range. A `null` end is preserved rather than collapsed — that
|
|
38
|
+
* is a range mid-selection, with its anchor set and the second click pending,
|
|
39
|
+
* and the trigger must still show the anchor.
|
|
40
|
+
*/
|
|
41
|
+
function parseRange(value) {
|
|
42
|
+
if (!value) return null;
|
|
43
|
+
const start = parseDate(value.start);
|
|
44
|
+
// Without a usable start there is no range at all: a `{ start: null }` would
|
|
45
|
+
// not satisfy `DateRange`, whose start is non-nullable.
|
|
46
|
+
if (!start) return null;
|
|
47
|
+
return {
|
|
48
|
+
start,
|
|
49
|
+
end: parseDate(value.end)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The value as it is submitted: `yyyy-MM-dd`, from local calendar fields. */
|
|
54
|
+
function toWire(date) {
|
|
55
|
+
if (!date || Number.isNaN(date.getTime())) return '';
|
|
56
|
+
return toDayKey(date);
|
|
57
|
+
}
|
|
58
|
+
const DEFAULT_FORMAT = {
|
|
59
|
+
dateStyle: 'medium'
|
|
60
|
+
};
|
|
61
|
+
function formatDate(date, locale, options) {
|
|
62
|
+
return new Intl.DateTimeFormat(locale, options ?? DEFAULT_FORMAT).format(date);
|
|
63
|
+
}
|
|
64
|
+
function isRange(value) {
|
|
65
|
+
return typeof value === 'object' && value !== null && 'start' in value && value.start instanceof Date;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The trigger's text for a value in either mode. An en dash (not a hyphen)
|
|
70
|
+
* joins a range, matching how date ranges are set in running text.
|
|
71
|
+
*/
|
|
72
|
+
function formatValue(value, locale, options) {
|
|
73
|
+
if (!value) return '';
|
|
74
|
+
if (isRange(value)) {
|
|
75
|
+
const start = formatDate(value.start, locale, options);
|
|
76
|
+
// A half-open range renders as the anchor alone: "Jan 20, 2026 – " would
|
|
77
|
+
// read as an unfinished sentence while the user picks the second end.
|
|
78
|
+
if (!value.end) return start;
|
|
79
|
+
return `${start} – ${formatDate(value.end, locale, options)}`;
|
|
80
|
+
}
|
|
81
|
+
if (value instanceof Date) return formatDate(value, locale, options);
|
|
82
|
+
return '';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Whether the trigger should show its placeholder. An anchored range is *not*
|
|
87
|
+
* empty — its start is already chosen and must be visible.
|
|
88
|
+
*/
|
|
89
|
+
function isEmptyValue(value) {
|
|
90
|
+
if (value === null || value === undefined) return true;
|
|
91
|
+
if (value instanceof Date) return Number.isNaN(value.getTime());
|
|
92
|
+
if (isRange(value)) return false;
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { formatValue, isEmptyValue, parseDate, parseRange, toWire };
|
|
97
|
+
//# sourceMappingURL=value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value.js","sources":["../../../../src/components/forms/date-picker/value.ts"],"sourcesContent":["import {\n formatter,\n toDayKey,\n fromDayKey\n} 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":";;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,MAAMA,OAAO,GAAG,qBAAqB;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,SAASA,CAACC,KAAyC,EAAe;AACzE,EAAA,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKC,SAAS,IAAID,KAAK,KAAK,EAAE,EAAE,OA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,7 @@ import { get, action } from '@ember/object';
|
|
|
4
4
|
import { debounce } from '@ember/runloop';
|
|
5
5
|
import { Checkbox } from './checkbox.js';
|
|
6
6
|
import { CheckboxGroup } from './checkbox-group.js';
|
|
7
|
+
import { DatePicker } from './date-picker/date-picker.js';
|
|
7
8
|
import { Input } from './input.js';
|
|
8
9
|
import { InputOtp } from './input-otp.js';
|
|
9
10
|
import { Radio } from './radio.js';
|
|
@@ -83,7 +84,7 @@ class Field extends Component {
|
|
|
83
84
|
decorateMethodV2(this.prototype, "handleBlur", [action]);
|
|
84
85
|
}
|
|
85
86
|
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) 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
|
+
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\"}}", {
|
|
87
88
|
strictMode: true,
|
|
88
89
|
scope: () => ({
|
|
89
90
|
hash,
|
|
@@ -94,6 +95,7 @@ class Field extends Component {
|
|
|
94
95
|
Radio,
|
|
95
96
|
RadioGroup,
|
|
96
97
|
Select,
|
|
98
|
+
DatePicker,
|
|
97
99
|
Switch,
|
|
98
100
|
Textarea
|
|
99
101
|
})
|
|
@@ -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 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 { 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\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 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 // Ember's get() handles both flat keys and dotted paths correctly\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 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","Switch","Textarea"],"mappings":";;;;;;;;;;;;;;;;;AAmHA;;;;;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;AACA,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,GAAG,IAAI,CAACR,IAAI,CAACK,QAAQ,EAA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ourcesContent":["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 // Ember's get() handles both flat keys and dotted paths correctly\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;AAE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,IAAA;QAAAC,QAAA;QAAAC,aAAA;QAAAC,KAAA;QAAAC,QAAA;QAAAC,KAAA;QAAAC,UAAA;QAAAC,MAAA;QAAAC,UAAA;QAAAC,MAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -52,7 +52,7 @@ class FormControl extends Component {
|
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
54
|
static {
|
|
55
|
-
setComponentTemplate(precompileTemplate("<div class={{@class}} ...attributes>\n {{#if (or @label (has-block \"label\"))}}\n <Label @for={{this.id}} @isRequired={{@isRequired}} @size={{@size}}>\n {{@label}}\n {{yield to=\"label\"}}\n </Label>\n {{/if}}\n\n {{#if (or @description (has-block \"description\"))}}\n <Description @id={{this.descriptionId}} @size={{@size}}>\n {{@description}}\n {{yield to=\"description\"}}\n </Description>\n {{/if}}\n\n {{yield (hash id=this.id isInvalid=this.isInvalid describedBy=this.describedBy Label=(component Label for=this.id size=@size isRequired=@isRequired) Description=(component Description id=this.descriptionId size=@size) Feedback=(component Feedback id=this.feedbackId size=@size messages=@errors
|
|
55
|
+
setComponentTemplate(precompileTemplate("<div class={{@class}} ...attributes>\n {{#if (or @label (has-block \"label\"))}}\n <Label @for={{this.id}} @isRequired={{@isRequired}} @size={{@size}}>\n {{@label}}\n {{yield to=\"label\"}}\n </Label>\n {{/if}}\n\n {{#if (or @description (has-block \"description\"))}}\n <Description @id={{this.descriptionId}} @size={{@size}}>\n {{@description}}\n {{yield to=\"description\"}}\n </Description>\n {{/if}}\n\n {{yield (hash id=this.id isInvalid=this.isInvalid describedBy=this.describedBy Label=(component Label for=this.id size=@size isRequired=@isRequired) Description=(component Description id=this.descriptionId size=@size) Feedback=(component Feedback id=this.feedbackId size=@size messages=@errors status=\"danger\" announce=false)) to=\"default\"}}\n\n {{#if this.showErrorFeedback}}\n <Feedback @id={{this.feedbackId}} @size={{@size}} @messages={{@errors}} @status=\"danger\" @announce={{false}} />\n {{/if}}\n\n {{!--\n The visible feedback is only rendered once the field is invalid, and a\n live region that appears at the same moment as its content is not\n reliably announced. This region is always in the DOM, visually hidden\n and empty, so assistive technology is already observing it when the\n messages arrive. It is intentionally not part of describedBy; the\n visible feedback is what describes the control.\n --}}\n <VisuallyHidden aria-live=\"assertive\" data-test-id=\"form-feedback-live-region\">{{this.errorMessageText}}</VisuallyHidden>\n</div>", {
|
|
56
56
|
strictMode: true,
|
|
57
57
|
scope: () => ({
|
|
58
58
|
or,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-control.js","sources":["../../../src/components/forms/form-control.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { guidFor } from '@ember/object/internals';\nimport { hash } from '@ember/helper';\nimport Feedback, {\n feedbackMessageText,\n type FormFeedbackSignature\n} from './form-feedback';\nimport Description, { type FormDescriptionSignature } from './form-description';\nimport Label, { type LabelSignature } from './label';\nimport VisuallyHidden from '../utilities/visually-hidden';\nimport type { ComponentLike, WithBoundArgs } from '@glint/template';\n\ninterface FormControlSharedArgs {\n /**\n * The label text rendered above the control and associated with it via `for`.\n * Use the `:label` block instead when the label needs markup.\n */\n label?: string;\n\n /**\n * Whether the field is required. Adds an asterisk to the label; it does not\n * set the `required` attribute on the control itself.\n *\n * @defaultValue false\n */\n isRequired?: boolean;\n\n /**\n * Help text rendered between the label and the control, and referenced by the\n * ids `describedBy` returns.\n */\n description?: string;\n\n /**\n * Validation messages for the field. A non-empty value also marks the control\n * invalid, and an array is joined with `; ` when displayed.\n */\n errors?: string[] | string;\n\n /**\n * Marks the control invalid without supplying messages, for validation that is\n * reported elsewhere.\n *\n * @defaultValue false\n */\n isInvalid?: boolean;\n\n /**\n * Whether the field is disabled. FormControl passes this through for styling;\n * the control it wraps is responsible for the `disabled` attribute.\n *\n * @defaultValue false\n */\n isDisabled?: boolean;\n}\n\ninterface Args extends FormControlSharedArgs {\n /**\n * The id given to the control, and the base for the description and feedback\n * ids. Generated when omitted, so pass one only when something outside the\n * block has to reference it.\n */\n id?: string;\n\n /**\n * The size of the label, description and feedback text.\n *\n * @defaultValue 'md'\n */\n size?: 'sm' | 'md' | 'lg';\n\n /**\n * Suppresses the automatic error feedback, for when the block renders the\n * yielded `Feedback` itself or places messages elsewhere.\n *\n * @defaultValue false\n */\n preventErrorFeedback?: boolean;\n\n /**\n * Class names for the wrapping element.\n */\n class?: string;\n}\n\ninterface FormControlSignature {\n Args: Args;\n Blocks: {\n default: [\n {\n id: string;\n isInvalid: boolean;\n describedBy: (\n hasDescription?: string | boolean,\n hasFeedback?: string | boolean\n ) => string | undefined;\n Label: WithBoundArgs<\n ComponentLike<LabelSignature>,\n 'for' | 'size' | 'isRequired'\n >;\n Description: WithBoundArgs<\n ComponentLike<FormDescriptionSignature>,\n 'id' | 'size'\n >;\n Feedback: WithBoundArgs<\n ComponentLike<FormFeedbackSignature>,\n 'id' | 'size' | 'messages' | '
|
|
1
|
+
{"version":3,"file":"form-control.js","sources":["../../../src/components/forms/form-control.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { guidFor } from '@ember/object/internals';\nimport { hash } from '@ember/helper';\nimport Feedback, {\n feedbackMessageText,\n type FormFeedbackSignature\n} from './form-feedback';\nimport Description, { type FormDescriptionSignature } from './form-description';\nimport Label, { type LabelSignature } from './label';\nimport VisuallyHidden from '../utilities/visually-hidden';\nimport type { ComponentLike, WithBoundArgs } from '@glint/template';\n\ninterface FormControlSharedArgs {\n /**\n * The label text rendered above the control and associated with it via `for`.\n * Use the `:label` block instead when the label needs markup.\n */\n label?: string;\n\n /**\n * Whether the field is required. Adds an asterisk to the label; it does not\n * set the `required` attribute on the control itself.\n *\n * @defaultValue false\n */\n isRequired?: boolean;\n\n /**\n * Help text rendered between the label and the control, and referenced by the\n * ids `describedBy` returns.\n */\n description?: string;\n\n /**\n * Validation messages for the field. A non-empty value also marks the control\n * invalid, and an array is joined with `; ` when displayed.\n */\n errors?: string[] | string;\n\n /**\n * Marks the control invalid without supplying messages, for validation that is\n * reported elsewhere.\n *\n * @defaultValue false\n */\n isInvalid?: boolean;\n\n /**\n * Whether the field is disabled. FormControl passes this through for styling;\n * the control it wraps is responsible for the `disabled` attribute.\n *\n * @defaultValue false\n */\n isDisabled?: boolean;\n}\n\ninterface Args extends FormControlSharedArgs {\n /**\n * The id given to the control, and the base for the description and feedback\n * ids. Generated when omitted, so pass one only when something outside the\n * block has to reference it.\n */\n id?: string;\n\n /**\n * The size of the label, description and feedback text.\n *\n * @defaultValue 'md'\n */\n size?: 'sm' | 'md' | 'lg';\n\n /**\n * Suppresses the automatic error feedback, for when the block renders the\n * yielded `Feedback` itself or places messages elsewhere.\n *\n * @defaultValue false\n */\n preventErrorFeedback?: boolean;\n\n /**\n * Class names for the wrapping element.\n */\n class?: string;\n}\n\ninterface FormControlSignature {\n Args: Args;\n Blocks: {\n default: [\n {\n id: string;\n isInvalid: boolean;\n describedBy: (\n hasDescription?: string | boolean,\n hasFeedback?: string | boolean\n ) => string | undefined;\n Label: WithBoundArgs<\n ComponentLike<LabelSignature>,\n 'for' | 'size' | 'isRequired'\n >;\n Description: WithBoundArgs<\n ComponentLike<FormDescriptionSignature>,\n 'id' | 'size'\n >;\n Feedback: WithBoundArgs<\n ComponentLike<FormFeedbackSignature>,\n 'id' | 'size' | 'messages' | 'status'\n >;\n }\n ];\n label: [];\n description: [];\n };\n Element: HTMLDivElement;\n}\n\nfunction or(arg1: unknown, arg2: unknown): boolean {\n return !!(arg1 || arg2);\n}\n\nclass FormControl extends Component<FormControlSignature> {\n id = this.args.id || guidFor(this);\n\n get descriptionId(): string {\n return this.id + '-description';\n }\n\n get feedbackId(): string {\n return this.id + '-feedback';\n }\n\n describedBy = (\n hasDescription?: string | boolean,\n hasFeedback?: string | boolean\n ): string | undefined => {\n const ids = [];\n\n if (hasDescription) {\n ids.push(this.descriptionId);\n }\n\n if (hasFeedback) {\n ids.push(this.feedbackId);\n }\n\n if (ids.length > 0) {\n return ids.join(' ');\n }\n };\n\n get isInvalid(): boolean {\n if (\n this.args.isInvalid ||\n (this.args.errors && this.args.errors.length > 0)\n ) {\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * The error messages as a single string, used by the persistent live region.\n * Uses `FormFeedback`'s own join, so both render the same separator.\n */\n get errorMessageText(): string {\n return feedbackMessageText(this.args.errors);\n }\n\n get showErrorFeedback(): boolean {\n if (!(this.args.preventErrorFeedback === true) && this.isInvalid) {\n return true;\n }\n return false;\n }\n\n <template>\n <div class={{@class}} ...attributes>\n {{#if (or @label (has-block \"label\"))}}\n <Label @for={{this.id}} @isRequired={{@isRequired}} @size={{@size}}>\n {{@label}}\n {{yield to=\"label\"}}\n </Label>\n {{/if}}\n\n {{#if (or @description (has-block \"description\"))}}\n <Description @id={{this.descriptionId}} @size={{@size}}>\n {{@description}}\n {{yield to=\"description\"}}\n </Description>\n {{/if}}\n\n {{yield\n (hash\n id=this.id\n isInvalid=this.isInvalid\n describedBy=this.describedBy\n Label=(component Label for=this.id size=@size isRequired=@isRequired)\n Description=(component Description id=this.descriptionId size=@size)\n Feedback=(component\n Feedback\n id=this.feedbackId\n size=@size\n messages=@errors\n status=\"danger\"\n announce=false\n )\n )\n to=\"default\"\n }}\n\n {{#if this.showErrorFeedback}}\n <Feedback\n @id={{this.feedbackId}}\n @size={{@size}}\n @messages={{@errors}}\n @status=\"danger\"\n @announce={{false}}\n />\n {{/if}}\n\n {{!\n The visible feedback is only rendered once the field is invalid, and a\n live region that appears at the same moment as its content is not\n reliably announced. This region is always in the DOM, visually hidden\n and empty, so assistive technology is already observing it when the\n messages arrive. It is intentionally not part of describedBy; the\n visible feedback is what describes the control.\n }}\n <VisuallyHidden\n aria-live=\"assertive\"\n data-test-id=\"form-feedback-live-region\"\n >{{this.errorMessageText}}</VisuallyHidden>\n </div>\n </template>\n}\n\nexport { FormControl, type FormControlSignature, type FormControlSharedArgs };\nexport default FormControl;\n"],"names":["or","arg1","arg2","FormControl","Component","id","args","guidFor","descriptionId","feedbackId","describedBy","hasDescription","hasFeedback","ids","push","length","join","isInvalid","errors","errorMessageText","feedbackMessageText","showErrorFeedback","preventErrorFeedback","setComponentTemplate","precompileTemplate","strictMode","scope","Label","Description","hash","Feedback","VisuallyHidden"],"mappings":";;;;;;;;;;AAoHA,SAASA,GAAGC,IAAa,EAAEC,IAAa,EAAU;AAChD,EAAA,OAAO,CAAC,EAAED,IAAA,IAAQC,IAAI,CAAA;AACxB;AAEA,MAAMC,oBAAoBC,SAAA,CAAU;EAClCC,EAAA,GAAK,IAAI,CAACC,IAAI,CAACD,EAAE,IAAIE,OAAA,CAAQ,IAAI,CAAA;EAEjC,IAAIC,aAAAA,GAAwB;AAC1B,IAAA,OAAO,IAAI,CAACH,EAAE,GAAG,cAAA;AACnB,EAAA;EAEA,IAAII,UAAAA,GAAqB;AACvB,IAAA,OAAO,IAAI,CAACJ,EAAE,GAAG,WAAA;AACnB,EAAA;AAEAK,EAAAA,WAAA,GAAcA,CACZC,cAAiC,EACjCC,WAA8B,KACX;IACnB,MAAMC,MAAM,EAAE;AAEd,IAAA,IAAIF,cAAA,EAAgB;AAClBE,MAAAA,GAAA,CAAIC,IAAI,CAAC,IAAI,CAACN,aAAa,CAAA;AAC7B,IAAA;AAEA,IAAA,IAAII,WAAA,EAAa;AACfC,MAAAA,GAAA,CAAIC,IAAI,CAAC,IAAI,CAACL,UAAU,CAAA;AAC1B,IAAA;AAEA,IAAA,IAAII,GAAA,CAAIE,MAAM,GAAG,CAAA,EAAG;AAClB,MAAA,OAAOF,GAAA,CAAIG,IAAI,CAAC,GAAA,CAAA;AAClB,IAAA;EACF,CAAA;EAEA,IAAIC,SAAAA,GAAqB;IACvB,IACE,IAAI,CAACX,IAAI,CAACW,SAAS,IAClB,IAAI,CAACX,IAAI,CAACY,MAAM,IAAI,IAAI,CAACZ,IAAI,CAACY,MAAM,CAACH,MAAM,GAAG,CAAC,EAChD;AACA,MAAA,OAAO,IAAA;AACT,IAAA,CAAA,MAAO;AACL,MAAA,OAAO,KAAA;AACT,IAAA;AACF,EAAA;AAEA;;;;EAIA,IAAII,gBAAAA,GAA2B;AAC7B,IAAA,OAAOC,mBAAA,CAAoB,IAAI,CAACd,IAAI,CAACY,MAAM,CAAA;AAC7C,EAAA;EAEA,IAAIG,iBAAAA,GAA6B;AAC/B,IAAA,IAAI,EAAE,IAAI,CAACf,IAAI,CAACgB,oBAAoB,KAAK,IAAI,CAAA,IAAK,IAAI,CAACL,SAAS,EAAE;AAChE,MAAA,OAAO,IAAA;AACT,IAAA;AACA,IAAA,OAAO,KAAA;AACT,EAAA;AAEA,EAAA;IAAAM,oBAAA,CAAAC,kBAAA,CAAA,8/CAAA,EA0DA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAA1B,EAAA;QAAA2B,KAAA;qBAAAC,eAAA;QAAAC,IAAA;kBAAAC,YAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -14,7 +14,7 @@ class FormDescription extends Component {
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
static {
|
|
17
|
-
setComponentTemplate(precompileTemplate("<div id={{@id}} class={{this.classes}} data-component=\"form-description\" ...attributes>\n {{yield}}\n</div>", {
|
|
17
|
+
setComponentTemplate(precompileTemplate("<div id={{@id}} class={{this.classes}} data-component=\"form-description\" data-part=\"base\" ...attributes>\n {{yield}}\n</div>", {
|
|
18
18
|
strictMode: true
|
|
19
19
|
}), this);
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-description.js","sources":["../../../src/components/forms/form-description.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { useStyles, type FormDescriptionVariants } from '@frontile/theme';\n\ninterface FormDescriptionSignature {\n Args: {\n /**\n * The id of the description element, referenced by the control's\n * `aria-describedby`.\n */\n id?: string;\n\n /**\n * The size of the description text.\n *\n * @defaultValue 'md'\n */\n size?: FormDescriptionVariants['size'];\n\n /**\n * Class names for the description element, merged with the theme's.\n */\n class?: string;\n };\n Element: HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nclass FormDescription extends Component<FormDescriptionSignature> {\n get classes() {\n const { formDescription } = useStyles();\n\n return formDescription({\n size: this.args.size || 'md',\n class: this.args.class\n });\n }\n\n <template>\n <div\n id={{@id}}\n class={{this.classes}}\n data-component=\"form-description\"\n ...attributes\n >\n {{yield}}\n </div>\n </template>\n}\n\nexport { FormDescription, type FormDescriptionSignature };\nexport default FormDescription;\n"],"names":["FormDescription","Component","classes","formDescription","useStyles","size","args","class","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;AA6BA,MAAMA,wBAAwBC,SAAA,CAAU;EACtC,IAAIC,OAAAA,GAAU;IACZ,MAAM;AAAEC,MAAAA;KAAiB,GAAGC,SAAA,EAAA;AAE5B,IAAA,OAAOD,eAAA,CAAgB;AACrBE,MAAAA,IAAA,EAAM,IAAI,CAACC,IAAI,CAACD,IAAI,IAAI,IAAA;AACxBE,MAAAA,KAAA,EAAO,IAAI,CAACD,IAAI,CAACC;AACnB,KAAA,CAAA;AACF,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"form-description.js","sources":["../../../src/components/forms/form-description.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { useStyles, type FormDescriptionVariants } from '@frontile/theme';\n\ninterface FormDescriptionSignature {\n Args: {\n /**\n * The id of the description element, referenced by the control's\n * `aria-describedby`.\n */\n id?: string;\n\n /**\n * The size of the description text.\n *\n * @defaultValue 'md'\n */\n size?: FormDescriptionVariants['size'];\n\n /**\n * Class names for the description element, merged with the theme's.\n */\n class?: string;\n };\n Element: HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nclass FormDescription extends Component<FormDescriptionSignature> {\n get classes() {\n const { formDescription } = useStyles();\n\n return formDescription({\n size: this.args.size || 'md',\n class: this.args.class\n });\n }\n\n <template>\n <div\n id={{@id}}\n class={{this.classes}}\n data-component=\"form-description\"\n data-part=\"base\"\n ...attributes\n >\n {{yield}}\n </div>\n </template>\n}\n\nexport { FormDescription, type FormDescriptionSignature };\nexport default FormDescription;\n"],"names":["FormDescription","Component","classes","formDescription","useStyles","size","args","class","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;AA6BA,MAAMA,wBAAwBC,SAAA,CAAU;EACtC,IAAIC,OAAAA,GAAU;IACZ,MAAM;AAAEC,MAAAA;KAAiB,GAAGC,SAAA,EAAA;AAE5B,IAAA,OAAOD,eAAA,CAAgB;AACrBE,MAAAA,IAAA,EAAM,IAAI,CAACC,IAAI,CAACD,IAAI,IAAI,IAAA;AACxBE,MAAAA,KAAA,EAAO,IAAI,CAACD,IAAI,CAACC;AACnB,KAAA,CAAA;AACF,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,mIAAA,EAUA;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
|
+
import { cached } from '@glimmer/tracking';
|
|
2
3
|
import { useStyles } from '@frontile/theme';
|
|
4
|
+
import { r as renamedArgValue } from '../../deprecated-args-BIUjLA8y.js';
|
|
3
5
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
4
6
|
import { setComponentTemplate } from '@ember/component';
|
|
7
|
+
import { a as decorateMethodV2 } from '../../runtime--fcdnjmJ-BOdRhmsS.js';
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* Renders feedback messages as a single string. An array is joined with `; `.
|
|
@@ -17,8 +20,28 @@ function feedbackMessageText(messages) {
|
|
|
17
20
|
return typeof messages === 'string' ? messages : messages.join('; ');
|
|
18
21
|
}
|
|
19
22
|
class FormFeedback extends Component {
|
|
23
|
+
/**
|
|
24
|
+
* Resolved once so `isError` and `classes` agree, and so the deprecation
|
|
25
|
+
* fires once per render rather than per reader.
|
|
26
|
+
*/
|
|
27
|
+
get status() {
|
|
28
|
+
return renamedArgValue(this.args.status, this.args.intent, {}, {
|
|
29
|
+
component: 'FormFeedback',
|
|
30
|
+
from: 'intent',
|
|
31
|
+
to: 'status',
|
|
32
|
+
id: 'frontile.form-feedback.intent'
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Drives `aria-live="assertive"`. The default is `danger`, so the ABSENCE
|
|
37
|
+
* of the arg must stay assertive -- a missing value must never quietly
|
|
38
|
+
* downgrade an error announcement to polite.
|
|
39
|
+
*/
|
|
40
|
+
static {
|
|
41
|
+
decorateMethodV2(this.prototype, "status", [cached]);
|
|
42
|
+
}
|
|
20
43
|
get isError() {
|
|
21
|
-
return typeof this.args.messages !== 'undefined' && (this.
|
|
44
|
+
return typeof this.args.messages !== 'undefined' && (this.status === 'danger' || typeof this.status === 'undefined');
|
|
22
45
|
}
|
|
23
46
|
get classes() {
|
|
24
47
|
const {
|
|
@@ -26,7 +49,7 @@ class FormFeedback extends Component {
|
|
|
26
49
|
} = useStyles();
|
|
27
50
|
return formFeedback({
|
|
28
51
|
size: this.args.size || 'md',
|
|
29
|
-
|
|
52
|
+
status: this.status || 'danger',
|
|
30
53
|
class: this.args.class
|
|
31
54
|
});
|
|
32
55
|
}
|
|
@@ -43,7 +66,7 @@ class FormFeedback extends Component {
|
|
|
43
66
|
return feedbackMessageText(this.args.messages);
|
|
44
67
|
}
|
|
45
68
|
static {
|
|
46
|
-
setComponentTemplate(precompileTemplate("<div id={{@id}} class={{this.classes}} data-component=\"form-feedback\" aria-live={{this.ariaLive}} ...attributes>\n {{this.messageText}}\n {{yield}}\n</div>", {
|
|
69
|
+
setComponentTemplate(precompileTemplate("<div id={{@id}} class={{this.classes}} data-component=\"form-feedback\" data-part=\"base\" aria-live={{this.ariaLive}} ...attributes>\n {{this.messageText}}\n {{yield}}\n</div>", {
|
|
47
70
|
strictMode: true
|
|
48
71
|
}), this);
|
|
49
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-feedback.js","sources":["../../../src/components/forms/form-feedback.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { useStyles, type FormFeedbackVariants } from '@frontile/theme';\n\ninterface FormFeedbackSignature {\n Args: {\n /**\n * The id of the feedback element, referenced by the control's\n * `aria-describedby`.\n */\n id?: string;\n\n /**\n * A list of messages or a single message string. An array is joined with `; `.\n */\n messages?: string[] | string;\n\n /**\n * The
|
|
1
|
+
{"version":3,"file":"form-feedback.js","sources":["../../../src/components/forms/form-feedback.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached } from '@glimmer/tracking';\nimport { useStyles, type FormFeedbackVariants } from '@frontile/theme';\nimport { renamedArgValue } from '../../-private/deprecated-args';\n\ninterface FormFeedbackSignature {\n Args: {\n /**\n * The id of the feedback element, referenced by the control's\n * `aria-describedby`.\n */\n id?: string;\n\n /**\n * A list of messages or a single message string. An array is joined with `; `.\n */\n messages?: string[] | string;\n\n /**\n * The status of the feedback, which also decides whether it is announced\n * assertively (`danger`) or politely.\n *\n * @defaultValue 'danger'\n */\n status?: FormFeedbackVariants['status'];\n\n /**\n * @deprecated Use `status`. The name changed because this value also\n * decides whether the message is announced assertively.\n */\n intent?: FormFeedbackVariants['status'];\n\n /**\n * The size of the feedback text.\n *\n * @defaultValue 'md'\n */\n size?: FormFeedbackVariants['size'];\n\n /**\n * Whether the element is itself an `aria-live` region. Set this to `false`\n * when something else (such as `FormControl`, which keeps a persistent\n * live region in the DOM) already announces the messages, so they are not\n * announced twice.\n *\n * @defaultValue true\n */\n announce?: boolean;\n\n /**\n * Class names for the feedback element, merged with the theme's.\n */\n class?: string;\n };\n Element: HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\n/**\n * Renders feedback messages as a single string. An array is joined with `; `.\n *\n * Shared with `FormControl`, whose persistent live region announces the same\n * text, so both render an identical separator.\n *\n * @param messages A list of messages or a single message string.\n * @returns The messages as one string, or an empty string when there are none.\n */\nfunction feedbackMessageText(messages: string[] | string | undefined): string {\n if (!messages) return '';\n\n return typeof messages === 'string' ? messages : messages.join('; ');\n}\n\nclass FormFeedback extends Component<FormFeedbackSignature> {\n /**\n * Resolved once so `isError` and `classes` agree, and so the deprecation\n * fires once per render rather than per reader.\n */\n @cached\n get status(): FormFeedbackVariants['status'] {\n return renamedArgValue(this.args.status, this.args.intent, {} as const, {\n component: 'FormFeedback',\n from: 'intent',\n to: 'status',\n id: 'frontile.form-feedback.intent'\n });\n }\n\n /**\n * Drives `aria-live=\"assertive\"`. The default is `danger`, so the ABSENCE\n * of the arg must stay assertive -- a missing value must never quietly\n * downgrade an error announcement to polite.\n */\n get isError(): boolean {\n return (\n typeof this.args.messages !== 'undefined' &&\n (this.status === 'danger' || typeof this.status === 'undefined')\n );\n }\n\n get classes() {\n const { formFeedback } = useStyles();\n\n return formFeedback({\n size: this.args.size || 'md',\n status: this.status || 'danger',\n class: this.args.class\n });\n }\n\n get announce(): boolean {\n return this.args.announce !== false;\n }\n\n get ariaLive(): string | undefined {\n if (!this.announce) {\n return undefined;\n }\n return this.isError ? 'assertive' : 'polite';\n }\n\n get messageText(): string {\n return feedbackMessageText(this.args.messages);\n }\n\n <template>\n <div\n id={{@id}}\n class={{this.classes}}\n data-component=\"form-feedback\"\n data-part=\"base\"\n aria-live={{this.ariaLive}}\n ...attributes\n >\n {{this.messageText}}\n {{yield}}\n </div>\n </template>\n}\n\nexport { FormFeedback, feedbackMessageText, type FormFeedbackSignature };\nexport default FormFeedback;\n"],"names":["feedbackMessageText","messages","join","FormFeedback","Component","status","renamedArgValue","args","intent","component","from","to","id","n","prototype","cached","isError","classes","formFeedback","useStyles","size","class","announce","ariaLive","undefined","messageText","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;;;;AA4DA;;;;;;;;;AASA,SAASA,oBAAoBC,QAAuC,EAAS;AAC3E,EAAA,IAAI,CAACA,UAAU,OAAO,E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AAQ,EAAE;AAClB,MAAA,OAAOE,SAAA;AACT,IAAA;AACA,IAAA,OAAO,IAAI,CAACR,OAAO,GAAG,WAAA,GAAc,QAAA;AACtC,EAAA;EAEA,IAAIS,WAAAA,GAAsB;AACxB,IAAA,OAAOzB,mBAAA,CAAoB,IAAI,CAACO,IAAI,CAACN,QAAQ,CAAA;AAC/C,EAAA;AAEA,EAAA;IAAAyB,oBAAA,CAAAC,kBAAA,CAAA,oLAAA,EAYA;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -5,9 +5,12 @@ import templateOnly from '@ember/component/template-only';
|
|
|
5
5
|
const IconChevronUpDown = setComponentTemplate(precompileTemplate("<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\" aria-hidden=\"true\" ...attributes>\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M8.25 15 12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9\" />\n</svg>", {
|
|
6
6
|
strictMode: true
|
|
7
7
|
}), templateOnly());
|
|
8
|
+
const IconCalendar = setComponentTemplate(precompileTemplate("<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" aria-hidden=\"true\" ...attributes>\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 7.5v11.25m-18 0A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75m-18 0V11.25A2.25 2.25 0 0 1 5.25 9h13.5A2.25 2.25 0 0 1 21 11.25v7.5\" />\n</svg>", {
|
|
9
|
+
strictMode: true
|
|
10
|
+
}), templateOnly());
|
|
8
11
|
var icons = setComponentTemplate(precompileTemplate("@frontile/froms Icons component is empty, use template imports.", {
|
|
9
12
|
strictMode: true
|
|
10
13
|
}), templateOnly());
|
|
11
14
|
|
|
12
|
-
export { IconChevronUpDown, icons as default };
|
|
15
|
+
export { IconCalendar, IconChevronUpDown, icons as default };
|
|
13
16
|
//# sourceMappingURL=icons.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.js","sources":["../../../src/components/forms/icons.gts"],"sourcesContent":["import type { TOC } from '@ember/component/template-only';\n\nconst IconChevronUpDown: TOC<{\n Element: SVGElement;\n}> = <template>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n aria-hidden=\"true\"\n ...attributes\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M8.25 15 12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9\"\n />\n </svg>\n</template>;\n\nexport { IconChevronUpDown };\n\n<template>\n @frontile/froms Icons component is empty, use template imports.\n</template>\n"],"names":["IconChevronUpDown","setComponentTemplate","precompileTemplate","strictMode","templateOnly"],"mappings":";;;;AAEA,MAAMA,iBAED,GAAAC,oBAAA,CAAAC,kBAAA,CAAA,+RAAA,EAgBL;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA;AAIV,YAAAH,oBAAA,CAAAC,kBAAA,CAAA,iEAAA,EAEA;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"icons.js","sources":["../../../src/components/forms/icons.gts"],"sourcesContent":["import type { TOC } from '@ember/component/template-only';\n\nconst IconChevronUpDown: TOC<{\n Element: SVGElement;\n}> = <template>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke-width=\"1.5\"\n stroke=\"currentColor\"\n aria-hidden=\"true\"\n ...attributes\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M8.25 15 12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9\"\n />\n </svg>\n</template>;\n\nconst IconCalendar: TOC<{\n Element: SVGElement;\n}> = <template>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n aria-hidden=\"true\"\n ...attributes\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n d=\"M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 7.5v11.25m-18 0A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75m-18 0V11.25A2.25 2.25 0 0 1 5.25 9h13.5A2.25 2.25 0 0 1 21 11.25v7.5\"\n />\n </svg>\n</template>;\n\nexport { IconChevronUpDown, IconCalendar };\n\n<template>\n @frontile/froms Icons component is empty, use template imports.\n</template>\n"],"names":["IconChevronUpDown","setComponentTemplate","precompileTemplate","strictMode","templateOnly","IconCalendar"],"mappings":";;;;AAEA,MAAMA,iBAED,GAAAC,oBAAA,CAAAC,kBAAA,CAAA,+RAAA,EAgBL;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA;AAEV,MAAMC,YAED,GAAAJ,oBAAA,CAAAC,kBAAA,CAAA,gdAAA,EAgBL;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA;AAIV,YAAAH,oBAAA,CAAAC,kBAAA,CAAA,iEAAA,EAEA;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA,CAAA;;;;"}
|
|
@@ -15,6 +15,8 @@ export { Radio } from './radio.js';
|
|
|
15
15
|
export { RadioGroup } from './radio-group.js';
|
|
16
16
|
export { FormControl } from './form-control.js';
|
|
17
17
|
export { Switch } from './switch.js';
|
|
18
|
+
export { DatePicker } from './date-picker/date-picker.js';
|
|
19
|
+
export { formatValue, isEmptyValue, parseDate, parseRange, toWire } from './date-picker/value.js';
|
|
18
20
|
export { StandardValidator } from '../../utils/standard-validator.js';
|
|
19
21
|
export { deepEqual, flattenData, hasNestedData, unflattenData } from '../../utils/nested-data.js';
|
|
20
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -393,7 +393,7 @@ class InputOtp extends Component {
|
|
|
393
393
|
decorateMethodV2(this.prototype, "handleOnBlur", [action]);
|
|
394
394
|
}
|
|
395
395
|
static {
|
|
396
|
-
setComponentTemplate(precompileTemplate("<FormControl @size={{@size}} @label={{@label}} @isRequired={{@isRequired}} @description={{@description}} @errors={{@errors}} @isInvalid={{@isInvalid}} @class={{this.classes.base class=@classes.base}} as |c|>\n {{!-- Chrome's translate feature rewrites the cell text nodes, wrapping\n them in <font> elements that Glimmer then tries to update. --}}\n <div class={{this.classes.container class=@classes.container}} data-
|
|
396
|
+
setComponentTemplate(precompileTemplate("<FormControl @size={{@size}} @label={{@label}} @isRequired={{@isRequired}} @description={{@description}} @errors={{@errors}} @isInvalid={{@isInvalid}} @class={{this.classes.base class=@classes.base}} data-component=\"input-otp\" data-part=\"base\" as |c|>\n {{!-- Chrome's translate feature rewrites the cell text nodes, wrapping\n them in <font> elements that Glimmer then tries to update. --}}\n <div class={{this.classes.container class=@classes.container}} data-part=\"container\" translate=\"no\">\n {{#each this.cellGroups key=\"@index\" as |group groupIndex|}}\n {{#if groupIndex}}\n <div class={{this.classes.separator class=@classes.separator}} data-part=\"separator\" aria-hidden=\"true\">{{this.separator}}</div>\n {{/if}}\n <div class={{this.classes.group class=@classes.group}} data-part=\"group\">\n {{#each group key=\"index\" as |cell|}}\n <div class={{this.classes.cell class=@classes.cell isActive=cell.isActive isInvalid=c.isInvalid isDisabled=@isDisabled}} data-part=\"cell\" data-active={{if cell.isActive \"true\"}} aria-hidden=\"true\">\n <span class={{this.classes.cellChar class=@classes.cellChar}} data-part=\"cell-char\">\n {{cell.displayChar}}\n </span>\n {{#if cell.hasFakeCaret}}\n {{!-- Never the only focus affordance -- under\n prefers-reduced-motion it stops blinking and reads as a\n static bar, so the active cell also rings. --}}\n <span class={{this.classes.caret class=@classes.caret}} data-part=\"caret\"></span>\n {{/if}}\n </div>\n {{/each}}\n </div>\n {{/each}}\n\n {{!-- False positive in no-unsupported-role-attributes\n (ember-template-lint 7.9.3). Its getImplicitRole helper matches an\n aria-query key on the type attribute alone and ignores that key's\n other constraints, so a plain text input resolves to the\n list-bearing combobox entry instead of textbox. This input has no\n list attribute, so textbox is its real implicit role, and textbox\n does support aria-placeholder. The rule is disabled for this\n element only, so its autofixer cannot silently delete\n aria-placeholder when someone runs pnpm lint:hbs --fix. See the\n @placeholder test in input-otp-test.gts. --}}\n {{!-- template-lint-disable no-unsupported-role-attributes --}}\n <input {{this.inputRef.setup}} {{this.syncFromValueArg @value}} {{on \"input\" this.handleOnInput}} {{on \"change\" this.handleOnChange}} {{on \"focus\" this.handleFocus}} {{on \"blur\" this.handleOnBlur}} id={{c.id}} name={{@name}} type=\"text\" maxlength={{this.length}} disabled={{@isDisabled}} class={{this.classes.input class=@classes.input}} data-part=\"input\" aria-invalid={{if c.isInvalid \"true\"}} aria-describedby={{c.describedBy @description c.isInvalid}} aria-placeholder={{@placeholder}} autocomplete=\"one-time-code\" inputmode={{this.inputMode}} pattern={{this.pattern.source}} autocapitalize={{this.autoCapitalize}} autocorrect=\"off\" spellcheck=\"false\" ...attributes />\n {{!-- template-lint-enable no-unsupported-role-attributes --}}\n </div>\n</FormControl>", {
|
|
397
397
|
strictMode: true,
|
|
398
398
|
scope: () => ({
|
|
399
399
|
FormControl,
|