frontile 0.18.0-alpha.8 → 0.18.0-alpha.9

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.
@@ -0,0 +1,338 @@
1
+ import Component from '@glimmer/component';
2
+ import { tracked, cached } from '@glimmer/tracking';
3
+ import { on } from '@ember/modifier';
4
+ import { NativeSelect } from './native-select.js';
5
+ import { Listbox } from '../collections/listbox/listbox.js';
6
+ import { useStyles } from '@frontile/theme';
7
+ import { Spinner } from '../utilities/spinner.js';
8
+ import { VisuallyHidden } from '../utilities/visually-hidden.js';
9
+ import { ref } from '../../utils/ref.js';
10
+ import { Popover } from '../overlays/popover.js';
11
+ import { FormControl } from './form-control.js';
12
+ import { triggerFormInputEvent } from '../../utils/forms-utils-index.js';
13
+ import { CloseButton } from '../buttons/close-button.js';
14
+ import { IconChevronUpDown } from './icons.js';
15
+ import { defaultFilter, keyAndLabelForItem } from '../../utils/listManager.js';
16
+ import { cancel, debounce, later } from '@ember/runloop';
17
+ import { modifier } from 'ember-modifier';
18
+ import { precompileTemplate } from '@ember/template-compilation';
19
+ import { setComponentTemplate } from '@ember/component';
20
+ import { d as decorateFieldV2, i as initializeDeferredDecorator, a as decorateMethodV2 } from '../../runtime-BPCpkOf1-B5Lbloj7.js';
21
+
22
+ /**
23
+ * Autocomplete Component - a text input combined with a listbox popover,
24
+ * following the WAI-ARIA 1.2 combobox pattern.
25
+ *
26
+ * Users filter the options by typing (type-ahead). Options can come from a
27
+ * static list (built-in filtering), an externally filtered list
28
+ * (`disableFiltering` + `onInputChange`), or an async source (`onSearch`).
29
+ *
30
+ * Selection state follows the same two-way data binding pattern as `Select`:
31
+ * internal tracked state gives immediate UI updates, while `onSelectionChange`
32
+ * notifies the parent, whose arg updates sync back through modifiers.
33
+ */
34
+ class Autocomplete extends Component {
35
+ static {
36
+ decorateFieldV2(this.prototype, "nodes", [tracked], function () {
37
+ return [];
38
+ });
39
+ }
40
+ #nodes = (initializeDeferredDecorator(this, "nodes"), void 0);
41
+ static {
42
+ decorateFieldV2(this.prototype, "isOpen", [tracked], function () {
43
+ return false;
44
+ });
45
+ }
46
+ #isOpen = (initializeDeferredDecorator(this, "isOpen"), void 0);
47
+ static {
48
+ decorateFieldV2(this.prototype, "_selectedKey", [tracked], function () {
49
+ return null;
50
+ });
51
+ }
52
+ #_selectedKey = (initializeDeferredDecorator(this, "_selectedKey"), void 0);
53
+ /**
54
+ * Internal tracked selection state.
55
+ * Synced with @selectedKey via the updateSelectedKey modifier.
56
+ */
57
+ static {
58
+ decorateFieldV2(this.prototype, "_inputValue", [tracked]);
59
+ }
60
+ #_inputValue = (initializeDeferredDecorator(this, "_inputValue"), void 0);
61
+ /**
62
+ * The text the user has typed. `undefined` means the user is not editing,
63
+ * so the input displays the selected item's label instead.
64
+ */
65
+ static {
66
+ decorateFieldV2(this.prototype, "asyncItems", [tracked]);
67
+ }
68
+ #asyncItems = (initializeDeferredDecorator(this, "asyncItems"), void 0);
69
+ /**
70
+ * Items resolved from the latest `onSearch` call. `undefined` until the
71
+ * first search resolves; `@items` is rendered in the meantime.
72
+ */
73
+ static {
74
+ decorateFieldV2(this.prototype, "isSearchPending", [tracked], function () {
75
+ return false;
76
+ });
77
+ }
78
+ #isSearchPending = (initializeDeferredDecorator(this, "isSearchPending"), void 0);
79
+ /** Monotonic token to discard out-of-order onSearch resolutions. */#searchToken = 0;
80
+ #pendingSearch;
81
+ /** Element id of the currently active (highlighted) option, for aria-activedescendant. */
82
+ static {
83
+ decorateFieldV2(this.prototype, "activeDescendant", [tracked]);
84
+ }
85
+ #activeDescendant = (initializeDeferredDecorator(this, "activeDescendant"), void 0);
86
+ /** The currently active (highlighted) option. */activeItem;
87
+ /**
88
+ * Label of the selected key, captured at selection time. Needed in async
89
+ * mode, where the selected item may no longer be present in the currently
90
+ * rendered items (e.g. after search results are reset on close).
91
+ */
92
+ static {
93
+ decorateFieldV2(this.prototype, "selectedLabel", [tracked]);
94
+ }
95
+ #selectedLabel = (initializeDeferredDecorator(this, "selectedLabel"), void 0);
96
+ containerRef = ref();
97
+ triggerRef = ref();
98
+ constructor(owner, args) {
99
+ super(owner, args);
100
+ this._selectedKey = this.args.selectedKey || null;
101
+ }
102
+ willDestroy() {
103
+ super.willDestroy();
104
+ if (this.#pendingSearch) {
105
+ cancel(this.#pendingSearch);
106
+ }
107
+ }
108
+ onSelectionChange = keys => {
109
+ this.applySelection(keys[0] ?? null);
110
+ };
111
+ onNativeSelectionChange = key => {
112
+ this.applySelection(key);
113
+ };
114
+ applySelection(key) {
115
+ this.selectedLabel = key ? this.nodes.find(n => n.key === key)?.textValue : undefined;
116
+ this._selectedKey = key;
117
+ this.args.onSelectionChange?.(key);
118
+ this.clearInputValue();
119
+ triggerFormInputEvent(this.containerRef.current);
120
+ }
121
+ onOpenChange = isOpen => {
122
+ this.isOpen = isOpen;
123
+ };
124
+ onInput = event => {
125
+ const target = event.target;
126
+ this.setInputValue(target.value);
127
+ if (!this.isOpen) {
128
+ this.isOpen = true;
129
+ }
130
+ };
131
+ setInputValue(value) {
132
+ this._inputValue = value;
133
+ if (typeof this.args.onInputChange === 'function') {
134
+ this.args.onInputChange(value);
135
+ }
136
+ if (typeof this.args.onSearch === 'function') {
137
+ if (value === '') {
138
+ // A blank query shows the default `@items` again instead of searching.
139
+ this.resetSearch();
140
+ return;
141
+ }
142
+ this.isSearchPending = true;
143
+ this.#pendingSearch = debounce(this, this.performSearch, value, this.args.searchDebounce ?? 250);
144
+ }
145
+ }
146
+ /** Cancels any in-flight search and restores the default `@items`. */
147
+ resetSearch() {
148
+ if (this.#pendingSearch) {
149
+ cancel(this.#pendingSearch);
150
+ }
151
+ this.#searchToken++;
152
+ this.asyncItems = undefined;
153
+ this.isSearchPending = false;
154
+ }
155
+ clearInputValue() {
156
+ this._inputValue = undefined;
157
+ if (typeof this.args.onInputChange === 'function') {
158
+ this.args.onInputChange('');
159
+ }
160
+ }
161
+ async performSearch(query) {
162
+ const token = ++this.#searchToken;
163
+ try {
164
+ const result = await this.args.onSearch?.(query);
165
+ if (token === this.#searchToken && !this.isDestroying) {
166
+ this.asyncItems = result;
167
+ }
168
+ } finally {
169
+ if (token === this.#searchToken && !this.isDestroying) {
170
+ this.isSearchPending = false;
171
+ }
172
+ }
173
+ }
174
+ onKeyDown = event => {
175
+ if (event.key === 'Enter' && this.isOpen) {
176
+ // Prevent form submission while the dropdown is open. Canceling
177
+ // keydown also suppresses the keypress event the Listbox listens to,
178
+ // so select the active option directly.
179
+ event.preventDefault();
180
+ this.activeItem?.el.click();
181
+ }
182
+ };
183
+ /** Current selection as an array, for the Listbox / NativeSelect API. */
184
+ get selectedKeys() {
185
+ return this._selectedKey ? [this._selectedKey] : [];
186
+ }
187
+ get blockScroll() {
188
+ return this.args.blockScroll !== false;
189
+ }
190
+ get disableFocusTrap() {
191
+ return this.args.disableFocusTrap !== false;
192
+ }
193
+ onAction = key => {
194
+ if (typeof this.args.onAction === 'function') {
195
+ this.args.onAction(key);
196
+ }
197
+ if (this.args.closeOnItemSelect !== false) {
198
+ this.isOpen = false;
199
+ }
200
+ this.handleBlur();
201
+ };
202
+ // wait a beat for any side effects to complete before calling onBlur
203
+ handleBlur = () => {
204
+ if (typeof this.args.onBlur === 'function') {
205
+ later(() => {
206
+ this.args.onBlur?.();
207
+ }, 150);
208
+ }
209
+ };
210
+ clearSelectedKeys = () => {
211
+ this.onSelectionChange([]);
212
+ this.clearInputValue();
213
+ this.triggerRef.current?.focus();
214
+ };
215
+ onItemsChange = (nodes, _) => {
216
+ this.nodes = nodes;
217
+ };
218
+ didClose = () => {
219
+ if (!this.args.allowsCustomValue) {
220
+ this._inputValue = undefined;
221
+ }
222
+ this.activeDescendant = undefined;
223
+ this.activeItem = undefined;
224
+ // Reset async results so reopening shows the default `@items` again.
225
+ if (typeof this.args.onSearch === 'function') {
226
+ this.resetSearch();
227
+ }
228
+ this.args.didClose?.();
229
+ };
230
+ onActiveItemChange = (_key, item) => {
231
+ this.activeItem = item;
232
+ this.activeDescendant = item?.el.id || undefined;
233
+ };
234
+ get selectedTextValue() {
235
+ const key = this._selectedKey;
236
+ if (!key) {
237
+ return '';
238
+ }
239
+ const node = this.nodes.find(n => n.key === key);
240
+ return node?.textValue ?? this.selectedLabel ?? key;
241
+ }
242
+ get inputValue() {
243
+ if (typeof this.args.inputValue === 'string') {
244
+ return this.args.inputValue;
245
+ }
246
+ if (this._inputValue !== undefined) {
247
+ return this._inputValue;
248
+ }
249
+ return this.selectedTextValue;
250
+ }
251
+ get isFiltering() {
252
+ const value = typeof this.args.inputValue === 'string' ? this.args.inputValue : this._inputValue;
253
+ return typeof value === 'string' && value !== '';
254
+ }
255
+ get backdrop() {
256
+ return this.args.backdrop ?? 'transparent';
257
+ }
258
+ get classes() {
259
+ const {
260
+ autocomplete
261
+ } = useStyles();
262
+ return autocomplete({
263
+ size: this.args.inputSize
264
+ });
265
+ }
266
+ static {
267
+ decorateMethodV2(this.prototype, "classes", [cached]);
268
+ }
269
+ get isClearable() {
270
+ return this.args.isClearable && (this.selectedKeys.length > 0 || this.isFiltering);
271
+ }
272
+ get isLoading() {
273
+ return this.args.isLoading || this.isSearchPending;
274
+ }
275
+ get filteredItems() {
276
+ if (typeof this.args.onSearch === 'function') {
277
+ return this.asyncItems ?? this.args.items;
278
+ }
279
+ if (this.args.disableFiltering || !this.isFiltering) {
280
+ return this.args.items;
281
+ }
282
+ const filter = this.args.filter || defaultFilter;
283
+ const query = this.inputValue;
284
+ return this.args.items?.filter(item => filter(keyAndLabelForItem(item).label, query));
285
+ }
286
+ /**
287
+ * True when an async autocomplete is open with a blank query and nothing
288
+ * to show — the moment to prompt the user to start typing.
289
+ */
290
+ static {
291
+ decorateMethodV2(this.prototype, "filteredItems", [cached]);
292
+ }
293
+ get isSearchPromptState() {
294
+ return typeof this.args.onSearch === 'function' && !this.isFiltering && !this.isLoading && (this.filteredItems?.length ?? 0) === 0;
295
+ }
296
+ get showEmptyContent() {
297
+ return this.filteredItems?.length === 0 && !this.isLoading && !this.args.hideEmptyContent;
298
+ }
299
+ get autoActivateMode() {
300
+ if (this.isFiltering) {
301
+ return 'first';
302
+ }
303
+ return 'selected';
304
+ }
305
+ /**
306
+ * Syncs internal `_selectedKey` with external `@selectedKey` argument.
307
+ */
308
+ updateSelectedKey = modifier((_, [selectedKey]) => {
309
+ if (selectedKey !== undefined) {
310
+ this._selectedKey = selectedKey;
311
+ }
312
+ });
313
+ static {
314
+ setComponentTemplate(precompileTemplate("\n <div {{this.updateSelectedKey @selectedKey}} {{this.containerRef.setup}} class={{this.classes.base class=@classes.base}} data-component=\"autocomplete\" ...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.filteredItems}} @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}}>\n {{#if (has-block \"startContent\")}}\n <div data-test-id=\"input-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-test-id=\"trigger\" data-component=\"autocomplete-trigger\" 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 \"blur\" this.handleBlur}} />\n <div data-test-id=\"input-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\"}} data-test-id=\"loading-spinner\" />\n {{else if this.isClearable}}\n <CloseButton @title=\"Clear\" @variant=\"subtle\" @size=\"xs\" @class={{this.classes.clearButton class=@classes.clearButton}} data-test-id=\"input-clear-button\" @onPress={{this.clearSelectedKeys}} />\n {{else}}\n <IconChevronUpDown 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.filteredItems}} @allowEmpty={{@allowEmpty}} @appearance={{@appearance}} @disabledKeys={{@disabledKeys}} @intent={{@intent}} @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}}>\n <:item as |l|>\n {{#if (has-block \"item\")}}\n {{yield l to=\"item\"}}\n {{else}}\n <l.Item @key={{l.key}} @appearance={{@appearance}} @intent={{@intent}}>\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-test-id=\"search-message\">\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-test-id=\"empty-content\">\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 ", {
315
+ strictMode: true,
316
+ scope: () => ({
317
+ FormControl,
318
+ Popover,
319
+ VisuallyHidden,
320
+ NativeSelect,
321
+ on,
322
+ Spinner,
323
+ isSm,
324
+ CloseButton,
325
+ IconChevronUpDown,
326
+ Listbox,
327
+ and,
328
+ or
329
+ })
330
+ }), this);
331
+ }
332
+ }
333
+ const isSm = size => size === 'sm';
334
+ const and = (a, b) => Boolean(a) && Boolean(b);
335
+ const or = (a, b) => Boolean(a) || Boolean(b);
336
+
337
+ export { Autocomplete, Autocomplete as default };
338
+ //# sourceMappingURL=autocomplete.js.map
@@ -0,0 +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 {\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 './icons';\nimport { keyAndLabelForItem, defaultFilter } from '../../utils/listManager';\nimport { later, debounce, cancel } from '@ember/runloop';\n\nimport { modifier } from 'ember-modifier';\n\ninterface AutocompleteArgs<T>\n extends 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 | 'appearance'\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 * The default implementation performs a case-insensitive \"contains\" search.\n *\n * @param itemValue - The label of an item in the dropdown.\n * @param inputValue - The user's input text.\n * @returns A boolean indicating whether the item should be shown.\n */\n filter?: (itemValue: string, inputValue: string) => boolean;\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 * This option ignores the `allowEmpty` setting.\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 the autocomplete component loses focus.\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 * Selection state follows the same two-way data binding pattern as `Select`:\n * internal tracked state gives immediate UI updates, while `onSelectionChange`\n * notifies the parent, whose arg updates sync back through modifiers.\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 /** The currently active (highlighted) option. */\n activeItem?: ListItem;\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 }\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. Canceling\n // keydown also suppresses the keypress event the Listbox listens to,\n // so select the active option directly.\n event.preventDefault();\n\n this.activeItem?.el.click();\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 this.handleBlur();\n };\n\n // wait a beat for any side effects to complete before calling onBlur\n handleBlur = () => {\n if (typeof this.args.onBlur === 'function') {\n later(() => {\n this.args.onBlur?.();\n }, 150);\n }\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 this.activeItem = 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.activeItem = item;\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 return autocomplete({\n size: this.args.inputSize\n });\n }\n\n get isClearable() {\n return (\n this.args.isClearable &&\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 const filter = this.args.filter || defaultFilter;\n const query = this.inputValue;\n\n return this.args.items?.filter((item) =>\n filter(keyAndLabelForItem(item).label, query)\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 ...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 >\n {{#if (has-block \"startContent\")}}\n <div\n data-test-id=\"input-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-test-id=\"trigger\"\n data-component=\"autocomplete-trigger\"\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 \"blur\" this.handleBlur}}\n />\n <div\n data-test-id=\"input-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\n @size={{if (isSm @inputSize) \"xs\" \"sm\"}}\n data-test-id=\"loading-spinner\"\n />\n {{else if this.isClearable}}\n <CloseButton\n @title=\"Clear\"\n @variant=\"subtle\"\n @size=\"xs\"\n @class={{this.classes.clearButton class=@classes.clearButton}}\n data-test-id=\"input-clear-button\"\n @onPress={{this.clearSelectedKeys}}\n />\n {{else}}\n <IconChevronUpDown\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 @appearance={{@appearance}}\n @disabledKeys={{@disabledKeys}}\n @intent={{@intent}}\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 >\n <:item as |l|>\n {{#if (has-block \"item\")}}\n {{yield l to=\"item\"}}\n {{else}}\n <l.Item\n @key={{l.key}}\n @appearance={{@appearance}}\n @intent={{@intent}}\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-test-id=\"search-message\"\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-test-id=\"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","void 0","activeItem","containerRef","ref","triggerRef","constructor","owner","args","_selectedKey","selectedKey","willDestroy","cancel","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","el","click","selectedKeys","blockScroll","disableFocusTrap","onAction","closeOnItemSelect","handleBlur","onBlur","later","clearSelectedKeys","focus","onItemsChange","_","didClose","allowsCustomValue","activeDescendant","onActiveItemChange","_key","item","id","selectedTextValue","node","inputValue","isFiltering","backdrop","classes","autocomplete","useStyles","size","inputSize","cached","isClearable","length","isLoading","filteredItems","items","disableFiltering","filter","defaultFilter","keyAndLabelForItem","label","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":";;;;;;;;;;;;;;;;;;;;;AAoSA;;;;;;;;;;;AAWC;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;AAAA,EAAA,MAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,OAAA,CAAA,EAAAC,MAAA;AAAA,EAAA;IAAAJ,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CAC9BC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAiB,KAAA;AAAA,IAAA,CAAA,CAAA;AAAA;AAAA,EAAA,OAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,QAAA,CAAA,EAAAC,MAAA;AAAA,EAAA;IAAAJ,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CAMjBC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAsC,IAAA;AAAA,IAAA,CAAA,CAAA;AAAA;AAAA,EAAA,aAA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from './input.js';
8
8
  export { Label } from './label.js';
9
9
  export { NativeSelect } from './native-select.js';
10
10
  export { Select } from './select.js';
11
+ export { Autocomplete } from './autocomplete.js';
11
12
  export { Textarea } from './textarea.js';
12
13
  export { Radio } from './radio.js';
13
14
  export { RadioGroup } from './radio-group.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
@@ -12,7 +12,7 @@ import { FormControl } from './form-control.js';
12
12
  import { triggerFormInputEvent } from '../../utils/forms-utils-index.js';
13
13
  import { CloseButton } from '../buttons/close-button.js';
14
14
  import { IconChevronUpDown } from './icons.js';
15
- import { keyAndLabelForItem } from '../../utils/listManager.js';
15
+ import { defaultFilter, keyAndLabelForItem } from '../../utils/listManager.js';
16
16
  import { action } from '@ember/object';
17
17
  import { later } from '@ember/runloop';
18
18
  import { modifier } from 'ember-modifier';
@@ -320,7 +320,7 @@ class Select extends Component {
320
320
  if (this.filterValue === undefined) {
321
321
  return this.args.items;
322
322
  }
323
- let filter = this.args.filter || ((itemValue, filterValue) => itemValue.toLowerCase().includes(filterValue.toLowerCase()));
323
+ let filter = this.args.filter || defaultFilter;
324
324
  return this.args.items?.filter(item => filter(keyAndLabelForItem(item).label, this.filterValue || ''));
325
325
  }
326
326
  get showEmptyContent() {