frontile 0.18.2 → 0.18.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/components/collections/calendar/calendar.d.ts +7 -1
- package/declarations/components/collections/calendar/calendar.d.ts.map +1 -1
- package/declarations/components/collections/calendar/header.d.ts +2 -0
- package/declarations/components/collections/calendar/header.d.ts.map +1 -1
- package/declarations/components/collections/calendar/types.d.ts +15 -0
- package/declarations/components/collections/calendar/types.d.ts.map +1 -1
- package/declarations/components/collections/calendar/year-grid.d.ts +2 -0
- package/declarations/components/collections/calendar/year-grid.d.ts.map +1 -1
- package/declarations/components/forms/autocomplete.d.ts +49 -1
- package/declarations/components/forms/autocomplete.d.ts.map +1 -1
- package/declarations/components/forms/date-input/date-input.d.ts +2 -1
- package/declarations/components/forms/date-input/date-input.d.ts.map +1 -1
- package/declarations/components/forms/date-input/types.d.ts +15 -1
- package/declarations/components/forms/date-input/types.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/date-picker.d.ts +2 -0
- package/declarations/components/forms/date-picker/date-picker.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/end-content.d.ts +3 -1
- package/declarations/components/forms/date-picker/end-content.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/types.d.ts +26 -2
- package/declarations/components/forms/date-picker/types.d.ts.map +1 -1
- package/declarations/components/forms/select/select.d.ts +28 -1
- package/declarations/components/forms/select/select.d.ts.map +1 -1
- package/declarations/components/forms/select/types.d.ts +35 -1
- package/declarations/components/forms/select/types.d.ts.map +1 -1
- package/declarations/utils/filter.d.ts +30 -0
- package/declarations/utils/filter.d.ts.map +1 -1
- package/dist/components/collections/calendar/calendar.js +13 -1
- package/dist/components/collections/calendar/calendar.js.map +1 -1
- package/dist/components/collections/calendar/header.js +1 -1
- package/dist/components/collections/calendar/header.js.map +1 -1
- package/dist/components/collections/calendar/year-grid.js +1 -1
- package/dist/components/collections/calendar/year-grid.js.map +1 -1
- package/dist/components/forms/autocomplete.js +35 -4
- package/dist/components/forms/autocomplete.js.map +1 -1
- package/dist/components/forms/date-input/date-input.js +10 -1
- package/dist/components/forms/date-input/date-input.js.map +1 -1
- package/dist/components/forms/date-picker/date-picker.js +12 -1
- package/dist/components/forms/date-picker/date-picker.js.map +1 -1
- package/dist/components/forms/date-picker/end-content.js +1 -3
- package/dist/components/forms/date-picker/end-content.js.map +1 -1
- package/dist/components/forms/select/select.js +56 -2
- package/dist/components/forms/select/select.js.map +1 -1
- package/dist/utils/filter.js +32 -1
- package/dist/utils/filter.js.map +1 -1
- package/package.json +3 -3
|
@@ -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,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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","SelectedChips","SelectTrigger","SelectEndContent","Listbox"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAMA,GAAA,GAAMA,CAACC,CAAU,EAAEC,CAAU,KAAKC,OAAA,CAAQF,CAAA,CAAA,IAAME,OAAA,CAAQD,CAAA,CAAA;AAE9D;;;;;;;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AA,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;;"}
|
package/dist/utils/filter.js
CHANGED
|
@@ -162,5 +162,36 @@ function filterAndRankItems(items, query, labelFor, filter = defaultFilter) {
|
|
|
162
162
|
return matched.map(entry => entry.item);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
|
|
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
|
package/dist/utils/filter.js.map
CHANGED
|
@@ -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,CA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ourcesContent":["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,E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1B,KAAK,CAAC;EAEzC,OAAOsB,OAAO,CAACM,GAAG,CAAEC,KAAK,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
|
+
"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.
|
|
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": "
|
|
155
|
+
"gitHead": "96554f29c5bf19003b46cafae0fdf7f20fef72c9"
|
|
156
156
|
}
|