frontile 0.18.2 → 0.18.5
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/components/collections/calendar/calendar.d.ts +7 -1
- package/declarations/components/collections/calendar/calendar.d.ts.map +1 -1
- package/declarations/components/collections/calendar/header.d.ts +2 -0
- package/declarations/components/collections/calendar/header.d.ts.map +1 -1
- package/declarations/components/collections/calendar/types.d.ts +15 -0
- package/declarations/components/collections/calendar/types.d.ts.map +1 -1
- package/declarations/components/collections/calendar/year-grid.d.ts +2 -0
- package/declarations/components/collections/calendar/year-grid.d.ts.map +1 -1
- package/declarations/components/forms/autocomplete.d.ts +49 -1
- package/declarations/components/forms/autocomplete.d.ts.map +1 -1
- package/declarations/components/forms/date-input/date-input.d.ts +2 -1
- package/declarations/components/forms/date-input/date-input.d.ts.map +1 -1
- package/declarations/components/forms/date-input/types.d.ts +15 -1
- package/declarations/components/forms/date-input/types.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/date-picker.d.ts +2 -0
- package/declarations/components/forms/date-picker/date-picker.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/end-content.d.ts +3 -1
- package/declarations/components/forms/date-picker/end-content.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/types.d.ts +26 -2
- package/declarations/components/forms/date-picker/types.d.ts.map +1 -1
- package/declarations/components/forms/select/select.d.ts +28 -1
- package/declarations/components/forms/select/select.d.ts.map +1 -1
- package/declarations/components/forms/select/types.d.ts +35 -1
- package/declarations/components/forms/select/types.d.ts.map +1 -1
- package/declarations/utils/filter.d.ts +30 -0
- package/declarations/utils/filter.d.ts.map +1 -1
- package/dist/components/collections/calendar/calendar.js +13 -1
- package/dist/components/collections/calendar/calendar.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/year-grid.js +1 -1
- package/dist/components/collections/calendar/year-grid.js.map +1 -1
- package/dist/components/forms/autocomplete.js +35 -4
- package/dist/components/forms/autocomplete.js.map +1 -1
- package/dist/components/forms/date-input/date-input.js +10 -1
- package/dist/components/forms/date-input/date-input.js.map +1 -1
- package/dist/components/forms/date-picker/date-picker.js +12 -1
- package/dist/components/forms/date-picker/date-picker.js.map +1 -1
- package/dist/components/forms/date-picker/end-content.js +1 -3
- package/dist/components/forms/date-picker/end-content.js.map +1 -1
- package/dist/components/forms/select/select.js +56 -2
- package/dist/components/forms/select/select.js.map +1 -1
- package/dist/utils/filter.js +32 -1
- package/dist/utils/filter.js.map +1 -1
- package/package.json +3 -3
|
@@ -14,8 +14,9 @@ import { triggerFormInputEvent } from '../../utils/forms-utils-index.js';
|
|
|
14
14
|
import { CloseButton } from '../buttons/close-button.js';
|
|
15
15
|
import { I as IconChevronUpDown } from '../../icons-DZ61nCzv.js';
|
|
16
16
|
import { keyAndLabelForItem } from '../../utils/listManager.js';
|
|
17
|
-
import { filterAndRankItems } from '../../utils/filter.js';
|
|
17
|
+
import { filterAndRankItems, limitItems } from '../../utils/filter.js';
|
|
18
18
|
import { cancel, debounce } from '@ember/runloop';
|
|
19
|
+
import { assert } from '@ember/debug';
|
|
19
20
|
import { r as renamedArgValue } from '../../deprecated-args-BIUjLA8y.js';
|
|
20
21
|
import { modifier } from 'ember-modifier';
|
|
21
22
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
@@ -342,12 +343,42 @@ class Autocomplete extends Component {
|
|
|
342
343
|
return filterAndRankItems(this.args.items, this.inputValue, item => keyAndLabelForItem(item).label, this.args.filter);
|
|
343
344
|
}
|
|
344
345
|
/**
|
|
345
|
-
*
|
|
346
|
-
*
|
|
346
|
+
* The options the listbox renders: `filteredItems`, capped by
|
|
347
|
+
* `@displayLimit`.
|
|
347
348
|
*/
|
|
348
349
|
static {
|
|
349
350
|
decorateMethodV2(this.prototype, "filteredItems", [cached]);
|
|
350
351
|
}
|
|
352
|
+
get displayedItems() {
|
|
353
|
+
const {
|
|
354
|
+
displayLimit
|
|
355
|
+
} = this.args;
|
|
356
|
+
assert(`Autocomplete: @displayLimit must be a positive integer, received ${String(displayLimit)}`, displayLimit === undefined || Number.isInteger(displayLimit) && displayLimit > 0);
|
|
357
|
+
const selectedKeys = this.selectedKeys;
|
|
358
|
+
return limitItems(this.filteredItems, displayLimit, item => selectedKeys.includes(keyAndLabelForItem(item).key));
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* What the display limit content reports, or `undefined` when nothing is
|
|
362
|
+
* left out.
|
|
363
|
+
*/
|
|
364
|
+
static {
|
|
365
|
+
decorateMethodV2(this.prototype, "displayedItems", [cached]);
|
|
366
|
+
}
|
|
367
|
+
get displayLimitContent() {
|
|
368
|
+
const shown = this.displayedItems?.length ?? 0;
|
|
369
|
+
const total = this.filteredItems?.length ?? 0;
|
|
370
|
+
if (shown === total || this.args.hideDisplayLimitContent) {
|
|
371
|
+
return undefined;
|
|
372
|
+
}
|
|
373
|
+
return {
|
|
374
|
+
shown,
|
|
375
|
+
total
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* True when an async autocomplete is open with a blank query and nothing
|
|
380
|
+
* to show — the moment to prompt the user to start typing.
|
|
381
|
+
*/
|
|
351
382
|
get isSearchPromptState() {
|
|
352
383
|
return typeof this.args.onSearch === 'function' && !this.isFiltering && !this.isLoading && (this.filteredItems?.length ?? 0) === 0;
|
|
353
384
|
}
|
|
@@ -369,7 +400,7 @@ class Autocomplete extends Component {
|
|
|
369
400
|
}
|
|
370
401
|
});
|
|
371
402
|
static {
|
|
372
|
-
setComponentTemplate(precompileTemplate("<div {{this.updateSelectedKey @selectedKey}} {{this.containerRef.setup}} class={{this.classes.base class=@classes.base}} data-component=\"autocomplete\" data-part=\"base\" ...attributes>\n <FormControl @id={{@id}} @size={{@inputSize}} @label={{@label}} @isRequired={{@isRequired}} @description={{@description}} @errors={{@errors}} @isInvalid={{@isInvalid}} as |c|>\n <Popover @placement={{@placement}} @flipOptions={{@flipOptions}} @middleware={{@middleware}} @shiftOptions={{@shiftOptions}} @offsetOptions={{@offsetOptions}} @strategy={{@strategy}} @didClose={{this.didClose}} @isOpen={{this.isOpen}} @onOpenChange={{this.onOpenChange}} as |p|>\n <VisuallyHidden>\n <NativeSelect @items={{this.
|
|
403
|
+
setComponentTemplate(precompileTemplate("<div {{this.updateSelectedKey @selectedKey}} {{this.containerRef.setup}} class={{this.classes.base class=@classes.base}} data-component=\"autocomplete\" data-part=\"base\" ...attributes>\n <FormControl @id={{@id}} @size={{@inputSize}} @label={{@label}} @isRequired={{@isRequired}} @description={{@description}} @errors={{@errors}} @isInvalid={{@isInvalid}} as |c|>\n <Popover @placement={{@placement}} @flipOptions={{@flipOptions}} @middleware={{@middleware}} @shiftOptions={{@shiftOptions}} @offsetOptions={{@offsetOptions}} @strategy={{@strategy}} @didClose={{this.didClose}} @isOpen={{this.isOpen}} @onOpenChange={{this.onOpenChange}} as |p|>\n <VisuallyHidden>\n {{!-- Limited like the listbox: it holds the options the user can\n pick, and a hidden list of every match would cost the same\n rendering @displayLimit saves. The selection is always kept. --}}\n <NativeSelect @items={{this.displayedItems}} @allowEmpty={{@allowEmpty}} @disabledKeys={{@disabledKeys}} @onSelectionChange={{this.onNativeSelectionChange}} @selectedKey={{this._selectedKey}} @selectionMode=\"single\" @onItemsChange={{this.onItemsChange}} @placeholder={{@placeholder}} @id={{c.id}} @name={{@name}} tabindex=\"-1\" disabled={{@isDisabled}}>\n <:item as |l|>\n <l.Item @key={{l.key}}>\n {{l.label}}\n </l.Item>\n </:item>\n <:default as |l|>\n {{!-- @glint-expect-error: the signature of the native select is not the same as the listbox--}}\n {{yield l to=\"default\"}}\n </:default>\n </NativeSelect>\n </VisuallyHidden>\n\n <div class={{this.classes.innerContainer class=@classes.innerContainer}} data-part=\"inner-container\">\n {{#if (has-block \"startContent\")}}\n <div data-part=\"start-content\" class={{this.classes.startContent class=@classes.startContent startContentPointerEvents=(if @startContentPointerEvents @startContentPointerEvents \"auto\")}}>\n {{yield to=\"startContent\"}}\n </div>\n {{/if}}\n {{!-- aria-expanded and aria-controls are set at runtime by the\n Popover trigger modifier, and role=combobox is not implicit\n on a text input --}}\n {{!-- template-lint-disable no-redundant-role require-mandatory-role-attributes --}}\n <input type=\"text\" role=\"combobox\" aria-autocomplete=\"list\" aria-activedescendant={{this.activeDescendant}} autocomplete=\"off\" autocapitalize=\"off\" autocorrect=\"off\" spellcheck=\"false\" {{p.trigger}} {{p.anchor}} {{this.triggerRef.setup}} data-part=\"input\" disabled={{@isDisabled}} placeholder={{@placeholder}} class={{this.classes.input class=@classes.input hasStartContent=(has-block \"startContent\") hasEndContent=true}} value={{this.inputValue}} {{on \"input\" this.onInput}} {{on \"keydown\" this.onKeyDown}} {{on \"focusout\" this.blurTracker.handleFocusOut}} />\n <div data-part=\"end-content\" class={{this.classes.endContent class=@classes.endContent endContentPointerEvents=(if @endContentPointerEvents @endContentPointerEvents \"none\")}}>\n {{yield to=\"endContent\"}}\n\n {{#if this.isLoading}}\n <Spinner @size={{if (isSm @inputSize) \"xs\" \"sm\"}} />\n {{else if this.isClearable}}\n <CloseButton @title=\"Clear\" @variant=\"soft\" @size=\"xs\" @class={{this.classes.clearButton class=@classes.clearButton}} data-part=\"clear-button\" @onPress={{this.clearSelectedKeys}} />\n {{else}}\n <IconChevronUpDown data-part=\"icon\" class={{this.classes.icon class=@classes.icon}} />\n {{/if}}\n </div>\n </div>\n\n <p.Content @size={{if @popoverSize @popoverSize \"trigger\"}} @target={{@target}} @renderInPlace={{@renderInPlace}} @disableFocusTrap={{this.disableFocusTrap}} @blockScroll={{this.blockScroll}} @transitionDuration={{@transitionDuration}} @backdrop={{this.backdrop}} @disableTransitions={{@disableTransitions}} @focusTrapOptions={{@focusTrapOptions}} @closeOnOutsideClick={{@closeOnOutsideClick}} @closeOnEscapeKey={{@closeOnEscapeKey}} @backdropTransition={{@backdropTransition}} @transition={{@transition}} @preventAutoFocus={{true}}>\n <Listbox @items={{this.displayedItems}} @allowEmpty={{@allowEmpty}} @variant={{this.variant}} @disabledKeys={{@disabledKeys}} @color={{this.color}} @isKeyboardEventsEnabled={{true}} @onAction={{this.onAction}} @onSelectionChange={{this.onSelectionChange}} @onActiveItemChange={{this.onActiveItemChange}} @selectedKeys={{this.selectedKeys}} @selectionMode=\"single\" @type=\"listbox\" @class={{this.classes.listbox class=@classes.listbox}} @elementToAddKeyboardEvents={{this.triggerRef.current}} @autoActivateMode={{this.autoActivateMode}} data-part=\"listbox\">\n <:item as |l|>\n {{#if (has-block \"item\")}}\n {{yield l to=\"item\"}}\n {{else}}\n <l.Item @key={{l.key}} @variant={{this.variant}} @color={{this.color}}>\n {{l.label}}\n </l.Item>\n {{/if}}\n </:item>\n <:default as |l|>\n {{yield l to=\"default\"}}\n </:default>\n </Listbox>\n {{#if (and this.isSearchPromptState (or @searchMessage (has-block \"searchMessage\")))}}\n <div class={{this.classes.emptyContent class=@classes.emptyContent}} data-part=\"empty-content\">\n {{#if (has-block \"searchMessage\")}}\n {{yield to=\"searchMessage\"}}\n {{else}}\n {{@searchMessage}}\n {{/if}}\n </div>\n {{else if this.showEmptyContent}}\n <div class={{this.classes.emptyContent class=@classes.emptyContent}} data-part=\"empty-content\">\n {{#if (has-block \"emptyContent\")}}\n {{yield to=\"emptyContent\"}}\n {{else}}\n No results found.\n {{/if}}\n </div>\n {{/if}}\n {{#if this.displayLimitContent}}\n <div class={{this.classes.displayLimitContent class=@classes.displayLimitContent}} data-part=\"display-limit-content\">\n {{#if (has-block \"displayLimitContent\")}}\n {{yield this.displayLimitContent to=\"displayLimitContent\"}}\n {{else}}\n Showing\n {{this.displayLimitContent.shown}}\n of\n {{this.displayLimitContent.total}}. Type to narrow down.\n {{/if}}\n </div>\n {{/if}}\n </p.Content>\n </Popover>\n </FormControl>\n</div>", {
|
|
373
404
|
strictMode: true,
|
|
374
405
|
scope: () => ({
|
|
375
406
|
FormControl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.js","sources":["../../../src/components/forms/autocomplete.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked, cached } from '@glimmer/tracking';\nimport { on } from '@ember/modifier';\nimport type Owner from '@ember/owner';\nimport { NativeSelect, type ListItem } from './native-select';\nimport { Listbox, type ListboxSignature } from '../collections/listbox';\nimport {\n useStyles,\n type AutocompleteSlots,\n type AutocompleteVariants,\n type SlotsToClasses\n} from '@frontile/theme';\nimport { Spinner } from '../utilities/spinner';\nimport { VisuallyHidden } from '../utilities/visually-hidden';\nimport { ref } from '../../utils/ref';\nimport { ControlBlurTracker } from '../../-private/control-blur';\nimport {\n Popover,\n type PopoverSignature,\n type ContentSignature\n} from '../overlays/popover';\nimport { FormControl, type FormControlSharedArgs } from './form-control';\nimport { triggerFormInputEvent } from '../../utils/forms-utils-index';\nimport { CloseButton } from '../buttons/close-button';\nimport { IconChevronUpDown } from '../../-private/icons';\nimport { keyAndLabelForItem } from '../../utils/listManager';\nimport { filterAndRankItems, type FilterFn } from '../../utils/filter';\nimport { debounce, cancel } from '@ember/runloop';\nimport { renamedArgValue } from '../../-private/deprecated-args';\n\nimport { modifier } from 'ember-modifier';\n\ninterface AutocompleteArgs<T>\n extends\n Pick<\n PopoverSignature['Args'],\n | 'placement'\n | 'flipOptions'\n | 'middleware'\n | 'shiftOptions'\n | 'offsetOptions'\n | 'strategy'\n | 'didClose'\n >,\n Pick<\n ListboxSignature<T>['Args'],\n | 'variant'\n | 'appearance'\n | 'color'\n | 'intent'\n | 'disabledKeys'\n | 'allowEmpty'\n | 'items'\n | 'onAction'\n >,\n Pick<\n ContentSignature['Args'],\n | 'renderInPlace'\n | 'target'\n | 'transitionDuration'\n | 'backdrop'\n | 'disableTransitions'\n | 'focusTrapOptions'\n | 'closeOnOutsideClick'\n | 'closeOnEscapeKey'\n | 'backdropTransition'\n | 'transition'\n >,\n FormControlSharedArgs {\n /**\n * The currently selected key.\n *\n * Autocomplete is single-selection only — for a searchable multi-select,\n * use `Select` with `@isFilterable` and `@selectionMode=\"multiple\"`.\n *\n * **Data Flow:**\n * - Pass this to set the initial selection\n * - Update this in your `onSelectionChange` handler to maintain two-way binding\n * - The component calls `onSelectionChange` whenever the user changes the selection\n */\n selectedKey?: string | null;\n\n /**\n * Callback fired when the selection changes.\n *\n * Update your `@selectedKey` state in this callback to maintain two-way binding.\n *\n * @param key - The newly selected key, or null if selection was cleared\n */\n onSelectionChange?: (key: string | null) => void;\n /**\n * The unique identifier for the autocomplete component.\n */\n id?: string;\n\n /**\n * Defines the input size of the autocomplete.\n */\n inputSize?: AutocompleteVariants['size'];\n\n /**\n * Defines the size of the popover dropdown.\n * - 'sm': Small\n * - 'md': Medium\n * - 'lg': Large\n * - 'trigger': Same size as the trigger\n *\n * @defaultValue 'trigger'\n */\n popoverSize?: 'sm' | 'md' | 'lg' | 'trigger';\n\n /**\n * Custom classes to style different slots within the autocomplete component.\n */\n classes?: SlotsToClasses<AutocompleteSlots>;\n\n /**\n * Whether the autocomplete should close upon selecting an item.\n *\n * @defaultValue true\n */\n closeOnItemSelect?: boolean;\n\n /**\n * Whether scrolling should be blocked when the dropdown is open.\n *\n * @defaultValue true\n */\n blockScroll?: boolean;\n\n /**\n * Whether the focus trap should be disabled when the dropdown is open.\n *\n * @defaultValue true\n */\n disableFocusTrap?: boolean;\n\n /**\n * The placeholder text displayed when the input is empty.\n */\n placeholder?: string;\n\n /**\n * Whether the autocomplete should be disabled, preventing user interaction.\n */\n isDisabled?: boolean;\n\n /**\n * The text value of the input.\n *\n * Pass this together with `onInputChange` to control the input text externally,\n * for example to implement server-side filtering.\n */\n inputValue?: string;\n\n /**\n * Callback fired whenever the user changes the input text.\n *\n * @param value - The current text of the input\n */\n onInputChange?: (value: string) => void;\n\n /**\n * Function to filter the items against the current input text.\n *\n * The default implementation ranks by relevance, so the closest match is\n * listed first rather than whichever match came first in `@items`.\n *\n * @param itemValue - The label of an item in the dropdown.\n * @param inputValue - The user's input text.\n * @returns A number to rank (higher first, `0` means no match) or a boolean\n * to filter only, preserving the order of `@items`.\n */\n filter?: FilterFn;\n\n /**\n * Disables the built-in filtering, rendering `@items` as-is.\n * Use together with `inputValue`/`onInputChange` when filtering happens\n * outside of the component (e.g. server-side).\n *\n * @defaultValue false\n */\n disableFiltering?: boolean;\n\n /**\n * Async search function. When provided, the component calls it (debounced)\n * as the user types and renders the resolved items, showing a loading\n * spinner while the returned promise is pending. Stale responses are\n * ignored (latest query wins). Built-in filtering is disabled; `@items`\n * is used as the initial list before the first search.\n *\n * @param query - The current input text\n * @returns The items matching the query\n */\n onSearch?: (query: string) => Promise<T[]> | T[];\n\n /**\n * Debounce duration, in milliseconds, applied to `onSearch` calls.\n *\n * @defaultValue 250\n */\n searchDebounce?: number;\n\n /**\n * When true, the text typed by the user is kept on blur/close even if it\n * does not match any option. By default the input reverts to the selected\n * item's label (or empty) when the dropdown closes without a selection.\n *\n * @defaultValue false\n */\n allowsCustomValue?: boolean;\n\n /**\n * If true, the autocomplete will show a loading spinner instead of the dropdown icon.\n * The spinner is also shown automatically while an `onSearch` promise is pending.\n */\n isLoading?: boolean;\n\n /**\n * The name attribute for the autocomplete component, useful for form submissions.\n */\n name?: string;\n\n /**\n * Whether to include a clear button in the autocomplete component.\n * If enabled, this allows users to clear the selection and input text.\n *\n * This option deliberately overrides `allowEmpty`: that argument governs\n * deselecting an *option* in the listbox, while this is a separate affordance\n * you opt into for exactly the purpose of emptying the field. Since\n * `allowEmpty` defaults to false, honouring it here would render the button\n * dead by default.\n *\n * No clear button is rendered on a disabled Autocomplete.\n *\n * @defaultValue false\n */\n isClearable?: boolean;\n\n /**\n * Controls pointer-events property of startContent.\n * If you want to pass the click event to the input, set it to `none`.\n *\n * @defaultValue 'auto'\n */\n startContentPointerEvents?: 'none' | 'auto';\n\n /**\n * Controls pointer-events property of endContent.\n * Defaults to `none` to pass click events to the input. If your content\n * needs to capture events, add the `pointer-events-auto` class to that element.\n *\n * @defaultValue 'none'\n */\n endContentPointerEvents?: 'none' | 'auto';\n\n /**\n * If true, hides the empty content when there are no options available.\n *\n * @defaultValue false\n */\n hideEmptyContent?: boolean;\n\n /**\n * Message shown in the dropdown of an async autocomplete (`onSearch`)\n * while the query is blank — e.g. \"Type to search for an address…\".\n * Prompts the user to start typing when they open the dropdown by\n * clicking. Also customizable via the `searchMessage` block.\n */\n searchMessage?: string;\n\n /**\n * Callback fired when focus leaves the Autocomplete.\n *\n * \"Leaves the Autocomplete\" means the whole control: the input *and* its\n * dropdown, which is rendered outside the input in the DOM. Moving focus\n * between them -- which is what clicking an option does -- is not a blur, so\n * this does not fire while the user is picking an option. It fires once, when\n * focus lands somewhere outside the control (or nowhere, with the dropdown\n * closed).\n *\n * This is what `Field` drives blur validation from.\n */\n onBlur?: () => void;\n}\n\ninterface AutocompleteSignature<T> {\n Args: AutocompleteArgs<T>;\n Element: HTMLDivElement;\n Blocks: ListboxSignature<T>['Blocks'] & {\n /**\n * Content to display at the **beginning** of the autocomplete component.\n * This can be an icon, a label, or any custom UI element.\n */\n startContent: [];\n\n /**\n * Content to display at the **end** of the autocomplete component.\n * This can be an icon, a button, or any custom UI element.\n */\n endContent: [];\n\n /**\n * The content to display when there are no matching options.\n * If `hideEmptyContent` argument is true, this content will not be shown.\n */\n emptyContent: [];\n\n /**\n * Message shown in the dropdown of an async autocomplete while the\n * query is blank, prompting the user to start typing. Takes priority\n * over the `searchMessage` argument.\n */\n searchMessage: [];\n };\n}\n\n/**\n * Autocomplete Component - a text input combined with a listbox popover,\n * following the WAI-ARIA 1.2 combobox pattern.\n *\n * Users filter the options by typing (type-ahead). Options can come from a\n * static list (built-in filtering), an externally filtered list\n * (`disableFiltering` + `onInputChange`), or an async source (`onSearch`).\n *\n */\nclass Autocomplete<T = unknown> extends Component<AutocompleteSignature<T>> {\n @tracked nodes: ListItem[] = [];\n @tracked isOpen = false;\n\n /**\n * Internal tracked selection state.\n * Synced with @selectedKey via the updateSelectedKey modifier.\n */\n @tracked _selectedKey: string | null = null;\n\n /**\n * The text the user has typed. `undefined` means the user is not editing,\n * so the input displays the selected item's label instead.\n */\n @tracked _inputValue?: string;\n\n /**\n * Items resolved from the latest `onSearch` call. `undefined` until the\n * first search resolves; `@items` is rendered in the meantime.\n */\n @tracked asyncItems?: T[];\n\n @tracked isSearchPending = false;\n\n /** Monotonic token to discard out-of-order onSearch resolutions. */\n #searchToken = 0;\n\n #pendingSearch?: ReturnType<typeof debounce>;\n\n /** Element id of the currently active (highlighted) option, for aria-activedescendant. */\n @tracked activeDescendant?: string;\n\n /**\n * Label of the selected key, captured at selection time. Needed in async\n * mode, where the selected item may no longer be present in the currently\n * rendered items (e.g. after search results are reset on close).\n */\n @tracked selectedLabel?: string;\n\n containerRef = ref<HTMLDivElement>();\n triggerRef = ref<HTMLInputElement>();\n\n constructor(owner: Owner, args: AutocompleteArgs<T>) {\n super(owner, args);\n this._selectedKey = this.args.selectedKey || null;\n }\n\n willDestroy(): void {\n super.willDestroy();\n if (this.#pendingSearch) {\n cancel(this.#pendingSearch);\n }\n // Nothing may resolve against a destroyed component.\n this.blurTracker.cancel();\n }\n\n onSelectionChange = (keys: string[]) => {\n this.applySelection(keys[0] ?? null);\n };\n\n onNativeSelectionChange = (key: string | null) => {\n this.applySelection(key);\n };\n\n applySelection(key: string | null) {\n this.selectedLabel = key\n ? this.nodes.find((n) => n.key === key)?.textValue\n : undefined;\n this._selectedKey = key;\n this.args.onSelectionChange?.(key);\n this.clearInputValue();\n triggerFormInputEvent(this.containerRef.current);\n }\n\n onOpenChange = (isOpen: boolean) => {\n this.isOpen = isOpen;\n };\n\n onInput = (event: Event) => {\n const target = event.target as HTMLInputElement;\n this.setInputValue(target.value);\n\n if (!this.isOpen) {\n this.isOpen = true;\n }\n };\n\n setInputValue(value: string) {\n this._inputValue = value;\n\n if (typeof this.args.onInputChange === 'function') {\n this.args.onInputChange(value);\n }\n\n if (typeof this.args.onSearch === 'function') {\n if (value === '') {\n // A blank query shows the default `@items` again instead of searching.\n this.resetSearch();\n return;\n }\n\n this.isSearchPending = true;\n this.#pendingSearch = debounce(\n this,\n this.performSearch,\n value,\n this.args.searchDebounce ?? 250\n );\n }\n }\n\n /** Cancels any in-flight search and restores the default `@items`. */\n resetSearch() {\n if (this.#pendingSearch) {\n cancel(this.#pendingSearch);\n }\n this.#searchToken++;\n this.asyncItems = undefined;\n this.isSearchPending = false;\n }\n\n clearInputValue() {\n this._inputValue = undefined;\n if (typeof this.args.onInputChange === 'function') {\n this.args.onInputChange('');\n }\n }\n\n async performSearch(query: string) {\n const token = ++this.#searchToken;\n\n try {\n const result = await this.args.onSearch?.(query);\n if (token === this.#searchToken && !this.isDestroying) {\n this.asyncItems = result;\n }\n } finally {\n if (token === this.#searchToken && !this.isDestroying) {\n this.isSearchPending = false;\n }\n }\n }\n\n onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Enter' && this.isOpen) {\n // Prevent form submission while the dropdown is open. Selecting the\n // active option is the Listbox's job: it handles Enter on keydown, so\n // canceling this event no longer suppresses the one it listens to.\n event.preventDefault();\n }\n };\n\n /** Current selection as an array, for the Listbox / NativeSelect API. */\n get selectedKeys(): string[] {\n return this._selectedKey ? [this._selectedKey] : [];\n }\n\n get blockScroll() {\n return this.args.blockScroll !== false;\n }\n\n get disableFocusTrap() {\n return this.args.disableFocusTrap !== false;\n }\n\n onAction = (key: string) => {\n if (typeof this.args.onAction === 'function') {\n this.args.onAction(key);\n }\n\n if (this.args.closeOnItemSelect !== false) {\n this.isOpen = false;\n }\n\n // Deliberately does not touch `@onBlur`. Picking an option is not focus\n // leaving the control; `blurTracker` decides that from the input's own\n // `focusout`.\n };\n\n /**\n * Reports focus leaving the *whole* control -- the input and its portaled\n * dropdown -- rather than the input, which blurs on the way into the\n * dropdown whenever an option is clicked. See `ControlBlurTracker`.\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 clearSelectedKeys = () => {\n this.onSelectionChange([]);\n this.clearInputValue();\n this.triggerRef.current?.focus();\n };\n\n onItemsChange = (nodes: ListItem[], _: 'add' | 'remove') => {\n this.nodes = nodes;\n };\n\n didClose = () => {\n if (!this.args.allowsCustomValue) {\n this._inputValue = undefined;\n }\n this.activeDescendant = undefined;\n\n // Reset async results so reopening shows the default `@items` again.\n if (typeof this.args.onSearch === 'function') {\n this.resetSearch();\n }\n\n this.args.didClose?.();\n };\n\n onActiveItemChange = (_key?: string, item?: ListItem) => {\n this.activeDescendant = item?.el.id || undefined;\n };\n\n get selectedTextValue(): string {\n const key = this._selectedKey;\n if (!key) {\n return '';\n }\n const node = this.nodes.find((n) => n.key === key);\n return node?.textValue ?? this.selectedLabel ?? key;\n }\n\n get inputValue(): string {\n if (typeof this.args.inputValue === 'string') {\n return this.args.inputValue;\n }\n if (this._inputValue !== undefined) {\n return this._inputValue;\n }\n return this.selectedTextValue;\n }\n\n get isFiltering(): boolean {\n const value =\n typeof this.args.inputValue === 'string'\n ? this.args.inputValue\n : this._inputValue;\n\n return typeof value === 'string' && value !== '';\n }\n\n get backdrop() {\n return this.args.backdrop ?? 'transparent';\n }\n\n @cached\n get classes() {\n const { autocomplete } = useStyles();\n // Referenced here, on the always-rendered root, so `@appearance`/\n // `@variant` (and `@intent`/`@color`) raises its deprecation regardless\n // of whether the popover content (and so the internal `Listbox`) is\n // currently mounted.\n void this.variant;\n void this.color;\n return autocomplete({\n size: this.args.inputSize\n });\n }\n\n /**\n * Resolved once (`@cached`) and forwarded to the internal `Listbox` as\n * `@variant` only -- never `@appearance` as well, which would make the\n * inner `Listbox` raise its own deprecation for the same usage.\n */\n @cached\n get variant() {\n return renamedArgValue(\n this.args.variant,\n this.args.appearance,\n { default: 'solid', outlined: 'outline', faded: 'subtle' } as const,\n {\n component: 'Autocomplete',\n from: 'appearance',\n to: 'variant',\n id: 'frontile.autocomplete.appearance'\n }\n );\n }\n\n /**\n * Resolved once (`@cached`) and forwarded to the internal `Listbox` as\n * `@color` only -- never `@intent` as well, which would make the inner\n * `Listbox` raise its own deprecation for the same usage.\n */\n @cached\n get color() {\n return renamedArgValue(\n this.args.color,\n this.args.intent,\n { default: 'neutral' } as const,\n {\n component: 'Autocomplete',\n from: 'intent',\n to: 'color',\n id: 'frontile.autocomplete.intent'\n }\n );\n }\n\n /**\n * Whether the clear button takes the chevron's place: something to clear,\n * and a control that can act on it.\n *\n * `@allowEmpty` is deliberately not consulted -- it governs deselecting an\n * *option* in the listbox, while `@isClearable` is a separate affordance the\n * consumer opts into for exactly this purpose (and `@allowEmpty` defaults to\n * false, so honouring it here would leave the button dead by default). A\n * disabled Autocomplete shows no clear button at all: it carries no disabled\n * state of its own, so it would be a focusable button that clears a field\n * the user is not allowed to change.\n */\n get isClearable() {\n return (\n this.args.isClearable &&\n !this.args.isDisabled &&\n (this.selectedKeys.length > 0 || this.isFiltering)\n );\n }\n\n get isLoading() {\n return this.args.isLoading || this.isSearchPending;\n }\n\n @cached\n get filteredItems() {\n if (typeof this.args.onSearch === 'function') {\n return this.asyncItems ?? this.args.items;\n }\n\n if (this.args.disableFiltering || !this.isFiltering) {\n return this.args.items;\n }\n\n return filterAndRankItems(\n this.args.items,\n this.inputValue,\n (item) => keyAndLabelForItem(item).label,\n this.args.filter\n );\n }\n\n /**\n * True when an async autocomplete is open with a blank query and nothing\n * to show — the moment to prompt the user to start typing.\n */\n get isSearchPromptState(): boolean {\n return (\n typeof this.args.onSearch === 'function' &&\n !this.isFiltering &&\n !this.isLoading &&\n (this.filteredItems?.length ?? 0) === 0\n );\n }\n\n get showEmptyContent() {\n return (\n this.filteredItems?.length === 0 &&\n !this.isLoading &&\n !this.args.hideEmptyContent\n );\n }\n\n get autoActivateMode(): 'first' | 'selected' {\n if (this.isFiltering) {\n return 'first';\n }\n return 'selected';\n }\n\n /**\n * Syncs internal `_selectedKey` with external `@selectedKey` argument.\n */\n updateSelectedKey = modifier(\n (_: HTMLDivElement, [selectedKey]: [string | null | undefined]) => {\n if (selectedKey !== undefined) {\n this._selectedKey = selectedKey;\n }\n }\n );\n\n <template>\n <div\n {{this.updateSelectedKey @selectedKey}}\n {{this.containerRef.setup}}\n class={{this.classes.base class=@classes.base}}\n data-component=\"autocomplete\"\n data-part=\"base\"\n ...attributes\n >\n <FormControl\n @id={{@id}}\n @size={{@inputSize}}\n @label={{@label}}\n @isRequired={{@isRequired}}\n @description={{@description}}\n @errors={{@errors}}\n @isInvalid={{@isInvalid}}\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={{this.didClose}}\n @isOpen={{this.isOpen}}\n @onOpenChange={{this.onOpenChange}}\n as |p|\n >\n <VisuallyHidden>\n <NativeSelect\n @items={{this.filteredItems}}\n @allowEmpty={{@allowEmpty}}\n @disabledKeys={{@disabledKeys}}\n @onSelectionChange={{this.onNativeSelectionChange}}\n @selectedKey={{this._selectedKey}}\n @selectionMode=\"single\"\n @onItemsChange={{this.onItemsChange}}\n @placeholder={{@placeholder}}\n @id={{c.id}}\n @name={{@name}}\n tabindex=\"-1\"\n disabled={{@isDisabled}}\n >\n <:item as |l|>\n <l.Item @key={{l.key}}>\n {{l.label}}\n </l.Item>\n </:item>\n <:default as |l|>\n {{! @glint-expect-error: the signature of the native select is not the same as the listbox}}\n {{yield l to=\"default\"}}\n </:default>\n </NativeSelect>\n </VisuallyHidden>\n\n <div\n class={{this.classes.innerContainer class=@classes.innerContainer}}\n data-part=\"inner-container\"\n >\n {{#if (has-block \"startContent\")}}\n <div\n data-part=\"start-content\"\n class={{this.classes.startContent\n class=@classes.startContent\n startContentPointerEvents=(if\n @startContentPointerEvents @startContentPointerEvents \"auto\"\n )\n }}\n >\n {{yield to=\"startContent\"}}\n </div>\n {{/if}}\n {{! aria-expanded and aria-controls are set at runtime by the\n Popover trigger modifier, and role=combobox is not implicit\n on a text input }}\n {{! template-lint-disable no-redundant-role require-mandatory-role-attributes }}\n <input\n type=\"text\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-activedescendant={{this.activeDescendant}}\n autocomplete=\"off\"\n autocapitalize=\"off\"\n autocorrect=\"off\"\n spellcheck=\"false\"\n {{p.trigger}}\n {{p.anchor}}\n {{this.triggerRef.setup}}\n data-part=\"input\"\n disabled={{@isDisabled}}\n placeholder={{@placeholder}}\n class={{this.classes.input\n class=@classes.input\n hasStartContent=(has-block \"startContent\")\n hasEndContent=true\n }}\n value={{this.inputValue}}\n {{on \"input\" this.onInput}}\n {{on \"keydown\" this.onKeyDown}}\n {{on \"focusout\" this.blurTracker.handleFocusOut}}\n />\n <div\n data-part=\"end-content\"\n class={{this.classes.endContent\n class=@classes.endContent\n endContentPointerEvents=(if\n @endContentPointerEvents @endContentPointerEvents \"none\"\n )\n }}\n >\n {{yield to=\"endContent\"}}\n\n {{#if this.isLoading}}\n <Spinner @size={{if (isSm @inputSize) \"xs\" \"sm\"}} />\n {{else if this.isClearable}}\n <CloseButton\n @title=\"Clear\"\n @variant=\"soft\"\n @size=\"xs\"\n @class={{this.classes.clearButton class=@classes.clearButton}}\n data-part=\"clear-button\"\n @onPress={{this.clearSelectedKeys}}\n />\n {{else}}\n <IconChevronUpDown\n data-part=\"icon\"\n class={{this.classes.icon class=@classes.icon}}\n />\n {{/if}}\n </div>\n </div>\n\n <p.Content\n @size={{if @popoverSize @popoverSize \"trigger\"}}\n @target={{@target}}\n @renderInPlace={{@renderInPlace}}\n @disableFocusTrap={{this.disableFocusTrap}}\n @blockScroll={{this.blockScroll}}\n @transitionDuration={{@transitionDuration}}\n @backdrop={{this.backdrop}}\n @disableTransitions={{@disableTransitions}}\n @focusTrapOptions={{@focusTrapOptions}}\n @closeOnOutsideClick={{@closeOnOutsideClick}}\n @closeOnEscapeKey={{@closeOnEscapeKey}}\n @backdropTransition={{@backdropTransition}}\n @transition={{@transition}}\n @preventAutoFocus={{true}}\n >\n <Listbox\n @items={{this.filteredItems}}\n @allowEmpty={{@allowEmpty}}\n @variant={{this.variant}}\n @disabledKeys={{@disabledKeys}}\n @color={{this.color}}\n @isKeyboardEventsEnabled={{true}}\n @onAction={{this.onAction}}\n @onSelectionChange={{this.onSelectionChange}}\n @onActiveItemChange={{this.onActiveItemChange}}\n @selectedKeys={{this.selectedKeys}}\n @selectionMode=\"single\"\n @type=\"listbox\"\n @class={{this.classes.listbox class=@classes.listbox}}\n @elementToAddKeyboardEvents={{this.triggerRef.current}}\n @autoActivateMode={{this.autoActivateMode}}\n data-part=\"listbox\"\n >\n <:item as |l|>\n {{#if (has-block \"item\")}}\n {{yield l to=\"item\"}}\n {{else}}\n <l.Item\n @key={{l.key}}\n @variant={{this.variant}}\n @color={{this.color}}\n >\n {{l.label}}\n </l.Item>\n {{/if}}\n </:item>\n <:default as |l|>\n {{yield l to=\"default\"}}\n </:default>\n </Listbox>\n {{#if\n (and\n this.isSearchPromptState\n (or @searchMessage (has-block \"searchMessage\"))\n )\n }}\n <div\n class={{this.classes.emptyContent class=@classes.emptyContent}}\n data-part=\"empty-content\"\n >\n {{#if (has-block \"searchMessage\")}}\n {{yield to=\"searchMessage\"}}\n {{else}}\n {{@searchMessage}}\n {{/if}}\n </div>\n {{else if this.showEmptyContent}}\n <div\n class={{this.classes.emptyContent class=@classes.emptyContent}}\n data-part=\"empty-content\"\n >\n {{#if (has-block \"emptyContent\")}}\n {{yield to=\"emptyContent\"}}\n {{else}}\n No results found.\n {{/if}}\n </div>\n {{/if}}\n </p.Content>\n </Popover>\n </FormControl>\n </div>\n </template>\n}\n\nconst isSm = (size: AutocompleteVariants['size']) => size === 'sm';\nconst and = (a: unknown, b: unknown) => Boolean(a) && Boolean(b);\nconst or = (a: unknown, b: unknown) => Boolean(a) || Boolean(b);\n\nexport { Autocomplete, type AutocompleteSignature };\nexport default Autocomplete;\n"],"names":["Autocomplete","Component","g","prototype","tracked","i","containerRef","ref","triggerRef","constructor","owner","args","_selectedKey","selectedKey","willDestroy","cancel","blurTracker","onSelectionChange","keys","applySelection","onNativeSelectionChange","key","selectedLabel","nodes","find","n","textValue","undefined","clearInputValue","triggerFormInputEvent","current","onOpenChange","isOpen","onInput","event","target","setInputValue","value","_inputValue","onInputChange","onSearch","resetSearch","isSearchPending","debounce","performSearch","searchDebounce","asyncItems","query","token","result","isDestroying","onKeyDown","preventDefault","selectedKeys","blockScroll","disableFocusTrap","onAction","closeOnItemSelect","ControlBlurTracker","trigger","container","isDestroyed","onBlur","clearSelectedKeys","focus","onItemsChange","_","didClose","allowsCustomValue","activeDescendant","onActiveItemChange","_key","item","el","id","selectedTextValue","node","inputValue","isFiltering","backdrop","classes","autocomplete","useStyles","variant","color","size","inputSize","cached","renamedArgValue","appearance","default","outlined","faded","component","from","to","intent","isClearable","isDisabled","length","isLoading","filteredItems","items","disableFiltering","filterAndRankItems","keyAndLabelForItem","label","filter","isSearchPromptState","showEmptyContent","hideEmptyContent","autoActivateMode","updateSelectedKey","modifier","setComponentTemplate","precompileTemplate","strictMode","scope","FormControl","Popover","VisuallyHidden","NativeSelect","on","Spinner","isSm","CloseButton","IconChevronUpDown","Listbox","and","or","a","b","Boolean"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6TA;;;;;;;;AAQC;AACD,MAAMA,YAAA,SAAkCC,UAAgC;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,OAAA,EAAA,CACrEC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAA4B,EAAE;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,MAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,OAAA,CAAA,EAAA,MAAA;AAAA,EAAA;IAAAH,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CAC9BC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAiB,KAAA;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,OAAA,I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":["../../../src/components/forms/autocomplete.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked, cached } from '@glimmer/tracking';\nimport { on } from '@ember/modifier';\nimport type Owner from '@ember/owner';\nimport { NativeSelect, type ListItem } from './native-select';\nimport { Listbox, type ListboxSignature } from '../collections/listbox';\nimport {\n useStyles,\n type AutocompleteSlots,\n type AutocompleteVariants,\n type SlotsToClasses\n} from '@frontile/theme';\nimport { Spinner } from '../utilities/spinner';\nimport { VisuallyHidden } from '../utilities/visually-hidden';\nimport { ref } from '../../utils/ref';\nimport { ControlBlurTracker } from '../../-private/control-blur';\nimport {\n Popover,\n type PopoverSignature,\n type ContentSignature\n} from '../overlays/popover';\nimport { FormControl, type FormControlSharedArgs } from './form-control';\nimport { triggerFormInputEvent } from '../../utils/forms-utils-index';\nimport { CloseButton } from '../buttons/close-button';\nimport { IconChevronUpDown } from '../../-private/icons';\nimport { keyAndLabelForItem } from '../../utils/listManager';\nimport {\n filterAndRankItems,\n limitItems,\n type FilterFn,\n type DisplayLimitContentArgs\n} from '../../utils/filter';\nimport { debounce, cancel } from '@ember/runloop';\nimport { assert } from '@ember/debug';\nimport { renamedArgValue } from '../../-private/deprecated-args';\n\nimport { modifier } from 'ember-modifier';\n\ninterface AutocompleteArgs<T>\n extends\n Pick<\n PopoverSignature['Args'],\n | 'placement'\n | 'flipOptions'\n | 'middleware'\n | 'shiftOptions'\n | 'offsetOptions'\n | 'strategy'\n | 'didClose'\n >,\n Pick<\n ListboxSignature<T>['Args'],\n | 'variant'\n | 'appearance'\n | 'color'\n | 'intent'\n | 'disabledKeys'\n | 'allowEmpty'\n | 'items'\n | 'onAction'\n >,\n Pick<\n ContentSignature['Args'],\n | 'renderInPlace'\n | 'target'\n | 'transitionDuration'\n | 'backdrop'\n | 'disableTransitions'\n | 'focusTrapOptions'\n | 'closeOnOutsideClick'\n | 'closeOnEscapeKey'\n | 'backdropTransition'\n | 'transition'\n >,\n FormControlSharedArgs {\n /**\n * The currently selected key.\n *\n * Autocomplete is single-selection only — for a searchable multi-select,\n * use `Select` with `@isFilterable` and `@selectionMode=\"multiple\"`.\n *\n * **Data Flow:**\n * - Pass this to set the initial selection\n * - Update this in your `onSelectionChange` handler to maintain two-way binding\n * - The component calls `onSelectionChange` whenever the user changes the selection\n */\n selectedKey?: string | null;\n\n /**\n * Callback fired when the selection changes.\n *\n * Update your `@selectedKey` state in this callback to maintain two-way binding.\n *\n * @param key - The newly selected key, or null if selection was cleared\n */\n onSelectionChange?: (key: string | null) => void;\n /**\n * The unique identifier for the autocomplete component.\n */\n id?: string;\n\n /**\n * Defines the input size of the autocomplete.\n */\n inputSize?: AutocompleteVariants['size'];\n\n /**\n * Defines the size of the popover dropdown.\n * - 'sm': Small\n * - 'md': Medium\n * - 'lg': Large\n * - 'trigger': Same size as the trigger\n *\n * @defaultValue 'trigger'\n */\n popoverSize?: 'sm' | 'md' | 'lg' | 'trigger';\n\n /**\n * Custom classes to style different slots within the autocomplete component.\n */\n classes?: SlotsToClasses<AutocompleteSlots>;\n\n /**\n * Whether the autocomplete should close upon selecting an item.\n *\n * @defaultValue true\n */\n closeOnItemSelect?: boolean;\n\n /**\n * Whether scrolling should be blocked when the dropdown is open.\n *\n * @defaultValue true\n */\n blockScroll?: boolean;\n\n /**\n * Whether the focus trap should be disabled when the dropdown is open.\n *\n * @defaultValue true\n */\n disableFocusTrap?: boolean;\n\n /**\n * The placeholder text displayed when the input is empty.\n */\n placeholder?: string;\n\n /**\n * Whether the autocomplete should be disabled, preventing user interaction.\n */\n isDisabled?: boolean;\n\n /**\n * The text value of the input.\n *\n * Pass this together with `onInputChange` to control the input text externally,\n * for example to implement server-side filtering.\n */\n inputValue?: string;\n\n /**\n * Callback fired whenever the user changes the input text.\n *\n * @param value - The current text of the input\n */\n onInputChange?: (value: string) => void;\n\n /**\n * Function to filter the items against the current input text.\n *\n * The default implementation ranks by relevance, so the closest match is\n * listed first rather than whichever match came first in `@items`.\n *\n * @param itemValue - The label of an item in the dropdown.\n * @param inputValue - The user's input text.\n * @returns A number to rank (higher first, `0` means no match) or a boolean\n * to filter only, preserving the order of `@items`.\n */\n filter?: FilterFn;\n\n /**\n * Disables the built-in filtering, rendering `@items` as-is.\n * Use together with `inputValue`/`onInputChange` when filtering happens\n * outside of the component (e.g. server-side).\n *\n * @defaultValue false\n */\n disableFiltering?: boolean;\n\n /**\n * The most options the dropdown renders at once.\n *\n * Every rendered option is DOM to build, and to rebuild on each keystroke as\n * the matches change, so a list of hundreds of options makes typing lag.\n * With a limit, only the first `displayLimit` options are rendered, in the\n * order the filter ranked them, and the `displayLimitContent` block says how\n * many more there are. The rest are reached by typing a narrower query.\n *\n * It caps whatever the dropdown would show: the built-in matches, `@items`\n * under `disableFiltering`, or the results of `onSearch`. The selected\n * option is always rendered, even past the limit.\n *\n * @defaultValue undefined (every option is rendered)\n */\n displayLimit?: number;\n\n /**\n * Async search function. When provided, the component calls it (debounced)\n * as the user types and renders the resolved items, showing a loading\n * spinner while the returned promise is pending. Stale responses are\n * ignored (latest query wins). Built-in filtering is disabled; `@items`\n * is used as the initial list before the first search.\n *\n * @param query - The current input text\n * @returns The items matching the query\n */\n onSearch?: (query: string) => Promise<T[]> | T[];\n\n /**\n * Debounce duration, in milliseconds, applied to `onSearch` calls.\n *\n * @defaultValue 250\n */\n searchDebounce?: number;\n\n /**\n * When true, the text typed by the user is kept on blur/close even if it\n * does not match any option. By default the input reverts to the selected\n * item's label (or empty) when the dropdown closes without a selection.\n *\n * @defaultValue false\n */\n allowsCustomValue?: boolean;\n\n /**\n * If true, the autocomplete will show a loading spinner instead of the dropdown icon.\n * The spinner is also shown automatically while an `onSearch` promise is pending.\n */\n isLoading?: boolean;\n\n /**\n * The name attribute for the autocomplete component, useful for form submissions.\n */\n name?: string;\n\n /**\n * Whether to include a clear button in the autocomplete component.\n * If enabled, this allows users to clear the selection and input text.\n *\n * This option deliberately overrides `allowEmpty`: that argument governs\n * deselecting an *option* in the listbox, while this is a separate affordance\n * you opt into for exactly the purpose of emptying the field. Since\n * `allowEmpty` defaults to false, honouring it here would render the button\n * dead by default.\n *\n * No clear button is rendered on a disabled Autocomplete.\n *\n * @defaultValue false\n */\n isClearable?: boolean;\n\n /**\n * Controls pointer-events property of startContent.\n * If you want to pass the click event to the input, set it to `none`.\n *\n * @defaultValue 'auto'\n */\n startContentPointerEvents?: 'none' | 'auto';\n\n /**\n * Controls pointer-events property of endContent.\n * Defaults to `none` to pass click events to the input. If your content\n * needs to capture events, add the `pointer-events-auto` class to that element.\n *\n * @defaultValue 'none'\n */\n endContentPointerEvents?: 'none' | 'auto';\n\n /**\n * If true, hides the empty content when there are no options available.\n *\n * @defaultValue false\n */\n hideEmptyContent?: boolean;\n\n /**\n * If true, hides the display limit content when `@displayLimit` leaves\n * options out.\n *\n * @defaultValue false\n */\n hideDisplayLimitContent?: boolean;\n\n /**\n * Message shown in the dropdown of an async autocomplete (`onSearch`)\n * while the query is blank — e.g. \"Type to search for an address…\".\n * Prompts the user to start typing when they open the dropdown by\n * clicking. Also customizable via the `searchMessage` block.\n */\n searchMessage?: string;\n\n /**\n * Callback fired when focus leaves the Autocomplete.\n *\n * \"Leaves the Autocomplete\" means the whole control: the input *and* its\n * dropdown, which is rendered outside the input in the DOM. Moving focus\n * between them -- which is what clicking an option does -- is not a blur, so\n * this does not fire while the user is picking an option. It fires once, when\n * focus lands somewhere outside the control (or nowhere, with the dropdown\n * closed).\n *\n * This is what `Field` drives blur validation from.\n */\n onBlur?: () => void;\n}\n\ninterface AutocompleteSignature<T> {\n Args: AutocompleteArgs<T>;\n Element: HTMLDivElement;\n Blocks: ListboxSignature<T>['Blocks'] & {\n /**\n * Content to display at the **beginning** of the autocomplete component.\n * This can be an icon, a label, or any custom UI element.\n */\n startContent: [];\n\n /**\n * Content to display at the **end** of the autocomplete component.\n * This can be an icon, a button, or any custom UI element.\n */\n endContent: [];\n\n /**\n * The content to display when there are no matching options.\n * If `hideEmptyContent` argument is true, this content will not be shown.\n */\n emptyContent: [];\n\n /**\n * The content to display below the options when `@displayLimit` leaves\n * some of them out. Yields how many options are shown and how many match\n * in total. If `hideDisplayLimitContent` argument is true, this content\n * will not be shown.\n */\n displayLimitContent: [DisplayLimitContentArgs];\n\n /**\n * Message shown in the dropdown of an async autocomplete while the\n * query is blank, prompting the user to start typing. Takes priority\n * over the `searchMessage` argument.\n */\n searchMessage: [];\n };\n}\n\n/**\n * Autocomplete Component - a text input combined with a listbox popover,\n * following the WAI-ARIA 1.2 combobox pattern.\n *\n * Users filter the options by typing (type-ahead). Options can come from a\n * static list (built-in filtering), an externally filtered list\n * (`disableFiltering` + `onInputChange`), or an async source (`onSearch`).\n *\n */\nclass Autocomplete<T = unknown> extends Component<AutocompleteSignature<T>> {\n @tracked nodes: ListItem[] = [];\n @tracked isOpen = false;\n\n /**\n * Internal tracked selection state.\n * Synced with @selectedKey via the updateSelectedKey modifier.\n */\n @tracked _selectedKey: string | null = null;\n\n /**\n * The text the user has typed. `undefined` means the user is not editing,\n * so the input displays the selected item's label instead.\n */\n @tracked _inputValue?: string;\n\n /**\n * Items resolved from the latest `onSearch` call. `undefined` until the\n * first search resolves; `@items` is rendered in the meantime.\n */\n @tracked asyncItems?: T[];\n\n @tracked isSearchPending = false;\n\n /** Monotonic token to discard out-of-order onSearch resolutions. */\n #searchToken = 0;\n\n #pendingSearch?: ReturnType<typeof debounce>;\n\n /** Element id of the currently active (highlighted) option, for aria-activedescendant. */\n @tracked activeDescendant?: string;\n\n /**\n * Label of the selected key, captured at selection time. Needed in async\n * mode, where the selected item may no longer be present in the currently\n * rendered items (e.g. after search results are reset on close).\n */\n @tracked selectedLabel?: string;\n\n containerRef = ref<HTMLDivElement>();\n triggerRef = ref<HTMLInputElement>();\n\n constructor(owner: Owner, args: AutocompleteArgs<T>) {\n super(owner, args);\n this._selectedKey = this.args.selectedKey || null;\n }\n\n willDestroy(): void {\n super.willDestroy();\n if (this.#pendingSearch) {\n cancel(this.#pendingSearch);\n }\n // Nothing may resolve against a destroyed component.\n this.blurTracker.cancel();\n }\n\n onSelectionChange = (keys: string[]) => {\n this.applySelection(keys[0] ?? null);\n };\n\n onNativeSelectionChange = (key: string | null) => {\n this.applySelection(key);\n };\n\n applySelection(key: string | null) {\n this.selectedLabel = key\n ? this.nodes.find((n) => n.key === key)?.textValue\n : undefined;\n this._selectedKey = key;\n this.args.onSelectionChange?.(key);\n this.clearInputValue();\n triggerFormInputEvent(this.containerRef.current);\n }\n\n onOpenChange = (isOpen: boolean) => {\n this.isOpen = isOpen;\n };\n\n onInput = (event: Event) => {\n const target = event.target as HTMLInputElement;\n this.setInputValue(target.value);\n\n if (!this.isOpen) {\n this.isOpen = true;\n }\n };\n\n setInputValue(value: string) {\n this._inputValue = value;\n\n if (typeof this.args.onInputChange === 'function') {\n this.args.onInputChange(value);\n }\n\n if (typeof this.args.onSearch === 'function') {\n if (value === '') {\n // A blank query shows the default `@items` again instead of searching.\n this.resetSearch();\n return;\n }\n\n this.isSearchPending = true;\n this.#pendingSearch = debounce(\n this,\n this.performSearch,\n value,\n this.args.searchDebounce ?? 250\n );\n }\n }\n\n /** Cancels any in-flight search and restores the default `@items`. */\n resetSearch() {\n if (this.#pendingSearch) {\n cancel(this.#pendingSearch);\n }\n this.#searchToken++;\n this.asyncItems = undefined;\n this.isSearchPending = false;\n }\n\n clearInputValue() {\n this._inputValue = undefined;\n if (typeof this.args.onInputChange === 'function') {\n this.args.onInputChange('');\n }\n }\n\n async performSearch(query: string) {\n const token = ++this.#searchToken;\n\n try {\n const result = await this.args.onSearch?.(query);\n if (token === this.#searchToken && !this.isDestroying) {\n this.asyncItems = result;\n }\n } finally {\n if (token === this.#searchToken && !this.isDestroying) {\n this.isSearchPending = false;\n }\n }\n }\n\n onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Enter' && this.isOpen) {\n // Prevent form submission while the dropdown is open. Selecting the\n // active option is the Listbox's job: it handles Enter on keydown, so\n // canceling this event no longer suppresses the one it listens to.\n event.preventDefault();\n }\n };\n\n /** Current selection as an array, for the Listbox / NativeSelect API. */\n get selectedKeys(): string[] {\n return this._selectedKey ? [this._selectedKey] : [];\n }\n\n get blockScroll() {\n return this.args.blockScroll !== false;\n }\n\n get disableFocusTrap() {\n return this.args.disableFocusTrap !== false;\n }\n\n onAction = (key: string) => {\n if (typeof this.args.onAction === 'function') {\n this.args.onAction(key);\n }\n\n if (this.args.closeOnItemSelect !== false) {\n this.isOpen = false;\n }\n\n // Deliberately does not touch `@onBlur`. Picking an option is not focus\n // leaving the control; `blurTracker` decides that from the input's own\n // `focusout`.\n };\n\n /**\n * Reports focus leaving the *whole* control -- the input and its portaled\n * dropdown -- rather than the input, which blurs on the way into the\n * dropdown whenever an option is clicked. See `ControlBlurTracker`.\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 clearSelectedKeys = () => {\n this.onSelectionChange([]);\n this.clearInputValue();\n this.triggerRef.current?.focus();\n };\n\n onItemsChange = (nodes: ListItem[], _: 'add' | 'remove') => {\n this.nodes = nodes;\n };\n\n didClose = () => {\n if (!this.args.allowsCustomValue) {\n this._inputValue = undefined;\n }\n this.activeDescendant = undefined;\n\n // Reset async results so reopening shows the default `@items` again.\n if (typeof this.args.onSearch === 'function') {\n this.resetSearch();\n }\n\n this.args.didClose?.();\n };\n\n onActiveItemChange = (_key?: string, item?: ListItem) => {\n this.activeDescendant = item?.el.id || undefined;\n };\n\n get selectedTextValue(): string {\n const key = this._selectedKey;\n if (!key) {\n return '';\n }\n const node = this.nodes.find((n) => n.key === key);\n return node?.textValue ?? this.selectedLabel ?? key;\n }\n\n get inputValue(): string {\n if (typeof this.args.inputValue === 'string') {\n return this.args.inputValue;\n }\n if (this._inputValue !== undefined) {\n return this._inputValue;\n }\n return this.selectedTextValue;\n }\n\n get isFiltering(): boolean {\n const value =\n typeof this.args.inputValue === 'string'\n ? this.args.inputValue\n : this._inputValue;\n\n return typeof value === 'string' && value !== '';\n }\n\n get backdrop() {\n return this.args.backdrop ?? 'transparent';\n }\n\n @cached\n get classes() {\n const { autocomplete } = useStyles();\n // Referenced here, on the always-rendered root, so `@appearance`/\n // `@variant` (and `@intent`/`@color`) raises its deprecation regardless\n // of whether the popover content (and so the internal `Listbox`) is\n // currently mounted.\n void this.variant;\n void this.color;\n return autocomplete({\n size: this.args.inputSize\n });\n }\n\n /**\n * Resolved once (`@cached`) and forwarded to the internal `Listbox` as\n * `@variant` only -- never `@appearance` as well, which would make the\n * inner `Listbox` raise its own deprecation for the same usage.\n */\n @cached\n get variant() {\n return renamedArgValue(\n this.args.variant,\n this.args.appearance,\n { default: 'solid', outlined: 'outline', faded: 'subtle' } as const,\n {\n component: 'Autocomplete',\n from: 'appearance',\n to: 'variant',\n id: 'frontile.autocomplete.appearance'\n }\n );\n }\n\n /**\n * Resolved once (`@cached`) and forwarded to the internal `Listbox` as\n * `@color` only -- never `@intent` as well, which would make the inner\n * `Listbox` raise its own deprecation for the same usage.\n */\n @cached\n get color() {\n return renamedArgValue(\n this.args.color,\n this.args.intent,\n { default: 'neutral' } as const,\n {\n component: 'Autocomplete',\n from: 'intent',\n to: 'color',\n id: 'frontile.autocomplete.intent'\n }\n );\n }\n\n /**\n * Whether the clear button takes the chevron's place: something to clear,\n * and a control that can act on it.\n *\n * `@allowEmpty` is deliberately not consulted -- it governs deselecting an\n * *option* in the listbox, while `@isClearable` is a separate affordance the\n * consumer opts into for exactly this purpose (and `@allowEmpty` defaults to\n * false, so honouring it here would leave the button dead by default). A\n * disabled Autocomplete shows no clear button at all: it carries no disabled\n * state of its own, so it would be a focusable button that clears a field\n * the user is not allowed to change.\n */\n get isClearable() {\n return (\n this.args.isClearable &&\n !this.args.isDisabled &&\n (this.selectedKeys.length > 0 || this.isFiltering)\n );\n }\n\n get isLoading() {\n return this.args.isLoading || this.isSearchPending;\n }\n\n @cached\n get filteredItems() {\n if (typeof this.args.onSearch === 'function') {\n return this.asyncItems ?? this.args.items;\n }\n\n if (this.args.disableFiltering || !this.isFiltering) {\n return this.args.items;\n }\n\n return filterAndRankItems(\n this.args.items,\n this.inputValue,\n (item) => keyAndLabelForItem(item).label,\n this.args.filter\n );\n }\n\n /**\n * The options the listbox renders: `filteredItems`, capped by\n * `@displayLimit`.\n */\n @cached\n get displayedItems() {\n const { displayLimit } = this.args;\n assert(\n `Autocomplete: @displayLimit must be a positive integer, received ${String(displayLimit)}`,\n displayLimit === undefined ||\n (Number.isInteger(displayLimit) && displayLimit > 0)\n );\n\n const selectedKeys = this.selectedKeys;\n return limitItems(this.filteredItems, displayLimit, (item) =>\n selectedKeys.includes(keyAndLabelForItem(item).key)\n );\n }\n\n /**\n * What the display limit content reports, or `undefined` when nothing is\n * left out.\n */\n get displayLimitContent(): DisplayLimitContentArgs | undefined {\n const shown = this.displayedItems?.length ?? 0;\n const total = this.filteredItems?.length ?? 0;\n if (shown === total || this.args.hideDisplayLimitContent) {\n return undefined;\n }\n return { shown, total };\n }\n\n /**\n * True when an async autocomplete is open with a blank query and nothing\n * to show — the moment to prompt the user to start typing.\n */\n get isSearchPromptState(): boolean {\n return (\n typeof this.args.onSearch === 'function' &&\n !this.isFiltering &&\n !this.isLoading &&\n (this.filteredItems?.length ?? 0) === 0\n );\n }\n\n get showEmptyContent() {\n return (\n this.filteredItems?.length === 0 &&\n !this.isLoading &&\n !this.args.hideEmptyContent\n );\n }\n\n get autoActivateMode(): 'first' | 'selected' {\n if (this.isFiltering) {\n return 'first';\n }\n return 'selected';\n }\n\n /**\n * Syncs internal `_selectedKey` with external `@selectedKey` argument.\n */\n updateSelectedKey = modifier(\n (_: HTMLDivElement, [selectedKey]: [string | null | undefined]) => {\n if (selectedKey !== undefined) {\n this._selectedKey = selectedKey;\n }\n }\n );\n\n <template>\n <div\n {{this.updateSelectedKey @selectedKey}}\n {{this.containerRef.setup}}\n class={{this.classes.base class=@classes.base}}\n data-component=\"autocomplete\"\n data-part=\"base\"\n ...attributes\n >\n <FormControl\n @id={{@id}}\n @size={{@inputSize}}\n @label={{@label}}\n @isRequired={{@isRequired}}\n @description={{@description}}\n @errors={{@errors}}\n @isInvalid={{@isInvalid}}\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={{this.didClose}}\n @isOpen={{this.isOpen}}\n @onOpenChange={{this.onOpenChange}}\n as |p|\n >\n <VisuallyHidden>\n {{! Limited like the listbox: it holds the options the user can\n pick, and a hidden list of every match would cost the same\n rendering @displayLimit saves. The selection is always kept. }}\n <NativeSelect\n @items={{this.displayedItems}}\n @allowEmpty={{@allowEmpty}}\n @disabledKeys={{@disabledKeys}}\n @onSelectionChange={{this.onNativeSelectionChange}}\n @selectedKey={{this._selectedKey}}\n @selectionMode=\"single\"\n @onItemsChange={{this.onItemsChange}}\n @placeholder={{@placeholder}}\n @id={{c.id}}\n @name={{@name}}\n tabindex=\"-1\"\n disabled={{@isDisabled}}\n >\n <:item as |l|>\n <l.Item @key={{l.key}}>\n {{l.label}}\n </l.Item>\n </:item>\n <:default as |l|>\n {{! @glint-expect-error: the signature of the native select is not the same as the listbox}}\n {{yield l to=\"default\"}}\n </:default>\n </NativeSelect>\n </VisuallyHidden>\n\n <div\n class={{this.classes.innerContainer class=@classes.innerContainer}}\n data-part=\"inner-container\"\n >\n {{#if (has-block \"startContent\")}}\n <div\n data-part=\"start-content\"\n class={{this.classes.startContent\n class=@classes.startContent\n startContentPointerEvents=(if\n @startContentPointerEvents @startContentPointerEvents \"auto\"\n )\n }}\n >\n {{yield to=\"startContent\"}}\n </div>\n {{/if}}\n {{! aria-expanded and aria-controls are set at runtime by the\n Popover trigger modifier, and role=combobox is not implicit\n on a text input }}\n {{! template-lint-disable no-redundant-role require-mandatory-role-attributes }}\n <input\n type=\"text\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-activedescendant={{this.activeDescendant}}\n autocomplete=\"off\"\n autocapitalize=\"off\"\n autocorrect=\"off\"\n spellcheck=\"false\"\n {{p.trigger}}\n {{p.anchor}}\n {{this.triggerRef.setup}}\n data-part=\"input\"\n disabled={{@isDisabled}}\n placeholder={{@placeholder}}\n class={{this.classes.input\n class=@classes.input\n hasStartContent=(has-block \"startContent\")\n hasEndContent=true\n }}\n value={{this.inputValue}}\n {{on \"input\" this.onInput}}\n {{on \"keydown\" this.onKeyDown}}\n {{on \"focusout\" this.blurTracker.handleFocusOut}}\n />\n <div\n data-part=\"end-content\"\n class={{this.classes.endContent\n class=@classes.endContent\n endContentPointerEvents=(if\n @endContentPointerEvents @endContentPointerEvents \"none\"\n )\n }}\n >\n {{yield to=\"endContent\"}}\n\n {{#if this.isLoading}}\n <Spinner @size={{if (isSm @inputSize) \"xs\" \"sm\"}} />\n {{else if this.isClearable}}\n <CloseButton\n @title=\"Clear\"\n @variant=\"soft\"\n @size=\"xs\"\n @class={{this.classes.clearButton class=@classes.clearButton}}\n data-part=\"clear-button\"\n @onPress={{this.clearSelectedKeys}}\n />\n {{else}}\n <IconChevronUpDown\n data-part=\"icon\"\n class={{this.classes.icon class=@classes.icon}}\n />\n {{/if}}\n </div>\n </div>\n\n <p.Content\n @size={{if @popoverSize @popoverSize \"trigger\"}}\n @target={{@target}}\n @renderInPlace={{@renderInPlace}}\n @disableFocusTrap={{this.disableFocusTrap}}\n @blockScroll={{this.blockScroll}}\n @transitionDuration={{@transitionDuration}}\n @backdrop={{this.backdrop}}\n @disableTransitions={{@disableTransitions}}\n @focusTrapOptions={{@focusTrapOptions}}\n @closeOnOutsideClick={{@closeOnOutsideClick}}\n @closeOnEscapeKey={{@closeOnEscapeKey}}\n @backdropTransition={{@backdropTransition}}\n @transition={{@transition}}\n @preventAutoFocus={{true}}\n >\n <Listbox\n @items={{this.displayedItems}}\n @allowEmpty={{@allowEmpty}}\n @variant={{this.variant}}\n @disabledKeys={{@disabledKeys}}\n @color={{this.color}}\n @isKeyboardEventsEnabled={{true}}\n @onAction={{this.onAction}}\n @onSelectionChange={{this.onSelectionChange}}\n @onActiveItemChange={{this.onActiveItemChange}}\n @selectedKeys={{this.selectedKeys}}\n @selectionMode=\"single\"\n @type=\"listbox\"\n @class={{this.classes.listbox class=@classes.listbox}}\n @elementToAddKeyboardEvents={{this.triggerRef.current}}\n @autoActivateMode={{this.autoActivateMode}}\n data-part=\"listbox\"\n >\n <:item as |l|>\n {{#if (has-block \"item\")}}\n {{yield l to=\"item\"}}\n {{else}}\n <l.Item\n @key={{l.key}}\n @variant={{this.variant}}\n @color={{this.color}}\n >\n {{l.label}}\n </l.Item>\n {{/if}}\n </:item>\n <:default as |l|>\n {{yield l to=\"default\"}}\n </:default>\n </Listbox>\n {{#if\n (and\n this.isSearchPromptState\n (or @searchMessage (has-block \"searchMessage\"))\n )\n }}\n <div\n class={{this.classes.emptyContent class=@classes.emptyContent}}\n data-part=\"empty-content\"\n >\n {{#if (has-block \"searchMessage\")}}\n {{yield to=\"searchMessage\"}}\n {{else}}\n {{@searchMessage}}\n {{/if}}\n </div>\n {{else if this.showEmptyContent}}\n <div\n class={{this.classes.emptyContent class=@classes.emptyContent}}\n data-part=\"empty-content\"\n >\n {{#if (has-block \"emptyContent\")}}\n {{yield to=\"emptyContent\"}}\n {{else}}\n No results found.\n {{/if}}\n </div>\n {{/if}}\n {{#if this.displayLimitContent}}\n <div\n class={{this.classes.displayLimitContent\n class=@classes.displayLimitContent\n }}\n data-part=\"display-limit-content\"\n >\n {{#if (has-block \"displayLimitContent\")}}\n {{yield this.displayLimitContent to=\"displayLimitContent\"}}\n {{else}}\n Showing\n {{this.displayLimitContent.shown}}\n of\n {{this.displayLimitContent.total}}. Type to narrow down.\n {{/if}}\n </div>\n {{/if}}\n </p.Content>\n </Popover>\n </FormControl>\n </div>\n </template>\n}\n\nconst isSm = (size: AutocompleteVariants['size']) => size === 'sm';\nconst and = (a: unknown, b: unknown) => Boolean(a) && Boolean(b);\nconst or = (a: unknown, b: unknown) => Boolean(a) || Boolean(b);\n\nexport { Autocomplete, type AutocompleteSignature };\nexport default Autocomplete;\n"],"names":["Autocomplete","Component","g","prototype","tracked","i","containerRef","ref","triggerRef","constructor","owner","args","_selectedKey","selectedKey","willDestroy","cancel","blurTracker","onSelectionChange","keys","applySelection","onNativeSelectionChange","key","selectedLabel","nodes","find","n","textValue","undefined","clearInputValue","triggerFormInputEvent","current","onOpenChange","isOpen","onInput","event","target","setInputValue","value","_inputValue","onInputChange","onSearch","resetSearch","isSearchPending","debounce","performSearch","searchDebounce","asyncItems","query","token","result","isDestroying","onKeyDown","preventDefault","selectedKeys","blockScroll","disableFocusTrap","onAction","closeOnItemSelect","ControlBlurTracker","trigger","container","isDestroyed","onBlur","clearSelectedKeys","focus","onItemsChange","_","didClose","allowsCustomValue","activeDescendant","onActiveItemChange","_key","item","el","id","selectedTextValue","node","inputValue","isFiltering","backdrop","classes","autocomplete","useStyles","variant","color","size","inputSize","cached","renamedArgValue","appearance","default","outlined","faded","component","from","to","intent","isClearable","isDisabled","length","isLoading","filteredItems","items","disableFiltering","filterAndRankItems","keyAndLabelForItem","label","filter","displayedItems","displayLimit","assert","String","Number","isInteger","limitItems","includes","displayLimitContent","shown","total","hideDisplayLimitContent","isSearchPromptState","showEmptyContent","hideEmptyContent","autoActivateMode","updateSelectedKey","modifier","setComponentTemplate","precompileTemplate","strictMode","scope","FormControl","Popover","VisuallyHidden","NativeSelect","on","Spinner","isSm","CloseButton","IconChevronUpDown","Listbox","and","or","a","b","Boolean"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoWA;;;;;;;;AAQC;AACD,MAAMA,YAAA,SAAkCC,UAAgC;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,OAAA,EAAA,CACrEC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAA4B,EAAE;AAAA,IAAA,CAAA,CAAA;AAAA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AIsB,gBAAAA,GAAmB;AACrB,IAAA,OACE,IAAI,CAACpB,aAAa,EAAEF,MAAA,KAAW,KAC/B,CAAC,IAAI,CAACC,SAAS,IACf,CAAC,IAAI,CAACzF,IAAI,CAAC+G,gBAAgB;AAE/B,EAAA;EAEA,IAAIC,gBAAAA,GAAyC;IAC3C,IAAI,IAAI,CAAC7C,WAAW,EAAE;AACpB,MAAA,OAAO,OAAA;AACT,IAAA;AACA,IAAA,OAAO,UAAA;AACT,EAAA;AAEA;;AAEC;EACD8C,iBAAA,GAAoBC,QAAA,CAClB,CAAC3D,CAAG,EAAgB,CAACrD,WAAA,CAAyC,KAAA;IAC5D,IAAIA,gBAAgBc,SAAA,EAAW;MAC7B,IAAI,CAACf,YAAY,GAAGC,WAAA;AACtB,IAAA;AACF,EAAA,CAAA,CAAA;AAGF,EAAA;IAAAiH,oBAAA,CAAAC,kBAAA,CAAA,k9MAAA,EA8OA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,WAAA;QAAAC,OAAA;QAAAC,cAAA;QAAAC,YAAA;QAAAC,EAAA;QAAAC,OAAA;QAAAC,IAAA;QAAAC,WAAA;QAAAC,iBAAA;QAAAC,OAAA;QAAAC,GAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;AAEA,MAAML,IAAA,GAAQnD,QAAuCA,IAAA,KAAS,IAAA;AAC9D,MAAMuD,GAAA,GAAMA,CAACE,CAAU,EAAEC,CAAU,KAAKC,OAAA,CAAQF,CAAA,CAAA,IAAME,OAAA,CAAQD,CAAA,CAAA;AAC9D,MAAMF,EAAA,GAAKA,CAACC,CAAU,EAAEC,CAAU,KAAKC,OAAA,CAAQF,CAAA,CAAA,IAAME,OAAA,CAAQD,CAAA,CAAA;;"}
|
|
@@ -14,6 +14,9 @@ import { precompileTemplate } from '@ember/template-compilation';
|
|
|
14
14
|
import { setComponentTemplate } from '@ember/component';
|
|
15
15
|
import { d as decorateFieldV2, i as initializeDeferredDecorator, a as decorateMethodV2 } from '../../../runtime--fcdnjmJ-BOdRhmsS.js';
|
|
16
16
|
|
|
17
|
+
const DEFAULT_LABELS = {
|
|
18
|
+
clear: 'Clear'
|
|
19
|
+
};
|
|
17
20
|
/**
|
|
18
21
|
* A date typed into segments rather than picked from a grid. `DatePicker`
|
|
19
22
|
* renders the same segments and adds a calendar.
|
|
@@ -159,6 +162,12 @@ class DateInput extends Component {
|
|
|
159
162
|
if (container && next instanceof Node && container.contains(next)) return;
|
|
160
163
|
this.args.onBlur?.();
|
|
161
164
|
};
|
|
165
|
+
get labels() {
|
|
166
|
+
return {
|
|
167
|
+
...DEFAULT_LABELS,
|
|
168
|
+
...this.args.labels
|
|
169
|
+
};
|
|
170
|
+
}
|
|
162
171
|
/**
|
|
163
172
|
* A disabled or read-only field never offers it: it carries no disabled
|
|
164
173
|
* state of its own and would be a live button clearing a field the user may
|
|
@@ -188,7 +197,7 @@ class DateInput extends Component {
|
|
|
188
197
|
decorateMethodV2(this.prototype, "classes", [cached]);
|
|
189
198
|
}
|
|
190
199
|
static {
|
|
191
|
-
setComponentTemplate(precompileTemplate("<div {{this.syncLocale this.locale this.formatOptions this.timeOptions}} {{this.syncValue @value}} {{this.containerRef.setup}} {{on \"focusout\" this.handleFocusOut}} class={{this.classes.base class=@classes.base}} data-component=\"date-input\" data-part=\"base\" ...attributes>\n {{#if @name}}\n <input type=\"hidden\" name={{@name}} value={{this.wireValue}} />\n {{/if}}\n\n <FormControl @id={{@id}} @size={{@inputSize}} @label={{@label}} @isRequired={{@isRequired}} @description={{@description}} @errors={{@errors}} @isInvalid={{this.isInvalid}} @isDisabled={{@isDisabled}} as |c|>\n <div class={{this.classes.innerContainer class=@classes.innerContainer}} data-part=\"inner-container\" {{!-- The field shell lives here, not on the segment row, so the clear\n button sits inside the border. `role=\"group\"` supports neither\n aria-invalid nor aria-disabled, so the shell styles off these. --}} data-invalid={{if c.isInvalid \"true\" \"false\"}} data-disabled={{if @isDisabled \"true\" \"false\"}}>\n <SegmentGroup @parts={{this.parts}} @onPartsChange={{this.handlePartsChange}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{c.id}} @label={{@label}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} />\n {{#if this.isClearable}}\n <div data-part=\"end-content\" class={{this.classes.endContent class=@classes.endContent}}>\n <CloseButton @title
|
|
200
|
+
setComponentTemplate(precompileTemplate("<div {{this.syncLocale this.locale this.formatOptions this.timeOptions}} {{this.syncValue @value}} {{this.containerRef.setup}} {{on \"focusout\" this.handleFocusOut}} class={{this.classes.base class=@classes.base}} data-component=\"date-input\" data-part=\"base\" ...attributes>\n {{#if @name}}\n <input type=\"hidden\" name={{@name}} value={{this.wireValue}} />\n {{/if}}\n\n <FormControl @id={{@id}} @size={{@inputSize}} @label={{@label}} @isRequired={{@isRequired}} @description={{@description}} @errors={{@errors}} @isInvalid={{this.isInvalid}} @isDisabled={{@isDisabled}} as |c|>\n <div class={{this.classes.innerContainer class=@classes.innerContainer}} data-part=\"inner-container\" {{!-- The field shell lives here, not on the segment row, so the clear\n button sits inside the border. `role=\"group\"` supports neither\n aria-invalid nor aria-disabled, so the shell styles off these. --}} data-invalid={{if c.isInvalid \"true\" \"false\"}} data-disabled={{if @isDisabled \"true\" \"false\"}}>\n <SegmentGroup @parts={{this.parts}} @onPartsChange={{this.handlePartsChange}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{c.id}} @label={{@label}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} />\n {{#if this.isClearable}}\n <div data-part=\"end-content\" class={{this.classes.endContent class=@classes.endContent}}>\n <CloseButton @title={{this.labels.clear}} @variant=\"soft\" @size=\"xs\" @class={{this.classes.clearButton class=@classes.clearButton}} data-part=\"clear-button\" @onPress={{this.clear}} />\n </div>\n {{/if}}\n </div>\n </FormControl>\n</div>", {
|
|
192
201
|
strictMode: true,
|
|
193
202
|
scope: () => ({
|
|
194
203
|
on,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-input.js","sources":["../../../../src/components/forms/date-input/date-input.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached, tracked } from '@glimmer/tracking';\nimport { on } from '@ember/modifier';\nimport { modifier } from 'ember-modifier';\nimport { useStyles } from '@frontile/theme';\nimport { FormControl } from '../form-control';\nimport { CloseButton } from '../../buttons/close-button';\nimport { SegmentGroup } from './segment-group';\nimport {\n buildParts,\n toDate,\n fromDate,\n isSegment,\n carryOver,\n resolveSegmentFormat,\n hasDateChanged\n} from './segments';\nimport { parseDate, toWire } from '../date-picker/value';\nimport { ref } from '../../../utils/ref';\nimport { triggerFormInputEvent } from '../../../utils/forms-utils-index';\nimport type {\n Part,\n DateInputArgs,\n DateInputClasses,\n TimeOptions\n} from './types';\n\ninterface DateInputSignature {\n Args: DateInputArgs;\n Element: HTMLDivElement;\n}\n\n/**\n * A date typed into segments rather than picked from a grid. `DatePicker`\n * renders the same segments and adds a calendar.\n */\nclass DateInput extends Component<DateInputSignature> {\n containerRef = ref<HTMLElement>();\n\n /**\n * The segments are the state, not the value: mid-entry they hold digits that\n * compose to no date at all, which no `Date` can represent.\n */\n @tracked private trackedParts: Part[] = [];\n\n /**\n * An untracked mirror of {@link parts}. The sync modifiers below need to\n * read the current segments in order to rebuild them, and reading the\n * tracked field inside a modifier would put it in that modifier's own\n * tracking frame -- which the same modifier then writes to, re-running\n * itself forever.\n */\n #currentParts: Part[] = [];\n\n constructor(owner: unknown, args: DateInputArgs) {\n super(owner as never, args);\n\n const seed = args.defaultValue;\n this.setParts(\n fromDate(\n buildParts(this.locale, this.formatOptions, this.timeOptions),\n seed === undefined ? null : parseDate(seed)\n )\n );\n }\n\n get parts(): Part[] {\n return this.trackedParts;\n }\n\n private setParts(parts: Part[]): void {\n this.#currentParts = parts;\n this.trackedParts = parts;\n }\n\n get locale(): string {\n return this.args.locale ?? navigator.language;\n }\n\n get formatOptions(): Intl.DateTimeFormatOptions | undefined {\n // A textual month has no numeric segment to type into, so it falls back\n // to a numeric one. `dateStyle: 'medium'` is the common way to hit this --\n // it is DatePicker's button-trigger default. Only the month is replaced:\n // the rest of the format is the consumer's and stands.\n return resolveSegmentFormat(this.args.formatOptions, {\n message:\n '<DateInput> needs numeric segments; ' +\n 'a textual @formatOptions month falls back to a numeric one.',\n id: 'frontile.date-input.textual-format'\n });\n }\n\n /** The time segments the field adds to the date, if any. */\n @cached\n get timeOptions(): TimeOptions {\n return {\n granularity: this.args.granularity,\n hourCycle: this.args.hourCycle\n };\n }\n\n /**\n * The composed value, or null while any segment is empty.\n *\n * Cached because `wireValue`, `isOutOfRange` and the template all read it\n * independently, and each `toDate` walks the parts three times over.\n */\n @cached\n get value(): Date | null {\n return toDate(this.parts);\n }\n\n get wireValue(): string {\n return toWire(this.value, this.args.granularity);\n }\n\n get isEmpty(): boolean {\n return this.parts.every((p) => !isSegment(p) || p.value === null);\n }\n\n get placeholderValue(): Date {\n return this.args.placeholderValue ?? new Date();\n }\n\n /**\n * Whether the composed value is outside the allowed range. Never blocks a\n * keystroke -- typing toward 2020 passes through 2, 20 and 202 on the way,\n * and a field that refused those could not be typed into at all.\n */\n get isOutOfRange(): boolean {\n const value = this.value;\n if (!value) return false;\n\n if (this.args.minValue && value < this.args.minValue) return true;\n if (this.args.maxValue && value > this.args.maxValue) return true;\n return this.args.isDateUnavailable?.(value) ?? false;\n }\n\n get isInvalid(): boolean {\n return Boolean(this.args.isInvalid) || this.isOutOfRange;\n }\n\n /**\n * Pushes `@value` into the segments when the argument changes. `undefined`\n * is ignored, so a field bound by `Field` before the form holds anything for\n * it keeps what the user typed -- the rule `DatePicker` documents.\n */\n syncValue = modifier(\n (_: HTMLElement, [raw]: [Date | string | null | undefined]) => {\n if (raw === undefined) return;\n\n const parsed = parseDate(raw);\n\n // Ignore the echo of our own `@onChange`. A controlled consumer writes\n // back the value this field just reported, and rewriting the segments\n // from it would destroy a partial entry: backspacing one digit of the\n // year un-commits it, so the field composes `null`, reports `null`, and\n // is handed `null` straight back -- which `fromDate` would spend on\n // clearing every other segment too. One keystroke would empty the field.\n if (!hasDateChanged(toDate(this.#currentParts), parsed)) return;\n\n this.setParts(fromDate(this.#currentParts, parsed));\n }\n );\n\n /**\n * Rebuilds the segment order when the locale or format changes, carrying\n * each segment's own state across so switching en-US to en-GB reorders the\n * field without emptying it -- half-typed digits included, which is why\n * this goes segment by segment rather than through the composed value.\n */\n syncLocale = modifier(\n (\n _: HTMLElement,\n [locale, format, time]: [\n string,\n Intl.DateTimeFormatOptions | undefined,\n TimeOptions\n ]\n ) => {\n this.setParts(\n carryOver(buildParts(locale, format, time), this.#currentParts)\n );\n }\n );\n\n handlePartsChange = (parts: Part[]): void => {\n const before = toDate(this.#currentParts);\n this.setParts(parts);\n const after = toDate(parts);\n\n // Only value transitions are reported. The four keystrokes that fill a\n // month and a day compose no date at all, and report nothing.\n if (hasDateChanged(before, after)) {\n this.args.onChange?.(after);\n triggerFormInputEvent(this.containerRef.current);\n }\n };\n\n /**\n * `@onBlur` means \"the user left the field\", not \"the user left a segment\",\n * so a move between segments is filtered out by asking whether focus landed\n * inside the container. `DatePicker` needs `ControlBlurTracker` for this\n * because its focus can legitimately be in a popover outside its own DOM;\n * this field has no popover, so containment is the whole question.\n */\n handleFocusOut = (event: FocusEvent): void => {\n const container = this.containerRef.current;\n const next = event.relatedTarget;\n\n if (container && next instanceof Node && container.contains(next)) return;\n\n this.args.onBlur?.();\n };\n\n /**\n * A disabled or read-only field never offers it: it carries no disabled\n * state of its own and would be a live button clearing a field the user may\n * not change.\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 focus must be handed somewhere\n * explicitly or it falls to `<body>` and a keyboard user loses their place.\n */\n clear = (): void => {\n this.handlePartsChange(fromDate(this.#currentParts, null));\n this.containerRef.current\n ?.querySelector<HTMLElement>('[data-part=\"segment\"]')\n ?.focus();\n };\n\n @cached\n get classes(): DateInputClasses {\n const { dateInput } = useStyles();\n return dateInput({ size: this.args.inputSize });\n }\n\n <template>\n <div\n {{this.syncLocale this.locale this.formatOptions this.timeOptions}}\n {{this.syncValue @value}}\n {{this.containerRef.setup}}\n {{on \"focusout\" this.handleFocusOut}}\n class={{this.classes.base class=@classes.base}}\n data-component=\"date-input\"\n data-part=\"base\"\n ...attributes\n >\n {{#if @name}}\n <input type=\"hidden\" name={{@name}} value={{this.wireValue}} />\n {{/if}}\n\n <FormControl\n @id={{@id}}\n @size={{@inputSize}}\n @label={{@label}}\n @isRequired={{@isRequired}}\n @description={{@description}}\n @errors={{@errors}}\n @isInvalid={{this.isInvalid}}\n @isDisabled={{@isDisabled}}\n as |c|\n >\n <div\n class={{this.classes.innerContainer class=@classes.innerContainer}}\n data-part=\"inner-container\"\n {{! The field shell lives here, not on the segment row, so the clear\n button sits inside the border. `role=\"group\"` supports neither\n aria-invalid nor aria-disabled, so the shell styles off these. }}\n data-invalid={{if c.isInvalid \"true\" \"false\"}}\n data-disabled={{if @isDisabled \"true\" \"false\"}}\n >\n <SegmentGroup\n @parts={{this.parts}}\n @onPartsChange={{this.handlePartsChange}}\n @locale={{this.locale}}\n @placeholderValue={{this.placeholderValue}}\n @isDisabled={{@isDisabled}}\n @isReadOnly={{@isReadOnly}}\n @isInvalid={{c.isInvalid}}\n @id={{c.id}}\n @label={{@label}}\n @describedBy={{c.describedBy @description c.isInvalid}}\n @segmentLabels={{@segmentLabels}}\n @classes={{this.classes}}\n @userClasses={{@classes}}\n />\n {{#if this.isClearable}}\n <div\n data-part=\"end-content\"\n class={{this.classes.endContent class=@classes.endContent}}\n >\n <CloseButton\n @title=\"Clear\"\n @variant=\"soft\"\n @size=\"xs\"\n @class={{this.classes.clearButton class=@classes.clearButton}}\n data-part=\"clear-button\"\n @onPress={{this.clear}}\n />\n </div>\n {{/if}}\n </div>\n </FormControl>\n </div>\n </template>\n}\n\nexport { DateInput, type DateInputSignature };\nexport default DateInput;\n"],"names":["DateInput","Component","containerRef","ref","g","prototype","tracked","i","constructor","owner","args","seed","defaultValue","setParts","fromDate","buildParts","locale","formatOptions","timeOptions","undefined","parseDate","parts","trackedParts","navigator","language","resolveSegmentFormat","message","id","granularity","hourCycle","n","cached","value","toDate","wireValue","toWire","isEmpty","every","p","isSegment","placeholderValue","Date","isOutOfRange","minValue","maxValue","isDateUnavailable","isInvalid","Boolean","syncValue","modifier","_","raw","parsed","hasDateChanged","syncLocale","format","time","carryOver","handlePartsChange","before","after","onChange","triggerFormInputEvent","current","handleFocusOut","event","container","next","relatedTarget","Node","contains","onBlur","isClearable","isDisabled","isReadOnly","clear","querySelector","focus","classes","dateInput","useStyles","size","inputSize","setComponentTemplate","precompileTemplate","strictMode","scope","on","FormControl","SegmentGroup","CloseButton"],"mappings":";;;;;;;;;;;;;;;;AAgCA;;;;AAIA,MAAMA,kBAAkBC,SAAA,CAAU;EAChCC,YAAA,GAAeC,KAAI;AAEnB;;;AAGC;AAHD,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CAICC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAuC,EAAE;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,aAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,cAAA,CAAA,EAAA,MAAA;AAE1C;;;;;;AAMC;EACD,aAAa,GAAW,EAAE;AAE1BC,EAAAA,WAAAA,CAAYC,KAAc,EAAEC,IAAmB,EAAE;AAC/C,IAAA,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H,IAAA,CAAA,EAAO;AAEnE,IAAA,IAAI,CAACzD,IAAI,CAAC6D,MAAM,IAAA;EAClB,CAAA;AAEA;;;;;EAKA,IAAIC,WAAAA,GAAuB;IACzB,OACEzB,OAAA,CAAQ,IAAI,CAACrC,IAAI,CAAC8D,WAAW,CAAA,IAC7B,CAAC,IAAI,CAACpC,OAAO,IACb,CAAC,IAAI,CAAC1B,IAAI,CAAC+D,UAAU,IACrB,CAAC,IAAI,CAAC/D,IAAI,CAACgE,UAAU;AAEzB,EAAA;AAEA;;;;;EAKAC,KAAA,GAAQA,MAAQ;AACd,IAAA,IAAI,CAACjB,iBAAiB,CAAC5C,QAAA,CAAS,IAAI,CAAC,aAAa,EAAE,IAAA,CAAA,CAAA;AACpD,IAAA,IAAI,CAACZ,YAAY,CAAC6D,OAAO,EACrBa,cAA2B,uBAAA,CAAA,EAC3BC,KAAA,EAAA;EACN,CAAA;EAEA,IACIC,UAA4B;IAC9B,MAAM;AAAEC,MAAAA;KAAW,GAAGC,SAAA,EAAA;AACtB,IAAA,OAAOD,SAAA,CAAU;AAAEE,MAAAA,IAAA,EAAM,IAAI,CAACvE,IAAI,CAACwE;AAAU,KAAA,CAAA;AAC/C,EAAA;AAAA,EAAA;IAAApD,gBAAA,CAAA,IAAA,CAAAzB,SAAA,EAAA,SAAA,EAAA,CAJC0B,MAAA,CAAA,CAAA;AAAA;AAMD,EAAA;IAAAoD,oBAAA,CAAAC,kBAAA,CAAA,iyDAAA,EAoEA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,EAAA;QAAAC,WAAA;QAAAC,YAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
1
|
+
{"version":3,"file":"date-input.js","sources":["../../../../src/components/forms/date-input/date-input.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached, tracked } from '@glimmer/tracking';\nimport { on } from '@ember/modifier';\nimport { modifier } from 'ember-modifier';\nimport { useStyles } from '@frontile/theme';\nimport { FormControl } from '../form-control';\nimport { CloseButton } from '../../buttons/close-button';\nimport { SegmentGroup } from './segment-group';\nimport {\n buildParts,\n toDate,\n fromDate,\n isSegment,\n carryOver,\n resolveSegmentFormat,\n hasDateChanged\n} from './segments';\nimport { parseDate, toWire } from '../date-picker/value';\nimport { ref } from '../../../utils/ref';\nimport { triggerFormInputEvent } from '../../../utils/forms-utils-index';\nimport type {\n Part,\n DateInputArgs,\n DateInputClasses,\n DateInputLabels,\n TimeOptions\n} from './types';\n\nconst DEFAULT_LABELS: DateInputLabels = {\n clear: 'Clear'\n};\n\ninterface DateInputSignature {\n Args: DateInputArgs;\n Element: HTMLDivElement;\n}\n\n/**\n * A date typed into segments rather than picked from a grid. `DatePicker`\n * renders the same segments and adds a calendar.\n */\nclass DateInput extends Component<DateInputSignature> {\n containerRef = ref<HTMLElement>();\n\n /**\n * The segments are the state, not the value: mid-entry they hold digits that\n * compose to no date at all, which no `Date` can represent.\n */\n @tracked private trackedParts: Part[] = [];\n\n /**\n * An untracked mirror of {@link parts}. The sync modifiers below need to\n * read the current segments in order to rebuild them, and reading the\n * tracked field inside a modifier would put it in that modifier's own\n * tracking frame -- which the same modifier then writes to, re-running\n * itself forever.\n */\n #currentParts: Part[] = [];\n\n constructor(owner: unknown, args: DateInputArgs) {\n super(owner as never, args);\n\n const seed = args.defaultValue;\n this.setParts(\n fromDate(\n buildParts(this.locale, this.formatOptions, this.timeOptions),\n seed === undefined ? null : parseDate(seed)\n )\n );\n }\n\n get parts(): Part[] {\n return this.trackedParts;\n }\n\n private setParts(parts: Part[]): void {\n this.#currentParts = parts;\n this.trackedParts = parts;\n }\n\n get locale(): string {\n return this.args.locale ?? navigator.language;\n }\n\n get formatOptions(): Intl.DateTimeFormatOptions | undefined {\n // A textual month has no numeric segment to type into, so it falls back\n // to a numeric one. `dateStyle: 'medium'` is the common way to hit this --\n // it is DatePicker's button-trigger default. Only the month is replaced:\n // the rest of the format is the consumer's and stands.\n return resolveSegmentFormat(this.args.formatOptions, {\n message:\n '<DateInput> needs numeric segments; ' +\n 'a textual @formatOptions month falls back to a numeric one.',\n id: 'frontile.date-input.textual-format'\n });\n }\n\n /** The time segments the field adds to the date, if any. */\n @cached\n get timeOptions(): TimeOptions {\n return {\n granularity: this.args.granularity,\n hourCycle: this.args.hourCycle\n };\n }\n\n /**\n * The composed value, or null while any segment is empty.\n *\n * Cached because `wireValue`, `isOutOfRange` and the template all read it\n * independently, and each `toDate` walks the parts three times over.\n */\n @cached\n get value(): Date | null {\n return toDate(this.parts);\n }\n\n get wireValue(): string {\n return toWire(this.value, this.args.granularity);\n }\n\n get isEmpty(): boolean {\n return this.parts.every((p) => !isSegment(p) || p.value === null);\n }\n\n get placeholderValue(): Date {\n return this.args.placeholderValue ?? new Date();\n }\n\n /**\n * Whether the composed value is outside the allowed range. Never blocks a\n * keystroke -- typing toward 2020 passes through 2, 20 and 202 on the way,\n * and a field that refused those could not be typed into at all.\n */\n get isOutOfRange(): boolean {\n const value = this.value;\n if (!value) return false;\n\n if (this.args.minValue && value < this.args.minValue) return true;\n if (this.args.maxValue && value > this.args.maxValue) return true;\n return this.args.isDateUnavailable?.(value) ?? false;\n }\n\n get isInvalid(): boolean {\n return Boolean(this.args.isInvalid) || this.isOutOfRange;\n }\n\n /**\n * Pushes `@value` into the segments when the argument changes. `undefined`\n * is ignored, so a field bound by `Field` before the form holds anything for\n * it keeps what the user typed -- the rule `DatePicker` documents.\n */\n syncValue = modifier(\n (_: HTMLElement, [raw]: [Date | string | null | undefined]) => {\n if (raw === undefined) return;\n\n const parsed = parseDate(raw);\n\n // Ignore the echo of our own `@onChange`. A controlled consumer writes\n // back the value this field just reported, and rewriting the segments\n // from it would destroy a partial entry: backspacing one digit of the\n // year un-commits it, so the field composes `null`, reports `null`, and\n // is handed `null` straight back -- which `fromDate` would spend on\n // clearing every other segment too. One keystroke would empty the field.\n if (!hasDateChanged(toDate(this.#currentParts), parsed)) return;\n\n this.setParts(fromDate(this.#currentParts, parsed));\n }\n );\n\n /**\n * Rebuilds the segment order when the locale or format changes, carrying\n * each segment's own state across so switching en-US to en-GB reorders the\n * field without emptying it -- half-typed digits included, which is why\n * this goes segment by segment rather than through the composed value.\n */\n syncLocale = modifier(\n (\n _: HTMLElement,\n [locale, format, time]: [\n string,\n Intl.DateTimeFormatOptions | undefined,\n TimeOptions\n ]\n ) => {\n this.setParts(\n carryOver(buildParts(locale, format, time), this.#currentParts)\n );\n }\n );\n\n handlePartsChange = (parts: Part[]): void => {\n const before = toDate(this.#currentParts);\n this.setParts(parts);\n const after = toDate(parts);\n\n // Only value transitions are reported. The four keystrokes that fill a\n // month and a day compose no date at all, and report nothing.\n if (hasDateChanged(before, after)) {\n this.args.onChange?.(after);\n triggerFormInputEvent(this.containerRef.current);\n }\n };\n\n /**\n * `@onBlur` means \"the user left the field\", not \"the user left a segment\",\n * so a move between segments is filtered out by asking whether focus landed\n * inside the container. `DatePicker` needs `ControlBlurTracker` for this\n * because its focus can legitimately be in a popover outside its own DOM;\n * this field has no popover, so containment is the whole question.\n */\n handleFocusOut = (event: FocusEvent): void => {\n const container = this.containerRef.current;\n const next = event.relatedTarget;\n\n if (container && next instanceof Node && container.contains(next)) return;\n\n this.args.onBlur?.();\n };\n\n get labels(): DateInputLabels {\n return { ...DEFAULT_LABELS, ...this.args.labels };\n }\n\n /**\n * A disabled or read-only field never offers it: it carries no disabled\n * state of its own and would be a live button clearing a field the user may\n * not change.\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 focus must be handed somewhere\n * explicitly or it falls to `<body>` and a keyboard user loses their place.\n */\n clear = (): void => {\n this.handlePartsChange(fromDate(this.#currentParts, null));\n this.containerRef.current\n ?.querySelector<HTMLElement>('[data-part=\"segment\"]')\n ?.focus();\n };\n\n @cached\n get classes(): DateInputClasses {\n const { dateInput } = useStyles();\n return dateInput({ size: this.args.inputSize });\n }\n\n <template>\n <div\n {{this.syncLocale this.locale this.formatOptions this.timeOptions}}\n {{this.syncValue @value}}\n {{this.containerRef.setup}}\n {{on \"focusout\" this.handleFocusOut}}\n class={{this.classes.base class=@classes.base}}\n data-component=\"date-input\"\n data-part=\"base\"\n ...attributes\n >\n {{#if @name}}\n <input type=\"hidden\" name={{@name}} value={{this.wireValue}} />\n {{/if}}\n\n <FormControl\n @id={{@id}}\n @size={{@inputSize}}\n @label={{@label}}\n @isRequired={{@isRequired}}\n @description={{@description}}\n @errors={{@errors}}\n @isInvalid={{this.isInvalid}}\n @isDisabled={{@isDisabled}}\n as |c|\n >\n <div\n class={{this.classes.innerContainer class=@classes.innerContainer}}\n data-part=\"inner-container\"\n {{! The field shell lives here, not on the segment row, so the clear\n button sits inside the border. `role=\"group\"` supports neither\n aria-invalid nor aria-disabled, so the shell styles off these. }}\n data-invalid={{if c.isInvalid \"true\" \"false\"}}\n data-disabled={{if @isDisabled \"true\" \"false\"}}\n >\n <SegmentGroup\n @parts={{this.parts}}\n @onPartsChange={{this.handlePartsChange}}\n @locale={{this.locale}}\n @placeholderValue={{this.placeholderValue}}\n @isDisabled={{@isDisabled}}\n @isReadOnly={{@isReadOnly}}\n @isInvalid={{c.isInvalid}}\n @id={{c.id}}\n @label={{@label}}\n @describedBy={{c.describedBy @description c.isInvalid}}\n @segmentLabels={{@segmentLabels}}\n @classes={{this.classes}}\n @userClasses={{@classes}}\n />\n {{#if this.isClearable}}\n <div\n data-part=\"end-content\"\n class={{this.classes.endContent class=@classes.endContent}}\n >\n <CloseButton\n @title={{this.labels.clear}}\n @variant=\"soft\"\n @size=\"xs\"\n @class={{this.classes.clearButton class=@classes.clearButton}}\n data-part=\"clear-button\"\n @onPress={{this.clear}}\n />\n </div>\n {{/if}}\n </div>\n </FormControl>\n </div>\n </template>\n}\n\nexport { DateInput, type DateInputSignature };\nexport default DateInput;\n"],"names":["DEFAULT_LABELS","clear","DateInput","Component","containerRef","ref","g","prototype","tracked","i","constructor","owner","args","seed","defaultValue","setParts","fromDate","buildParts","locale","formatOptions","timeOptions","undefined","parseDate","parts","trackedParts","navigator","language","resolveSegmentFormat","message","id","granularity","hourCycle","n","cached","value","toDate","wireValue","toWire","isEmpty","every","p","isSegment","placeholderValue","Date","isOutOfRange","minValue","maxValue","isDateUnavailable","isInvalid","Boolean","syncValue","modifier","_","raw","parsed","hasDateChanged","syncLocale","format","time","carryOver","handlePartsChange","before","after","onChange","triggerFormInputEvent","current","handleFocusOut","event","container","next","relatedTarget","Node","contains","onBlur","labels","isClearable","isDisabled","isReadOnly","querySelector","focus","classes","dateInput","useStyles","size","inputSize","setComponentTemplate","precompileTemplate","strictMode","scope","on","FormControl","SegmentGroup","CloseButton"],"mappings":";;;;;;;;;;;;;;;;AA4BA,MAAMA,cAAgB,GAAkB;AACtCC,EAAAA,KAAA,EAAO;AACT,CAAA;AAOA;;;;AAIA,MAAMC,kBAAkBC,SAAA,CAAU;EAChCC,YAAA,GAAeC,KAAI;AAEnB;;;AAGC;AAHD,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CAICC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAuC,EAAE;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,aAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,cAAA,CAAA,EAAA,MAAA;AAE1C;;;;;;AAMC;EACD,aAAa,GAAW,EAAE;AAE1BC,EAAAA,WAAAA,CAAYC,KAAc,EAAEC,IAAmB,EAAE;AAC/C,IAAA,KAAK,CAACD,KAAA,EAAgBC,IAAA,CAAA;AAEtB,IAAA,MAAMC,IAAA,GAAOD,KAAKE,YAAY;AAC9B,IAAA,IAAI,CAACC,QAAQ,CACXC,QAAA,CACEC,WAAW,IAAI,CAACC,MAAM,EAAE,IAAI,CAACC,aAA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D;KAAO;AAClD,EAAA;AAEA;;;;;EAKA,IAAIC,WAAAA,GAAuB;IACzB,OACE1B,OAAA,CAAQ,IAAI,CAACrC,IAAI,CAAC+D,WAAW,CAAA,IAC7B,CAAC,IAAI,CAACrC,OAAO,IACb,CAAC,IAAI,CAAC1B,IAAI,CAACgE,UAAU,IACrB,CAAC,IAAI,CAAChE,IAAI,CAACiE,UAAU;AAEzB,EAAA;AAEA;;;;;EAKA5E,KAAA,GAAQA,MAAQ;AACd,IAAA,IAAI,CAAC2D,iBAAiB,CAAC5C,QAAA,CAAS,IAAI,CAAC,aAAa,EAAE,IAAA,CAAA,CAAA;AACpD,IAAA,IAAI,CAACZ,YAAY,CAAC6D,OAAO,EACrBa,cAA2B,uBAAA,CAAA,EAC3BC,KAAA,EAAA;EACN,CAAA;EAEA,IACIC,UAA4B;IAC9B,MAAM;AAAEC,MAAAA;KAAW,GAAGC,SAAA,EAAA;AACtB,IAAA,OAAOD,SAAA,CAAU;AAAEE,MAAAA,IAAA,EAAM,IAAI,CAACvE,IAAI,CAACwE;AAAU,KAAA,CAAA;AAC/C,EAAA;AAAA,EAAA;IAAApD,gBAAA,CAAA,IAAA,CAAAzB,SAAA,EAAA,SAAA,EAAA,CAJC0B,MAAA,CAAA,CAAA;AAAA;AAMD,EAAA;IAAAoD,oBAAA,CAAAC,kBAAA,CAAA,6yDAAA,EAoEA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,EAAA;QAAAC,WAAA;QAAAC,YAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -19,6 +19,10 @@ import { precompileTemplate } from '@ember/template-compilation';
|
|
|
19
19
|
import { setComponentTemplate } from '@ember/component';
|
|
20
20
|
import { d as decorateFieldV2, i as initializeDeferredDecorator, a as decorateMethodV2 } from '../../../runtime--fcdnjmJ-BOdRhmsS.js';
|
|
21
21
|
|
|
22
|
+
const DEFAULT_LABELS = {
|
|
23
|
+
clear: 'Clear',
|
|
24
|
+
chooseDate: label => label ? `Choose date, ${label}` : 'Choose date'
|
|
25
|
+
};
|
|
22
26
|
/**
|
|
23
27
|
* A date field: segments the value can be typed into, a calendar button that
|
|
24
28
|
* opens a calendar in a popover, and -- under `@isEditable={{false}}` -- the
|
|
@@ -158,6 +162,12 @@ class DatePicker extends Component {
|
|
|
158
162
|
get mode() {
|
|
159
163
|
return this.args.mode ?? 'single';
|
|
160
164
|
}
|
|
165
|
+
get clearLabel() {
|
|
166
|
+
return this.args.labels?.clear ?? DEFAULT_LABELS.clear;
|
|
167
|
+
}
|
|
168
|
+
get calendarButtonLabel() {
|
|
169
|
+
return (this.args.labels?.chooseDate ?? DEFAULT_LABELS.chooseDate)(this.args.label);
|
|
170
|
+
}
|
|
161
171
|
get locale() {
|
|
162
172
|
return this.args.locale ?? navigator.language;
|
|
163
173
|
}
|
|
@@ -599,6 +609,7 @@ class DatePicker extends Component {
|
|
|
599
609
|
isDateUnavailable: this.args.isDateUnavailable,
|
|
600
610
|
visibleMonths: this.args.visibleMonths,
|
|
601
611
|
captionLayout: this.args.captionLayout,
|
|
612
|
+
labels: this.args.labels,
|
|
602
613
|
labelledBy: this.args.id,
|
|
603
614
|
autofocus: true
|
|
604
615
|
};
|
|
@@ -621,7 +632,7 @@ class DatePicker extends Component {
|
|
|
621
632
|
decorateMethodV2(this.prototype, "footerBlockArg", [cached]);
|
|
622
633
|
}
|
|
623
634
|
static {
|
|
624
|
-
setComponentTemplate(precompileTemplate("<div {{this.syncSegmentFormat this.locale this.segmentFormat this.timeOptions}} {{this.syncValue @value}} {{this.containerRef.setup}} class={{this.classes.base class=@classes.base}} data-component=\"date-picker\" data-part=\"base\" ...attributes>\n {{!-- A range's two names use dot notation, the convention Form documents\n for nested data -- so it arrives at a validator and at onSubmit as one\n { start, end } object rather than two loose keys. --}}\n {{#if @name}}\n {{#if this.isRangeMode}}\n <input type=\"hidden\" name={{concat @name \".start\"}} value={{this.wireRangeStart}} />\n <input type=\"hidden\" name={{concat @name \".end\"}} value={{this.wireRangeEnd}} />\n {{else}}\n <input type=\"hidden\" name={{@name}} value={{this.wireValue}} />\n {{/if}}\n {{/if}}\n <FormControl @id={{@id}} @size={{@inputSize}} @label={{@label}} @isRequired={{@isRequired}} @description={{@description}} @errors={{@errors}} @isInvalid={{@isInvalid}} @isDisabled={{@isDisabled}} as |c|>\n <Popover @placement={{@placement}} @flipOptions={{@flipOptions}} @middleware={{@middleware}} @shiftOptions={{@shiftOptions}} @offsetOptions={{@offsetOptions}} @strategy={{@strategy}} @didClose={{@didClose}} @isOpen={{this.isOpen}} @onOpenChange={{this.onOpenChange}} as |p|>\n <div {{p.anchor}} class={{this.classes.innerContainer class=@classes.innerContainer}} data-part=\"inner-container\" {{!-- The shell is on this element when segmented, so its invalid and\n disabled styling has to read from here. `role=\"group\"` inside\n cannot carry aria-invalid, which is why these are data\n attributes. --}} data-invalid={{if c.isInvalid \"true\" \"false\"}} data-disabled={{if @isDisabled \"true\" \"false\"}}>\n {{#if this.isSegmented}}\n {{!-- Blur tracking and focus recording ride on splattributes:\n the group renders `...attributes` on its `role=\"group\"` element,\n and both events bubble there from the segments. --}}\n {{#if this.isRangeMode}}\n {{!-- Two groups, so neither can take `c.id` or `@label`: ids\n must be unique and a name shared by both would leave a screen\n reader unable to tell the ends apart. Each derives its own\n from the field's. --}}\n <SegmentGroup @parts={{this.parts}} @onPartsChange={{this.handleStartParts}} @onRangePaste={{this.handleRangePaste}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{concat c.id \"-start\"}} @label={{this.startLabel}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} {{on \"focusin\" this.handleSegmentFocusIn}} {{on \"focusout\" this.blurTracker.handleFocusOut}} />\n <span data-part=\"separator\" aria-hidden=\"true\" class={{this.classes.separator class=@classes.separator}}>–</span>\n {{!-- No `@onRangePaste`: pasting \"20 Jan - 25 Jan\" into the end\n of a range and having it rewrite the start would be\n surprising. --}}\n <SegmentGroup @parts={{this.endParts}} @onPartsChange={{this.handleEndParts}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{concat c.id \"-end\"}} @label={{this.endLabel}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} {{on \"focusin\" this.handleSegmentFocusIn}} {{on \"focusout\" this.blurTracker.handleFocusOut}} />\n {{else}}\n <SegmentGroup @parts={{this.parts}} @onPartsChange={{this.handlePartsChange}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{c.id}} @label={{@label}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} {{on \"focusin\" this.handleSegmentFocusIn}} {{on \"focusout\" this.blurTracker.handleFocusOut}} />\n {{/if}}\n {{else}}\n <DatePickerTrigger @id={{c.id}} @trigger={{p.trigger}} @placeholder={{@placeholder}} @formatted={{this.formatted}} @isEmpty={{this.isEmpty}} @isDisabled={{@isDisabled}} @isInvalid={{c.isInvalid}} @hasCustomContent={{has-block \"value\"}} @accessibleName={{this.accessibleName}} @triggerRef={{this.triggerRef.setup}} @classes={{this.classes}} @userClasses={{@classes}} @onFocusOut={{this.blurTracker.handleFocusOut}}>\n <:value>\n {{#if (has-block \"value\")}}\n {{yield this.valueBlockArg to=\"value\"}}\n {{/if}}\n </:value>\n </DatePickerTrigger>\n {{/if}}\n\n <DatePickerEndContent @classes={{this.classes}} @userClasses={{@classes}} @endContentPointerEvents={{this.endContentPointerEvents}} @isClearable={{this.isClearable}} @onClear={{this.clear}} @isEditable={{this.isSegmented}} @trigger={{p.trigger}} @
|
|
635
|
+
setComponentTemplate(precompileTemplate("<div {{this.syncSegmentFormat this.locale this.segmentFormat this.timeOptions}} {{this.syncValue @value}} {{this.containerRef.setup}} class={{this.classes.base class=@classes.base}} data-component=\"date-picker\" data-part=\"base\" ...attributes>\n {{!-- A range's two names use dot notation, the convention Form documents\n for nested data -- so it arrives at a validator and at onSubmit as one\n { start, end } object rather than two loose keys. --}}\n {{#if @name}}\n {{#if this.isRangeMode}}\n <input type=\"hidden\" name={{concat @name \".start\"}} value={{this.wireRangeStart}} />\n <input type=\"hidden\" name={{concat @name \".end\"}} value={{this.wireRangeEnd}} />\n {{else}}\n <input type=\"hidden\" name={{@name}} value={{this.wireValue}} />\n {{/if}}\n {{/if}}\n <FormControl @id={{@id}} @size={{@inputSize}} @label={{@label}} @isRequired={{@isRequired}} @description={{@description}} @errors={{@errors}} @isInvalid={{@isInvalid}} @isDisabled={{@isDisabled}} as |c|>\n <Popover @placement={{@placement}} @flipOptions={{@flipOptions}} @middleware={{@middleware}} @shiftOptions={{@shiftOptions}} @offsetOptions={{@offsetOptions}} @strategy={{@strategy}} @didClose={{@didClose}} @isOpen={{this.isOpen}} @onOpenChange={{this.onOpenChange}} as |p|>\n <div {{p.anchor}} class={{this.classes.innerContainer class=@classes.innerContainer}} data-part=\"inner-container\" {{!-- The shell is on this element when segmented, so its invalid and\n disabled styling has to read from here. `role=\"group\"` inside\n cannot carry aria-invalid, which is why these are data\n attributes. --}} data-invalid={{if c.isInvalid \"true\" \"false\"}} data-disabled={{if @isDisabled \"true\" \"false\"}}>\n {{#if this.isSegmented}}\n {{!-- Blur tracking and focus recording ride on splattributes:\n the group renders `...attributes` on its `role=\"group\"` element,\n and both events bubble there from the segments. --}}\n {{#if this.isRangeMode}}\n {{!-- Two groups, so neither can take `c.id` or `@label`: ids\n must be unique and a name shared by both would leave a screen\n reader unable to tell the ends apart. Each derives its own\n from the field's. --}}\n <SegmentGroup @parts={{this.parts}} @onPartsChange={{this.handleStartParts}} @onRangePaste={{this.handleRangePaste}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{concat c.id \"-start\"}} @label={{this.startLabel}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} {{on \"focusin\" this.handleSegmentFocusIn}} {{on \"focusout\" this.blurTracker.handleFocusOut}} />\n <span data-part=\"separator\" aria-hidden=\"true\" class={{this.classes.separator class=@classes.separator}}>–</span>\n {{!-- No `@onRangePaste`: pasting \"20 Jan - 25 Jan\" into the end\n of a range and having it rewrite the start would be\n surprising. --}}\n <SegmentGroup @parts={{this.endParts}} @onPartsChange={{this.handleEndParts}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{concat c.id \"-end\"}} @label={{this.endLabel}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} {{on \"focusin\" this.handleSegmentFocusIn}} {{on \"focusout\" this.blurTracker.handleFocusOut}} />\n {{else}}\n <SegmentGroup @parts={{this.parts}} @onPartsChange={{this.handlePartsChange}} @locale={{this.locale}} @placeholderValue={{this.placeholderValue}} @isDisabled={{@isDisabled}} @isReadOnly={{@isReadOnly}} @isInvalid={{c.isInvalid}} @id={{c.id}} @label={{@label}} @describedBy={{c.describedBy @description c.isInvalid}} @segmentLabels={{@segmentLabels}} @classes={{this.classes}} @userClasses={{@classes}} {{on \"focusin\" this.handleSegmentFocusIn}} {{on \"focusout\" this.blurTracker.handleFocusOut}} />\n {{/if}}\n {{else}}\n <DatePickerTrigger @id={{c.id}} @trigger={{p.trigger}} @placeholder={{@placeholder}} @formatted={{this.formatted}} @isEmpty={{this.isEmpty}} @isDisabled={{@isDisabled}} @isInvalid={{c.isInvalid}} @hasCustomContent={{has-block \"value\"}} @accessibleName={{this.accessibleName}} @triggerRef={{this.triggerRef.setup}} @classes={{this.classes}} @userClasses={{@classes}} @onFocusOut={{this.blurTracker.handleFocusOut}}>\n <:value>\n {{#if (has-block \"value\")}}\n {{yield this.valueBlockArg to=\"value\"}}\n {{/if}}\n </:value>\n </DatePickerTrigger>\n {{/if}}\n\n <DatePickerEndContent @classes={{this.classes}} @userClasses={{@classes}} @endContentPointerEvents={{this.endContentPointerEvents}} @isClearable={{this.isClearable}} @onClear={{this.clear}} @isEditable={{this.isSegmented}} @trigger={{p.trigger}} @calendarButtonLabel={{this.calendarButtonLabel}} @clearLabel={{this.clearLabel}} @isDisabled={{@isDisabled}} />\n </div>\n\n {{!-- preventAutoFocus: overlay's default focus grab runs later()\n after Calendar's autofocus already focused the day; turned off so\n Calendar's autofocus is the only thing moving focus into the grid. --}}\n <p.Content @size={{if @popoverSize @popoverSize \"auto\"}} @target={{@target}} @renderInPlace={{@renderInPlace}} @closeOnOutsideClick={{@closeOnOutsideClick}} @closeOnEscapeKey={{@closeOnEscapeKey}} @transitionDuration={{@transitionDuration}} @disableTransitions={{@disableTransitions}} @blockScroll={{false}} @preventAutoFocus={{true}} {{!-- Overlay captures document.activeElement when the content\n mounts -- the calendar button, on the segmented path -- and\n refocuses it on teardown, after close() has already put focus back\n on the segment. `close()` is the one answer; this stops the\n overlay giving a second. --}} @preventFocusRestore={{this.isSegmented}} role=\"dialog\" aria-label={{@label}}>\n {{#if (has-block \"calendar\")}}\n {{yield this.calendarBlockArg to=\"calendar\"}}\n {{else}}\n <Calendar @mode={{this.mode}} @color={{@color}} @value={{this.value}} @onChange={{this.handleCalendarChange}} @locale={{@locale}} @weekStartsOn={{@weekStartsOn}} @minValue={{@minValue}} @maxValue={{@maxValue}} @isDateUnavailable={{@isDateUnavailable}} @visibleMonths={{@visibleMonths}} @captionLayout={{@captionLayout}} @labels={{@labels}} @fixedWeeks={{@fixedWeeks}} @showOutsideDays={{@showOutsideDays}} @isReadOnly={{@isReadOnly}} @isDisabled={{@isDisabled}} @labelledBy={{c.id}} @autofocus={{true}} @classes={{hash base=(this.classes.calendar class=@classes.calendar)}} data-part=\"calendar\" />\n {{/if}}\n\n {{#if (has-block \"footer\")}}\n <div data-part=\"footer\" class={{this.classes.footer class=@classes.footer}}>\n {{yield this.footerBlockArg to=\"footer\"}}\n </div>\n {{/if}}\n </p.Content>\n </Popover>\n </FormControl>\n</div>", {
|
|
625
636
|
strictMode: true,
|
|
626
637
|
scope: () => ({
|
|
627
638
|
concat,
|