frontile 0.18.3 → 0.18.6

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.
Files changed (54) hide show
  1. package/declarations/-private/reveal-within.d.ts +19 -0
  2. package/declarations/-private/reveal-within.d.ts.map +1 -0
  3. package/declarations/components/collections/calendar/year-grid.d.ts.map +1 -1
  4. package/declarations/components/forms/autocomplete.d.ts +49 -1
  5. package/declarations/components/forms/autocomplete.d.ts.map +1 -1
  6. package/declarations/components/forms/date-input/segment-group.d.ts +2 -1
  7. package/declarations/components/forms/date-input/segment-group.d.ts.map +1 -1
  8. package/declarations/components/forms/date-input/segments.d.ts +3 -1
  9. package/declarations/components/forms/date-input/segments.d.ts.map +1 -1
  10. package/declarations/components/forms/date-picker/date-picker.d.ts +119 -1
  11. package/declarations/components/forms/date-picker/date-picker.d.ts.map +1 -1
  12. package/declarations/components/forms/date-picker/time-columns.d.ts +87 -0
  13. package/declarations/components/forms/date-picker/time-columns.d.ts.map +1 -0
  14. package/declarations/components/forms/date-picker/types.d.ts +28 -0
  15. package/declarations/components/forms/date-picker/types.d.ts.map +1 -1
  16. package/declarations/components/forms/select/native-mirror.d.ts +3 -2
  17. package/declarations/components/forms/select/native-mirror.d.ts.map +1 -1
  18. package/declarations/components/forms/select/select.d.ts +42 -3
  19. package/declarations/components/forms/select/select.d.ts.map +1 -1
  20. package/declarations/components/forms/select/types.d.ts +36 -1
  21. package/declarations/components/forms/select/types.d.ts.map +1 -1
  22. package/declarations/components/overlays/overlay.d.ts +17 -2
  23. package/declarations/components/overlays/overlay.d.ts.map +1 -1
  24. package/declarations/test-support.d.ts.map +1 -1
  25. package/declarations/utils/filter.d.ts +30 -0
  26. package/declarations/utils/filter.d.ts.map +1 -1
  27. package/dist/components/collections/calendar/year-grid.js +1 -30
  28. package/dist/components/collections/calendar/year-grid.js.map +1 -1
  29. package/dist/components/forms/autocomplete.js +35 -4
  30. package/dist/components/forms/autocomplete.js.map +1 -1
  31. package/dist/components/forms/date-input/segment-group.js +1 -1
  32. package/dist/components/forms/date-input/segment-group.js.map +1 -1
  33. package/dist/components/forms/date-input/segments.js +1 -1
  34. package/dist/components/forms/date-input/segments.js.map +1 -1
  35. package/dist/components/forms/date-input.js +1 -1
  36. package/dist/components/forms/date-picker/date-picker.js +57 -6
  37. package/dist/components/forms/date-picker/date-picker.js.map +1 -1
  38. package/dist/components/forms/date-picker/time-columns.js +238 -0
  39. package/dist/components/forms/date-picker/time-columns.js.map +1 -0
  40. package/dist/components/forms/index.js +1 -1
  41. package/dist/components/forms/select/native-mirror.js.map +1 -1
  42. package/dist/components/forms/select/select.js +76 -4
  43. package/dist/components/forms/select/select.js.map +1 -1
  44. package/dist/components/overlays/overlay.js +55 -7
  45. package/dist/components/overlays/overlay.js.map +1 -1
  46. package/dist/forms.js +1 -1
  47. package/dist/index.js +1 -1
  48. package/dist/reveal-within-BcqpOmSI.js +33 -0
  49. package/dist/reveal-within-BcqpOmSI.js.map +1 -0
  50. package/dist/test-support.js +3 -1
  51. package/dist/test-support.js.map +1 -1
  52. package/dist/utils/filter.js +32 -1
  53. package/dist/utils/filter.js.map +1 -1
  54. 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,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,EA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AAGF;EACAwH,uBAAA,GAA0BD,QAAA,CACxB,CAAC9B,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;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 every selected item even while the listbox is filtered down\n * (`mirroredItems` keeps them past `@displayLimit` too). Chips and the\n * 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 * The options the hidden native `<select>` holds: the unfiltered `@items`,\n * capped by `@displayLimit` like the listbox, plus every selected option.\n *\n * The form value is the selected options, so it never needs the others.\n * Holding every item instead costs the same rendering the limit saves in\n * the listbox, and it is paid while the Select is closed: a page with a\n * hundred Selects over a thousand items each built a hundred thousand\n * hidden options. Unfiltered, so a filter can't change what the form sees.\n */\n @cached\n get mirroredItems() {\n const selectedKeys = this.selectedKeys;\n return limitItems(this.args.items, this.args.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={{this.mirroredItems}}\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","mirroredItems","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;;;;;;;;;;;;AAaC;AACD,MAAME,MAAA,SAA4BC,UAA0B;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,OAAA,EAAA,CAUzDC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAA4B,EAAE;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,MAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,OAAA,CAAA,EAAA,MAAA;AAT/B;;;;;;;;AAQC;AARD,EAAA;IAAAH,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CAWCC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAiB,KAAA;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,OAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,QAAA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,gBAAgBa,SAAA,EAAW;MAC7B,IAAI,CAACd,YAAY,GAAGC,WAAA;AACtB,IAAA;AACF,EAAA,CAAA,CAAA;AAGF,EAAA;IAAAkI,oBAAA,CAAAC,kBAAA,CAAA,siPAAA,EAoPA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,WAAA;QAAAC,OAAA;QAAAC,cAAA;QAAAC,kBAAA;QAAAC,EAAA;QAAA3J,GAAA;QAAA4J,aAAA;QAAAC,aAAA;QAAAC,gBAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
@@ -10,14 +10,15 @@ import { createFocusTrap } from 'focus-trap';
10
10
  import onClickOutside from 'ember-click-outside/modifiers/on-click-outside';
11
11
  import { Backdrop } from './backdrop.js';
12
12
  import { hasPainted, afterFirstPaint, shouldDeferMount, shouldSkipEnterTransition, withoutEnterTransition } from './mount-animation.js';
13
- import { Portal, findParentPortal } from './portal.js';
13
+ import { findParentPortal, Portal } from './portal.js';
14
14
  import { macroCondition, isTesting } from '@embroider/macros';
15
15
  import { precompileTemplate } from '@ember/template-compilation';
16
16
  import { setComponentTemplate } from '@ember/component';
17
17
  import { d as decorateFieldV2, i as initializeDeferredDecorator, a as decorateMethodV2 } from '../../runtime--fcdnjmJ-BOdRhmsS.js';
18
18
 
19
19
  /**
20
- * Wraps `createFocusTrap` so activate/deactivate/pause/unpause never throw.
20
+ * Wraps `createFocusTrap` so activate/deactivate/pause/unpause (and
21
+ * updateContainerElements, which re-validates the same way) never throw.
21
22
  *
22
23
  * focus-trap keeps a page-global stack of traps; deactivating one can reach
23
24
  * into the stack to re-validate (`unpause`) whichever trap is now on top. If
@@ -43,7 +44,8 @@ function createTestResilientFocusTrap(...args) {
43
44
  activate: guard('activate'),
44
45
  deactivate: guard('deactivate'),
45
46
  pause: guard('pause'),
46
- unpause: guard('unpause')
47
+ unpause: guard('unpause'),
48
+ updateContainerElements: guard('updateContainerElements')
47
49
  };
48
50
  }
49
51
  /**
@@ -71,6 +73,18 @@ function isWithinNestedPortal(contentElement, target) {
71
73
  }
72
74
  return ownPortal.contains(targetPortal);
73
75
  }
76
+ /**
77
+ * The portals nested directly in the one `contentElement` renders into: where
78
+ * a Select's list, a Popover or a Dropdown opened from inside this overlay
79
+ * renders. Portals nested deeper sit inside these.
80
+ */
81
+ function nestedPortalsOf(contentElement) {
82
+ const ownPortal = findParentPortal(contentElement);
83
+ if (!ownPortal) {
84
+ return [];
85
+ }
86
+ return Array.from(ownPortal.children).filter(child => child instanceof HTMLElement && child.getAttribute('data-portal') === 'true');
87
+ }
74
88
  // Blocking the body scroll mutates global state, so it has to be reference
