@angular/aria 22.0.0-next.2 → 22.0.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/fesm2022/_accordion-chunk.mjs.map +1 -1
  2. package/fesm2022/_click-event-manager-chunk.mjs +45 -0
  3. package/fesm2022/_click-event-manager-chunk.mjs.map +1 -0
  4. package/fesm2022/_combobox-chunk.mjs +4 -4
  5. package/fesm2022/_combobox-chunk.mjs.map +1 -1
  6. package/fesm2022/_combobox-listbox-chunk.mjs +22 -12
  7. package/fesm2022/_combobox-listbox-chunk.mjs.map +1 -1
  8. package/fesm2022/_combobox-tree-chunk.mjs +18 -8
  9. package/fesm2022/_combobox-tree-chunk.mjs.map +1 -1
  10. package/fesm2022/_deferred-content-chunk.mjs +7 -7
  11. package/fesm2022/_deferred-content-chunk.mjs.map +1 -1
  12. package/fesm2022/_expansion-chunk.mjs.map +1 -1
  13. package/fesm2022/_list-chunk.mjs.map +1 -1
  14. package/fesm2022/_list-navigation-chunk.mjs.map +1 -1
  15. package/fesm2022/_list-typeahead-chunk.mjs +10 -10
  16. package/fesm2022/_list-typeahead-chunk.mjs.map +1 -1
  17. package/fesm2022/_menu-chunk.mjs +34 -13
  18. package/fesm2022/_menu-chunk.mjs.map +1 -1
  19. package/fesm2022/_pointer-event-manager-chunk.mjs.map +1 -1
  20. package/fesm2022/_signal-like-chunk.mjs +1 -1
  21. package/fesm2022/_signal-like-chunk.mjs.map +1 -1
  22. package/fesm2022/_tabs-chunk.mjs +15 -5
  23. package/fesm2022/_tabs-chunk.mjs.map +1 -1
  24. package/fesm2022/_toolbar-widget-group-chunk.mjs +14 -2
  25. package/fesm2022/_toolbar-widget-group-chunk.mjs.map +1 -1
  26. package/fesm2022/_widget-chunk.mjs +6 -4
  27. package/fesm2022/_widget-chunk.mjs.map +1 -1
  28. package/fesm2022/accordion.mjs +13 -13
  29. package/fesm2022/accordion.mjs.map +1 -1
  30. package/fesm2022/aria.mjs +1 -1
  31. package/fesm2022/aria.mjs.map +1 -1
  32. package/fesm2022/combobox.mjs +15 -15
  33. package/fesm2022/combobox.mjs.map +1 -1
  34. package/fesm2022/grid.mjs +12 -12
  35. package/fesm2022/grid.mjs.map +1 -1
  36. package/fesm2022/listbox.mjs +25 -32
  37. package/fesm2022/listbox.mjs.map +1 -1
  38. package/fesm2022/menu.mjs +28 -32
  39. package/fesm2022/menu.mjs.map +1 -1
  40. package/fesm2022/private.mjs +9 -8
  41. package/fesm2022/private.mjs.map +1 -1
  42. package/fesm2022/tabs.mjs +23 -31
  43. package/fesm2022/tabs.mjs.map +1 -1
  44. package/fesm2022/toolbar.mjs +22 -30
  45. package/fesm2022/toolbar.mjs.map +1 -1
  46. package/fesm2022/tree.mjs +24 -32
  47. package/fesm2022/tree.mjs.map +1 -1
  48. package/package.json +2 -2
  49. package/resources/code-examples.db +0 -0
  50. package/types/_accordion-chunk.d.ts +2 -2
  51. package/types/_click-event-manager-chunk.d.ts +27 -0
  52. package/types/_combobox-chunk.d.ts +1 -1
  53. package/types/_grid-chunk.d.ts +2 -2
  54. package/types/_list-chunk.d.ts +1 -1
  55. package/types/_listbox-chunk.d.ts +12 -5
  56. package/types/_menu-chunk.d.ts +14 -10
  57. package/types/_tabs-chunk.d.ts +12 -6
  58. package/types/_toolbar-chunk.d.ts +6 -1
  59. package/types/_tree-chunk.d.ts +7 -1
  60. package/types/listbox.d.ts +4 -6
  61. package/types/menu.d.ts +2 -2
  62. package/types/private.d.ts +2 -1
  63. package/types/tabs.d.ts +1 -4
  64. package/types/toolbar.d.ts +2 -5
  65. package/types/tree.d.ts +2 -5
