frontile 0.18.3 → 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.
@@ -6,7 +6,7 @@ import { type AutocompleteSlots, type AutocompleteVariants, type SlotsToClasses
6
6
  import { ControlBlurTracker } from '../../-private/control-blur';
7
7
  import { type PopoverSignature, type ContentSignature } from '../overlays/popover';
8
8
  import { type FormControlSharedArgs } from './form-control';
9
- import { type FilterFn } from '../../utils/filter';
9
+ import { type FilterFn, type DisplayLimitContentArgs } from '../../utils/filter';
10
10
  interface AutocompleteArgs<T> extends Pick<PopoverSignature['Args'], 'placement' | 'flipOptions' | 'middleware' | 'shiftOptions' | 'offsetOptions' | 'strategy' | 'didClose'>, Pick<ListboxSignature<T>['Args'], 'variant' | 'appearance' | 'color' | 'intent' | 'disabledKeys' | 'allowEmpty' | 'items' | 'onAction'>, Pick<ContentSignature['Args'], 'renderInPlace' | 'target' | 'transitionDuration' | 'backdrop' | 'disableTransitions' | 'focusTrapOptions' | 'closeOnOutsideClick' | 'closeOnEscapeKey' | 'backdropTransition' | 'transition'>, FormControlSharedArgs {
11
11
  /**
12
12
  * The currently selected key.
@@ -109,6 +109,22 @@ interface AutocompleteArgs<T> extends Pick<PopoverSignature['Args'], 'placement'
109
109
  * @defaultValue false
110
110
  */
111
111
  disableFiltering?: boolean;
112
+ /**
113
+ * The most options the dropdown renders at once.
114
+ *
115
+ * Every rendered option is DOM to build, and to rebuild on each keystroke as
116
+ * the matches change, so a list of hundreds of options makes typing lag.
117
+ * With a limit, only the first `displayLimit` options are rendered, in the
118
+ * order the filter ranked them, and the `displayLimitContent` block says how
119
+ * many more there are. The rest are reached by typing a narrower query.
120
+ *
121
+ * It caps whatever the dropdown would show: the built-in matches, `@items`
122
+ * under `disableFiltering`, or the results of `onSearch`. The selected
123
+ * option is always rendered, even past the limit.
124
+ *
125
+ * @defaultValue undefined (every option is rendered)
126
+ */
127
+ displayLimit?: number;
112
128
  /**
113
129
  * Async search function. When provided, the component calls it (debounced)
114
130
  * as the user types and renders the resolved items, showing a loading
@@ -179,6 +195,13 @@ interface AutocompleteArgs<T> extends Pick<PopoverSignature['Args'], 'placement'
179
195
  * @defaultValue false
180
196
  */
181
197
  hideEmptyContent?: boolean;
198
+ /**
199
+ * If true, hides the display limit content when `@displayLimit` leaves
200
+ * options out.
201
+ *
202
+ * @defaultValue false
203
+ */
204
+ hideDisplayLimitContent?: boolean;
182
205
  /**
183
206
  * Message shown in the dropdown of an async autocomplete (`onSearch`)
184
207
  * while the query is blank — e.g. "Type to search for an address…".
@@ -219,6 +242,13 @@ interface AutocompleteSignature<T> {
219
242
  * If `hideEmptyContent` argument is true, this content will not be shown.
220
243
  */
221
244
  emptyContent: [];
245
+ /**
246
+ * The content to display below the options when `@displayLimit` leaves
247
+ * some of them out. Yields how many options are shown and how many match
248
+ * in total. If `hideDisplayLimitContent` argument is true, this content
249
+ * will not be shown.
250
+ */
251
+ displayLimitContent: [DisplayLimitContentArgs];
222
252
  /**
223
253
  * Message shown in the dropdown of an async autocomplete while the
224
254
  * query is blank, prompting the user to start typing. Takes priority
@@ -388,6 +418,14 @@ declare class Autocomplete<T = unknown> extends Component<AutocompleteSignature<
388
418
  startContentPointerEvents?: "none" | "auto" | undefined;
389
419
  endContentPointerEvents?: "none" | "auto" | undefined;
390
420
  } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
421
+ displayLimitContent: (slotProps?: ({
422
+ size?: "sm" | "md" | "lg" | undefined;
423
+ hasStartContent?: boolean | undefined;
424
+ hasEndContent?: boolean | undefined;
425
+ hasChips?: boolean | undefined;
426
+ startContentPointerEvents?: "none" | "auto" | undefined;
427
+ endContentPointerEvents?: "none" | "auto" | undefined;
428
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
391
429
  } & {
392
430
  base: (slotProps?: ({
393
431
  size?: "sm" | "md" | "lg" | undefined;
@@ -425,6 +463,16 @@ declare class Autocomplete<T = unknown> extends Component<AutocompleteSignature<
425
463
  get isClearable(): boolean | undefined;
426
464
  get isLoading(): boolean;
427
465
  get filteredItems(): T[] | undefined;
466
+ /**
467
+ * The options the listbox renders: `filteredItems`, capped by
468
+ * `@displayLimit`.
469
+ */
470
+ get displayedItems(): T[] | undefined;
471
+ /**
472
+ * What the display limit content reports, or `undefined` when nothing is
473
+ * left out.
474
+ */
475
+ get displayLimitContent(): DisplayLimitContentArgs | undefined;
428
476
  /**
429
477
  * True when an async autocomplete is open with a blank query and nothing
430
478
  * to show — the moment to prompt the user to start typing.
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/forms/autocomplete.gts"],"names":[],"mappings":"AA46BA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAG3C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAW,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAe,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAKzE,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAMvE,UAAU,gBAAgB,CAAC,CAAC,CAC1B,SACE,IAAI,CACF,gBAAgB,CAAC,MAAM,CAAC,EACtB,WAAW,GACX,aAAa,GACb,YAAY,GACZ,cAAc,GACd,eAAe,GACf,UAAU,GACV,UAAU,CACb,EACD,IAAI,CACF,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM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,CAO9B;IAED,IAAI,UAAU,IAAI,MAAM,CAQvB;IAED,IAAI,WAAW,IAAI,OAAO,CAOzB;IAED,IAAI,QAAQ,8CAEX;IAED,IACI,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAWV;IAED;;;;OAIG;IACH,IACI,OAAO,+CAYV;IAED;;;;OAIG;IACH,IACI,KAAK,oGAYR;IAED;;;;;;;;;;;OAWG;IACH,IAAI,WAAW,wBAMd;IAED,IAAI,SAAS,YAEZ;IAED,IACI,aAAa,oBAehB;IAED;;;OAGG;IACH,IAAI,mBAAmB,IAAI,OAAO,CAOjC;IAED,IAAI,gBAAgB,YAMnB;IAED,IAAI,gBAAgB,IAAI,OAAO,GAAG,UAAU,CAK3C;IAED;;OAEG;IACH,iBAAiB;;;;;;OAMf;CAqTH;AAMD,OAAO,EAAE,YAAY,EAAE,KAAK,qBAAqB,EAAE,CAAC;AACpD,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/forms/autocomplete.gts"],"names":[],"mappings":"AAugCA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAG3C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAW,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAe,KAAK,qBAAqB,EAAE,MAAM,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BAAqB,EAAE,CAAC;AACpD,eAAe,YAAY,CAAC"}
@@ -2,6 +2,7 @@ import Component from '@glimmer/component';
2
2
  import type Owner from '@ember/owner';
3
3
  import type { ListItem } from '../native-select';
4
4
  import { ControlBlurTracker } from '../../../-private/control-blur';
5
+ import { type DisplayLimitContentArgs } from '../../../utils/filter';
5
6
  import type { ResolvedSelectChipOptions, SelectArgs, SelectChipOptions, SelectSignature, SelectedItem, SelectedItemBlockArg } from './types';
6
7
  /**
7
8
  * A dropdown selection component: a custom listbox in a popover, backed by a
@@ -45,6 +46,10 @@ declare class Select<T = unknown> extends Component<SelectSignature<T>> {
45
46
  onOpenChange: (isOpen: boolean) => void;
46
47
  onFilterChange: (event: Event) => void;
47
48
  /**
49
+ * Enter in the open filter picks the active option (the Listbox handles
50
+ * that), so it must not also submit a wrapping form, the same guard
51
+ * Autocomplete has. Closed, Enter is left to the form.
52
+ *
48
53
  * Backspace on an empty filter removes the last chip — the familiar tag-input
49
54
  * gesture. With text in the filter, Backspace edits the text as usual.
50
55
  */
@@ -168,6 +173,9 @@ declare class Select<T = unknown> extends Component<SelectSignature<T>> {
168
173
  * readable anywhere else in that case, so the name carries it: the control
169
174
  * name *and* the selected options' text.
170
175
  *
176
+ * With nothing selected the placeholder is the trigger's visible text, so
177
+ * it joins the name (`Merchant, All merchants`) rather than being dropped.
178
+ *
171
179
  * The two halves are composed so that the separator only appears when both
172
180
  * are there. A selected key with no registered option behind it resolves to
173
181
  * no text at all, and `"Owner, "` is announced as "Owner comma"; and with
@@ -304,6 +312,15 @@ declare class Select<T = unknown> extends Component<SelectSignature<T>> {
304
312
  endContentPointerEvents?: "none" | "auto" | undefined;
305
313
  isFilterable?: boolean | undefined;
306
314
  } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
315
+ displayLimitContent: (slotProps?: ({
316
+ size?: "sm" | "md" | "lg" | undefined;
317
+ hasStartContent?: boolean | undefined;
318
+ hasEndContent?: boolean | undefined;
319
+ hasChips?: boolean | undefined;
320
+ startContentPointerEvents?: "none" | "auto" | undefined;
321
+ endContentPointerEvents?: "none" | "auto" | undefined;
322
+ isFilterable?: boolean | undefined;
323
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
307
324
  chipsField: (slotProps?: ({
308
325
  size?: "sm" | "md" | "lg" | undefined;
309
326
  hasStartContent?: boolean | undefined;
@@ -353,6 +370,16 @@ declare class Select<T = unknown> extends Component<SelectSignature<T>> {
353
370
  get filterFieldValue(): string;
354
371
  get filteredItems(): T[] | undefined;
355
372
  get showEmptyContent(): boolean;
373
+ /**
374
+ * The matches the listbox renders: `filteredItems`, capped by
375
+ * `@displayLimit`.
376
+ */
377
+ get displayedItems(): T[] | undefined;
378
+ /**
379
+ * What the display limit content reports, or `undefined` when nothing is
380
+ * left out.
381
+ */
382
+ get displayLimitContent(): DisplayLimitContentArgs | undefined;
356
383
  get autoActivateMode(): 'first' | 'selected';
357
384
  /** Syncs internal `_selectedKeys` whenever `@selectedKeys` changes. */
358
385
  updateMultipleSelectValue: import("ember-modifier").FunctionBasedModifier<{
@@ -371,6 +398,6 @@ declare class Select<T = unknown> extends Component<SelectSignature<T>> {
371
398
  Element: HTMLDivElement;
372
399
  }>;
373
400
  }
374
- export { Select, type SelectSignature, type SelectChipOptions, type SelectedItem, type SelectedItemBlockArg };
401
+ export { Select, type SelectSignature, type SelectChipOptions, type SelectedItem, type SelectedItemBlockArg, type DisplayLimitContentArgs };
375
402
  export default Select;
376
403
  //# sourceMappingURL=select.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/select/select.gts"],"names":[],"mappings":"AAu3BA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAE3C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAMtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAMjD,OAAO,EAAE,kBAAkB,EAAE,MA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAaV;IAED;;;;;;OAMG;IACH,IAAI,WAAW,wBAOd;IAED,IAAI,gBAAgB,WAUnB;IAID,IACI,aAAa,oBAWhB;IAED,IAAI,gBAAgB,YAEnB;IAED;;;OAGG;IACH,IACI,cAAc,oBAgBjB;IAED;;;OAGG;IACH,IAAI,mBAAmB,IAAI,uBAAuB,GAAG,SAAS,CAO7D;IAED,IAAI,gBAAgB,IAAI,OAAO,GAAG,UAAU,CAK3C;IAED,uEAAuE;IACvE,yBAAyB;;;;;;OAQvB;IAEF,qEAAqE;IACrE,uBAAuB;;;;;;OAMrB;CAqSH;AAED,OAAO,EACL,MAAM,EACN,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC7B,CAAC;AACF,eAAe,MAAM,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { ListboxSignature } from '../../collections/listbox';
2
- import type { FilterFn } from '../../../utils/filter';
2
+ import type { FilterFn, DisplayLimitContentArgs } from '../../../utils/filter';
3
3
  import type { SelectSlots, SelectVariants, SlotsToClasses } from '@frontile/theme';
4
4
  import type { useStyles } from '@frontile/theme';
5
5
  import type { PopoverSignature, ContentSignature } from '../../overlays/popover';
@@ -302,6 +302,26 @@ type SelectArgs<T> = (ExplicitSingleSelectArgs<T> | DefaultSingleSelectArgs<T> |
302
302
  * to filter only, preserving the order of `@items`.
303
303
  */
304
304
  filter?: FilterFn;
305
+ /**
306
+ * The most options the dropdown renders at once.
307
+ *
308
+ * Every rendered option is DOM to build, and to rebuild on each keystroke as
309
+ * the matches change, so a list of hundreds of options makes typing in the
310
+ * filter lag. With a limit, only the first `displayLimit` matches are
311
+ * rendered, in the order the filter ranked them, and the
312
+ * `displayLimitContent` block says how many more there are. The rest are
313
+ * reached by typing a narrower query.
314
+ *
315
+ * Selected options are always rendered, even past the limit.
316
+ *
317
+ * Requires `@isFilterable`: without a filter, the options past the limit
318
+ * could not be reached at all. Options passed in block form are not
319
+ * counted or limited. The hidden native `<select>` always holds every
320
+ * option, so the form value is never affected.
321
+ *
322
+ * @defaultValue undefined (every option is rendered)
323
+ */
324
+ displayLimit?: number;
305
325
  /**
306
326
  * If true, the select will show a loading spinner instead of the dropdown icon.
307
327
  */
@@ -346,6 +366,13 @@ type SelectArgs<T> = (ExplicitSingleSelectArgs<T> | DefaultSingleSelectArgs<T> |
346
366
  * @defaultValue false
347
367
  */
348
368
  hideEmptyContent?: boolean;
369
+ /**
370
+ * If true, hides the display limit content when `@displayLimit` leaves
371
+ * options out.
372
+ *
373
+ * @defaultValue false
374
+ */
375
+ hideDisplayLimitContent?: boolean;
349
376
  /**
350
377
  * Callback fired when focus leaves the Select.
351
378
  *
@@ -383,6 +410,13 @@ interface SelectSignature<T> {
383
410
  * If `hideEmptyContent` argument is true, this content will not be shown.
384
411
  */
385
412
  emptyContent: [];
413
+ /**
414
+ * The content to display below the options when `@displayLimit` leaves
415
+ * some of them out. Yields how many options are shown and how many match
416
+ * in total. If `hideDisplayLimitContent` argument is true, this content
417
+ * will not be shown.
418
+ */
419
+ displayLimitContent: [DisplayLimitContentArgs];
386
420
  /**
387
421
  * Custom content for each *selected* option, in place of its plain text.
388
422
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/select/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,cAAc,EACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM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C,CAAC;IACpC,IAAI,EAAE,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7C,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACpC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,yBAAyB,EAC9B,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,eAAe,EACrB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/select/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,cAAc,EACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;GAIG;AACH,UAAU,YAAY;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,UAAU,oBAAoB,CAAC,CAAC,GAAG,OAAO;IACxC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,CAAC,CAAC;IAET,GAAG,EAAE,MAAM,CAAC;I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EAC7B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,eAAe,EACrB,CAAC"}
@@ -85,4 +85,34 @@ export declare const SECONDARY_FIELD_WEIGHT = 0.6;
85
85
  * @param filter - Scores one item; defaults to {@link defaultFilter}.
86
86
  */
87
87
  export declare function filterAndRankItems<T>(items: T[] | undefined, query: string, labelFor: (item: T) => string | string[], filter?: FilterFn): T[] | undefined;
88
+ /**
89
+ * Cap `items` at the first `limit`, for rendering.
90
+ *
91
+ * A long list is cheap to filter but expensive to render: every option is DOM
92
+ * that has to be built, and rebuilt as the matches change on each keystroke.
93
+ * Capping what is rendered keeps that cost proportional to `limit` instead of
94
+ * to `items`. It is meant for lists the user narrows by typing, where the
95
+ * options past the cap are still reachable through the query.
96
+ *
97
+ * Items `isKept` accepts are rendered even past the cap, in their place in
98
+ * `items`, so a cap never hides the current selection. That is why the result
99
+ * can be longer than `limit`.
100
+ *
101
+ * Without a `limit`, or when `items` already fits, `items` is returned as is.
102
+ *
103
+ * @param items - The items to cap, already filtered and ranked.
104
+ * @param limit - The most items to render.
105
+ * @param isKept - Items to render whatever their position.
106
+ */
107
+ export declare function limitItems<T>(items: T[] | undefined, limit: number | undefined, isKept?: (item: T) => boolean): T[] | undefined;
108
+ /**
109
+ * Yielded to the `displayLimitContent` block of a `Select` or `Autocomplete`
110
+ * whose `@displayLimit` left options out.
111
+ */
112
+ export interface DisplayLimitContentArgs {
113
+ /** How many options are rendered. */
114
+ shown: number;
115
+ /** How many options match, rendered or not. */
116
+ total: number;
117
+ }
88
118
  //# sourceMappingURL=filter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/utils/filter.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,QAAQ,GAAG,CACrB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,KACf,OAAO,GAAG,MAAM,CAAC;AAStB;;;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AACH,eAAO,MAAM,aAAa,cA1CX,MAAM,cAAc,MAAM,KAAK,MA0CE,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAuC1C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,KAAK,EAAE,CAAC,EAAE,GAAG,SAAS,EACtB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,EAAE,EACxC,MAAM,GAAE,QAAwB,GAC/B,CAAC,EAAE,GAAG,SAAS,CAkBjB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,KAAK,EAAE,CAAC,EAAE,GAAG,SAAS,EACtB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,MAAM,GAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAqB,GACzC,CAAC,EAAE,GAAG,SAAS,CAMjB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -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
- * True when an async autocomplete is open with a blank query and nothing
346
- * to show — the moment to prompt the user to start typing.
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.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}} 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.filteredItems}} @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 </p.Content>\n </Popover>\n </FormControl>\n</div>", {
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,EA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AA;AAC9D,MAAMF,EAAA,GAAKA,CAACC,CAAU,EAAEC,CAAU,KAAKC,OAAA,CAAQF,CAAA,CAAA,IAAME,OAAA,CAAQD,CAAA,CAAA;;"}
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 {\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;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C,OAAA,CAAQF,CAAA,CAAA,IAAME,OAAA,CAAQD,CAAA,CAAA;;"}
@@ -1,5 +1,6 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { tracked, cached } from '@glimmer/tracking';
3
+ import { assert } from '@ember/debug';
3
4
  import { on } from '@ember/modifier';
4
5
  import { modifier } from 'ember-modifier';
5
6
  import { useStyles } from '@frontile/theme';
@@ -12,7 +13,7 @@ import { ref } from '../../../utils/ref.js';
12
13
  import { C as ControlBlurTracker } from '../../../control-blur-C8OnSQR5.js';
13
14
  import { triggerFormInputEvent } from '../../../utils/forms-utils-index.js';
14
15
  import { canDeselectKey, keyAndLabelForItem } from '../../../utils/listManager.js';
15
- import { filterAndRankItems } from '../../../utils/filter.js';
16
+ import { filterAndRankItems, limitItems } from '../../../utils/filter.js';
16
17
  import { SelectNativeMirror } from './native-mirror.js';
17
18
  import { SelectTrigger } from './trigger.js';
18
19
  import { SelectedChips } from './selected-items.js';
@@ -138,10 +139,18 @@ class Select extends Component {
138
139
  this.filterValue = target.value;
139
140
  };
140
141
  /**
142
+ * Enter in the open filter picks the active option (the Listbox handles
143
+ * that), so it must not also submit a wrapping form, the same guard
144
+ * Autocomplete has. Closed, Enter is left to the form.
145
+ *
141
146
  * Backspace on an empty filter removes the last chip — the familiar tag-input
142
147
  * gesture. With text in the filter, Backspace edits the text as usual.
143
148
  */
144
149
  handleFilterKeydown = event => {
150
+ if (event.key === 'Enter' && this.isOpen) {
151
+ event.preventDefault();
152
+ return;
153
+ }
145
154
  if (event.key !== 'Backspace' || !this.showChips) {
146
155
  return;
147
156
  }
@@ -435,6 +444,9 @@ class Select extends Component {
435
444
  * readable anywhere else in that case, so the name carries it: the control
436
445
  * name *and* the selected options' text.
437
446
  *
447
+ * With nothing selected the placeholder is the trigger's visible text, so
448
+ * it joins the name (`Merchant, All merchants`) rather than being dropped.
449
+ *
438
450
  * The two halves are composed so that the separator only appears when both
439
451
  * are there. A selected key with no registered option behind it resolves to
440
452
  * no text at all, and `"Owner, "` is announced as "Owner comma"; and with
@@ -444,6 +456,11 @@ class Select extends Component {
444
456
  */
445
457
  get triggerAccessibleName() {
446
458
  const name = this.args.label || this.args.placeholder;
459
+ // Nothing selected: the placeholder is the visible text, so it joins the
460
+ // name (WCAG 2.5.3 Label in Name).
461
+ if (!this.hasSelection && this.args.label && this.args.placeholder) {
462
+ return this.args.label === this.args.placeholder ? this.args.label : `${this.args.label}, ${this.args.placeholder}`;
463
+ }
447
464
  // Chips mode names the *control* only -- the chips are read separately --
448
465
  // and has no better fallback than the literal.
449
466
  if (this.showChips) {
@@ -524,15 +541,52 @@ class Select extends Component {
524
541
  }
525
542
  return this.selectedTextValue;
526
543
  }
544
+ // Cached: the listbox, the empty content and the display limit read it, and
545
+ // filtering a long list on every read would repeat the work per keystroke.
527
546
  get filteredItems() {
528
547
  if (this.filterValue === undefined) {
529
548
  return this.args.items;
530
549
  }
531
550
  return filterAndRankItems(this.args.items, this.filterValue || '', item => keyAndLabelForItem(item).label, this.args.filter);
532
551
  }
552
+ static {
553
+ decorateMethodV2(this.prototype, "filteredItems", [cached]);
554
+ }
533
555
  get showEmptyContent() {
534
556
  return this.filteredItems?.length === 0 && !this.args.hideEmptyContent;
535
557
  }
558
+ /**
559
+ * The matches the listbox renders: `filteredItems`, capped by
560
+ * `@displayLimit`.
561
+ */
562
+ get displayedItems() {
563
+ const {
564
+ displayLimit,
565
+ isFilterable
566
+ } = this.args;
567
+ assert(`Select: @displayLimit must be a positive integer, received ${String(displayLimit)}`, displayLimit === undefined || Number.isInteger(displayLimit) && displayLimit > 0);
568
+ assert('Select: @displayLimit requires @isFilterable, otherwise the options past the limit cannot be reached', displayLimit === undefined || isFilterable);
569
+ const selectedKeys = this.selectedKeys;
570
+ return limitItems(this.filteredItems, displayLimit, item => selectedKeys.includes(keyAndLabelForItem(item).key));
571
+ }
572
+ /**
573
+ * What the display limit content reports, or `undefined` when nothing is
574
+ * left out.
575
+ */
576
+ static {
577
+ decorateMethodV2(this.prototype, "displayedItems", [cached]);
578
+ }
579
+ get displayLimitContent() {
580
+ const shown = this.displayedItems?.length ?? 0;
581
+ const total = this.filteredItems?.length ?? 0;
582
+ if (shown === total || this.args.hideDisplayLimitContent) {
583
+ return undefined;
584
+ }
585
+ return {
586
+ shown,
587
+ total
588
+ };
589
+ }
536
590
  get autoActivateMode() {
537
591
  if (this.filterValue === undefined || this.filterValue === '') {
538
592
  return 'selected';
@@ -554,7 +608,7 @@ class Select extends Component {
554
608
  }
555
609
  });
556
610
  static {
557
- setComponentTemplate(precompileTemplate("<div {{this.updateMultipleSelectValue @selectedKeys}} {{this.updateSingleSelectValue @selectedKey}} {{this.containerRef.setup}} class={{this.classes.base class=@classes.base}} data-component=\"select\" 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 <SelectNativeMirror @items={{@items}} @allowEmpty={{@allowEmpty}} @disabledKeys={{@disabledKeys}} @selectionMode={{@selectionMode}} @selectedKeys={{this.selectedKeys}} @selectedKey={{this.getSelectedKey}} @onSelectionChange={{this.onSelectionChange}} @onSingleSelectionChange={{this.onSingleSelectionChange}} @onItemsChange={{this.onItemsChange}} @placeholder={{@placeholder}} @id={{c.id}} @name={{@name}} @isDisabled={{@isDisabled}}>\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 </SelectNativeMirror>\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 {{!-- The wrapper, not the trigger, is the popover's width reference:\n in chips mode the trigger is only as wide as the space left over\n inside the field. The wrapper is a real full-width box in both\n modes, so the dropdown matches the field either way. --}}\n <div {{p.anchor}} {{p.measureWidth}} {{on \"click\" this.handleFieldClick}} data-test-id={{if this.showChips \"chips-field\"}} data-part=\"chips-field\" {{!-- These flags are stringified rather than handed the boolean.\n Glimmer renders a true boolean attribute as an empty value, so\n passing isInvalid straight through produced an empty data-invalid\n and the theme selector keyed on the value true never matched. --}} data-has-chips={{if this.showChips \"true\" \"false\"}} data-invalid={{if c.isInvalid \"true\" \"false\"}} data-disabled={{if @isDisabled \"true\" \"false\"}} class={{this.classes.chipsField class=@classes.chipsField hasStartContent=(has-block \"startContent\") hasEndContent=true}}>\n {{#if (and this.showChips this.hasSelection)}}\n {{!-- A block cannot be passed conditionally in Glimmer, so the\n :item block below is always supplied and the branch lives\n inside it: with no :selectedItem block from the consumer, both\n it and the trigger render exactly what they rendered before. --}}\n <SelectedChips @containerRef={{this.chipsContainerRef.setup}} @items={{this.selectedItems}} @classes={{this.classes}} @userClasses={{@classes}} @chipOptions={{this.chipOptions}} @isDisabled={{@isDisabled}} @isRemovable={{this.chipsRemovable}} @onRemove={{this.removeSelectedKey}}>\n <:item as |selected|>\n {{~#if (has-block \"selectedItem\")~}}\n {{~yield selected to=\"selectedItem\"~}}\n {{~else~}}\n {{~selected.label~}}\n {{~/if~}}\n </:item>\n </SelectedChips>\n {{/if}}\n <SelectTrigger @isFilterable={{@isFilterable}} @trigger={{p.trigger}} @triggerRef={{this.triggerRef.setup}} @isDisabled={{@isDisabled}} @showChips={{this.showChips}} @accessibleName={{this.triggerAccessibleName}} @placeholder={{@placeholder}} @hasSelection={{this.hasSelection}} @hasStartContent={{has-block \"startContent\"}} @classes={{this.classes}} @userClasses={{@classes}} @items={{this.selectedItems}} @filterValue={{this.filterFieldValue}} @onFilterInput={{this.onFilterChange}} @onFilterKeydown={{this.handleFilterKeydown}} @onKeydown={{this.handleTriggerKeydown}} @onFocusOut={{this.blurTracker.handleFocusOut}} @hasCustomContent={{has-block \"selectedItem\"}}>\n <:selectedItem as |selected|>\n {{~#if (has-block \"selectedItem\")~}}\n {{~yield selected to=\"selectedItem\"~}}\n {{~else~}}\n {{~selected.label~}}\n {{~/if~}}\n </:selectedItem>\n </SelectTrigger>\n </div>\n <SelectEndContent @classes={{this.classes}} @userClasses={{@classes}} @endContentPointerEvents={{@endContentPointerEvents}} @inputSize={{@inputSize}} @isLoading={{@isLoading}} @isClearable={{this.isClearable}} @onClear={{this.clearSelectedKeys}}>\n {{yield to=\"endContent\"}}\n </SelectEndContent>\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}} @variant={{this.variant}} @disabledKeys={{@disabledKeys}} @color={{this.color}} @isKeyboardEventsEnabled={{true}} @onAction={{this.onAction}} @onSelectionChange={{this.onSelectionChange}} @selectedKeys={{this.selectedKeys}} @selectionMode={{if @selectionMode @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 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 </p.Content>\n </Popover>\n </FormControl>\n</div>", {
611
+ setComponentTemplate(precompileTemplate("<div {{this.updateMultipleSelectValue @selectedKeys}} {{this.updateSingleSelectValue @selectedKey}} {{this.containerRef.setup}} class={{this.classes.base class=@classes.base}} data-component=\"select\" 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 <SelectNativeMirror @items={{@items}} @allowEmpty={{@allowEmpty}} @disabledKeys={{@disabledKeys}} @selectionMode={{@selectionMode}} @selectedKeys={{this.selectedKeys}} @selectedKey={{this.getSelectedKey}} @onSelectionChange={{this.onSelectionChange}} @onSingleSelectionChange={{this.onSingleSelectionChange}} @onItemsChange={{this.onItemsChange}} @placeholder={{@placeholder}} @id={{c.id}} @name={{@name}} @isDisabled={{@isDisabled}}>\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 </SelectNativeMirror>\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 {{!-- The wrapper, not the trigger, is the popover's width reference:\n in chips mode the trigger is only as wide as the space left over\n inside the field. The wrapper is a real full-width box in both\n modes, so the dropdown matches the field either way. --}}\n <div {{p.anchor}} {{p.measureWidth}} {{on \"click\" this.handleFieldClick}} data-test-id={{if this.showChips \"chips-field\"}} data-part=\"chips-field\" {{!-- These flags are stringified rather than handed the boolean.\n Glimmer renders a true boolean attribute as an empty value, so\n passing isInvalid straight through produced an empty data-invalid\n and the theme selector keyed on the value true never matched. --}} data-has-chips={{if this.showChips \"true\" \"false\"}} data-invalid={{if c.isInvalid \"true\" \"false\"}} data-disabled={{if @isDisabled \"true\" \"false\"}} class={{this.classes.chipsField class=@classes.chipsField hasStartContent=(has-block \"startContent\") hasEndContent=true}}>\n {{#if (and this.showChips this.hasSelection)}}\n {{!-- A block cannot be passed conditionally in Glimmer, so the\n :item block below is always supplied and the branch lives\n inside it: with no :selectedItem block from the consumer, both\n it and the trigger render exactly what they rendered before. --}}\n <SelectedChips @containerRef={{this.chipsContainerRef.setup}} @items={{this.selectedItems}} @classes={{this.classes}} @userClasses={{@classes}} @chipOptions={{this.chipOptions}} @isDisabled={{@isDisabled}} @isRemovable={{this.chipsRemovable}} @onRemove={{this.removeSelectedKey}}>\n <:item as |selected|>\n {{~#if (has-block \"selectedItem\")~}}\n {{~yield selected to=\"selectedItem\"~}}\n {{~else~}}\n {{~selected.label~}}\n {{~/if~}}\n </:item>\n </SelectedChips>\n {{/if}}\n <SelectTrigger @isFilterable={{@isFilterable}} @trigger={{p.trigger}} @triggerRef={{this.triggerRef.setup}} @isDisabled={{@isDisabled}} @showChips={{this.showChips}} @accessibleName={{this.triggerAccessibleName}} @placeholder={{@placeholder}} @hasSelection={{this.hasSelection}} @hasStartContent={{has-block \"startContent\"}} @classes={{this.classes}} @userClasses={{@classes}} @items={{this.selectedItems}} @filterValue={{this.filterFieldValue}} @onFilterInput={{this.onFilterChange}} @onFilterKeydown={{this.handleFilterKeydown}} @onKeydown={{this.handleTriggerKeydown}} @onFocusOut={{this.blurTracker.handleFocusOut}} @hasCustomContent={{has-block \"selectedItem\"}}>\n <:selectedItem as |selected|>\n {{~#if (has-block \"selectedItem\")~}}\n {{~yield selected to=\"selectedItem\"~}}\n {{~else~}}\n {{~selected.label~}}\n {{~/if~}}\n </:selectedItem>\n </SelectTrigger>\n </div>\n <SelectEndContent @classes={{this.classes}} @userClasses={{@classes}} @endContentPointerEvents={{@endContentPointerEvents}} @inputSize={{@inputSize}} @isLoading={{@isLoading}} @isClearable={{this.isClearable}} @onClear={{this.clearSelectedKeys}}>\n {{yield to=\"endContent\"}}\n </SelectEndContent>\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}} @selectedKeys={{this.selectedKeys}} @selectionMode={{if @selectionMode @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 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>", {
558
612
  strictMode: true,
559
613
  scope: () => ({
560
614
  FormControl,
@@ -1 +1 @@
1
- {"version":3,"file":"select.js","sources":["../../../../src/components/forms/select/select.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked, cached } from '@glimmer/tracking';\nimport type Owner from '@ember/owner';\nimport { on } from '@ember/modifier';\nimport { modifier } from 'ember-modifier';\nimport { useStyles } from '@frontile/theme';\nimport { renamedArgValue } from '../../../-private/deprecated-args';\n\nimport type { ListItem } from '../native-select';\nimport { Listbox } from '../../collections/listbox';\nimport { VisuallyHidden } from '../../utilities/visually-hidden';\nimport { Popover } from '../../overlays/popover';\nimport { FormControl } from '../form-control';\nimport { ref } from '../../../utils/ref';\nimport { ControlBlurTracker } from '../../../-private/control-blur';\nimport { triggerFormInputEvent } from '../../../utils/forms-utils-index';\nimport { canDeselectKey, keyAndLabelForItem } from '../../../utils/listManager';\nimport { filterAndRankItems } from '../../../utils/filter';\n\nimport { SelectNativeMirror } from './native-mirror';\nimport { SelectTrigger } from './trigger';\nimport { SelectedChips } from './selected-items';\nimport { SelectEndContent } from './end-content';\nimport type {\n DefaultSingleSelectArgs,\n ExplicitSingleSelectArgs,\n ResolvedSelectChipOptions,\n SelectArgs,\n SelectChipOptions,\n SelectSignature,\n SelectedItem,\n SelectedItemBlockArg\n} from './types';\n\n// Import helper function directly instead of using ember-truth-helpers\nconst and = (a: unknown, b: unknown) => Boolean(a) && Boolean(b);\n\n/*\n * Internal `_selectedKey` / `_selectedKeys` are the source of truth for\n * rendering. `@selectedKey(s)` seeds them in the constructor and the\n * `updateSingle/MultipleSelectValue` modifiers keep them synced whenever the\n * arg changes; user interactions update them directly for an immediate UI\n * response, then call `@onSelectionChange` so the parent can update its copy.\n */\n/**\n * A dropdown selection component: a custom listbox in a popover, backed by a\n * visually hidden native `<select>` so the value submits with a form.\n *\n * Selection can be controlled with `@selectedKey` / `@selectedKeys` plus\n * `@onSelectionChange`, or left uncontrolled.\n */\nclass Select<T = unknown> extends Component<SelectSignature<T>> {\n /**\n * Every item registered by the hidden native `<select>`, in item order.\n *\n * The hidden select is deliberately given the *unfiltered* `@items` — it\n * carries the form value, which must not shrink to the filter — so this\n * covers the whole list even while the listbox is filtered down. Chips and\n * the joined text value can therefore be resolved straight from it.\n */\n @tracked nodes: ListItem[] = [];\n\n @tracked isOpen = false;\n /**\n * Internal tracked state for single selection mode.\n * Source of truth for rendering. Synced with @selectedKey via the updateSingleSelectValue modifier.\n */\n @tracked _selectedKey: string | null = null;\n\n /**\n * Internal tracked state for multiple selection mode.\n * Source of truth for rendering. Synced with @selectedKeys via the updateMultipleSelectValue modifier.\n */\n @tracked _selectedKeys: string[] = [];\n\n constructor(owner: Owner, args: SelectArgs<T>) {\n super(owner, args);\n\n if (this.args.selectionMode === 'multiple') {\n this._selectedKeys = this.args.selectedKeys || [];\n } else {\n this._selectedKey =\n (this.args as ExplicitSingleSelectArgs<T> | DefaultSingleSelectArgs<T>)\n .selectedKey || null;\n }\n\n this.validateArgs();\n }\n\n validateArgs() {\n if (this.args.selectionMode === 'multiple') {\n if (\n typeof (this.args as unknown as Record<string, unknown>)[\n 'selectedKey'\n ] !== 'undefined'\n ) {\n console.warn(\n 'WARNING: selectedKey is not supported in multiple selection mode. Use selectedKeys instead.'\n );\n }\n } else {\n if (\n typeof (this.args as unknown as Record<string, unknown>)[\n 'selectedKeys'\n ] !== 'undefined'\n ) {\n console.warn(\n 'WARNING: selectedKeys is deprecated for single selection mode. Use selectedKey instead.'\n );\n }\n }\n }\n\n @tracked filterValue?: string;\n\n containerRef = ref<HTMLDivElement>();\n triggerRef = ref<HTMLInputElement | HTMLButtonElement>();\n chipsContainerRef = ref<HTMLDivElement>();\n\n onSelectionChange = (keys: string[]) => {\n if (this.args.selectionMode === 'multiple') {\n this._selectedKeys = keys;\n if (typeof this.args.onSelectionChange === 'function') {\n (this.args.onSelectionChange as (keys: string[]) => void)(keys);\n }\n } else {\n const singleKey: string | null = keys.length > 0 ? keys[0] || null : null;\n this._selectedKey = singleKey;\n if (typeof this.args.onSelectionChange === 'function') {\n (this.args.onSelectionChange as (key: string | null) => void)(\n singleKey\n );\n }\n }\n\n this.filterValue = undefined;\n triggerFormInputEvent(this.containerRef.current);\n };\n\n /**\n * Like `onSelectionChange`, but for the native `<select>`'s single-value API.\n */\n onSingleSelectionChange = (key: string | null) => {\n this._selectedKey = key;\n if (typeof this.args.onSelectionChange === 'function') {\n (this.args.onSelectionChange as (key: string | null) => void)(key);\n }\n\n this.filterValue = undefined;\n triggerFormInputEvent(this.containerRef.current);\n };\n\n onOpenChange = (isOpen: boolean) => {\n this.isOpen = isOpen;\n };\n\n onFilterChange = (event: Event) => {\n const target = event.target as HTMLInputElement;\n this.filterValue = target.value;\n };\n\n /**\n * Backspace on an empty filter removes the last chip — the familiar tag-input\n * gesture. With text in the filter, Backspace edits the text as usual.\n */\n handleFilterKeydown = (event: KeyboardEvent) => {\n if (event.key !== 'Backspace' || !this.showChips) {\n return;\n }\n const target = event.target as HTMLInputElement;\n if (target.value !== '') {\n return;\n }\n this.removeLastSelectedKey();\n };\n\n /**\n * The non-filterable counterpart of {@link handleFilterKeydown}.\n *\n * Chip close buttons are deliberately outside the tab order (they would\n * otherwise cost a Tab stop each before the combobox is reached), so\n * Backspace/Delete on the trigger is the *only* keyboard route to removing a\n * chip here. There is no text to edit on a button trigger, so both keys act\n * immediately; `preventDefault` keeps Backspace from navigating back.\n */\n handleTriggerKeydown = (event: KeyboardEvent) => {\n if (!this.showChips || this.args.isDisabled) {\n return;\n }\n if (event.key !== 'Backspace' && event.key !== 'Delete') {\n return;\n }\n event.preventDefault();\n this.removeLastSelectedKey();\n };\n\n /**\n * Removes the trailing chip. `removeSelectedKey` applies the same\n * `@allowEmpty` rule the chip close buttons follow, so the last required\n * selection stays put.\n */\n removeLastSelectedKey(): void {\n const items = this.selectedItems;\n const last = items[items.length - 1];\n if (last) {\n this.removeSelectedKey(last.key);\n }\n }\n\n /** Current selection normalized to an array, for template rendering. */\n get selectedKeys(): string[] {\n if (this.args.selectionMode === 'multiple') {\n return this._selectedKeys;\n } else {\n const key = this.getSelectedKey;\n return key ? [key] : [];\n }\n }\n\n get getSelectedKey(): string | null {\n return this._selectedKey;\n }\n\n get blockScroll() {\n if (this.args.blockScroll === false) {\n return false;\n }\n return true;\n }\n\n get disableFocusTrap() {\n if (this.args.disableFocusTrap === false) {\n return false;\n }\n return true;\n }\n\n onAction = (key: string) => {\n if (typeof this.args.onAction === 'function') {\n this.args.onAction(key);\n }\n\n if (\n this.args.closeOnItemSelect !== false &&\n this.args.selectionMode !== 'multiple'\n ) {\n this.isOpen = false;\n }\n\n // Deliberately does not touch `@onBlur`. Selecting is not blurring: this\n // runs on every option click, including the ones that leave the dropdown\n // open in multiple selection mode. Focus loss is reported by\n // `blurTracker` instead, from the trigger's own `focusout`.\n };\n\n /**\n * Reports focus leaving the *whole* control -- the field and its portaled\n * dropdown -- rather than the trigger, which blurs on the way into the\n * dropdown and on every option click. 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 willDestroy(): void {\n super.willDestroy();\n // Nothing may resolve against a destroyed component.\n this.blurTracker.cancel();\n }\n\n /**\n * In chips mode the trigger is only as wide as the room left over beside the\n * chips, so the field's padding -- and the strip under the chevron -- are not\n * part of it, and with a single selection the trigger can be a narrow sliver.\n * Without this, clicking anywhere else in the field would do nothing, while\n * the same click anywhere on a non-chips field opens the dropdown (there the\n * trigger *is* the whole field). Forwards such a click to the trigger,\n * including clicks on a chip's own body, so the whole field is a click\n * target. The one exception is a chip's close button: within the chips\n * container the only `<button>` elements a chip ever renders are its close\n * button (see chip.gts / close-button.gts), so `closest('button')` combined\n * with containment against `chipsContainerRef` identifies it without relying\n * on any test-only attribute. Clicks on the trigger itself are left alone\n * too, since it already handles its own clicks.\n */\n handleFieldClick = (event: MouseEvent): void => {\n if (!this.showChips || this.args.isDisabled) {\n return;\n }\n\n const trigger = this.triggerRef.current;\n const target = event.target;\n\n if (!trigger || !(target instanceof Element)) {\n return;\n }\n\n // The trigger handles its own clicks; this listener also sees them bubble.\n if (trigger === target || trigger.contains(target)) {\n return;\n }\n\n const chipsContainer = this.chipsContainerRef.current;\n\n if (chipsContainer && chipsContainer.contains(target)) {\n const closeButton = target.closest('button');\n if (closeButton && chipsContainer.contains(closeButton)) {\n return;\n }\n }\n\n trigger.focus();\n trigger.click();\n };\n\n /**\n * Wipes the selection from the clear button.\n *\n * Unlike the chips and the listbox options, this deliberately does *not*\n * consult `@allowEmpty`. `@allowEmpty` governs deselecting *an option* --\n * the listbox refuses to let the last one be toggled off, and\n * `chipsRemovable` mirrors that -- whereas `@isClearable` is a separate,\n * explicit affordance the consumer opts into for exactly this purpose. It\n * also defaults to `false`, so honouring it here would render the clear\n * button dead in every default configuration. Documented as an override on\n * `@isClearable` itself; the two must keep saying the same thing.\n *\n * A disabled Select renders no clear button at all (see `isClearable`), so\n * there is nothing to guard here.\n */\n clearSelectedKeys = () => {\n this.onSelectionChange([]);\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: 'Select',\n from: 'appearance',\n to: 'variant',\n id: 'frontile.select.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: 'Select',\n from: 'intent',\n to: 'color',\n id: 'frontile.select.intent'\n }\n );\n }\n\n /**\n * Resolved chip appearance: `@chip` wins, then the Select's own `@color`\n * (or deprecated `@intent`), then chip defaults tuned for sitting inside a\n * field.\n */\n get chipOptions(): ResolvedSelectChipOptions {\n const chip =\n this.args.selectionMode === 'multiple' ? this.args.chip : undefined;\n return {\n // `appearance` is passed through only when the consumer set it. Giving\n // it a default would make Chip's deprecation fire on every chip render.\n variant: chip?.variant ?? (chip?.appearance ? undefined : 'soft'),\n appearance: chip?.appearance,\n // `intent` is passed through only when the consumer (or Select's own\n // deprecated `@intent`) actually set it. Defaulting it would fire\n // Chip's `intent` deprecation on every chip render, for a prop nobody\n // wrote.\n color:\n chip?.color ??\n this.args.color ??\n ((chip?.intent ?? this.args.intent) ? undefined : 'neutral'),\n intent: chip?.intent ?? this.args.intent,\n size: chip?.size ?? 'sm',\n radius: chip?.radius,\n withDot: chip?.withDot ?? false\n };\n }\n\n /**\n * Whether chips may be removed. Mirrors the listbox: with `@allowEmpty`\n * false — the default — the final selection cannot be deselected, so its\n * chip renders without a close button rather than with a dead one.\n */\n get chipsRemovable(): boolean {\n // Asks `canDeselectKey` — the rule the listbox itself applies when an\n // already-selected option is clicked — rather than restating it, so a chip\n // and its option can never disagree about the same removal.\n //\n // Asked of `selectedItems`, the collection the chips render from, so the\n // decision cannot disagree with what is on screen either (a selected key\n // with no remembered item would otherwise be counted but never render a\n // chip at all). Every chip's key is in that collection by construction, so\n // the rule's answer is the same for all of them; it is asked of the last\n // chip, the one Backspace removes.\n const keys = this.selectedItems.map((item) => item.key);\n const lastKey = keys[keys.length - 1];\n\n // With nothing selected there is no chip, so nothing reads this today --\n // but the answer is deliberately `@allowEmpty`, not `false`. That is what\n // this getter has always returned for an empty selection, and keeping it\n // means the answer never depends on whether a chip happens to exist right\n // now. `canDeselectKey` cannot be asked here (it needs a key), so the\n // empty case is answered directly. Do not \"simplify\" this away.\n if (lastKey === undefined) {\n return this.args.allowEmpty === true;\n }\n\n return canDeselectKey(keys, lastKey, this.args.allowEmpty);\n }\n\n /**\n * Removes a single selection from a chip's close button. Routes through\n * `onSelectionChange`, which already syncs internal state, notifies the\n * parent and dispatches the form input event.\n */\n removeSelectedKey = (key: string) => {\n if (this.args.isDisabled || !this.chipsRemovable) {\n return;\n }\n this.onSelectionChange(this.selectedKeys.filter((k) => k !== key));\n };\n\n onItemsChange = (nodes: ListItem[], _: 'add' | 'remove') => {\n // `onItemsChange` runs while a modifier installs, i.e. inside a render\n // pass. Reading a tracked field here and writing it in the same\n // computation would trip Glimmer's read-then-write assertion, so `nodes`\n // is only ever written, never read, in this callback.\n this.nodes = nodes;\n };\n\n didClose = () => {\n this.filterValue = undefined;\n if (typeof this.args.didClose === 'function') {\n this.args.didClose();\n }\n };\n\n /**\n * Whether selections render as chips. Chips are the default presentation for\n * multiple selection mode; `@selectedItemsDisplay=\"text\"` opts back out to the\n * comma-joined string.\n */\n get showChips(): boolean {\n return (\n this.args.selectionMode === 'multiple' &&\n this.args.selectedItemsDisplay !== 'text'\n );\n }\n\n get hasSelection(): boolean {\n return this.selectedKeys.length > 0;\n }\n\n /**\n * The accessible name for the trigger when its own text cannot supply one.\n *\n * Left to itself the trigger names itself from its own text -- the selected\n * label, or the placeholder -- and that is still what happens in the plain\n * case; see the trigger, which only applies this when it has to.\n *\n * Two cases need it:\n *\n * - **Chips mode.** The trigger renders nothing; the chips are its siblings\n * and are read separately. Naming the *control* is both enough and\n * correct here -- appending the selection would have it read twice -- so\n * this returns the bare name.\n * - **A `:selectedItem` block.** The block owns the trigger's content and may\n * render nothing readable at all (an avatar, an icon), which would leave\n * the combobox announced as an unnamed button. The selection is not\n * readable anywhere else in that case, so the name carries it: the control\n * name *and* the selected options' text.\n *\n * The two halves are composed so that the separator only appears when both\n * are there. A selected key with no registered option behind it resolves to\n * no text at all, and `\"Owner, \"` is announced as \"Owner comma\"; and with\n * neither `@label` nor `@placeholder` the only control name available is the\n * hardcoded, unlocalizable `Select options`, so the selected text is left to\n * name the control on its own rather than be prefixed by English.\n */\n get triggerAccessibleName(): string {\n const name = this.args.label || this.args.placeholder;\n\n // Chips mode names the *control* only -- the chips are read separately --\n // and has no better fallback than the literal.\n if (this.showChips) {\n return name || 'Select options';\n }\n\n const selectedText = this.hasSelection ? this.selectedTextValue : '';\n\n if (!name) {\n return selectedText || 'Select options';\n }\n\n return selectedText ? `${name}, ${selectedText}` : name;\n }\n\n /**\n * The selected options in item order (not click order) so chips do not\n * reorder underneath the user as they select.\n *\n * Resolved against `nodes`, which the hidden native `<select>` populates from\n * the unfiltered `@items`, so a chip stays put while a filter hides the item\n * it came from.\n */\n get selectedItems(): SelectedItem[] {\n const keys = this.selectedKeys;\n return this.nodes\n .filter((node) => keys.includes(node.key))\n .map((node) => ({\n key: node.key,\n textValue: node.textValue,\n item: node.item\n }));\n }\n\n /**\n * The same selection `selectedItems` describes, rendered as text.\n *\n * Chips and this string are two presentations of one thing, so they read one\n * projection: walking `nodes` a second time here is how a fix to the\n * selection's contents once landed in the chips and not in the text.\n */\n get selectedTextValue(): string {\n return this.selectedItems.map((item) => item.textValue).join(', ');\n }\n\n get backdrop() {\n if (typeof this.args.backdrop === 'undefined') {\n return 'transparent';\n }\n return this.args.backdrop;\n }\n\n get classes() {\n const { select } = 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 select({\n size: this.args.inputSize,\n hasChips: this.showChips,\n isFilterable: !!this.args.isFilterable\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. A disabled Select never shows it -- the\n * end-content cluster is not pointer-transparent to it and it carries no\n * disabled state of its own, so it would otherwise be a focusable button\n * that clears a field the user is not allowed to change.\n */\n get isClearable() {\n return (\n this.args.isClearable &&\n !this.args.isDisabled &&\n this.selectedKeys &&\n this.selectedKeys.length > 0\n );\n }\n\n get filterFieldValue() {\n if (this.filterValue !== undefined) {\n return this.filterValue;\n }\n // With chips, the selection is already visible beside the input. Echoing\n // the joined text here would fill the box and block typing.\n if (this.showChips) {\n return '';\n }\n return this.selectedTextValue;\n }\n\n get filteredItems() {\n if (this.filterValue === undefined) {\n return this.args.items;\n }\n\n return filterAndRankItems(\n this.args.items,\n this.filterValue || '',\n (item) => keyAndLabelForItem(item).label,\n this.args.filter\n );\n }\n\n get showEmptyContent() {\n return this.filteredItems?.length === 0 && !this.args.hideEmptyContent;\n }\n\n get autoActivateMode(): 'first' | 'selected' {\n if (this.filterValue === undefined || this.filterValue === '') {\n return 'selected';\n }\n return 'first';\n }\n\n /** Syncs internal `_selectedKeys` whenever `@selectedKeys` changes. */\n updateMultipleSelectValue = modifier(\n (_: HTMLDivElement, [selectedKeys]: [string[] | null | undefined]) => {\n if (selectedKeys !== undefined && selectedKeys !== null) {\n this._selectedKeys = selectedKeys;\n } else {\n this._selectedKeys = [];\n }\n }\n );\n\n /** Syncs internal `_selectedKey` whenever `@selectedKey` changes. */\n updateSingleSelectValue = 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.updateMultipleSelectValue @selectedKeys}}\n {{this.updateSingleSelectValue @selectedKey}}\n {{this.containerRef.setup}}\n class={{this.classes.base class=@classes.base}}\n data-component=\"select\"\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 <SelectNativeMirror\n @items={{@items}}\n @allowEmpty={{@allowEmpty}}\n @disabledKeys={{@disabledKeys}}\n @selectionMode={{@selectionMode}}\n @selectedKeys={{this.selectedKeys}}\n @selectedKey={{this.getSelectedKey}}\n @onSelectionChange={{this.onSelectionChange}}\n @onSingleSelectionChange={{this.onSingleSelectionChange}}\n @onItemsChange={{this.onItemsChange}}\n @placeholder={{@placeholder}}\n @id={{c.id}}\n @name={{@name}}\n @isDisabled={{@isDisabled}}\n >\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 </SelectNativeMirror>\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 {{! The wrapper, not the trigger, is the popover's width reference:\n in chips mode the trigger is only as wide as the space left over\n inside the field. The wrapper is a real full-width box in both\n modes, so the dropdown matches the field either way. }}\n <div\n {{p.anchor}}\n {{p.measureWidth}}\n {{on \"click\" this.handleFieldClick}}\n data-test-id={{if this.showChips \"chips-field\"}}\n data-part=\"chips-field\"\n {{! These flags are stringified rather than handed the boolean.\n Glimmer renders a true boolean attribute as an empty value, so\n passing isInvalid straight through produced an empty data-invalid\n and the theme selector keyed on the value true never matched. }}\n data-has-chips={{if this.showChips \"true\" \"false\"}}\n data-invalid={{if c.isInvalid \"true\" \"false\"}}\n data-disabled={{if @isDisabled \"true\" \"false\"}}\n class={{this.classes.chipsField\n class=@classes.chipsField\n hasStartContent=(has-block \"startContent\")\n hasEndContent=true\n }}\n >\n {{#if (and this.showChips this.hasSelection)}}\n {{! A block cannot be passed conditionally in Glimmer, so the\n :item block below is always supplied and the branch lives\n inside it: with no :selectedItem block from the consumer, both\n it and the trigger render exactly what they rendered before. }}\n <SelectedChips\n @containerRef={{this.chipsContainerRef.setup}}\n @items={{this.selectedItems}}\n @classes={{this.classes}}\n @userClasses={{@classes}}\n @chipOptions={{this.chipOptions}}\n @isDisabled={{@isDisabled}}\n @isRemovable={{this.chipsRemovable}}\n @onRemove={{this.removeSelectedKey}}\n >\n <:item as |selected|>\n {{~#if (has-block \"selectedItem\")~}}\n {{~yield selected to=\"selectedItem\"~}}\n {{~else~}}\n {{~selected.label~}}\n {{~/if~}}\n </:item>\n </SelectedChips>\n {{/if}}\n <SelectTrigger\n @isFilterable={{@isFilterable}}\n @trigger={{p.trigger}}\n @triggerRef={{this.triggerRef.setup}}\n @isDisabled={{@isDisabled}}\n @showChips={{this.showChips}}\n @accessibleName={{this.triggerAccessibleName}}\n @placeholder={{@placeholder}}\n @hasSelection={{this.hasSelection}}\n @hasStartContent={{has-block \"startContent\"}}\n @classes={{this.classes}}\n @userClasses={{@classes}}\n @items={{this.selectedItems}}\n @filterValue={{this.filterFieldValue}}\n @onFilterInput={{this.onFilterChange}}\n @onFilterKeydown={{this.handleFilterKeydown}}\n @onKeydown={{this.handleTriggerKeydown}}\n @onFocusOut={{this.blurTracker.handleFocusOut}}\n @hasCustomContent={{has-block \"selectedItem\"}}\n >\n <:selectedItem as |selected|>\n {{~#if (has-block \"selectedItem\")~}}\n {{~yield selected to=\"selectedItem\"~}}\n {{~else~}}\n {{~selected.label~}}\n {{~/if~}}\n </:selectedItem>\n </SelectTrigger>\n </div>\n <SelectEndContent\n @classes={{this.classes}}\n @userClasses={{@classes}}\n @endContentPointerEvents={{@endContentPointerEvents}}\n @inputSize={{@inputSize}}\n @isLoading={{@isLoading}}\n @isClearable={{this.isClearable}}\n @onClear={{this.clearSelectedKeys}}\n >\n {{yield to=\"endContent\"}}\n </SelectEndContent>\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 @selectedKeys={{this.selectedKeys}}\n @selectionMode={{if @selectionMode @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 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\nexport {\n Select,\n type SelectSignature,\n type SelectChipOptions,\n type SelectedItem,\n type SelectedItemBlockArg\n};\nexport default Select;\n"],"names":["and","a","b","Boolean","Select","Component","g","prototype","tracked","i","constructor","owner","args","selectionMode","_selectedKeys","selectedKeys","_selectedKey","selectedKey","validateArgs","console","warn","containerRef","ref","triggerRef","chipsContainerRef","onSelectionChange","keys","singleKey","length","filterValue","undefined","triggerFormInputEvent","current","onSingleSelectionChange","key","onOpenChange","isOpen","onFilterChange","event","target","value","handleFilterKeydown","showChips","removeLastSelectedKey","handleTriggerKeydown","isDisabled","preventDefault","items","selectedItems","last","removeSelectedKey","getSelectedKey","blockScroll","disableFocusTrap","onAction","closeOnItemSelect","blurTracker","ControlBlurTracker","trigger","container","isDestroyed","isDestroying","onBlur","willDestroy","cancel","handleFieldClick","Element","contains","chipsContainer","closeButton","closest","focus","click","clearSelectedKeys","variant","renamedArgValue","appearance","default","outlined","faded","component","from","to","id","n","cached","color","intent","chipOptions","chip","size","radius","withDot","chipsRemovable","map","item","lastKey","allowEmpty","canDeselectKey","filter","k","onItemsChange","nodes","_","didClose","selectedItemsDisplay","hasSelection","triggerAccessibleName","name","label","placeholder","selectedText","selectedTextValue","node","includes","textValue","join","backdrop","classes","select","useStyles","inputSize","hasChips","isFilterable","isClearable","filterFieldValue","filteredItems","filterAndRankItems","keyAndLabelForItem","showEmptyContent","hideEmptyContent","autoActivateMode","updateMultipleSelectValue","modifier","updateSingleSelectValue","setComponentTemplate","precompileTemplate","strictMode","scope","FormControl","Popover","VisuallyHidden","SelectNativeMirror","on","SelectedChips","SelectTrigger","SelectEndContent","Listbox"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAMA,GAAA,GAAMA,CAACC,CAAU,EAAEC,CAAU,KAAKC,OAAA,CAAQF,CAAA,CAAA,IAAME,OAAA,CAAQD,CAAA,CAAA;AAE9D;;;;;;;;;;;;AAaC;AACD,MAAME,MAAA,SAA4BC,UAA0B;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,OAAA,EAAA,CASzDC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAA4B,EAAE;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,MAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,OAAA,CAAA,EAAA,MAAA;AAR/B;;;;;;;AAOC;AAPD,EAAA;IAAAH,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CAUCC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAiB,KAAA;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,OAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,QAAA,CAAA,EAAA,MAAA;AAAA,EAAA;IAAAH,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CAKjBC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAsC,IAAA;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,aAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,cAAA,CAAA,EAAA,MAAA;AAJvC;;;AAGC;AAHD,EAAA;IAAAH,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,eAAA,EAAA,CAUCC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAkC,EAAE;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,cAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,e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Y,GAAGC,WAAA;AACtB,IAAA;AACF,EAAA,CAAA,CAAA;AAGF,EAAA;IAAAsH,oBAAA,CAAAC,kBAAA,CAAA,q/NAAA,EAmOA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,WAAA;QAAAC,OAAA;QAAAC,cAAA;QAAAC,kBAAA;QAAAC,EAAA;QAAA/I,GAAA;QAAAgJ,aAAA;QAAAC,aAAA;QAAAC,gBAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
1
+ {"version":3,"file":"select.js","sources":["../../../../src/components/forms/select/select.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked, cached } from '@glimmer/tracking';\nimport type Owner from '@ember/owner';\nimport { assert } from '@ember/debug';\nimport { on } from '@ember/modifier';\nimport { modifier } from 'ember-modifier';\nimport { useStyles } from '@frontile/theme';\nimport { renamedArgValue } from '../../../-private/deprecated-args';\n\nimport type { ListItem } from '../native-select';\nimport { Listbox } from '../../collections/listbox';\nimport { VisuallyHidden } from '../../utilities/visually-hidden';\nimport { Popover } from '../../overlays/popover';\nimport { FormControl } from '../form-control';\nimport { ref } from '../../../utils/ref';\nimport { ControlBlurTracker } from '../../../-private/control-blur';\nimport { triggerFormInputEvent } from '../../../utils/forms-utils-index';\nimport { canDeselectKey, keyAndLabelForItem } from '../../../utils/listManager';\nimport {\n filterAndRankItems,\n limitItems,\n type DisplayLimitContentArgs\n} from '../../../utils/filter';\n\nimport { SelectNativeMirror } from './native-mirror';\nimport { SelectTrigger } from './trigger';\nimport { SelectedChips } from './selected-items';\nimport { SelectEndContent } from './end-content';\nimport type {\n DefaultSingleSelectArgs,\n ExplicitSingleSelectArgs,\n ResolvedSelectChipOptions,\n SelectArgs,\n SelectChipOptions,\n SelectSignature,\n SelectedItem,\n SelectedItemBlockArg\n} from './types';\n\n// Import helper function directly instead of using ember-truth-helpers\nconst and = (a: unknown, b: unknown) => Boolean(a) && Boolean(b);\n\n/*\n * Internal `_selectedKey` / `_selectedKeys` are the source of truth for\n * rendering. `@selectedKey(s)` seeds them in the constructor and the\n * `updateSingle/MultipleSelectValue` modifiers keep them synced whenever the\n * arg changes; user interactions update them directly for an immediate UI\n * response, then call `@onSelectionChange` so the parent can update its copy.\n */\n/**\n * A dropdown selection component: a custom listbox in a popover, backed by a\n * visually hidden native `<select>` so the value submits with a form.\n *\n * Selection can be controlled with `@selectedKey` / `@selectedKeys` plus\n * `@onSelectionChange`, or left uncontrolled.\n */\nclass Select<T = unknown> extends Component<SelectSignature<T>> {\n /**\n * Every item registered by the hidden native `<select>`, in item order.\n *\n * The hidden select is deliberately given the *unfiltered* `@items` — it\n * carries the form value, which must not shrink to the filter — so this\n * covers the whole list even while the listbox is filtered down. Chips and\n * the joined text value can therefore be resolved straight from it.\n */\n @tracked nodes: ListItem[] = [];\n\n @tracked isOpen = false;\n /**\n * Internal tracked state for single selection mode.\n * Source of truth for rendering. Synced with @selectedKey via the updateSingleSelectValue modifier.\n */\n @tracked _selectedKey: string | null = null;\n\n /**\n * Internal tracked state for multiple selection mode.\n * Source of truth for rendering. Synced with @selectedKeys via the updateMultipleSelectValue modifier.\n */\n @tracked _selectedKeys: string[] = [];\n\n constructor(owner: Owner, args: SelectArgs<T>) {\n super(owner, args);\n\n if (this.args.selectionMode === 'multiple') {\n this._selectedKeys = this.args.selectedKeys || [];\n } else {\n this._selectedKey =\n (this.args as ExplicitSingleSelectArgs<T> | DefaultSingleSelectArgs<T>)\n .selectedKey || null;\n }\n\n this.validateArgs();\n }\n\n validateArgs() {\n if (this.args.selectionMode === 'multiple') {\n if (\n typeof (this.args as unknown as Record<string, unknown>)[\n 'selectedKey'\n ] !== 'undefined'\n ) {\n console.warn(\n 'WARNING: selectedKey is not supported in multiple selection mode. Use selectedKeys instead.'\n );\n }\n } else {\n if (\n typeof (this.args as unknown as Record<string, unknown>)[\n 'selectedKeys'\n ] !== 'undefined'\n ) {\n console.warn(\n 'WARNING: selectedKeys is deprecated for single selection mode. Use selectedKey instead.'\n );\n }\n }\n }\n\n @tracked filterValue?: string;\n\n containerRef = ref<HTMLDivElement>();\n triggerRef = ref<HTMLInputElement | HTMLButtonElement>();\n chipsContainerRef = ref<HTMLDivElement>();\n\n onSelectionChange = (keys: string[]) => {\n if (this.args.selectionMode === 'multiple') {\n this._selectedKeys = keys;\n if (typeof this.args.onSelectionChange === 'function') {\n (this.args.onSelectionChange as (keys: string[]) => void)(keys);\n }\n } else {\n const singleKey: string | null = keys.length > 0 ? keys[0] || null : null;\n this._selectedKey = singleKey;\n if (typeof this.args.onSelectionChange === 'function') {\n (this.args.onSelectionChange as (key: string | null) => void)(\n singleKey\n );\n }\n }\n\n this.filterValue = undefined;\n triggerFormInputEvent(this.containerRef.current);\n };\n\n /**\n * Like `onSelectionChange`, but for the native `<select>`'s single-value API.\n */\n onSingleSelectionChange = (key: string | null) => {\n this._selectedKey = key;\n if (typeof this.args.onSelectionChange === 'function') {\n (this.args.onSelectionChange as (key: string | null) => void)(key);\n }\n\n this.filterValue = undefined;\n triggerFormInputEvent(this.containerRef.current);\n };\n\n onOpenChange = (isOpen: boolean) => {\n this.isOpen = isOpen;\n };\n\n onFilterChange = (event: Event) => {\n const target = event.target as HTMLInputElement;\n this.filterValue = target.value;\n };\n\n /**\n * Enter in the open filter picks the active option (the Listbox handles\n * that), so it must not also submit a wrapping form, the same guard\n * Autocomplete has. Closed, Enter is left to the form.\n *\n * Backspace on an empty filter removes the last chip — the familiar tag-input\n * gesture. With text in the filter, Backspace edits the text as usual.\n */\n handleFilterKeydown = (event: KeyboardEvent) => {\n if (event.key === 'Enter' && this.isOpen) {\n event.preventDefault();\n return;\n }\n if (event.key !== 'Backspace' || !this.showChips) {\n return;\n }\n const target = event.target as HTMLInputElement;\n if (target.value !== '') {\n return;\n }\n this.removeLastSelectedKey();\n };\n\n /**\n * The non-filterable counterpart of {@link handleFilterKeydown}.\n *\n * Chip close buttons are deliberately outside the tab order (they would\n * otherwise cost a Tab stop each before the combobox is reached), so\n * Backspace/Delete on the trigger is the *only* keyboard route to removing a\n * chip here. There is no text to edit on a button trigger, so both keys act\n * immediately; `preventDefault` keeps Backspace from navigating back.\n */\n handleTriggerKeydown = (event: KeyboardEvent) => {\n if (!this.showChips || this.args.isDisabled) {\n return;\n }\n if (event.key !== 'Backspace' && event.key !== 'Delete') {\n return;\n }\n event.preventDefault();\n this.removeLastSelectedKey();\n };\n\n /**\n * Removes the trailing chip. `removeSelectedKey` applies the same\n * `@allowEmpty` rule the chip close buttons follow, so the last required\n * selection stays put.\n */\n removeLastSelectedKey(): void {\n const items = this.selectedItems;\n const last = items[items.length - 1];\n if (last) {\n this.removeSelectedKey(last.key);\n }\n }\n\n /** Current selection normalized to an array, for template rendering. */\n get selectedKeys(): string[] {\n if (this.args.selectionMode === 'multiple') {\n return this._selectedKeys;\n } else {\n const key = this.getSelectedKey;\n return key ? [key] : [];\n }\n }\n\n get getSelectedKey(): string | null {\n return this._selectedKey;\n }\n\n get blockScroll() {\n if (this.args.blockScroll === false) {\n return false;\n }\n return true;\n }\n\n get disableFocusTrap() {\n if (this.args.disableFocusTrap === false) {\n return false;\n }\n return true;\n }\n\n onAction = (key: string) => {\n if (typeof this.args.onAction === 'function') {\n this.args.onAction(key);\n }\n\n if (\n this.args.closeOnItemSelect !== false &&\n this.args.selectionMode !== 'multiple'\n ) {\n this.isOpen = false;\n }\n\n // Deliberately does not touch `@onBlur`. Selecting is not blurring: this\n // runs on every option click, including the ones that leave the dropdown\n // open in multiple selection mode. Focus loss is reported by\n // `blurTracker` instead, from the trigger's own `focusout`.\n };\n\n /**\n * Reports focus leaving the *whole* control -- the field and its portaled\n * dropdown -- rather than the trigger, which blurs on the way into the\n * dropdown and on every option click. 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 willDestroy(): void {\n super.willDestroy();\n // Nothing may resolve against a destroyed component.\n this.blurTracker.cancel();\n }\n\n /**\n * In chips mode the trigger is only as wide as the room left over beside the\n * chips, so the field's padding -- and the strip under the chevron -- are not\n * part of it, and with a single selection the trigger can be a narrow sliver.\n * Without this, clicking anywhere else in the field would do nothing, while\n * the same click anywhere on a non-chips field opens the dropdown (there the\n * trigger *is* the whole field). Forwards such a click to the trigger,\n * including clicks on a chip's own body, so the whole field is a click\n * target. The one exception is a chip's close button: within the chips\n * container the only `<button>` elements a chip ever renders are its close\n * button (see chip.gts / close-button.gts), so `closest('button')` combined\n * with containment against `chipsContainerRef` identifies it without relying\n * on any test-only attribute. Clicks on the trigger itself are left alone\n * too, since it already handles its own clicks.\n */\n handleFieldClick = (event: MouseEvent): void => {\n if (!this.showChips || this.args.isDisabled) {\n return;\n }\n\n const trigger = this.triggerRef.current;\n const target = event.target;\n\n if (!trigger || !(target instanceof Element)) {\n return;\n }\n\n // The trigger handles its own clicks; this listener also sees them bubble.\n if (trigger === target || trigger.contains(target)) {\n return;\n }\n\n const chipsContainer = this.chipsContainerRef.current;\n\n if (chipsContainer && chipsContainer.contains(target)) {\n const closeButton = target.closest('button');\n if (closeButton && chipsContainer.contains(closeButton)) {\n return;\n }\n }\n\n trigger.focus();\n trigger.click();\n };\n\n /**\n * Wipes the selection from the clear button.\n *\n * Unlike the chips and the listbox options, this deliberately does *not*\n * consult `@allowEmpty`. `@allowEmpty` governs deselecting *an option* --\n * the listbox refuses to let the last one be toggled off, and\n * `chipsRemovable` mirrors that -- whereas `@isClearable` is a separate,\n * explicit affordance the consumer opts into for exactly this purpose. It\n * also defaults to `false`, so honouring it here would render the clear\n * button dead in every default configuration. Documented as an override on\n * `@isClearable` itself; the two must keep saying the same thing.\n *\n * A disabled Select renders no clear button at all (see `isClearable`), so\n * there is nothing to guard here.\n */\n clearSelectedKeys = () => {\n this.onSelectionChange([]);\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: 'Select',\n from: 'appearance',\n to: 'variant',\n id: 'frontile.select.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: 'Select',\n from: 'intent',\n to: 'color',\n id: 'frontile.select.intent'\n }\n );\n }\n\n /**\n * Resolved chip appearance: `@chip` wins, then the Select's own `@color`\n * (or deprecated `@intent`), then chip defaults tuned for sitting inside a\n * field.\n */\n get chipOptions(): ResolvedSelectChipOptions {\n const chip =\n this.args.selectionMode === 'multiple' ? this.args.chip : undefined;\n return {\n // `appearance` is passed through only when the consumer set it. Giving\n // it a default would make Chip's deprecation fire on every chip render.\n variant: chip?.variant ?? (chip?.appearance ? undefined : 'soft'),\n appearance: chip?.appearance,\n // `intent` is passed through only when the consumer (or Select's own\n // deprecated `@intent`) actually set it. Defaulting it would fire\n // Chip's `intent` deprecation on every chip render, for a prop nobody\n // wrote.\n color:\n chip?.color ??\n this.args.color ??\n ((chip?.intent ?? this.args.intent) ? undefined : 'neutral'),\n intent: chip?.intent ?? this.args.intent,\n size: chip?.size ?? 'sm',\n radius: chip?.radius,\n withDot: chip?.withDot ?? false\n };\n }\n\n /**\n * Whether chips may be removed. Mirrors the listbox: with `@allowEmpty`\n * false — the default — the final selection cannot be deselected, so its\n * chip renders without a close button rather than with a dead one.\n */\n get chipsRemovable(): boolean {\n // Asks `canDeselectKey` — the rule the listbox itself applies when an\n // already-selected option is clicked — rather than restating it, so a chip\n // and its option can never disagree about the same removal.\n //\n // Asked of `selectedItems`, the collection the chips render from, so the\n // decision cannot disagree with what is on screen either (a selected key\n // with no remembered item would otherwise be counted but never render a\n // chip at all). Every chip's key is in that collection by construction, so\n // the rule's answer is the same for all of them; it is asked of the last\n // chip, the one Backspace removes.\n const keys = this.selectedItems.map((item) => item.key);\n const lastKey = keys[keys.length - 1];\n\n // With nothing selected there is no chip, so nothing reads this today --\n // but the answer is deliberately `@allowEmpty`, not `false`. That is what\n // this getter has always returned for an empty selection, and keeping it\n // means the answer never depends on whether a chip happens to exist right\n // now. `canDeselectKey` cannot be asked here (it needs a key), so the\n // empty case is answered directly. Do not \"simplify\" this away.\n if (lastKey === undefined) {\n return this.args.allowEmpty === true;\n }\n\n return canDeselectKey(keys, lastKey, this.args.allowEmpty);\n }\n\n /**\n * Removes a single selection from a chip's close button. Routes through\n * `onSelectionChange`, which already syncs internal state, notifies the\n * parent and dispatches the form input event.\n */\n removeSelectedKey = (key: string) => {\n if (this.args.isDisabled || !this.chipsRemovable) {\n return;\n }\n this.onSelectionChange(this.selectedKeys.filter((k) => k !== key));\n };\n\n onItemsChange = (nodes: ListItem[], _: 'add' | 'remove') => {\n // `onItemsChange` runs while a modifier installs, i.e. inside a render\n // pass. Reading a tracked field here and writing it in the same\n // computation would trip Glimmer's read-then-write assertion, so `nodes`\n // is only ever written, never read, in this callback.\n this.nodes = nodes;\n };\n\n didClose = () => {\n this.filterValue = undefined;\n if (typeof this.args.didClose === 'function') {\n this.args.didClose();\n }\n };\n\n /**\n * Whether selections render as chips. Chips are the default presentation for\n * multiple selection mode; `@selectedItemsDisplay=\"text\"` opts back out to the\n * comma-joined string.\n */\n get showChips(): boolean {\n return (\n this.args.selectionMode === 'multiple' &&\n this.args.selectedItemsDisplay !== 'text'\n );\n }\n\n get hasSelection(): boolean {\n return this.selectedKeys.length > 0;\n }\n\n /**\n * The accessible name for the trigger when its own text cannot supply one.\n *\n * Left to itself the trigger names itself from its own text -- the selected\n * label, or the placeholder -- and that is still what happens in the plain\n * case; see the trigger, which only applies this when it has to.\n *\n * Two cases need it:\n *\n * - **Chips mode.** The trigger renders nothing; the chips are its siblings\n * and are read separately. Naming the *control* is both enough and\n * correct here -- appending the selection would have it read twice -- so\n * this returns the bare name.\n * - **A `:selectedItem` block.** The block owns the trigger's content and may\n * render nothing readable at all (an avatar, an icon), which would leave\n * the combobox announced as an unnamed button. The selection is not\n * readable anywhere else in that case, so the name carries it: the control\n * name *and* the selected options' text.\n *\n * With nothing selected the placeholder is the trigger's visible text, so\n * it joins the name (`Merchant, All merchants`) rather than being dropped.\n *\n * The two halves are composed so that the separator only appears when both\n * are there. A selected key with no registered option behind it resolves to\n * no text at all, and `\"Owner, \"` is announced as \"Owner comma\"; and with\n * neither `@label` nor `@placeholder` the only control name available is the\n * hardcoded, unlocalizable `Select options`, so the selected text is left to\n * name the control on its own rather than be prefixed by English.\n */\n get triggerAccessibleName(): string {\n const name = this.args.label || this.args.placeholder;\n\n // Nothing selected: the placeholder is the visible text, so it joins the\n // name (WCAG 2.5.3 Label in Name).\n if (!this.hasSelection && this.args.label && this.args.placeholder) {\n return this.args.label === this.args.placeholder\n ? this.args.label\n : `${this.args.label}, ${this.args.placeholder}`;\n }\n\n // Chips mode names the *control* only -- the chips are read separately --\n // and has no better fallback than the literal.\n if (this.showChips) {\n return name || 'Select options';\n }\n\n const selectedText = this.hasSelection ? this.selectedTextValue : '';\n\n if (!name) {\n return selectedText || 'Select options';\n }\n\n return selectedText ? `${name}, ${selectedText}` : name;\n }\n\n /**\n * The selected options in item order (not click order) so chips do not\n * reorder underneath the user as they select.\n *\n * Resolved against `nodes`, which the hidden native `<select>` populates from\n * the unfiltered `@items`, so a chip stays put while a filter hides the item\n * it came from.\n */\n get selectedItems(): SelectedItem[] {\n const keys = this.selectedKeys;\n return this.nodes\n .filter((node) => keys.includes(node.key))\n .map((node) => ({\n key: node.key,\n textValue: node.textValue,\n item: node.item\n }));\n }\n\n /**\n * The same selection `selectedItems` describes, rendered as text.\n *\n * Chips and this string are two presentations of one thing, so they read one\n * projection: walking `nodes` a second time here is how a fix to the\n * selection's contents once landed in the chips and not in the text.\n */\n get selectedTextValue(): string {\n return this.selectedItems.map((item) => item.textValue).join(', ');\n }\n\n get backdrop() {\n if (typeof this.args.backdrop === 'undefined') {\n return 'transparent';\n }\n return this.args.backdrop;\n }\n\n get classes() {\n const { select } = 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 select({\n size: this.args.inputSize,\n hasChips: this.showChips,\n isFilterable: !!this.args.isFilterable\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. A disabled Select never shows it -- the\n * end-content cluster is not pointer-transparent to it and it carries no\n * disabled state of its own, so it would otherwise be a focusable button\n * that clears a field the user is not allowed to change.\n */\n get isClearable() {\n return (\n this.args.isClearable &&\n !this.args.isDisabled &&\n this.selectedKeys &&\n this.selectedKeys.length > 0\n );\n }\n\n get filterFieldValue() {\n if (this.filterValue !== undefined) {\n return this.filterValue;\n }\n // With chips, the selection is already visible beside the input. Echoing\n // the joined text here would fill the box and block typing.\n if (this.showChips) {\n return '';\n }\n return this.selectedTextValue;\n }\n\n // Cached: the listbox, the empty content and the display limit read it, and\n // filtering a long list on every read would repeat the work per keystroke.\n @cached\n get filteredItems() {\n if (this.filterValue === undefined) {\n return this.args.items;\n }\n\n return filterAndRankItems(\n this.args.items,\n this.filterValue || '',\n (item) => keyAndLabelForItem(item).label,\n this.args.filter\n );\n }\n\n get showEmptyContent() {\n return this.filteredItems?.length === 0 && !this.args.hideEmptyContent;\n }\n\n /**\n * The matches the listbox renders: `filteredItems`, capped by\n * `@displayLimit`.\n */\n @cached\n get displayedItems() {\n const { displayLimit, isFilterable } = this.args;\n assert(\n `Select: @displayLimit must be a positive integer, received ${String(displayLimit)}`,\n displayLimit === undefined ||\n (Number.isInteger(displayLimit) && displayLimit > 0)\n );\n assert(\n 'Select: @displayLimit requires @isFilterable, otherwise the options past the limit cannot be reached',\n displayLimit === undefined || isFilterable\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 get autoActivateMode(): 'first' | 'selected' {\n if (this.filterValue === undefined || this.filterValue === '') {\n return 'selected';\n }\n return 'first';\n }\n\n /** Syncs internal `_selectedKeys` whenever `@selectedKeys` changes. */\n updateMultipleSelectValue = modifier(\n (_: HTMLDivElement, [selectedKeys]: [string[] | null | undefined]) => {\n if (selectedKeys !== undefined && selectedKeys !== null) {\n this._selectedKeys = selectedKeys;\n } else {\n this._selectedKeys = [];\n }\n }\n );\n\n /** Syncs internal `_selectedKey` whenever `@selectedKey` changes. */\n updateSingleSelectValue = 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.updateMultipleSelectValue @selectedKeys}}\n {{this.updateSingleSelectValue @selectedKey}}\n {{this.containerRef.setup}}\n class={{this.classes.base class=@classes.base}}\n data-component=\"select\"\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 <SelectNativeMirror\n @items={{@items}}\n @allowEmpty={{@allowEmpty}}\n @disabledKeys={{@disabledKeys}}\n @selectionMode={{@selectionMode}}\n @selectedKeys={{this.selectedKeys}}\n @selectedKey={{this.getSelectedKey}}\n @onSelectionChange={{this.onSelectionChange}}\n @onSingleSelectionChange={{this.onSingleSelectionChange}}\n @onItemsChange={{this.onItemsChange}}\n @placeholder={{@placeholder}}\n @id={{c.id}}\n @name={{@name}}\n @isDisabled={{@isDisabled}}\n >\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 </SelectNativeMirror>\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 {{! The wrapper, not the trigger, is the popover's width reference:\n in chips mode the trigger is only as wide as the space left over\n inside the field. The wrapper is a real full-width box in both\n modes, so the dropdown matches the field either way. }}\n <div\n {{p.anchor}}\n {{p.measureWidth}}\n {{on \"click\" this.handleFieldClick}}\n data-test-id={{if this.showChips \"chips-field\"}}\n data-part=\"chips-field\"\n {{! These flags are stringified rather than handed the boolean.\n Glimmer renders a true boolean attribute as an empty value, so\n passing isInvalid straight through produced an empty data-invalid\n and the theme selector keyed on the value true never matched. }}\n data-has-chips={{if this.showChips \"true\" \"false\"}}\n data-invalid={{if c.isInvalid \"true\" \"false\"}}\n data-disabled={{if @isDisabled \"true\" \"false\"}}\n class={{this.classes.chipsField\n class=@classes.chipsField\n hasStartContent=(has-block \"startContent\")\n hasEndContent=true\n }}\n >\n {{#if (and this.showChips this.hasSelection)}}\n {{! A block cannot be passed conditionally in Glimmer, so the\n :item block below is always supplied and the branch lives\n inside it: with no :selectedItem block from the consumer, both\n it and the trigger render exactly what they rendered before. }}\n <SelectedChips\n @containerRef={{this.chipsContainerRef.setup}}\n @items={{this.selectedItems}}\n @classes={{this.classes}}\n @userClasses={{@classes}}\n @chipOptions={{this.chipOptions}}\n @isDisabled={{@isDisabled}}\n @isRemovable={{this.chipsRemovable}}\n @onRemove={{this.removeSelectedKey}}\n >\n <:item as |selected|>\n {{~#if (has-block \"selectedItem\")~}}\n {{~yield selected to=\"selectedItem\"~}}\n {{~else~}}\n {{~selected.label~}}\n {{~/if~}}\n </:item>\n </SelectedChips>\n {{/if}}\n <SelectTrigger\n @isFilterable={{@isFilterable}}\n @trigger={{p.trigger}}\n @triggerRef={{this.triggerRef.setup}}\n @isDisabled={{@isDisabled}}\n @showChips={{this.showChips}}\n @accessibleName={{this.triggerAccessibleName}}\n @placeholder={{@placeholder}}\n @hasSelection={{this.hasSelection}}\n @hasStartContent={{has-block \"startContent\"}}\n @classes={{this.classes}}\n @userClasses={{@classes}}\n @items={{this.selectedItems}}\n @filterValue={{this.filterFieldValue}}\n @onFilterInput={{this.onFilterChange}}\n @onFilterKeydown={{this.handleFilterKeydown}}\n @onKeydown={{this.handleTriggerKeydown}}\n @onFocusOut={{this.blurTracker.handleFocusOut}}\n @hasCustomContent={{has-block \"selectedItem\"}}\n >\n <:selectedItem as |selected|>\n {{~#if (has-block \"selectedItem\")~}}\n {{~yield selected to=\"selectedItem\"~}}\n {{~else~}}\n {{~selected.label~}}\n {{~/if~}}\n </:selectedItem>\n </SelectTrigger>\n </div>\n <SelectEndContent\n @classes={{this.classes}}\n @userClasses={{@classes}}\n @endContentPointerEvents={{@endContentPointerEvents}}\n @inputSize={{@inputSize}}\n @isLoading={{@isLoading}}\n @isClearable={{this.isClearable}}\n @onClear={{this.clearSelectedKeys}}\n >\n {{yield to=\"endContent\"}}\n </SelectEndContent>\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 @selectedKeys={{this.selectedKeys}}\n @selectionMode={{if @selectionMode @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 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\nexport {\n Select,\n type SelectSignature,\n type SelectChipOptions,\n type SelectedItem,\n type SelectedItemBlockArg,\n type DisplayLimitContentArgs\n};\nexport default Select;\n"],"names":["and","a","b","Boolean","Select","Component","g","prototype","tracked","i","constructor","owner","args","selectionMode","_selectedKeys","selectedKeys","_selectedKey","selectedKey","validateArgs","console","warn","containerRef","ref","triggerRef","chipsContainerRef","onSelectionChange","keys","singleKey","length","filterValue","undefined","triggerFormInputEvent","current","onSingleSelectionChange","key","onOpenChange","isOpen","onFilterChange","event","target","value","handleFilterKeydown","preventDefault","showChips","removeLastSelectedKey","handleTriggerKeydown","isDisabled","items","selectedItems","last","removeSelectedKey","getSelectedKey","blockScroll","disableFocusTrap","onAction","closeOnItemSelect","blurTracker","ControlBlurTracker","trigger","container","isDestroyed","isDestroying","onBlur","willDestroy","cancel","handleFieldClick","Element","contains","chipsContainer","closeButton","closest","focus","click","clearSelectedKeys","variant","renamedArgValue","appearance","default","outlined","faded","component","from","to","id","n","cached","color","intent","chipOptions","chip","size","radius","withDot","chipsRemovable","map","item","lastKey","allowEmpty","canDeselectKey","filter","k","onItemsChange","nodes","_","didClose","selectedItemsDisplay","hasSelection","triggerAccessibleName","name","label","placeholder","selectedText","selectedTextValue","node","includes","textValue","join","backdrop","classes","select","useStyles","inputSize","hasChips","isFilterable","isClearable","filterFieldValue","filteredItems","filterAndRankItems","keyAndLabelForItem","showEmptyContent","hideEmptyContent","displayedItems","displayLimit","assert","String","Number","isInteger","limitItems","displayLimitContent","shown","total","hideDisplayLimitContent","autoActivateMode","updateMultipleSelectValue","modifier","updateSingleSelectValue","setComponentTemplate","precompileTemplate","strictMode","scope","FormControl","Popover","VisuallyHidden","SelectNativeMirror","on","S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AAA,KAAiBe,SAAA,IAAaf,YAAA,KAAiB,IAAA,EAAM;MACvD,IAAI,CAACD,aAAa,GAAGC,YAAA;AACvB,IAAA,CAAA,MAAO;MACL,IAAI,CAACD,aAAa,GAAG,EAAE;AACzB,IAAA;AACF,EAAA,CAAA,CAAA;AAGF;EACAmI,uBAAA,GAA0BD,QAAA,CACxB,CAACzC,CAAG,EAAgB,CAACtF,WAAA,CAAyC,KAAA;IAC5D,IAAIA,gBAAgBa,SAAA,EAAW;MAC7B,IAAI,CAACd,YAAY,GAAGC,WAAA;AACtB,IAAA;AACF,EAAA,CAAA,CAAA;AAGF,EAAA;IAAAiI,oBAAA,CAAAC,kBAAA,CAAA,0hPAAA,EAoPA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,WAAA;QAAAC,OAAA;QAAAC,cAAA;QAAAC,kBAAA;QAAAC,EAAA;QAAA1J,GAAA;QAAA2J,aAAA;QAAAC,aAAA;QAAAC,gBAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
@@ -162,5 +162,36 @@ function filterAndRankItems(items, query, labelFor, filter = defaultFilter) {
162
162
  return matched.map(entry => entry.item);
163
163
  }
164
164
 
165
- export { DEFAULT_MATCH_THRESHOLD, SECONDARY_FIELD_WEIGHT, createFuzzyFilter, defaultFilter, filterAndRankItems };
165
+ /**
166
+ * Cap `items` at the first `limit`, for rendering.
167
+ *
168
+ * A long list is cheap to filter but expensive to render: every option is DOM
169
+ * that has to be built, and rebuilt as the matches change on each keystroke.
170
+ * Capping what is rendered keeps that cost proportional to `limit` instead of
171
+ * to `items`. It is meant for lists the user narrows by typing, where the
172
+ * options past the cap are still reachable through the query.
173
+ *
174
+ * Items `isKept` accepts are rendered even past the cap, in their place in
175
+ * `items`, so a cap never hides the current selection. That is why the result
176
+ * can be longer than `limit`.
177
+ *
178
+ * Without a `limit`, or when `items` already fits, `items` is returned as is.
179
+ *
180
+ * @param items - The items to cap, already filtered and ranked.
181
+ * @param limit - The most items to render.
182
+ * @param isKept - Items to render whatever their position.
183
+ */
184
+ function limitItems(items, limit, isKept = () => false) {
185
+ if (!items || limit === undefined || items.length <= limit) {
186
+ return items;
187
+ }
188
+ return items.filter((item, index) => index < limit || isKept(item));
189
+ }
190
+
191
+ /**
192
+ * Yielded to the `displayLimitContent` block of a `Select` or `Autocomplete`
193
+ * whose `@displayLimit` left options out.
194
+ */
195
+
196
+ export { DEFAULT_MATCH_THRESHOLD, SECONDARY_FIELD_WEIGHT, createFuzzyFilter, defaultFilter, filterAndRankItems, limitItems };
166
197
  //# sourceMappingURL=filter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter.js","sources":["../../src/utils/filter.ts"],"sourcesContent":["import fuzzysort from 'fuzzysort';\n\n/**\n * Score or match an item against the current input text.\n *\n * Return a **number** to rank: higher sorts first and `0` (or any value at or\n * below it) means no match. Return a **boolean** to match without expressing\n * relevance — `true` normalizes to a full match (`1`) and `false` to `0`.\n *\n * Because a boolean filter scores every match identically, and the sort is\n * stable, a purely boolean filter leaves the order of `@items` untouched. That\n * is exactly the behavior filters had before scoring existed.\n */\nexport type FilterFn = (\n itemValue: string,\n inputValue: string\n) => boolean | number;\n\n/**\n * Guarantees a match is distinguishable from no match. `0` is load-bearing in\n * {@link FilterFn}, so a value that must count as a match is never allowed to\n * land exactly on it.\n */\nconst MIN_MATCH_SCORE = Number.EPSILON;\n\n/**\n * Scores at or above this count as a match; anything below is discarded.\n *\n * This is fuzzysort's own default: `fuzzysort.go()` applies `threshold: 0.5`,\n * while `fuzzysort.single()` — which this filter uses, because it scores one\n * item at a time — applies none at all. Taking the threshold on ourselves keeps\n * us at the library's own quality bar rather than below it.\n *\n * It matters because fuzzy matching is *looser* than the `includes()` filter\n * this replaced, and fuzzysort cannot distinguish a useful abbreviation\n * (`btn` -> `Button`) from noise (`sa` -> `Spain`) — both are scattered mid-word\n * subsequences scoring ~0.32-0.36. Without a threshold, a two-letter query\n * against a country list returns two to three times as many rows as before,\n * most of them baffling.\n *\n * A threshold alone is not enough, though: genuine substring matches can score\n * *below* it (`ma` -> `Guatemala` is 0.500, `an` -> `Switzerland` is 0.447), so\n * see the substring floor in {@link createFuzzyFilter}.\n */\nexport const DEFAULT_MATCH_THRESHOLD = 0.5;\n\nexport interface FuzzyFilterOptions {\n /**\n * Minimum score to count as a match, between `0` and `1`. Lower it to trade\n * precision for recall — at `0`, `btn` matches `Button`, and `sa` also\n * matches `Spain`.\n *\n * Substring matches are never dropped regardless of this value.\n *\n * @defaultValue {@link DEFAULT_MATCH_THRESHOLD}\n */\n threshold?: number;\n}\n\n/**\n * Build a relevance filter backed by fuzzysort.\n *\n * The filter is a strict superset of a case-insensitive \"contains\" match: every\n * item `includes()` would have matched still matches, scored at no less than\n * the threshold, so raising the threshold can never make a result disappear\n * that used to be there. On top of that it matches acronyms and initialisms\n * (`bg` -> `ButtonGroup`, `nz` -> `New Zealand`) and orders everything by\n * relevance instead of by source position.\n *\n * @param options - See {@link FuzzyFilterOptions}.\n */\nexport function createFuzzyFilter(\n options: FuzzyFilterOptions = {}\n): (itemValue: string, inputValue: string) => number {\n const threshold = options.threshold ?? DEFAULT_MATCH_THRESHOLD;\n\n // The query is the same for every candidate in a pass, so its lowercased\n // form is memoized rather than rebuilt once per item.\n let lastQuery: string | undefined;\n let lastQueryLower = '';\n\n return function fuzzyFilter(itemValue: string, inputValue: string): number {\n // A blank query matches everything. fuzzysort returns null for a blank or\n // whitespace-only needle, which would otherwise read as \"no match\" and\n // empty the list rather than leaving it alone.\n if (!inputValue.trim()) {\n return 1;\n }\n\n if (!itemValue) {\n return 0;\n }\n\n if (inputValue !== lastQuery) {\n lastQuery = inputValue;\n lastQueryLower = inputValue.toLowerCase();\n }\n\n const score = fuzzysort.single(inputValue, itemValue)?.score ?? 0;\n\n // The substring floor. This is what makes the filter a superset of the old\n // `includes()` default: a substring match is always a match, whatever it\n // scored, so the threshold only ever removes results that are new.\n if (itemValue.toLowerCase().includes(lastQueryLower)) {\n return Math.max(score, threshold, MIN_MATCH_SCORE);\n }\n\n return score >= threshold ? Math.max(score, MIN_MATCH_SCORE) : 0;\n };\n}\n\n/**\n * The default relevance filter: {@link createFuzzyFilter} at\n * {@link DEFAULT_MATCH_THRESHOLD}.\n */\nexport const defaultFilter = createFuzzyFilter();\n\n/**\n * Weight applied to every field after the first.\n *\n * Fields are combined by weighted **max**, never by sum: summing lets three\n * weak field hits outrank one exact hit on the primary field.\n */\nexport const SECONDARY_FIELD_WEIGHT = 0.6;\n\n/**\n * Normalize whatever a {@link FilterFn} returned into a score.\n *\n * `true` is a full match rather than a zero one — without this, a filter that\n * mixed booleans and numbers would sort its `true` results below every numeric\n * match, including the very weakest.\n *\n * `NaN` falls through to `0`, since no comparison with it is true.\n */\nfunction toScore(result: boolean | number): number {\n if (typeof result === 'number') {\n return result > 0 ? result : 0;\n }\n\n return result ? 1 : 0;\n}\n\n/** Weighted max across fields; see {@link SECONDARY_FIELD_WEIGHT}. */\nfunction scoreFields(\n values: string | string[],\n query: string,\n filter: FilterFn\n): number {\n if (typeof values === 'string') {\n return toScore(filter(values, query));\n }\n\n let best = 0;\n\n values.forEach((value, index) => {\n const weight = index === 0 ? 1 : SECONDARY_FIELD_WEIGHT;\n best = Math.max(best, toScore(filter(value, query)) * weight);\n });\n\n return best;\n}\n\n/**\n * Filter `items` by `query`, ordering them by relevance.\n *\n * A blank query returns the items untouched, so a caller can render a default\n * list (recents, suggestions) without special-casing it.\n *\n * The sort is stable, so items scoring equally keep the order they were given.\n * A filter that only ever returns booleans scores every match identically and\n * therefore preserves the order of `items` exactly.\n *\n * @param items - The items to filter.\n * @param query - The user's input text.\n * @param labelFor - Extracts the text to match against. Return an array to\n * search several fields; the first is the primary one and the rest are\n * weighted by {@link SECONDARY_FIELD_WEIGHT}, combined by max.\n * @param filter - Scores one item; defaults to {@link defaultFilter}.\n */\nexport function filterAndRankItems<T>(\n items: T[] | undefined,\n query: string,\n labelFor: (item: T) => string | string[],\n filter: FilterFn = defaultFilter\n): T[] | undefined {\n if (!items || !query.trim()) {\n return items;\n }\n\n const matched: { item: T; score: number }[] = [];\n\n for (const item of items) {\n const score = scoreFields(labelFor(item), query, filter);\n\n if (score > 0) {\n matched.push({ item, score });\n }\n }\n\n matched.sort((a, b) => b.score - a.score);\n\n return matched.map((entry) => entry.item);\n}\n"],"names":["MIN_MATCH_SCORE","Number","EPSILON","DEFAULT_MATCH_THRESHOLD","createFuzzyFilter","options","threshold","lastQuery","lastQueryLower","fuzzyFilter","itemValue","inputValue","trim","toLowerCase","score","fuzzysort","single","includes","Math","max","defaultFilter","SECONDARY_FIELD_WEIGHT","toScore","result","scoreFields","values","query","filter","best","forEach","value","index","weight","filterAndRankItems","items","labelFor","matched","item","push","sort","a","b","map","entry"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA,MAAMA,eAAe,GAAGC,MAAM,CAACC,OAAO;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,uBAAuB,GAAG;AAevC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,iBAAiBA,CAC/BC,OAA2B,GAAG,EAAE,EACmB;AACnD,EAAA,MAAMC,SAAS,GAAGD,OAAO,CAACC,SAAS,IAAIH,uBAAuB;;AAE9D;AACA;AACA,EAAA,IAAII,SAA6B;EACjC,IAAIC,cAAc,GAAG,EAAE;AAEvB,EAAA,OAAO,SAASC,WAAWA,CAACC,SAAiB,EAAEC,UAAkB,EAAU;AACzE;AACA;AACA;AACA,IAAA,IAAI,CAACA,UAAU,CAACC,IAAI,EAAE,EAAE;AACtB,MAAA,OAAO,CAAC;AACV,IAAA;IAEA,IAAI,CAACF,SAAS,EAAE;AACd,MAAA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C,KAAK,EAAEC,KAAK,KAAK;IAC/B,MAAMC,MAAM,GAAGD,KAAK,KAAK,CAAC,GAAG,CAAC,GAAGV,sBAAsB;AACvDO,IAAAA,IAAI,GAAGV,IAAI,CAACC,GAAG,CAACS,IAAI,EAAEN,OAAO,CAACK,MAAM,CAACG,KAAK,EAAEJ,KAAK,CAAC,CAAC,GAAGM,MAAM,CAAC;AAC/D,EAAA,CAAC,CAAC;AAEF,EAAA,OAAOJ,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,kBAAkBA,CAChCC,KAAsB,EACtBR,KAAa,EACbS,QAAwC,EACxCR,MAAgB,GAAGP,aAAa,EACf;EACjB,IAAI,CAACc,KAAK,IAAI,CAACR,KAAK,CAACd,IAAI,EAAE,EAAE;AAC3B,IAAA,OAAOsB,KAAK;AACd,EAAA;EAEA,MAAME,OAAqC,GAAG,EAAE;AAEhD,EAAA,KAAK,MAAMC,IAAI,IAAIH,KAAK,EAAE;AACxB,IAAA,MAAMpB,KAAK,GAAGU,WAAW,CAACW,QAAQ,CAACE,IAAI,CAAC,EAAEX,KAAK,EAAEC,MAAM,CAAC;IAExD,IAAIb,KAAK,GAAG,CAAC,EAAE;MACbsB,OAAO,CAACE,IAAI,CAAC;QAAED,IAAI;AAAEvB,QAAAA;AAAM,OAAC,CAAC;AAC/B,IAAA;AACF,EAAA;AAEAsB,EAAAA,OAAO,CAACG,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKA,CAAC,CAAC3B,KAAK,GAAG0B,CAAC,CAAC1B,KAAK,CAAC;EAEzC,OAAOsB,OAAO,CAACM,GAAG,CAAEC,KAAK,IAAKA,KAAK,CAACN,IAAI,CAAC;AAC3C;;"}
1
+ {"version":3,"file":"filter.js","sources":["../../src/utils/filter.ts"],"sourcesContent":["import fuzzysort from 'fuzzysort';\n\n/**\n * Score or match an item against the current input text.\n *\n * Return a **number** to rank: higher sorts first and `0` (or any value at or\n * below it) means no match. Return a **boolean** to match without expressing\n * relevance — `true` normalizes to a full match (`1`) and `false` to `0`.\n *\n * Because a boolean filter scores every match identically, and the sort is\n * stable, a purely boolean filter leaves the order of `@items` untouched. That\n * is exactly the behavior filters had before scoring existed.\n */\nexport type FilterFn = (\n itemValue: string,\n inputValue: string\n) => boolean | number;\n\n/**\n * Guarantees a match is distinguishable from no match. `0` is load-bearing in\n * {@link FilterFn}, so a value that must count as a match is never allowed to\n * land exactly on it.\n */\nconst MIN_MATCH_SCORE = Number.EPSILON;\n\n/**\n * Scores at or above this count as a match; anything below is discarded.\n *\n * This is fuzzysort's own default: `fuzzysort.go()` applies `threshold: 0.5`,\n * while `fuzzysort.single()` — which this filter uses, because it scores one\n * item at a time — applies none at all. Taking the threshold on ourselves keeps\n * us at the library's own quality bar rather than below it.\n *\n * It matters because fuzzy matching is *looser* than the `includes()` filter\n * this replaced, and fuzzysort cannot distinguish a useful abbreviation\n * (`btn` -> `Button`) from noise (`sa` -> `Spain`) — both are scattered mid-word\n * subsequences scoring ~0.32-0.36. Without a threshold, a two-letter query\n * against a country list returns two to three times as many rows as before,\n * most of them baffling.\n *\n * A threshold alone is not enough, though: genuine substring matches can score\n * *below* it (`ma` -> `Guatemala` is 0.500, `an` -> `Switzerland` is 0.447), so\n * see the substring floor in {@link createFuzzyFilter}.\n */\nexport const DEFAULT_MATCH_THRESHOLD = 0.5;\n\nexport interface FuzzyFilterOptions {\n /**\n * Minimum score to count as a match, between `0` and `1`. Lower it to trade\n * precision for recall — at `0`, `btn` matches `Button`, and `sa` also\n * matches `Spain`.\n *\n * Substring matches are never dropped regardless of this value.\n *\n * @defaultValue {@link DEFAULT_MATCH_THRESHOLD}\n */\n threshold?: number;\n}\n\n/**\n * Build a relevance filter backed by fuzzysort.\n *\n * The filter is a strict superset of a case-insensitive \"contains\" match: every\n * item `includes()` would have matched still matches, scored at no less than\n * the threshold, so raising the threshold can never make a result disappear\n * that used to be there. On top of that it matches acronyms and initialisms\n * (`bg` -> `ButtonGroup`, `nz` -> `New Zealand`) and orders everything by\n * relevance instead of by source position.\n *\n * @param options - See {@link FuzzyFilterOptions}.\n */\nexport function createFuzzyFilter(\n options: FuzzyFilterOptions = {}\n): (itemValue: string, inputValue: string) => number {\n const threshold = options.threshold ?? DEFAULT_MATCH_THRESHOLD;\n\n // The query is the same for every candidate in a pass, so its lowercased\n // form is memoized rather than rebuilt once per item.\n let lastQuery: string | undefined;\n let lastQueryLower = '';\n\n return function fuzzyFilter(itemValue: string, inputValue: string): number {\n // A blank query matches everything. fuzzysort returns null for a blank or\n // whitespace-only needle, which would otherwise read as \"no match\" and\n // empty the list rather than leaving it alone.\n if (!inputValue.trim()) {\n return 1;\n }\n\n if (!itemValue) {\n return 0;\n }\n\n if (inputValue !== lastQuery) {\n lastQuery = inputValue;\n lastQueryLower = inputValue.toLowerCase();\n }\n\n const score = fuzzysort.single(inputValue, itemValue)?.score ?? 0;\n\n // The substring floor. This is what makes the filter a superset of the old\n // `includes()` default: a substring match is always a match, whatever it\n // scored, so the threshold only ever removes results that are new.\n if (itemValue.toLowerCase().includes(lastQueryLower)) {\n return Math.max(score, threshold, MIN_MATCH_SCORE);\n }\n\n return score >= threshold ? Math.max(score, MIN_MATCH_SCORE) : 0;\n };\n}\n\n/**\n * The default relevance filter: {@link createFuzzyFilter} at\n * {@link DEFAULT_MATCH_THRESHOLD}.\n */\nexport const defaultFilter = createFuzzyFilter();\n\n/**\n * Weight applied to every field after the first.\n *\n * Fields are combined by weighted **max**, never by sum: summing lets three\n * weak field hits outrank one exact hit on the primary field.\n */\nexport const SECONDARY_FIELD_WEIGHT = 0.6;\n\n/**\n * Normalize whatever a {@link FilterFn} returned into a score.\n *\n * `true` is a full match rather than a zero one — without this, a filter that\n * mixed booleans and numbers would sort its `true` results below every numeric\n * match, including the very weakest.\n *\n * `NaN` falls through to `0`, since no comparison with it is true.\n */\nfunction toScore(result: boolean | number): number {\n if (typeof result === 'number') {\n return result > 0 ? result : 0;\n }\n\n return result ? 1 : 0;\n}\n\n/** Weighted max across fields; see {@link SECONDARY_FIELD_WEIGHT}. */\nfunction scoreFields(\n values: string | string[],\n query: string,\n filter: FilterFn\n): number {\n if (typeof values === 'string') {\n return toScore(filter(values, query));\n }\n\n let best = 0;\n\n values.forEach((value, index) => {\n const weight = index === 0 ? 1 : SECONDARY_FIELD_WEIGHT;\n best = Math.max(best, toScore(filter(value, query)) * weight);\n });\n\n return best;\n}\n\n/**\n * Filter `items` by `query`, ordering them by relevance.\n *\n * A blank query returns the items untouched, so a caller can render a default\n * list (recents, suggestions) without special-casing it.\n *\n * The sort is stable, so items scoring equally keep the order they were given.\n * A filter that only ever returns booleans scores every match identically and\n * therefore preserves the order of `items` exactly.\n *\n * @param items - The items to filter.\n * @param query - The user's input text.\n * @param labelFor - Extracts the text to match against. Return an array to\n * search several fields; the first is the primary one and the rest are\n * weighted by {@link SECONDARY_FIELD_WEIGHT}, combined by max.\n * @param filter - Scores one item; defaults to {@link defaultFilter}.\n */\nexport function filterAndRankItems<T>(\n items: T[] | undefined,\n query: string,\n labelFor: (item: T) => string | string[],\n filter: FilterFn = defaultFilter\n): T[] | undefined {\n if (!items || !query.trim()) {\n return items;\n }\n\n const matched: { item: T; score: number }[] = [];\n\n for (const item of items) {\n const score = scoreFields(labelFor(item), query, filter);\n\n if (score > 0) {\n matched.push({ item, score });\n }\n }\n\n matched.sort((a, b) => b.score - a.score);\n\n return matched.map((entry) => entry.item);\n}\n\n/**\n * Cap `items` at the first `limit`, for rendering.\n *\n * A long list is cheap to filter but expensive to render: every option is DOM\n * that has to be built, and rebuilt as the matches change on each keystroke.\n * Capping what is rendered keeps that cost proportional to `limit` instead of\n * to `items`. It is meant for lists the user narrows by typing, where the\n * options past the cap are still reachable through the query.\n *\n * Items `isKept` accepts are rendered even past the cap, in their place in\n * `items`, so a cap never hides the current selection. That is why the result\n * can be longer than `limit`.\n *\n * Without a `limit`, or when `items` already fits, `items` is returned as is.\n *\n * @param items - The items to cap, already filtered and ranked.\n * @param limit - The most items to render.\n * @param isKept - Items to render whatever their position.\n */\nexport function limitItems<T>(\n items: T[] | undefined,\n limit: number | undefined,\n isKept: (item: T) => boolean = () => false\n): T[] | undefined {\n if (!items || limit === undefined || items.length <= limit) {\n return items;\n }\n\n return items.filter((item, index) => index < limit || isKept(item));\n}\n\n/**\n * Yielded to the `displayLimitContent` block of a `Select` or `Autocomplete`\n * whose `@displayLimit` left options out.\n */\nexport interface DisplayLimitContentArgs {\n /** How many options are rendered. */\n shown: number;\n /** How many options match, rendered or not. */\n total: number;\n}\n"],"names":["MIN_MATCH_SCORE","Number","EPSILON","DEFAULT_MATCH_THRESHOLD","createFuzzyFilter","options","threshold","lastQuery","lastQueryLower","fuzzyFilter","itemValue","inputValue","trim","toLowerCase","score","fuzzysort","single","includes","Math","max","defaultFilter","SECONDARY_FIELD_WEIGHT","toScore","result","scoreFields","values","query","filter","best","forEach","value","index","weight","filterAndRankItems","items","labelFor","matched","item","push","sort","a","b","map","entry","limitItems","limit","isKept","undefined","length"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA,MAAMA,eAAe,GAAGC,MAAM,CAACC,OAAO;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,uBAAuB,GAAG;AAevC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,iBAAiBA,CAC/BC,OAA2B,GAAG,EAAE,EACmB;AACnD,EAAA,MAAMC,SAAS,GAAGD,OAAO,CAACC,SAAS,IAAIH,uBAAuB;;AAE9D;AACA;AACA,EAAA,IAAII,SAA6B;EACjC,IAAIC,cAAc,GAAG,EAAE;AAEvB,EAAA,OAAO,SAASC,WAAWA,CAACC,SAAiB,EAAEC,UAA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,IAAKA,KAAK,CAACN,IAAI,CAAC;AAC3C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,UAAUA,CACxBV,KAAsB,EACtBW,KAAyB,EACzBC,MAA4B,GAAGA,MAAM,KAAK,EACzB;AACjB,EAAA,IAAI,CAACZ,KAAK,IAAIW,KAAK,KAAKE,SAAS,IAAIb,KAAK,CAACc,MAAM,IAAIH,KAAK,EAAE;AAC1D,IAAA,OAAOX,KAAK;AACd,EAAA;AAEA,EAAA,OAAOA,KAAK,CAACP,MAAM,CAAC,CAACU,IAAI,EAAEN,KAAK,KAAKA,KAAK,GAAGc,KAAK,IAAIC,MAAM,CAACT,IAAI,CAAC,CAAC;AACrE;;AAEA;AACA;AACA;AACA;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frontile",
3
- "version": "0.18.3",
3
+ "version": "0.18.5",
4
4
  "description": "Component Library for Ember Octane apps",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -94,7 +94,7 @@
94
94
  "@embroider/addon-shim": "^1.10.3",
95
95
  "@embroider/macros": "^1.21.1",
96
96
  "@floating-ui/dom": "^1.8.0",
97
- "@frontile/theme": "^0.18.3",
97
+ "@frontile/theme": "^0.18.5",
98
98
  "@glint/template": "^1.9.0",
99
99
  "@universal-ember/table": "^4.0.0",
100
100
  "date-fns": "^4.4.0",
@@ -152,5 +152,5 @@
152
152
  "./services/notifications.js": "./dist/_app_/services/notifications.js"
153
153
  }
154
154
  },
155
- "gitHead": "f705a21182b422660ae92f7afac7e1f0658fff95"
155
+ "gitHead": "96554f29c5bf19003b46cafae0fdf7f20fef72c9"
156
156
  }