75
89
  // counted: nested overlays (a Drawer opened from a Modal, a Select inside a
76
90
  // Modal) each lock on open and unlock on close, and only the last one out is
@@ -148,6 +162,8 @@ class Overlay extends Component {
148
162
  // teardown, because the args can change while the overlay is open and an
149
163
  // asymmetric lock/unlock would leak the reference count.
150
164
  didLockBodyScroll = false;
165
+ // Keeps the focus trap's containers in step with the nested portals.
166
+ nestedPortalObserver;
151
167
  cancelPaintWait;
152
168
  constructor(owner, args) {
153
169
  super(owner, args);
@@ -216,6 +232,8 @@ class Overlay extends Component {
216
232
  }
217
233
  return () => {
218
234
  this.contentElement = undefined;
235
+ this.nestedPortalObserver?.disconnect();
236
+ this.nestedPortalObserver = undefined;
219
237
  if (this.args.isOpen !== true) {
220
238
  this.hasClosedOnce = true;
221
239
  }
@@ -292,12 +310,42 @@ class Overlay extends Component {
292
310
  ...this.args.focusTrapOptions
293
311
  };
294
312
  }
295
- get createFocusTrap() {
313
+ /**
314
+ * The trap covers the content and the portals nested in this overlay's
315
+ * portal, the same ones `handleOutsideClick` doesn't count as outside.
316
+ *
317
+ * With the content alone as its container, the trap took a press in a
318
+ * nested portal for an outside click and deactivated: from then on Tab
319
+ * walked out of the Drawer. A touch on a Select's list also sent the focus
320
+ * back to where it was when the trap activated, out of the Select's
321
+ * filter. As containers, nested overlays are also part of the Tab cycle,
322
+ * after the content.
323
+ *
324
+ * Nested overlays open and close while this one stays open, so a
325
+ * MutationObserver on the portal keeps the containers current.
326
+ */
327
+ createFocusTrap = (...[element, options]) => {
328
+ let create = createFocusTrap;
296
329
  if (macroCondition(isTesting())) {
297
- return createTestResilientFocusTrap;
330
+ create = createTestResilientFocusTrap;
298
331
  }
299
- return undefined;
300
- }
332
+ // The element the `focusTrap` modifier is on: the content. We pass it no
333
+ // `additionalElements`, so it's never a list.
334
+ const content = element;
335
+ const containers = () => [content, ...nestedPortalsOf(content)];
336
+ const trap = create(containers(), options);
337
+ const ownPortal = findParentPortal(content);
338
+ if (ownPortal) {
339
+ this.nestedPortalObserver?.disconnect();
340
+ this.nestedPortalObserver = new MutationObserver(() => {
341
+ trap.updateContainerElements(containers());
342
+ });
343
+ this.nestedPortalObserver.observe(ownPortal, {
344
+ childList: true
345
+ });
346
+ }
347
+ return trap;
348
+ };
301
349
  get classes() {
302
350
  const {
303
351
  overlay
@@ -1 +1 @@
1
- {"version":3,"file":"overlay.js","sources":["../../../src/components/overlays/overlay.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached, tracked } from '@glimmer/tracking';\nimport { later } from '@ember/runloop';\nimport { on } from '@ember/modifier';\nimport { cssTransition } from 'ember-css-transitions';\nimport { useStyles } from '@frontile/theme';\nimport { modifier } from 'ember-modifier';\nimport { focusTrap, type FocusTrapModifierSignature } from 'ember-focus-trap';\nimport { createFocusTrap, type FocusTrap } from 'focus-trap';\nimport onClickOutside from 'ember-click-outside/modifiers/on-click-outside';\nimport { Backdrop, type BackdropSignature } from './backdrop';\nimport {\n afterFirstPaint,\n hasPainted,\n shouldDeferMount,\n shouldSkipEnterTransition,\n withoutEnterTransition\n} from './mount-animation';\nimport { Portal, findParentPortal, type PortalSignature } from './portal';\nimport type Owner from '@ember/owner';\nimport type { ModifierLike } from '@glint/template';\nimport type { CssTransitionSignature } from 'ember-css-transitions/modifiers/css-transition';\nimport { isTesting, macroCondition } from '@embroider/macros';\n\ntype FocusTrapOptions = NonNullable<\n FocusTrapModifierSignature['Args']['Named']['focusTrapOptions']\n>;\n\ntype FocusTrapLifecycleMethod = 'activate' | 'deactivate' | 'pause' | 'unpause';\n\n/**\n * Wraps `createFocusTrap` so activate/deactivate/pause/unpause never throw.\n *\n * focus-trap keeps a page-global stack of traps; deactivating one can reach\n * into the stack to re-validate (`unpause`) whichever trap is now on top. If\n * that other trap's container was already torn down -- which this test suite\n * does constantly, mounting and unmounting hundreds of trapped overlays in a\n * single browser session -- focus-trap throws \"must have at least one\n * container with at least one tabbable node\", per its own docs' \"Help\"\n * section: this is an expected hazard of trapped elements that \"appear and\n * disappear dynamically\", not a sign of a real focus bug. Test-only: real\n * usage never hits the same rapid-fire mount/unmount churn.\n */\nfunction createTestResilientFocusTrap(\n ...args: Parameters<typeof createFocusTrap>\n): FocusTrap {\n const trap = createFocusTrap(...args);\n\n const guard =\n (method: FocusTrapLifecycleMethod) =>\n (...methodArgs: unknown[]): FocusTrap => {\n try {\n return (trap[method] as (...a: unknown[]) => FocusTrap)(...methodArgs);\n } catch {\n return trap;\n }\n };\n\n return {\n ...trap,\n activate: guard('activate'),\n deactivate: guard('deactivate'),\n pause: guard('pause'),\n unpause: guard('unpause')\n };\n}\n\n/**\n * Whether `target` sits inside a portal nested within this overlay's own\n * portal.\n *\n * The question a click handler needs answered is about *this* click, not about\n * the mere existence of a nested portal. Asking only \"is a nested portal\n * mounted?\" made a parent overlay ignore every outside click for as long as a\n * child was open -- so with a Dropdown submenu (or a Select inside a Modal)\n * open, clicking the page did not close anything.\n *\n * A portal that is not a descendant of this overlay's portal -- one given an\n * explicit `@target`, or opted out of `appendToParentPortal` -- is not nested,\n * and a click in it is a genuine outside click.\n */\nfunction isWithinNestedPortal(\n contentElement: HTMLElement,\n target: EventTarget | null\n): boolean {\n const ownPortal = findParentPortal(contentElement);\n if (!ownPortal || !(target instanceof Element)) {\n return false;\n }\n\n const targetPortal = target.closest('[data-portal=\"true\"]');\n if (!targetPortal || targetPortal === ownPortal) {\n return false;\n }\n\n return ownPortal.contains(targetPortal);\n}\n\n// Blocking the body scroll mutates global state, so it has to be reference\n// counted: nested overlays (a Drawer opened from a Modal, a Select inside a\n// Modal) each lock on open and unlock on close, and only the last one out is\n// allowed to restore the page. We also remember the inline value the app had\n// before the first lock, so restoring does not silently wipe an app-level\n// `body { overflow: ... }`.\nlet bodyScrollLockCount = 0;\nlet previousBodyOverflow = '';\n\nfunction lockBodyScroll(): void {\n if (bodyScrollLockCount === 0) {\n previousBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n }\n bodyScrollLockCount++;\n}\n\nfunction unlockBodyScroll(): void {\n if (bodyScrollLockCount === 0) {\n return;\n }\n\n bodyScrollLockCount--;\n\n if (bodyScrollLockCount === 0) {\n document.body.style.overflow = previousBodyOverflow;\n previousBodyOverflow = '';\n }\n}\n\nfunction hasWormholeOrAlertParentElement(el: HTMLElement) {\n let parent = el.parentElement;\n while (parent) {\n if (\n parent.id === 'ember-basic-dropdown-wormhole' ||\n parent.role === 'alert'\n ) {\n return true;\n }\n parent = parent.parentElement;\n }\n return false;\n}\n\ninterface Args extends Pick<\n PortalSignature['Args'],\n 'renderInPlace' | 'target'\n> {\n /**\n * Duration of the animation\n *\n * @defaultValue 200\n */\n transitionDuration?: number;\n\n /**\n * How the area behind the overlay is rendered: `none` omits the backdrop\n * entirely, `transparent` keeps it clickable but invisible, `faded` dims the\n * page, and `blur` blurs it.\n */\n backdrop?: BackdropSignature['Args']['type'];\n\n /**\n * Transition classes for the backdrop, overriding the defaults used when it\n * fades in and out.\n */\n backdropTransition?: BackdropSignature['Args']['transition'];\n\n /**\n * Disable css transitions\n *\n * @defaultValue false\n */\n disableTransitions?: boolean;\n\n /**\n * Whether an overlay that is *already open the first time it renders* --\n * deep-linked open, or restored by a page refresh -- animates in.\n *\n * When true (the default) the overlay waits for the browser's first paint\n * before mounting, so the animation plays against a page the user has\n * already seen. Set it to false for an already-open overlay that should\n * simply be there, with no reveal. An overlay opened later by interaction\n * animates either way, and so does closing.\n *\n * @defaultValue true\n */\n animateOnMount?: boolean;\n\n /**\n * Whether the focus trap is disabled or not\n *\n * @defaultValue false\n */\n disableFocusTrap?: boolean;\n\n /**\n * Focus trap options\n *\n * @defaultValue { clickOutsideDeactivates: true, allowOutsideClick: true }\n */\n focusTrapOptions?: FocusTrapOptions;\n\n /**\n * Whether it is open or not\n */\n isOpen: boolean;\n\n /**\n * A function that will be called when closed\n */\n onClose?: () => void;\n\n /**\n * A function that will be called when closing is finished executing, this\n * includes waiting for animations/transitions to finish.\n */\n didClose?: () => void;\n\n /**\n * A function that will be called when opened\n */\n onOpen?: () => void;\n\n /**\n * Whether to close when the area outside (the backdrop) is clicked\n *\n * @defaultValue true\n */\n closeOnOutsideClick?: boolean;\n\n /**\n * Whether to close when the overlay element is clicked, used for modal and drawer components.\n * This is set to true by default to allow \"outside click\" functionality to work properly.\n * Most overlay content is wrapped with an inner element, preventing accidental closure.\n *\n * @defaultValue true\n */\n closeOnOverlayElementClick?: boolean;\n\n /**\n * Whether to close when the escape key is pressed\n *\n * @defaultValue true\n */\n closeOnEscapeKey?: boolean;\n\n /**\n * Transition options\n *\n * @defaultValue {name:'overlay-transition--fade'}\n */\n transition?: CssTransitionSignature['Args']['Named'];\n\n /**\n * Opt out of the flex layout applied to the content element, for overlays\n * that need to lay their content out themselves.\n *\n * @defaultValue false\n */\n disableFlexContent?: boolean;\n\n /**\n * An extra modifier applied to the content element, for behavior the overlay\n * doesn't provide itself.\n */\n customContentModifier?: ModifierLike<{ Element: HTMLElement }>;\n\n /**\n * Custom class name for the content element, merged with the default ones\n * using Tailwind Merge.\n */\n class?: string;\n /**\n * @defaultValue false\n */\n preventFocusRestore?: boolean;\n\n /**\n * When focusTrap is disabled, by default Oberlay will be auto focused. This option prevents that.\n * @defaultValue false\n */\n preventAutoFocus?: boolean;\n\n /**\n * @defaultValue true\n */\n blockScroll?: boolean;\n}\n\ninterface OverlaySignature {\n Args: Args;\n Element: HTMLDivElement;\n Blocks: { default: [] };\n}\n\nclass Overlay extends Component<OverlaySignature> {\n @tracked keepOpen = false;\n\n // Whether the browser has painted since this overlay was created. Only ever\n // consulted while the mount is being deferred; see `mount-animation.ts`.\n @tracked hasWaitedForPaint = false;\n\n // Whether `@isOpen` was already true on the very first render. Captured once\n // rather than derived, because the whole question is about what the args\n // looked like at mount.\n isOpenAtMount = this.args.isOpen === true;\n\n // Whether the page had already painted when this overlay was created, which\n // only an overlay that mounts open ever has to know -- and every Dropdown,\n // Select and Tooltip in the app builds an Overlay too.\n hadPaintedAtMount = this.isOpenAtMount ? hasPainted() : false;\n\n // Latched when the first open closes, so a *reopen* of the same overlay\n // animates normally. Only a genuine close counts: the content element is\n // also torn down and rebuilt when the portal destination changes under an\n // open overlay, and flipping this then would swap the enter class names out\n // from under the running modifier, which cleans up using whatever names it\n // holds when the transition ends.\n @tracked hasClosedOnce = false;\n\n contentElement: HTMLElement | undefined;\n focusedElement: Element | null | undefined;\n mouseDownContentElement: EventTarget | null = null;\n\n // Whether *this* overlay is holding a reference on the body scroll lock. We\n // record the decision made when opening instead of re-deriving it at\n // teardown, because the args can change while the overlay is open and an\n // asymmetric lock/unlock would leak the reference count.\n didLockBodyScroll = false;\n\n cancelPaintWait: (() => void) | undefined;\n\n constructor(owner: Owner, args: Args) {\n super(owner, args);\n\n if (!this.shouldDeferMount) {\n return;\n }\n\n this.cancelPaintWait = afterFirstPaint(() => {\n if (!this.isDestroying && !this.isDestroyed) {\n this.hasWaitedForPaint = true;\n }\n });\n }\n\n willDestroy(): void {\n super.willDestroy();\n this.cancelPaintWait?.();\n }\n\n handleClose(): void {\n if (this.args.isOpen && typeof this.args.onClose === 'function') {\n this.args.onClose();\n }\n }\n\n handleContentClick = (event: MouseEvent): void => {\n if (\n this.args.closeOnOutsideClick !== false &&\n this.args.closeOnOverlayElementClick !== false &&\n event.target === this.contentElement &&\n this.mouseDownContentElement == this.contentElement &&\n !isWithinNestedPortal(this.contentElement, event.target) &&\n !hasWormholeOrAlertParentElement(event.target as HTMLElement)\n ) {\n this.handleClose();\n }\n this.mouseDownContentElement = null;\n };\n\n handleOutsideClick = (e: Event): void => {\n if (\n this.args.closeOnOutsideClick !== false &&\n this.contentElement &&\n !isWithinNestedPortal(this.contentElement, e.target) &&\n !hasWormholeOrAlertParentElement(e.target as HTMLElement)\n ) {\n this.handleClose();\n e.preventDefault();\n }\n };\n\n handleContentMouseDown = (event: MouseEvent): void => {\n if (this.args.closeOnOverlayElementClick !== false) {\n this.mouseDownContentElement = event.target;\n }\n };\n\n handleKeyDown = (event: KeyboardEvent): void => {\n if (event.key === 'Escape' && this.args.closeOnEscapeKey !== false) {\n this.handleClose();\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n };\n\n setupContent = modifier((el: HTMLDivElement) => {\n let transitionDuration = this.args.transitionDuration || 200;\n if (!this.isAnimationEnabled) {\n transitionDuration = 0;\n }\n later(() => {\n if (this.isDestroyed) return;\n if (this.args.disableFocusTrap !== true) return;\n if (this.args.preventAutoFocus === true) return;\n el.focus();\n }, transitionDuration);\n\n this.contentElement = el;\n this.keepOpen = true;\n this.focusedElement = document.activeElement;\n\n if (this.args.renderInPlace !== true && this.args.blockScroll !== false) {\n this.didLockBodyScroll = true;\n lockBodyScroll();\n }\n\n if (typeof this.args.onOpen === 'function') {\n this.args.onOpen();\n }\n return () => {\n this.contentElement = undefined;\n\n if (this.args.isOpen !== true) {\n this.hasClosedOnce = true;\n }\n\n if (this.didLockBodyScroll) {\n this.didLockBodyScroll = false;\n unlockBodyScroll();\n }\n\n const { didClose } = this.args;\n later(() => {\n if (!this.isDestroyed) this.keepOpen = false;\n if (typeof didClose === 'function' && !this.isDestroyed) {\n didClose();\n }\n\n // restore focus\n if (\n !this.args.preventFocusRestore &&\n this.focusedElement &&\n (this.focusedElement as HTMLElement).tabIndex > -1 &&\n typeof (this.focusedElement as HTMLElement).focus !== 'undefined'\n ) {\n (this.focusedElement as HTMLElement).focus();\n }\n }, transitionDuration);\n };\n });\n\n @cached\n get mountAnimationState() {\n return {\n isFirstOpen: this.isOpenAtMount && !this.hasClosedOnce,\n animationsEnabled: this.isAnimationEnabled,\n animateOnMount: this.args.animateOnMount,\n canWaitForFrame: typeof requestAnimationFrame === 'function',\n hasPainted: this.hadPaintedAtMount\n };\n }\n\n get shouldDeferMount(): boolean {\n return shouldDeferMount(this.mountAnimationState);\n }\n\n get skipEnterTransition(): boolean {\n return shouldSkipEnterTransition(this.mountAnimationState);\n }\n\n get isVisible(): boolean {\n if (this.shouldDeferMount && !this.hasWaitedForPaint) {\n return false;\n }\n\n return this.args.isOpen || this.keepOpen;\n }\n\n get backdrop(): BackdropSignature['Args']['type'] {\n if (!this.args.isOpen) {\n return 'none';\n }\n return this.args.backdrop || 'faded';\n }\n\n get isAnimationEnabled(): boolean {\n if (macroCondition(isTesting())) {\n return false;\n }\n return !(this.args.disableTransitions === true);\n }\n\n /**\n * Consumer options are merged over the defaults rather than replacing them.\n *\n * Swapping the object wholesale made setting any single option -- a\n * `setReturnFocus`, an `initialFocus` -- silently drop\n * `clickOutsideDeactivates` and `allowOutsideClick` with it, at which point\n * the trap swallows outside clicks and the overlay can only be dismissed\n * with Escape. Nothing warns, and the cause is nowhere near the symptom.\n * A consumer that genuinely wants the trap to hold outside clicks can still\n * say so by passing those two as `false`.\n */\n get focusTrapOptions(): FocusTrapOptions {\n return {\n clickOutsideDeactivates: true,\n allowOutsideClick: true,\n ...this.args.focusTrapOptions\n };\n }\n\n get createFocusTrap(): typeof createFocusTrap | undefined {\n if (macroCondition(isTesting())) {\n return createTestResilientFocusTrap;\n }\n return undefined;\n }\n\n get classes() {\n const { overlay } = useStyles();\n\n return overlay({\n class: this.args.class,\n inPlace: this.args.renderInPlace,\n enableFlexContent: !(this.args.disableFlexContent === true)\n });\n }\n\n get customContentModifier() {\n if (this.args.customContentModifier) {\n return this.args.customContentModifier;\n }\n\n return modifier(() => {});\n }\n\n // Applied to both the content and the backdrop, so they never disagree about\n // whether this mount animates.\n maybeWithoutEnter<T extends object>(options: T): T {\n return this.skipEnterTransition ? withoutEnterTransition(options) : options;\n }\n\n get backdropTransition() {\n return this.maybeWithoutEnter(\n this.args.backdropTransition || { isEnabled: this.isAnimationEnabled }\n );\n }\n\n get transition() {\n let options: BackdropSignature['Args']['transition'] = {\n name: 'overlay-transition--fade',\n isEnabled: this.isAnimationEnabled\n };\n\n if (typeof this.args.transition === 'object') {\n options = { ...options, ...this.args.transition };\n }\n\n return this.maybeWithoutEnter(options);\n }\n\n <template>\n {{! template-lint-disable no-invalid-interactive }}\n {{! template-lint-disable no-pointer-down-event-binding }}\n\n {{#if this.isVisible}}\n <Portal @renderInPlace={{@renderInPlace}} @target={{@target}}>\n <Backdrop\n @type={{this.backdrop}}\n @inPlace={{@renderInPlace}}\n @transition={{this.backdropTransition}}\n />\n\n {{#if @isOpen}}\n <div\n {{this.setupContent}}\n {{on \"click\" this.handleContentClick}}\n {{on \"keydown\" this.handleKeyDown}}\n {{on \"mousedown\" this.handleContentMouseDown}}\n {{cssTransition\n didTransitionIn=this.transition.didTransitionIn\n didTransitionOut=this.transition.didTransitionOut\n enterClass=this.transition.enterClass\n enterActiveClass=this.transition.enterActiveClass\n enterToClass=this.transition.enterToClass\n isEnabled=this.transition.isEnabled\n leaveClass=this.transition.leaveClass\n leaveActiveClass=this.transition.leaveActiveClass\n leaveToClass=this.transition.leaveToClass\n name=this.transition.name\n parentSelector=this.transition.parentSelector\n }}\n {{onClickOutside this.handleOutsideClick capture=true}}\n {{focusTrap\n isActive=(if @disableFocusTrap false @isOpen)\n focusTrapOptions=this.focusTrapOptions\n _createFocusTrap=this.createFocusTrap\n }}\n class={{this.classes}}\n {{! Keep this custom modifer by last}}\n {{this.customContentModifier}}\n data-component=\"overlay\"\n data-part=\"base\"\n tabindex=\"0\"\n ...attributes\n >\n {{yield}}\n </div>\n {{/if}}\n </Portal>\n {{/if}}\n </template>\n}\n\nexport { Overlay, type OverlaySignature };\nexport default Overlay;\n"],"names":["createTestResilientFocusTrap","args","trap","createFocusTrap","guard","method","methodArgs","activate","deactivate","pause","unpause","isWithinNestedPortal","contentElement","target","ownPortal","findParentPortal","Element","targetPortal","closest","contains","bodyScrollLockCount","previousBodyOverflow","lockBodyScroll","document","body","style","overflow","unlockBodyScroll","hasWormholeOrAlertParentElement","el","parent","parentElement","id","role","Overlay","Component","g","prototype","tracked","i","isOpenAtMount","isOpen","hadPaintedAtMount","hasPainted","focusedElement","mouseDownContentElement","didLockBodyScroll","cancelPaintWait","constructor","owner","shouldDeferMount","afterFirstPaint","isDestroying","isDestroyed","hasWaitedForPaint","willDestroy","handleClose","onClose","handleContentClick","event","closeOnOutsideClick","closeOnOverlayElementClick","handleOutsideClick","e","preventDefault","handleContentMouseDown","handleKeyDown","key","closeOnEscapeKey","stopImmediatePropagation","setupContent","modifier","transitionDuration","isAnimationEnabled","later","disableFocusTrap","preventAutoFocus","focus","keepOpen","activeElement","renderInPlace","blockScroll","onOpen","undefined","hasClosedOnce","didClose","preventFocusRestore","tabIndex","mountAnimationState","isFirstOpen","animationsEnabled","animateOnMount","canWaitForFrame","requestAnimationFrame","n","cached","skipEnterTransition","shouldSkipEnterTransition","isVisible","backdrop","macroCondition","isTesting","disableTransitions","focusTrapOptions","clickOutsideDeactivates","allowOutsideClick","classes","overlay","useStyles","class","inPlace","enableFlexContent","disableFlexContent","customContentModifier","maybeWithoutEnter","options","withoutEnterTransition","backdropTransition","isEnabled","transition","name","setComponentTemplate","precompileTemplate","strictMode","scope","Portal","Backdrop","on","cssTransition","onClickOutside","focusTrap"],"mappings":";;;;;;;;;;;;;;;;;;AA8BA;;;;;;;;;;;;AAYC;AACD,SAASA,4BAAAA,CACP,GAAGC,IAAwC,EAC1C;AACD,EAAA,MAAMC,OAAOC,eAAA,CAAA,GAAmBF,IAAA,CAAA;AAEhC,EAAA,MAAMG,KAAA,GACHC,MAAQ,IACT,CAAC,GAAGC,UAA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js","sources":["../../../src/components/overlays/overlay.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached, tracked } from '@glimmer/tracking';\nimport { later } from '@ember/runloop';\nimport { on } from '@ember/modifier';\nimport { cssTransition } from 'ember-css-transitions';\nimport { useStyles } from '@frontile/theme';\nimport { modifier } from 'ember-modifier';\nimport { focusTrap, type FocusTrapModifierSignature } from 'ember-focus-trap';\nimport { createFocusTrap, type FocusTrap } from 'focus-trap';\nimport onClickOutside from 'ember-click-outside/modifiers/on-click-outside';\nimport { Backdrop, type BackdropSignature } from './backdrop';\nimport {\n afterFirstPaint,\n hasPainted,\n shouldDeferMount,\n shouldSkipEnterTransition,\n withoutEnterTransition\n} from './mount-animation';\nimport { Portal, findParentPortal, type PortalSignature } from './portal';\nimport type Owner from '@ember/owner';\nimport type { ModifierLike } from '@glint/template';\nimport type { CssTransitionSignature } from 'ember-css-transitions/modifiers/css-transition';\nimport { isTesting, macroCondition } from '@embroider/macros';\n\ntype FocusTrapOptions = NonNullable<\n FocusTrapModifierSignature['Args']['Named']['focusTrapOptions']\n>;\n\ntype GuardedFocusTrapMethod =\n 'activate' | 'deactivate' | 'pause' | 'unpause' | 'updateContainerElements';\n\n/**\n * Wraps `createFocusTrap` so activate/deactivate/pause/unpause (and\n * updateContainerElements, which re-validates the same way) never throw.\n *\n * focus-trap keeps a page-global stack of traps; deactivating one can reach\n * into the stack to re-validate (`unpause`) whichever trap is now on top. If\n * that other trap's container was already torn down -- which this test suite\n * does constantly, mounting and unmounting hundreds of trapped overlays in a\n * single browser session -- focus-trap throws \"must have at least one\n * container with at least one tabbable node\", per its own docs' \"Help\"\n * section: this is an expected hazard of trapped elements that \"appear and\n * disappear dynamically\", not a sign of a real focus bug. Test-only: real\n * usage never hits the same rapid-fire mount/unmount churn.\n */\nfunction createTestResilientFocusTrap(\n ...args: Parameters<typeof createFocusTrap>\n): FocusTrap {\n const trap = createFocusTrap(...args);\n\n const guard =\n (method: GuardedFocusTrapMethod) =>\n (...methodArgs: unknown[]): FocusTrap => {\n try {\n return (trap[method] as (...a: unknown[]) => FocusTrap)(...methodArgs);\n } catch {\n return trap;\n }\n };\n\n return {\n ...trap,\n activate: guard('activate'),\n deactivate: guard('deactivate'),\n pause: guard('pause'),\n unpause: guard('unpause'),\n updateContainerElements: guard('updateContainerElements')\n };\n}\n\n/**\n * Whether `target` sits inside a portal nested within this overlay's own\n * portal.\n *\n * The question a click handler needs answered is about *this* click, not about\n * the mere existence of a nested portal. Asking only \"is a nested portal\n * mounted?\" made a parent overlay ignore every outside click for as long as a\n * child was open -- so with a Dropdown submenu (or a Select inside a Modal)\n * open, clicking the page did not close anything.\n *\n * A portal that is not a descendant of this overlay's portal -- one given an\n * explicit `@target`, or opted out of `appendToParentPortal` -- is not nested,\n * and a click in it is a genuine outside click.\n */\nfunction isWithinNestedPortal(\n contentElement: HTMLElement,\n target: EventTarget | null\n): boolean {\n const ownPortal = findParentPortal(contentElement);\n if (!ownPortal || !(target instanceof Element)) {\n return false;\n }\n\n const targetPortal = target.closest('[data-portal=\"true\"]');\n if (!targetPortal || targetPortal === ownPortal) {\n return false;\n }\n\n return ownPortal.contains(targetPortal);\n}\n\n/**\n * The portals nested directly in the one `contentElement` renders into: where\n * a Select's list, a Popover or a Dropdown opened from inside this overlay\n * renders. Portals nested deeper sit inside these.\n */\nfunction nestedPortalsOf(contentElement: HTMLElement): HTMLElement[] {\n const ownPortal = findParentPortal(contentElement);\n if (!ownPortal) {\n return [];\n }\n\n return Array.from(ownPortal.children).filter(\n (child): child is HTMLElement =>\n child instanceof HTMLElement &&\n child.getAttribute('data-portal') === 'true'\n );\n}\n\n// Blocking the body scroll mutates global state, so it has to be reference\n// counted: nested overlays (a Drawer opened from a Modal, a Select inside a\n// Modal) each lock on open and unlock on close, and only the last one out is\n// allowed to restore the page. We also remember the inline value the app had\n// before the first lock, so restoring does not silently wipe an app-level\n// `body { overflow: ... }`.\nlet bodyScrollLockCount = 0;\nlet previousBodyOverflow = '';\n\nfunction lockBodyScroll(): void {\n if (bodyScrollLockCount === 0) {\n previousBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n }\n bodyScrollLockCount++;\n}\n\nfunction unlockBodyScroll(): void {\n if (bodyScrollLockCount === 0) {\n return;\n }\n\n bodyScrollLockCount--;\n\n if (bodyScrollLockCount === 0) {\n document.body.style.overflow = previousBodyOverflow;\n previousBodyOverflow = '';\n }\n}\n\nfunction hasWormholeOrAlertParentElement(el: HTMLElement) {\n let parent = el.parentElement;\n while (parent) {\n if (\n parent.id === 'ember-basic-dropdown-wormhole' ||\n parent.role === 'alert'\n ) {\n return true;\n }\n parent = parent.parentElement;\n }\n return false;\n}\n\ninterface Args extends Pick<\n PortalSignature['Args'],\n 'renderInPlace' | 'target'\n> {\n /**\n * Duration of the animation\n *\n * @defaultValue 200\n */\n transitionDuration?: number;\n\n /**\n * How the area behind the overlay is rendered: `none` omits the backdrop\n * entirely, `transparent` keeps it clickable but invisible, `faded` dims the\n * page, and `blur` blurs it.\n */\n backdrop?: BackdropSignature['Args']['type'];\n\n /**\n * Transition classes for the backdrop, overriding the defaults used when it\n * fades in and out.\n */\n backdropTransition?: BackdropSignature['Args']['transition'];\n\n /**\n * Disable css transitions\n *\n * @defaultValue false\n */\n disableTransitions?: boolean;\n\n /**\n * Whether an overlay that is *already open the first time it renders* --\n * deep-linked open, or restored by a page refresh -- animates in.\n *\n * When true (the default) the overlay waits for the browser's first paint\n * before mounting, so the animation plays against a page the user has\n * already seen. Set it to false for an already-open overlay that should\n * simply be there, with no reveal. An overlay opened later by interaction\n * animates either way, and so does closing.\n *\n * @defaultValue true\n */\n animateOnMount?: boolean;\n\n /**\n * Whether the focus trap is disabled or not\n *\n * @defaultValue false\n */\n disableFocusTrap?: boolean;\n\n /**\n * Focus trap options\n *\n * @defaultValue { clickOutsideDeactivates: true, allowOutsideClick: true }\n */\n focusTrapOptions?: FocusTrapOptions;\n\n /**\n * Whether it is open or not\n */\n isOpen: boolean;\n\n /**\n * A function that will be called when closed\n */\n onClose?: () => void;\n\n /**\n * A function that will be called when closing is finished executing, this\n * includes waiting for animations/transitions to finish.\n */\n didClose?: () => void;\n\n /**\n * A function that will be called when opened\n */\n onOpen?: () => void;\n\n /**\n * Whether to close when the area outside (the backdrop) is clicked\n *\n * @defaultValue true\n */\n closeOnOutsideClick?: boolean;\n\n /**\n * Whether to close when the overlay element is clicked, used for modal and drawer components.\n * This is set to true by default to allow \"outside click\" functionality to work properly.\n * Most overlay content is wrapped with an inner element, preventing accidental closure.\n *\n * @defaultValue true\n */\n closeOnOverlayElementClick?: boolean;\n\n /**\n * Whether to close when the escape key is pressed\n *\n * @defaultValue true\n */\n closeOnEscapeKey?: boolean;\n\n /**\n * Transition options\n *\n * @defaultValue {name:'overlay-transition--fade'}\n */\n transition?: CssTransitionSignature['Args']['Named'];\n\n /**\n * Opt out of the flex layout applied to the content element, for overlays\n * that need to lay their content out themselves.\n *\n * @defaultValue false\n */\n disableFlexContent?: boolean;\n\n /**\n * An extra modifier applied to the content element, for behavior the overlay\n * doesn't provide itself.\n */\n customContentModifier?: ModifierLike<{ Element: HTMLElement }>;\n\n /**\n * Custom class name for the content element, merged with the default ones\n * using Tailwind Merge.\n */\n class?: string;\n /**\n * @defaultValue false\n */\n preventFocusRestore?: boolean;\n\n /**\n * When focusTrap is disabled, by default Oberlay will be auto focused. This option prevents that.\n * @defaultValue false\n */\n preventAutoFocus?: boolean;\n\n /**\n * @defaultValue true\n */\n blockScroll?: boolean;\n}\n\ninterface OverlaySignature {\n Args: Args;\n Element: HTMLDivElement;\n Blocks: { default: [] };\n}\n\nclass Overlay extends Component<OverlaySignature> {\n @tracked keepOpen = false;\n\n // Whether the browser has painted since this overlay was created. Only ever\n // consulted while the mount is being deferred; see `mount-animation.ts`.\n @tracked hasWaitedForPaint = false;\n\n // Whether `@isOpen` was already true on the very first render. Captured once\n // rather than derived, because the whole question is about what the args\n // looked like at mount.\n isOpenAtMount = this.args.isOpen === true;\n\n // Whether the page had already painted when this overlay was created, which\n // only an overlay that mounts open ever has to know -- and every Dropdown,\n // Select and Tooltip in the app builds an Overlay too.\n hadPaintedAtMount = this.isOpenAtMount ? hasPainted() : false;\n\n // Latched when the first open closes, so a *reopen* of the same overlay\n // animates normally. Only a genuine close counts: the content element is\n // also torn down and rebuilt when the portal destination changes under an\n // open overlay, and flipping this then would swap the enter class names out\n // from under the running modifier, which cleans up using whatever names it\n // holds when the transition ends.\n @tracked hasClosedOnce = false;\n\n contentElement: HTMLElement | undefined;\n focusedElement: Element | null | undefined;\n mouseDownContentElement: EventTarget | null = null;\n\n // Whether *this* overlay is holding a reference on the body scroll lock. We\n // record the decision made when opening instead of re-deriving it at\n // teardown, because the args can change while the overlay is open and an\n // asymmetric lock/unlock would leak the reference count.\n didLockBodyScroll = false;\n\n // Keeps the focus trap's containers in step with the nested portals.\n nestedPortalObserver: MutationObserver | undefined;\n\n cancelPaintWait: (() => void) | undefined;\n\n constructor(owner: Owner, args: Args) {\n super(owner, args);\n\n if (!this.shouldDeferMount) {\n return;\n }\n\n this.cancelPaintWait = afterFirstPaint(() => {\n if (!this.isDestroying && !this.isDestroyed) {\n this.hasWaitedForPaint = true;\n }\n });\n }\n\n willDestroy(): void {\n super.willDestroy();\n this.cancelPaintWait?.();\n }\n\n handleClose(): void {\n if (this.args.isOpen && typeof this.args.onClose === 'function') {\n this.args.onClose();\n }\n }\n\n handleContentClick = (event: MouseEvent): void => {\n if (\n this.args.closeOnOutsideClick !== false &&\n this.args.closeOnOverlayElementClick !== false &&\n event.target === this.contentElement &&\n this.mouseDownContentElement == this.contentElement &&\n !isWithinNestedPortal(this.contentElement, event.target) &&\n !hasWormholeOrAlertParentElement(event.target as HTMLElement)\n ) {\n this.handleClose();\n }\n this.mouseDownContentElement = null;\n };\n\n handleOutsideClick = (e: Event): void => {\n if (\n this.args.closeOnOutsideClick !== false &&\n this.contentElement &&\n !isWithinNestedPortal(this.contentElement, e.target) &&\n !hasWormholeOrAlertParentElement(e.target as HTMLElement)\n ) {\n this.handleClose();\n e.preventDefault();\n }\n };\n\n handleContentMouseDown = (event: MouseEvent): void => {\n if (this.args.closeOnOverlayElementClick !== false) {\n this.mouseDownContentElement = event.target;\n }\n };\n\n handleKeyDown = (event: KeyboardEvent): void => {\n if (event.key === 'Escape' && this.args.closeOnEscapeKey !== false) {\n this.handleClose();\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n };\n\n setupContent = modifier((el: HTMLDivElement) => {\n let transitionDuration = this.args.transitionDuration || 200;\n if (!this.isAnimationEnabled) {\n transitionDuration = 0;\n }\n later(() => {\n if (this.isDestroyed) return;\n if (this.args.disableFocusTrap !== true) return;\n if (this.args.preventAutoFocus === true) return;\n el.focus();\n }, transitionDuration);\n\n this.contentElement = el;\n this.keepOpen = true;\n this.focusedElement = document.activeElement;\n\n if (this.args.renderInPlace !== true && this.args.blockScroll !== false) {\n this.didLockBodyScroll = true;\n lockBodyScroll();\n }\n\n if (typeof this.args.onOpen === 'function') {\n this.args.onOpen();\n }\n return () => {\n this.contentElement = undefined;\n this.nestedPortalObserver?.disconnect();\n this.nestedPortalObserver = undefined;\n\n if (this.args.isOpen !== true) {\n this.hasClosedOnce = true;\n }\n\n if (this.didLockBodyScroll) {\n this.didLockBodyScroll = false;\n unlockBodyScroll();\n }\n\n const { didClose } = this.args;\n later(() => {\n if (!this.isDestroyed) this.keepOpen = false;\n if (typeof didClose === 'function' && !this.isDestroyed) {\n didClose();\n }\n\n // restore focus\n if (\n !this.args.preventFocusRestore &&\n this.focusedElement &&\n (this.focusedElement as HTMLElement).tabIndex > -1 &&\n typeof (this.focusedElement as HTMLElement).focus !== 'undefined'\n ) {\n (this.focusedElement as HTMLElement).focus();\n }\n }, transitionDuration);\n };\n });\n\n @cached\n get mountAnimationState() {\n return {\n isFirstOpen: this.isOpenAtMount && !this.hasClosedOnce,\n animationsEnabled: this.isAnimationEnabled,\n animateOnMount: this.args.animateOnMount,\n canWaitForFrame: typeof requestAnimationFrame === 'function',\n hasPainted: this.hadPaintedAtMount\n };\n }\n\n get shouldDeferMount(): boolean {\n return shouldDeferMount(this.mountAnimationState);\n }\n\n get skipEnterTransition(): boolean {\n return shouldSkipEnterTransition(this.mountAnimationState);\n }\n\n get isVisible(): boolean {\n if (this.shouldDeferMount && !this.hasWaitedForPaint) {\n return false;\n }\n\n return this.args.isOpen || this.keepOpen;\n }\n\n get backdrop(): BackdropSignature['Args']['type'] {\n if (!this.args.isOpen) {\n return 'none';\n }\n return this.args.backdrop || 'faded';\n }\n\n get isAnimationEnabled(): boolean {\n if (macroCondition(isTesting())) {\n return false;\n }\n return !(this.args.disableTransitions === true);\n }\n\n /**\n * Consumer options are merged over the defaults rather than replacing them.\n *\n * Swapping the object wholesale made setting any single option -- a\n * `setReturnFocus`, an `initialFocus` -- silently drop\n * `clickOutsideDeactivates` and `allowOutsideClick` with it, at which point\n * the trap swallows outside clicks and the overlay can only be dismissed\n * with Escape. Nothing warns, and the cause is nowhere near the symptom.\n * A consumer that genuinely wants the trap to hold outside clicks can still\n * say so by passing those two as `false`.\n */\n get focusTrapOptions(): FocusTrapOptions {\n return {\n clickOutsideDeactivates: true,\n allowOutsideClick: true,\n ...this.args.focusTrapOptions\n };\n }\n\n /**\n * The trap covers the content and the portals nested in this overlay's\n * portal, the same ones `handleOutsideClick` doesn't count as outside.\n *\n * With the content alone as its container, the trap took a press in a\n * nested portal for an outside click and deactivated: from then on Tab\n * walked out of the Drawer. A touch on a Select's list also sent the focus\n * back to where it was when the trap activated, out of the Select's\n * filter. As containers, nested overlays are also part of the Tab cycle,\n * after the content.\n *\n * Nested overlays open and close while this one stays open, so a\n * MutationObserver on the portal keeps the containers current.\n */\n createFocusTrap = (\n ...[element, options]: Parameters<typeof createFocusTrap>\n ): FocusTrap => {\n let create = createFocusTrap;\n if (macroCondition(isTesting())) {\n create = createTestResilientFocusTrap;\n }\n\n // The element the `focusTrap` modifier is on: the content. We pass it no\n // `additionalElements`, so it's never a list.\n const content = element as HTMLElement;\n const containers = () => [content, ...nestedPortalsOf(content)];\n const trap = create(containers(), options);\n\n const ownPortal = findParentPortal(content);\n if (ownPortal) {\n this.nestedPortalObserver?.disconnect();\n this.nestedPortalObserver = new MutationObserver(() => {\n trap.updateContainerElements(containers());\n });\n this.nestedPortalObserver.observe(ownPortal, { childList: true });\n }\n\n return trap;\n };\n\n get classes() {\n const { overlay } = useStyles();\n\n return overlay({\n class: this.args.class,\n inPlace: this.args.renderInPlace,\n enableFlexContent: !(this.args.disableFlexContent === true)\n });\n }\n\n get customContentModifier() {\n if (this.args.customContentModifier) {\n return this.args.customContentModifier;\n }\n\n return modifier(() => {});\n }\n\n // Applied to both the content and the backdrop, so they never disagree about\n // whether this mount animates.\n maybeWithoutEnter<T extends object>(options: T): T {\n return this.skipEnterTransition ? withoutEnterTransition(options) : options;\n }\n\n get backdropTransition() {\n return this.maybeWithoutEnter(\n this.args.backdropTransition || { isEnabled: this.isAnimationEnabled }\n );\n }\n\n get transition() {\n let options: BackdropSignature['Args']['transition'] = {\n name: 'overlay-transition--fade',\n isEnabled: this.isAnimationEnabled\n };\n\n if (typeof this.args.transition === 'object') {\n options = { ...options, ...this.args.transition };\n }\n\n return this.maybeWithoutEnter(options);\n }\n\n <template>\n {{! template-lint-disable no-invalid-interactive }}\n {{! template-lint-disable no-pointer-down-event-binding }}\n\n {{#if this.isVisible}}\n <Portal @renderInPlace={{@renderInPlace}} @target={{@target}}>\n <Backdrop\n @type={{this.backdrop}}\n @inPlace={{@renderInPlace}}\n @transition={{this.backdropTransition}}\n />\n\n {{#if @isOpen}}\n <div\n {{this.setupContent}}\n {{on \"click\" this.handleContentClick}}\n {{on \"keydown\" this.handleKeyDown}}\n {{on \"mousedown\" this.handleContentMouseDown}}\n {{cssTransition\n didTransitionIn=this.transition.didTransitionIn\n didTransitionOut=this.transition.didTransitionOut\n enterClass=this.transition.enterClass\n enterActiveClass=this.transition.enterActiveClass\n enterToClass=this.transition.enterToClass\n isEnabled=this.transition.isEnabled\n leaveClass=this.transition.leaveClass\n leaveActiveClass=this.transition.leaveActiveClass\n leaveToClass=this.transition.leaveToClass\n name=this.transition.name\n parentSelector=this.transition.parentSelector\n }}\n {{onClickOutside this.handleOutsideClick capture=true}}\n {{focusTrap\n isActive=(if @disableFocusTrap false @isOpen)\n focusTrapOptions=this.focusTrapOptions\n _createFocusTrap=this.createFocusTrap\n }}\n class={{this.classes}}\n {{! Keep this custom modifer by last}}\n {{this.customContentModifier}}\n data-component=\"overlay\"\n data-part=\"base\"\n tabindex=\"0\"\n ...attributes\n >\n {{yield}}\n </div>\n {{/if}}\n </Portal>\n {{/if}}\n </template>\n}\n\nexport { Overlay, type OverlaySignature };\nexport default Overlay;\n"],"names":["createTestResilientFocusTrap","args","trap","createFocusTrap","guard","method","methodArgs","activate","deactivate","pause","unpause","updateContainerElements","isWithinNestedPortal","contentElement","target","ownPortal","findParentPortal","Element","targetPortal","closest","contains","nestedPortalsOf","Array","from","children","filter","child","HTMLElement","getAttribute","bodyScrollLockCount","previousBodyOverflow","lockBodyScroll","document","body","style","overflow","unlockBodyScroll","hasWormholeOrAlertParentElement","el","parent","parentElement","id","role","Overlay","Component","g","prototype","tracked","i","isOpenAtMount","isOpen","hadPaintedAtMount","hasPainted","focusedElement","mouseDownContentElement","didLockBodyScroll","nestedPortalObserver","cancelPaintWait","constructor","owner","shouldDeferMount","afterFirstPaint","isDestroying","isDestroyed","hasWaitedForPaint","willDestroy","handleClose","onClose","handleContentClick","event","closeOnOutsideClick","closeOnOverlayElementClick","handleOutsideClick","e","preventDefault","handleContentMouseDown","handleKeyDown","key","closeOnEscapeKey","stopImmediatePropagation","setupContent","modifier","transitionDuration","isAnimationEnabled","later","disableFocusTrap","preventAutoFocus","focus","keepOpen","activeElement","renderInPlace","blockScroll","onOpen","undefined","disconnect","hasClosedOnce","didClose","preventFocusRestore","tabIndex","mountAnimationState","isFirstOpen","animationsEnabled","animateOnMount","canWaitForFrame","requestAnimationFrame","n","cached","skipEnterTransition","shouldSkipEnterTransition","isVisible","backdrop","macroCondition","isTesting","disableTransitions","focusTrapOptions","clickOutsideDeactivates","allowOutsideClick","element","options","create","content","containers","MutationObserver","observe","childList","classes","overlay","useStyles","class","inPlace","enableFlexContent","disableFlexContent","customContentModifier","maybeWithoutEnter","withoutEnterTransition","backdropTransition","isEnabled","transition","name","setComponentTemplate","precompileTemplate","strictMode","scope","Portal","Backdrop","on","cssTransition","onClickOutside","focusTrap"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA;;;;;;;;;;;;;AAaC;AACD,SAASA,4BAAAA,CACP,GAAGC,IAAwC,EAC1C;AACD,EAAA,MAAMC,OAAOC,eAAA,CAAA,GAAmBF,IAAA,CAAA;AAEhC,EAAA,MAAMG,KAAA,GACHC,MAAQ,IACT,CAAC,GAAGC,UAAmB,KAAK;IAC1B,IAAI;AACF,MAAA,OAAQJ,IAAI,CAACG,MAAA,CAAO,CAAkC,GAAKC,UAAA,CAAA;AAC7D,IAAA,CAAA,CAAE,MAAM;AACN,MAAA,OAAOJ,IAAA;AACT,IAAA;EACF,CAAA;EAEF,OAAO;AACL,IAAA,GAAGA,IAAI;AACPK,IAAAA,QAAA,EAAUH,KAAA,CAAM,UAAA,CAAA;AAChBI,IAAAA,UAAA,EAAYJ,KAAA,CAAM,YAAA,CAAA;AAClBK,IAAAA,KAAA,EAAOL,KAAA,CAAM,OAAA,CAAA;AACbM,IAAAA,OAAA,EAASN,KAAA,CAAM,SAAA,CAAA;IACfO,uBAAA,EAAyBP,KAAA,CAAM,yBAAA;GACjC;AACF;AAEA;;;;;;;;;;;;;;AAcA,SAASQ,qBACPC,cAA2B,EAC3BC,MAA0B,EAClB;AACR,EAAA,MAAMC,YAAYC,gBAAA,CAAiBH,cAAA,CAAA;EACnC,IAAI,CAACE,SAAA,IAAa,EAAED,MAAA,YAAkBG,OAAO,CAAA,EAAG;AAC9C,IAAA,OAAO,KAAA;AACT,EAAA;AAEA,EAAA,MAAMC,YAAA,GAAeJ,MAAA,CAAOK,OAAO,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UAAU,KAAK,QAAA,EAAU;AAC5CnB,MAAAA,OAAA,GAAU;AAAE,QAAA,GAAGA,OAAO;QAAE,GAAG,IAAI,CAACrH,IAAI,CAACwI;OAAW;AAClD,IAAA;AAEA,IAAA,OAAO,IAAI,CAACJ,iBAAiB,CAACf,OAAA,CAAA;AAChC,EAAA;AAEA,EAAA;IAAAqB,oBAAA,CAAAC,kBAAA,CAAA,k5CAAA,EAkDA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,MAAA;QAAAC,QAAA;QAAAC,EAAA;QAAAC,aAAA;QAAAC,cAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
package/dist/forms.js CHANGED
@@ -17,7 +17,7 @@ export { FormControl } from './components/forms/form-control.js';
17
17
  export { Switch } from './components/forms/switch.js';
18
18
  export { DatePicker } from './components/forms/date-picker/date-picker.js';
19
19
  export { DEFAULT_TIME_FORMAT, formatValue, isEmptyValue, parseDate, parseRange, toWire, withTimeOf } from './components/forms/date-picker/value.js';
20
- export { BOUNDS, DEFAULT_FORMAT, applyDigit, applyLetter, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, hourOfDay, hourOnCycle, isSegment, resolveSegmentFormat, resolveTwoDigitYear, step, timeOf, toDate, toNumericFormat, withTime, withValue } from './components/forms/date-input/segments.js';
20
+ export { BOUNDS, DEFAULT_FORMAT, applyDigit, applyLetter, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, hourOfDay, hourOnCycle, isSegment, resolveSegmentFormat, resolveTwoDigitYear, seedFrom, step, timeOf, toDate, toNumericFormat, withTime, withValue } from './components/forms/date-input/segments.js';
21
21
  export { formatForClipboard, parsePasted, splitRange } from './components/forms/date-input/clipboard.js';
22
22
  export { DateInput } from './components/forms/date-input/date-input.js';
23
23
  export { StandardValidator } from './utils/standard-validator.js';
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ export { FormControl } from './components/forms/form-control.js';
34
34
  export { Switch } from './components/forms/switch.js';
35
35
  export { DatePicker } from './components/forms/date-picker/date-picker.js';
36
36
  export { DEFAULT_TIME_FORMAT, formatValue, isEmptyValue, parseDate, parseRange, toWire, withTimeOf } from './components/forms/date-picker/value.js';
37
- export { BOUNDS, DEFAULT_FORMAT, applyDigit, applyLetter, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, hourOfDay, hourOnCycle, isSegment, resolveSegmentFormat, resolveTwoDigitYear, step, timeOf, toDate, toNumericFormat, withTime, withValue } from './components/forms/date-input/segments.js';
37
+ export { BOUNDS, DEFAULT_FORMAT, applyDigit, applyLetter, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, hourOfDay, hourOnCycle, isSegment, resolveSegmentFormat, resolveTwoDigitYear, seedFrom, step, timeOf, toDate, toNumericFormat, withTime, withValue } from './components/forms/date-input/segments.js';
38
38
  export { formatForClipboard, parsePasted, splitRange } from './components/forms/date-input/clipboard.js';
39
39
  export { DateInput } from './components/forms/date-input/date-input.js';
40
40
  export { StandardValidator } from './utils/standard-validator.js';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Scroll `target` into view inside `panel` and nowhere else.
3
+ *
4
+ * `scrollIntoView` and a plain `focus()` both scroll *every* scrollable
5
+ * ancestor up to the document, so either one makes the host page jump when a
6
+ * panel opens or when arrow keys walk past its edge. Adjusting `scrollTop`
7
+ * directly keeps the movement inside the panel.
8
+ *
9
+ * The measurements come from `offsetTop`, not `getBoundingClientRect()`:
10
+ * client rects are in transformed pixels, so under any ancestor `scale()` they
11
+ * would not agree with `scrollTop`. This relies on the panel being the
12
+ * target's `offsetParent`, so the panel has to be positioned.
13
+ *
14
+ * `center` places the target mid-panel, for the opening jump to a value that
15
+ * is usually a long way down the list; otherwise the target is brought just
16
+ * far enough into view, which is what stepping key by key wants.
17
+ */
18
+ function revealWithin(panel, target, center) {
19
+ const top = target.offsetTop;
20
+ const bottom = top + target.offsetHeight;
21
+ if (center) {
22
+ panel.scrollTop = top - (panel.clientHeight - target.offsetHeight) / 2;
23
+ return;
24
+ }
25
+ if (top < panel.scrollTop) {
26
+ panel.scrollTop = top;
27
+ } else if (bottom > panel.scrollTop + panel.clientHeight) {
28
+ panel.scrollTop = bottom - panel.clientHeight;
29
+ }
30
+ }
31
+
32
+ export { revealWithin as r };
33
+ //# sourceMappingURL=reveal-within-BcqpOmSI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reveal-within-BcqpOmSI.js","sources":["../src/-private/reveal-within.ts"],"sourcesContent":["/**\n * Scroll `target` into view inside `panel` and nowhere else.\n *\n * `scrollIntoView` and a plain `focus()` both scroll *every* scrollable\n * ancestor up to the document, so either one makes the host page jump when a\n * panel opens or when arrow keys walk past its edge. Adjusting `scrollTop`\n * directly keeps the movement inside the panel.\n *\n * The measurements come from `offsetTop`, not `getBoundingClientRect()`:\n * client rects are in transformed pixels, so under any ancestor `scale()` they\n * would not agree with `scrollTop`. This relies on the panel being the\n * target's `offsetParent`, so the panel has to be positioned.\n *\n * `center` places the target mid-panel, for the opening jump to a value that\n * is usually a long way down the list; otherwise the target is brought just\n * far enough into view, which is what stepping key by key wants.\n */\nexport function revealWithin(\n panel: HTMLElement,\n target: HTMLElement,\n center: boolean\n): void {\n const top = target.offsetTop;\n const bottom = top + target.offsetHeight;\n\n if (center) {\n panel.scrollTop = top - (panel.clientHeight - target.offsetHeight) / 2;\n return;\n }\n\n if (top < panel.scrollTop) {\n panel.scrollTop = top;\n } else if (bottom > panel.scrollTop + panel.clientHeight) {\n panel.scrollTop = bottom - panel.clientHeight;\n }\n}\n"],"names":["revealWithin","panel","target","center","top","offsetTop","bottom","offsetHeight","scrollTop","clientHeight"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAYA,CAC1BC,KAAkB,EAClBC,MAAmB,EACnBC,MAAe,EACT;AACN,EAAA,MAAMC,GAAG,GAAGF,MAAM,CAACG,SAAS;AAC5B,EAAA,MAAMC,MAAM,GAAGF,GAAG,GAAGF,MAAM,CAACK,YAAY;AAExC,EAAA,IAAIJ,MAAM,EAAE;AACVF,IAAAA,KAAK,CAACO,SAAS,GAAGJ,GAAG,GAAG,CAACH,KAAK,CAACQ,YAAY,GAAGP,MAAM,CAACK,YAAY,IAAI,CAAC;AACtE,IAAA;AACF,EAAA;AAEA,EAAA,IAAIH,GAAG,GAAGH,KAAK,CAACO,SAAS,EAAE;IACzBP,KAAK,CAACO,SAAS,GAAGJ,GAAG;EACvB,CAAC,MAAM,IAAIE,MAAM,GAAGL,KAAK,CAACO,SAAS,GAAGP,KAAK,CAACQ,YAAY,EAAE;AACxDR,IAAAA,KAAK,CAACO,SAAS,GAAGF,MAAM,GAAGL,KAAK,CAACQ,YAAY;AAC/C,EAAA;AACF;;"}
@@ -1713,7 +1713,9 @@ function changeOption(functionName, selectSelector, key, toggle) {
1713
1713
  }
1714
1714
  const option = select.querySelector(`[data-key="${key}"]`);
1715
1715
  if (!option) {
1716
- throw new Error(`You called "${functionName}('${selectSelector}', '${key}')" but no option with key "${key}" was found`);
1716
+ // A Select with `@displayLimit` holds only the first options (and the
1717
+ // selected ones) in its hidden `<select>`, like its listbox.
1718
+ throw new Error(`You called "${functionName}('${selectSelector}', '${key}')" but no option with key "${key}" was found. ` + 'With @displayLimit, only the first options and the selected ones are there: type into the filter and click the option instead.');
1717
1719
  }
1718
1720
  if (toggle && option.selected) {
1719
1721
  option.selected = false;