@@ -1 +1 @@
1
- {"version":3,"file":"_list-navigation-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/behaviors/list-focus/list-focus.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/behaviors/list-navigation/list-navigation.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, signal, SignalLike, WritableSignalLike} from '../signal-like/signal-like';\n\n/** Represents an item in a collection, such as a listbox option, than may receive focus. */\nexport interface ListFocusItem {\n /** A unique identifier for the item. */\n id: SignalLike<string>;\n\n /** The html element that should receive focus. */\n element: SignalLike<HTMLElement | undefined>;\n\n /** Whether an item is disabled. */\n disabled: SignalLike<boolean>;\n}\n\n/** Represents the required inputs for a collection that contains focusable items. */\nexport interface ListFocusInputs<T extends ListFocusItem> {\n /** The focus strategy used by the list. */\n focusMode: SignalLike<'roving' | 'activedescendant'>;\n\n /** Whether the list is disabled. */\n disabled: SignalLike<boolean>;\n\n /** The items in the list. */\n items: SignalLike<T[]>;\n\n /** The active item. */\n activeItem: WritableSignalLike<T | undefined>;\n\n /** Whether disabled items in the list should be focusable. */\n softDisabled: SignalLike<boolean>;\n\n /** The html element that should receive focus. */\n element: SignalLike<HTMLElement | undefined>;\n}\n\n/** Controls focus for a list of items. */\nexport class ListFocus<T extends ListFocusItem> {\n /** The last item that was active. */\n prevActiveItem = signal<T | undefined>(undefined);\n\n /** The index of the last item that was active. */\n prevActiveIndex = computed(() => {\n return this.prevActiveItem() ? this.inputs.items().indexOf(this.prevActiveItem()!) : -1;\n });\n\n /** The current active index in the list. */\n activeIndex = computed(() => {\n return this.inputs.activeItem() ? this.inputs.items().indexOf(this.inputs.activeItem()!) : -1;\n });\n\n constructor(readonly inputs: ListFocusInputs<T>) {}\n\n /** Whether the list is in a disabled state. */\n isListDisabled(): boolean {\n return this.inputs.disabled() || this.inputs.items().every(i => i.disabled());\n }\n\n /** The id of the current active item. */\n getActiveDescendant(): string | undefined {\n if (this.isListDisabled()) {\n return undefined;\n }\n if (this.inputs.focusMode() === 'roving') {\n return undefined;\n }\n return this.inputs.activeItem()?.id() ?? undefined;\n }\n\n /** The tab index for the list. */\n getListTabIndex(): -1 | 0 {\n if (this.isListDisabled()) {\n return 0;\n }\n return this.inputs.focusMode() === 'activedescendant' ? 0 : -1;\n }\n\n /** Returns the tab index for the given item. */\n getItemTabIndex(item: T): -1 | 0 {\n if (this.isListDisabled()) {\n return -1;\n }\n if (this.inputs.focusMode() === 'activedescendant') {\n return -1;\n }\n return this.inputs.activeItem() === item ? 0 : -1;\n }\n\n /** Moves focus to the given item if it is focusable. */\n focus(item: T, opts?: {focusElement?: boolean}): boolean {\n if (this.isListDisabled() || !this.isFocusable(item)) {\n return false;\n }\n\n this.prevActiveItem.set(this.inputs.activeItem());\n this.inputs.activeItem.set(item);\n\n if (opts?.focusElement || opts?.focusElement === undefined) {\n this.inputs.focusMode() === 'roving'\n ? item.element()?.focus()\n : this.inputs.element()?.focus();\n }\n\n return true;\n }\n\n /** Returns true if the given item can be navigated to. */\n isFocusable(item: T): boolean {\n return !item.disabled() || this.inputs.softDisabled();\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {SignalLike} from '../signal-like/signal-like';\nimport {ListFocus, ListFocusInputs, ListFocusItem} from '../list-focus/list-focus';\n\n/** Represents an item in a collection, such as a listbox option, than can be navigated to. */\nexport interface ListNavigationItem extends ListFocusItem {}\n\n/** Represents the required inputs for a collection that has navigable items. */\nexport interface ListNavigationInputs<T extends ListNavigationItem> extends ListFocusInputs<T> {\n /** Whether focus should wrap when navigating. */\n wrap: SignalLike<boolean>;\n\n /** Whether the list is vertically or horizontally oriented. */\n orientation: SignalLike<'vertical' | 'horizontal'>;\n\n /** The direction that text is read based on the users locale. */\n textDirection: SignalLike<'rtl' | 'ltr'>;\n}\n\n/** Options for list navigation. */\nexport interface ListNavigationOpts<T> {\n /**\n * Whether to focus the item's element.\n * Defaults to true.\n */\n focusElement?: boolean;\n\n /**\n * The list of items to navigate through.\n * Defaults to the list of items from the inputs.\n */\n items?: T[];\n}\n\n/** Controls navigation for a list of items. */\nexport class ListNavigation<T extends ListNavigationItem> {\n constructor(readonly inputs: ListNavigationInputs<T> & {focusManager: ListFocus<T>}) {}\n\n /** Navigates to the given item. */\n goto(item?: T, opts?: ListNavigationOpts<T>): boolean {\n return item ? this.inputs.focusManager.focus(item, opts) : false;\n }\n\n /** Navigates to the next item in the list. */\n next(opts?: ListNavigationOpts<T>): boolean {\n return this._advance(1, opts);\n }\n\n /** Peeks the next item in the list. */\n peekNext(opts?: ListNavigationOpts<T>): T | undefined {\n return this._peek(1, opts);\n }\n\n /** Navigates to the previous item in the list. */\n prev(opts?: ListNavigationOpts<T>): boolean {\n return this._advance(-1, opts);\n }\n\n /** Peeks the previous item in the list. */\n peekPrev(opts?: ListNavigationOpts<T>): T | undefined {\n return this._peek(-1, opts);\n }\n\n /** Navigates to the first item in the list. */\n first(opts?: ListNavigationOpts<T>): boolean {\n const item = this.peekFirst(opts);\n return item ? this.goto(item, opts) : false;\n }\n\n /** Navigates to the last item in the list. */\n last(opts?: ListNavigationOpts<T>): boolean {\n const item = this.peekLast(opts);\n return item ? this.goto(item, opts) : false;\n }\n\n /** Gets the first focusable item from the given list of items. */\n peekFirst(opts?: ListNavigationOpts<T>): T | undefined {\n const items = opts?.items ?? this.inputs.items();\n return items.find(i => this.inputs.focusManager.isFocusable(i));\n }\n\n /** Gets the last focusable item from the given list of items. */\n peekLast(opts?: ListNavigationOpts<T>): T | undefined {\n const items = opts?.items ?? this.inputs.items();\n for (let i = items.length - 1; i >= 0; i--) {\n if (this.inputs.focusManager.isFocusable(items[i])) {\n return items[i];\n }\n }\n return;\n }\n\n /** Advances to the next or previous focusable item in the list based on the given delta. */\n private _advance(delta: 1 | -1, opts?: ListNavigationOpts<T>): boolean {\n const item = this._peek(delta, opts);\n return item ? this.goto(item, opts) : false;\n }\n\n /** Peeks the next or previous focusable item in the list based on the given delta. */\n private _peek(delta: 1 | -1, opts?: ListNavigationOpts<T>): T | undefined {\n const items = opts?.items ?? this.inputs.items();\n const itemCount = items.length;\n const activeItem = this.inputs.focusManager.inputs.activeItem();\n const startIndex =\n opts?.items && activeItem\n ? items.indexOf(activeItem)\n : this.inputs.focusManager.activeIndex();\n\n const step = (i: number) =>\n this.inputs.wrap() ? (i + delta + itemCount) % itemCount : i + delta;\n\n // If wrapping is enabled, this loop ultimately terminates when `i` gets back to `startIndex`\n // in the case that all options are disabled. If wrapping is disabled, the loop terminates\n // when the index goes out of bounds.\n for (let i = step(startIndex); i !== startIndex && i < itemCount && i >= 0; i = step(i)) {\n if (this.inputs.focusManager.isFocusable(items[i])) {\n return items[i];\n }\n }\n\n return;\n }\n}\n"],"names":["ListFocus","inputs","prevActiveItem","signal","undefined","prevActiveIndex","computed","items","indexOf","activeIndex","activeItem","constructor","isListDisabled","disabled","every","i","getActiveDescendant","focusMode","id","getListTabIndex","getItemTabIndex","item","focus","opts","isFocusable","set","focusElement","element","softDisabled","ListNavigation","goto","focusManager","next","_advance","peekNext","_peek","prev","peekPrev","first","peekFirst","last","peekLast","find","length","delta","itemCount","startIndex","step","wrap"],"mappings":";;MA4CaA,SAAS,CAAA;EAcCC,MAAA;AAZrBC,EAAAA,cAAc,GAAGC,MAAM,CAAgBC,SAAS,CAAC;EAGjDC,eAAe,GAAGC,QAAQ,CAAC,MAAK;IAC9B,OAAO,IAAI,CAACJ,cAAc,EAAE,GAAG,IAAI,CAACD,MAAM,CAACM,KAAK,EAAE,CAACC,OAAO,CAAC,IAAI,CAACN,cAAc,EAAG,CAAC,GAAG,CAAC,CAAC;AACzF,GAAC,CAAC;EAGFO,WAAW,GAAGH,QAAQ,CAAC,MAAK;AAC1B,IAAA,OAAO,IAAI,CAACL,MAAM,CAACS,UAAU,EAAE,GAAG,IAAI,CAACT,MAAM,CAACM,KAAK,EAAE,CAACC,OAAO,CAAC,IAAI,CAACP,MAAM,CAACS,UAAU,EAAG,CAAC,GAAG,CAAC,CAAC;AAC/F,GAAC,CAAC;EAEFC,WAAAA,CAAqBV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ACD;;;;"}
1
+ {"version":3,"file":"_list-navigation-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/behaviors/list-focus/list-focus.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/behaviors/list-navigation/list-navigation.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, signal, SignalLike, WritableSignalLike} from '../signal-like/signal-like';\n\n/** Represents an item in a collection, such as a listbox option, than may receive focus. */\nexport interface ListFocusItem {\n /** A unique identifier for the item. */\n id: SignalLike<string>;\n\n /** The html element that should receive focus. */\n element: SignalLike<HTMLElement | undefined>;\n\n /** Whether an item is disabled. */\n disabled: SignalLike<boolean>;\n}\n\n/** Represents the required inputs for a collection that contains focusable items. */\nexport interface ListFocusInputs<T extends ListFocusItem> {\n /** The focus strategy used by the list. */\n focusMode: SignalLike<'roving' | 'activedescendant'>;\n\n /** Whether the list is disabled. */\n disabled: SignalLike<boolean>;\n\n /** The items in the list. */\n items: SignalLike<T[]>;\n\n /** The active item. */\n activeItem: WritableSignalLike<T | undefined>;\n\n /** Whether disabled items in the list should be focusable. */\n softDisabled: SignalLike<boolean>;\n\n /** The html element that should receive focus. */\n element: SignalLike<HTMLElement | undefined>;\n}\n\n/** Controls focus for a list of items. */\nexport class ListFocus<T extends ListFocusItem> {\n /** The last item that was active. */\n prevActiveItem = signal<T | undefined>(undefined);\n\n /** The index of the last item that was active. */\n prevActiveIndex = computed(() => {\n return this.prevActiveItem() ? this.inputs.items().indexOf(this.prevActiveItem()!) : -1;\n });\n\n /** The current active index in the list. */\n activeIndex = computed(() => {\n return this.inputs.activeItem() ? this.inputs.items().indexOf(this.inputs.activeItem()!) : -1;\n });\n\n constructor(readonly inputs: ListFocusInputs<T>) {}\n\n /** Whether the list is in a disabled state. */\n isListDisabled(): boolean {\n return this.inputs.disabled() || this.inputs.items().every(i => i.disabled());\n }\n\n /** The id of the current active item. */\n getActiveDescendant(): string | undefined {\n if (this.isListDisabled()) {\n return undefined;\n }\n if (this.inputs.focusMode() === 'roving') {\n return undefined;\n }\n return this.inputs.activeItem()?.id() ?? undefined;\n }\n\n /** The tab index for the list. */\n getListTabIndex(): -1 | 0 {\n if (this.isListDisabled()) {\n return 0;\n }\n return this.inputs.focusMode() === 'activedescendant' ? 0 : -1;\n }\n\n /** Returns the tab index for the given item. */\n getItemTabIndex(item: T): -1 | 0 {\n if (this.isListDisabled()) {\n return -1;\n }\n if (this.inputs.focusMode() === 'activedescendant') {\n return -1;\n }\n return this.inputs.activeItem() === item ? 0 : -1;\n }\n\n /** Moves focus to the given item if it is focusable. */\n focus(item: T, opts?: {focusElement?: boolean}): boolean {\n if (this.isListDisabled() || !this.isFocusable(item)) {\n return false;\n }\n\n this.prevActiveItem.set(this.inputs.activeItem());\n this.inputs.activeItem.set(item);\n\n if (opts?.focusElement || opts?.focusElement === undefined) {\n this.inputs.focusMode() === 'roving'\n ? item.element()?.focus()\n : this.inputs.element()?.focus();\n }\n\n return true;\n }\n\n /** Returns true if the given item can be navigated to. */\n isFocusable(item: T): boolean {\n return !item.disabled() || this.inputs.softDisabled();\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {SignalLike} from '../signal-like/signal-like';\nimport {ListFocus, ListFocusInputs, ListFocusItem} from '../list-focus/list-focus';\n\n/** Represents an item in a collection, such as a listbox option, than can be navigated to. */\nexport interface ListNavigationItem extends ListFocusItem {}\n\n/** Represents the required inputs for a collection that has navigable items. */\nexport interface ListNavigationInputs<T extends ListNavigationItem> extends ListFocusInputs<T> {\n /** Whether focus should wrap when navigating. */\n wrap: SignalLike<boolean>;\n\n /** Whether the list is vertically or horizontally oriented. */\n orientation: SignalLike<'vertical' | 'horizontal'>;\n\n /** The direction that text is read based on the users locale. */\n textDirection: SignalLike<'rtl' | 'ltr'>;\n}\n\n/** Options for list navigation. */\nexport interface ListNavigationOpts<T> {\n /**\n * Whether to focus the item's element.\n * Defaults to true.\n */\n focusElement?: boolean;\n\n /**\n * The list of items to navigate through.\n * Defaults to the list of items from the inputs.\n */\n items?: T[];\n}\n\n/** Controls navigation for a list of items. */\nexport class ListNavigation<T extends ListNavigationItem> {\n constructor(readonly inputs: ListNavigationInputs<T> & {focusManager: ListFocus<T>}) {}\n\n /** Navigates to the given item. */\n goto(item?: T, opts?: ListNavigationOpts<T>): boolean {\n return item ? this.inputs.focusManager.focus(item, opts) : false;\n }\n\n /** Navigates to the next item in the list. */\n next(opts?: ListNavigationOpts<T>): boolean {\n return this._advance(1, opts);\n }\n\n /** Peeks the next item in the list. */\n peekNext(opts?: ListNavigationOpts<T>): T | undefined {\n return this._peek(1, opts);\n }\n\n /** Navigates to the previous item in the list. */\n prev(opts?: ListNavigationOpts<T>): boolean {\n return this._advance(-1, opts);\n }\n\n /** Peeks the previous item in the list. */\n peekPrev(opts?: ListNavigationOpts<T>): T | undefined {\n return this._peek(-1, opts);\n }\n\n /** Navigates to the first item in the list. */\n first(opts?: ListNavigationOpts<T>): boolean {\n const item = this.peekFirst(opts);\n return item ? this.goto(item, opts) : false;\n }\n\n /** Navigates to the last item in the list. */\n last(opts?: ListNavigationOpts<T>): boolean {\n const item = this.peekLast(opts);\n return item ? this.goto(item, opts) : false;\n }\n\n /** Gets the first focusable item from the given list of items. */\n peekFirst(opts?: ListNavigationOpts<T>): T | undefined {\n const items = opts?.items ?? this.inputs.items();\n return items.find(i => this.inputs.focusManager.isFocusable(i));\n }\n\n /** Gets the last focusable item from the given list of items. */\n peekLast(opts?: ListNavigationOpts<T>): T | undefined {\n const items = opts?.items ?? this.inputs.items();\n for (let i = items.length - 1; i >= 0; i--) {\n if (this.inputs.focusManager.isFocusable(items[i])) {\n return items[i];\n }\n }\n return;\n }\n\n /** Advances to the next or previous focusable item in the list based on the given delta. */\n private _advance(delta: 1 | -1, opts?: ListNavigationOpts<T>): boolean {\n const item = this._peek(delta, opts);\n return item ? this.goto(item, opts) : false;\n }\n\n /** Peeks the next or previous focusable item in the list based on the given delta. */\n private _peek(delta: 1 | -1, opts?: ListNavigationOpts<T>): T | undefined {\n const items = opts?.items ?? this.inputs.items();\n const itemCount = items.length;\n const activeItem = this.inputs.focusManager.inputs.activeItem();\n const startIndex =\n opts?.items && activeItem\n ? items.indexOf(activeItem)\n : this.inputs.focusManager.activeIndex();\n\n const step = (i: number) =>\n this.inputs.wrap() ? (i + delta + itemCount) % itemCount : i + delta;\n\n // If wrapping is enabled, this loop ultimately terminates when `i` gets back to `startIndex`\n // in the case that all options are disabled. If wrapping is disabled, the loop terminates\n // when the index goes out of bounds.\n for (let i = step(startIndex); i !== startIndex && i < itemCount && i >= 0; i = step(i)) {\n if (this.inputs.focusManager.isFocusable(items[i])) {\n return items[i];\n }\n }\n\n return;\n }\n}\n"],"names":["ListFocus","inputs","prevActiveItem","signal","undefined","prevActiveIndex","computed","items","indexOf","activeIndex","activeItem","constructor","isListDisabled","disabled","every","i","getActiveDescendant","focusMode","id","getListTabIndex","getItemTabIndex","item","focus","opts","isFocusable","set","focusElement","element","softDisabled","ListNavigation","goto","focusManager","next","_advance","peekNext","_peek","prev","peekPrev","first","peekFirst","last","peekLast","find","length","delta","itemCount","startIndex","step","wrap"],"mappings":";;MA4CaA,SAAS,CAAA;EAcCC,MAAA;AAZrBC,EAAAA,cAAc,GAAGC,MAAM,CAAgBC,SAAS,CAAC;EAGjDC,eAAe,GAAGC,QAAQ,CAAC,MAAK;IAC9B,OAAO,IAAI,CAACJ,cAAc,EAAE,GAAG,IAAI,CAACD,MAAM,CAACM,KAAK,EAAE,CAACC,OAAO,CAAC,IAAI,CAACN,cAAc,EAAG,CAAC,GAAG,EAAE;AACzF,EAAA,CAAC,CAAC;EAGFO,WAAW,GAAGH,QAAQ,CAAC,MAAK;AAC1B,IAA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CAACD,UAAU,CAAC,EAAE/B,CAAC,KAAK+B,UAAU,IAAI/B,CAAC,GAAG8B,SAAS,IAAI9B,CAAC,IAAI,CAAC,EAAEA,CAAC,GAAGgC,IAAI,CAAChC,CAAC,CAAC,EAAE;AACvF,MAAA,IAAI,IAAI,CAACd,MAAM,CAAC8B,YAAY,CAACP,WAAW,CAACjB,KAAK,CAACQ,CAAC,CAAC,CAAC,EAAE;QAClD,OAAOR,KAAK,CAACQ,CAAC,CAAC;AACjB,MAAA;AACF,IAAA;AAEA,IAAA;AACF,EAAA;AACD;;;;"}
@@ -4,7 +4,7 @@ class ListSelection {
4
4
  inputs;
5
5
  rangeStartIndex = signal(0);
6
6
  rangeEndIndex = signal(0);
7
- selectedItems = computed(() => this.inputs.items().filter(item => this.inputs.values().includes(item.value())));
7
+ selectedItems = computed(() => this.inputs.items().filter(item => this.inputs.value().includes(item.value())));
8
8
  constructor(inputs) {
9
9
  this.inputs = inputs;
10
10
  }
@@ -12,7 +12,7 @@ class ListSelection {
12
12
  anchor: true
13
13
  }) {
14
14
  item = item ?? this.inputs.focusManager.inputs.activeItem();
15
- if (!item || item.disabled() || !item.selectable() || !this.inputs.focusManager.isFocusable(item) || this.inputs.values().includes(item.value())) {
15
+ if (!item || item.disabled() || !item.selectable() || !this.inputs.focusManager.isFocusable(item) || this.inputs.value().includes(item.value())) {
16
16
  return;
17
17
  }
18
18
  if (!this.inputs.multi()) {
@@ -22,24 +22,24 @@ class ListSelection {
22
22
  if (opts.anchor) {
23
23
  this.beginRangeSelection(index);
24
24
  }
25
- this.inputs.values.update(values => values.concat(item.value()));
25
+ this.inputs.value.update(values => values.concat(item.value()));
26
26
  }
27
27
  deselect(item) {
28
28
  item = item ?? this.inputs.focusManager.inputs.activeItem();
29
29
  if (item && !item.disabled() && item.selectable()) {
30
- this.inputs.values.update(values => values.filter(value => value !== item.value()));
30
+ this.inputs.value.update(values => values.filter(value => value !== item.value()));
31
31
  }
32
32
  }
33
33
  toggle(item) {
34
34
  item = item ?? this.inputs.focusManager.inputs.activeItem();
35
35
  if (item) {
36
- this.inputs.values().includes(item.value()) ? this.deselect(item) : this.select(item);
36
+ this.inputs.value().includes(item.value()) ? this.deselect(item) : this.select(item);
37
37
  }
38
38
  }
39
39
  toggleOne() {
40
40
  const item = this.inputs.focusManager.inputs.activeItem();
41
41
  if (item) {
42
- this.inputs.values().includes(item.value()) ? this.deselect() : this.selectOne();
42
+ this.inputs.value().includes(item.value()) ? this.deselect() : this.selectOne();
43
43
  }
44
44
  }
45
45
  selectAll() {
@@ -54,14 +54,14 @@ class ListSelection {
54
54
  this.beginRangeSelection();
55
55
  }
56
56
  deselectAll() {
57
- for (const value of this.inputs.values()) {
57
+ for (const value of this.inputs.value()) {
58
58
  const item = this.inputs.items().find(i => i.value() === value);
59
- item ? this.deselect(item) : this.inputs.values.update(values => values.filter(v => v !== value));
59
+ item ? this.deselect(item) : this.inputs.value.update(values => values.filter(v => v !== value));
60
60
  }
61
61
  }
62
62
  toggleAll() {
63
63
  const selectableValues = this.inputs.items().filter(i => !i.disabled() && i.selectable() && this.inputs.focusManager.isFocusable(i)).map(i => i.value());
64
- selectableValues.every(i => this.inputs.values().includes(i)) ? this.deselectAll() : this.selectAll();
64
+ selectableValues.every(i => this.inputs.value().includes(i)) ? this.deselectAll() : this.selectAll();
65
65
  }
66
66
  selectOne() {
67
67
  const item = this.inputs.focusManager.inputs.activeItem();
@@ -69,7 +69,7 @@ class ListSelection {
69
69
  return;
70
70
  }
71
71
  this.deselectAll();
72
- if (this.inputs.values().length > 0 && !this.inputs.multi()) {
72
+ if (this.inputs.value().length > 0 && !this.inputs.multi()) {
73
73
  return;
74
74
  }
75
75
  this.select();
@@ -1 +1 @@
1
- {"version":3,"file":"_list-typeahead-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/behaviors/list-selection/list-selection.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/behaviors/list-typeahead/list-typeahead.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, signal, SignalLike, WritableSignalLike} from '../signal-like/signal-like';\nimport {ListFocus, ListFocusInputs, ListFocusItem} from '../list-focus/list-focus';\n\n/** Represents an item in a collection, such as a listbox option, that can be selected. */\nexport interface ListSelectionItem<V> extends ListFocusItem {\n /** The value of the item. */\n value: SignalLike<V>;\n\n /** Whether the item is selectable. */\n selectable: SignalLike<boolean>;\n}\n\n/** Represents the required inputs for a collection that contains selectable items. */\nexport interface ListSelectionInputs<T extends ListSelectionItem<V>, V> extends ListFocusInputs<T> {\n /** Whether multiple items in the list can be selected at once. */\n multi: SignalLike<boolean>;\n\n /** The current value of the list selection. */\n values: WritableSignalLike<V[]>;\n\n /** The selection strategy used by the list. */\n selectionMode: SignalLike<'follow' | 'explicit'>;\n}\n\n/** Controls selection for a list of items. */\nexport class ListSelection<T extends ListSelectionItem<V>, V> {\n /** The start index to use for range selection. */\n rangeStartIndex = signal<number>(0);\n\n /** The end index to use for range selection. */\n rangeEndIndex = signal<number>(0);\n\n /** The currently selected items. */\n selectedItems = computed(() =>\n this.inputs.items().filter(item => this.inputs.values().includes(item.value())),\n );\n\n constructor(readonly inputs: ListSelectionInputs<T, V> & {focusManager: ListFocus<T>}) {}\n\n /** Selects the item at the current active index. */\n select(item?: ListSelectionItem<V>, opts = {anchor: true}) {\n item = item ?? (this.inputs.focusManager.inputs.activeItem() as ListSelectionItem<V>);\n\n if (\n !item ||\n item.disabled() ||\n !item.selectable() ||\n !this.inputs.focusManager.isFocusable(item as T) ||\n this.inputs.values().includes(item.value())\n ) {\n return;\n }\n\n if (!this.inputs.multi()) {\n this.deselectAll();\n }\n\n const index = this.inputs.items().findIndex(i => i === item);\n if (opts.anchor) {\n this.beginRangeSelection(index);\n }\n this.inputs.values.update(values => values.concat(item.value()));\n }\n\n /** Deselects the item at the current active index. */\n deselect(item?: ListSelectionItem<V>) {\n item = item ?? this.inputs.focusManager.inputs.activeItem();\n\n if (item && !item.disabled() && item.selectable()) {\n this.inputs.values.update(values => values.filter(value => value !== item.value()));\n }\n }\n\n /** Toggles the item at the current active index. */\n toggle(item?: ListSelectionItem<V>) {\n item = item ?? this.inputs.focusManager.inputs.activeItem();\n if (item) {\n this.inputs.values().includes(item.value()) ? this.deselect(item) : this.select(item);\n }\n }\n\n /** Toggles only the item at the current active index. */\n toggleOne() {\n const item = this.inputs.focusManager.inputs.activeItem();\n if (item) {\n this.inputs.values().includes(item.value()) ? this.deselect() : this.selectOne();\n }\n }\n\n /** Selects all items in the list. */\n selectAll() {\n if (!this.inputs.multi()) {\n return; // Should we log a warning?\n }\n\n for (const item of this.inputs.items()) {\n this.select(item, {anchor: false});\n }\n\n this.beginRangeSelection();\n }\n\n /** Deselects all items in the list. */\n deselectAll() {\n // If an item is not in the list, it forcefully gets deselected.\n // This actually creates a bug for the following edge case:\n //\n // Setup: An item is not in the list (maybe it's lazily loaded), and it is disabled & selected.\n // Expected: If deselectAll() is called, it should NOT get deselected (because it is disabled).\n // Actual: Calling deselectAll() will still deselect the item.\n //\n // Why? Because we can't check if the item is disabled if it's not in the list.\n //\n // Alternatively, we could NOT deselect items that are not in the list, but this has the\n // inverse (and more common) effect of keeping enabled items selected when they aren't in the\n // list.\n\n for (const value of this.inputs.values()) {\n const item = this.inputs.items().find(i => i.value() === value);\n\n item\n ? this.deselect(item)\n : this.inputs.values.update(values => values.filter(v => v !== value));\n }\n }\n\n /**\n * Selects all items in the list or deselects all\n * items in the list if all items are already selected.\n */\n toggleAll() {\n const selectableValues = this.inputs\n .items()\n .filter(i => !i.disabled() && i.selectable() && this.inputs.focusManager.isFocusable(i))\n .map(i => i.value());\n\n selectableValues.every(i => this.inputs.values().includes(i))\n ? this.deselectAll()\n : this.selectAll();\n }\n\n /** Sets the selection to only the current active item. */\n selectOne() {\n const item = this.inputs.focusManager.inputs.activeItem();\n if (item && (item.disabled() || !item.selectable())) {\n return;\n }\n\n this.deselectAll();\n\n if (this.inputs.values().length > 0 && !this.inputs.multi()) {\n return;\n }\n\n this.select();\n }\n\n /**\n * Selects all items in the list up to the anchor item.\n *\n * Deselects all items that were previously within the\n * selected range that are now outside of the selected range\n */\n selectRange(opts = {anchor: true}) {\n const isStartOfRange = this.inputs.focusManager.prevActiveIndex() === this.rangeStartIndex();\n\n if (isStartOfRange && opts.anchor) {\n this.beginRangeSelection(this.inputs.focusManager.prevActiveIndex());\n }\n\n const itemsInRange = this._getItemsFromIndex(this.rangeStartIndex());\n const itemsOutOfRange = this._getItemsFromIndex(this.rangeEndIndex()).filter(\n i => !itemsInRange.includes(i),\n );\n\n for (const item of itemsOutOfRange) {\n this.deselect(item);\n }\n\n for (const item of itemsInRange) {\n this.select(item, {anchor: false});\n }\n\n if (itemsInRange.length) {\n const item = itemsInRange.pop();\n const index = this.inputs.items().findIndex(i => i === item);\n this.rangeEndIndex.set(index);\n }\n }\n\n /** Marks the given index as the start of a range selection. */\n beginRangeSelection(index: number = this.inputs.focusManager.activeIndex()) {\n this.rangeStartIndex.set(index);\n this.rangeEndIndex.set(index);\n }\n\n /** Returns the items in the list starting from the given index. */\n private _getItemsFromIndex(index: number) {\n if (index === -1) {\n return [];\n }\n\n const upper = Math.max(this.inputs.focusManager.activeIndex(), index);\n const lower = Math.min(this.inputs.focusManager.activeIndex(), index);\n\n const items = [];\n for (let i = lower; i <= upper; i++) {\n items.push(this.inputs.items()[i]);\n }\n\n if (this.inputs.focusManager.activeIndex() < index) {\n return items.reverse();\n }\n\n return items;\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, signal, SignalLike} from '../signal-like/signal-like';\nimport {ListFocus, ListFocusInputs, ListFocusItem} from '../list-focus/list-focus';\n\n/**\n * Represents an item in a collection, such as a listbox option, than can be navigated to by\n * typeahead.\n */\nexport interface ListTypeaheadItem extends ListFocusItem {\n /** The text used by the typeahead search. */\n searchTerm: SignalLike<string>;\n}\n\n/**\n * Represents the required inputs for a collection that contains items that can be navigated to by\n * typeahead.\n */\nexport interface ListTypeaheadInputs<T extends ListTypeaheadItem> extends ListFocusInputs<T> {\n /** The amount of time before the typeahead search is reset. */\n typeaheadDelay: SignalLike<number>;\n}\n\n/** Controls typeahead for a list of items. */\nexport class ListTypeahead<T extends ListTypeaheadItem> {\n /** A reference to the timeout for resetting the typeahead search. */\n timeout?: ReturnType<typeof setTimeout> | undefined;\n\n /** The focus controller of the parent list. */\n focusManager: ListFocus<T>;\n\n /** Whether the user is actively typing a typeahead search query. */\n isTyping = computed(() => this._query().length > 0);\n\n /** Keeps track of the characters that typeahead search is being called with. */\n private _query = signal('');\n\n /** The index where that the typeahead search was initiated from. */\n private _startIndex = signal<number | undefined>(undefined);\n\n constructor(readonly inputs: ListTypeaheadInputs<T> & {focusManager: ListFocus<T>}) {\n this.focusManager = inputs.focusManager;\n }\n\n /** Performs a typeahead search, appending the given character to the search string. */\n search(char: string): boolean {\n if (char.length !== 1) {\n return false;\n }\n\n if (!this.isTyping() && char === ' ') {\n return false;\n }\n\n if (this._startIndex() === undefined) {\n this._startIndex.set(this.focusManager.activeIndex());\n }\n\n clearTimeout(this.timeout);\n this._query.update(q => q + char.toLowerCase());\n const item = this._getItem();\n\n if (item) {\n this.focusManager.focus(item);\n }\n\n this.timeout = setTimeout(() => {\n this._query.set('');\n this._startIndex.set(undefined);\n }, this.inputs.typeaheadDelay());\n\n return true;\n }\n\n /**\n * Returns the first item whose search term matches the\n * current query starting from the the current anchor index.\n */\n private _getItem() {\n const items = this.focusManager.inputs.items();\n const itemCount = items.length;\n const startIndex = this._startIndex()!;\n\n for (let i = 0; i < itemCount; i++) {\n const index = (startIndex + 1 + i) % itemCount;\n const item = items[index];\n\n if (\n this.focusManager.isFocusable(item) &&\n item.searchTerm().toLowerCase().startsWith(this._query())\n ) {\n return item;\n }\n }\n\n return undefined;\n }\n}\n"],"names":["ListSelection","inputs","rangeStartIndex","signal","rangeEndIndex","selectedItems","computed","items","filter","item","values","includes","value","constructor","select","opts","anchor","focusManager","activeItem","disabled","selectable","isFocusable","multi","deselectAll","index","findIndex","i","beginRangeSelection","update","concat","deselect","toggle","toggleOne","selectOne","selectAll","find","v","toggleAll","selectableValues","map","every","length","selectRange","isStartOfRange","prevActiveIndex","itemsInRange","_getItemsFromIndex","itemsOutOfRange","pop","set","activeIndex","upper","Math","max","lower","min","push","reverse","ListTypeahead","timeout","isTyping","_query","_startIndex","undefined","search","char","clearTimeout","q","toLowerCase","_getItem","focus","setTimeout","typeaheadDelay","itemCount","startIndex","searchTerm","startsWith"],"mappings":";;MAiCaA,aAAa,CAAA;EAYHC,MAAA;AAVrBC,EAAAA,eAAe,GAAGC,MAAM,CAAS,CAAC,CAAC;AAGnCC,EAAAA,aAAa,GAAGD,MAAM,CAAS,CAAC,CAAC;AAGjCE,EAAAA,aAAa,GAAGC,QAAQ,CAAC,MACvB,IAAI,CAACL,MAAM,CAACM,KAAK,EAAE,CAACC,MAAM,CAACC,IAAI,IAAI,IAAI,CAACR,MAAM,CAACS,MAAM,EAAE,CAACC,QAAQ,CAACF,IAAI,CAACG,KAAK,EAAE,CAAC,CAAC,CAChF;EAEDC,WAAAA,CAAqBZ,MAAgE,EAAA;IAAhE,IAAM,CAAAA,MAAA,GAANA,MAAM;AAA6D;AAGxFa,EAAAA,MAAMA,CAACL,IAA2B,EAAEM,IAAI,GAAG;AAACC,IAAAA,MAAM,EAAE;AAAK,GAAA,EAAA;AACvDP,IAAAA,IAAI,GAAGA,IAAI,IAAK,IAAI,CAACR,MAAM,CAACgB,YAAY,CAAChB,MAAM,CAACiB,UAAU,EAA2B;IAErF,IACE,CAACT,IAAI,IACLA,IAAI,CAACU,QAAQ,EAAE,IACf,CAACV,IAAI,CAACW,UAAU,EAAE,IAClB,CAAC,IAAI,CAACnB,M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AAE,EAAE;MAClC,MAAMF,KAAK,GAAG,CAACkD,UAAU,GAAG,CAAC,GAAGhD,CAAC,IAAI+C,SAAS;AAC9C,MAAA,MAAMhE,IAAI,GAAGF,KAAK,CAACiB,KAAK,CAAC;MAEzB,IACE,IAAI,CAACP,YAAY,CAACI,WAAW,CAACZ,IAAI,CAAC,IACnCA,IAAI,CAACkE,UAAU,EAAE,CAACP,WAAW,EAAE,CAACQ,UAAU,CAAC,IAAI,CAACf,MAAM,EAAE,CAAC,EACzD;AACA,QAAA,OAAOpD,IAAI;AACb;AACF;AAEA,IAAA,OAAOsD,SAAS;AAClB;AACD;;;;"}
1
+ {"version":3,"file":"_list-typeahead-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/behaviors/list-selection/list-selection.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/behaviors/list-typeahead/list-typeahead.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, signal, SignalLike, WritableSignalLike} from '../signal-like/signal-like';\nimport {ListFocus, ListFocusInputs, ListFocusItem} from '../list-focus/list-focus';\n\n/** Represents an item in a collection, such as a listbox option, that can be selected. */\nexport interface ListSelectionItem<V> extends ListFocusItem {\n /** The value of the item. */\n value: SignalLike<V>;\n\n /** Whether the item is selectable. */\n selectable: SignalLike<boolean>;\n}\n\n/** Represents the required inputs for a collection that contains selectable items. */\nexport interface ListSelectionInputs<T extends ListSelectionItem<V>, V> extends ListFocusInputs<T> {\n /** Whether multiple items in the list can be selected at once. */\n multi: SignalLike<boolean>;\n\n /** The current value of the list selection. */\n value: WritableSignalLike<V[]>;\n\n /** The selection strategy used by the list. */\n selectionMode: SignalLike<'follow' | 'explicit'>;\n}\n\n/** Controls selection for a list of items. */\nexport class ListSelection<T extends ListSelectionItem<V>, V> {\n /** The start index to use for range selection. */\n rangeStartIndex = signal<number>(0);\n\n /** The end index to use for range selection. */\n rangeEndIndex = signal<number>(0);\n\n /** The currently selected items. */\n selectedItems = computed(() =>\n this.inputs.items().filter(item => this.inputs.value().includes(item.value())),\n );\n\n constructor(readonly inputs: ListSelectionInputs<T, V> & {focusManager: ListFocus<T>}) {}\n\n /** Selects the item at the current active index. */\n select(item?: ListSelectionItem<V>, opts = {anchor: true}) {\n item = item ?? (this.inputs.focusManager.inputs.activeItem() as ListSelectionItem<V>);\n\n if (\n !item ||\n item.disabled() ||\n !item.selectable() ||\n !this.inputs.focusManager.isFocusable(item as T) ||\n this.inputs.value().includes(item.value())\n ) {\n return;\n }\n\n if (!this.inputs.multi()) {\n this.deselectAll();\n }\n\n const index = this.inputs.items().findIndex(i => i === item);\n if (opts.anchor) {\n this.beginRangeSelection(index);\n }\n this.inputs.value.update(values => values.concat(item.value()));\n }\n\n /** Deselects the item at the current active index. */\n deselect(item?: ListSelectionItem<V>) {\n item = item ?? this.inputs.focusManager.inputs.activeItem();\n\n if (item && !item.disabled() && item.selectable()) {\n this.inputs.value.update(values => values.filter(value => value !== item.value()));\n }\n }\n\n /** Toggles the item at the current active index. */\n toggle(item?: ListSelectionItem<V>) {\n item = item ?? this.inputs.focusManager.inputs.activeItem();\n if (item) {\n this.inputs.value().includes(item.value()) ? this.deselect(item) : this.select(item);\n }\n }\n\n /** Toggles only the item at the current active index. */\n toggleOne() {\n const item = this.inputs.focusManager.inputs.activeItem();\n if (item) {\n this.inputs.value().includes(item.value()) ? this.deselect() : this.selectOne();\n }\n }\n\n /** Selects all items in the list. */\n selectAll() {\n if (!this.inputs.multi()) {\n return; // Should we log a warning?\n }\n\n for (const item of this.inputs.items()) {\n this.select(item, {anchor: false});\n }\n\n this.beginRangeSelection();\n }\n\n /** Deselects all items in the list. */\n deselectAll() {\n // If an item is not in the list, it forcefully gets deselected.\n // This actually creates a bug for the following edge case:\n //\n // Setup: An item is not in the list (maybe it's lazily loaded), and it is disabled & selected.\n // Expected: If deselectAll() is called, it should NOT get deselected (because it is disabled).\n // Actual: Calling deselectAll() will still deselect the item.\n //\n // Why? Because we can't check if the item is disabled if it's not in the list.\n //\n // Alternatively, we could NOT deselect items that are not in the list, but this has the\n // inverse (and more common) effect of keeping enabled items selected when they aren't in the\n // list.\n\n for (const value of this.inputs.value()) {\n const item = this.inputs.items().find(i => i.value() === value);\n\n item\n ? this.deselect(item)\n : this.inputs.value.update(values => values.filter(v => v !== value));\n }\n }\n\n /**\n * Selects all items in the list or deselects all\n * items in the list if all items are already selected.\n */\n toggleAll() {\n const selectableValues = this.inputs\n .items()\n .filter(i => !i.disabled() && i.selectable() && this.inputs.focusManager.isFocusable(i))\n .map(i => i.value());\n\n selectableValues.every(i => this.inputs.value().includes(i))\n ? this.deselectAll()\n : this.selectAll();\n }\n\n /** Sets the selection to only the current active item. */\n selectOne() {\n const item = this.inputs.focusManager.inputs.activeItem();\n if (item && (item.disabled() || !item.selectable())) {\n return;\n }\n\n this.deselectAll();\n\n if (this.inputs.value().length > 0 && !this.inputs.multi()) {\n return;\n }\n\n this.select();\n }\n\n /**\n * Selects all items in the list up to the anchor item.\n *\n * Deselects all items that were previously within the\n * selected range that are now outside of the selected range\n */\n selectRange(opts = {anchor: true}) {\n const isStartOfRange = this.inputs.focusManager.prevActiveIndex() === this.rangeStartIndex();\n\n if (isStartOfRange && opts.anchor) {\n this.beginRangeSelection(this.inputs.focusManager.prevActiveIndex());\n }\n\n const itemsInRange = this._getItemsFromIndex(this.rangeStartIndex());\n const itemsOutOfRange = this._getItemsFromIndex(this.rangeEndIndex()).filter(\n i => !itemsInRange.includes(i),\n );\n\n for (const item of itemsOutOfRange) {\n this.deselect(item);\n }\n\n for (const item of itemsInRange) {\n this.select(item, {anchor: false});\n }\n\n if (itemsInRange.length) {\n const item = itemsInRange.pop();\n const index = this.inputs.items().findIndex(i => i === item);\n this.rangeEndIndex.set(index);\n }\n }\n\n /** Marks the given index as the start of a range selection. */\n beginRangeSelection(index: number = this.inputs.focusManager.activeIndex()) {\n this.rangeStartIndex.set(index);\n this.rangeEndIndex.set(index);\n }\n\n /** Returns the items in the list starting from the given index. */\n private _getItemsFromIndex(index: number) {\n if (index === -1) {\n return [];\n }\n\n const upper = Math.max(this.inputs.focusManager.activeIndex(), index);\n const lower = Math.min(this.inputs.focusManager.activeIndex(), index);\n\n const items = [];\n for (let i = lower; i <= upper; i++) {\n items.push(this.inputs.items()[i]);\n }\n\n if (this.inputs.focusManager.activeIndex() < index) {\n return items.reverse();\n }\n\n return items;\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, signal, SignalLike} from '../signal-like/signal-like';\nimport {ListFocus, ListFocusInputs, ListFocusItem} from '../list-focus/list-focus';\n\n/**\n * Represents an item in a collection, such as a listbox option, than can be navigated to by\n * typeahead.\n */\nexport interface ListTypeaheadItem extends ListFocusItem {\n /** The text used by the typeahead search. */\n searchTerm: SignalLike<string>;\n}\n\n/**\n * Represents the required inputs for a collection that contains items that can be navigated to by\n * typeahead.\n */\nexport interface ListTypeaheadInputs<T extends ListTypeaheadItem> extends ListFocusInputs<T> {\n /** The amount of time before the typeahead search is reset. */\n typeaheadDelay: SignalLike<number>;\n}\n\n/** Controls typeahead for a list of items. */\nexport class ListTypeahead<T extends ListTypeaheadItem> {\n /** A reference to the timeout for resetting the typeahead search. */\n timeout?: ReturnType<typeof setTimeout> | undefined;\n\n /** The focus controller of the parent list. */\n focusManager: ListFocus<T>;\n\n /** Whether the user is actively typing a typeahead search query. */\n isTyping = computed(() => this._query().length > 0);\n\n /** Keeps track of the characters that typeahead search is being called with. */\n private _query = signal('');\n\n /** The index where that the typeahead search was initiated from. */\n private _startIndex = signal<number | undefined>(undefined);\n\n constructor(readonly inputs: ListTypeaheadInputs<T> & {focusManager: ListFocus<T>}) {\n this.focusManager = inputs.focusManager;\n }\n\n /** Performs a typeahead search, appending the given character to the search string. */\n search(char: string): boolean {\n if (char.length !== 1) {\n return false;\n }\n\n if (!this.isTyping() && char === ' ') {\n return false;\n }\n\n if (this._startIndex() === undefined) {\n this._startIndex.set(this.focusManager.activeIndex());\n }\n\n clearTimeout(this.timeout);\n this._query.update(q => q + char.toLowerCase());\n const item = this._getItem();\n\n if (item) {\n this.focusManager.focus(item);\n }\n\n this.timeout = setTimeout(() => {\n this._query.set('');\n this._startIndex.set(undefined);\n }, this.inputs.typeaheadDelay());\n\n return true;\n }\n\n /**\n * Returns the first item whose search term matches the\n * current query starting from the the current anchor index.\n */\n private _getItem() {\n const items = this.focusManager.inputs.items();\n const itemCount = items.length;\n const startIndex = this._startIndex()!;\n\n for (let i = 0; i < itemCount; i++) {\n const index = (startIndex + 1 + i) % itemCount;\n const item = items[index];\n\n if (\n this.focusManager.isFocusable(item) &&\n item.searchTerm().toLowerCase().startsWith(this._query())\n ) {\n return item;\n }\n }\n\n return undefined;\n }\n}\n"],"names":["ListSelection","inputs","rangeStartIndex","signal","rangeEndIndex","selectedItems","computed","items","filter","item","value","includes","constructor","select","opts","anchor","focusManager","activeItem","disabled","selectable","isFocusable","multi","deselectAll","index","findIndex","i","beginRangeSelection","update","values","concat","deselect","toggle","toggleOne","selectOne","selectAll","find","v","toggleAll","selectableValues","map","every","length","selectRange","isStartOfRange","prevActiveIndex","itemsInRange","_getItemsFromIndex","itemsOutOfRange","pop","set","activeIndex","upper","Math","max","lower","min","push","reverse","ListTypeahead","timeout","isTyping","_query","_startIndex","undefined","search","char","clearTimeout","q","toLowerCase","_getItem","focus","setTimeout","typeaheadDelay","itemCount","startIndex","searchTerm","startsWith"],"mappings":";;MAiCaA,aAAa,CAAA;EAYHC,MAAA;AAVrBC,EAAAA,eAAe,GAAGC,MAAM,CAAS,CAAC,CAAC;AAGnCC,EAAAA,aAAa,GAAGD,MAAM,CAAS,CAAC,CAAC;AAGjCE,EAAAA,aAAa,GAAGC,QAAQ,CAAC,MACv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? !!this.inputs.parent()?.expanded() : true);
10
10
  listBehavior;
11
11
  isFocused = signal(false);
12
- hasBeenFocused = signal(false);
12
+ hasBeenInteracted = signal(false);
13
13
  hasBeenHovered = signal(false);
14
14
  _openTimeout;
15
15
  _closeTimeout;
@@ -58,17 +58,27 @@ class MenuPattern {
58
58
  this.id = inputs.id;
59
59
  this.listBehavior = new List({
60
60
  ...inputs,
61
- values: signal([])
61
+ value: signal([])
62
62
  });
63
63
  }
64
64
  setDefaultState() {
65
65
  if (!this.inputs.parent()) {
66
- this.listBehavior.goto(this.inputs.items()[0], {
67
- focusElement: false
68
- });
66
+ const firstFocusable = this.listBehavior.navigationBehavior.peekFirst();
67
+ if (firstFocusable) {
68
+ this.listBehavior.goto(firstFocusable, {
69
+ focusElement: false
70
+ });
71
+ }
72
+ }
73
+ }
74
+ setDefaultStateEffect() {
75
+ if (this.hasBeenInteracted() || this.hasBeenHovered()) return;
76
+ if (this.inputs.items().length > 0) {
77
+ this.setDefaultState();
69
78
  }
70
79
  }
71
80
  onKeydown(event) {
81
+ this.hasBeenInteracted.set(true);
72
82
  this.keydownManager().handle(event);
73
83
  }
74
84
  onMouseOver(event) {
@@ -148,7 +158,7 @@ class MenuPattern {
148
158
  }
149
159
  onFocusIn() {
150
160
  this.isFocused.set(true);
151
- this.hasBeenFocused.set(true);
161
+ this.hasBeenInteracted.set(true);
152
162
  }
153
163
  onFocusOut(event) {
154
164
  const parent = this.inputs.parent();
@@ -285,7 +295,7 @@ class MenuBarPattern {
285
295
  dynamicSpaceKey = computed(() => this.listBehavior.isTyping() ? '' : ' ');
286
296
  typeaheadRegexp = /^.$/;
287
297
  isFocused = signal(false);
288
- hasBeenFocused = signal(false);
298
+ hasBeenInteracted = signal(false);
289
299
  disabled = () => this.inputs.disabled();
290
300
  keydownManager = computed(() => {
291
301
  return new KeyboardEventManager().on(this._nextKey, () => this.next(), {
@@ -307,9 +317,19 @@ class MenuBarPattern {
307
317
  this.listBehavior = new List(inputs);
308
318
  }
309
319
  setDefaultState() {
310
- this.inputs.activeItem.set(this.inputs.items()[0]);
320
+ const firstFocusable = this.listBehavior.navigationBehavior.peekFirst();
321
+ if (firstFocusable) {
322
+ this.inputs.activeItem.set(firstFocusable);
323
+ }
324
+ }
325
+ setDefaultStateEffect() {
326
+ if (this.hasBeenInteracted()) return;
327
+ if (this.inputs.items().length > 0) {
328
+ this.setDefaultState();
329
+ }
311
330
  }
312
331
  onKeydown(event) {
332
+ this.hasBeenInteracted.set(true);
313
333
  this.keydownManager().handle(event);
314
334
  }
315
335
  onClick(event) {
@@ -330,7 +350,7 @@ class MenuBarPattern {
330
350
  }
331
351
  onFocusIn() {
332
352
  this.isFocused.set(true);
333
- this.hasBeenFocused.set(true);
353
+ this.hasBeenInteracted.set(true);
334
354
  }
335
355
  onFocusOut(event) {
336
356
  const relatedTarget = event.relatedTarget;
@@ -382,7 +402,7 @@ class MenuBarPattern {
382
402
  class MenuTriggerPattern {
383
403
  inputs;
384
404
  expanded = signal(false);
385
- hasBeenFocused = signal(false);
405
+ hasBeenInteracted = signal(false);
386
406
  role = () => 'button';
387
407
  hasPopup = () => true;
388
408
  menu;
@@ -407,6 +427,7 @@ class MenuTriggerPattern {
407
427
  }
408
428
  onKeydown(event) {
409
429
  if (!this.inputs.disabled()) {
430
+ this.hasBeenInteracted.set(true);
410
431
  this.keydownManager().handle(event);
411
432
  }
412
433
  }
@@ -418,7 +439,7 @@ class MenuTriggerPattern {
418
439
  }
419
440
  }
420
441
  onFocusIn() {
421
- this.hasBeenFocused.set(true);
442
+ this.hasBeenInteracted.set(true);
422
443
  }
423
444
  onFocusOut(event) {
424
445
  const element = this.inputs.element();
@@ -458,7 +479,7 @@ class MenuItemPattern {
458
479
  searchTerm;
459
480
  element;
460
481
  active = computed(() => this.inputs.parent()?.inputs.activeItem() === this);
461
- hasBeenFocused = signal(false);
482
+ hasBeenInteracted = signal(false);
462
483
  tabIndex = computed(() => {
463
484
  if (this.submenu() && this.submenu()?.inputs.activeItem()) {
464
485
  return -1;
@@ -512,7 +533,7 @@ class MenuItemPattern {
512
533
  }
513
534
  }
514
535
  onFocusIn() {
515
- this.hasBeenFocused.set(true);
536
+ this.hasBeenInteracted.set(true);
516
537
  }
517
538
  }
518
539
 
@@ -1 +1 @@
1
- {"version":3,"file":"_menu-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/menu/menu.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {KeyboardEventManager} from '../behaviors/event-manager';\nimport {computed, signal, SignalLike} from '../behaviors/signal-like/signal-like';\nimport {List, ListInputs, ListItem} from '../behaviors/list/list';\n\n/** The inputs for the MenuBarPattern class. */\nexport interface MenuBarInputs<V> extends ListInputs<MenuItemPattern<V>, V> {\n /** The menu items contained in the menu. */\n items: SignalLike<MenuItemPattern<V>[]>;\n\n /** Callback function triggered when a menu item is selected. */\n itemSelected?: (value: V) => void;\n\n /** The text direction of the menu bar. */\n textDirection: SignalLike<'ltr' | 'rtl'>;\n}\n\n/** The inputs for the MenuPattern class. */\nexport interface MenuInputs<V> extends Omit<ListInputs<MenuItemPattern<V>, V>, 'values'> {\n /** The unique ID of the menu. */\n id: SignalLike<string>;\n\n /** The menu items contained in the menu. */\n items: SignalLike<MenuItemPattern<V>[]>;\n\n /** A reference to the parent menu or menu trigger. */\n parent: SignalLike<MenuTriggerPattern<V> | MenuItemPattern<V> | undefined>;\n\n /** Callback function triggered when a menu item is selected. */\n itemSelected?: (value: V) => void;\n\n /** The text direction of the menu bar. */\n textDirection: SignalLike<'ltr' | 'rtl'>;\n\n /** The delay in milliseconds before expanding sub-menus on hover. */\n expansionDelay: SignalLike<number>;\n}\n\n/** The inputs for the MenuTriggerPattern class. */\nexport interface MenuTriggerInputs<V> {\n /** A reference to the menu trigger element. */\n element: SignalLike<HTMLElement | undefined>;\n\n /** A reference to the menu associated with the trigger. */\n menu: SignalLike<MenuPattern<V> | undefined>;\n\n /** The text direction of the menu bar. */\n textDirection: SignalLike<'ltr' | 'rtl'>;\n\n /** Whether the menu trigger is disabled. */\n disabled: SignalLike<boolean>;\n}\n\n/** The inputs for the MenuItemPattern class. */\nexport interface MenuItemInputs<V> extends Omit<ListItem<V>, 'index' | 'selectable'> {\n /** A reference to the parent menu or menu trigger. */\n parent: SignalLike<MenuPattern<V> | MenuBarPattern<V> | undefined>;\n\n /** A reference to the submenu associated with the menu item. */\n submenu: SignalLike<MenuPattern<V> | undefined>;\n}\n\n/** The menu ui pattern class. */\nexport class MenuPattern<V> {\n /** The unique ID of the menu. */\n id: SignalLike<string>;\n\n /** The role of the menu. */\n role = () => 'menu';\n\n /** Whether the menu is disabled. */\n disabled = () => this.inputs.disabled();\n\n /** Whether the menu is visible. */\n visible = computed(() => (this.inputs.parent() ? !!this.inputs.parent()?.expanded() : true));\n\n /** Controls list behavior for the menu items. */\n listBehavior: List<MenuItemPattern<V>, V>;\n\n /** Whether the menu or any of its child elements are currently focused. */\n isFocused = signal(false);\n\n /** Whether the menu has received focus. */\n hasBeenFocused = signal(false);\n\n /** Whether the menu trigger has been hovered. */\n hasBeenHovered = signal(false);\n\n /** Timeout used to open sub-menus on hover. */\n _openTimeout: any;\n\n /** Timeout used to close sub-menus on hover out. */\n _closeTimeout: any;\n\n /** The tab index of the menu. */\n tabIndex = () => this.listBehavior.tabIndex();\n\n /** Whether the menu should be focused on mouse over. */\n shouldFocus = computed(() => {\n const root = this.root();\n\n if (root instanceof MenuTriggerPattern) {\n return true;\n }\n\n if (root instanceof MenuBarPattern || root instanceof MenuPattern) {\n return root.isFocused();\n }\n\n return false;\n });\n\n /** The key used to expand sub-menus. */\n private _expandKey = computed(() => {\n return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';\n });\n\n /** The key used to collapse sub-menus. */\n private _collapseKey = computed(() => {\n return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';\n });\n\n /** Represents the space key. Does nothing when the user is actively using typeahead. */\n dynamicSpaceKey = computed(() => (this.listBehavior.isTyping() ? '' : ' '));\n\n /** The regexp used to decide if a key should trigger typeahead. */\n typeaheadRegexp = /^.$/;\n\n /** The root of the menu. */\n root: SignalLike<MenuTriggerPattern<V> | MenuBarPattern<V> | MenuPattern<V> | undefined> =\n computed(() => {\n const parent = this.inputs.parent();\n\n if (!parent) {\n return this;\n }\n\n if (parent instanceof MenuTriggerPattern) {\n return parent;\n }\n\n const grandparent = parent.inputs.parent();\n\n if (grandparent instanceof MenuBarPattern) {\n return grandparent;\n }\n\n return grandparent?.root();\n });\n\n /** Handles keyboard events for the menu. */\n keydownManager = computed(() => {\n return new KeyboardEventManager()\n .on('ArrowDown', () => this.next(), {ignoreRepeat: false})\n .on('ArrowUp', () => this.prev(), {ignoreRepeat: false})\n .on('Home', () => this.first())\n .on('End', () => this.last())\n .on('Enter', () => this.trigger())\n .on('Escape', () => this.closeAll())\n .on(this._expandKey, () => this.expand())\n .on(this._collapseKey, () => this.collapse())\n .on(this.dynamicSpaceKey, () => this.trigger())\n .on(this.typeaheadRegexp, e => this.listBehavior.search(e.key));\n });\n\n constructor(readonly inputs: MenuInputs<V>) {\n this.id = inputs.id;\n this.listBehavior = new List<MenuItemPattern<V>, V>({\n ...inputs,\n values: signal([]),\n });\n }\n\n /** Sets the default state for the menu. */\n setDefaultState() {\n if (!this.inputs.parent()) {\n this.listBehavior.goto(this.inputs.items()[0], {focusElement: false});\n }\n }\n\n /** Handles keyboard events for the menu. */\n onKeydown(event: KeyboardEvent) {\n this.keydownManager().handle(event);\n }\n\n /** Handles mouseover events for the menu. */\n onMouseOver(event: MouseEvent) {\n if (!this.visible()) {\n return;\n }\n\n this.hasBeenHovered.set(true);\n const item = this.inputs.items().find(i => i.element()?.contains(event.target as Node));\n\n if (!item) {\n return;\n }\n\n const parent = this.inputs.parent();\n const activeItem = this?.inputs.activeItem();\n\n if (parent instanceof MenuItemPattern) {\n const grandparent = parent.inputs.parent();\n if (grandparent instanceof MenuPattern) {\n grandparent._clearTimeouts();\n grandparent.listBehavior.goto(parent, {focusElement: false});\n }\n }\n\n if (activeItem && activeItem !== item) {\n this._closeItem(activeItem);\n }\n\n if (item.expanded()) {\n this._clearCloseTimeout();\n }\n\n this._openItem(item);\n this.listBehavior.goto(item, {focusElement: this.shouldFocus()});\n }\n\n /** Closes the specified menu item after a delay. */\n private _closeItem(item: MenuItemPattern<V>) {\n this._clearOpenTimeout();\n\n if (!this._closeTimeout) {\n this._closeTimeout = setTimeout(() => {\n item.close();\n this._closeTimeout = undefined;\n }, this.inputs.expansionDelay());\n }\n }\n\n /** Opens the specified menu item after a delay. */\n private _openItem(item: MenuItemPattern<V>) {\n this._clearOpenTimeout();\n\n this._openTimeout = setTimeout(() => {\n item.open();\n this._openTimeout = undefined;\n }, this.inputs.expansionDelay());\n }\n\n /** Handles mouseout events for the menu. */\n onMouseOut(event: MouseEvent) {\n this._clearOpenTimeout();\n\n if (this.isFocused()) {\n return;\n }\n\n const root = this.root();\n const parent = this.inputs.parent();\n const relatedTarget = event.relatedTarget as Node | null;\n\n if (!root || !parent || parent instanceof MenuTriggerPattern) {\n return;\n }\n\n const grandparent = parent.inputs.parent();\n\n if (!grandparent || grandparent instanceof MenuBarPattern) {\n return;\n }\n\n if (!grandparent.inputs.element()?.contains(relatedTarget)) {\n parent.close();\n }\n }\n\n /** Handles click events for the menu. */\n onClick(event: MouseEvent) {\n const relatedTarget = event.target as Node | null;\n const item = this.inputs.items().find(i => i.element()?.contains(relatedTarget));\n\n if (item) {\n item.open();\n this.listBehavior.goto(item);\n this.submit(item);\n }\n }\n\n /** Handles focusin events for the menu. */\n onFocusIn() {\n this.isFocused.set(true);\n this.hasBeenFocused.set(true);\n }\n\n /** Handles the focusout event for the menu. */\n onFocusOut(event: FocusEvent) {\n const parent = this.inputs.parent();\n const parentEl = parent?.inputs.element();\n const relatedTarget = event.relatedTarget as Node | null;\n\n if (!relatedTarget) {\n this.isFocused.set(false);\n this.inputs.parent()?.close({refocus: true});\n }\n\n if (parent instanceof MenuItemPattern) {\n const grandparent = parent.inputs.parent();\n const siblings = grandparent?.inputs.items().filter(i => i !== parent);\n const item = siblings?.find(i => i.element()?.contains(relatedTarget));\n\n if (item) {\n return;\n }\n }\n\n if (\n this.visible() &&\n !parentEl?.contains(relatedTarget) &&\n !this.inputs.element()?.contains(relatedTarget)\n ) {\n this.isFocused.set(false);\n this.inputs.parent()?.close();\n }\n }\n\n /** Focuses the previous menu item. */\n prev() {\n this.inputs.activeItem()?.close();\n this.listBehavior.prev();\n }\n\n /** Focuses the next menu item. */\n next() {\n this.inputs.activeItem()?.close();\n this.listBehavior.next();\n }\n\n /** Focuses the first menu item. */\n first() {\n this.inputs.activeItem()?.close();\n this.listBehavior.first();\n }\n\n /** Focuses the last menu item. */\n last() {\n this.inputs.activeItem()?.close();\n this.listBehavior.last();\n }\n\n /** Triggers the active menu item. */\n trigger() {\n this.inputs.activeItem()?.hasPopup()\n ? this.inputs.activeItem()?.open({first: true})\n : this.submit();\n }\n\n /** Submits the menu. */\n submit(item = this.inputs.activeItem()) {\n if (!item || item.disabled() || item.submenu()) {\n return;\n }\n\n const root = this.root();\n\n if (root instanceof MenuTriggerPattern) {\n root.close({refocus: true});\n root?.inputs.menu()?.inputs.itemSelected?.(item.value());\n } else if (root instanceof MenuBarPattern) {\n root.close();\n root?.inputs.itemSelected?.(item.value());\n } else if (root instanceof MenuPattern) {\n root.inputs.activeItem()?.close({refocus: true});\n root?.inputs.itemSelected?.(item.value());\n }\n }\n\n /** Collapses the current menu or focuses the previous item in the menubar. */\n collapse() {\n const root = this.root();\n const parent = this.inputs.parent();\n\n if (parent instanceof MenuItemPattern && !(parent.inputs.parent() instanceof MenuBarPattern)) {\n parent.close({refocus: true});\n } else if (root instanceof MenuBarPattern) {\n root.prev();\n }\n }\n\n /** Expands the current menu or focuses the next item in the menubar. */\n expand() {\n const root = this.root();\n const activeItem = this.inputs.activeItem();\n\n if (activeItem?.submenu()) {\n activeItem.open({first: true});\n } else if (root instanceof MenuBarPattern) {\n root.next();\n }\n }\n\n /** Closes the menu. */\n close() {\n this.inputs.parent()?.close();\n }\n\n /** Closes the menu and all parent menus. */\n closeAll() {\n const root = this.root();\n\n if (root instanceof MenuTriggerPattern) {\n root.close({refocus: true});\n }\n\n if (root instanceof MenuBarPattern) {\n root.close();\n }\n\n if (root instanceof MenuPattern) {\n root.inputs.activeItem()?.close({refocus: true});\n }\n }\n\n /** Clears any open or close timeouts for sub-menus. */\n _clearTimeouts() {\n this._clearOpenTimeout();\n this._clearCloseTimeout();\n }\n\n /** Clears the open timeout. */\n _clearOpenTimeout() {\n if (this._openTimeout) {\n clearTimeout(this._openTimeout);\n this._openTimeout = undefined;\n }\n }\n\n /** Clears the close timeout. */\n _clearCloseTimeout() {\n if (this._closeTimeout) {\n clearTimeout(this._closeTimeout);\n this._closeTimeout = undefined;\n }\n }\n}\n\n/** The menubar ui pattern class. */\nexport class MenuBarPattern<V> {\n /** Controls list behavior for the menu items. */\n listBehavior: List<MenuItemPattern<V>, V>;\n\n /** The tab index of the menu. */\n tabIndex = () => this.listBehavior.tabIndex();\n\n /** The key used to navigate to the next item. */\n private _nextKey = computed(() => {\n return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';\n });\n\n /** The key used to navigate to the previous item. */\n private _previousKey = computed(() => {\n return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';\n });\n\n /** Represents the space key. Does nothing when the user is actively using typeahead. */\n dynamicSpaceKey = computed(() => (this.listBehavior.isTyping() ? '' : ' '));\n\n /** The regexp used to decide if a key should trigger typeahead. */\n typeaheadRegexp = /^.$/;\n\n /** Whether the menubar or any of its children are currently focused. */\n isFocused = signal(false);\n\n /** Whether the menubar has been focused. */\n hasBeenFocused = signal(false);\n\n /** Whether the menubar is disabled. */\n disabled = () => this.inputs.disabled();\n\n /** Handles keyboard events for the menu. */\n keydownManager = computed(() => {\n return new KeyboardEventManager()\n .on(this._nextKey, () => this.next(), {ignoreRepeat: false})\n .on(this._previousKey, () => this.prev(), {ignoreRepeat: false})\n .on('End', () => this.listBehavior.last())\n .on('Home', () => this.listBehavior.first())\n .on('Enter', () => this.inputs.activeItem()?.open({first: true}))\n .on('ArrowUp', () => this.inputs.activeItem()?.open({last: true}))\n .on('ArrowDown', () => this.inputs.activeItem()?.open({first: true}))\n .on(this.dynamicSpaceKey, () => this.inputs.activeItem()?.open({first: true}))\n .on(this.typeaheadRegexp, e => this.listBehavior.search(e.key));\n });\n\n constructor(readonly inputs: MenuBarInputs<V>) {\n this.listBehavior = new List<MenuItemPattern<V>, V>(inputs);\n }\n\n /** Sets the default state for the menubar. */\n setDefaultState() {\n this.inputs.activeItem.set(this.inputs.items()[0]);\n }\n\n /** Handles keyboard events for the menu. */\n onKeydown(event: KeyboardEvent) {\n this.keydownManager().handle(event);\n }\n\n /** Handles click events for the menu bar. */\n onClick(event: MouseEvent) {\n const item = this.inputs.items().find(i => i.element()?.contains(event.target as Node));\n\n if (!item) {\n return;\n }\n\n this.goto(item);\n item.expanded() ? item.close() : item.open();\n }\n\n /** Handles mouseover events for the menu bar. */\n onMouseOver(event: MouseEvent) {\n const item = this.inputs.items().find(i => i.element()?.contains(event.target as Node));\n\n if (item) {\n this.goto(item, {focusElement: this.isFocused()});\n }\n }\n\n /** Handles focusin events for the menu bar. */\n onFocusIn() {\n this.isFocused.set(true);\n this.hasBeenFocused.set(true);\n }\n\n /** Handles focusout events for the menu bar. */\n onFocusOut(event: FocusEvent) {\n const relatedTarget = event.relatedTarget as Node | null;\n\n if (!this.inputs.element()?.contains(relatedTarget)) {\n this.isFocused.set(false);\n this.close();\n }\n }\n\n /** Goes to and optionally focuses the specified menu item. */\n goto(item: MenuItemPattern<V>, opts?: {focusElement?: boolean}) {\n const prevItem = this.inputs.activeItem();\n this.listBehavior.goto(item, opts);\n\n if (prevItem?.expanded()) {\n prevItem?.close();\n this.inputs.activeItem()?.open();\n }\n\n if (item === prevItem) {\n if (item.expanded() && item.submenu()?.inputs.activeItem()) {\n item.submenu()?.inputs.activeItem()?.close();\n item.submenu()?.listBehavior.unfocus();\n }\n }\n }\n\n /** Focuses the next menu item. */\n next() {\n const prevItem = this.inputs.activeItem();\n this.listBehavior.next();\n\n if (prevItem?.expanded()) {\n prevItem?.close();\n this.inputs.activeItem()?.open({first: true});\n }\n }\n\n /** Focuses the previous menu item. */\n prev() {\n const prevItem = this.inputs.activeItem();\n this.listBehavior.prev();\n\n if (prevItem?.expanded()) {\n prevItem?.close();\n this.inputs.activeItem()?.open({first: true});\n }\n }\n\n /** Closes the menubar and refocuses the root menu bar item. */\n close() {\n this.inputs.activeItem()?.close({refocus: this.isFocused()});\n }\n}\n\n/** The menu trigger ui pattern class. */\nexport class MenuTriggerPattern<V> {\n /** Whether the menu is expanded. */\n expanded = signal(false);\n\n /** Whether the menu trigger has received focus. */\n hasBeenFocused = signal(false);\n\n /** The role of the menu trigger. */\n role = () => 'button';\n\n /** Whether the menu trigger has a popup. */\n hasPopup = () => true;\n\n /** The menu associated with the trigger. */\n menu: SignalLike<MenuPattern<V> | undefined>;\n\n /** The tab index of the menu trigger. */\n tabIndex = computed(() => (this.expanded() && this.menu()?.inputs.activeItem() ? -1 : 0));\n\n /** Whether the menu trigger is disabled. */\n disabled = () => this.inputs.disabled();\n\n /** Handles keyboard events for the menu trigger. */\n keydownManager = computed(() => {\n return new KeyboardEventManager()\n .on(' ', () => this.open({first: true}))\n .on('Enter', () => this.open({first: true}))\n .on('ArrowDown', () => this.open({first: true}))\n .on('ArrowUp', () => this.open({last: true}))\n .on('Escape', () => this.close({refocus: true}));\n });\n\n constructor(readonly inputs: MenuTriggerInputs<V>) {\n this.menu = this.inputs.menu;\n }\n\n /** Handles keyboard events for the menu trigger. */\n onKeydown(event: KeyboardEvent) {\n if (!this.inputs.disabled()) {\n this.keydownManager().handle(event);\n }\n }\n\n /** Handles click events for the menu trigger. */\n onClick() {\n if (!this.inputs.disabled()) {\n this.expanded() ? this.close() : this.open({first: true});\n }\n }\n\n /** Handles focusin events for the menu trigger. */\n onFocusIn() {\n this.hasBeenFocused.set(true);\n }\n\n /** Handles focusout events for the menu trigger. */\n onFocusOut(event: FocusEvent) {\n const element = this.inputs.element();\n const relatedTarget = event.relatedTarget as Node | null;\n\n if (\n this.expanded() &&\n !element?.contains(relatedTarget) &&\n !this.inputs.menu()?.inputs.element()?.contains(relatedTarget)\n ) {\n this.close();\n }\n }\n\n /** Opens the menu. */\n open(opts?: {first?: boolean; last?: boolean}) {\n this.expanded.set(true);\n\n if (opts?.first) {\n this.inputs.menu()?.first();\n } else if (opts?.last) {\n this.inputs.menu()?.last();\n }\n }\n\n /** Closes the menu. */\n close(opts: {refocus?: boolean} = {}) {\n this.expanded.set(false);\n this.menu()?.listBehavior.unfocus();\n\n if (opts.refocus) {\n this.inputs.element()?.focus();\n }\n\n let menuitems = this.inputs.menu()?.inputs.items() ?? [];\n\n while (menuitems.length) {\n const menuitem = menuitems.pop();\n menuitem?._expanded.set(false);\n menuitem?.inputs.parent()?.listBehavior.unfocus();\n menuitems = menuitems.concat(menuitem?.submenu()?.inputs.items() ?? []);\n }\n }\n}\n\n/** The menu item ui pattern class. */\nexport class MenuItemPattern<V> implements ListItem<V> {\n /** The value of the menu item. */\n value: SignalLike<V>;\n\n /** The unique ID of the menu item. */\n id: SignalLike<string>;\n\n /** Whether the menu item is disabled. */\n disabled = () => this.inputs.parent()?.disabled() || this.inputs.disabled();\n\n /** The search term for the menu item. */\n searchTerm: SignalLike<string>;\n\n /** The element of the menu item. */\n element: SignalLike<HTMLElement | undefined>;\n\n /** Whether the menu item is active. */\n active = computed(() => this.inputs.parent()?.inputs.activeItem() === this);\n\n /** Whether the menu item has received focus. */\n hasBeenFocused = signal(false);\n\n /** The tab index of the menu item. */\n tabIndex = computed(() => {\n if (this.submenu() && this.submenu()?.inputs.activeItem()) {\n return -1;\n }\n return this.inputs.parent()?.listBehavior.getItemTabindex(this) ?? -1;\n });\n\n /** The position of the menu item in the menu. */\n index = computed(() => this.inputs.parent()?.inputs.items().indexOf(this) ?? -1);\n\n /** Whether the menu item is expanded. */\n expanded = computed(() => (this.submenu() ? this._expanded() : null));\n\n /** Whether the menu item is expanded. */\n _expanded = signal(false);\n\n /** The ID of the menu that the menu item controls. */\n controls = signal<string | undefined>(undefined);\n\n /** The role of the menu item. */\n role = () => 'menuitem';\n\n /** Whether the menu item has a popup. */\n hasPopup = computed(() => !!this.submenu());\n\n /** The submenu associated with the menu item. */\n submenu: SignalLike<MenuPattern<V> | undefined>;\n\n /** Whether the menu item is selectable. */\n selectable: SignalLike<boolean>;\n\n constructor(readonly inputs: MenuItemInputs<V>) {\n this.id = inputs.id;\n this.value = inputs.value;\n this.element = inputs.element;\n this.submenu = this.inputs.submenu;\n this.searchTerm = inputs.searchTerm;\n this.selectable = computed(() => !this.submenu());\n }\n\n /** Opens the submenu. */\n open(opts?: {first?: boolean; last?: boolean}) {\n if (this.disabled()) {\n return;\n }\n\n this._expanded.set(true);\n\n if (opts?.first) {\n this.submenu()?.first();\n }\n if (opts?.last) {\n this.submenu()?.last();\n }\n }\n\n /** Closes the submenu. */\n close(opts: {refocus?: boolean} = {}) {\n this._expanded.set(false);\n\n if (opts.refocus) {\n this.inputs.parent()?.listBehavior.goto(this);\n }\n\n let menuitems = this.inputs.submenu()?.inputs.items() ?? [];\n\n while (menuitems.length) {\n const menuitem = menuitems.pop();\n menuitem?._expanded.set(false);\n menuitem?.inputs.parent()?.listBehavior.unfocus();\n menuitems = menuitems.concat(menuitem?.submenu()?.inputs.items() ?? []);\n\n const parent = menuitem?.inputs.parent();\n\n if (parent instanceof MenuPattern) {\n parent._clearTimeouts();\n }\n }\n }\n\n /** Handles focusin events for the menu item. */\n onFocusIn() {\n this.hasBeenFocused.set(true);\n }\n}\n"],"names":["MenuPattern","inputs","id","role","disabled","visible","computed","parent","expanded","listBehavior","isFocused","signal","hasBeenFocused","hasBeenHovered","_openTimeout","_closeTimeout","tabIndex","shouldFocus","root","MenuTriggerPattern","MenuBarPattern","_expandKey","textDirection","_collapseKey","dynamicSpaceKey","isTyping","typeaheadRegexp","grandparent","keydownManager","KeyboardEventManager","on","next","ignoreRepeat","prev","first","last","trigger","closeAll","expand","collapse","e","search","key","constructor","List","values","setDefaultState","goto","items","focusElement","onKeydown","event","handle","onMouseOver","set","item","find","i","element","contains","target","activeItem","MenuItemPattern","_clearTimeouts","_closeItem","_clearCloseTimeout","_openItem","_clearOpenTimeout","setTimeout","close","undefined","expansionDelay","open","onMouseOut","relatedTarget","onClick","submit","onFocusIn","onFocusOut","parentEl","refocus","siblings","filter","hasPopup","submenu","menu","itemSelected","value","clearTimeout","_nextKey","_previousKey","opts","prevItem","unfocus","focus","menuitems","length","menuitem","pop","_expanded","concat","searchTerm","active","getItemTabindex","index","indexOf","controls","selectable"],"mappings":";;;MAsEaA,WAAW,CAAA;EAsGDC,MAAA;EApGrBC,EAAE;EAGFC,IAAI,GAAGA,MAAM,MAAM;EAGnBC,QAAQ,GAAGA,MAAM,IAAI,CAACH,MAAM,CAACG,QAAQ,EAAE;EAGvCC,OAAO,GAAGC,QAAQ,CAAC,MAAO,IAAI,CAACL,MAAM,CAACM,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAACN,MAAM,CAACM,MAAM,EAAE,EAAEC,QAAQ,EAAE,GAAG,IAAK,CAAC;EAG5FC,YAAY;AAGZC,EAAAA,SAAS,GAAGC,MAAM,CAAC,KAAK,CAAC;AAGzBC,EAAAA,cAAc,GAAGD,MAAM,CAAC,KAAK,CAAC;AAG9BE,EAAAA,cAAc,GAAGF,MAAM,CAAC,KAAK,CAAC;EAG9BG,YAAY;EAGZC,aAAa;EAGbC,QAAQ,GAAGA,MAAM,IAAI,CAACP,YAAY,CAACO,QAAQ,EAAE;EAG7CC,WAAW,GAAGX,QAAQ,CAAC,MAAK;AAC1B,IAAA,MAAMY,IAAI,GAAG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,EAAE;MAExC,IAAIA,MAAM,YAAYP,WAAW,EAAE;QACjCO,MAAM,CAACwD,cAAc,EAAE;AACzB;AACF;AACF;AAGAc,EAAAA,SAASA,GAAA;AACP,IAAA,IAAI,CAACjE,cAAc,CAAC0C,GAAG,CAAC,IAAI,CAAC;AAC/B;AACD;;;;"}
1
+ {"version":3,"file":"_menu-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/menu/menu.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {KeyboardEventManager} from '../behaviors/event-manager';\nimport {computed, signal, SignalLike} from '../behaviors/signal-like/signal-like';\nimport {List, ListInputs, ListItem} from '../behaviors/list/list';\n\n/** The inputs for the MenuBarPattern class. */\nexport interface MenuBarInputs<V> extends ListInputs<MenuItemPattern<V>, V> {\n /** The menu items contained in the menu. */\n items: SignalLike<MenuItemPattern<V>[]>;\n\n /** Callback function triggered when a menu item is selected. */\n itemSelected?: (value: V) => void;\n\n /** The text direction of the menu bar. */\n textDirection: SignalLike<'ltr' | 'rtl'>;\n}\n\n/** The inputs for the MenuPattern class. */\nexport interface MenuInputs<V> extends Omit<ListInputs<MenuItemPattern<V>, V>, 'value'> {\n /** The unique ID of the menu. */\n id: SignalLike<string>;\n\n /** The menu items contained in the menu. */\n items: SignalLike<MenuItemPattern<V>[]>;\n\n /** A reference to the parent menu or menu trigger. */\n parent: SignalLike<MenuTriggerPattern<V> | MenuItemPattern<V> | undefined>;\n\n /** Callback function triggered when a menu item is selected. */\n itemSelected?: (value: V) => void;\n\n /** The text direction of the menu bar. */\n textDirection: SignalLike<'ltr' | 'rtl'>;\n\n /** The delay in milliseconds before expanding sub-menus on hover. */\n expansionDelay: SignalLike<number>;\n}\n\n/** The inputs for the MenuTriggerPattern class. */\nexport interface MenuTriggerInputs<V> {\n /** A reference to the menu trigger element. */\n element: SignalLike<HTMLElement | undefined>;\n\n /** A reference to the menu associated with the trigger. */\n menu: SignalLike<MenuPattern<V> | undefined>;\n\n /** The text direction of the menu bar. */\n textDirection: SignalLike<'ltr' | 'rtl'>;\n\n /** Whether the menu trigger is disabled. */\n disabled: SignalLike<boolean>;\n}\n\n/** The inputs for the MenuItemPattern class. */\nexport interface MenuItemInputs<V> extends Omit<ListItem<V>, 'index' | 'selectable'> {\n /** A reference to the parent menu or menu trigger. */\n parent: SignalLike<MenuPattern<V> | MenuBarPattern<V> | undefined>;\n\n /** A reference to the submenu associated with the menu item. */\n submenu: SignalLike<MenuPattern<V> | undefined>;\n}\n\n/** The menu ui pattern class. */\nexport class MenuPattern<V> {\n /** The unique ID of the menu. */\n id: SignalLike<string>;\n\n /** The role of the menu. */\n role = () => 'menu';\n\n /** Whether the menu is disabled. */\n disabled = () => this.inputs.disabled();\n\n /** Whether the menu is visible. */\n visible = computed(() => (this.inputs.parent() ? !!this.inputs.parent()?.expanded() : true));\n\n /** Controls list behavior for the menu items. */\n listBehavior: List<MenuItemPattern<V>, V>;\n\n /** Whether the menu or any of its child elements are currently focused. */\n isFocused = signal(false);\n\n /** Whether the menu has received interaction. */\n hasBeenInteracted = signal(false);\n\n /** Whether the menu trigger has been hovered. */\n hasBeenHovered = signal(false);\n\n /** Timeout used to open sub-menus on hover. */\n _openTimeout: any;\n\n /** Timeout used to close sub-menus on hover out. */\n _closeTimeout: any;\n\n /** The tab index of the menu. */\n tabIndex = () => this.listBehavior.tabIndex();\n\n /** Whether the menu should be focused on mouse over. */\n shouldFocus = computed(() => {\n const root = this.root();\n\n if (root instanceof MenuTriggerPattern) {\n return true;\n }\n\n if (root instanceof MenuBarPattern || root instanceof MenuPattern) {\n return root.isFocused();\n }\n\n return false;\n });\n\n /** The key used to expand sub-menus. */\n private _expandKey = computed(() => {\n return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';\n });\n\n /** The key used to collapse sub-menus. */\n private _collapseKey = computed(() => {\n return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';\n });\n\n /** Represents the space key. Does nothing when the user is actively using typeahead. */\n dynamicSpaceKey = computed(() => (this.listBehavior.isTyping() ? '' : ' '));\n\n /** The regexp used to decide if a key should trigger typeahead. */\n typeaheadRegexp = /^.$/;\n\n /** The root of the menu. */\n root: SignalLike<MenuTriggerPattern<V> | MenuBarPattern<V> | MenuPattern<V> | undefined> =\n computed(() => {\n const parent = this.inputs.parent();\n\n if (!parent) {\n return this;\n }\n\n if (parent instanceof MenuTriggerPattern) {\n return parent;\n }\n\n const grandparent = parent.inputs.parent();\n\n if (grandparent instanceof MenuBarPattern) {\n return grandparent;\n }\n\n return grandparent?.root();\n });\n\n /** Handles keyboard events for the menu. */\n keydownManager = computed(() => {\n return new KeyboardEventManager()\n .on('ArrowDown', () => this.next(), {ignoreRepeat: false})\n .on('ArrowUp', () => this.prev(), {ignoreRepeat: false})\n .on('Home', () => this.first())\n .on('End', () => this.last())\n .on('Enter', () => this.trigger())\n .on('Escape', () => this.closeAll())\n .on(this._expandKey, () => this.expand())\n .on(this._collapseKey, () => this.collapse())\n .on(this.dynamicSpaceKey, () => this.trigger())\n .on(this.typeaheadRegexp, e => this.listBehavior.search(e.key));\n });\n\n constructor(readonly inputs: MenuInputs<V>) {\n this.id = inputs.id;\n this.listBehavior = new List<MenuItemPattern<V>, V>({\n ...inputs,\n value: signal([]),\n });\n }\n\n /** Sets the default state for the menu. */\n setDefaultState() {\n if (!this.inputs.parent()) {\n const firstFocusable = this.listBehavior.navigationBehavior.peekFirst();\n if (firstFocusable) {\n this.listBehavior.goto(firstFocusable, {focusElement: false});\n }\n }\n }\n\n /** Sets the default active state of the menu before receiving interaction for the first time. */\n setDefaultStateEffect(): void {\n if (this.hasBeenInteracted() || this.hasBeenHovered()) return;\n\n if (this.inputs.items().length > 0) {\n this.setDefaultState();\n }\n }\n\n /** Handles keyboard events for the menu. */\n onKeydown(event: KeyboardEvent) {\n this.hasBeenInteracted.set(true);\n this.keydownManager().handle(event);\n }\n\n /** Handles mouseover events for the menu. */\n onMouseOver(event: MouseEvent) {\n if (!this.visible()) {\n return;\n }\n\n this.hasBeenHovered.set(true);\n const item = this.inputs.items().find(i => i.element()?.contains(event.target as Node));\n\n if (!item) {\n return;\n }\n\n const parent = this.inputs.parent();\n const activeItem = this?.inputs.activeItem();\n\n if (parent instanceof MenuItemPattern) {\n const grandparent = parent.inputs.parent();\n if (grandparent instanceof MenuPattern) {\n grandparent._clearTimeouts();\n grandparent.listBehavior.goto(parent, {focusElement: false});\n }\n }\n\n if (activeItem && activeItem !== item) {\n this._closeItem(activeItem);\n }\n\n if (item.expanded()) {\n this._clearCloseTimeout();\n }\n\n this._openItem(item);\n this.listBehavior.goto(item, {focusElement: this.shouldFocus()});\n }\n\n /** Closes the specified menu item after a delay. */\n private _closeItem(item: MenuItemPattern<V>) {\n this._clearOpenTimeout();\n\n if (!this._closeTimeout) {\n this._closeTimeout = setTimeout(() => {\n item.close();\n this._closeTimeout = undefined;\n }, this.inputs.expansionDelay());\n }\n }\n\n /** Opens the specified menu item after a delay. */\n private _openItem(item: MenuItemPattern<V>) {\n this._clearOpenTimeout();\n\n this._openTimeout = setTimeout(() => {\n item.open();\n this._openTimeout = undefined;\n }, this.inputs.expansionDelay());\n }\n\n /** Handles mouseout events for the menu. */\n onMouseOut(event: MouseEvent) {\n this._clearOpenTimeout();\n\n if (this.isFocused()) {\n return;\n }\n\n const root = this.root();\n const parent = this.inputs.parent();\n const relatedTarget = event.relatedTarget as Node | null;\n\n if (!root || !parent || parent instanceof MenuTriggerPattern) {\n return;\n }\n\n const grandparent = parent.inputs.parent();\n\n if (!grandparent || grandparent instanceof MenuBarPattern) {\n return;\n }\n\n if (!grandparent.inputs.element()?.contains(relatedTarget)) {\n parent.close();\n }\n }\n\n /** Handles click events for the menu. */\n onClick(event: MouseEvent) {\n const relatedTarget = event.target as Node | null;\n const item = this.inputs.items().find(i => i.element()?.contains(relatedTarget));\n\n if (item) {\n item.open();\n this.listBehavior.goto(item);\n this.submit(item);\n }\n }\n\n /** Handles focusin events for the menu. */\n onFocusIn() {\n this.isFocused.set(true);\n this.hasBeenInteracted.set(true);\n }\n\n /** Handles the focusout event for the menu. */\n onFocusOut(event: FocusEvent) {\n const parent = this.inputs.parent();\n const parentEl = parent?.inputs.element();\n const relatedTarget = event.relatedTarget as Node | null;\n\n if (!relatedTarget) {\n this.isFocused.set(false);\n this.inputs.parent()?.close({refocus: true});\n }\n\n if (parent instanceof MenuItemPattern) {\n const grandparent = parent.inputs.parent();\n const siblings = grandparent?.inputs.items().filter(i => i !== parent);\n const item = siblings?.find(i => i.element()?.contains(relatedTarget));\n\n if (item) {\n return;\n }\n }\n\n if (\n this.visible() &&\n !parentEl?.contains(relatedTarget) &&\n !this.inputs.element()?.contains(relatedTarget)\n ) {\n this.isFocused.set(false);\n this.inputs.parent()?.close();\n }\n }\n\n /** Focuses the previous menu item. */\n prev() {\n this.inputs.activeItem()?.close();\n this.listBehavior.prev();\n }\n\n /** Focuses the next menu item. */\n next() {\n this.inputs.activeItem()?.close();\n this.listBehavior.next();\n }\n\n /** Focuses the first menu item. */\n first() {\n this.inputs.activeItem()?.close();\n this.listBehavior.first();\n }\n\n /** Focuses the last menu item. */\n last() {\n this.inputs.activeItem()?.close();\n this.listBehavior.last();\n }\n\n /** Triggers the active menu item. */\n trigger() {\n this.inputs.activeItem()?.hasPopup()\n ? this.inputs.activeItem()?.open({first: true})\n : this.submit();\n }\n\n /** Submits the menu. */\n submit(item = this.inputs.activeItem()) {\n if (!item || item.disabled() || item.submenu()) {\n return;\n }\n\n const root = this.root();\n\n if (root instanceof MenuTriggerPattern) {\n root.close({refocus: true});\n root?.inputs.menu()?.inputs.itemSelected?.(item.value());\n } else if (root instanceof MenuBarPattern) {\n root.close();\n root?.inputs.itemSelected?.(item.value());\n } else if (root instanceof MenuPattern) {\n root.inputs.activeItem()?.close({refocus: true});\n root?.inputs.itemSelected?.(item.value());\n }\n }\n\n /** Collapses the current menu or focuses the previous item in the menubar. */\n collapse() {\n const root = this.root();\n const parent = this.inputs.parent();\n\n if (parent instanceof MenuItemPattern && !(parent.inputs.parent() instanceof MenuBarPattern)) {\n parent.close({refocus: true});\n } else if (root instanceof MenuBarPattern) {\n root.prev();\n }\n }\n\n /** Expands the current menu or focuses the next item in the menubar. */\n expand() {\n const root = this.root();\n const activeItem = this.inputs.activeItem();\n\n if (activeItem?.submenu()) {\n activeItem.open({first: true});\n } else if (root instanceof MenuBarPattern) {\n root.next();\n }\n }\n\n /** Closes the menu. */\n close() {\n this.inputs.parent()?.close();\n }\n\n /** Closes the menu and all parent menus. */\n closeAll() {\n const root = this.root();\n\n if (root instanceof MenuTriggerPattern) {\n root.close({refocus: true});\n }\n\n if (root instanceof MenuBarPattern) {\n root.close();\n }\n\n if (root instanceof MenuPattern) {\n root.inputs.activeItem()?.close({refocus: true});\n }\n }\n\n /** Clears any open or close timeouts for sub-menus. */\n _clearTimeouts() {\n this._clearOpenTimeout();\n this._clearCloseTimeout();\n }\n\n /** Clears the open timeout. */\n _clearOpenTimeout() {\n if (this._openTimeout) {\n clearTimeout(this._openTimeout);\n this._openTimeout = undefined;\n }\n }\n\n /** Clears the close timeout. */\n _clearCloseTimeout() {\n if (this._closeTimeout) {\n clearTimeout(this._closeTimeout);\n this._closeTimeout = undefined;\n }\n }\n}\n\n/** The menubar ui pattern class. */\nexport class MenuBarPattern<V> {\n /** Controls list behavior for the menu items. */\n listBehavior: List<MenuItemPattern<V>, V>;\n\n /** The tab index of the menu. */\n tabIndex = () => this.listBehavior.tabIndex();\n\n /** The key used to navigate to the next item. */\n private _nextKey = computed(() => {\n return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';\n });\n\n /** The key used to navigate to the previous item. */\n private _previousKey = computed(() => {\n return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';\n });\n\n /** Represents the space key. Does nothing when the user is actively using typeahead. */\n dynamicSpaceKey = computed(() => (this.listBehavior.isTyping() ? '' : ' '));\n\n /** The regexp used to decide if a key should trigger typeahead. */\n typeaheadRegexp = /^.$/;\n\n /** Whether the menubar or any of its children are currently focused. */\n isFocused = signal(false);\n\n /** Whether the menubar has been interacted with. */\n hasBeenInteracted = signal(false);\n\n /** Whether the menubar is disabled. */\n disabled = () => this.inputs.disabled();\n\n /** Handles keyboard events for the menu. */\n keydownManager = computed(() => {\n return new KeyboardEventManager()\n .on(this._nextKey, () => this.next(), {ignoreRepeat: false})\n .on(this._previousKey, () => this.prev(), {ignoreRepeat: false})\n .on('End', () => this.listBehavior.last())\n .on('Home', () => this.listBehavior.first())\n .on('Enter', () => this.inputs.activeItem()?.open({first: true}))\n .on('ArrowUp', () => this.inputs.activeItem()?.open({last: true}))\n .on('ArrowDown', () => this.inputs.activeItem()?.open({first: true}))\n .on(this.dynamicSpaceKey, () => this.inputs.activeItem()?.open({first: true}))\n .on(this.typeaheadRegexp, e => this.listBehavior.search(e.key));\n });\n\n constructor(readonly inputs: MenuBarInputs<V>) {\n this.listBehavior = new List<MenuItemPattern<V>, V>(inputs);\n }\n\n /** Sets the default state for the menubar. */\n setDefaultState() {\n const firstFocusable = this.listBehavior.navigationBehavior.peekFirst();\n if (firstFocusable) {\n this.inputs.activeItem.set(firstFocusable);\n }\n }\n\n /** Sets the default active state of the menubar before receiving interaction for the first time. */\n setDefaultStateEffect(): void {\n if (this.hasBeenInteracted()) return;\n\n if (this.inputs.items().length > 0) {\n this.setDefaultState();\n }\n }\n\n /** Handles keyboard events for the menu. */\n onKeydown(event: KeyboardEvent) {\n this.hasBeenInteracted.set(true);\n this.keydownManager().handle(event);\n }\n\n /** Handles click events for the menu bar. */\n onClick(event: MouseEvent) {\n const item = this.inputs.items().find(i => i.element()?.contains(event.target as Node));\n\n if (!item) {\n return;\n }\n\n this.goto(item);\n item.expanded() ? item.close() : item.open();\n }\n\n /** Handles mouseover events for the menu bar. */\n onMouseOver(event: MouseEvent) {\n const item = this.inputs.items().find(i => i.element()?.contains(event.target as Node));\n\n if (item) {\n this.goto(item, {focusElement: this.isFocused()});\n }\n }\n\n /** Handles focusin events for the menu bar. */\n onFocusIn() {\n this.isFocused.set(true);\n this.hasBeenInteracted.set(true);\n }\n\n /** Handles focusout events for the menu bar. */\n onFocusOut(event: FocusEvent) {\n const relatedTarget = event.relatedTarget as Node | null;\n\n if (!this.inputs.element()?.contains(relatedTarget)) {\n this.isFocused.set(false);\n this.close();\n }\n }\n\n /** Goes to and optionally focuses the specified menu item. */\n goto(item: MenuItemPattern<V>, opts?: {focusElement?: boolean}) {\n const prevItem = this.inputs.activeItem();\n this.listBehavior.goto(item, opts);\n\n if (prevItem?.expanded()) {\n prevItem?.close();\n this.inputs.activeItem()?.open();\n }\n\n if (item === prevItem) {\n if (item.expanded() && item.submenu()?.inputs.activeItem()) {\n item.submenu()?.inputs.activeItem()?.close();\n item.submenu()?.listBehavior.unfocus();\n }\n }\n }\n\n /** Focuses the next menu item. */\n next() {\n const prevItem = this.inputs.activeItem();\n this.listBehavior.next();\n\n if (prevItem?.expanded()) {\n prevItem?.close();\n this.inputs.activeItem()?.open({first: true});\n }\n }\n\n /** Focuses the previous menu item. */\n prev() {\n const prevItem = this.inputs.activeItem();\n this.listBehavior.prev();\n\n if (prevItem?.expanded()) {\n prevItem?.close();\n this.inputs.activeItem()?.open({first: true});\n }\n }\n\n /** Closes the menubar and refocuses the root menu bar item. */\n close() {\n this.inputs.activeItem()?.close({refocus: this.isFocused()});\n }\n}\n\n/** The menu trigger ui pattern class. */\nexport class MenuTriggerPattern<V> {\n /** Whether the menu trigger is expanded. */\n expanded = signal(false);\n\n /** Whether the menu trigger has received interaction. */\n hasBeenInteracted = signal(false);\n\n /** The role of the menu trigger. */\n role = () => 'button';\n\n /** Whether the menu trigger has a popup. */\n hasPopup = () => true;\n\n /** The menu associated with the trigger. */\n menu: SignalLike<MenuPattern<V> | undefined>;\n\n /** The tab index of the menu trigger. */\n tabIndex = computed(() => (this.expanded() && this.menu()?.inputs.activeItem() ? -1 : 0));\n\n /** Whether the menu trigger is disabled. */\n disabled = () => this.inputs.disabled();\n\n /** Handles keyboard events for the menu trigger. */\n keydownManager = computed(() => {\n return new KeyboardEventManager()\n .on(' ', () => this.open({first: true}))\n .on('Enter', () => this.open({first: true}))\n .on('ArrowDown', () => this.open({first: true}))\n .on('ArrowUp', () => this.open({last: true}))\n .on('Escape', () => this.close({refocus: true}));\n });\n\n constructor(readonly inputs: MenuTriggerInputs<V>) {\n this.menu = this.inputs.menu;\n }\n\n /** Handles keyboard events for the menu trigger. */\n onKeydown(event: KeyboardEvent) {\n if (!this.inputs.disabled()) {\n this.hasBeenInteracted.set(true);\n this.keydownManager().handle(event);\n }\n }\n\n /** Handles click events for the menu trigger. */\n onClick() {\n if (!this.inputs.disabled()) {\n this.expanded() ? this.close() : this.open({first: true});\n }\n }\n\n /** Handles focusin events for the menu trigger. */\n onFocusIn() {\n this.hasBeenInteracted.set(true);\n }\n\n /** Handles focusout events for the menu trigger. */\n onFocusOut(event: FocusEvent) {\n const element = this.inputs.element();\n const relatedTarget = event.relatedTarget as Node | null;\n\n if (\n this.expanded() &&\n !element?.contains(relatedTarget) &&\n !this.inputs.menu()?.inputs.element()?.contains(relatedTarget)\n ) {\n this.close();\n }\n }\n\n /** Opens the menu. */\n open(opts?: {first?: boolean; last?: boolean}) {\n this.expanded.set(true);\n\n if (opts?.first) {\n this.inputs.menu()?.first();\n } else if (opts?.last) {\n this.inputs.menu()?.last();\n }\n }\n\n /** Closes the menu. */\n close(opts: {refocus?: boolean} = {}) {\n this.expanded.set(false);\n this.menu()?.listBehavior.unfocus();\n\n if (opts.refocus) {\n this.inputs.element()?.focus();\n }\n\n let menuitems = this.inputs.menu()?.inputs.items() ?? [];\n\n while (menuitems.length) {\n const menuitem = menuitems.pop();\n menuitem?._expanded.set(false);\n menuitem?.inputs.parent()?.listBehavior.unfocus();\n menuitems = menuitems.concat(menuitem?.submenu()?.inputs.items() ?? []);\n }\n }\n}\n\n/** The menu item ui pattern class. */\nexport class MenuItemPattern<V> implements ListItem<V> {\n /** The value of the menu item. */\n value: SignalLike<V>;\n\n /** The unique ID of the menu item. */\n id: SignalLike<string>;\n\n /** Whether the menu item is disabled. */\n disabled = () => this.inputs.parent()?.disabled() || this.inputs.disabled();\n\n /** The search term for the menu item. */\n searchTerm: SignalLike<string>;\n\n /** The element of the menu item. */\n element: SignalLike<HTMLElement | undefined>;\n\n /** Whether the menu item is active. */\n active = computed(() => this.inputs.parent()?.inputs.activeItem() === this);\n\n /** Whether the menu item has received interaction. */\n hasBeenInteracted = signal(false);\n\n /** The tab index of the menu item. */\n tabIndex = computed(() => {\n if (this.submenu() && this.submenu()?.inputs.activeItem()) {\n return -1;\n }\n return this.inputs.parent()?.listBehavior.getItemTabindex(this) ?? -1;\n });\n\n /** The position of the menu item in the menu. */\n index = computed(() => this.inputs.parent()?.inputs.items().indexOf(this) ?? -1);\n\n /** Whether the menu item is expanded. */\n expanded = computed(() => (this.submenu() ? this._expanded() : null));\n\n /** Whether the menu item is expanded. */\n _expanded = signal(false);\n\n /** The ID of the menu that the menu item controls. */\n controls = signal<string | undefined>(undefined);\n\n /** The role of the menu item. */\n role = () => 'menuitem';\n\n /** Whether the menu item has a popup. */\n hasPopup = computed(() => !!this.submenu());\n\n /** The submenu associated with the menu item. */\n submenu: SignalLike<MenuPattern<V> | undefined>;\n\n /** Whether the menu item is selectable. */\n selectable: SignalLike<boolean>;\n\n constructor(readonly inputs: MenuItemInputs<V>) {\n this.id = inputs.id;\n this.value = inputs.value;\n this.element = inputs.element;\n this.submenu = this.inputs.submenu;\n this.searchTerm = inputs.searchTerm;\n this.selectable = computed(() => !this.submenu());\n }\n\n /** Opens the submenu. */\n open(opts?: {first?: boolean; last?: boolean}) {\n if (this.disabled()) {\n return;\n }\n\n this._expanded.set(true);\n\n if (opts?.first) {\n this.submenu()?.first();\n }\n if (opts?.last) {\n this.submenu()?.last();\n }\n }\n\n /** Closes the submenu. */\n close(opts: {refocus?: boolean} = {}) {\n this._expanded.set(false);\n\n if (opts.refocus) {\n this.inputs.parent()?.listBehavior.goto(this);\n }\n\n let menuitems = this.inputs.submenu()?.inputs.items() ?? [];\n\n while (menuitems.length) {\n const menuitem = menuitems.pop();\n menuitem?._expanded.set(false);\n menuitem?.inputs.parent()?.listBehavior.unfocus();\n menuitems = menuitems.concat(menuitem?.submenu()?.inputs.items() ?? []);\n\n const parent = menuitem?.inputs.parent();\n\n if (parent instanceof MenuPattern) {\n parent._clearTimeouts();\n }\n }\n }\n\n /** Handles focusin events for the menu item. */\n onFocusIn() {\n this.hasBeenInteracted.set(true);\n }\n}\n"],"names":["MenuPattern","inputs","id","role","disabled","visible","computed","parent","expanded","listBehavior","isFocused","signal","hasBeenInteracted","hasBeenHovered","_openTimeout","_closeTimeout","tabIndex","shouldFocus","root","MenuTriggerPattern","MenuBarPattern","_expandKey","textDirection","_collapseKey","dynamicSpaceKey","isTyping","typeaheadRegexp","grandparent","keydownManager","KeyboardEventManager","on","next","ignoreRepeat","prev","first","last","trigger","closeAll","expand","collapse","e","search","key","constructor","List","value","setDefaultState","firstFocusable","navigationBehavior","peekFirst","goto","focusElement","setDefaultStateEffect","items","length","onKeydown","event","set","handle","onMouseOver","item","find","i","element","contains","target","activeItem","MenuItemPattern","_clearTimeouts","_closeItem","_clearCloseTimeout","_openItem","_clearOpenTimeout","setTimeout","close","undefined","expansionDelay","open","onMouseOut","relatedTarget","onClick","submit","onFocusIn","onFocusOut","parentEl","refocus","siblings","filter","hasPopup","submenu","menu","itemSelected","clearTimeout","_nextKey","_previousKey","opts","prevItem","unfocus","focus","menuitems","menuitem","pop","_expanded","concat","searchTerm","active","getItemTabindex","index","indexOf","controls","selectable"],"mappings":";;;MAsEaA,WAAW,CAAA;EAsGDC,MAAA;EApGrBC,EAAE;EAGFC,IAAI,GAAGA,MAAM,MAAM;EAGnBC,QAAQ,GAAGA,MAAM,IAAI,CAACH,MAAM,CAACG,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