frontile 0.18.5 → 0.18.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/-private/icons.d.ts +4 -0
- package/declarations/-private/icons.d.ts.map +1 -1
- package/declarations/-private/reveal-within.d.ts +19 -0
- package/declarations/-private/reveal-within.d.ts.map +1 -0
- package/declarations/components/collections/calendar/year-grid.d.ts.map +1 -1
- package/declarations/components/collections/dropdown/dropdown.d.ts +50 -53
- package/declarations/components/collections/dropdown/dropdown.d.ts.map +1 -1
- package/declarations/components/collections/listbox/item.d.ts +52 -1
- package/declarations/components/collections/listbox/item.d.ts.map +1 -1
- package/declarations/components/forms/date-input/segment-group.d.ts +2 -1
- package/declarations/components/forms/date-input/segment-group.d.ts.map +1 -1
- package/declarations/components/forms/date-input/segments.d.ts +3 -1
- package/declarations/components/forms/date-input/segments.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/date-picker.d.ts +119 -1
- package/declarations/components/forms/date-picker/date-picker.d.ts.map +1 -1
- package/declarations/components/forms/date-picker/time-columns.d.ts +87 -0
- package/declarations/components/forms/date-picker/time-columns.d.ts.map +1 -0
- package/declarations/components/forms/date-picker/types.d.ts +28 -0
- package/declarations/components/forms/date-picker/types.d.ts.map +1 -1
- package/declarations/components/forms/select/native-mirror.d.ts +3 -2
- package/declarations/components/forms/select/native-mirror.d.ts.map +1 -1
- package/declarations/components/forms/select/select.d.ts +31 -2
- package/declarations/components/forms/select/select.d.ts.map +1 -1
- package/declarations/components/forms/select/types.d.ts +3 -2
- package/declarations/components/forms/select/types.d.ts.map +1 -1
- package/declarations/components/layout/app-layout-state.d.ts +32 -0
- package/declarations/components/layout/app-layout-state.d.ts.map +1 -0
- package/declarations/components/layout/app-layout.d.ts +954 -0
- package/declarations/components/layout/app-layout.d.ts.map +1 -0
- package/declarations/components/layout/aside-toggle.d.ts +55 -0
- package/declarations/components/layout/aside-toggle.d.ts.map +1 -0
- package/declarations/components/layout/aside.d.ts +761 -0
- package/declarations/components/layout/aside.d.ts.map +1 -0
- package/declarations/components/layout/bottom-nav-more.d.ts +123 -0
- package/declarations/components/layout/bottom-nav-more.d.ts.map +1 -0
- package/declarations/components/layout/bottom-nav.d.ts +60 -0
- package/declarations/components/layout/bottom-nav.d.ts.map +1 -0
- package/declarations/components/layout/context.d.ts +134 -0
- package/declarations/components/layout/context.d.ts.map +1 -0
- package/declarations/components/layout/index.d.ts +14 -0
- package/declarations/components/layout/index.d.ts.map +1 -0
- package/declarations/components/layout/main.d.ts +28 -0
- package/declarations/components/layout/main.d.ts.map +1 -0
- package/declarations/components/layout/menu-toggle.d.ts +58 -0
- package/declarations/components/layout/menu-toggle.d.ts.map +1 -0
- package/declarations/components/layout/nav-context.d.ts +45 -0
- package/declarations/components/layout/nav-context.d.ts.map +1 -0
- package/declarations/components/layout/nav-folder.d.ts +216 -0
- package/declarations/components/layout/nav-folder.d.ts.map +1 -0
- package/declarations/components/layout/nav-item.d.ts +220 -0
- package/declarations/components/layout/nav-item.d.ts.map +1 -0
- package/declarations/components/layout/nav-link.d.ts +67 -0
- package/declarations/components/layout/nav-link.d.ts.map +1 -0
- package/declarations/components/layout/navbar.d.ts +27 -0
- package/declarations/components/layout/navbar.d.ts.map +1 -0
- package/declarations/components/layout/page-header.d.ts +40 -0
- package/declarations/components/layout/page-header.d.ts.map +1 -0
- package/declarations/components/layout/sidebar-group.d.ts +41 -0
- package/declarations/components/layout/sidebar-group.d.ts.map +1 -0
- package/declarations/components/layout/sidebar-toggle.d.ts +71 -0
- package/declarations/components/layout/sidebar-toggle.d.ts.map +1 -0
- package/declarations/components/layout/sidebar.d.ts +904 -0
- package/declarations/components/layout/sidebar.d.ts.map +1 -0
- package/declarations/components/navigation/index.d.ts +1 -0
- package/declarations/components/navigation/index.d.ts.map +1 -1
- package/declarations/components/navigation/stepper/collapse-menu.d.ts +42 -0
- package/declarations/components/navigation/stepper/collapse-menu.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/list.d.ts +24 -0
- package/declarations/components/navigation/stepper/list.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/panel.d.ts +42 -0
- package/declarations/components/navigation/stepper/panel.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/step.d.ts +123 -0
- package/declarations/components/navigation/stepper/step.d.ts.map +1 -0
- package/declarations/components/navigation/stepper/stepper.d.ts +947 -0
- package/declarations/components/navigation/stepper/stepper.d.ts.map +1 -0
- package/declarations/components/navigation/stepper.d.ts +6 -0
- package/declarations/components/navigation/stepper.d.ts.map +1 -0
- package/declarations/components/navigation/tab-nav/item.d.ts +2 -2
- package/declarations/components/navigation/tab-nav/item.d.ts.map +1 -1
- package/declarations/components/overlays/overlay.d.ts +17 -2
- package/declarations/components/overlays/overlay.d.ts.map +1 -1
- package/declarations/components/overlays/portal.d.ts.map +1 -1
- package/declarations/components/utilities/collapsible.d.ts +19 -2
- package/declarations/components/utilities/collapsible.d.ts.map +1 -1
- package/declarations/index.d.ts +1 -0
- package/declarations/index.d.ts.map +1 -1
- package/declarations/layout.d.ts +2 -0
- package/declarations/layout.d.ts.map +1 -0
- package/declarations/test-support.d.ts.map +1 -1
- package/declarations/utils/breakpoint.d.ts +16 -0
- package/declarations/utils/breakpoint.d.ts.map +1 -0
- package/declarations/utils/document-listener.d.ts +6 -0
- package/declarations/utils/document-listener.d.ts.map +1 -0
- package/declarations/utils/listManager.d.ts +7 -1
- package/declarations/utils/listManager.d.ts.map +1 -1
- package/declarations/utils/route-active.d.ts +34 -0
- package/declarations/utils/route-active.d.ts.map +1 -0
- package/declarations/utils/selection-indicator.d.ts +7 -4
- package/declarations/utils/selection-indicator.d.ts.map +1 -1
- package/dist/components/collections/calendar/header.js +1 -1
- package/dist/components/collections/calendar/year-grid.js +1 -30
- package/dist/components/collections/calendar/year-grid.js.map +1 -1
- package/dist/components/collections/dropdown/dropdown.js +172 -48
- package/dist/components/collections/dropdown/dropdown.js.map +1 -1
- package/dist/components/collections/listbox/item.js +36 -2
- package/dist/components/collections/listbox/item.js.map +1 -1
- package/dist/components/collections/table/column-visibility.js +1 -1
- package/dist/components/collections/table/sort-button.js +1 -1
- package/dist/components/disclosure/accordion/item.js +1 -1
- package/dist/components/forms/autocomplete.js +1 -1
- package/dist/components/forms/date-input/segment-group.js +1 -1
- package/dist/components/forms/date-input/segment-group.js.map +1 -1
- package/dist/components/forms/date-input/segments.js +1 -1
- package/dist/components/forms/date-input/segments.js.map +1 -1
- package/dist/components/forms/date-input.js +1 -1
- package/dist/components/forms/date-picker/date-picker.js +57 -6
- package/dist/components/forms/date-picker/date-picker.js.map +1 -1
- package/dist/components/forms/date-picker/end-content.js +1 -1
- package/dist/components/forms/date-picker/time-columns.js +238 -0
- package/dist/components/forms/date-picker/time-columns.js.map +1 -0
- package/dist/components/forms/index.js +1 -1
- package/dist/components/forms/native-select.js +1 -1
- package/dist/components/forms/select/end-content.js +1 -1
- package/dist/components/forms/select/native-mirror.js.map +1 -1
- package/dist/components/forms/select/select.js +24 -5
- package/dist/components/forms/select/select.js.map +1 -1
- package/dist/components/layout/app-layout-state.js +64 -0
- package/dist/components/layout/app-layout-state.js.map +1 -0
- package/dist/components/layout/app-layout.js +416 -0
- package/dist/components/layout/app-layout.js.map +1 -0
- package/dist/components/layout/aside-toggle.js +55 -0
- package/dist/components/layout/aside-toggle.js.map +1 -0
- package/dist/components/layout/aside.js +100 -0
- package/dist/components/layout/aside.js.map +1 -0
- package/dist/components/layout/bottom-nav-more.js +150 -0
- package/dist/components/layout/bottom-nav-more.js.map +1 -0
- package/dist/components/layout/bottom-nav.js +65 -0
- package/dist/components/layout/bottom-nav.js.map +1 -0
- package/dist/components/layout/context.js +89 -0
- package/dist/components/layout/context.js.map +1 -0
- package/dist/components/layout/index.js +14 -0
- package/dist/components/layout/index.js.map +1 -0
- package/dist/components/layout/main.js +34 -0
- package/dist/components/layout/main.js.map +1 -0
- package/dist/components/layout/menu-toggle.js +61 -0
- package/dist/components/layout/menu-toggle.js.map +1 -0
- package/dist/components/layout/nav-context.js +85 -0
- package/dist/components/layout/nav-context.js.map +1 -0
- package/dist/components/layout/nav-folder.js +271 -0
- package/dist/components/layout/nav-folder.js.map +1 -0
- package/dist/components/layout/nav-item.js +192 -0
- package/dist/components/layout/nav-item.js.map +1 -0
- package/dist/components/layout/nav-link.js +58 -0
- package/dist/components/layout/nav-link.js.map +1 -0
- package/dist/components/layout/navbar.js +30 -0
- package/dist/components/layout/navbar.js.map +1 -0
- package/dist/components/layout/page-header.js +45 -0
- package/dist/components/layout/page-header.js.map +1 -0
- package/dist/components/layout/sidebar-group.js +41 -0
- package/dist/components/layout/sidebar-group.js.map +1 -0
- package/dist/components/layout/sidebar-toggle.js +82 -0
- package/dist/components/layout/sidebar-toggle.js.map +1 -0
- package/dist/components/layout/sidebar.js +249 -0
- package/dist/components/layout/sidebar.js.map +1 -0
- package/dist/components/navigation/breadcrumbs/separator.js +1 -1
- package/dist/components/navigation/index.js +4 -0
- package/dist/components/navigation/index.js.map +1 -1
- package/dist/components/navigation/pagination/pagination.js +1 -1
- package/dist/components/navigation/stepper/collapse-menu.js +128 -0
- package/dist/components/navigation/stepper/collapse-menu.js.map +1 -0
- package/dist/components/navigation/stepper/list.js +17 -0
- package/dist/components/navigation/stepper/list.js.map +1 -0
- package/dist/components/navigation/stepper/panel.js +26 -0
- package/dist/components/navigation/stepper/panel.js.map +1 -0
- package/dist/components/navigation/stepper/step.js +130 -0
- package/dist/components/navigation/stepper/step.js.map +1 -0
- package/dist/components/navigation/stepper/stepper.js +475 -0
- package/dist/components/navigation/stepper/stepper.js.map +1 -0
- package/dist/components/navigation/stepper.js +5 -0
- package/dist/components/navigation/stepper.js.map +1 -0
- package/dist/components/navigation/tab-nav/item.js +6 -40
- package/dist/components/navigation/tab-nav/item.js.map +1 -1
- package/dist/components/notifications/index.js +1 -1
- package/dist/components/notifications/notification-card.js +2 -2
- package/dist/components/notifications/notifications-container.js +1 -1
- package/dist/components/overlays/overlay.js +55 -7
- package/dist/components/overlays/overlay.js.map +1 -1
- package/dist/components/overlays/portal.js +11 -2
- package/dist/components/overlays/portal.js.map +1 -1
- package/dist/components/status/alert.js +1 -1
- package/dist/components/utilities/collapsible.js +33 -5
- package/dist/components/utilities/collapsible.js.map +1 -1
- package/dist/forms.js +1 -1
- package/dist/{icons-DZ61nCzv.js → icons-55dthVFk.js} +14 -2
- package/dist/{icons-DZ61nCzv.js.map → icons-55dthVFk.js.map} +1 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/layout.js +14 -0
- package/dist/layout.js.map +1 -0
- package/dist/navigation.js +4 -0
- package/dist/navigation.js.map +1 -1
- package/dist/{notification-card-dz-eE6z9.js → notification-card-BPfDo-Gf.js} +2 -2
- package/dist/{notification-card-dz-eE6z9.js.map → notification-card-BPfDo-Gf.js.map} +1 -1
- package/dist/notifications.js +1 -1
- package/dist/reveal-within-BcqpOmSI.js +33 -0
- package/dist/reveal-within-BcqpOmSI.js.map +1 -0
- package/dist/test-support.js +3 -1
- package/dist/test-support.js.map +1 -1
- package/dist/utils/breakpoint.js +56 -0
- package/dist/utils/breakpoint.js.map +1 -0
- package/dist/utils/document-listener.js +10 -0
- package/dist/utils/document-listener.js.map +1 -0
- package/dist/utils/listManager.js +12 -2
- package/dist/utils/listManager.js.map +1 -1
- package/dist/utils/route-active.js +70 -0
- package/dist/utils/route-active.js.map +1 -0
- package/dist/utils/selection-indicator.js +25 -5
- package/dist/utils/selection-indicator.js.map +1 -1
- package/package.json +7 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listManager.js","sources":["../../src/utils/listManager.ts"],"sourcesContent":["import { tracked } from '@glimmer/tracking';\nimport { cancel, debounce, later } from '@ember/runloop';\nimport { modifier } from 'ember-modifier';\nimport type { Timer } from '@ember/runloop';\nimport { getElementById } from '../-private/dom';\nimport { defaultFilter, type FilterFn } from './filter';\n\ntype SelectionMode = 'none' | 'single' | 'multiple';\ntype AutoActivateMode = 'none' | 'first' | 'selected';\n\ninterface ListItemArgs {\n key: string;\n textValue?: string;\n isSelected?: boolean;\n isDisabled?: boolean;\n isActive?: boolean;\n\n /**\n * The entry of the collection this item was rendered from, so consumers of a\n * selection can reach their own object rather than only its key and text.\n *\n * Undefined when there is no such object: an item written out in block form\n * is not backed by a collection entry, so nothing is invented for it.\n */\n item?: unknown;\n}\n\n/**\n * What `register` needs: every display flag resolved, and the source item\n * carried along if the caller has one.\n */\ntype ListItemRegistration = Required<Omit<ListItemArgs, 'item'>> &\n Pick<ListItemArgs, 'item'>;\n\nclass ListItem {\n el: HTMLLIElement | HTMLOptionElement;\n key: string;\n textValue: string;\n\n // Not tracked, and deliberately so. This is fixed at registration: the\n // element and its source entry arrive together, and a change to either\n // re-runs `setupItem`, which unregisters this item and registers a fresh\n // one. Making it tracked would add a settable tag to a class whose every\n // other field needs the mirror guards below to stay clear of Glimmer's\n // read-then-write assertion, for a value that is never written again.\n item?: unknown;\n\n // Ember's tracked setter dirties a tag unconditionally — it never compares\n // against the current value. That makes a redundant write more than wasted\n // work here: Glimmer reads an attribute and writes it to the DOM inside a\n // single autotracking frame, and writing `tabindex` onto the focused item\n // blurs it, so the browser dispatches `focusout` synchronously and this\n // item's own listeners run *inside* the frame that just consumed `isActive`.\n // Dirtying a tag that frame already consumed trips a backtracking-rerender\n // assertion, so every field below only writes on a real change.\n //\n // Each comparison reads a plain mirror rather than the tracked field itself.\n // Reading the tracked field would *consume* its tag, so the write that\n // followed would dirty a tag the current frame had just consumed — precisely\n // the failure these guards exist to prevent. For the same reason, code that\n // reads a field only to decide whether to write it should read the mirror;\n // `isActiveUntracked` exposes that for the one caller outside this class.\n @tracked private _isSelected: boolean;\n @tracked private _isDisabled: boolean;\n @tracked private _isActive: boolean;\n\n private isSelectedMirror: boolean;\n private isDisabledMirror: boolean;\n private isActiveMirror: boolean;\n\n get isSelected(): boolean {\n return this._isSelected;\n }\n\n set isSelected(value: boolean) {\n if (this.isSelectedMirror !== value) {\n this.isSelectedMirror = value;\n this._isSelected = value;\n }\n }\n\n get isDisabled(): boolean {\n return this._isDisabled;\n }\n\n set isDisabled(value: boolean) {\n if (this.isDisabledMirror !== value) {\n this.isDisabledMirror = value;\n this._isDisabled = value;\n }\n }\n\n get isActive(): boolean {\n return this._isActive;\n }\n\n set isActive(value: boolean) {\n if (this.isActiveMirror !== value) {\n this.isActiveMirror = value;\n this._isActive = value;\n }\n }\n\n /**\n * The three flags read without consuming their tags, for write decisions and\n * for `ListManager`'s tab-stop bookkeeping -- which has to look at every\n * sibling and must not drag every sibling's tag into the frame that does so.\n */\n get isActiveUntracked(): boolean {\n return this.isActiveMirror;\n }\n\n get isSelectedUntracked(): boolean {\n return this.isSelectedMirror;\n }\n\n get isDisabledUntracked(): boolean {\n return this.isDisabledMirror;\n }\n\n constructor(\n el: HTMLLIElement | HTMLOptionElement,\n args: ListItemRegistration\n ) {\n this.el = el;\n this.key = args.key;\n this.textValue = args.textValue;\n this.item = args.item;\n this._isSelected = this.isSelectedMirror = args.isSelected;\n this._isDisabled = this.isDisabledMirror = args.isDisabled;\n this._isActive = this.isActiveMirror = args.isActive;\n }\n}\n\ninterface ListManagerArgs {\n selectionMode?: SelectionMode;\n selectedKeys?: string[];\n disabledKeys?: string[];\n allowEmpty?: boolean;\n autoActivateMode?: AutoActivateMode;\n onAction?: (key: string) => void;\n onSelectionChange?: (key: string[]) => void;\n onListItemsChange?: (items: ListItem[], action: 'add' | 'remove') => void;\n onActiveItemChange?: (key?: string, item?: ListItem) => void;\n}\n\nclass ListManager {\n #items: ListItem[] = [];\n\n /**\n * The one pending \"the list changed\" task, and what the batch behind it did.\n *\n * Registration is per item, but everything that follows it -- ordering the\n * list against the document, telling the consumer what the list now holds,\n * and moving the active item -- belongs to the *batch*. Doing it per\n * registration made a 500-option Select order 500 nodes 500 times over and\n * queue 500 timers, each ordering them again, none of them cancelled. One\n * timer, replaced whenever another item registers or unregisters, does the\n * work once against the finished DOM.\n *\n * Deferring is not only cheaper, it is more accurate: mid-batch the document\n * still holds the elements Glimmer is about to tear down, so the orders\n * computed then were partly garbage (see `#orderedItems`).\n */\n #pendingTimer?: Timer;\n #pendingAdd = false;\n #pendingRemove = false;\n #pendingAction?: 'add' | 'remove';\n\n /**\n * Whether the `setup` modifier has been torn down without being re-installed.\n *\n * Destructors normally run children first, so every item has unregistered by\n * the time `setup` tears down and cancelling there is enough. This flag\n * covers the other order: once `setup` has gone, a late unregister records\n * what it did but queues nothing, so no flush can fire against a tree that\n * no longer exists. `setup` clears it, which is what makes a re-run -- where\n * the destructor runs purely as a prelude to the body -- harmless.\n */\n #isTornDown = false;\n\n /**\n * The item that owns the composite's tab stop, by key.\n *\n * The ARIA listbox pattern allows exactly one tabbable option: the options\n * are stepped *into* once and then navigated with the arrow keys. Every\n * selected option carrying `tabindex=\"0\"` turned an eight-selection\n * multi-select into eight tab stops. The active item owns the stop, falling\n * back to the first selection, then to the first option a user can act on --\n * so a list nobody has touched yet is still reachable by Tab.\n *\n * Held as one tracked value rather than derived inside each option's getter:\n * a getter that had to look at every sibling would consume every sibling's\n * `isActive` tag, and the writes this class makes while Glimmer renders\n * would then dirty tags the same frame had just consumed. `#refreshTabStop`\n * reads the plain mirrors for the same reason, and this field is written\n * through a mirror guard of its own -- see `ListItem` above for the whole\n * story.\n */\n @tracked private _tabStopKey?: string;\n private tabStopKeyMirror?: string;\n\n searchKeys: string = '';\n args: ListManagerArgs = {\n selectionMode: 'none',\n selectedKeys: [],\n disabledKeys: [],\n allowEmpty: false,\n autoActivateMode: 'none'\n };\n\n constructor(args: ListManagerArgs = {}) {\n this.updateArgs(args);\n }\n\n /**\n * How this list selects, for consumers that have to render differently\n * depending on it.\n *\n * A menu row, for one, is only a `menuitemcheckbox` or `menuitemradio` when\n * the list actually selects -- and the row is handed the manager, not the\n * mode, so it has to be able to ask.\n *\n * Tracked, unlike the rest of `args`: this one is read while rendering, so a\n * consumer that flips `@selectionMode` has to repaint the rows that derive\n * their role from it. Left plain, `role` kept its old value while the item's\n * own tracked `isSelected` moved on, which lands `aria-checked` on a plain\n * `menuitem` -- the invalid ARIA the checkable roles exist to avoid.\n *\n * `args.selectionMode` is the plain mirror this is guarded against -- it is\n * already the untracked copy every internal read goes through, so no second\n * one is needed. `updateArgs` writes the pair together; see `ListItem` above\n * for why a redundant tracked write is worth avoiding.\n */\n @tracked private _selectionMode: SelectionMode = 'none';\n\n get selectionMode(): SelectionMode {\n return this._selectionMode;\n }\n\n /**\n * Registered items that are still in the document, in DOM order.\n *\n * The order cannot be maintained eagerly as items register: Glimmer moves\n * the element of an item that persists across an update instead of\n * re-creating it (no registration to react to), and it installs the\n * modifiers of newly rendered items before tearing down the ones they\n * replace — so a sort at registration time both misses later moves and\n * compares against detached elements, which `compareDocumentPosition`\n * orders arbitrarily. Deriving the order from the document when it is\n * needed keeps navigation in step with what the user sees.\n */\n get #orderedItems(): ListItem[] {\n return this.#items\n .filter((item) => item.el.isConnected)\n .sort((a, b) => {\n const position = a.el.compareDocumentPosition(b.el);\n if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1;\n if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1;\n return 0;\n });\n }\n\n /** Whether any registered item is still in the document. */\n get #hasVisibleItems(): boolean {\n return this.#items.some((item) => item.el.isConnected);\n }\n\n /** Whether `key` is the single option that carries `tabindex=\"0\"`. */\n isTabStop(key: string): boolean {\n return this._tabStopKey === key;\n }\n\n private set tabStopKey(value: string | undefined) {\n if (this.tabStopKeyMirror !== value) {\n this.tabStopKeyMirror = value;\n this._tabStopKey = value;\n }\n }\n\n /**\n * Work out which option owns the tab stop, reading only the untracked\n * mirrors so nothing is consumed on a path that can run mid-render.\n *\n * Only called from places where the answer can actually have changed and\n * where the DOM is worth ordering once: an activation, a selection update,\n * and the batch flush. Notably *not* from `unregister` -- see there.\n *\n * Pass `activated` when the caller already knows which item just became\n * active: the answer is then that item, with no need to order the document\n * at all. `setNextOptionActive` and friends have already paid for one\n * ordered scan to find it, and a second one would put the per-keypress cost\n * of `compareDocumentPosition` over the whole list -- the very cost this\n * batching removes from render -- straight back into arrow navigation.\n */\n #refreshTabStop(activated?: ListItem): void {\n // The scan below settles on the active item whenever there is one, so a\n // just-activated item *is* the answer -- unless it is disabled, which the\n // scan skips, in which case fall through and work it out properly.\n if (activated && !activated.isDisabledUntracked) {\n this.tabStopKey = activated.key;\n return;\n }\n\n let active: ListItem | undefined;\n let selected: ListItem | undefined;\n let first: ListItem | undefined;\n\n for (const item of this.#orderedItems) {\n if (item.isDisabledUntracked) continue;\n if (!first) first = item;\n if (!selected && item.isSelectedUntracked) selected = item;\n if (!active && item.isActiveUntracked) active = item;\n if (active) break;\n }\n\n this.tabStopKey = (active || selected || first)?.key;\n }\n\n register(\n el: HTMLLIElement | HTMLOptionElement,\n args: ListItemRegistration\n ): void {\n const newItem = new ListItem(el, args);\n if (\n this.args.autoActivateMode == 'first' &&\n !this.#hasVisibleItems &&\n !args.isDisabled\n ) {\n newItem.isActive = true;\n this.args.onActiveItemChange?.(newItem.key, newItem);\n }\n this.#items.push(newItem);\n\n // A first, cheap guess at the tab stop, so a freshly rendered list has a\n // tabbable option before the batch flush gets to work out the real answer.\n // Deliberately no `#refreshTabStop()` here: that orders the document, and\n // ordering it once per registration is the cost this batching removes.\n if (typeof this.tabStopKeyMirror === 'undefined' && !args.isDisabled) {\n this.tabStopKey = newItem.key;\n }\n\n this.#scheduleListChange('add');\n }\n\n unregister(el: HTMLLIElement | HTMLOptionElement): void {\n this.#items = this.#items.filter((item) => item.el !== el);\n\n // The tab stop is left pointing at the item that just went, and the flush\n // below corrects it a tick later. Clearing it here would write tracked\n // state while Glimmer tears down the elements it is replacing -- the same\n // render pass in which the surviving options have already read it for\n // their `tabindex` -- which is exactly the backtracking-rerender hazard\n // `ListItem` documents. For the tick in between, no option is tabbable;\n // the alternative is an assertion.\n\n this.#scheduleListChange('remove');\n }\n\n /**\n * Note what the batch did and make sure exactly one flush is queued for it.\n *\n * Always queued, even with no `onListItemsChange` and no auto-activation:\n * the tab stop has to be re-derived after any change to the membership, and\n * the flush is the only place the document is ordered once per batch rather\n * than once per item.\n */\n #scheduleListChange(action: 'add' | 'remove'): void {\n if (action === 'add') {\n this.#pendingAdd = true;\n } else {\n this.#pendingRemove = true;\n }\n this.#pendingAction = action;\n\n if (this.#isTornDown) {\n return;\n }\n\n cancel(this.#pendingTimer);\n this.#pendingTimer = later(this, this.#flushListChange, 1);\n }\n\n #flushListChange(): void {\n this.#pendingTimer = undefined;\n\n const added = this.#pendingAdd;\n const removed = this.#pendingRemove;\n const action = this.#pendingAction;\n this.#pendingAdd = false;\n this.#pendingRemove = false;\n this.#pendingAction = undefined;\n\n if (action && typeof this.args.onListItemsChange === 'function') {\n this.args.onListItemsChange(this.#orderedItems, action);\n }\n\n if (this.args.autoActivateMode === 'none' || !this.#hasVisibleItems) {\n this.#refreshTabStop();\n return;\n }\n\n if (added) {\n if (this.args.autoActivateMode === 'first') {\n this.setFirstOptionActive();\n } else {\n this.setSelectedOptionActive();\n }\n } else if (removed && this.args.autoActivateMode === 'first') {\n // The active item may have been the one that went.\n this.setFirstOptionActive();\n }\n\n this.#refreshTabStop();\n }\n\n /**\n * Drop whatever the current batch had queued.\n *\n * `ListManager` is a plain class, so the only teardown it can hook is the\n * destructor of the `setup` modifier that installed it -- which is where\n * this is called from. That destructor also runs when `setup`'s arguments\n * change, so `setup` re-queues a flush that was still pending; only a real\n * teardown never reaches the body again, and there the timer stays cancelled.\n */\n teardown(): void {\n cancel(this.#pendingTimer);\n this.#pendingTimer = undefined;\n this.#isTornDown = true;\n }\n\n /** Re-queue a batch that `teardown` cancelled but that has not run yet. */\n #resumePendingListChange(): void {\n this.#isTornDown = false;\n\n if (this.#pendingAction && !this.#pendingTimer) {\n this.#pendingTimer = later(this, this.#flushListChange, 1);\n }\n }\n\n at(el?: HTMLLIElement | HTMLOptionElement): ListItem | undefined {\n return this.#items.find((item) => item.el === el);\n }\n\n atKey(key: string): ListItem | undefined {\n return this.#items.find((item) => item.key === key);\n }\n\n updateArgs(args: ListManagerArgs): void {\n this.args.selectedKeys = args.selectedKeys || [];\n this.args.disabledKeys = args.disabledKeys || [];\n this.args.allowEmpty = args.allowEmpty || false;\n this.args.autoActivateMode = args.autoActivateMode || 'none';\n const selectionMode = args.selectionMode || 'none';\n if (this.args.selectionMode !== selectionMode) {\n this.args.selectionMode = selectionMode;\n this._selectionMode = selectionMode;\n }\n\n for (let i = 0; i < this.#items.length; i++) {\n const item = this.#items[i] as ListItem;\n item.isSelected = this.isKeySelected(item.key);\n item.isDisabled = this.isKeyDisabled(item.key);\n }\n\n // Callbacks are replaced whenever the caller *mentions* them, rather than\n // whenever it passes a truthy one.\n //\n // A manager is built once, in a component's field initializer, and only\n // `setup` runs again when arguments change -- so a callback that `setup`\n // does not carry can never be refreshed, and a `Listbox` whose `@onAction`\n // is rebuilt each render (`{{fn this.pick group.id}}` inside an\n // `{{#each}}`) went on calling the closure from its first render forever.\n //\n // The key has to decide it, not the value: `setup` names every callback it\n // owns, passing undefined when the consumer gave none, and that undefined\n // must win. A caller that owns only some of them -- NativeSelect hands its\n // own `onSelectionChange` to the constructor and only `onListItemsChange`\n // to `setup` -- leaves the rest unmentioned, and those keep what they have.\n if ('onAction' in args) {\n this.args.onAction = args.onAction;\n }\n\n if ('onSelectionChange' in args) {\n this.args.onSelectionChange = args.onSelectionChange;\n }\n\n if ('onListItemsChange' in args) {\n this.args.onListItemsChange = args.onListItemsChange;\n }\n\n if ('onActiveItemChange' in args) {\n this.args.onActiveItemChange = args.onActiveItemChange;\n }\n\n // The selection this just wrote onto the items may have moved the tab stop.\n this.#refreshTabStop();\n }\n\n selectActiveItem(): void {\n const item = this.#activeItem;\n if (item) {\n item.el.click();\n }\n }\n\n selectItem(item?: ListItem): void {\n if (item) {\n if (this.args.selectionMode !== 'none') {\n this.activateItem(item);\n }\n if (typeof this.args.onAction === 'function') {\n this.args.onAction(item.key);\n }\n\n if (\n typeof this.args.onSelectionChange === 'function' &&\n this.args.selectionMode !== 'none'\n ) {\n this.args.onSelectionChange(this.#toggleSelectedItem(item));\n }\n }\n }\n\n activateItem(item?: ListItem): void {\n // `isActiveUntracked`, not `isActive`: this read only decides whether to\n // write, and consuming the tag here would put the write below in the same\n // frame as a read of it — the hazard `ListItem` documents.\n if (item && !item.isActiveUntracked) {\n this.#clearActive();\n item.isActive = true;\n // The tab stop is this item, by definition -- named directly rather\n // than re-derived, so an arrow keypress orders the list only the once\n // its caller already did. See `#refreshTabStop`.\n this.#refreshTabStop(item);\n this.args.onActiveItemChange?.(item.key, item);\n\n // Ensure the item is scrolled into view\n requestAnimationFrame(() => {\n // The list may have been torn down between the write above and the\n // frame; scrolling a detached element to nowhere is pointless.\n //\n // This guard is not part of the batching fix and nothing reported it:\n // it is a latent bug this work made easy to see, because deferring\n // the batch widened the window in which a list can be torn down\n // between an activation and its frame. Kept here rather than left for\n // later, since it is two lines and the alternative is a stray\n // `scrollIntoView` on a detached node.\n if (item.el.isConnected) {\n item.el.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n }\n });\n }\n }\n\n setNextOptionActive(): void {\n const items = this.#orderedItems;\n for (let i = this.#indexOfActiveItem(items) + 1; i < items.length; i++) {\n const item = items[i];\n if (item && !item.isDisabled && !item.isActive) {\n this.activateItem(item);\n break;\n }\n }\n }\n\n setPreviousOptionActive(): void {\n const items = this.#orderedItems;\n for (let i = this.#indexOfActiveItem(items) - 1; i >= 0; i--) {\n const item = items[i];\n if (item && !item.isDisabled && !item.isActive) {\n this.activateItem(item);\n break;\n }\n }\n }\n\n setFirstOptionActive(): void {\n const items = this.#orderedItems;\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n if (item && !item.isDisabled) {\n this.activateItem(item);\n break;\n }\n }\n }\n\n setSelectedOptionActive(): void {\n const items = this.#orderedItems;\n let activated = false;\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n if (item && !item.isDisabled && item.isSelected) {\n this.activateItem(item);\n activated = true;\n break;\n }\n }\n\n if (!activated) {\n this.setFirstOptionActive();\n }\n }\n\n setLastOptionActive(): void {\n const items = this.#orderedItems;\n for (let i = items.length - 1; i >= 0; i--) {\n const item = items[i];\n if (item && !item.isDisabled) {\n this.activateItem(item);\n break;\n }\n }\n }\n\n search(key: string): void {\n debounce(this, this.#clearSearch, 500);\n this.searchKeys += key.toLowerCase();\n\n const items = this.#orderedItems;\n for (let i = 0; i < items.length; i++) {\n const item = items[i] as ListItem;\n\n if (\n !item.isDisabled &&\n this.searchKeys &&\n item.textValue.trim().toLowerCase().startsWith(this.searchKeys)\n ) {\n this.activateItem(item);\n break;\n }\n }\n }\n\n /**\n * Clears the type-ahead search buffer immediately, without waiting for the\n * debounced timeout that `search()` schedules. Consumers that select an\n * item outside of `search()` itself (e.g. pressing Enter mid-search) call\n * this so a stale buffer doesn't survive the selection.\n */\n clearSearch(): void {\n this.#clearSearch();\n }\n\n isKeyDisabled(key: string): boolean {\n return this.args.disabledKeys?.includes(key) || false;\n }\n\n isKeySelected(key: string): boolean {\n return this.args.selectedKeys?.includes(key) || false;\n }\n\n #indexOfActiveItem(items: ListItem[]): number {\n let item = items.find((i) => i.isActive);\n\n if (!item) {\n item = items.find((i) => i.isSelected);\n }\n if (!item) {\n return -1;\n }\n return items.indexOf(item);\n }\n\n /**\n * The selection `#toggleSelectedItem` starts from: the keys that are\n * selected right now, ordered the way it rebuilds them.\n */\n #selectionSnapshot(): string[] {\n const selectedKeys: string[] = [];\n\n const items = this.#orderedItems;\n\n // A selection is not the rendered list's to discard. Rebuilding purely\n // from `#orderedItems` drops every selected key whose item is not on\n // screen right now -- filtered out, most obviously -- so toggling one\n // option in a filtered multi-select used to wipe the rest of the\n // selection. Carry those keys over from the authoritative list instead.\n //\n // They go first so the rebuilt array keeps the shape it always had: when\n // nothing is hidden this set is empty and the result is exactly the DOM\n // -ordered scan below, unchanged.\n //\n // `multiple` only. Single mode replaces the selection outright, so it\n // never lost anything here, and carrying a key over would change what\n // counts as \"the last selection\" for the `allowEmpty` rule\n // (`canDeselectKey`).\n if (this.args.selectionMode === 'multiple') {\n const renderedKeys = new Set(items.map((_item) => _item.key));\n for (const key of this.args.selectedKeys || []) {\n if (!renderedKeys.has(key)) {\n selectedKeys.push(key);\n }\n }\n }\n\n for (let i = 0; i < items.length; i++) {\n const _item = items[i] as ListItem;\n if (_item.isSelected) {\n selectedKeys.push(_item.key);\n }\n }\n\n return selectedKeys;\n }\n\n #toggleSelectedItem(item: ListItem): string[] {\n let selectedKeys = this.#selectionSnapshot();\n\n if (canDeselectKey(selectedKeys, item.key, this.args.allowEmpty)) {\n const indexToRemove = selectedKeys.indexOf(item.key);\n selectedKeys.splice(indexToRemove, 1);\n } else {\n if (this.args.selectionMode === 'single') {\n selectedKeys = [item.key];\n } else if (!selectedKeys.includes(item.key)) {\n selectedKeys.push(item.key);\n }\n }\n\n return selectedKeys;\n }\n\n get #activeItem(): ListItem | undefined {\n return this.#orderedItems.find((item) => item.isActive);\n }\n\n #clearSearch(): void {\n this.searchKeys = '';\n }\n\n #clearActive(): void {\n for (let i = 0; i < this.#items.length; i++) {\n // No `isActive` check: the setter already skips unchanged values, and\n // reading it here would consume every item's tag on a path that can run\n // mid-render.\n (this.#items[i] as ListItem).isActive = false;\n }\n }\n\n setup = modifier(\n (\n _el: HTMLUListElement | HTMLSelectElement,\n _: unknown[],\n args: ListManagerArgs\n ) => {\n this.updateArgs(args);\n\n // This modifier's destructor also runs before every re-invocation, so a\n // flush it cancelled while the list was still very much alive has to be\n // put back. Only a real teardown never reaches this line again.\n this.#resumePendingListChange();\n\n return (): void => {\n this.teardown();\n };\n }\n );\n\n setupItem = modifier(\n (\n el: HTMLLIElement | HTMLOptionElement,\n _: unknown[],\n args: Pick<ListItemArgs, 'key' | 'textValue' | 'item'> & {\n onRegister?: (item: ListItem) => void;\n disableEvents?: boolean;\n }\n ) => {\n let textValue = args.textValue;\n if (\n typeof textValue === 'undefined' ||\n textValue === '' ||\n textValue === null\n ) {\n // `aria-labelledby` is not a selector: it holds a *space-separated\n // list* of ids, and those ids are resolved against the whole\n // document, not against this element's subtree. Treating the raw\n // value as `#id` therefore turned a multi-id label into a descendant\n // selector that matches nothing, missed labels living outside the\n // item — leaving `textValue` empty and type-ahead search broken — and\n // threw outright on any id that is not a valid CSS identifier.\n const labelledBy = el.getAttribute('aria-labelledby');\n const labelId = labelledBy?.trim().split(/\\s+/)[0];\n\n if (labelId) {\n const labelElement = getElementById(el.ownerDocument, labelId);\n if (labelElement) {\n textValue = labelElement.textContent?.trim() || '';\n }\n }\n\n // Still nothing — either there was no label, or the id it named is\n // not in the document — so fall back to the item's own text.\n if (!textValue) {\n textValue = el.textContent?.trim() || '';\n }\n }\n\n this.register(el as HTMLLIElement, {\n key: args.key,\n textValue: textValue || '',\n item: args.item,\n isActive: false,\n isDisabled: this.isKeyDisabled(args.key),\n isSelected: this.isKeySelected(args.key)\n });\n const item = this.at(el);\n if (item && typeof args.onRegister === 'function') {\n args.onRegister(item);\n }\n\n const mouseEnter = (): void => {\n this.activateItem(item);\n };\n\n const mouseLeave = (): void => {\n if (item) {\n item.isActive = false;\n }\n };\n\n // Glimmer mutates this item's DOM during a render — rewriting `tabindex`\n // on the focused item, or clearing the block that contains it — and the\n // browser reacts by blurring the element and dispatching `focusout`\n // synchronously, inside the frame that just consumed `isActive` (see\n // `ListItem` above). Those blurs carry no `relatedTarget`.\n //\n // Neither do some genuine ones: clicking a non-focusable region,\n // switching tab or window, or moving focus to browser chrome. Ignoring\n // every targetless blur therefore trades a possibly-stale highlight for\n // never writing tracked state mid-render. That is a good trade here —\n // for a roving-tabindex widget, keeping the active item across a blur is\n // closer to the ARIA pattern than clearing it.\n const focusOut = (event: Event): void => {\n if ((event as FocusEvent).relatedTarget === null) {\n return;\n }\n mouseLeave();\n };\n\n if (!args.disableEvents) {\n el.addEventListener('mouseenter', mouseEnter);\n el.addEventListener('mouseleave', mouseLeave);\n\n el.addEventListener('focusin', mouseEnter);\n el.addEventListener('focusout', focusOut);\n }\n\n return (): void => {\n this.unregister(el);\n\n if (!args.disableEvents) {\n el.removeEventListener('mouseenter', mouseEnter);\n el.removeEventListener('mouseleave', mouseLeave);\n\n el.removeEventListener('focusin', mouseEnter);\n el.removeEventListener('focusout', focusOut);\n }\n };\n }\n );\n}\n\n/**\n * The `allowEmpty` deselect rule, in one place.\n *\n * Given the keys that make up a selection, whether `key` may be taken out of\n * it: a key that is not in the selection has nothing to remove, and the last\n * remaining key only goes when emptying the selection is allowed.\n *\n * `selectionMode` deliberately plays no part. It decides how a selection is\n * built, not whether it may shrink -- see `#selectionSnapshot`.\n */\nfunction canDeselectKey(\n selectedKeys: string[],\n key: string,\n allowEmpty: boolean = false\n): boolean {\n if (!selectedKeys.includes(key)) {\n return false;\n }\n return (allowEmpty && selectedKeys.length == 1) || selectedKeys.length > 1;\n}\n\nfunction keyAndLabelForItem(item: unknown): { key: string; label: string } {\n // Handle primitive types directly\n if (typeof item === 'string' || typeof item === 'number') {\n const value = item.toString();\n return { key: value, label: value };\n }\n\n // If the item is an object, try to extract key and label using common property names\n if (typeof item === 'object' && item !== null) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const typedItem = item as any;\n\n // Try to use the 'key' property first; if not available, use 'id'\n let keyProp = typedItem.key || typedItem.id;\n if (keyProp === undefined) {\n keyProp = item.toString();\n }\n\n // Determine the label by checking multiple possible properties\n let labelProp =\n typedItem.label || typedItem.value || typedItem.name || typedItem.title;\n if (labelProp === undefined) {\n labelProp = item.toString();\n }\n\n return { key: keyProp.toString(), label: labelProp.toString() };\n }\n\n // Fallback if item does not match expected types\n return { key: '', label: '' };\n}\n\nexport type {\n ListItem,\n ListItemArgs,\n ListItemRegistration,\n SelectionMode,\n AutoActivateMode\n};\n// `defaultFilter` and `FilterFn` live in ./filter now. They are re-exported\n// here, unused by this module, because this was their public path before the\n// move and consumers import them from it.\nexport { ListManager, canDeselectKey, keyAndLabelForItem, defaultFilter };\nexport type { FilterFn };\n"],"names":["ListItem","el","key","textValue","item","g","prototype","tracked","i","isSelectedMirror","isDisabledMirror","isActiveMirror","isSelected","_isSelected","value","isDisabled","_isDisabled","isActive","_isActive","isActiveUntracked","isSelectedUntracked","isDisabledUntracked","constructor","args","ListManager","tabStopKeyMirror","searchKeys","selectionMode","selectedKeys","disabledKeys","allowEmpty","autoActivateMode","updateArgs","_selectionMode","#orderedItems","filter","isConnected","sort","a","b","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","#hasVisibleItems","some","isTabStop","_tabStopKey","tabStopKey","#refreshTabStop","activated","active","selected","first","register","newItem","onActiveItemChange","push","unregister","#scheduleListChange","action","cancel","later","#flushListChange","undefined","added","removed","onListItemsChange","setFirstOptionActive","setSelectedOptionActive","teardown","#resumePendingListChange","at","find","atKey","length","isKeySelected","isKeyDisabled","onAction","onSelectionChange","selectActiveItem","click","selectItem","activateItem","requestAnimationFrame","scrollIntoView","block","inline","setNextOptionActive","items","setPreviousOptionActive","setLastOptionActive","search","debounce","toLowerCase","trim","startsWith","clearSearch","includes","#indexOfActiveItem","indexOf","#selectionSnapshot","renderedKeys","Set","map","_item","has","#toggleSelectedItem","canDeselectKey","indexToRemove","splice","#activeItem","#clearSearch","#clearActive","setup","modifier","_el","_","setupItem","labelledBy","getAttribute","labelId","split","labelElement","getElementById","ownerDocument","textContent","onRegister","mouseEnter","mouseLeave","focusOut","event","relatedTarget","disableEvents","addEventListener","removeEventListener","keyAndLabelForItem","toString","label","typedItem","keyProp","id","labelProp","name","title"],"mappings":";;;;;;;AAkCA,MAAMA,QAAQ,CAAC;EACbC,EAAE;EACFC,GAAG;EACHC,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;EACAC,IAAI;;AAEJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,aAAA,EAAA,CACCC,OAAO,CAAA,CAAA;AAAA;EAAA,YAAA,IAAAC,2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;AAAExI,MAAAA,GAAG,EAAEY,KAAK;AAAE6H,MAAAA,KAAK,EAAE7H;KAAO;AACrC,EAAA;;AAEA;EACA,IAAI,OAAOV,IAAI,KAAK,QAAQ,IAAIA,IAAI,KAAK,IAAI,EAAE;AAC7C;IACA,MAAMwI,SAAS,GAAGxI,IAAW;;AAE7B;IACA,IAAIyI,OAAO,GAAGD,SAAS,CAAC1I,GAAG,IAAI0I,SAAS,CAACE,EAAE;IAC3C,IAAID,OAAO,KAAK5E,SAAS,EAAE;AACzB4E,MAAAA,OAAO,GAAGzI,IAAI,CAACsI,QAAQ,EAAE;AAC3B,IAAA;;AAEA;AACA,IAAA,IAAIK,SAAS,GACXH,SAAS,CAACD,KAAK,IAAIC,SAAS,CAAC9H,KAAK,IAAI8H,SAAS,CAACI,IAAI,IAAIJ,SAAS,CAACK,KAAK;IACzE,IAAIF,SAAS,KAAK9E,SAAS,EAAE;AAC3B8E,MAAAA,SAAS,GAAG3I,IAAI,CAACsI,QAAQ,EAAE;AAC7B,IAAA;IAEA,OAAO;AAAExI,MAAAA,GAAG,EAAE2I,OAAO,CAACH,QAAQ,EAAE;AAAEC,MAAAA,KAAK,EAAEI,SAAS,CAACL,QAAQ;KAAI;AACjE,EAAA;;AAEA;EACA,OAAO;AAAExI,IAAAA,GAAG,EAAE,EAAE;AAAEyI,IAAAA,KAAK,EAAE;GAAI;AAC/B;;"}
|
|
1
|
+
{"version":3,"file":"listManager.js","sources":["../../src/utils/listManager.ts"],"sourcesContent":["import { tracked } from '@glimmer/tracking';\nimport { cancel, debounce, later } from '@ember/runloop';\nimport { modifier } from 'ember-modifier';\nimport type { Timer } from '@ember/runloop';\nimport { getElementById } from '../-private/dom';\nimport { defaultFilter, type FilterFn } from './filter';\n\ntype SelectionMode = 'none' | 'single' | 'multiple';\ntype AutoActivateMode = 'none' | 'first' | 'selected';\n\ninterface ListItemArgs {\n key: string;\n textValue?: string;\n isSelected?: boolean;\n isDisabled?: boolean;\n isActive?: boolean;\n\n /**\n * The entry of the collection this item was rendered from, so consumers of a\n * selection can reach their own object rather than only its key and text.\n *\n * Undefined when there is no such object: an item written out in block form\n * is not backed by a collection entry, so nothing is invented for it.\n */\n item?: unknown;\n}\n\n/**\n * What `register` needs: every display flag resolved, and the source item\n * carried along if the caller has one.\n */\ntype ListItemRegistration = Required<Omit<ListItemArgs, 'item'>> &\n Pick<ListItemArgs, 'item'>;\n\nclass ListItem {\n el: HTMLLIElement | HTMLOptionElement;\n key: string;\n textValue: string;\n\n // Not tracked, and deliberately so. This is fixed at registration: the\n // element and its source entry arrive together, and a change to either\n // re-runs `setupItem`, which unregisters this item and registers a fresh\n // one. Making it tracked would add a settable tag to a class whose every\n // other field needs the mirror guards below to stay clear of Glimmer's\n // read-then-write assertion, for a value that is never written again.\n item?: unknown;\n\n // Ember's tracked setter dirties a tag unconditionally — it never compares\n // against the current value. That makes a redundant write more than wasted\n // work here: Glimmer reads an attribute and writes it to the DOM inside a\n // single autotracking frame, and writing `tabindex` onto the focused item\n // blurs it, so the browser dispatches `focusout` synchronously and this\n // item's own listeners run *inside* the frame that just consumed `isActive`.\n // Dirtying a tag that frame already consumed trips a backtracking-rerender\n // assertion, so every field below only writes on a real change.\n //\n // Each comparison reads a plain mirror rather than the tracked field itself.\n // Reading the tracked field would *consume* its tag, so the write that\n // followed would dirty a tag the current frame had just consumed — precisely\n // the failure these guards exist to prevent. For the same reason, code that\n // reads a field only to decide whether to write it should read the mirror;\n // `isActiveUntracked` exposes that for the one caller outside this class.\n @tracked private _isSelected: boolean;\n @tracked private _isDisabled: boolean;\n @tracked private _isActive: boolean;\n\n private isSelectedMirror: boolean;\n private isDisabledMirror: boolean;\n private isActiveMirror: boolean;\n\n get isSelected(): boolean {\n return this._isSelected;\n }\n\n set isSelected(value: boolean) {\n if (this.isSelectedMirror !== value) {\n this.isSelectedMirror = value;\n this._isSelected = value;\n }\n }\n\n get isDisabled(): boolean {\n return this._isDisabled;\n }\n\n set isDisabled(value: boolean) {\n if (this.isDisabledMirror !== value) {\n this.isDisabledMirror = value;\n this._isDisabled = value;\n }\n }\n\n get isActive(): boolean {\n return this._isActive;\n }\n\n set isActive(value: boolean) {\n if (this.isActiveMirror !== value) {\n this.isActiveMirror = value;\n this._isActive = value;\n }\n }\n\n /**\n * The three flags read without consuming their tags, for write decisions and\n * for `ListManager`'s tab-stop bookkeeping -- which has to look at every\n * sibling and must not drag every sibling's tag into the frame that does so.\n */\n get isActiveUntracked(): boolean {\n return this.isActiveMirror;\n }\n\n get isSelectedUntracked(): boolean {\n return this.isSelectedMirror;\n }\n\n get isDisabledUntracked(): boolean {\n return this.isDisabledMirror;\n }\n\n /**\n * Disabled by the item itself (`setupItem`'s `isDisabled`), on top of the\n * manager's `disabledKeys`. Fixed at registration like `item`: a change\n * re-runs `setupItem`, which registers a fresh item.\n */\n isDisabledByItem = false;\n\n constructor(\n el: HTMLLIElement | HTMLOptionElement,\n args: ListItemRegistration\n ) {\n this.el = el;\n this.key = args.key;\n this.textValue = args.textValue;\n this.item = args.item;\n this._isSelected = this.isSelectedMirror = args.isSelected;\n this._isDisabled = this.isDisabledMirror = args.isDisabled;\n this._isActive = this.isActiveMirror = args.isActive;\n }\n}\n\ninterface ListManagerArgs {\n selectionMode?: SelectionMode;\n selectedKeys?: string[];\n disabledKeys?: string[];\n allowEmpty?: boolean;\n autoActivateMode?: AutoActivateMode;\n onAction?: (key: string) => void;\n onSelectionChange?: (key: string[]) => void;\n onListItemsChange?: (items: ListItem[], action: 'add' | 'remove') => void;\n onActiveItemChange?: (key?: string, item?: ListItem) => void;\n}\n\nclass ListManager {\n #items: ListItem[] = [];\n\n /**\n * The one pending \"the list changed\" task, and what the batch behind it did.\n *\n * Registration is per item, but everything that follows it -- ordering the\n * list against the document, telling the consumer what the list now holds,\n * and moving the active item -- belongs to the *batch*. Doing it per\n * registration made a 500-option Select order 500 nodes 500 times over and\n * queue 500 timers, each ordering them again, none of them cancelled. One\n * timer, replaced whenever another item registers or unregisters, does the\n * work once against the finished DOM.\n *\n * Deferring is not only cheaper, it is more accurate: mid-batch the document\n * still holds the elements Glimmer is about to tear down, so the orders\n * computed then were partly garbage (see `#orderedItems`).\n */\n #pendingTimer?: Timer;\n #pendingAdd = false;\n #pendingRemove = false;\n #pendingAction?: 'add' | 'remove';\n\n /**\n * Whether the `setup` modifier has been torn down without being re-installed.\n *\n * Destructors normally run children first, so every item has unregistered by\n * the time `setup` tears down and cancelling there is enough. This flag\n * covers the other order: once `setup` has gone, a late unregister records\n * what it did but queues nothing, so no flush can fire against a tree that\n * no longer exists. `setup` clears it, which is what makes a re-run -- where\n * the destructor runs purely as a prelude to the body -- harmless.\n */\n #isTornDown = false;\n\n /**\n * The item that owns the composite's tab stop, by key.\n *\n * The ARIA listbox pattern allows exactly one tabbable option: the options\n * are stepped *into* once and then navigated with the arrow keys. Every\n * selected option carrying `tabindex=\"0\"` turned an eight-selection\n * multi-select into eight tab stops. The active item owns the stop, falling\n * back to the first selection, then to the first option a user can act on --\n * so a list nobody has touched yet is still reachable by Tab.\n *\n * Held as one tracked value rather than derived inside each option's getter:\n * a getter that had to look at every sibling would consume every sibling's\n * `isActive` tag, and the writes this class makes while Glimmer renders\n * would then dirty tags the same frame had just consumed. `#refreshTabStop`\n * reads the plain mirrors for the same reason, and this field is written\n * through a mirror guard of its own -- see `ListItem` above for the whole\n * story.\n */\n @tracked private _tabStopKey?: string;\n private tabStopKeyMirror?: string;\n\n searchKeys: string = '';\n args: ListManagerArgs = {\n selectionMode: 'none',\n selectedKeys: [],\n disabledKeys: [],\n allowEmpty: false,\n autoActivateMode: 'none'\n };\n\n constructor(args: ListManagerArgs = {}) {\n this.updateArgs(args);\n }\n\n /**\n * How this list selects, for consumers that have to render differently\n * depending on it.\n *\n * A menu row, for one, is only a `menuitemcheckbox` or `menuitemradio` when\n * the list actually selects -- and the row is handed the manager, not the\n * mode, so it has to be able to ask.\n *\n * Tracked, unlike the rest of `args`: this one is read while rendering, so a\n * consumer that flips `@selectionMode` has to repaint the rows that derive\n * their role from it. Left plain, `role` kept its old value while the item's\n * own tracked `isSelected` moved on, which lands `aria-checked` on a plain\n * `menuitem` -- the invalid ARIA the checkable roles exist to avoid.\n *\n * `args.selectionMode` is the plain mirror this is guarded against -- it is\n * already the untracked copy every internal read goes through, so no second\n * one is needed. `updateArgs` writes the pair together; see `ListItem` above\n * for why a redundant tracked write is worth avoiding.\n */\n @tracked private _selectionMode: SelectionMode = 'none';\n\n get selectionMode(): SelectionMode {\n return this._selectionMode;\n }\n\n /**\n * Registered items that are still in the document, in DOM order.\n *\n * The order cannot be maintained eagerly as items register: Glimmer moves\n * the element of an item that persists across an update instead of\n * re-creating it (no registration to react to), and it installs the\n * modifiers of newly rendered items before tearing down the ones they\n * replace — so a sort at registration time both misses later moves and\n * compares against detached elements, which `compareDocumentPosition`\n * orders arbitrarily. Deriving the order from the document when it is\n * needed keeps navigation in step with what the user sees.\n */\n get #orderedItems(): ListItem[] {\n return this.#items\n .filter((item) => item.el.isConnected)\n .sort((a, b) => {\n const position = a.el.compareDocumentPosition(b.el);\n if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1;\n if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1;\n return 0;\n });\n }\n\n /** Whether any registered item is still in the document. */\n get #hasVisibleItems(): boolean {\n return this.#items.some((item) => item.el.isConnected);\n }\n\n /** Whether `key` is the single option that carries `tabindex=\"0\"`. */\n isTabStop(key: string): boolean {\n return this._tabStopKey === key;\n }\n\n private set tabStopKey(value: string | undefined) {\n if (this.tabStopKeyMirror !== value) {\n this.tabStopKeyMirror = value;\n this._tabStopKey = value;\n }\n }\n\n /**\n * Work out which option owns the tab stop, reading only the untracked\n * mirrors so nothing is consumed on a path that can run mid-render.\n *\n * Only called from places where the answer can actually have changed and\n * where the DOM is worth ordering once: an activation, a selection update,\n * and the batch flush. Notably *not* from `unregister` -- see there.\n *\n * Pass `activated` when the caller already knows which item just became\n * active: the answer is then that item, with no need to order the document\n * at all. `setNextOptionActive` and friends have already paid for one\n * ordered scan to find it, and a second one would put the per-keypress cost\n * of `compareDocumentPosition` over the whole list -- the very cost this\n * batching removes from render -- straight back into arrow navigation.\n */\n #refreshTabStop(activated?: ListItem): void {\n // The scan below settles on the active item whenever there is one, so a\n // just-activated item *is* the answer -- unless it is disabled, which the\n // scan skips, in which case fall through and work it out properly.\n if (activated && !activated.isDisabledUntracked) {\n this.tabStopKey = activated.key;\n return;\n }\n\n let active: ListItem | undefined;\n let selected: ListItem | undefined;\n let first: ListItem | undefined;\n\n for (const item of this.#orderedItems) {\n if (item.isDisabledUntracked) continue;\n if (!first) first = item;\n if (!selected && item.isSelectedUntracked) selected = item;\n if (!active && item.isActiveUntracked) active = item;\n if (active) break;\n }\n\n this.tabStopKey = (active || selected || first)?.key;\n }\n\n register(\n el: HTMLLIElement | HTMLOptionElement,\n args: ListItemRegistration\n ): void {\n const newItem = new ListItem(el, args);\n if (\n this.args.autoActivateMode == 'first' &&\n !this.#hasVisibleItems &&\n !args.isDisabled\n ) {\n newItem.isActive = true;\n this.args.onActiveItemChange?.(newItem.key, newItem);\n }\n this.#items.push(newItem);\n\n // A first, cheap guess at the tab stop, so a freshly rendered list has a\n // tabbable option before the batch flush gets to work out the real answer.\n // Deliberately no `#refreshTabStop()` here: that orders the document, and\n // ordering it once per registration is the cost this batching removes.\n if (typeof this.tabStopKeyMirror === 'undefined' && !args.isDisabled) {\n this.tabStopKey = newItem.key;\n }\n\n this.#scheduleListChange('add');\n }\n\n unregister(el: HTMLLIElement | HTMLOptionElement): void {\n this.#items = this.#items.filter((item) => item.el !== el);\n\n // The tab stop is left pointing at the item that just went, and the flush\n // below corrects it a tick later. Clearing it here would write tracked\n // state while Glimmer tears down the elements it is replacing -- the same\n // render pass in which the surviving options have already read it for\n // their `tabindex` -- which is exactly the backtracking-rerender hazard\n // `ListItem` documents. For the tick in between, no option is tabbable;\n // the alternative is an assertion.\n\n this.#scheduleListChange('remove');\n }\n\n /**\n * Note what the batch did and make sure exactly one flush is queued for it.\n *\n * Always queued, even with no `onListItemsChange` and no auto-activation:\n * the tab stop has to be re-derived after any change to the membership, and\n * the flush is the only place the document is ordered once per batch rather\n * than once per item.\n */\n #scheduleListChange(action: 'add' | 'remove'): void {\n if (action === 'add') {\n this.#pendingAdd = true;\n } else {\n this.#pendingRemove = true;\n }\n this.#pendingAction = action;\n\n if (this.#isTornDown) {\n return;\n }\n\n cancel(this.#pendingTimer);\n this.#pendingTimer = later(this, this.#flushListChange, 1);\n }\n\n #flushListChange(): void {\n this.#pendingTimer = undefined;\n\n const added = this.#pendingAdd;\n const removed = this.#pendingRemove;\n const action = this.#pendingAction;\n this.#pendingAdd = false;\n this.#pendingRemove = false;\n this.#pendingAction = undefined;\n\n if (action && typeof this.args.onListItemsChange === 'function') {\n this.args.onListItemsChange(this.#orderedItems, action);\n }\n\n if (this.args.autoActivateMode === 'none' || !this.#hasVisibleItems) {\n this.#refreshTabStop();\n return;\n }\n\n if (added) {\n if (this.args.autoActivateMode === 'first') {\n this.setFirstOptionActive();\n } else {\n this.setSelectedOptionActive();\n }\n } else if (removed && this.args.autoActivateMode === 'first') {\n // The active item may have been the one that went.\n this.setFirstOptionActive();\n }\n\n this.#refreshTabStop();\n }\n\n /**\n * Drop whatever the current batch had queued.\n *\n * `ListManager` is a plain class, so the only teardown it can hook is the\n * destructor of the `setup` modifier that installed it -- which is where\n * this is called from. That destructor also runs when `setup`'s arguments\n * change, so `setup` re-queues a flush that was still pending; only a real\n * teardown never reaches the body again, and there the timer stays cancelled.\n */\n teardown(): void {\n cancel(this.#pendingTimer);\n this.#pendingTimer = undefined;\n this.#isTornDown = true;\n }\n\n /** Re-queue a batch that `teardown` cancelled but that has not run yet. */\n #resumePendingListChange(): void {\n this.#isTornDown = false;\n\n if (this.#pendingAction && !this.#pendingTimer) {\n this.#pendingTimer = later(this, this.#flushListChange, 1);\n }\n }\n\n at(el?: HTMLLIElement | HTMLOptionElement): ListItem | undefined {\n return this.#items.find((item) => item.el === el);\n }\n\n atKey(key: string): ListItem | undefined {\n return this.#items.find((item) => item.key === key);\n }\n\n updateArgs(args: ListManagerArgs): void {\n this.args.selectedKeys = args.selectedKeys || [];\n this.args.disabledKeys = args.disabledKeys || [];\n this.args.allowEmpty = args.allowEmpty || false;\n this.args.autoActivateMode = args.autoActivateMode || 'none';\n const selectionMode = args.selectionMode || 'none';\n if (this.args.selectionMode !== selectionMode) {\n this.args.selectionMode = selectionMode;\n this._selectionMode = selectionMode;\n }\n\n for (let i = 0; i < this.#items.length; i++) {\n const item = this.#items[i] as ListItem;\n item.isSelected = this.isKeySelected(item.key);\n item.isDisabled = item.isDisabledByItem || this.isKeyDisabled(item.key);\n }\n\n // Callbacks are replaced whenever the caller *mentions* them, rather than\n // whenever it passes a truthy one.\n //\n // A manager is built once, in a component's field initializer, and only\n // `setup` runs again when arguments change -- so a callback that `setup`\n // does not carry can never be refreshed, and a `Listbox` whose `@onAction`\n // is rebuilt each render (`{{fn this.pick group.id}}` inside an\n // `{{#each}}`) went on calling the closure from its first render forever.\n //\n // The key has to decide it, not the value: `setup` names every callback it\n // owns, passing undefined when the consumer gave none, and that undefined\n // must win. A caller that owns only some of them -- NativeSelect hands its\n // own `onSelectionChange` to the constructor and only `onListItemsChange`\n // to `setup` -- leaves the rest unmentioned, and those keep what they have.\n if ('onAction' in args) {\n this.args.onAction = args.onAction;\n }\n\n if ('onSelectionChange' in args) {\n this.args.onSelectionChange = args.onSelectionChange;\n }\n\n if ('onListItemsChange' in args) {\n this.args.onListItemsChange = args.onListItemsChange;\n }\n\n if ('onActiveItemChange' in args) {\n this.args.onActiveItemChange = args.onActiveItemChange;\n }\n\n // The selection this just wrote onto the items may have moved the tab stop.\n this.#refreshTabStop();\n }\n\n selectActiveItem(): void {\n const item = this.#activeItem;\n if (item) {\n item.el.click();\n }\n }\n\n selectItem(item?: ListItem): void {\n if (item) {\n if (this.args.selectionMode !== 'none') {\n this.activateItem(item);\n }\n if (typeof this.args.onAction === 'function') {\n this.args.onAction(item.key);\n }\n\n if (\n typeof this.args.onSelectionChange === 'function' &&\n this.args.selectionMode !== 'none'\n ) {\n this.args.onSelectionChange(this.#toggleSelectedItem(item));\n }\n }\n }\n\n activateItem(item?: ListItem): void {\n // `isActiveUntracked`, not `isActive`: this read only decides whether to\n // write, and consuming the tag here would put the write below in the same\n // frame as a read of it — the hazard `ListItem` documents.\n if (item && !item.isActiveUntracked) {\n this.#clearActive();\n item.isActive = true;\n // The tab stop is this item, by definition -- named directly rather\n // than re-derived, so an arrow keypress orders the list only the once\n // its caller already did. See `#refreshTabStop`.\n this.#refreshTabStop(item);\n this.args.onActiveItemChange?.(item.key, item);\n\n // Ensure the item is scrolled into view\n requestAnimationFrame(() => {\n // The list may have been torn down between the write above and the\n // frame; scrolling a detached element to nowhere is pointless.\n //\n // This guard is not part of the batching fix and nothing reported it:\n // it is a latent bug this work made easy to see, because deferring\n // the batch widened the window in which a list can be torn down\n // between an activation and its frame. Kept here rather than left for\n // later, since it is two lines and the alternative is a stray\n // `scrollIntoView` on a detached node.\n if (item.el.isConnected) {\n item.el.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n }\n });\n }\n }\n\n setNextOptionActive(): void {\n const items = this.#orderedItems;\n for (let i = this.#indexOfActiveItem(items) + 1; i < items.length; i++) {\n const item = items[i];\n if (item && !item.isDisabled && !item.isActive) {\n this.activateItem(item);\n break;\n }\n }\n }\n\n setPreviousOptionActive(): void {\n const items = this.#orderedItems;\n for (let i = this.#indexOfActiveItem(items) - 1; i >= 0; i--) {\n const item = items[i];\n if (item && !item.isDisabled && !item.isActive) {\n this.activateItem(item);\n break;\n }\n }\n }\n\n setFirstOptionActive(): void {\n const items = this.#orderedItems;\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n if (item && !item.isDisabled) {\n this.activateItem(item);\n break;\n }\n }\n }\n\n setSelectedOptionActive(): void {\n const items = this.#orderedItems;\n let activated = false;\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n if (item && !item.isDisabled && item.isSelected) {\n this.activateItem(item);\n activated = true;\n break;\n }\n }\n\n if (!activated) {\n this.setFirstOptionActive();\n }\n }\n\n setLastOptionActive(): void {\n const items = this.#orderedItems;\n for (let i = items.length - 1; i >= 0; i--) {\n const item = items[i];\n if (item && !item.isDisabled) {\n this.activateItem(item);\n break;\n }\n }\n }\n\n search(key: string): void {\n debounce(this, this.#clearSearch, 500);\n this.searchKeys += key.toLowerCase();\n\n const items = this.#orderedItems;\n for (let i = 0; i < items.length; i++) {\n const item = items[i] as ListItem;\n\n if (\n !item.isDisabled &&\n this.searchKeys &&\n item.textValue.trim().toLowerCase().startsWith(this.searchKeys)\n ) {\n this.activateItem(item);\n break;\n }\n }\n }\n\n /**\n * Clears the type-ahead search buffer immediately, without waiting for the\n * debounced timeout that `search()` schedules. Consumers that select an\n * item outside of `search()` itself (e.g. pressing Enter mid-search) call\n * this so a stale buffer doesn't survive the selection.\n */\n clearSearch(): void {\n this.#clearSearch();\n }\n\n isKeyDisabled(key: string): boolean {\n return this.args.disabledKeys?.includes(key) || false;\n }\n\n isKeySelected(key: string): boolean {\n return this.args.selectedKeys?.includes(key) || false;\n }\n\n #indexOfActiveItem(items: ListItem[]): number {\n let item = items.find((i) => i.isActive);\n\n if (!item) {\n item = items.find((i) => i.isSelected);\n }\n if (!item) {\n return -1;\n }\n return items.indexOf(item);\n }\n\n /**\n * The selection `#toggleSelectedItem` starts from: the keys that are\n * selected right now, ordered the way it rebuilds them.\n */\n #selectionSnapshot(): string[] {\n const selectedKeys: string[] = [];\n\n const items = this.#orderedItems;\n\n // A selection is not the rendered list's to discard. Rebuilding purely\n // from `#orderedItems` drops every selected key whose item is not on\n // screen right now -- filtered out, most obviously -- so toggling one\n // option in a filtered multi-select used to wipe the rest of the\n // selection. Carry those keys over from the authoritative list instead.\n //\n // They go first so the rebuilt array keeps the shape it always had: when\n // nothing is hidden this set is empty and the result is exactly the DOM\n // -ordered scan below, unchanged.\n //\n // `multiple` only. Single mode replaces the selection outright, so it\n // never lost anything here, and carrying a key over would change what\n // counts as \"the last selection\" for the `allowEmpty` rule\n // (`canDeselectKey`).\n if (this.args.selectionMode === 'multiple') {\n const renderedKeys = new Set(items.map((_item) => _item.key));\n for (const key of this.args.selectedKeys || []) {\n if (!renderedKeys.has(key)) {\n selectedKeys.push(key);\n }\n }\n }\n\n for (let i = 0; i < items.length; i++) {\n const _item = items[i] as ListItem;\n if (_item.isSelected) {\n selectedKeys.push(_item.key);\n }\n }\n\n return selectedKeys;\n }\n\n #toggleSelectedItem(item: ListItem): string[] {\n let selectedKeys = this.#selectionSnapshot();\n\n if (canDeselectKey(selectedKeys, item.key, this.args.allowEmpty)) {\n const indexToRemove = selectedKeys.indexOf(item.key);\n selectedKeys.splice(indexToRemove, 1);\n } else {\n if (this.args.selectionMode === 'single') {\n selectedKeys = [item.key];\n } else if (!selectedKeys.includes(item.key)) {\n selectedKeys.push(item.key);\n }\n }\n\n return selectedKeys;\n }\n\n get #activeItem(): ListItem | undefined {\n return this.#orderedItems.find((item) => item.isActive);\n }\n\n #clearSearch(): void {\n this.searchKeys = '';\n }\n\n #clearActive(): void {\n for (let i = 0; i < this.#items.length; i++) {\n // No `isActive` check: the setter already skips unchanged values, and\n // reading it here would consume every item's tag on a path that can run\n // mid-render.\n (this.#items[i] as ListItem).isActive = false;\n }\n }\n\n setup = modifier(\n (\n _el: HTMLUListElement | HTMLSelectElement,\n _: unknown[],\n args: ListManagerArgs\n ) => {\n this.updateArgs(args);\n\n // This modifier's destructor also runs before every re-invocation, so a\n // flush it cancelled while the list was still very much alive has to be\n // put back. Only a real teardown never reaches this line again.\n this.#resumePendingListChange();\n\n return (): void => {\n this.teardown();\n };\n }\n );\n\n setupItem = modifier(\n (\n el: HTMLLIElement | HTMLOptionElement,\n _: unknown[],\n args: Pick<ListItemArgs, 'key' | 'textValue' | 'item' | 'isDisabled'> & {\n onRegister?: (item: ListItem) => void;\n disableEvents?: boolean;\n }\n ) => {\n let textValue = args.textValue;\n if (\n typeof textValue === 'undefined' ||\n textValue === '' ||\n textValue === null\n ) {\n // `aria-labelledby` is not a selector: it holds a *space-separated\n // list* of ids, and those ids are resolved against the whole\n // document, not against this element's subtree. Treating the raw\n // value as `#id` therefore turned a multi-id label into a descendant\n // selector that matches nothing, missed labels living outside the\n // item — leaving `textValue` empty and type-ahead search broken — and\n // threw outright on any id that is not a valid CSS identifier.\n const labelledBy = el.getAttribute('aria-labelledby');\n const labelId = labelledBy?.trim().split(/\\s+/)[0];\n\n if (labelId) {\n const labelElement = getElementById(el.ownerDocument, labelId);\n if (labelElement) {\n textValue = labelElement.textContent?.trim() || '';\n }\n }\n\n // Still nothing — either there was no label, or the id it named is\n // not in the document — so fall back to the item's own text.\n if (!textValue) {\n textValue = el.textContent?.trim() || '';\n }\n }\n\n this.register(el as HTMLLIElement, {\n key: args.key,\n textValue: textValue || '',\n item: args.item,\n isActive: false,\n isDisabled: Boolean(args.isDisabled) || this.isKeyDisabled(args.key),\n isSelected: this.isKeySelected(args.key)\n });\n const item = this.at(el);\n if (item) {\n item.isDisabledByItem = Boolean(args.isDisabled);\n }\n if (item && typeof args.onRegister === 'function') {\n args.onRegister(item);\n }\n\n const mouseEnter = (): void => {\n this.activateItem(item);\n };\n\n const mouseLeave = (): void => {\n if (item) {\n item.isActive = false;\n }\n };\n\n // Glimmer mutates this item's DOM during a render — rewriting `tabindex`\n // on the focused item, or clearing the block that contains it — and the\n // browser reacts by blurring the element and dispatching `focusout`\n // synchronously, inside the frame that just consumed `isActive` (see\n // `ListItem` above). Those blurs carry no `relatedTarget`.\n //\n // Neither do some genuine ones: clicking a non-focusable region,\n // switching tab or window, or moving focus to browser chrome. Ignoring\n // every targetless blur therefore trades a possibly-stale highlight for\n // never writing tracked state mid-render. That is a good trade here —\n // for a roving-tabindex widget, keeping the active item across a blur is\n // closer to the ARIA pattern than clearing it.\n const focusOut = (event: Event): void => {\n if ((event as FocusEvent).relatedTarget === null) {\n return;\n }\n mouseLeave();\n };\n\n if (!args.disableEvents) {\n el.addEventListener('mouseenter', mouseEnter);\n el.addEventListener('mouseleave', mouseLeave);\n\n el.addEventListener('focusin', mouseEnter);\n el.addEventListener('focusout', focusOut);\n }\n\n return (): void => {\n this.unregister(el);\n\n if (!args.disableEvents) {\n el.removeEventListener('mouseenter', mouseEnter);\n el.removeEventListener('mouseleave', mouseLeave);\n\n el.removeEventListener('focusin', mouseEnter);\n el.removeEventListener('focusout', focusOut);\n }\n };\n }\n );\n}\n\n/**\n * The `allowEmpty` deselect rule, in one place.\n *\n * Given the keys that make up a selection, whether `key` may be taken out of\n * it: a key that is not in the selection has nothing to remove, and the last\n * remaining key only goes when emptying the selection is allowed.\n *\n * `selectionMode` deliberately plays no part. It decides how a selection is\n * built, not whether it may shrink -- see `#selectionSnapshot`.\n */\nfunction canDeselectKey(\n selectedKeys: string[],\n key: string,\n allowEmpty: boolean = false\n): boolean {\n if (!selectedKeys.includes(key)) {\n return false;\n }\n return (allowEmpty && selectedKeys.length == 1) || selectedKeys.length > 1;\n}\n\nfunction keyAndLabelForItem(item: unknown): { key: string; label: string } {\n // Handle primitive types directly\n if (typeof item === 'string' || typeof item === 'number') {\n const value = item.toString();\n return { key: value, label: value };\n }\n\n // If the item is an object, try to extract key and label using common property names\n if (typeof item === 'object' && item !== null) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const typedItem = item as any;\n\n // Try to use the 'key' property first; if not available, use 'id'\n let keyProp = typedItem.key || typedItem.id;\n if (keyProp === undefined) {\n keyProp = item.toString();\n }\n\n // Determine the label by checking multiple possible properties\n let labelProp =\n typedItem.label || typedItem.value || typedItem.name || typedItem.title;\n if (labelProp === undefined) {\n labelProp = item.toString();\n }\n\n return { key: keyProp.toString(), label: labelProp.toString() };\n }\n\n // Fallback if item does not match expected types\n return { key: '', label: '' };\n}\n\nexport type {\n ListItem,\n ListItemArgs,\n ListItemRegistration,\n SelectionMode,\n AutoActivateMode\n};\n// `defaultFilter` and `FilterFn` live in ./filter now. They are re-exported\n// here, unused by this module, because this was their public path before the\n// move and consumers import them from it.\nexport { ListManager, canDeselectKey, keyAndLabelForItem, defaultFilter };\nexport type { FilterFn };\n"],"names":["ListItem","el","key","textValue","item","g","prototype","tracked","i","isSelectedMirror","isDisabledMirror","isActiveMirror","isSelected","_isSelected","value","isDisabled","_isDisabled","isActive","_isActive","isActiveUntracked","isSelectedUntracked","isDisabledUntracked","isDisabledByItem","constructor","args","ListManager","tabStopKeyMirror","searchKeys","selectionMode","selectedKeys","disabledKeys","allowEmpty","autoActivateMode","updateArgs","_selectionMode","#orderedItems","filter","isConnected","sort","a","b","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","#hasVisibleItems","some","isTabStop","_tabStopKey","tabStopKey","#refreshTabStop","activated","active","selected","first","register","newItem","onActiveItemChange","push","unregister","#scheduleListChange","action","cancel","later","#flushListChange","undefined","added","removed","onListItemsChange","setFirstOptionActive","setSelectedOptionActive","teardown","#resumePendingListChange","at","find","atKey","length","isKeySelected","isKeyDisabled","onAction","onSelectionChange","selectActiveItem","click","selectItem","activateItem","requestAnimationFrame","scrollIntoView","block","inline","setNextOptionActive","items","setPreviousOptionActive","setLastOptionActive","search","debounce","toLowerCase","trim","startsWith","clearSearch","includes","#indexOfActiveItem","indexOf","#selectionSnapshot","renderedKeys","Set","map","_item","has","#toggleSelectedItem","canDeselectKey","indexToRemove","splice","#activeItem","#clearSearch","#clearActive","setup","modifier","_el","_","setupItem","labelledBy","getAttribute","labelId","split","labelElement","getElementById","ownerDocument","textContent","Boolean","onRegister","mouseEnter","mouseLeave","focusOut","event","relatedTarget","disableEvents","addEventListener","removeEventListener","keyAndLabelForItem","toString","label","typedItem","keyProp","id","labelProp","name","title"],"mappings":";;;;;;;AAkCA,MAAMA,QAAQ,CAAC;EACbC,EAAE;EACFC,GAAG;EACHC,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;EACAC,IAAI;;AAEJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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AE;AAAE2I,IAAAA,KAAK,EAAE;GAAI;AAC/B;;"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes the dynamic segments and query params given to a route link.
|
|
3
|
+
*/
|
|
4
|
+
function normalizeRouteArgs(args) {
|
|
5
|
+
return {
|
|
6
|
+
// `!= null` (not truthiness) so a legitimate falsy dynamic segment --
|
|
7
|
+
// `model={{0}}` or `model=""` -- is not silently dropped.
|
|
8
|
+
models: args.models ?? (args.model != null ? [args.model] : []),
|
|
9
|
+
// `LinkTo`'s `@query` throws when given `undefined` rather than treating it
|
|
10
|
+
// as "no query params" -- so this must default to an empty object.
|
|
11
|
+
query: args.query ?? {}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Whether a route link is active. An explicit `isActive` wins; without a
|
|
17
|
+
* `route` the answer is `false`; otherwise the router decides.
|
|
18
|
+
*/
|
|
19
|
+
function isRouteActive(router, args) {
|
|
20
|
+
if (args.isActive !== undefined) {
|
|
21
|
+
return args.isActive;
|
|
22
|
+
}
|
|
23
|
+
if (!args.route) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Redundant belt-and-braces: `RouterService#isActive` already entangles
|
|
28
|
+
// itself with `currentURL`'s tag internally (see
|
|
29
|
+
// `consumeTag(tagFor(this._router, 'currentURL'))` in ember-source's
|
|
30
|
+
// `router-service.js`), so a caller recomputes on every transition even
|
|
31
|
+
// without the read below. Kept anyway as a documented, version-independent
|
|
32
|
+
// guarantee -- and covered by the transition test in
|
|
33
|
+
// `tab-nav-routing-test.gts` -- in case that internal entanglement is ever
|
|
34
|
+
// dropped.
|
|
35
|
+
void router.currentURL;
|
|
36
|
+
const {
|
|
37
|
+
models,
|
|
38
|
+
query
|
|
39
|
+
} = normalizeRouteArgs(args);
|
|
40
|
+
try {
|
|
41
|
+
return router.isActive(args.route, ...models, {
|
|
42
|
+
queryParams: query
|
|
43
|
+
});
|
|
44
|
+
} catch {
|
|
45
|
+
// `isActive` throws for a route that is not currently reachable -- an
|
|
46
|
+
// unentered engine, or a dynamic segment whose model is not loaded. Not
|
|
47
|
+
// being reachable is not being active.
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* `isRouteActive` for a router that is resolved lazily. `getRouter` runs only
|
|
54
|
+
* when the router is actually needed -- `route` given and `isActive` not -- so
|
|
55
|
+
* a link that never routes never touches `service:router`. Shared by
|
|
56
|
+
* `NavLink` and the handle `NavItem` registers with a folder, so both always
|
|
57
|
+
* agree on what is active.
|
|
58
|
+
*/
|
|
59
|
+
function isLinkActive(args, getRouter) {
|
|
60
|
+
if (args.isActive !== undefined) {
|
|
61
|
+
return args.isActive;
|
|
62
|
+
}
|
|
63
|
+
if (!args.route) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return isRouteActive(getRouter(), args);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { isLinkActive, isRouteActive, normalizeRouteArgs };
|
|
70
|
+
//# sourceMappingURL=route-active.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-active.js","sources":["../../src/utils/route-active.ts"],"sourcesContent":["import type RouterService from '@ember/routing/router-service';\n\nexport interface RouteActiveArgs {\n /** The route name. Without it nothing is derived from the router. */\n route?: string;\n /** A single dynamic segment for `route`. */\n model?: unknown;\n /** Dynamic segments for `route`. Wins over `model`. */\n models?: unknown[];\n /** Query params for `route`. */\n query?: Record<string, unknown>;\n /** Explicit override. Always wins over anything derived from the router. */\n isActive?: boolean;\n}\n\n/**\n * Normalizes the dynamic segments and query params given to a route link.\n */\nexport function normalizeRouteArgs(\n args: Pick<RouteActiveArgs, 'model' | 'models' | 'query'>\n): { models: unknown[]; query: Record<string, unknown> } {\n return {\n // `!= null` (not truthiness) so a legitimate falsy dynamic segment --\n // `model={{0}}` or `model=\"\"` -- is not silently dropped.\n models: args.models ?? (args.model != null ? [args.model] : []),\n // `LinkTo`'s `@query` throws when given `undefined` rather than treating it\n // as \"no query params\" -- so this must default to an empty object.\n query: args.query ?? {}\n };\n}\n\n/**\n * Whether a route link is active. An explicit `isActive` wins; without a\n * `route` the answer is `false`; otherwise the router decides.\n */\nexport function isRouteActive(\n router: RouterService,\n args: RouteActiveArgs\n): boolean {\n if (args.isActive !== undefined) {\n return args.isActive;\n }\n if (!args.route) {\n return false;\n }\n\n // Redundant belt-and-braces: `RouterService#isActive` already entangles\n // itself with `currentURL`'s tag internally (see\n // `consumeTag(tagFor(this._router, 'currentURL'))` in ember-source's\n // `router-service.js`), so a caller recomputes on every transition even\n // without the read below. Kept anyway as a documented, version-independent\n // guarantee -- and covered by the transition test in\n // `tab-nav-routing-test.gts` -- in case that internal entanglement is ever\n // dropped.\n void router.currentURL;\n\n const { models, query } = normalizeRouteArgs(args);\n\n try {\n return router.isActive(args.route, ...models, {\n queryParams: query\n } as never);\n } catch {\n // `isActive` throws for a route that is not currently reachable -- an\n // unentered engine, or a dynamic segment whose model is not loaded. Not\n // being reachable is not being active.\n return false;\n }\n}\n\n/**\n * `isRouteActive` for a router that is resolved lazily. `getRouter` runs only\n * when the router is actually needed -- `route` given and `isActive` not -- so\n * a link that never routes never touches `service:router`. Shared by\n * `NavLink` and the handle `NavItem` registers with a folder, so both always\n * agree on what is active.\n */\nexport function isLinkActive(\n args: RouteActiveArgs,\n getRouter: () => RouterService\n): boolean {\n if (args.isActive !== undefined) {\n return args.isActive;\n }\n if (!args.route) {\n return false;\n }\n\n return isRouteActive(getRouter(), args);\n}\n"],"names":["normalizeRouteArgs","args","models","model","query","isRouteActive","router","isActive","undefined","route","currentURL","queryParams","isLinkActive","getRouter"],"mappings":"AAeA;AACA;AACA;AACO,SAASA,kBAAkBA,CAChCC,IAAyD,EACF;EACvD,OAAO;AACL;AACA;AACAC,IAAAA,MAAM,EAAED,IAAI,CAACC,MAAM,KAAKD,IAAI,CAACE,KAAK,IAAI,IAAI,GAAG,CAACF,IAAI,CAACE,KAAK,CAAC,GAAG,EAAE,CAAC;AAC/D;AACA;AACAC,IAAAA,KAAK,EAAEH,IAAI,CAACG,KAAK,IAAI;GACtB;AACH;;AAEA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAC3BC,MAAqB,EACrBL,IAAqB,EACZ;AACT,EAAA,IAAIA,IAAI,CAACM,QAAQ,KAAKC,SAAS,EAAE;IAC/B,OAAOP,IAAI,CAACM,QAAQ;AACtB,EAAA;AACA,EAAA,IAAI,CAACN,IAAI,CAACQ,KAAK,EAAE;AACf,IAAA,OAAO,KAAK;AACd,EAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACA,KAAKH,MAAM,CAACI,UAAU;EAEtB,MAAM;IAAER,MAAM;AAAEE,IAAAA;AAAM,GAAC,GAAGJ,kBAAkB,CAACC,IAAI,CAAC;EAElD,IAAI;IACF,OAAOK,MAAM,CAACC,QAAQ,CAACN,IAAI,CAACQ,KAAK,EAAE,GAAGP,MAAM,EAAE;AAC5CS,MAAAA,WAAW,EAAEP;AACf,KAAU,CAAC;AACb,EAAA,CAAC,CAAC,MAAM;AACN;AACA;AACA;AACA,IAAA,OAAO,KAAK;AACd,EAAA;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,YAAYA,CAC1BX,IAAqB,EACrBY,SAA8B,EACrB;AACT,EAAA,IAAIZ,IAAI,CAACM,QAAQ,KAAKC,SAAS,EAAE;IAC/B,OAAOP,IAAI,CAACM,QAAQ;AACtB,EAAA;AACA,EAAA,IAAI,CAACN,IAAI,CAACQ,KAAK,EAAE;AACf,IAAA,OAAO,KAAK;AACd,EAAA;AAEA,EAAA,OAAOJ,aAAa,CAACQ,SAAS,EAAE,EAAEZ,IAAI,CAAC;AACzC;;"}
|
|
@@ -25,6 +25,14 @@ class SelectionIndicator {
|
|
|
25
25
|
#resize = deferredWork('@frontile/utils:selection-indicator:resize');
|
|
26
26
|
#isReady = false;
|
|
27
27
|
|
|
28
|
+
// How many live claims the current target holds. A modifier whose
|
|
29
|
+
// definition changes -- its owner's context was rebuilt, say -- is
|
|
30
|
+
// reinstalled rather than updated, and Glimmer installs the new instance
|
|
31
|
+
// before destroying the old one. The same element is then claimed twice and
|
|
32
|
+
// released once, and that one release must not take the target away from
|
|
33
|
+
// the claim that is still live.
|
|
34
|
+
#claims = 0;
|
|
35
|
+
|
|
28
36
|
// Whether a real measurement has ever landed. Only the very first one is
|
|
29
37
|
// forced-layout-sensitive (see `setupContainer`); once it has happened, a
|
|
30
38
|
// click that moves the selection is no longer racing an ancestor's own
|
|
@@ -80,7 +88,12 @@ class SelectionIndicator {
|
|
|
80
88
|
* indicator immediately rather than a frame later.
|
|
81
89
|
*/
|
|
82
90
|
claim(element) {
|
|
83
|
-
this.#target
|
|
91
|
+
if (this.#target === element) {
|
|
92
|
+
this.#claims += 1;
|
|
93
|
+
} else {
|
|
94
|
+
this.#target = element;
|
|
95
|
+
this.#claims = 1;
|
|
96
|
+
}
|
|
84
97
|
this.#observer?.observe(element);
|
|
85
98
|
if (this.#hasMeasuredOnce) {
|
|
86
99
|
this.#measure();
|
|
@@ -88,15 +101,22 @@ class SelectionIndicator {
|
|
|
88
101
|
}
|
|
89
102
|
|
|
90
103
|
/**
|
|
91
|
-
* Releases `element` if it is still the target
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* target.
|
|
104
|
+
* Releases one claim on `element` if it is still the target, and gives the
|
|
105
|
+
* target up once no claim on it is left. When selection moves backwards,
|
|
106
|
+
* the incoming item's setup runs before the outgoing item's teardown, and
|
|
107
|
+
* without the target guard that teardown would wipe the new target. When a
|
|
108
|
+
* modifier is reinstalled on the same element, its new claim lands before
|
|
109
|
+
* the old one's release, and without the count that release would wipe the
|
|
110
|
+
* live claim.
|
|
95
111
|
*/
|
|
96
112
|
release(element) {
|
|
97
113
|
if (this.#target !== element) {
|
|
98
114
|
return;
|
|
99
115
|
}
|
|
116
|
+
this.#claims -= 1;
|
|
117
|
+
if (this.#claims > 0) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
100
120
|
this.#observer?.unobserve(element);
|
|
101
121
|
this.#target = undefined;
|
|
102
122
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection-indicator.js","sources":["../../src/utils/selection-indicator.ts"],"sourcesContent":["import { modifier } from 'ember-modifier';\nimport { deferredWork } from './deferred-work';\n\nconst READY_ATTRIBUTE = 'data-fr-si-ready';\n\n/**\n * Measures whichever element is currently selected and publishes its geometry\n * on the container as CSS custom properties. It never paints anything: the\n * theme decides whether that geometry becomes a full pill or a bar pinned to\n * one edge, which is what lets one primitive serve a segmented control and\n * tabs alike.\n *\n * Offsets are physical (`offsetLeft` / `offsetTop`), not logical, and that is\n * deliberate. The browser has already laid the items out for the container's\n * direction, so a physical offset fed to `translate` is correct in both LTR\n * and RTL. Reaching for `inset-inline-start` here would flip an already\n * flipped value.\n */\nclass SelectionIndicator {\n #container?: HTMLElement;\n #target?: HTMLElement;\n #observer?: ResizeObserver;\n #ready = deferredWork('@frontile/utils:selection-indicator:ready');\n #remeasure = deferredWork('@frontile/utils:selection-indicator:remeasure');\n #resize = deferredWork('@frontile/utils:selection-indicator:resize');\n #isReady = false;\n\n // Whether a real measurement has ever landed. Only the very first one is\n // forced-layout-sensitive (see `setupContainer`); once it has happened, a\n // click that moves the selection is no longer racing an ancestor's own\n // mount-time transition, so there is no reason to defer those.\n #hasMeasuredOnce = false;\n\n /**\n * Modifier to place on the container element. Observes its size and, once\n * a target is selected, publishes that target's geometry as CSS custom\n * properties on this element.\n */\n setupContainer = modifier((element: HTMLElement) => {\n this.#container = element;\n // Coalesced to one measurement per frame: the container and the target are\n // both observed, and resizing the container usually resizes the target too,\n // so a single layout change delivers two entries. Measuring reads layout\n // and then writes four custom properties, and a window drag fires this\n // continuously.\n this.#observer = new ResizeObserver(() =>\n this.#resize.schedule(() => this.#measure())\n );\n this.#observer.observe(element);\n\n if (this.#target) {\n this.#observer.observe(this.#target);\n }\n\n // Before the first real measurement, this call is happening during the\n // control's own initial mount -- the same render pass that can be\n // mounting an ancestor overlay's enter transition. Forcing layout here\n // lands at an arbitrary point in `ember-css-transitions`' own\n // reflow-then-swap sequence for that transition, which is enough to make\n // the browser skip it entirely. `ResizeObserver.observe()` above already\n // guarantees an initial, asynchronous notification for `element` (and for\n // the target, if already claimed), so leaving it to that -- deferred\n // through `#resize` like any other resize -- gets the same measurement\n // without the synchronous reflow. Once a first measurement has actually\n // landed, later remounts of this same container are no longer racing\n // anything, so measure immediately as before.\n if (this.#hasMeasuredOnce) {\n this.#measure();\n }\n\n return (): void => {\n this.#shutDown();\n };\n });\n\n /**\n * Claims `element` as the measured target. Exposed alongside `setupTarget`\n * so a consumer composing its own modifier -- a navigation bar that also has\n * to write `aria-current` -- can delegate here rather than reimplement the\n * handover rules below.\n *\n * Measures synchronously once a first measurement has already landed --\n * see `setupContainer` -- so a click that moves the selection updates the\n * indicator immediately rather than a frame later.\n */\n claim(element: HTMLElement): void {\n this.#target = element;\n this.#observer?.observe(element);\n if (this.#hasMeasuredOnce) {\n this.#measure();\n }\n }\n\n /**\n * Releases `element` if it is still the target. When selection moves\n * backwards, the incoming item's setup runs before the outgoing item's\n * teardown, and without this guard that teardown would wipe the new\n * target.\n */\n release(element: HTMLElement): void {\n if (this.#target !== element) {\n return;\n }\n this.#observer?.unobserve(element);\n this.#target = undefined;\n\n // Do not re-measure synchronously. When selection moves forwards the\n // order is reversed -- ember-modifier tears down before re-running\n // setup, and Glimmer revalidates in tree order -- so the outgoing\n // teardown lands first and the incoming target is still moments away\n // in this same render. Measuring now would strip the ready attribute,\n // and the theme gates both opacity and the transition on it, so the\n // indicator would blink out and jump to its new position instead of\n // sliding. Defer instead, and only fall through to the not-ready path\n // if nothing has claimed the target by then.\n this.#scheduleRemeasure();\n }\n\n /**\n * Modifier to place on each candidate target element, passing whether it\n * is currently selected as the sole positional argument. Only the\n * currently-selected target's geometry is measured and published.\n */\n setupTarget = modifier((element: HTMLElement, [isSelected]: [boolean]) => {\n if (isSelected) {\n this.claim(element);\n }\n\n return (): void => {\n this.release(element);\n };\n });\n\n /**\n * Recomputes and republishes the current target's geometry. Called\n * automatically on setup, selection change, and container/target resize;\n * exposed for callers that need to force a recomputation.\n */\n #measure = (): void => {\n const container = this.#container;\n if (!container) {\n return;\n }\n\n const target = this.#target;\n if (!target) {\n this.#markNotReady();\n return;\n }\n\n const width = target.offsetWidth;\n const height = target.offsetHeight;\n\n // A control inside a hidden ancestor -- a closed drawer, an inactive tab\n // panel -- measures zero. Publishing that would collapse the indicator and,\n // worse, mark it ready, so the first real measurement once it is shown\n // would animate in from the container origin. Stay un-ready instead; the\n // ResizeObserver fires when it becomes visible.\n if (width === 0 && height === 0) {\n this.#markNotReady();\n return;\n }\n\n container.style.setProperty('--fr-si-x', `${target.offsetLeft}px`);\n container.style.setProperty('--fr-si-y', `${target.offsetTop}px`);\n container.style.setProperty('--fr-si-width', `${width}px`);\n container.style.setProperty('--fr-si-height', `${height}px`);\n\n this.#hasMeasuredOnce = true;\n\n if (!this.#isReady) {\n this.#isReady = true;\n this.#scheduleReady(container);\n }\n };\n\n /**\n * Everything the container modifier's destructor undoes. The target is not\n * reset here: it belongs to `setupTarget`, whose own destructor clears it.\n */\n #shutDown(): void {\n this.#observer?.disconnect();\n this.#observer = undefined;\n this.#ready.cancel();\n this.#remeasure.cancel();\n this.#resize.cancel();\n this.#container = undefined;\n this.#isReady = false;\n }\n\n #markNotReady(): void {\n this.#ready.cancel();\n this.#isReady = false;\n this.#container?.removeAttribute(READY_ATTRIBUTE);\n }\n\n // The ready flag is set a frame after the first real measurement so the\n // theme can hold transitions off until the indicator is already in place.\n #scheduleReady(container: HTMLElement): void {\n this.#ready.schedule(() => container.setAttribute(READY_ATTRIBUTE, ''));\n }\n\n // Re-measures once the current render has settled, so a target being handed\n // from one element to another is never observed mid-handover.\n #scheduleRemeasure(): void {\n this.#remeasure.schedule(() => {\n // A new target claimed the slot in the meantime and measured itself.\n if (this.#target) {\n return;\n }\n this.#measure();\n }, 'microtask');\n }\n}\n\n/**\n * Creates a selection indicator.\n *\n * Mirrors the shape of `ref` and `toggleState`: the class stays internal and\n * the public surface is this lowercase factory, since this is a utility rather\n * than a component.\n */\nfunction selectionIndicator(): SelectionIndicator {\n return new SelectionIndicator();\n}\n\nexport { selectionIndicator, READY_ATTRIBUTE };\nexport type { SelectionIndicator };\n"],"names":["READY_ATTRIBUTE","SelectionIndicator","deferredWork","setupContainer","modifier","element","ResizeObserver","schedule","observe","claim","release","unobserve","undefined","setupTarget","isSelected","#measure","container","target","width","offsetWidth","height","offsetHeight","style","setProperty","offsetLeft","offsetTop","#shutDown","disconnect","cancel","#markNotReady","removeAttribute","#scheduleReady","setAttribute","#scheduleRemeasure","selectionIndicator"],"mappings":";;;AAGA,MAAMA,eAAe,GAAG;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,CAAC;AACvB,EAAA,UAAU;AACV,EAAA,OAAO;AACP,EAAA,SAAS;AACT,EAAA,MAAM,GAAGC,YAAY,CAAC,2CAA2C,CAAC;AAClE,EAAA,UAAU,GAAGA,YAAY,CAAC,+CAA+C,CAAC;AAC1E,EAAA,OAAO,GAAGA,YAAY,CAAC,4CAA4C,CAAC;EACpE,QAAQ,GAAG,KAAK;;AAEhB;AACA;AACA;AACA;EACA,gBAAgB,GAAG,KAAK;;AAExB;AACF;AACA;AACA;AACA;AACEC,EAAAA,cAAc,GAAGC,QAAQ,CAAEC,OAAoB,IAAK;AAClD,IAAA,IAAI,CAAC,UAAU,GAAGA,OAAO;AACzB;AACA;AACA;AACA;AACA;IACA,IAAI,CAAC,SAAS,GAAG,IAAIC,cAAc,CAAC,MAClC,IAAI,CAAC,OAAO,CAACC,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAC7C,CAAC;AAC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../../src/utils/selection-indicator.ts"],"sourcesContent":["import { modifier } from 'ember-modifier';\nimport { deferredWork } from './deferred-work';\n\nconst READY_ATTRIBUTE = 'data-fr-si-ready';\n\n/**\n * Measures whichever element is currently selected and publishes its geometry\n * on the container as CSS custom properties. It never paints anything: the\n * theme decides whether that geometry becomes a full pill or a bar pinned to\n * one edge, which is what lets one primitive serve a segmented control and\n * tabs alike.\n *\n * Offsets are physical (`offsetLeft` / `offsetTop`), not logical, and that is\n * deliberate. The browser has already laid the items out for the container's\n * direction, so a physical offset fed to `translate` is correct in both LTR\n * and RTL. Reaching for `inset-inline-start` here would flip an already\n * flipped value.\n */\nclass SelectionIndicator {\n #container?: HTMLElement;\n #target?: HTMLElement;\n #observer?: ResizeObserver;\n #ready = deferredWork('@frontile/utils:selection-indicator:ready');\n #remeasure = deferredWork('@frontile/utils:selection-indicator:remeasure');\n #resize = deferredWork('@frontile/utils:selection-indicator:resize');\n #isReady = false;\n\n // How many live claims the current target holds. A modifier whose\n // definition changes -- its owner's context was rebuilt, say -- is\n // reinstalled rather than updated, and Glimmer installs the new instance\n // before destroying the old one. The same element is then claimed twice and\n // released once, and that one release must not take the target away from\n // the claim that is still live.\n #claims = 0;\n\n // Whether a real measurement has ever landed. Only the very first one is\n // forced-layout-sensitive (see `setupContainer`); once it has happened, a\n // click that moves the selection is no longer racing an ancestor's own\n // mount-time transition, so there is no reason to defer those.\n #hasMeasuredOnce = false;\n\n /**\n * Modifier to place on the container element. Observes its size and, once\n * a target is selected, publishes that target's geometry as CSS custom\n * properties on this element.\n */\n setupContainer = modifier((element: HTMLElement) => {\n this.#container = element;\n // Coalesced to one measurement per frame: the container and the target are\n // both observed, and resizing the container usually resizes the target too,\n // so a single layout change delivers two entries. Measuring reads layout\n // and then writes four custom properties, and a window drag fires this\n // continuously.\n this.#observer = new ResizeObserver(() =>\n this.#resize.schedule(() => this.#measure())\n );\n this.#observer.observe(element);\n\n if (this.#target) {\n this.#observer.observe(this.#target);\n }\n\n // Before the first real measurement, this call is happening during the\n // control's own initial mount -- the same render pass that can be\n // mounting an ancestor overlay's enter transition. Forcing layout here\n // lands at an arbitrary point in `ember-css-transitions`' own\n // reflow-then-swap sequence for that transition, which is enough to make\n // the browser skip it entirely. `ResizeObserver.observe()` above already\n // guarantees an initial, asynchronous notification for `element` (and for\n // the target, if already claimed), so leaving it to that -- deferred\n // through `#resize` like any other resize -- gets the same measurement\n // without the synchronous reflow. Once a first measurement has actually\n // landed, later remounts of this same container are no longer racing\n // anything, so measure immediately as before.\n if (this.#hasMeasuredOnce) {\n this.#measure();\n }\n\n return (): void => {\n this.#shutDown();\n };\n });\n\n /**\n * Claims `element` as the measured target. Exposed alongside `setupTarget`\n * so a consumer composing its own modifier -- a navigation bar that also has\n * to write `aria-current` -- can delegate here rather than reimplement the\n * handover rules below.\n *\n * Measures synchronously once a first measurement has already landed --\n * see `setupContainer` -- so a click that moves the selection updates the\n * indicator immediately rather than a frame later.\n */\n claim(element: HTMLElement): void {\n if (this.#target === element) {\n this.#claims += 1;\n } else {\n this.#target = element;\n this.#claims = 1;\n }\n this.#observer?.observe(element);\n if (this.#hasMeasuredOnce) {\n this.#measure();\n }\n }\n\n /**\n * Releases one claim on `element` if it is still the target, and gives the\n * target up once no claim on it is left. When selection moves backwards,\n * the incoming item's setup runs before the outgoing item's teardown, and\n * without the target guard that teardown would wipe the new target. When a\n * modifier is reinstalled on the same element, its new claim lands before\n * the old one's release, and without the count that release would wipe the\n * live claim.\n */\n release(element: HTMLElement): void {\n if (this.#target !== element) {\n return;\n }\n this.#claims -= 1;\n if (this.#claims > 0) {\n return;\n }\n this.#observer?.unobserve(element);\n this.#target = undefined;\n\n // Do not re-measure synchronously. When selection moves forwards the\n // order is reversed -- ember-modifier tears down before re-running\n // setup, and Glimmer revalidates in tree order -- so the outgoing\n // teardown lands first and the incoming target is still moments away\n // in this same render. Measuring now would strip the ready attribute,\n // and the theme gates both opacity and the transition on it, so the\n // indicator would blink out and jump to its new position instead of\n // sliding. Defer instead, and only fall through to the not-ready path\n // if nothing has claimed the target by then.\n this.#scheduleRemeasure();\n }\n\n /**\n * Modifier to place on each candidate target element, passing whether it\n * is currently selected as the sole positional argument. Only the\n * currently-selected target's geometry is measured and published.\n */\n setupTarget = modifier((element: HTMLElement, [isSelected]: [boolean]) => {\n if (isSelected) {\n this.claim(element);\n }\n\n return (): void => {\n this.release(element);\n };\n });\n\n /**\n * Recomputes and republishes the current target's geometry. Called\n * automatically on setup, selection change, and container/target resize;\n * exposed for callers that need to force a recomputation.\n */\n #measure = (): void => {\n const container = this.#container;\n if (!container) {\n return;\n }\n\n const target = this.#target;\n if (!target) {\n this.#markNotReady();\n return;\n }\n\n const width = target.offsetWidth;\n const height = target.offsetHeight;\n\n // A control inside a hidden ancestor -- a closed drawer, an inactive tab\n // panel -- measures zero. Publishing that would collapse the indicator and,\n // worse, mark it ready, so the first real measurement once it is shown\n // would animate in from the container origin. Stay un-ready instead; the\n // ResizeObserver fires when it becomes visible.\n if (width === 0 && height === 0) {\n this.#markNotReady();\n return;\n }\n\n container.style.setProperty('--fr-si-x', `${target.offsetLeft}px`);\n container.style.setProperty('--fr-si-y', `${target.offsetTop}px`);\n container.style.setProperty('--fr-si-width', `${width}px`);\n container.style.setProperty('--fr-si-height', `${height}px`);\n\n this.#hasMeasuredOnce = true;\n\n if (!this.#isReady) {\n this.#isReady = true;\n this.#scheduleReady(container);\n }\n };\n\n /**\n * Everything the container modifier's destructor undoes. The target is not\n * reset here: it belongs to `setupTarget`, whose own destructor clears it.\n */\n #shutDown(): void {\n this.#observer?.disconnect();\n this.#observer = undefined;\n this.#ready.cancel();\n this.#remeasure.cancel();\n this.#resize.cancel();\n this.#container = undefined;\n this.#isReady = false;\n }\n\n #markNotReady(): void {\n this.#ready.cancel();\n this.#isReady = false;\n this.#container?.removeAttribute(READY_ATTRIBUTE);\n }\n\n // The ready flag is set a frame after the first real measurement so the\n // theme can hold transitions off until the indicator is already in place.\n #scheduleReady(container: HTMLElement): void {\n this.#ready.schedule(() => container.setAttribute(READY_ATTRIBUTE, ''));\n }\n\n // Re-measures once the current render has settled, so a target being handed\n // from one element to another is never observed mid-handover.\n #scheduleRemeasure(): void {\n this.#remeasure.schedule(() => {\n // A new target claimed the slot in the meantime and measured itself.\n if (this.#target) {\n return;\n }\n this.#measure();\n }, 'microtask');\n }\n}\n\n/**\n * Creates a selection indicator.\n *\n * Mirrors the shape of `ref` and `toggleState`: the class stays internal and\n * the public surface is this lowercase factory, since this is a utility rather\n * than a component.\n */\nfunction selectionIndicator(): SelectionIndicator {\n return new SelectionIndicator();\n}\n\nexport { selectionIndicator, READY_ATTRIBUTE };\nexport type { SelectionIndicator };\n"],"names":["READY_ATTRIBUTE","SelectionIndicator","deferredWork","setupContainer","modifier","element","ResizeObserver","schedule","observe","claim","release","unobserve","undefined","setupTarget","isSelected","#measure","container","target","width","offsetWidth","height","offsetHeight","style","setProperty","offsetLeft","offsetTop","#shutDown","disconnect","cancel","#markNotReady","removeAttribute","#scheduleReady","setAttribute","#scheduleRemeasure","selectionIndicator"],"mappings":";;;AAGA,MAAMA,eAAe,GAAG;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,CAAC;AACvB,EAAA,UAAU;AACV,EAAA,OAAO;AACP,EAAA,SAAS;AACT,EAAA,MAAM,GAAGC,YAAY,CAAC,2CAA2C,CAAC;AAClE,EAAA,UAAU,GAAGA,YAAY,CAAC,+CAA+C,CAAC;AAC1E,EAAA,OAAO,GAAGA,YAAY,CAAC,4CAA4C,CAAC;EACpE,QAAQ,GAAG,KAAK;;AAEhB;AACA;AACA;AACA;AACA;AACA;EACA,OAAO,GAAG,CAAC;;AAEX;AACA;AACA;AACA;EACA,gBAAgB,GAAG,KAAK;;AAExB;AACF;AACA;AACA;AACA;AACEC,EAAAA,cAAc,GAAGC,QAAQ,CAAEC,OAAoB,IAAK;AAClD,IAAA,IAAI,CAAC,UAAU,GAAGA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AAC,MAAMS,SAAS,CAACgB,YAAY,CAAChC,eAAe,EAAE,EAAE,CAAC,CAAC;AACzE,EAAA;;AAEA;AACA;EACA,kBAAkBiC,GAAS;AACzB,IAAA,IAAI,CAAC,UAAU,CAAC1B,QAAQ,CAAC,MAAM;AAC7B;AACA,MAAA,IAAI,IAAI,CAAC,OAAO,EAAE;AAChB,QAAA;AACF,MAAA;AACA,MAAA,IAAI,CAAC,QAAQ,EAAE;IACjB,CAAC,EAAE,WAAW,CAAC;AACjB,EAAA;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS2B,kBAAkBA,GAAuB;EAChD,OAAO,IAAIjC,kBAAkB,EAAE;AACjC;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frontile",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.7",
|
|
4
4
|
"description": "Component Library for Ember Octane apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
"types": "./declarations/navigation.d.ts",
|
|
47
47
|
"default": "./dist/navigation.js"
|
|
48
48
|
},
|
|
49
|
+
"./layout": {
|
|
50
|
+
"types": "./declarations/layout.d.ts",
|
|
51
|
+
"default": "./dist/layout.js"
|
|
52
|
+
},
|
|
49
53
|
"./disclosure": {
|
|
50
54
|
"types": "./declarations/disclosure.d.ts",
|
|
51
55
|
"default": "./dist/disclosure.js"
|
|
@@ -94,7 +98,7 @@
|
|
|
94
98
|
"@embroider/addon-shim": "^1.10.3",
|
|
95
99
|
"@embroider/macros": "^1.21.1",
|
|
96
100
|
"@floating-ui/dom": "^1.8.0",
|
|
97
|
-
"@frontile/theme": "^0.18.
|
|
101
|
+
"@frontile/theme": "^0.18.7",
|
|
98
102
|
"@glint/template": "^1.9.0",
|
|
99
103
|
"@universal-ember/table": "^4.0.0",
|
|
100
104
|
"date-fns": "^4.4.0",
|
|
@@ -152,5 +156,5 @@
|
|
|
152
156
|
"./services/notifications.js": "./dist/_app_/services/notifications.js"
|
|
153
157
|
}
|
|
154
158
|
},
|
|
155
|
-
"gitHead": "
|
|
159
|
+
"gitHead": "52f863c615e105f8124a80abd19ae813ee16a673"
|
|
156
160
|
}
|