@angular/aria 21.0.2 → 21.0.3

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 (56) hide show
  1. package/fesm2022/_combobox-chunk.mjs +425 -0
  2. package/fesm2022/_combobox-chunk.mjs.map +1 -0
  3. package/fesm2022/_combobox-listbox-chunk.mjs +522 -0
  4. package/fesm2022/_combobox-listbox-chunk.mjs.map +1 -0
  5. package/fesm2022/_combobox-popup-chunk.mjs +46 -0
  6. package/fesm2022/_combobox-popup-chunk.mjs.map +1 -0
  7. package/fesm2022/_list-navigation-chunk.mjs +116 -0
  8. package/fesm2022/_list-navigation-chunk.mjs.map +1 -0
  9. package/fesm2022/_pointer-event-manager-chunk.mjs +134 -0
  10. package/fesm2022/_pointer-event-manager-chunk.mjs.map +1 -0
  11. package/fesm2022/_widget-chunk.mjs +4 -246
  12. package/fesm2022/_widget-chunk.mjs.map +1 -1
  13. package/fesm2022/accordion.mjs +17 -4
  14. package/fesm2022/accordion.mjs.map +1 -1
  15. package/fesm2022/aria.mjs +1 -1
  16. package/fesm2022/aria.mjs.map +1 -1
  17. package/fesm2022/combobox.mjs +96 -120
  18. package/fesm2022/combobox.mjs.map +1 -1
  19. package/fesm2022/grid.mjs +225 -201
  20. package/fesm2022/grid.mjs.map +1 -1
  21. package/fesm2022/listbox.mjs +173 -161
  22. package/fesm2022/listbox.mjs.map +1 -1
  23. package/fesm2022/menu.mjs +256 -238
  24. package/fesm2022/menu.mjs.map +1 -1
  25. package/fesm2022/private.mjs +7 -932
  26. package/fesm2022/private.mjs.map +1 -1
  27. package/fesm2022/tabs.mjs +182 -168
  28. package/fesm2022/tabs.mjs.map +1 -1
  29. package/fesm2022/toolbar.mjs +15 -3
  30. package/fesm2022/toolbar.mjs.map +1 -1
  31. package/fesm2022/tree.mjs +4 -2
  32. package/fesm2022/tree.mjs.map +1 -1
  33. package/package.json +2 -2
  34. package/types/_combobox-chunk.d.ts +98 -0
  35. package/types/_combobox-chunk.d2.ts +193 -0
  36. package/types/_grid-chunk.d.ts +3 -210
  37. package/types/_list-chunk.d.ts +212 -0
  38. package/types/_list-navigation-chunk.d.ts +212 -0
  39. package/types/_listbox-chunk.d.ts +106 -0
  40. package/types/accordion.d.ts +52 -49
  41. package/types/combobox.d.ts +25 -111
  42. package/types/grid.d.ts +37 -32
  43. package/types/listbox.d.ts +8 -5
  44. package/types/menu.d.ts +113 -113
  45. package/types/private.d.ts +10 -498
  46. package/types/tabs.d.ts +89 -84
  47. package/types/toolbar.d.ts +69 -66
  48. package/types/tree.d.ts +106 -103
  49. package/_adev_assets/aria-accordion.json +0 -743
  50. package/_adev_assets/aria-combobox.json +0 -603
  51. package/_adev_assets/aria-grid.json +0 -893
  52. package/_adev_assets/aria-listbox.json +0 -540
  53. package/_adev_assets/aria-menu.json +0 -1049
  54. package/_adev_assets/aria-tabs.json +0 -880
  55. package/_adev_assets/aria-toolbar.json +0 -545
  56. package/_adev_assets/aria-tree.json +0 -853
@@ -1 +1 @@
1
- {"version":3,"file":"_widget-chunk.mjs","sources":["../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/private/behaviors/event-manager/event-manager.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/private/behaviors/event-manager/keyboard-event-manager.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/private/behaviors/event-manager/pointer-event-manager.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/private/behaviors/list-focus/list-focus.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/private/behaviors/list-navigation/list-navigation.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/private/behaviors/grid/grid-data.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/private/behaviors/grid/grid-focus.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/private/behaviors/grid/grid-navigation.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/private/behaviors/grid/grid-selection.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/private/behaviors/grid/grid.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/private/grid/grid.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/private/grid/row.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/private/grid/cell.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/src/aria/private/grid/widget.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\n/**\n * An event that supports modifier keys.\n *\n * Matches the native KeyboardEvent, MouseEvent, and TouchEvent.\n */\nexport interface EventWithModifiers extends Event {\n ctrlKey: boolean;\n shiftKey: boolean;\n altKey: boolean;\n metaKey: boolean;\n}\n\n/**\n * Options that are applicable to all event handlers.\n *\n * This library has not yet had a need for stopPropagationImmediate.\n */\nexport interface EventHandlerOptions {\n stopPropagation: boolean;\n preventDefault: boolean;\n}\n\n/** A basic event handler. */\nexport type EventHandler<T extends Event> = (event: T) => void;\n\n/** A function that determines whether an event is to be handled. */\nexport type EventMatcher<T extends Event> = (event: T) => boolean;\n\n/** A config that specifies how to handle a particular event. */\nexport interface EventHandlerConfig<T extends Event> extends EventHandlerOptions {\n matcher: EventMatcher<T>;\n handler: EventHandler<T>;\n}\n\n/** Bit flag representation of the possible modifier keys that can be present on an event. */\nexport enum Modifier {\n None = 0,\n Ctrl = 0b1,\n Shift = 0b10,\n Alt = 0b100,\n Meta = 0b1000,\n Any = 'Any',\n}\n\nexport type ModifierInputs = Modifier | Modifier[];\n\n/**\n * Abstract base class for all event managers.\n *\n * Event managers are designed to normalize how event handlers are authored and create a safety net\n * for common event handling gotchas like remembering to call preventDefault or stopPropagation.\n */\nexport abstract class EventManager<T extends Event> {\n protected configs: EventHandlerConfig<T>[] = [];\n abstract options: EventHandlerOptions;\n\n /** Runs the handlers that match with the given event. */\n handle(event: T): void {\n for (const config of this.configs) {\n if (config.matcher(event)) {\n config.handler(event);\n\n if (config.preventDefault) {\n event.preventDefault();\n }\n\n if (config.stopPropagation) {\n event.stopPropagation();\n }\n }\n }\n }\n\n /** Configures the event manager to handle specific events. (See subclasses for more). */\n abstract on(...args: [...unknown[]]): this;\n}\n\n/** Gets bit flag representation of the modifier keys present on the given event. */\nexport function getModifiers(event: EventWithModifiers): number {\n return (\n (+event.ctrlKey && Modifier.Ctrl) |\n (+event.shiftKey && Modifier.Shift) |\n (+event.altKey && Modifier.Alt) |\n (+event.metaKey && Modifier.Meta)\n );\n}\n\n/**\n * Checks if the given event has modifiers that are an exact match for any of the given modifier\n * flag combinations.\n */\nexport function hasModifiers(event: EventWithModifiers, modifiers: ModifierInputs): boolean {\n const eventModifiers = getModifiers(event);\n const modifiersList = Array.isArray(modifiers) ? modifiers : [modifiers];\n\n if (modifiersList.includes(Modifier.Any)) {\n return true;\n }\n\n return modifiersList.some(modifiers => eventModifiers === modifiers);\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 {\n EventHandler,\n EventHandlerOptions,\n EventManager,\n hasModifiers,\n ModifierInputs,\n Modifier,\n} from './event-manager';\n\n/**\n * Used to represent a keycode.\n *\n * This is used to match whether an events keycode should be handled. The ability to match using a\n * string, SignalLike, or Regexp gives us more flexibility when authoring event handlers.\n */\ntype KeyCode = string | SignalLike<string> | RegExp;\n\n/**\n * An event manager that is specialized for handling keyboard events. By default this manager stops\n * propagation and prevents default on all events it handles.\n */\nexport class KeyboardEventManager<T extends KeyboardEvent> extends EventManager<T> {\n options: EventHandlerOptions = {\n preventDefault: true,\n stopPropagation: true,\n };\n\n /** Configures this event manager to handle events with a specific key and no modifiers. */\n on(key: KeyCode, handler: EventHandler<T>, options?: Partial<EventHandlerOptions>): this;\n\n /** Configures this event manager to handle events with a specific modifer and key combination. */\n on(\n modifiers: ModifierInputs,\n key: KeyCode,\n handler: EventHandler<T>,\n options?: Partial<EventHandlerOptions>,\n ): this;\n\n on(...args: any[]) {\n const {modifiers, key, handler, options} = this._normalizeInputs(...args);\n\n this.configs.push({\n handler: handler,\n matcher: event => this._isMatch(event, key, modifiers),\n ...this.options,\n ...options,\n });\n\n return this;\n }\n\n private _normalizeInputs(...args: any[]) {\n const withModifiers = Array.isArray(args[0]) || args[0] in Modifier;\n const modifiers = withModifiers ? args[0] : Modifier.None;\n const key = withModifiers ? args[1] : args[0];\n const handler = withModifiers ? args[2] : args[1];\n const options = withModifiers ? args[3] : args[2];\n\n return {\n key: key as KeyCode,\n handler: handler as EventHandler<T>,\n modifiers: modifiers as ModifierInputs,\n options: (options ?? {}) as Partial<EventHandlerOptions>,\n };\n }\n\n private _isMatch(event: T, key: KeyCode, modifiers: ModifierInputs) {\n if (!hasModifiers(event, modifiers)) {\n return false;\n }\n\n if (key instanceof RegExp) {\n return key.test(event.key);\n }\n\n const keyStr = typeof key === 'string' ? key : key();\n return keyStr.toLowerCase() === event.key.toLowerCase();\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 {\n EventHandler,\n EventHandlerOptions,\n EventManager,\n hasModifiers,\n ModifierInputs,\n Modifier,\n} from './event-manager';\n\n/**\n * The different mouse buttons that may appear on a pointer event.\n */\nexport enum MouseButton {\n Main = 0,\n Auxiliary = 1,\n Secondary = 2,\n}\n\n/** An event manager that is specialized for handling pointer events. */\nexport class PointerEventManager<T extends PointerEvent> extends EventManager<T> {\n options: EventHandlerOptions = {\n preventDefault: false,\n stopPropagation: false,\n };\n\n /**\n * Configures this event manager to handle events with a specific modifer and mouse button\n * combination.\n */\n on(button: MouseButton, modifiers: ModifierInputs, handler: EventHandler<T>): this;\n\n /**\n * Configures this event manager to handle events with a specific mouse button and no modifiers.\n */\n on(modifiers: ModifierInputs, handler: EventHandler<T>): this;\n\n /**\n * Configures this event manager to handle events with the main mouse button and no modifiers.\n *\n * @param handler The handler function\n * @param options Options for whether to stop propagation or prevent default.\n */\n on(handler: EventHandler<T>): this;\n\n on(...args: any[]) {\n const {button, handler, modifiers} = this._normalizeInputs(...args);\n\n this.configs.push({\n handler,\n matcher: event => this._isMatch(event, button, modifiers),\n ...this.options,\n });\n return this;\n }\n\n private _normalizeInputs(...args: any[]) {\n if (args.length === 3) {\n return {\n button: args[0] as MouseButton,\n modifiers: args[1] as ModifierInputs,\n handler: args[2] as EventHandler<T>,\n };\n }\n\n if (args.length === 2) {\n return {\n button: MouseButton.Main,\n modifiers: args[0] as ModifierInputs,\n handler: args[1] as EventHandler<T>,\n };\n }\n\n return {\n button: MouseButton.Main,\n modifiers: Modifier.None,\n handler: args[0] as EventHandler<T>,\n };\n }\n\n _isMatch(event: PointerEvent, button: MouseButton, modifiers: ModifierInputs) {\n return button === (event.button ?? 0) && hasModifiers(event, modifiers);\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} from '@angular/core';\nimport {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 /** The index of the item in the list. */\n index: SignalLike<number>;\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 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/** 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?: {focusElement?: boolean}): 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?: {focusElement?: boolean}): boolean {\n return this._advance(1, opts);\n }\n\n /** Peeks the next item in the list. */\n peekNext(): T | undefined {\n return this._peek(1);\n }\n\n /** Navigates to the previous item in the list. */\n prev(opts?: {focusElement?: boolean}): boolean {\n return this._advance(-1, opts);\n }\n\n /** Peeks the previous item in the list. */\n peekPrev(): T | undefined {\n return this._peek(-1);\n }\n\n /** Navigates to the first item in the list. */\n first(opts?: {focusElement?: boolean}): boolean {\n const item = this.peekFirst();\n return item ? this.goto(item, opts) : false;\n }\n\n /** Navigates to the last item in the list. */\n last(opts?: {focusElement?: boolean}): boolean {\n const item = this.peekLast();\n return item ? this.goto(item, opts) : false;\n }\n\n /** Gets the first focusable item from the given list of items. */\n peekFirst(items: T[] = this.inputs.items()): T | undefined {\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(items: T[] = this.inputs.items()): T | undefined {\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?: {focusElement?: boolean}): boolean {\n const item = this._peek(delta);\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): T | undefined {\n const items = this.inputs.items();\n const itemCount = items.length;\n const startIndex = this.inputs.focusManager.activeIndex();\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","/**\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} from '@angular/core';\nimport {SignalLike} from '../signal-like/signal-like';\n\n/** Represents coordinates in a grid. */\nexport interface RowCol {\n /** The row index. */\n row: number;\n\n /** The column index. */\n col: number;\n}\n\n/** A string representation of grid coordinates. */\ntype CoordString = `${RowCol['row']}:${RowCol['col']}`;\n\n/** The base interface for a cell in a grid. */\nexport interface BaseGridCell {\n /** The number of rows the cell should span. */\n rowSpan: SignalLike<number>;\n\n /** The number of columns the cell should span. */\n colSpan: SignalLike<number>;\n}\n\n/** Represents the required inputs for GridData. */\nexport interface GridDataInputs<T extends BaseGridCell> {\n /** The two-dimensional array of cells that represents the grid. */\n cells: SignalLike<T[][]>;\n}\n\n/** Controls internal coordinates for a grid of items. */\nexport class GridData<T extends BaseGridCell> {\n /** The two-dimensional array of cells that represents the grid. */\n readonly cells: SignalLike<T[][]>;\n\n /** The maximum number of rows in the grid, accounting for row spans. */\n readonly maxRowCount = computed<number>(() => Math.max(...this._rowCountByCol().values(), 0));\n\n /** The maximum number of columns in the grid, accounting for column spans. */\n readonly maxColCount = computed<number>(() => Math.max(...this._colCountsByRow().values(), 0));\n\n /** A map from a cell to its primary and spanned coordinates. */\n private readonly _coordsMap = computed<Map<T, {coords: RowCol; spanCoords: RowCol[]}>>(() => {\n const coordsMap = new Map();\n const visitedCoords = new Set();\n\n for (let rowIndex = 0; rowIndex < this.cells().length; rowIndex++) {\n let colIndex = 0;\n const row = this.cells()[rowIndex];\n\n for (const cell of row) {\n // Skip past cells that are already taken.\n while (visitedCoords.has(`${rowIndex}:${colIndex}`)) {\n colIndex++;\n }\n\n const rowspan = cell.rowSpan();\n const colspan = cell.colSpan();\n const spanCoords: RowCol[] = [];\n\n for (let rowOffset = 0; rowOffset < rowspan; rowOffset++) {\n const row = rowIndex + rowOffset;\n for (let colOffset = 0; colOffset < colspan; colOffset++) {\n const col = colIndex + colOffset;\n visitedCoords.add(`${row}:${col}`);\n spanCoords.push({row, col});\n }\n }\n coordsMap.set(cell, {coords: spanCoords[0], spanCoords});\n\n colIndex += colspan;\n }\n }\n\n return coordsMap;\n });\n\n /** A map from a coordinate string to the cell at that coordinate. */\n private readonly _cellMap = computed<Map<CoordString, T>>(() => {\n const cellMap = new Map();\n for (const [cell, {spanCoords}] of this._coordsMap().entries()) {\n for (const {row, col} of spanCoords) {\n cellMap.set(`${row}:${col}`, cell);\n }\n }\n return cellMap;\n });\n\n /** A map from a row index to the number of columns in that row. */\n private readonly _colCountsByRow = computed<Map<number, number>>(() => {\n const colCountByRow = new Map();\n for (const [_, {spanCoords}] of this._coordsMap().entries()) {\n for (const {row, col} of spanCoords) {\n const colCount = colCountByRow.get(row);\n const newColCount = col + 1;\n if (colCount === undefined || colCount < newColCount) {\n colCountByRow.set(row, newColCount);\n }\n }\n }\n return colCountByRow;\n });\n\n /** A map from a column index to the number of rows in that column. */\n private readonly _rowCountByCol = computed<Map<number, number>>(() => {\n const rowCountByCol = new Map();\n for (const [_, {spanCoords}] of this._coordsMap().entries()) {\n for (const {row, col} of spanCoords) {\n const rowCount = rowCountByCol.get(col);\n const newRowCount = row + 1;\n if (rowCount === undefined || rowCount < newRowCount) {\n rowCountByCol.set(col, newRowCount);\n }\n }\n }\n return rowCountByCol;\n });\n\n constructor(readonly inputs: GridDataInputs<T>) {\n this.cells = this.inputs.cells;\n }\n\n /** Whether the cell exists. */\n hasCell(cell: T): boolean {\n return this._coordsMap().has(cell);\n }\n\n /** Gets the cell at the given coordinates. */\n getCell(rowCol: RowCol): T | undefined {\n return this._cellMap().get(`${rowCol.row}:${rowCol.col}`);\n }\n\n /** Gets the primary coordinates of the given cell. */\n getCoords(cell: T): RowCol | undefined {\n return this._coordsMap().get(cell)?.coords;\n }\n\n /** Gets all coordinates that the given cell spans. */\n getAllCoords(cell: T): RowCol[] | undefined {\n return this._coordsMap().get(cell)?.spanCoords;\n }\n\n /** Gets the number of rows in the given column. */\n getRowCount(col: number): number | undefined {\n return this._rowCountByCol().get(col);\n }\n\n /** Gets the number of columns in the given row. */\n getColCount(row: number): number | undefined {\n return this._colCountsByRow().get(row);\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, WritableSignal} from '@angular/core';\nimport {SignalLike} from '../signal-like/signal-like';\nimport type {GridData, BaseGridCell, RowCol} from './grid-data';\n\n/** Represents an cell in a grid, such as a grid cell, that may receive focus. */\nexport interface GridFocusCell extends BaseGridCell {\n /** A unique identifier for the cell. */\n id: SignalLike<string>;\n\n /** The html element that should receive focus. */\n element: SignalLike<HTMLElement>;\n\n /** Whether a cell is disabled. */\n disabled: SignalLike<boolean>;\n}\n\n/** Represents the required inputs for a grid that contains focusable cells. */\nexport interface GridFocusInputs {\n /** The focus strategy used by the grid. */\n focusMode: SignalLike<'roving' | 'activedescendant'>;\n\n /** Whether the grid is disabled. */\n disabled: SignalLike<boolean>;\n\n /** Whether disabled cells in the grid should be focusable. */\n softDisabled: SignalLike<boolean>;\n}\n\n/** Dependencies for the `GridFocus` class. */\ninterface GridFocusDeps<T extends GridFocusCell> {\n /** The `GridData` instance that this focus manager operates on. */\n grid: GridData<T>;\n}\n\n/** Controls focus for a 2D grid of cells. */\nexport class GridFocus<T extends GridFocusCell> {\n /** The current active cell. */\n readonly activeCell: WritableSignal<T | undefined> = signal(undefined);\n\n /** The current active cell coordinates. */\n readonly activeCoords = signal<RowCol>({row: -1, col: -1});\n\n /** Whether the grid active state is empty (no active cell or coordinates). */\n readonly stateEmpty = computed(\n () =>\n this.activeCell() === undefined ||\n (this.activeCoords().row === -1 && this.activeCoords().col === -1),\n );\n\n /**\n * Whether the grid focus state is stale.\n *\n * A stale state means the active cell or coordinates are no longer valid based on the\n * current grid data, for example if the underlying cells have changed.\n * A stale state should be re-initialized.\n */\n readonly stateStale = computed(() => {\n if (this.stateEmpty()) {\n return true;\n }\n\n const activeCell = this.activeCell();\n const activeCellCoords = this.inputs.grid.getCoords(activeCell!);\n const activeCoords = this.activeCoords();\n const activeCoordsCell = this.inputs.grid.getCell(activeCoords);\n\n const activeCellNotValid = activeCellCoords === undefined;\n const activeCellMismatch = activeCell !== activeCoordsCell;\n return activeCellNotValid || activeCellMismatch;\n });\n\n /** The id of the current active cell, for ARIA activedescendant. */\n readonly activeDescendant = computed<string | undefined>(() => {\n if (this.gridDisabled() || this.inputs.focusMode() === 'roving') {\n return undefined;\n }\n const currentActiveCell = this.activeCell();\n return currentActiveCell ? currentActiveCell.id() : undefined;\n });\n\n /** Whether the grid is in a disabled state. */\n readonly gridDisabled = computed<boolean>(() => {\n if (this.inputs.disabled()) {\n return true;\n }\n const gridCells = this.inputs.grid.cells();\n return gridCells.length === 0 || gridCells.every(row => row.every(cell => cell.disabled()));\n });\n\n /** The tab index for the grid container. */\n readonly gridTabIndex = computed<-1 | 0>(() => {\n if (this.gridDisabled()) {\n return 0;\n }\n return this.inputs.focusMode() === 'activedescendant' ? 0 : -1;\n });\n\n constructor(readonly inputs: GridFocusInputs & GridFocusDeps<T>) {}\n\n /** Returns the tab index for the given grid cell cell. */\n getCellTabIndex(cell: T): -1 | 0 {\n if (this.gridDisabled()) {\n return -1;\n }\n if (this.inputs.focusMode() === 'activedescendant') {\n return -1;\n }\n return this.activeCell() === cell ? 0 : -1;\n }\n\n /** Returns true if the given cell can be navigated to. */\n isFocusable(cell: T): boolean {\n return this.inputs.grid.hasCell(cell) && (!cell.disabled() || this.inputs.softDisabled());\n }\n\n /** Focuses the given cell. */\n focusCell(cell: T): boolean {\n if (this.gridDisabled()) {\n return false;\n }\n\n if (!this.isFocusable(cell)) {\n return false;\n }\n\n if (this.inputs.grid.getCoords(cell) === undefined) {\n return false;\n }\n\n this.activeCoords.set(this.inputs.grid.getCoords(cell)!);\n this.activeCell.set(cell);\n\n return true;\n }\n\n /** Moves focus to the cell at the given coordinates if it's part of a focusable cell. */\n focusCoordinates(coords: RowCol): boolean {\n if (this.gridDisabled()) {\n return false;\n }\n\n const cell = this.inputs.grid.getCell(coords);\n\n if (!cell || !this.isFocusable(cell)) {\n return false;\n }\n\n if (this.inputs.grid.getCell(coords) === undefined) {\n return false;\n }\n\n this.activeCoords.set(coords);\n this.activeCell.set(this.inputs.grid.getCell(coords));\n\n return true;\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} from '@angular/core';\nimport {SignalLike} from '../signal-like/signal-like';\nimport {GridFocus, GridFocusCell, GridFocusInputs} from './grid-focus';\nimport {GridData, RowCol} from './grid-data';\n\n/** A utility type that ensures an object has exactly one key from a given set. */\ntype ExactlyOneKey<T, K extends keyof T = keyof T> = {\n [P in K]: Record<P, T[P]> & Partial<Record<Exclude<K, P>, never>>;\n}[K];\n\n/** Represents a directional change in the grid, either by row or by column. */\ntype Delta = ExactlyOneKey<{row: -1 | 1; col: -1 | 1}>;\n\n/** Constants for the four cardinal directions. */\nexport const direction: Record<'Up' | 'Down' | 'Left' | 'Right', Delta> = {\n Up: {row: -1},\n Down: {row: 1},\n Left: {col: -1},\n Right: {col: 1},\n} as const;\n\n/** The wrapping behavior for keyboard navigation. */\nexport type WrapStrategy = 'continuous' | 'loop' | 'nowrap';\n\n/** Represents an item in a collection, such as a listbox option, than can be navigated to. */\nexport interface GridNavigationCell extends GridFocusCell {}\n\n/** Represents the required inputs for a collection that has navigable items. */\nexport interface GridNavigationInputs extends GridFocusInputs {\n /** The wrapping behavior for keyboard navigation along the row axis. */\n rowWrap: SignalLike<WrapStrategy>;\n\n /** The wrapping behavior for keyboard navigation along the column axis. */\n colWrap: SignalLike<WrapStrategy>;\n}\n\n/** Dependencies for the `GridNavigation` class. */\ninterface GridNavigationDeps<T extends GridNavigationCell> {\n /** The `GridData` instance that this navigation manager operates on. */\n grid: GridData<T>;\n\n /** The `GridFocus` instance that this navigation manager uses to manage focus. */\n gridFocus: GridFocus<T>;\n}\n\n/** Controls navigation for a grid of items. */\nexport class GridNavigation<T extends GridNavigationCell> {\n /** The maximum number of steps to take when searching for the next cell. */\n private _maxSteps = computed<number>(\n () => this.inputs.grid.maxRowCount() * this.inputs.grid.maxColCount(),\n );\n\n constructor(readonly inputs: GridNavigationInputs & GridNavigationDeps<T>) {}\n\n /** Navigates to the given item. */\n gotoCell(cell: T): boolean {\n return this.inputs.gridFocus.focusCell(cell);\n }\n\n /** Navigates to the given coordinates. */\n gotoCoords(coords: RowCol): boolean {\n return this.inputs.gridFocus.focusCoordinates(coords);\n }\n\n /**\n * Gets the coordinates of the next focusable cell in a given direction, without changing focus.\n */\n peek(\n direction: Delta,\n fromCoords: RowCol,\n wrap?: WrapStrategy,\n allowDisabled?: boolean,\n ): RowCol | undefined {\n wrap = wrap ?? (direction.row !== undefined ? this.inputs.rowWrap() : this.inputs.colWrap());\n return this._peekDirectional(direction, fromCoords, wrap, allowDisabled);\n }\n\n /**\n * Navigates to the next focusable cell in a given direction.\n */\n advance(direction: Delta): boolean {\n const nextCoords = this.peek(direction, this.inputs.gridFocus.activeCoords());\n return !!nextCoords && this.gotoCoords(nextCoords);\n }\n\n /**\n * Gets the coordinates of the first focusable cell.\n * If a row is not provided, searches the entire grid.\n */\n peekFirst(row?: number, allowDisabled?: boolean): RowCol | undefined {\n const fromCoords = {\n row: row ?? 0,\n col: -1,\n };\n return row === undefined\n ? this._peekDirectional(direction.Right, fromCoords, 'continuous', allowDisabled)\n : this._peekDirectional(direction.Right, fromCoords, 'nowrap', allowDisabled);\n }\n\n /**\n * Navigates to the first focusable cell.\n * If a row is not provided, searches the entire grid.\n */\n first(row?: number): boolean {\n const nextCoords = this.peekFirst(row);\n return !!nextCoords && this.gotoCoords(nextCoords);\n }\n\n /**\n * Gets the coordinates of the last focusable cell.\n * If a row is not provided, searches the entire grid.\n */\n peekLast(row?: number, allowDisabled?: boolean): RowCol | undefined {\n const fromCoords = {\n row: row ?? this.inputs.grid.maxRowCount() - 1,\n col: this.inputs.grid.maxColCount(),\n };\n return row === undefined\n ? this._peekDirectional(direction.Left, fromCoords, 'continuous', allowDisabled)\n : this._peekDirectional(direction.Left, fromCoords, 'nowrap', allowDisabled);\n }\n\n /**\n * Navigates to the last focusable cell.\n * If a row is not provided, searches the entire grid.\n */\n last(row?: number): boolean {\n const nextCoords = this.peekLast(row);\n return !!nextCoords && this.gotoCoords(nextCoords);\n }\n\n /**\n * Finds the next focusable cell in a given direction based on the wrapping behavior.\n */\n private _peekDirectional(\n delta: Delta,\n fromCoords: RowCol,\n wrap: 'continuous' | 'loop' | 'nowrap',\n allowDisabled: boolean = false,\n ): RowCol | undefined {\n if (this.inputs.gridFocus.gridDisabled()) return undefined;\n\n const fromCell = this.inputs.grid.getCell(fromCoords);\n const maxRowCount = this.inputs.grid.maxRowCount();\n const maxColCount = this.inputs.grid.maxColCount();\n const rowDelta = delta.row ?? 0;\n const colDelta = delta.col ?? 0;\n let nextCoords = {...fromCoords};\n\n for (let step = 0; step < this._maxSteps(); step++) {\n const isWrapping =\n nextCoords.col + colDelta < 0 ||\n nextCoords.col + colDelta >= maxColCount ||\n nextCoords.row + rowDelta < 0 ||\n nextCoords.row + rowDelta >= maxRowCount;\n\n if (wrap === 'nowrap' && isWrapping) return undefined;\n\n if (wrap === 'continuous') {\n const generalDelta = delta.row ?? delta.col;\n const rowStep = isWrapping ? generalDelta : rowDelta;\n const colStep = isWrapping ? generalDelta : colDelta;\n\n // Reaching start or end.\n const bothWrapping =\n (nextCoords.row + rowStep >= maxRowCount && nextCoords.col + colStep >= maxColCount) ||\n (nextCoords.row + rowStep < 0 && nextCoords.col + colStep < 0);\n if (bothWrapping) return undefined;\n\n nextCoords = {\n row: (nextCoords.row + rowStep + maxRowCount) % maxRowCount,\n col: (nextCoords.col + colStep + maxColCount) % maxColCount,\n };\n }\n\n if (wrap === 'loop') {\n nextCoords = {\n row: (nextCoords.row + rowDelta + maxRowCount) % maxRowCount,\n col: (nextCoords.col + colDelta + maxColCount) % maxColCount,\n };\n }\n\n if (wrap === 'nowrap') {\n nextCoords = {\n row: nextCoords.row + rowDelta,\n col: nextCoords.col + colDelta,\n };\n }\n\n // Back to original coordinates.\n if (nextCoords.row === fromCoords.row && nextCoords.col === fromCoords.col) {\n return undefined;\n }\n\n const nextCell = this.inputs.grid.getCell(nextCoords);\n if (\n nextCell !== undefined &&\n nextCell !== fromCell &&\n (allowDisabled || this.inputs.gridFocus.isFocusable(nextCell))\n ) {\n return nextCoords;\n }\n }\n\n return undefined;\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, WritableSignalLike} from '../signal-like/signal-like';\nimport {GridFocus, GridFocusCell, GridFocusInputs} from './grid-focus';\nimport {GridData, RowCol} from './grid-data';\nimport {signal} from '@angular/core';\n\n/** Represents a cell in a grid that can be selected. */\nexport interface GridSelectionCell extends GridFocusCell {\n /** Whether the cell is selected. */\n selected: WritableSignalLike<boolean>;\n\n /** Whether the cell is selectable. */\n selectable: SignalLike<boolean>;\n}\n\n/** Represents the required inputs for a grid that has selectable cells. */\nexport interface GridSelectionInputs extends GridFocusInputs {}\n\n/** Dependencies for the `GridSelection` class. */\ninterface GridSelectionDeps<T extends GridSelectionCell> {\n /** The `GridData` instance that this selection manager operates on. */\n grid: GridData<T>;\n\n /** The `GridFocus` instance that this selection manager uses to manage focus. */\n gridFocus: GridFocus<T>;\n}\n\n/** Controls selection for a grid of items. */\nexport class GridSelection<T extends GridSelectionCell> {\n /** The list of cells that were changed in the last selection operation. */\n private readonly _undoList: WritableSignalLike<[T, boolean][]> = signal([]);\n\n constructor(readonly inputs: GridSelectionInputs & GridSelectionDeps<T>) {}\n\n /** Reverts the last selection change. */\n undo(): void {\n for (const [cell, oldState] of this._undoList()) {\n cell.selected.set(oldState);\n }\n this._undoList.set([]);\n }\n\n /** Selects one or more cells in a given range. */\n select(fromCoords: RowCol, toCoords?: RowCol): void {\n this._updateState(fromCoords, toCoords ?? fromCoords, () => true);\n }\n\n /** Deselects one or more cells in a given range. */\n deselect(fromCoords: RowCol, toCoords?: RowCol): void {\n this._updateState(fromCoords, toCoords ?? fromCoords, () => false);\n }\n\n /** Toggles the selection state of one or more cells in a given range. */\n toggle(fromCoords: RowCol, toCoords?: RowCol): void {\n this._updateState(fromCoords, toCoords ?? fromCoords, oldState => !oldState);\n }\n\n /** Selects all valid cells in the grid. */\n selectAll(): void {\n this._updateState(\n {row: 0, col: 0},\n {row: this.inputs.grid.maxRowCount(), col: this.inputs.grid.maxColCount()},\n () => true,\n );\n }\n\n /** Deselects all valid cells in the grid. */\n deselectAll(): void {\n this._updateState(\n {row: 0, col: 0},\n {row: this.inputs.grid.maxRowCount(), col: this.inputs.grid.maxColCount()},\n () => false,\n );\n }\n\n /** Whether a cell is selctable. */\n isSelectable(cell: T) {\n return cell.selectable() && !cell.disabled();\n }\n\n /** A generator that yields all cells within a given range. */\n *_validCells(fromCoords: RowCol, toCoords: RowCol): Generator<T> {\n const startRow = Math.min(fromCoords.row, toCoords.row);\n const startCol = Math.min(fromCoords.col, toCoords.col);\n const endRow = Math.max(fromCoords.row, toCoords.row);\n const endCol = Math.max(fromCoords.col, toCoords.col);\n const visited = new Set<T>();\n for (let row = startRow; row < endRow + 1; row++) {\n for (let col = startCol; col < endCol + 1; col++) {\n const cell = this.inputs.grid.getCell({row, col});\n if (cell === undefined) continue;\n if (!this.isSelectable(cell)) continue;\n if (visited.has(cell)) continue;\n visited.add(cell);\n yield cell;\n }\n }\n }\n\n /**\n * Updates the selection state of cells in a given range and preserves previous changes\n * to a undo list.\n */\n private _updateState(\n fromCoords: RowCol,\n toCoords: RowCol,\n stateFn: (oldState: boolean) => boolean,\n ): void {\n const undoList: [T, boolean][] = [];\n for (const cell of this._validCells(fromCoords, toCoords)) {\n const oldState = cell.selected();\n undoList.push([cell, oldState]);\n cell.selected.set(stateFn(oldState));\n }\n this._undoList.set(undoList);\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, linkedSignal, signal} from '@angular/core';\nimport {GridData, BaseGridCell, GridDataInputs, RowCol} from './grid-data';\nimport {GridFocus, GridFocusCell, GridFocusInputs} from './grid-focus';\nimport {\n direction,\n GridNavigation,\n GridNavigationCell,\n GridNavigationInputs,\n} from './grid-navigation';\nimport {GridSelectionCell, GridSelectionInputs, GridSelection} from './grid-selection';\nimport {SignalLike} from '../signal-like/signal-like';\n\n/** The selection operations that can be performed after a navigation operation. */\nexport interface NavOptions {\n /** Toggles the selection state of the active cell. */\n toggle?: boolean;\n\n /**\n * Toggles the selection state of the active cell, and deselects all other cells if the\n * active cell is selected. If the active cell is the only selected cell, it will be deselected.\n */\n toggleOne?: boolean;\n\n /** Selects the active cell, preserving the selection state of other cells. */\n select?: boolean;\n\n /** Deselects all other cells and selects the active cell. */\n selectOne?: boolean;\n\n /**\n * Moves the selection anchor to the active cell and updates the selection to include all\n * cells between the anchor and the active cell.\n */\n anchor?: boolean;\n}\n\n/** A type that represents a cell in a grid, combining all cell-related interfaces. */\nexport type GridCell = BaseGridCell & GridFocusCell & GridNavigationCell & GridSelectionCell;\n\n/** Represents the required inputs for a grid. */\nexport type GridInputs<T extends GridCell> = GridDataInputs<T> &\n GridFocusInputs &\n GridNavigationInputs &\n GridSelectionInputs;\n\n/** The main class that orchestrates the grid behaviors. */\nexport class Grid<T extends GridCell> {\n /** The underlying data structure for the grid. */\n readonly data: GridData<T>;\n\n /** Controls focus for the grid. */\n readonly focusBehavior: GridFocus<T>;\n\n /** Controls navigation for the grid. */\n readonly navigationBehavior: GridNavigation<T>;\n\n /** Controls selection for the grid. */\n readonly selectionBehavior: GridSelection<T>;\n\n /** The anchor point for range selection, linked to the active coordinates. */\n readonly selectionAnchor = linkedSignal<RowCol>(() => this.focusBehavior.activeCoords());\n\n /** The cell at the selection anchor. */\n readonly selectionAnchorCell = computed(() => this.data.getCell(this.selectionAnchor()));\n\n /** Whether a range selection has settled. */\n readonly selectionStabled = signal(true);\n\n /** Whether all selectable cells are selected. */\n readonly allSelected: SignalLike<boolean> = computed(() =>\n this.data\n .cells()\n .flat()\n .filter(c => this.selectionBehavior.isSelectable(c))\n .every(c => c.selected()),\n );\n\n /** The tab index for the grid container. */\n readonly gridTabIndex: SignalLike<-1 | 0> = () => this.focusBehavior.gridTabIndex();\n\n /** Whether the grid is in a disabled state. */\n readonly gridDisabled: SignalLike<boolean> = () => this.focusBehavior.gridDisabled();\n\n /** The ID of the active descendant for ARIA `activedescendant` focus management. */\n readonly activeDescendant: SignalLike<string | undefined> = () =>\n this.focusBehavior.activeDescendant();\n\n constructor(readonly inputs: GridInputs<T>) {\n this.data = new GridData(inputs);\n this.focusBehavior = new GridFocus({...inputs, grid: this.data});\n this.navigationBehavior = new GridNavigation({\n ...inputs,\n grid: this.data,\n gridFocus: this.focusBehavior,\n });\n this.selectionBehavior = new GridSelection({\n ...inputs,\n grid: this.data,\n gridFocus: this.focusBehavior,\n });\n }\n\n /** Gets the 1-based row index of a cell. */\n rowIndex(cell: T): number | undefined {\n const index = this.data.getCoords(cell)?.row;\n return index !== undefined ? index + 1 : undefined;\n }\n\n /** Gets the 1-based column index of a cell. */\n colIndex(cell: T): number | undefined {\n const index = this.data.getCoords(cell)?.col;\n return index !== undefined ? index + 1 : undefined;\n }\n\n /** Gets the tab index for a given cell. */\n cellTabIndex(cell: T): -1 | 0 {\n return this.focusBehavior.getCellTabIndex(cell);\n }\n\n /** Navigates to the cell above the currently active cell. */\n up(opts: NavOptions = {}): boolean {\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() =>\n this.navigationBehavior.peek(direction.Up, this.selectionAnchor(), 'nowrap', true),\n )\n : this.navigationBehavior.advance(direction.Up),\n opts,\n );\n }\n\n /** Navigates to the cell below the currently active cell. */\n down(opts: NavOptions = {}): boolean {\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() =>\n this.navigationBehavior.peek(direction.Down, this.selectionAnchor(), 'nowrap', true),\n )\n : this.navigationBehavior.advance(direction.Down),\n opts,\n );\n }\n\n /** Navigates to the cell to the left of the currently active cell. */\n left(opts: NavOptions = {}): boolean {\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() =>\n this.navigationBehavior.peek(direction.Left, this.selectionAnchor(), 'nowrap', true),\n )\n : this.navigationBehavior.advance(direction.Left),\n opts,\n );\n }\n\n /** Navigates to the cell to the right of the currently active cell. */\n right(opts: NavOptions = {}): boolean {\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() =>\n this.navigationBehavior.peek(direction.Right, this.selectionAnchor(), 'nowrap', true),\n )\n : this.navigationBehavior.advance(direction.Right),\n opts,\n );\n }\n\n /** Navigates to the first focusable cell in the grid. */\n first(opts: NavOptions = {}): boolean {\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() => this.navigationBehavior.peekFirst(undefined, true))\n : this.navigationBehavior.first(),\n opts,\n );\n }\n\n /** Navigates to the first focusable cell in the current row. */\n firstInRow(opts: NavOptions = {}): boolean {\n const row = this.focusBehavior.activeCoords().row;\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() => this.navigationBehavior.peekFirst(row, true))\n : this.navigationBehavior.first(row),\n opts,\n );\n }\n\n /** Navigates to the last focusable cell in the grid. */\n last(opts: NavOptions = {}): boolean {\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() => this.navigationBehavior.peekLast(undefined, true))\n : this.navigationBehavior.last(),\n opts,\n );\n }\n\n /** Navigates to the last focusable cell in the current row. */\n lastInRow(opts: NavOptions = {}): boolean {\n const row = this.focusBehavior.activeCoords().row;\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() => this.navigationBehavior.peekLast(row, true))\n : this.navigationBehavior.last(row),\n opts,\n );\n }\n\n /** Selects all cells in the current row. */\n selectRow(): void {\n const row = this.focusBehavior.activeCoords().row;\n this.selectionBehavior.deselectAll();\n this.selectionBehavior.select({row, col: 0}, {row, col: this.data.maxColCount()});\n }\n\n /** Selects all cells in the current column. */\n selectCol(): void {\n const col = this.focusBehavior.activeCoords().col;\n this.selectionBehavior.deselectAll();\n this.selectionBehavior.select({row: 0, col}, {row: this.data.maxRowCount(), col});\n }\n\n /** Selects the active cell. */\n select(): void {\n this.selectionBehavior.select(this.focusBehavior.activeCoords());\n }\n\n /** Deselects the active cell. */\n deselect(): void {\n this.selectionBehavior.deselect(this.focusBehavior.activeCoords());\n }\n\n /**\n * Toggles the selection state of the coordinates of the given cell\n * or the current active coordinates.\n */\n toggle(): void {\n this.selectionBehavior.toggle(this.focusBehavior.activeCoords());\n }\n\n /** Toggles the selection state of the active cell, and deselects all other cells. */\n toggleOne(): void {\n const selected = !!this.focusBehavior.activeCell()?.selected();\n if (selected) {\n this.deselect();\n return;\n }\n\n this.deselectAll();\n this.select();\n }\n\n /** Selects all selectable cells in the grid. */\n selectAll(): void {\n this.selectionBehavior.selectAll();\n }\n\n /** Deselects all cells in the grid. */\n deselectAll(): void {\n this.selectionBehavior.deselectAll();\n }\n\n /** Navigates to and focuses the given cell. */\n gotoCell(cell: T, opts: NavOptions = {}): boolean {\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() => this.data.getCoords(cell))\n : this.navigationBehavior.gotoCell(cell),\n opts,\n );\n }\n\n /** Sets the default active state of the grid. */\n setDefaultState(): boolean {\n // Try to find a selected cell that's focusable.\n const focusableSelectedCell: T | undefined = this.data\n .cells()\n .flat()\n .filter(c => this.focusBehavior.isFocusable(c))\n .find(c => c.selected());\n\n if (focusableSelectedCell !== undefined) {\n this.focusBehavior.focusCell(focusableSelectedCell);\n return true;\n }\n\n // Otherwise find the first focusable cell.\n const firstFocusableCoords = this.navigationBehavior.peekFirst();\n\n if (firstFocusableCoords !== undefined) {\n return this.focusBehavior.focusCoordinates(firstFocusableCoords);\n }\n\n return false;\n }\n\n /** Resets the active state of the grid if it is empty or stale. */\n resetState(): boolean {\n if (this.focusBehavior.stateEmpty()) {\n return this.setDefaultState();\n }\n\n if (this.focusBehavior.stateStale()) {\n // Try focus on the same active cell after if a reordering happened.\n if (this.focusBehavior.focusCell(this.focusBehavior.activeCell()!)) {\n return true;\n }\n\n // If the active cell is no longer exist, focus on the coordinates instead.\n if (this.focusBehavior.focusCoordinates(this.focusBehavior.activeCoords())) {\n return true;\n }\n\n // If the coordinates no longer valid, go back to the first available cell.\n if (this.focusBehavior.focusCoordinates(this.navigationBehavior.peekFirst()!)) {\n return true;\n }\n }\n\n return false;\n }\n\n /** Updates the selection anchor to the given coordinates. */\n private _updateSelectionAnchor(peekFn: () => RowCol | undefined): boolean {\n const coords = peekFn();\n const success = coords !== undefined;\n if (!success) return false;\n this.selectionAnchor.set(coords);\n return success;\n }\n\n /** Updates the selection to include all cells between the anchor and the active cell. */\n private _updateRangeSelection(): void {\n if (!this.selectionStabled()) {\n this.selectionBehavior.undo();\n }\n this.selectionBehavior.select(\n ...this._getSelectionCoords(this.focusBehavior.activeCoords(), this.selectionAnchor()),\n );\n }\n\n /** Gets the start and end coordinates for a selection range. */\n private _getSelectionCoords(startCoords: RowCol, endCoords: RowCol): [RowCol, RowCol] {\n const startCell = this.data.getCell(startCoords)!;\n const endCell = this.data.getCell(endCoords)!;\n const allCoords = [...this.data.getAllCoords(startCell)!, ...this.data.getAllCoords(endCell)!];\n const allRows = allCoords.map(c => c.row);\n const allCols = allCoords.map(c => c.col);\n const fromCoords = {\n row: Math.min(...allRows),\n col: Math.min(...allCols),\n };\n const toCoords = {\n row: Math.max(...allRows),\n col: Math.max(...allCols),\n };\n\n return [fromCoords, toCoords];\n }\n\n /** Executes a navigation operation and applies selection options. */\n private _navigateWithSelection(op: () => boolean, opts: NavOptions = {}): boolean {\n const success = op();\n if (!success) return false;\n\n if (opts.anchor) {\n this._updateRangeSelection();\n this.selectionStabled.set(false);\n return success;\n }\n\n // Selection becomes stable after the active cell/coords moved.\n this.selectionStabled.set(true);\n\n if (opts.select) {\n this.select();\n return success;\n }\n\n if (opts.selectOne) {\n this.deselectAll();\n this.select();\n return success;\n }\n\n if (opts.toggle) {\n this.toggle();\n return success;\n }\n\n if (opts.toggleOne) {\n const selected = !!this.focusBehavior.activeCell()?.selected();\n this.deselectAll();\n if (!selected) {\n this.select();\n }\n return success;\n }\n\n return success;\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, untracked} from '@angular/core';\nimport {SignalLike} from '../behaviors/signal-like/signal-like';\nimport {KeyboardEventManager, PointerEventManager, Modifier} from '../behaviors/event-manager';\nimport {NavOptions, Grid, GridInputs as GridBehaviorInputs} from '../behaviors/grid';\nimport type {GridRowPattern} from './row';\nimport type {GridCellPattern} from './cell';\n\n/** Represents the required inputs for the grid pattern. */\nexport interface GridInputs extends Omit<GridBehaviorInputs<GridCellPattern>, 'cells'> {\n /** The html element of the grid. */\n element: SignalLike<HTMLElement>;\n\n /** The rows that make up the grid. */\n rows: SignalLike<GridRowPattern[]>;\n\n /** The direction that text is read based on the users locale. */\n textDirection: SignalLike<'rtl' | 'ltr'>;\n\n /** Whether selection is enabled for the grid. */\n enableSelection: SignalLike<boolean>;\n\n /** Whether multiple cell in the grid can be selected. */\n multi: SignalLike<boolean>;\n\n /** The selection strategy used by the grid. */\n selectionMode: SignalLike<'follow' | 'explicit'>;\n\n /** Whether enable range selection. */\n enableRangeSelection: SignalLike<boolean>;\n\n /** A function that returns the grid cell associated with a given element. */\n getCell: (e: Element | null) => GridCellPattern | undefined;\n}\n\n/** The UI pattern for a grid, handling keyboard navigation, focus, and selection. */\nexport class GridPattern {\n /** The underlying grid behavior that this pattern is built on. */\n readonly gridBehavior: Grid<GridCellPattern>;\n\n /** The cells in the grid. */\n readonly cells = computed(() => this.gridBehavior.data.cells());\n\n /** The tab index for the grid. */\n readonly tabIndex = computed(() => this.gridBehavior.gridTabIndex());\n\n /** Whether the grid is disabled. */\n readonly disabled = computed(() => this.gridBehavior.gridDisabled());\n\n /** The ID of the currently active descendant cell. */\n readonly activeDescendant = computed(() => this.gridBehavior.activeDescendant());\n\n /** The currently active cell. */\n readonly activeCell = computed(() => this.gridBehavior.focusBehavior.activeCell());\n\n /** The current selection anchor cell. */\n readonly anchorCell: SignalLike<GridCellPattern | undefined> = computed(() =>\n this.inputs.enableSelection() && this.inputs.multi()\n ? this.gridBehavior.selectionAnchorCell()\n : undefined,\n );\n\n /** Whether to pause grid navigation and give the keyboard control to cell or widget. */\n readonly pauseNavigation: SignalLike<boolean> = computed(() =>\n this.gridBehavior.data\n .cells()\n .flat()\n .reduce((res, c) => res || c.isActivated(), false),\n );\n\n /** Whether the focus is in the grid. */\n readonly isFocused = signal(false);\n\n /** Whether the grid has been focused once. */\n readonly hasBeenFocused = signal(false);\n\n /** Whether the user is currently dragging to select a range of cells. */\n readonly dragging = signal(false);\n\n /** The key for navigating to the previous column. */\n readonly prevColKey = computed(() =>\n this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft',\n );\n\n /** The key for navigating to the next column. */\n readonly nextColKey = computed(() =>\n this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight',\n );\n\n /** The keydown event manager for the grid. */\n readonly keydown = computed(() => {\n const manager = new KeyboardEventManager();\n\n if (this.pauseNavigation()) {\n return manager;\n }\n\n // Navigation handlers.\n const opts: NavOptions = {\n selectOne: this.inputs.enableSelection() && this.inputs.selectionMode() === 'follow',\n };\n manager\n .on('ArrowUp', () => this.gridBehavior.up(opts))\n .on('ArrowDown', () => this.gridBehavior.down(opts))\n .on(this.prevColKey(), () => this.gridBehavior.left(opts))\n .on(this.nextColKey(), () => this.gridBehavior.right(opts))\n .on('Home', () => this.gridBehavior.firstInRow(opts))\n .on('End', () => this.gridBehavior.lastInRow(opts))\n .on([Modifier.Ctrl], 'Home', () => this.gridBehavior.first(opts))\n .on([Modifier.Ctrl], 'End', () => this.gridBehavior.last(opts));\n\n // Basic explicit selection handlers.\n if (this.inputs.enableSelection() && this.inputs.selectionMode() === 'explicit') {\n manager.on(/Enter| /, () =>\n this.inputs.multi() ? this.gridBehavior.toggle() : this.gridBehavior.toggleOne(),\n );\n }\n\n // Range selection handlers.\n if (this.inputs.enableSelection() && this.inputs.enableRangeSelection()) {\n manager\n .on(Modifier.Shift, 'ArrowUp', () => this.gridBehavior.up({anchor: true}))\n .on(Modifier.Shift, 'ArrowDown', () => this.gridBehavior.down({anchor: true}))\n .on(Modifier.Shift, this.prevColKey(), () => this.gridBehavior.left({anchor: true}))\n .on(Modifier.Shift, this.nextColKey(), () => this.gridBehavior.right({anchor: true}))\n .on(Modifier.Shift, 'Home', () => this.gridBehavior.firstInRow({anchor: true}))\n .on(Modifier.Shift, 'End', () => this.gridBehavior.lastInRow({anchor: true}))\n .on([Modifier.Ctrl | Modifier.Shift], 'Home', () => this.gridBehavior.first({anchor: true}))\n .on([Modifier.Ctrl | Modifier.Shift], 'End', () => this.gridBehavior.last({anchor: true}))\n .on([Modifier.Ctrl, Modifier.Meta], 'A', () => {\n if (this.gridBehavior.allSelected()) {\n this.gridBehavior.deselectAll();\n } else {\n this.gridBehavior.selectAll();\n }\n })\n .on([Modifier.Shift], ' ', () => this.gridBehavior.selectRow())\n .on([Modifier.Ctrl, Modifier.Meta], ' ', () => this.gridBehavior.selectCol());\n }\n\n return manager;\n });\n\n /** The pointerdown event manager for the grid. */\n readonly pointerdown = computed(() => {\n const manager = new PointerEventManager();\n\n // Navigation without selection.\n if (!this.inputs.enableSelection()) {\n manager.on(e => {\n const cell = this.inputs.getCell(e.target as Element);\n if (!cell || !this.gridBehavior.focusBehavior.isFocusable(cell)) return;\n\n this.gridBehavior.gotoCell(cell);\n });\n }\n\n // Navigation with selection.\n if (this.inputs.enableSelection()) {\n manager.on(e => {\n const cell = this.inputs.getCell(e.target as Element);\n if (!cell || !this.gridBehavior.focusBehavior.isFocusable(cell)) return;\n\n this.gridBehavior.gotoCell(cell, {\n selectOne: this.inputs.selectionMode() === 'follow',\n toggleOne: this.inputs.selectionMode() === 'explicit' && !this.inputs.multi(),\n toggle: this.inputs.selectionMode() === 'explicit' && this.inputs.multi(),\n });\n\n if (this.inputs.multi() && this.inputs.enableRangeSelection()) {\n this.dragging.set(true);\n }\n });\n\n // Selection with modifier keys.\n if (this.inputs.multi()) {\n manager.on([Modifier.Ctrl, Modifier.Meta], e => {\n const cell = this.inputs.getCell(e.target as Element);\n if (!cell || !this.gridBehavior.focusBehavior.isFocusable(cell)) return;\n\n this.gridBehavior.gotoCell(cell, {toggle: true});\n\n if (this.inputs.enableRangeSelection()) {\n this.dragging.set(true);\n }\n });\n\n if (this.inputs.enableRangeSelection()) {\n manager.on(Modifier.Shift, e => {\n const cell = this.inputs.getCell(e.target as Element);\n if (!cell) return;\n\n this.gridBehavior.gotoCell(cell, {anchor: true});\n this.dragging.set(true);\n });\n }\n }\n }\n\n return manager;\n });\n\n /** The pointerup event manager for the grid. */\n readonly pointerup = computed(() => {\n const manager = new PointerEventManager();\n\n if (this.inputs.enableSelection() && this.inputs.enableRangeSelection()) {\n manager.on([Modifier.Shift, Modifier.Ctrl, Modifier.Meta, Modifier.None], () => {\n this.dragging.set(false);\n });\n }\n\n return manager;\n });\n\n /** Indicates maybe the losing focus is caused by row/cell deletion. */\n private readonly _maybeDeletion = signal(false);\n\n /** Indicates the losing focus is certainly caused by row/cell deletion. */\n private readonly _deletion = signal(false);\n\n /** Whether the grid state is stale and needs to be reconciled. */\n private readonly _stateStale = signal(false);\n\n constructor(readonly inputs: GridInputs) {\n this.gridBehavior = new Grid({\n ...inputs,\n cells: computed(() => this.inputs.rows().map(row => row.inputs.cells())),\n });\n }\n\n /** Handles keydown events on the grid. */\n onKeydown(event: KeyboardEvent) {\n if (this.disabled()) return;\n\n this.activeCell()?.onKeydown(event);\n this.keydown().handle(event);\n }\n\n /** Handles pointerdown events on the grid. */\n onPointerdown(event: PointerEvent) {\n if (this.disabled()) return;\n\n this.pointerdown().handle(event);\n }\n\n /** Handles pointermove events on the grid. */\n onPointermove(event: PointerEvent) {\n if (\n this.disabled() ||\n !this.inputs.enableSelection() ||\n !this.inputs.enableRangeSelection() ||\n !this.dragging()\n ) {\n return;\n }\n\n const cell = this.inputs.getCell(event.target as Element);\n\n // Dragging anchor.\n if (cell !== undefined) {\n this.gridBehavior.gotoCell(cell, {anchor: true});\n }\n }\n\n /** Handles pointerup events on the grid. */\n onPointerup(event: PointerEvent) {\n if (this.disabled()) return;\n\n this.pointerup().handle(event);\n }\n\n /** Handles focusin events on the grid. */\n onFocusIn(event: FocusEvent) {\n this.isFocused.set(true);\n this.hasBeenFocused.set(true);\n\n // Skip if in the middle of range selection.\n if (this.dragging()) return;\n\n // Cell that receives focus.\n const cell = this.inputs.getCell(event.target as Element | null);\n if (!cell || !this.gridBehavior.focusBehavior.isFocusable(cell)) return;\n\n // Pass down the focusin event to the cell.\n cell.onFocusIn(event);\n\n // Update active cell state if the cell is receiving focus by\n // tabbing, pointer, or any programmatic control into a widget inside the cell.\n if (cell !== this.activeCell()) {\n this.gridBehavior.gotoCell(cell);\n }\n }\n\n /** Handles focusout events on the grid. */\n onFocusOut(event: FocusEvent) {\n // Pass down focusout event to the cell that loses focus.\n const blurTarget = event.target as Element | null;\n const cell = this.inputs.getCell(blurTarget);\n\n // Pass down the focusout event to the cell.\n cell?.onFocusOut(event);\n\n const focusTarget = event.relatedTarget as Element | null;\n if (this.inputs.element().contains(focusTarget)) return;\n\n // If a `relatedTarget`(focusing target) is null, then it can be caused by either\n // - Clicking on a non-focusable element, or\n // - The focused element is removed from the page.\n if (focusTarget === null) {\n this._maybeDeletion.set(true);\n }\n\n this.isFocused.set(false);\n }\n\n /** Sets the default active state of the grid before receiving focus the first time. */\n setDefaultStateEffect(): void {\n if (this.hasBeenFocused()) return;\n\n this.gridBehavior.setDefaultState();\n }\n\n /** Resets the active state of the grid if it is empty or stale. */\n resetStateEffect(): void {\n const hasReset = this.gridBehavior.resetState();\n\n if (hasReset) {\n // If the active state has been reset right after a focusout event, then\n // we know it's caused by a row/cell deletion.\n if (this._maybeDeletion()) {\n this._deletion.set(true);\n } else {\n this._stateStale.set(true);\n }\n }\n // Reset maybe deletion state.\n this._maybeDeletion.set(false);\n }\n\n /** Resets the focus to the active cell element or grid element. */\n resetFocusEffect(): void {\n const stateStale = this._stateStale();\n if (!stateStale) return;\n\n const isFocused = untracked(() => this.isFocused());\n const isRoving = untracked(() => this.inputs.focusMode() === 'roving');\n const activeCell = untracked(() => this.activeCell());\n\n if (isRoving && activeCell !== undefined && isFocused) {\n if (!activeCell.isFocused()) {\n activeCell.focus();\n }\n }\n\n this._stateStale.set(false);\n }\n\n /** Restore focus when a deletion happened. */\n restoreFocusEffect(): void {\n const deletion = this._deletion();\n if (!deletion) return;\n\n const isRoving = untracked(() => this.inputs.focusMode() === 'roving');\n const activeCell = untracked(() => this.activeCell());\n\n if (isRoving && activeCell !== undefined) {\n if (!activeCell.isFocused()) {\n activeCell.focus();\n }\n }\n\n this._deletion.set(false);\n }\n\n /** Sets focus when active cell changed. */\n focusEffect(): void {\n const activeCell = this.activeCell();\n const gridFocused = untracked(() => this.isFocused());\n\n if (activeCell === undefined || !gridFocused) return;\n\n const isRoving = untracked(() => this.inputs.focusMode() === 'roving');\n const cellFocused = untracked(() => activeCell.isFocused());\n\n if (isRoving && !cellFocused) {\n activeCell.focus();\n }\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 '../behaviors/signal-like/signal-like';\nimport type {GridPattern} from './grid';\nimport type {GridCellPattern} from './cell';\n\n/** The inputs for the `GridRowPattern`. */\nexport interface GridRowInputs {\n /** The `GridPattern` that this row belongs to. */\n grid: SignalLike<GridPattern>;\n\n /** The cells that make up this row. */\n cells: SignalLike<GridCellPattern[]>;\n\n /** The index of this row within the grid. */\n rowIndex: SignalLike<number | undefined>;\n}\n\n/** The UI pattern for a grid row. */\nexport class GridRowPattern {\n /** The index of this row within the grid. */\n rowIndex: SignalLike<number | undefined>;\n\n constructor(readonly inputs: GridRowInputs) {\n this.rowIndex = inputs.rowIndex;\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, linkedSignal, WritableSignal} from '@angular/core';\nimport {KeyboardEventManager} from '../behaviors/event-manager';\nimport {ListFocus} from '../behaviors/list-focus/list-focus';\nimport {ListNavigation, ListNavigationInputs} from '../behaviors/list-navigation/list-navigation';\nimport {SignalLike, WritableSignalLike} from '../behaviors/signal-like/signal-like';\nimport {GridCell} from '../behaviors/grid';\nimport type {GridPattern} from './grid';\nimport type {GridRowPattern} from './row';\nimport {GridCellWidgetPattern} from './widget';\n\n/** The inputs for the `GridCellPattern`. */\nexport interface GridCellInputs\n extends GridCell,\n Omit<\n ListNavigationInputs<GridCellWidgetPattern>,\n 'focusMode' | 'items' | 'activeItem' | 'softDisabled' | 'element'\n > {\n /** The `GridPattern` that this cell belongs to. */\n grid: SignalLike<GridPattern>;\n\n /** The `GridRowPattern` that this cell belongs to. */\n row: SignalLike<GridRowPattern>;\n\n /** The widget patterns contained within this cell, if any. */\n widgets: SignalLike<GridCellWidgetPattern[]>;\n\n /** The index of this cell's row within the grid. */\n rowIndex: SignalLike<number | undefined>;\n\n /** The index of this cell's column within the grid. */\n colIndex: SignalLike<number | undefined>;\n\n /** A function that returns the cell widget associated with a given element. */\n getWidget: (e: Element | null) => GridCellWidgetPattern | undefined;\n}\n\n/** The UI pattern for a grid cell. */\nexport class GridCellPattern implements GridCell {\n /** A unique identifier for the cell. */\n readonly id: SignalLike<string> = () => this.inputs.id();\n\n /** The html element that should receive focus. */\n readonly element: SignalLike<HTMLElement> = () => this.inputs.element();\n\n /** Whether the cell has focus. */\n readonly isFocused: WritableSignal<boolean> = signal(false);\n\n /** Whether the cell is selected. */\n readonly selected: WritableSignalLike<boolean>;\n\n /** Whether the cell is selectable. */\n readonly selectable: SignalLike<boolean> = () => this.inputs.selectable();\n\n /** Whether a cell is disabled. */\n readonly disabled: SignalLike<boolean> = () => this.inputs.disabled();\n\n /** The number of rows the cell should span. */\n readonly rowSpan: SignalLike<number> = () => this.inputs.rowSpan();\n\n /** The number of columns the cell should span. */\n readonly colSpan: SignalLike<number> = () => this.inputs.colSpan();\n\n /** Whether the cell is active. */\n readonly active: SignalLike<boolean> = computed(() => this.inputs.grid().activeCell() === this);\n\n /** Whether the cell is a selection anchor. */\n readonly anchor: SignalLike<true | undefined> = computed(() =>\n this.inputs.grid().anchorCell() === this ? true : undefined,\n );\n\n /** The `aria-selected` attribute for the cell. */\n readonly ariaSelected: SignalLike<boolean | undefined> = computed(() =>\n this.inputs.grid().inputs.enableSelection() && this.selectable() ? this.selected() : undefined,\n );\n\n /** The `aria-rowindex` attribute for the cell. */\n readonly ariaRowIndex: SignalLike<number | undefined> = computed(\n () =>\n this.inputs.row().rowIndex() ??\n this.inputs.rowIndex() ??\n this.inputs.grid().gridBehavior.rowIndex(this),\n );\n\n /** The `aria-colindex` attribute for the cell. */\n readonly ariaColIndex: SignalLike<number | undefined> = computed(\n () => this.inputs.colIndex() ?? this.inputs.grid().gridBehavior.colIndex(this),\n );\n\n /** The internal tab index calculation for the cell. */\n private readonly _tabIndex: SignalLike<-1 | 0> = computed(() =>\n this.inputs.grid().gridBehavior.cellTabIndex(this),\n );\n\n /** The tab index for the cell. If the cell contains a widget, the cell's tab index is -1. */\n readonly tabIndex: SignalLike<-1 | 0> = computed(() => {\n if (this.singleWidgetMode() || this.navigationActivated()) {\n return -1;\n }\n return this._tabIndex();\n });\n\n // Single/Multi Widget Navigation Setup\n\n /** Whether the cell contains a single widget. */\n readonly singleWidgetMode: SignalLike<boolean> = computed(\n () => this.inputs.widgets().length === 1,\n );\n\n /** Whether the cell contains multiple widgets. */\n readonly multiWidgetMode: SignalLike<boolean> = computed(() => this.inputs.widgets().length > 1);\n\n /** Whether navigation between widgets is disabled. */\n readonly navigationDisabled: SignalLike<boolean> = computed(\n () => !this.multiWidgetMode() || !this.active() || this.inputs.disabled(),\n );\n\n /** The focus behavior for the widgets in the cell. */\n readonly focusBehavior: ListFocus<GridCellWidgetPattern>;\n\n /** The navigation behavior for the widgets in the cell. */\n readonly navigationBehavior: ListNavigation<GridCellWidgetPattern>;\n\n /** The currently active widget in the cell. */\n readonly activeWidget: WritableSignalLike<GridCellWidgetPattern | undefined> = linkedSignal(() =>\n this.inputs.widgets().length > 0 ? this.inputs.widgets()[0] : undefined,\n );\n\n /** Whether navigation between widgets is activated. */\n readonly navigationActivated: WritableSignalLike<boolean> = signal(false);\n\n /** Whether any widget within the cell is activated. */\n readonly widgetActivated: SignalLike<boolean> = computed(() =>\n this.inputs.widgets().some(w => w.isActivated()),\n );\n\n /** Whether the cell or widget inside the cell is activated. */\n readonly isActivated: SignalLike<boolean> = computed(\n () => this.navigationActivated() || this.widgetActivated(),\n );\n\n /** The key used to navigate to the previous widget. */\n readonly prevKey = computed(() => {\n if (this.inputs.orientation() === 'vertical') {\n return 'ArrowUp';\n }\n return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';\n });\n\n /** The key used to navigate to the next widget. */\n readonly nextKey = computed(() => {\n if (this.inputs.orientation() === 'vertical') {\n return 'ArrowDown';\n }\n return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';\n });\n\n /** The keyboard event manager for the cell. */\n readonly keydown = computed(() => {\n const manager = new KeyboardEventManager();\n\n // Before start list navigation.\n if (!this.navigationActivated()) {\n manager.on('Enter', () => this.startNavigation());\n return manager;\n }\n\n // Start list navigation.\n manager\n .on('Escape', () => this.stopNavigation())\n .on(this.prevKey(), () =>\n this._advance(() => this.navigationBehavior.prev({focusElement: false})),\n )\n .on(this.nextKey(), () =>\n this._advance(() => this.navigationBehavior.next({focusElement: false})),\n )\n .on('Home', () => this._advance(() => this.navigationBehavior.next({focusElement: false})))\n .on('End', () => this._advance(() => this.navigationBehavior.next({focusElement: false})));\n\n return manager;\n });\n\n constructor(readonly inputs: GridCellInputs) {\n this.selected = inputs.selected;\n\n const listNavigationInputs: ListNavigationInputs<GridCellWidgetPattern> = {\n ...inputs,\n items: inputs.widgets,\n activeItem: this.activeWidget,\n disabled: this.navigationDisabled,\n focusMode: () => 'roving',\n softDisabled: () => true,\n };\n\n this.focusBehavior = new ListFocus<GridCellWidgetPattern>(listNavigationInputs);\n this.navigationBehavior = new ListNavigation<GridCellWidgetPattern>({\n ...listNavigationInputs,\n focusManager: this.focusBehavior,\n });\n }\n\n /** Handles keydown events for the cell. */\n onKeydown(event: KeyboardEvent): void {\n if (this.disabled() || this.inputs.widgets().length === 0) return;\n\n // No navigation needed if single widget.\n if (this.singleWidgetMode()) {\n this.activeWidget()!.onKeydown(event);\n return;\n }\n\n // Focus is on the cell before the navigation starts.\n if (!this.navigationActivated()) {\n this.keydown().handle(event);\n return;\n }\n\n // Widget activate state can be changed during the widget keydown handling.\n const widgetActivated = this.widgetActivated();\n\n this.activeWidget()!.onKeydown(event);\n\n if (!widgetActivated) {\n this.keydown().handle(event);\n }\n }\n\n /** Handles focusin events for the cell. */\n onFocusIn(event: FocusEvent): void {\n this.isFocused.set(true);\n\n const focusTarget = event.target as Element | null;\n const widget = this.inputs.getWidget(focusTarget);\n if (!widget) return;\n\n // Pass down focusin event to the widget.\n widget.onFocusIn(event);\n\n // Update internal states if the widget(or anything within the widget) is\n // receiving focus by tabbing, pointer, or any programmatic control.\n\n // Update current active widget.\n if (widget !== this.activeWidget()) {\n this.navigationBehavior.goto(widget, {focusElement: false});\n }\n\n // Start widget navigation if multi widget.\n if (this.multiWidgetMode()) {\n this.navigationActivated.set(true);\n }\n }\n\n /** Handles focusout events for the cell. */\n onFocusOut(event: FocusEvent): void {\n const blurTarget = event.target as Element | null;\n const widget = this.inputs.getWidget(blurTarget);\n\n // Pass down focusout event to the widget.\n widget?.onFocusOut(event);\n\n const focusTarget = event.relatedTarget as Element | null;\n if (this.element().contains(focusTarget)) return;\n\n this.isFocused.set(false);\n // Reset navigation state when focus leaving cell.\n this.navigationActivated.set(false);\n }\n\n /** Focuses the cell or the active widget. */\n focus(): void {\n if (this.singleWidgetMode()) {\n this.activeWidget()?.focus();\n } else {\n this.element().focus();\n }\n }\n\n /** Gets the tab index for the widget within the cell. */\n widgetTabIndex(): -1 | 0 {\n if (this.singleWidgetMode()) {\n return this._tabIndex();\n }\n return this.navigationActivated() ? 0 : -1;\n }\n\n /** Starts navigation between widgets. */\n startNavigation(): void {\n if (this.navigationActivated()) return;\n\n this.navigationActivated.set(true);\n this.navigationBehavior.first();\n }\n\n /** Stops navigation between widgets and restores focus to the cell. */\n stopNavigation(): void {\n if (!this.navigationActivated()) return;\n\n this.navigationActivated.set(false);\n this.element().focus();\n }\n\n /** Executes a navigation operation and focuses the new active widget. */\n private _advance(op: () => boolean): void {\n const success = op();\n if (success) {\n this.activeWidget()?.focus();\n }\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, Signal, WritableSignal} from '@angular/core';\nimport {KeyboardEventManager, Modifier} from '../behaviors/event-manager';\nimport {ListNavigationItem} from '../behaviors/list-navigation/list-navigation';\nimport {SignalLike} from '../behaviors/signal-like/signal-like';\nimport type {GridCellPattern} from './cell';\n\n/** The inputs for the `GridCellWidgetPattern`. */\nexport interface GridCellWidgetInputs extends Omit<ListNavigationItem, 'index'> {\n /** The `GridCellPattern` that this widget belongs to. */\n cell: SignalLike<GridCellPattern>;\n\n /** The html element that should receive focus. */\n element: SignalLike<HTMLElement>;\n\n /** The type of widget, which determines how it is activated. */\n widgetType: SignalLike<'simple' | 'complex' | 'editable'>;\n\n /** The element that will receive focus when the widget is activated. */\n focusTarget: SignalLike<HTMLElement | undefined>;\n}\n\n/** The UI pattern for a widget inside a grid cell. */\nexport class GridCellWidgetPattern implements ListNavigationItem {\n /** A unique identifier for the widget. */\n readonly id: SignalLike<string> = () => this.inputs.id();\n\n /** The html element that should receive focus. */\n readonly element: SignalLike<HTMLElement> = () => this.inputs.element();\n\n /** The element that should receive focus. */\n readonly widgetHost: Signal<HTMLElement> = computed(\n () => this.inputs.focusTarget() ?? this.element(),\n );\n\n /** The index of the widget within the cell. */\n readonly index: Signal<number> = computed(() =>\n this.inputs.cell().inputs.widgets().indexOf(this),\n );\n\n /** Whether the widget is disabled. */\n readonly disabled: Signal<boolean> = computed(\n () => this.inputs.disabled() || this.inputs.cell().disabled(),\n );\n\n /** The tab index for the widget. */\n readonly tabIndex: Signal<-1 | 0> = computed(() => this.inputs.cell().widgetTabIndex());\n\n /** Whether the widget is the active item in the widget list. */\n readonly active: Signal<boolean> = computed(() => this.inputs.cell().activeWidget() === this);\n\n /** Whether the widget is currently activated. */\n readonly isActivated: WritableSignal<boolean> = signal(false);\n\n /** The last event that caused the widget to be activated. */\n readonly lastActivateEvent: WritableSignal<KeyboardEvent | FocusEvent | undefined> =\n signal(undefined);\n\n /** The last event that caused the widget to be deactivated. */\n readonly lastDeactivateEvent: WritableSignal<KeyboardEvent | FocusEvent | undefined> =\n signal(undefined);\n\n /** The keyboard event manager for the widget. */\n readonly keydown = computed(() => {\n const manager = new KeyboardEventManager();\n\n // Simple widget does not need to pause default grid behaviors.\n if (this.inputs.widgetType() === 'simple') {\n return manager;\n }\n\n // If a widget is activated, only listen to events that exits activate state.\n if (this.isActivated()) {\n manager.on('Escape', e => {\n this.deactivate(e);\n this.focus();\n });\n\n if (this.inputs.widgetType() === 'editable') {\n manager.on('Enter', e => {\n this.deactivate(e);\n this.focus();\n });\n }\n\n return manager;\n }\n\n // Enter key is used to activate widget for both complex and editable type.\n manager.on('Enter', e => this.activate(e));\n\n if (this.inputs.widgetType() === 'editable') {\n manager.on([Modifier.Shift, Modifier.None], /^[a-zA-Z0-9]$/, e => this.activate(e), {\n preventDefault: false,\n });\n }\n\n return manager;\n });\n\n constructor(readonly inputs: GridCellWidgetInputs) {}\n\n /** Handles keydown events for the widget. */\n onKeydown(event: KeyboardEvent): void {\n if (this.disabled()) return;\n\n this.keydown().handle(event);\n }\n\n /** Handles focusin events for the widget. */\n onFocusIn(event: FocusEvent): void {\n // Simple widget does not have activate state.\n if (this.inputs.widgetType() === 'simple') return;\n\n // Set activate state if the focus is inside of widget.\n const focusTarget = event.target as Element;\n if (this.widgetHost().contains(focusTarget) && this.widgetHost() !== focusTarget) {\n this.activate(event);\n }\n }\n\n /** Handles focusout events for the widget. */\n onFocusOut(event: FocusEvent): void {\n const focusTarget = event.relatedTarget as Element;\n if (this.widgetHost().contains(focusTarget)) return;\n\n // Reset states when focus leaving widget.\n this.deactivate(event);\n }\n\n /** Focuses the widget's host element. */\n focus(): void {\n this.widgetHost().focus();\n }\n\n /** Activates the widget. */\n activate(event?: KeyboardEvent | FocusEvent): void {\n if (this.isActivated()) return;\n if (this.inputs.widgetType() === 'simple') return;\n\n this.isActivated.set(true);\n this.lastActivateEvent.set(event);\n }\n\n /** Deactivates the widget and restores focus to the widget's host element. */\n deactivate(event?: KeyboardEvent | FocusEvent): void {\n if (!this.isActivated()) return;\n\n this.isActivated.set(false);\n this.lastDeactivateEvent.set(event);\n }\n}\n"],"names":["Modifier","EventManager","configs","handle","event","config","matcher","handler","preventDefault","stopPropagation","getModifiers","ctrlKey","Ctrl","shiftKey","Shift","altKey","Alt","metaKey","Meta","hasModifiers","modifiers","eventModifiers","modifiersList","Array","isArray","includes","Any","some","KeyboardEventManager","options","on","args","key","_normalizeInputs","push","_isMatch","withModifiers","None","RegExp","test","keyStr","toLowerCase","MouseButton","PointerEventManager","button","length","Main","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","delta","itemCount","startIndex","step","wrap","GridData","cells","maxRowCount","Math","max","_rowCountByCol","values","maxColCount","_colCountsByRow","_coordsMap","coordsMap","Map","visitedCoords","Set","rowIndex","colIndex","row","cell","has","rowspan","rowSpan","colspan","colSpan","spanCoords","rowOffset","colOffset","col","add","coords","_cellMap","cellMap","entries","colCountByRow","_","colCount","get","newColCount","rowCountByCol","rowCount","newRowCount","hasCell","getCell","rowCol","getCoords","getAllCoords","getRowCount","getColCount","GridFocus","activeCell","activeCoords","stateEmpty","stateStale","activeCellCoords","grid","activeCoordsCell","activeCellNotValid","activeCellMismatch","activeDescendant","gridDisabled","currentActiveCell","gridCells","gridTabIndex","getCellTabIndex","focusCell","focusCoordinates","direction","Up","Down","Left","Right","GridNavigation","_maxSteps","gotoCell","gridFocus","gotoCoords","peek","fromCoords","allowDisabled","rowWrap","colWrap","_peekDirectional","advance","nextCoords","fromCell","rowDelta","colDelta","isWrapping","generalDelta","rowStep","colStep","bothWrapping","nextCell","GridSelection","_undoList","undo","oldState","selected","select","toCoords","_updateState","deselect","toggle","selectAll","deselectAll","isSelectable","selectable","_validCells","startRow","min","startCol","endRow","endCol","visited","stateFn","undoList","Grid","data","focusBehavior","navigationBehavior","selectionBehavior","selectionAnchor","linkedSignal","selectionAnchorCell","selectionStabled","allSelected","flat","filter","c","index","cellTabIndex","up","_navigateWithSelection","anchor","_updateSelectionAnchor","down","left","right","firstInRow","lastInRow","selectRow","selectCol","toggleOne","setDefaultState","focusableSelectedCell","firstFocusableCoords","resetState","peekFn","success","_updateRangeSelection","_getSelectionCoords","startCoords","endCoords","startCell","endCell","allCoords","allRows","map","allCols","op","selectOne","GridPattern","gridBehavior","tabIndex","anchorCell","enableSelection","multi","pauseNavigation","reduce","res","isActivated","isFocused","hasBeenFocused","dragging","prevColKey","textDirection","nextColKey","keydown","manager","selectionMode","enableRangeSelection","pointerdown","e","target","pointerup","_maybeDeletion","_deletion","_stateStale","rows","onKeydown","onPointerdown","onPointermove","onPointerup","onFocusIn","onFocusOut","blurTarget","focusTarget","relatedTarget","contains","setDefaultStateEffect","resetStateEffect","hasReset","resetFocusEffect","untracked","isRoving","restoreFocusEffect","deletion","focusEffect","gridFocused","cellFocused","GridRowPattern","GridCellPattern","active","ariaSelected","ariaRowIndex","ariaColIndex","_tabIndex","singleWidgetMode","navigationActivated","widgets","multiWidgetMode","navigationDisabled","activeWidget","widgetActivated","w","prevKey","orientation","nextKey","startNavigation","stopNavigation","listNavigationInputs","widget","getWidget","widgetTabIndex","GridCellWidgetPattern","widgetHost","lastActivateEvent","lastDeactivateEvent","widgetType","deactivate","activate"],"mappings":";;IA2CYA;AAAZ,CAAA,UAAYA,QAAQ,EAAA;EAClBA,QAAA,CAAAA,QAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ;EACRA,QAAA,CAAAA,QAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAU;EACVA,QAAA,CAAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAY;EACZA,QAAA,CAAAA,QAAA,CAAA,KAAA,CAAA,GAAA,CAAA,CAAA,GAAA,KAAW;EACXA,QAAA,CAAAA,QAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAa;AACbA,EAAAA,QAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACb,CAAC,EAPWA,QAAQ,KAARA,QAAQ,GAOnB,EAAA,CAAA,CAAA;MAUqBC,YAAY,CAAA;AACtBC,EAAAA,OAAO,GAA4B,EAAE;EAI/CC,MAAMA,CAACC,KAAQ,EAAA;AACb,IAAA,KAAK,MAAMC,MAAM,IAAI,IAAI,CAACH,OAAO,EAAE;AACjC,MAAA,IAAIG,MAAM,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;AACzBC,QAAAA,MAAM,CAACE,OAAO,CAACH,KAAK,CAAC;QAErB,IAAIC,MAAM,CAACG,cAAc,EAAE;UACzBJ,KAAK,CAACI,cAAc,EAAE;AACxB;QAEA,IAAIH,MAAM,CAACI,eAAe,EAAE;UAC1BL,KAAK,CAACK,eAAe,EAAE;AACzB;AACF;AACF;AACF;AAID;AAGK,SAAUC,YAAYA,CAACN,KAAyB,EAAA;A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AAE;IACxB,IAAI,IAAI,CAACxN,MAAM,CAAC4R,UAAU,EAAE,KAAK,QAAQ,EAAE;AAE3C,IAAA,IAAI,CAACpE,WAAW,CAAChM,GAAG,CAAC,IAAI,CAAC;AAC1B,IAAA,IAAI,CAACkQ,iBAAiB,CAAClQ,GAAG,CAACpE,KAAK,CAAC;AACnC;EAGAyU,UAAUA,CAACzU,KAAkC,EAAA;AAC3C,IAAA,IAAI,CAAC,IAAI,CAACoQ,WAAW,EAAE,EAAE;AAEzB,IAAA,IAAI,CAACA,WAAW,CAAChM,GAAG,CAAC,KAAK,CAAC;AAC3B,IAAA,IAAI,CAACmQ,mBAAmB,CAACnQ,GAAG,CAACpE,KAAK,CAAC;AACrC;AACD;;;;"}
1
+ {"version":3,"file":"_widget-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/behaviors/grid/grid-data.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/behaviors/grid/grid-focus.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/behaviors/grid/grid-navigation.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/behaviors/grid/grid-selection.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/behaviors/grid/grid.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/grid/grid.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/grid/row.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/grid/cell.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/aria/private/grid/widget.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} from '@angular/core';\nimport {SignalLike} from '../signal-like/signal-like';\n\n/** Represents coordinates in a grid. */\nexport interface RowCol {\n /** The row index. */\n row: number;\n\n /** The column index. */\n col: number;\n}\n\n/** A string representation of grid coordinates. */\ntype CoordString = `${RowCol['row']}:${RowCol['col']}`;\n\n/** The base interface for a cell in a grid. */\nexport interface BaseGridCell {\n /** The number of rows the cell should span. */\n rowSpan: SignalLike<number>;\n\n /** The number of columns the cell should span. */\n colSpan: SignalLike<number>;\n}\n\n/** Represents the required inputs for GridData. */\nexport interface GridDataInputs<T extends BaseGridCell> {\n /** The two-dimensional array of cells that represents the grid. */\n cells: SignalLike<T[][]>;\n}\n\n/** Controls internal coordinates for a grid of items. */\nexport class GridData<T extends BaseGridCell> {\n /** The two-dimensional array of cells that represents the grid. */\n readonly cells: SignalLike<T[][]>;\n\n /** The maximum number of rows in the grid, accounting for row spans. */\n readonly maxRowCount = computed<number>(() => Math.max(...this._rowCountByCol().values(), 0));\n\n /** The maximum number of columns in the grid, accounting for column spans. */\n readonly maxColCount = computed<number>(() => Math.max(...this._colCountsByRow().values(), 0));\n\n /** A map from a cell to its primary and spanned coordinates. */\n private readonly _coordsMap = computed<Map<T, {coords: RowCol; spanCoords: RowCol[]}>>(() => {\n const coordsMap = new Map();\n const visitedCoords = new Set();\n\n for (let rowIndex = 0; rowIndex < this.cells().length; rowIndex++) {\n let colIndex = 0;\n const row = this.cells()[rowIndex];\n\n for (const cell of row) {\n // Skip past cells that are already taken.\n while (visitedCoords.has(`${rowIndex}:${colIndex}`)) {\n colIndex++;\n }\n\n const rowspan = cell.rowSpan();\n const colspan = cell.colSpan();\n const spanCoords: RowCol[] = [];\n\n for (let rowOffset = 0; rowOffset < rowspan; rowOffset++) {\n const row = rowIndex + rowOffset;\n for (let colOffset = 0; colOffset < colspan; colOffset++) {\n const col = colIndex + colOffset;\n visitedCoords.add(`${row}:${col}`);\n spanCoords.push({row, col});\n }\n }\n coordsMap.set(cell, {coords: spanCoords[0], spanCoords});\n\n colIndex += colspan;\n }\n }\n\n return coordsMap;\n });\n\n /** A map from a coordinate string to the cell at that coordinate. */\n private readonly _cellMap = computed<Map<CoordString, T>>(() => {\n const cellMap = new Map();\n for (const [cell, {spanCoords}] of this._coordsMap().entries()) {\n for (const {row, col} of spanCoords) {\n cellMap.set(`${row}:${col}`, cell);\n }\n }\n return cellMap;\n });\n\n /** A map from a row index to the number of columns in that row. */\n private readonly _colCountsByRow = computed<Map<number, number>>(() => {\n const colCountByRow = new Map();\n for (const [_, {spanCoords}] of this._coordsMap().entries()) {\n for (const {row, col} of spanCoords) {\n const colCount = colCountByRow.get(row);\n const newColCount = col + 1;\n if (colCount === undefined || colCount < newColCount) {\n colCountByRow.set(row, newColCount);\n }\n }\n }\n return colCountByRow;\n });\n\n /** A map from a column index to the number of rows in that column. */\n private readonly _rowCountByCol = computed<Map<number, number>>(() => {\n const rowCountByCol = new Map();\n for (const [_, {spanCoords}] of this._coordsMap().entries()) {\n for (const {row, col} of spanCoords) {\n const rowCount = rowCountByCol.get(col);\n const newRowCount = row + 1;\n if (rowCount === undefined || rowCount < newRowCount) {\n rowCountByCol.set(col, newRowCount);\n }\n }\n }\n return rowCountByCol;\n });\n\n constructor(readonly inputs: GridDataInputs<T>) {\n this.cells = this.inputs.cells;\n }\n\n /** Whether the cell exists. */\n hasCell(cell: T): boolean {\n return this._coordsMap().has(cell);\n }\n\n /** Gets the cell at the given coordinates. */\n getCell(rowCol: RowCol): T | undefined {\n return this._cellMap().get(`${rowCol.row}:${rowCol.col}`);\n }\n\n /** Gets the primary coordinates of the given cell. */\n getCoords(cell: T): RowCol | undefined {\n return this._coordsMap().get(cell)?.coords;\n }\n\n /** Gets all coordinates that the given cell spans. */\n getAllCoords(cell: T): RowCol[] | undefined {\n return this._coordsMap().get(cell)?.spanCoords;\n }\n\n /** Gets the number of rows in the given column. */\n getRowCount(col: number): number | undefined {\n return this._rowCountByCol().get(col);\n }\n\n /** Gets the number of columns in the given row. */\n getColCount(row: number): number | undefined {\n return this._colCountsByRow().get(row);\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, WritableSignal} from '@angular/core';\nimport {SignalLike} from '../signal-like/signal-like';\nimport type {GridData, BaseGridCell, RowCol} from './grid-data';\n\n/** Represents an cell in a grid, such as a grid cell, that may receive focus. */\nexport interface GridFocusCell extends BaseGridCell {\n /** A unique identifier for the cell. */\n id: SignalLike<string>;\n\n /** The html element that should receive focus. */\n element: SignalLike<HTMLElement>;\n\n /** Whether a cell is disabled. */\n disabled: SignalLike<boolean>;\n}\n\n/** Represents the required inputs for a grid that contains focusable cells. */\nexport interface GridFocusInputs {\n /** The focus strategy used by the grid. */\n focusMode: SignalLike<'roving' | 'activedescendant'>;\n\n /** Whether the grid is disabled. */\n disabled: SignalLike<boolean>;\n\n /** Whether disabled cells in the grid should be focusable. */\n softDisabled: SignalLike<boolean>;\n}\n\n/** Dependencies for the `GridFocus` class. */\ninterface GridFocusDeps<T extends GridFocusCell> {\n /** The `GridData` instance that this focus manager operates on. */\n grid: GridData<T>;\n}\n\n/** Controls focus for a 2D grid of cells. */\nexport class GridFocus<T extends GridFocusCell> {\n /** The current active cell. */\n readonly activeCell: WritableSignal<T | undefined> = signal(undefined);\n\n /** The current active cell coordinates. */\n readonly activeCoords = signal<RowCol>({row: -1, col: -1});\n\n /** Whether the grid active state is empty (no active cell or coordinates). */\n readonly stateEmpty = computed(\n () =>\n this.activeCell() === undefined ||\n (this.activeCoords().row === -1 && this.activeCoords().col === -1),\n );\n\n /**\n * Whether the grid focus state is stale.\n *\n * A stale state means the active cell or coordinates are no longer valid based on the\n * current grid data, for example if the underlying cells have changed.\n * A stale state should be re-initialized.\n */\n readonly stateStale = computed(() => {\n if (this.stateEmpty()) {\n return true;\n }\n\n const activeCell = this.activeCell();\n const activeCellCoords = this.inputs.grid.getCoords(activeCell!);\n const activeCoords = this.activeCoords();\n const activeCoordsCell = this.inputs.grid.getCell(activeCoords);\n\n const activeCellNotValid = activeCellCoords === undefined;\n const activeCellMismatch = activeCell !== activeCoordsCell;\n return activeCellNotValid || activeCellMismatch;\n });\n\n /** The id of the current active cell, for ARIA activedescendant. */\n readonly activeDescendant = computed<string | undefined>(() => {\n if (this.gridDisabled() || this.inputs.focusMode() === 'roving') {\n return undefined;\n }\n const currentActiveCell = this.activeCell();\n return currentActiveCell ? currentActiveCell.id() : undefined;\n });\n\n /** Whether the grid is in a disabled state. */\n readonly gridDisabled = computed<boolean>(() => {\n if (this.inputs.disabled()) {\n return true;\n }\n const gridCells = this.inputs.grid.cells();\n return gridCells.length === 0 || gridCells.every(row => row.every(cell => cell.disabled()));\n });\n\n /** The tab index for the grid container. */\n readonly gridTabIndex = computed<-1 | 0>(() => {\n if (this.gridDisabled()) {\n return 0;\n }\n return this.inputs.focusMode() === 'activedescendant' ? 0 : -1;\n });\n\n constructor(readonly inputs: GridFocusInputs & GridFocusDeps<T>) {}\n\n /** Returns the tab index for the given grid cell cell. */\n getCellTabIndex(cell: T): -1 | 0 {\n if (this.gridDisabled()) {\n return -1;\n }\n if (this.inputs.focusMode() === 'activedescendant') {\n return -1;\n }\n return this.activeCell() === cell ? 0 : -1;\n }\n\n /** Returns true if the given cell can be navigated to. */\n isFocusable(cell: T): boolean {\n return this.inputs.grid.hasCell(cell) && (!cell.disabled() || this.inputs.softDisabled());\n }\n\n /** Focuses the given cell. */\n focusCell(cell: T): boolean {\n if (this.gridDisabled()) {\n return false;\n }\n\n if (!this.isFocusable(cell)) {\n return false;\n }\n\n if (this.inputs.grid.getCoords(cell) === undefined) {\n return false;\n }\n\n this.activeCoords.set(this.inputs.grid.getCoords(cell)!);\n this.activeCell.set(cell);\n\n return true;\n }\n\n /** Moves focus to the cell at the given coordinates if it's part of a focusable cell. */\n focusCoordinates(coords: RowCol): boolean {\n if (this.gridDisabled()) {\n return false;\n }\n\n const cell = this.inputs.grid.getCell(coords);\n\n if (!cell || !this.isFocusable(cell)) {\n return false;\n }\n\n if (this.inputs.grid.getCell(coords) === undefined) {\n return false;\n }\n\n this.activeCoords.set(coords);\n this.activeCell.set(this.inputs.grid.getCell(coords));\n\n return true;\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} from '@angular/core';\nimport {SignalLike} from '../signal-like/signal-like';\nimport {GridFocus, GridFocusCell, GridFocusInputs} from './grid-focus';\nimport {GridData, RowCol} from './grid-data';\n\n/** A utility type that ensures an object has exactly one key from a given set. */\ntype ExactlyOneKey<T, K extends keyof T = keyof T> = {\n [P in K]: Record<P, T[P]> & Partial<Record<Exclude<K, P>, never>>;\n}[K];\n\n/** Represents a directional change in the grid, either by row or by column. */\ntype Delta = ExactlyOneKey<{row: -1 | 1; col: -1 | 1}>;\n\n/** Constants for the four cardinal directions. */\nexport const direction: Record<'Up' | 'Down' | 'Left' | 'Right', Delta> = {\n Up: {row: -1},\n Down: {row: 1},\n Left: {col: -1},\n Right: {col: 1},\n} as const;\n\n/** The wrapping behavior for keyboard navigation. */\nexport type WrapStrategy = 'continuous' | 'loop' | 'nowrap';\n\n/** Represents an item in a collection, such as a listbox option, than can be navigated to. */\nexport interface GridNavigationCell extends GridFocusCell {}\n\n/** Represents the required inputs for a collection that has navigable items. */\nexport interface GridNavigationInputs extends GridFocusInputs {\n /** The wrapping behavior for keyboard navigation along the row axis. */\n rowWrap: SignalLike<WrapStrategy>;\n\n /** The wrapping behavior for keyboard navigation along the column axis. */\n colWrap: SignalLike<WrapStrategy>;\n}\n\n/** Dependencies for the `GridNavigation` class. */\ninterface GridNavigationDeps<T extends GridNavigationCell> {\n /** The `GridData` instance that this navigation manager operates on. */\n grid: GridData<T>;\n\n /** The `GridFocus` instance that this navigation manager uses to manage focus. */\n gridFocus: GridFocus<T>;\n}\n\n/** Controls navigation for a grid of items. */\nexport class GridNavigation<T extends GridNavigationCell> {\n /** The maximum number of steps to take when searching for the next cell. */\n private _maxSteps = computed<number>(\n () => this.inputs.grid.maxRowCount() * this.inputs.grid.maxColCount(),\n );\n\n constructor(readonly inputs: GridNavigationInputs & GridNavigationDeps<T>) {}\n\n /** Navigates to the given item. */\n gotoCell(cell: T): boolean {\n return this.inputs.gridFocus.focusCell(cell);\n }\n\n /** Navigates to the given coordinates. */\n gotoCoords(coords: RowCol): boolean {\n return this.inputs.gridFocus.focusCoordinates(coords);\n }\n\n /**\n * Gets the coordinates of the next focusable cell in a given direction, without changing focus.\n */\n peek(\n direction: Delta,\n fromCoords: RowCol,\n wrap?: WrapStrategy,\n allowDisabled?: boolean,\n ): RowCol | undefined {\n wrap = wrap ?? (direction.row !== undefined ? this.inputs.rowWrap() : this.inputs.colWrap());\n return this._peekDirectional(direction, fromCoords, wrap, allowDisabled);\n }\n\n /**\n * Navigates to the next focusable cell in a given direction.\n */\n advance(direction: Delta): boolean {\n const nextCoords = this.peek(direction, this.inputs.gridFocus.activeCoords());\n return !!nextCoords && this.gotoCoords(nextCoords);\n }\n\n /**\n * Gets the coordinates of the first focusable cell.\n * If a row is not provided, searches the entire grid.\n */\n peekFirst(row?: number, allowDisabled?: boolean): RowCol | undefined {\n const fromCoords = {\n row: row ?? 0,\n col: -1,\n };\n return row === undefined\n ? this._peekDirectional(direction.Right, fromCoords, 'continuous', allowDisabled)\n : this._peekDirectional(direction.Right, fromCoords, 'nowrap', allowDisabled);\n }\n\n /**\n * Navigates to the first focusable cell.\n * If a row is not provided, searches the entire grid.\n */\n first(row?: number): boolean {\n const nextCoords = this.peekFirst(row);\n return !!nextCoords && this.gotoCoords(nextCoords);\n }\n\n /**\n * Gets the coordinates of the last focusable cell.\n * If a row is not provided, searches the entire grid.\n */\n peekLast(row?: number, allowDisabled?: boolean): RowCol | undefined {\n const fromCoords = {\n row: row ?? this.inputs.grid.maxRowCount() - 1,\n col: this.inputs.grid.maxColCount(),\n };\n return row === undefined\n ? this._peekDirectional(direction.Left, fromCoords, 'continuous', allowDisabled)\n : this._peekDirectional(direction.Left, fromCoords, 'nowrap', allowDisabled);\n }\n\n /**\n * Navigates to the last focusable cell.\n * If a row is not provided, searches the entire grid.\n */\n last(row?: number): boolean {\n const nextCoords = this.peekLast(row);\n return !!nextCoords && this.gotoCoords(nextCoords);\n }\n\n /**\n * Finds the next focusable cell in a given direction based on the wrapping behavior.\n */\n private _peekDirectional(\n delta: Delta,\n fromCoords: RowCol,\n wrap: 'continuous' | 'loop' | 'nowrap',\n allowDisabled: boolean = false,\n ): RowCol | undefined {\n if (this.inputs.gridFocus.gridDisabled()) return undefined;\n\n const fromCell = this.inputs.grid.getCell(fromCoords);\n const maxRowCount = this.inputs.grid.maxRowCount();\n const maxColCount = this.inputs.grid.maxColCount();\n const rowDelta = delta.row ?? 0;\n const colDelta = delta.col ?? 0;\n let nextCoords = {...fromCoords};\n\n for (let step = 0; step < this._maxSteps(); step++) {\n const isWrapping =\n nextCoords.col + colDelta < 0 ||\n nextCoords.col + colDelta >= maxColCount ||\n nextCoords.row + rowDelta < 0 ||\n nextCoords.row + rowDelta >= maxRowCount;\n\n if (wrap === 'nowrap' && isWrapping) return undefined;\n\n if (wrap === 'continuous') {\n const generalDelta = delta.row ?? delta.col;\n const rowStep = isWrapping ? generalDelta : rowDelta;\n const colStep = isWrapping ? generalDelta : colDelta;\n\n // Reaching start or end.\n const bothWrapping =\n (nextCoords.row + rowStep >= maxRowCount && nextCoords.col + colStep >= maxColCount) ||\n (nextCoords.row + rowStep < 0 && nextCoords.col + colStep < 0);\n if (bothWrapping) return undefined;\n\n nextCoords = {\n row: (nextCoords.row + rowStep + maxRowCount) % maxRowCount,\n col: (nextCoords.col + colStep + maxColCount) % maxColCount,\n };\n }\n\n if (wrap === 'loop') {\n nextCoords = {\n row: (nextCoords.row + rowDelta + maxRowCount) % maxRowCount,\n col: (nextCoords.col + colDelta + maxColCount) % maxColCount,\n };\n }\n\n if (wrap === 'nowrap') {\n nextCoords = {\n row: nextCoords.row + rowDelta,\n col: nextCoords.col + colDelta,\n };\n }\n\n // Back to original coordinates.\n if (nextCoords.row === fromCoords.row && nextCoords.col === fromCoords.col) {\n return undefined;\n }\n\n const nextCell = this.inputs.grid.getCell(nextCoords);\n if (\n nextCell !== undefined &&\n nextCell !== fromCell &&\n (allowDisabled || this.inputs.gridFocus.isFocusable(nextCell))\n ) {\n return nextCoords;\n }\n }\n\n return undefined;\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, WritableSignalLike} from '../signal-like/signal-like';\nimport {GridFocus, GridFocusCell, GridFocusInputs} from './grid-focus';\nimport {GridData, RowCol} from './grid-data';\nimport {signal} from '@angular/core';\n\n/** Represents a cell in a grid that can be selected. */\nexport interface GridSelectionCell extends GridFocusCell {\n /** Whether the cell is selected. */\n selected: WritableSignalLike<boolean>;\n\n /** Whether the cell is selectable. */\n selectable: SignalLike<boolean>;\n}\n\n/** Represents the required inputs for a grid that has selectable cells. */\nexport interface GridSelectionInputs extends GridFocusInputs {}\n\n/** Dependencies for the `GridSelection` class. */\ninterface GridSelectionDeps<T extends GridSelectionCell> {\n /** The `GridData` instance that this selection manager operates on. */\n grid: GridData<T>;\n\n /** The `GridFocus` instance that this selection manager uses to manage focus. */\n gridFocus: GridFocus<T>;\n}\n\n/** Controls selection for a grid of items. */\nexport class GridSelection<T extends GridSelectionCell> {\n /** The list of cells that were changed in the last selection operation. */\n private readonly _undoList: WritableSignalLike<[T, boolean][]> = signal([]);\n\n constructor(readonly inputs: GridSelectionInputs & GridSelectionDeps<T>) {}\n\n /** Reverts the last selection change. */\n undo(): void {\n for (const [cell, oldState] of this._undoList()) {\n cell.selected.set(oldState);\n }\n this._undoList.set([]);\n }\n\n /** Selects one or more cells in a given range. */\n select(fromCoords: RowCol, toCoords?: RowCol): void {\n this._updateState(fromCoords, toCoords ?? fromCoords, () => true);\n }\n\n /** Deselects one or more cells in a given range. */\n deselect(fromCoords: RowCol, toCoords?: RowCol): void {\n this._updateState(fromCoords, toCoords ?? fromCoords, () => false);\n }\n\n /** Toggles the selection state of one or more cells in a given range. */\n toggle(fromCoords: RowCol, toCoords?: RowCol): void {\n this._updateState(fromCoords, toCoords ?? fromCoords, oldState => !oldState);\n }\n\n /** Selects all valid cells in the grid. */\n selectAll(): void {\n this._updateState(\n {row: 0, col: 0},\n {row: this.inputs.grid.maxRowCount(), col: this.inputs.grid.maxColCount()},\n () => true,\n );\n }\n\n /** Deselects all valid cells in the grid. */\n deselectAll(): void {\n this._updateState(\n {row: 0, col: 0},\n {row: this.inputs.grid.maxRowCount(), col: this.inputs.grid.maxColCount()},\n () => false,\n );\n }\n\n /** Whether a cell is selctable. */\n isSelectable(cell: T) {\n return cell.selectable() && !cell.disabled();\n }\n\n /** A generator that yields all cells within a given range. */\n *_validCells(fromCoords: RowCol, toCoords: RowCol): Generator<T> {\n const startRow = Math.min(fromCoords.row, toCoords.row);\n const startCol = Math.min(fromCoords.col, toCoords.col);\n const endRow = Math.max(fromCoords.row, toCoords.row);\n const endCol = Math.max(fromCoords.col, toCoords.col);\n const visited = new Set<T>();\n for (let row = startRow; row < endRow + 1; row++) {\n for (let col = startCol; col < endCol + 1; col++) {\n const cell = this.inputs.grid.getCell({row, col});\n if (cell === undefined) continue;\n if (!this.isSelectable(cell)) continue;\n if (visited.has(cell)) continue;\n visited.add(cell);\n yield cell;\n }\n }\n }\n\n /**\n * Updates the selection state of cells in a given range and preserves previous changes\n * to a undo list.\n */\n private _updateState(\n fromCoords: RowCol,\n toCoords: RowCol,\n stateFn: (oldState: boolean) => boolean,\n ): void {\n const undoList: [T, boolean][] = [];\n for (const cell of this._validCells(fromCoords, toCoords)) {\n const oldState = cell.selected();\n undoList.push([cell, oldState]);\n cell.selected.set(stateFn(oldState));\n }\n this._undoList.set(undoList);\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, linkedSignal, signal} from '@angular/core';\nimport {GridData, BaseGridCell, GridDataInputs, RowCol} from './grid-data';\nimport {GridFocus, GridFocusCell, GridFocusInputs} from './grid-focus';\nimport {\n direction,\n GridNavigation,\n GridNavigationCell,\n GridNavigationInputs,\n} from './grid-navigation';\nimport {GridSelectionCell, GridSelectionInputs, GridSelection} from './grid-selection';\nimport {SignalLike} from '../signal-like/signal-like';\n\n/** The selection operations that can be performed after a navigation operation. */\nexport interface NavOptions {\n /** Toggles the selection state of the active cell. */\n toggle?: boolean;\n\n /**\n * Toggles the selection state of the active cell, and deselects all other cells if the\n * active cell is selected. If the active cell is the only selected cell, it will be deselected.\n */\n toggleOne?: boolean;\n\n /** Selects the active cell, preserving the selection state of other cells. */\n select?: boolean;\n\n /** Deselects all other cells and selects the active cell. */\n selectOne?: boolean;\n\n /**\n * Moves the selection anchor to the active cell and updates the selection to include all\n * cells between the anchor and the active cell.\n */\n anchor?: boolean;\n}\n\n/** A type that represents a cell in a grid, combining all cell-related interfaces. */\nexport type GridCell = BaseGridCell & GridFocusCell & GridNavigationCell & GridSelectionCell;\n\n/** Represents the required inputs for a grid. */\nexport type GridInputs<T extends GridCell> = GridDataInputs<T> &\n GridFocusInputs &\n GridNavigationInputs &\n GridSelectionInputs;\n\n/** The main class that orchestrates the grid behaviors. */\nexport class Grid<T extends GridCell> {\n /** The underlying data structure for the grid. */\n readonly data: GridData<T>;\n\n /** Controls focus for the grid. */\n readonly focusBehavior: GridFocus<T>;\n\n /** Controls navigation for the grid. */\n readonly navigationBehavior: GridNavigation<T>;\n\n /** Controls selection for the grid. */\n readonly selectionBehavior: GridSelection<T>;\n\n /** The anchor point for range selection, linked to the active coordinates. */\n readonly selectionAnchor = linkedSignal<RowCol>(() => this.focusBehavior.activeCoords());\n\n /** The cell at the selection anchor. */\n readonly selectionAnchorCell = computed(() => this.data.getCell(this.selectionAnchor()));\n\n /** Whether a range selection has settled. */\n readonly selectionStabled = signal(true);\n\n /** Whether all selectable cells are selected. */\n readonly allSelected: SignalLike<boolean> = computed(() =>\n this.data\n .cells()\n .flat()\n .filter(c => this.selectionBehavior.isSelectable(c))\n .every(c => c.selected()),\n );\n\n /** The tab index for the grid container. */\n readonly gridTabIndex: SignalLike<-1 | 0> = () => this.focusBehavior.gridTabIndex();\n\n /** Whether the grid is in a disabled state. */\n readonly gridDisabled: SignalLike<boolean> = () => this.focusBehavior.gridDisabled();\n\n /** The ID of the active descendant for ARIA `activedescendant` focus management. */\n readonly activeDescendant: SignalLike<string | undefined> = () =>\n this.focusBehavior.activeDescendant();\n\n constructor(readonly inputs: GridInputs<T>) {\n this.data = new GridData(inputs);\n this.focusBehavior = new GridFocus({...inputs, grid: this.data});\n this.navigationBehavior = new GridNavigation({\n ...inputs,\n grid: this.data,\n gridFocus: this.focusBehavior,\n });\n this.selectionBehavior = new GridSelection({\n ...inputs,\n grid: this.data,\n gridFocus: this.focusBehavior,\n });\n }\n\n /** Gets the 1-based row index of a cell. */\n rowIndex(cell: T): number | undefined {\n const index = this.data.getCoords(cell)?.row;\n return index !== undefined ? index + 1 : undefined;\n }\n\n /** Gets the 1-based column index of a cell. */\n colIndex(cell: T): number | undefined {\n const index = this.data.getCoords(cell)?.col;\n return index !== undefined ? index + 1 : undefined;\n }\n\n /** Gets the tab index for a given cell. */\n cellTabIndex(cell: T): -1 | 0 {\n return this.focusBehavior.getCellTabIndex(cell);\n }\n\n /** Navigates to the cell above the currently active cell. */\n up(opts: NavOptions = {}): boolean {\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() =>\n this.navigationBehavior.peek(direction.Up, this.selectionAnchor(), 'nowrap', true),\n )\n : this.navigationBehavior.advance(direction.Up),\n opts,\n );\n }\n\n /** Navigates to the cell below the currently active cell. */\n down(opts: NavOptions = {}): boolean {\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() =>\n this.navigationBehavior.peek(direction.Down, this.selectionAnchor(), 'nowrap', true),\n )\n : this.navigationBehavior.advance(direction.Down),\n opts,\n );\n }\n\n /** Navigates to the cell to the left of the currently active cell. */\n left(opts: NavOptions = {}): boolean {\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() =>\n this.navigationBehavior.peek(direction.Left, this.selectionAnchor(), 'nowrap', true),\n )\n : this.navigationBehavior.advance(direction.Left),\n opts,\n );\n }\n\n /** Navigates to the cell to the right of the currently active cell. */\n right(opts: NavOptions = {}): boolean {\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() =>\n this.navigationBehavior.peek(direction.Right, this.selectionAnchor(), 'nowrap', true),\n )\n : this.navigationBehavior.advance(direction.Right),\n opts,\n );\n }\n\n /** Navigates to the first focusable cell in the grid. */\n first(opts: NavOptions = {}): boolean {\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() => this.navigationBehavior.peekFirst(undefined, true))\n : this.navigationBehavior.first(),\n opts,\n );\n }\n\n /** Navigates to the first focusable cell in the current row. */\n firstInRow(opts: NavOptions = {}): boolean {\n const row = this.focusBehavior.activeCoords().row;\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() => this.navigationBehavior.peekFirst(row, true))\n : this.navigationBehavior.first(row),\n opts,\n );\n }\n\n /** Navigates to the last focusable cell in the grid. */\n last(opts: NavOptions = {}): boolean {\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() => this.navigationBehavior.peekLast(undefined, true))\n : this.navigationBehavior.last(),\n opts,\n );\n }\n\n /** Navigates to the last focusable cell in the current row. */\n lastInRow(opts: NavOptions = {}): boolean {\n const row = this.focusBehavior.activeCoords().row;\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() => this.navigationBehavior.peekLast(row, true))\n : this.navigationBehavior.last(row),\n opts,\n );\n }\n\n /** Selects all cells in the current row. */\n selectRow(): void {\n const row = this.focusBehavior.activeCoords().row;\n this.selectionBehavior.deselectAll();\n this.selectionBehavior.select({row, col: 0}, {row, col: this.data.maxColCount()});\n }\n\n /** Selects all cells in the current column. */\n selectCol(): void {\n const col = this.focusBehavior.activeCoords().col;\n this.selectionBehavior.deselectAll();\n this.selectionBehavior.select({row: 0, col}, {row: this.data.maxRowCount(), col});\n }\n\n /** Selects the active cell. */\n select(): void {\n this.selectionBehavior.select(this.focusBehavior.activeCoords());\n }\n\n /** Deselects the active cell. */\n deselect(): void {\n this.selectionBehavior.deselect(this.focusBehavior.activeCoords());\n }\n\n /**\n * Toggles the selection state of the coordinates of the given cell\n * or the current active coordinates.\n */\n toggle(): void {\n this.selectionBehavior.toggle(this.focusBehavior.activeCoords());\n }\n\n /** Toggles the selection state of the active cell, and deselects all other cells. */\n toggleOne(): void {\n const selected = !!this.focusBehavior.activeCell()?.selected();\n if (selected) {\n this.deselect();\n return;\n }\n\n this.deselectAll();\n this.select();\n }\n\n /** Selects all selectable cells in the grid. */\n selectAll(): void {\n this.selectionBehavior.selectAll();\n }\n\n /** Deselects all cells in the grid. */\n deselectAll(): void {\n this.selectionBehavior.deselectAll();\n }\n\n /** Navigates to and focuses the given cell. */\n gotoCell(cell: T, opts: NavOptions = {}): boolean {\n return this._navigateWithSelection(\n () =>\n opts.anchor\n ? this._updateSelectionAnchor(() => this.data.getCoords(cell))\n : this.navigationBehavior.gotoCell(cell),\n opts,\n );\n }\n\n /** Sets the default active state of the grid. */\n setDefaultState(): boolean {\n // Try to find a selected cell that's focusable.\n const focusableSelectedCell: T | undefined = this.data\n .cells()\n .flat()\n .filter(c => this.focusBehavior.isFocusable(c))\n .find(c => c.selected());\n\n if (focusableSelectedCell !== undefined) {\n this.focusBehavior.focusCell(focusableSelectedCell);\n return true;\n }\n\n // Otherwise find the first focusable cell.\n const firstFocusableCoords = this.navigationBehavior.peekFirst();\n\n if (firstFocusableCoords !== undefined) {\n return this.focusBehavior.focusCoordinates(firstFocusableCoords);\n }\n\n return false;\n }\n\n /** Resets the active state of the grid if it is empty or stale. */\n resetState(): boolean {\n if (this.focusBehavior.stateEmpty()) {\n return this.setDefaultState();\n }\n\n if (this.focusBehavior.stateStale()) {\n // Try focus on the same active cell after if a reordering happened.\n if (this.focusBehavior.focusCell(this.focusBehavior.activeCell()!)) {\n return true;\n }\n\n // If the active cell is no longer exist, focus on the coordinates instead.\n if (this.focusBehavior.focusCoordinates(this.focusBehavior.activeCoords())) {\n return true;\n }\n\n // If the coordinates no longer valid, go back to the first available cell.\n if (this.focusBehavior.focusCoordinates(this.navigationBehavior.peekFirst()!)) {\n return true;\n }\n }\n\n return false;\n }\n\n /** Updates the selection anchor to the given coordinates. */\n private _updateSelectionAnchor(peekFn: () => RowCol | undefined): boolean {\n const coords = peekFn();\n const success = coords !== undefined;\n if (!success) return false;\n this.selectionAnchor.set(coords);\n return success;\n }\n\n /** Updates the selection to include all cells between the anchor and the active cell. */\n private _updateRangeSelection(): void {\n if (!this.selectionStabled()) {\n this.selectionBehavior.undo();\n }\n this.selectionBehavior.select(\n ...this._getSelectionCoords(this.focusBehavior.activeCoords(), this.selectionAnchor()),\n );\n }\n\n /** Gets the start and end coordinates for a selection range. */\n private _getSelectionCoords(startCoords: RowCol, endCoords: RowCol): [RowCol, RowCol] {\n const startCell = this.data.getCell(startCoords)!;\n const endCell = this.data.getCell(endCoords)!;\n const allCoords = [...this.data.getAllCoords(startCell)!, ...this.data.getAllCoords(endCell)!];\n const allRows = allCoords.map(c => c.row);\n const allCols = allCoords.map(c => c.col);\n const fromCoords = {\n row: Math.min(...allRows),\n col: Math.min(...allCols),\n };\n const toCoords = {\n row: Math.max(...allRows),\n col: Math.max(...allCols),\n };\n\n return [fromCoords, toCoords];\n }\n\n /** Executes a navigation operation and applies selection options. */\n private _navigateWithSelection(op: () => boolean, opts: NavOptions = {}): boolean {\n const success = op();\n if (!success) return false;\n\n if (opts.anchor) {\n this._updateRangeSelection();\n this.selectionStabled.set(false);\n return success;\n }\n\n // Selection becomes stable after the active cell/coords moved.\n this.selectionStabled.set(true);\n\n if (opts.select) {\n this.select();\n return success;\n }\n\n if (opts.selectOne) {\n this.deselectAll();\n this.select();\n return success;\n }\n\n if (opts.toggle) {\n this.toggle();\n return success;\n }\n\n if (opts.toggleOne) {\n const selected = !!this.focusBehavior.activeCell()?.selected();\n this.deselectAll();\n if (!selected) {\n this.select();\n }\n return success;\n }\n\n return success;\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, untracked} from '@angular/core';\nimport {SignalLike} from '../behaviors/signal-like/signal-like';\nimport {KeyboardEventManager, PointerEventManager, Modifier} from '../behaviors/event-manager';\nimport {NavOptions, Grid, GridInputs as GridBehaviorInputs} from '../behaviors/grid';\nimport type {GridRowPattern} from './row';\nimport type {GridCellPattern} from './cell';\n\n/** Represents the required inputs for the grid pattern. */\nexport interface GridInputs extends Omit<GridBehaviorInputs<GridCellPattern>, 'cells'> {\n /** The html element of the grid. */\n element: SignalLike<HTMLElement>;\n\n /** The rows that make up the grid. */\n rows: SignalLike<GridRowPattern[]>;\n\n /** The direction that text is read based on the users locale. */\n textDirection: SignalLike<'rtl' | 'ltr'>;\n\n /** Whether selection is enabled for the grid. */\n enableSelection: SignalLike<boolean>;\n\n /** Whether multiple cell in the grid can be selected. */\n multi: SignalLike<boolean>;\n\n /** The selection strategy used by the grid. */\n selectionMode: SignalLike<'follow' | 'explicit'>;\n\n /** Whether enable range selection. */\n enableRangeSelection: SignalLike<boolean>;\n\n /** A function that returns the grid cell associated with a given element. */\n getCell: (e: Element | null) => GridCellPattern | undefined;\n}\n\n/** The UI pattern for a grid, handling keyboard navigation, focus, and selection. */\nexport class GridPattern {\n /** The underlying grid behavior that this pattern is built on. */\n readonly gridBehavior: Grid<GridCellPattern>;\n\n /** The cells in the grid. */\n readonly cells = computed(() => this.gridBehavior.data.cells());\n\n /** The tab index for the grid. */\n readonly tabIndex = computed(() => this.gridBehavior.gridTabIndex());\n\n /** Whether the grid is disabled. */\n readonly disabled = computed(() => this.gridBehavior.gridDisabled());\n\n /** The ID of the currently active descendant cell. */\n readonly activeDescendant = computed(() => this.gridBehavior.activeDescendant());\n\n /** The currently active cell. */\n readonly activeCell = computed(() => this.gridBehavior.focusBehavior.activeCell());\n\n /** The current selection anchor cell. */\n readonly anchorCell: SignalLike<GridCellPattern | undefined> = computed(() =>\n this.inputs.enableSelection() && this.inputs.multi()\n ? this.gridBehavior.selectionAnchorCell()\n : undefined,\n );\n\n /** Whether to pause grid navigation and give the keyboard control to cell or widget. */\n readonly pauseNavigation: SignalLike<boolean> = computed(() =>\n this.gridBehavior.data\n .cells()\n .flat()\n .reduce((res, c) => res || c.isActivated(), false),\n );\n\n /** Whether the focus is in the grid. */\n readonly isFocused = signal(false);\n\n /** Whether the grid has been focused once. */\n readonly hasBeenFocused = signal(false);\n\n /** Whether the user is currently dragging to select a range of cells. */\n readonly dragging = signal(false);\n\n /** The key for navigating to the previous column. */\n readonly prevColKey = computed(() =>\n this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft',\n );\n\n /** The key for navigating to the next column. */\n readonly nextColKey = computed(() =>\n this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight',\n );\n\n /** The keydown event manager for the grid. */\n readonly keydown = computed(() => {\n const manager = new KeyboardEventManager();\n\n if (this.pauseNavigation()) {\n return manager;\n }\n\n // Navigation handlers.\n const opts: NavOptions = {\n selectOne: this.inputs.enableSelection() && this.inputs.selectionMode() === 'follow',\n };\n manager\n .on('ArrowUp', () => this.gridBehavior.up(opts))\n .on('ArrowDown', () => this.gridBehavior.down(opts))\n .on(this.prevColKey(), () => this.gridBehavior.left(opts))\n .on(this.nextColKey(), () => this.gridBehavior.right(opts))\n .on('Home', () => this.gridBehavior.firstInRow(opts))\n .on('End', () => this.gridBehavior.lastInRow(opts))\n .on([Modifier.Ctrl], 'Home', () => this.gridBehavior.first(opts))\n .on([Modifier.Ctrl], 'End', () => this.gridBehavior.last(opts));\n\n // Basic explicit selection handlers.\n if (this.inputs.enableSelection() && this.inputs.selectionMode() === 'explicit') {\n manager.on(/Enter| /, () =>\n this.inputs.multi() ? this.gridBehavior.toggle() : this.gridBehavior.toggleOne(),\n );\n }\n\n // Range selection handlers.\n if (this.inputs.enableSelection() && this.inputs.enableRangeSelection()) {\n manager\n .on(Modifier.Shift, 'ArrowUp', () => this.gridBehavior.up({anchor: true}))\n .on(Modifier.Shift, 'ArrowDown', () => this.gridBehavior.down({anchor: true}))\n .on(Modifier.Shift, this.prevColKey(), () => this.gridBehavior.left({anchor: true}))\n .on(Modifier.Shift, this.nextColKey(), () => this.gridBehavior.right({anchor: true}))\n .on(Modifier.Shift, 'Home', () => this.gridBehavior.firstInRow({anchor: true}))\n .on(Modifier.Shift, 'End', () => this.gridBehavior.lastInRow({anchor: true}))\n .on([Modifier.Ctrl | Modifier.Shift], 'Home', () => this.gridBehavior.first({anchor: true}))\n .on([Modifier.Ctrl | Modifier.Shift], 'End', () => this.gridBehavior.last({anchor: true}))\n .on([Modifier.Ctrl, Modifier.Meta], 'A', () => {\n if (this.gridBehavior.allSelected()) {\n this.gridBehavior.deselectAll();\n } else {\n this.gridBehavior.selectAll();\n }\n })\n .on([Modifier.Shift], ' ', () => this.gridBehavior.selectRow())\n .on([Modifier.Ctrl, Modifier.Meta], ' ', () => this.gridBehavior.selectCol());\n }\n\n return manager;\n });\n\n /** The pointerdown event manager for the grid. */\n readonly pointerdown = computed(() => {\n const manager = new PointerEventManager();\n\n // Navigation without selection.\n if (!this.inputs.enableSelection()) {\n manager.on(e => {\n const cell = this.inputs.getCell(e.target as Element);\n if (!cell || !this.gridBehavior.focusBehavior.isFocusable(cell)) return;\n\n this.gridBehavior.gotoCell(cell);\n });\n }\n\n // Navigation with selection.\n if (this.inputs.enableSelection()) {\n manager.on(e => {\n const cell = this.inputs.getCell(e.target as Element);\n if (!cell || !this.gridBehavior.focusBehavior.isFocusable(cell)) return;\n\n this.gridBehavior.gotoCell(cell, {\n selectOne: this.inputs.selectionMode() === 'follow',\n toggleOne: this.inputs.selectionMode() === 'explicit' && !this.inputs.multi(),\n toggle: this.inputs.selectionMode() === 'explicit' && this.inputs.multi(),\n });\n\n if (this.inputs.multi() && this.inputs.enableRangeSelection()) {\n this.dragging.set(true);\n }\n });\n\n // Selection with modifier keys.\n if (this.inputs.multi()) {\n manager.on([Modifier.Ctrl, Modifier.Meta], e => {\n const cell = this.inputs.getCell(e.target as Element);\n if (!cell || !this.gridBehavior.focusBehavior.isFocusable(cell)) return;\n\n this.gridBehavior.gotoCell(cell, {toggle: true});\n\n if (this.inputs.enableRangeSelection()) {\n this.dragging.set(true);\n }\n });\n\n if (this.inputs.enableRangeSelection()) {\n manager.on(Modifier.Shift, e => {\n const cell = this.inputs.getCell(e.target as Element);\n if (!cell) return;\n\n this.gridBehavior.gotoCell(cell, {anchor: true});\n this.dragging.set(true);\n });\n }\n }\n }\n\n return manager;\n });\n\n /** The pointerup event manager for the grid. */\n readonly pointerup = computed(() => {\n const manager = new PointerEventManager();\n\n if (this.inputs.enableSelection() && this.inputs.enableRangeSelection()) {\n manager.on([Modifier.Shift, Modifier.Ctrl, Modifier.Meta, Modifier.None], () => {\n this.dragging.set(false);\n });\n }\n\n return manager;\n });\n\n /** Indicates maybe the losing focus is caused by row/cell deletion. */\n private readonly _maybeDeletion = signal(false);\n\n /** Indicates the losing focus is certainly caused by row/cell deletion. */\n private readonly _deletion = signal(false);\n\n /** Whether the grid state is stale and needs to be reconciled. */\n private readonly _stateStale = signal(false);\n\n constructor(readonly inputs: GridInputs) {\n this.gridBehavior = new Grid({\n ...inputs,\n cells: computed(() => this.inputs.rows().map(row => row.inputs.cells())),\n });\n }\n\n /** Handles keydown events on the grid. */\n onKeydown(event: KeyboardEvent) {\n if (this.disabled()) return;\n\n this.activeCell()?.onKeydown(event);\n this.keydown().handle(event);\n }\n\n /** Handles pointerdown events on the grid. */\n onPointerdown(event: PointerEvent) {\n if (this.disabled()) return;\n\n this.pointerdown().handle(event);\n }\n\n /** Handles pointermove events on the grid. */\n onPointermove(event: PointerEvent) {\n if (\n this.disabled() ||\n !this.inputs.enableSelection() ||\n !this.inputs.enableRangeSelection() ||\n !this.dragging()\n ) {\n return;\n }\n\n const cell = this.inputs.getCell(event.target as Element);\n\n // Dragging anchor.\n if (cell !== undefined) {\n this.gridBehavior.gotoCell(cell, {anchor: true});\n }\n }\n\n /** Handles pointerup events on the grid. */\n onPointerup(event: PointerEvent) {\n if (this.disabled()) return;\n\n this.pointerup().handle(event);\n }\n\n /** Handles focusin events on the grid. */\n onFocusIn(event: FocusEvent) {\n this.isFocused.set(true);\n this.hasBeenFocused.set(true);\n\n // Skip if in the middle of range selection.\n if (this.dragging()) return;\n\n // Cell that receives focus.\n const cell = this.inputs.getCell(event.target as Element | null);\n if (!cell || !this.gridBehavior.focusBehavior.isFocusable(cell)) return;\n\n // Pass down the focusin event to the cell.\n cell.onFocusIn(event);\n\n // Update active cell state if the cell is receiving focus by\n // tabbing, pointer, or any programmatic control into a widget inside the cell.\n if (cell !== this.activeCell()) {\n this.gridBehavior.gotoCell(cell);\n }\n }\n\n /** Handles focusout events on the grid. */\n onFocusOut(event: FocusEvent) {\n // Pass down focusout event to the cell that loses focus.\n const blurTarget = event.target as Element | null;\n const cell = this.inputs.getCell(blurTarget);\n\n // Pass down the focusout event to the cell.\n cell?.onFocusOut(event);\n\n const focusTarget = event.relatedTarget as Element | null;\n if (this.inputs.element().contains(focusTarget)) return;\n\n // If a `relatedTarget`(focusing target) is null, then it can be caused by either\n // - Clicking on a non-focusable element, or\n // - The focused element is removed from the page.\n if (focusTarget === null) {\n this._maybeDeletion.set(true);\n }\n\n this.isFocused.set(false);\n }\n\n /** Sets the default active state of the grid before receiving focus the first time. */\n setDefaultStateEffect(): void {\n if (this.hasBeenFocused()) return;\n\n this.gridBehavior.setDefaultState();\n }\n\n /** Resets the active state of the grid if it is empty or stale. */\n resetStateEffect(): void {\n const hasReset = this.gridBehavior.resetState();\n\n if (hasReset) {\n // If the active state has been reset right after a focusout event, then\n // we know it's caused by a row/cell deletion.\n if (this._maybeDeletion()) {\n this._deletion.set(true);\n } else {\n this._stateStale.set(true);\n }\n }\n // Reset maybe deletion state.\n this._maybeDeletion.set(false);\n }\n\n /** Resets the focus to the active cell element or grid element. */\n resetFocusEffect(): void {\n const stateStale = this._stateStale();\n if (!stateStale) return;\n\n const isFocused = untracked(() => this.isFocused());\n const isRoving = untracked(() => this.inputs.focusMode() === 'roving');\n const activeCell = untracked(() => this.activeCell());\n\n if (isRoving && activeCell !== undefined && isFocused) {\n if (!activeCell.isFocused()) {\n activeCell.focus();\n }\n }\n\n this._stateStale.set(false);\n }\n\n /** Restore focus when a deletion happened. */\n restoreFocusEffect(): void {\n const deletion = this._deletion();\n if (!deletion) return;\n\n const isRoving = untracked(() => this.inputs.focusMode() === 'roving');\n const activeCell = untracked(() => this.activeCell());\n\n if (isRoving && activeCell !== undefined) {\n if (!activeCell.isFocused()) {\n activeCell.focus();\n }\n }\n\n this._deletion.set(false);\n }\n\n /** Sets focus when active cell changed. */\n focusEffect(): void {\n const activeCell = this.activeCell();\n const gridFocused = untracked(() => this.isFocused());\n\n if (activeCell === undefined || !gridFocused) return;\n\n const isRoving = untracked(() => this.inputs.focusMode() === 'roving');\n const cellFocused = untracked(() => activeCell.isFocused());\n\n if (isRoving && !cellFocused) {\n activeCell.focus();\n }\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 '../behaviors/signal-like/signal-like';\nimport type {GridPattern} from './grid';\nimport type {GridCellPattern} from './cell';\n\n/** The inputs for the `GridRowPattern`. */\nexport interface GridRowInputs {\n /** The `GridPattern` that this row belongs to. */\n grid: SignalLike<GridPattern>;\n\n /** The cells that make up this row. */\n cells: SignalLike<GridCellPattern[]>;\n\n /** The index of this row within the grid. */\n rowIndex: SignalLike<number | undefined>;\n}\n\n/** The UI pattern for a grid row. */\nexport class GridRowPattern {\n /** The index of this row within the grid. */\n rowIndex: SignalLike<number | undefined>;\n\n constructor(readonly inputs: GridRowInputs) {\n this.rowIndex = inputs.rowIndex;\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, linkedSignal, WritableSignal} from '@angular/core';\nimport {KeyboardEventManager} from '../behaviors/event-manager';\nimport {ListFocus} from '../behaviors/list-focus/list-focus';\nimport {ListNavigation, ListNavigationInputs} from '../behaviors/list-navigation/list-navigation';\nimport {SignalLike, WritableSignalLike} from '../behaviors/signal-like/signal-like';\nimport {GridCell} from '../behaviors/grid';\nimport type {GridPattern} from './grid';\nimport type {GridRowPattern} from './row';\nimport {GridCellWidgetPattern} from './widget';\n\n/** The inputs for the `GridCellPattern`. */\nexport interface GridCellInputs\n extends\n GridCell,\n Omit<\n ListNavigationInputs<GridCellWidgetPattern>,\n 'focusMode' | 'items' | 'activeItem' | 'softDisabled' | 'element'\n > {\n /** The `GridPattern` that this cell belongs to. */\n grid: SignalLike<GridPattern>;\n\n /** The `GridRowPattern` that this cell belongs to. */\n row: SignalLike<GridRowPattern>;\n\n /** The widget patterns contained within this cell, if any. */\n widgets: SignalLike<GridCellWidgetPattern[]>;\n\n /** The index of this cell's row within the grid. */\n rowIndex: SignalLike<number | undefined>;\n\n /** The index of this cell's column within the grid. */\n colIndex: SignalLike<number | undefined>;\n\n /** A function that returns the cell widget associated with a given element. */\n getWidget: (e: Element | null) => GridCellWidgetPattern | undefined;\n}\n\n/** The UI pattern for a grid cell. */\nexport class GridCellPattern implements GridCell {\n /** A unique identifier for the cell. */\n readonly id: SignalLike<string> = () => this.inputs.id();\n\n /** The html element that should receive focus. */\n readonly element: SignalLike<HTMLElement> = () => this.inputs.element();\n\n /** Whether the cell has focus. */\n readonly isFocused: WritableSignal<boolean> = signal(false);\n\n /** Whether the cell is selected. */\n readonly selected: WritableSignalLike<boolean>;\n\n /** Whether the cell is selectable. */\n readonly selectable: SignalLike<boolean> = () => this.inputs.selectable();\n\n /** Whether a cell is disabled. */\n readonly disabled: SignalLike<boolean> = () => this.inputs.disabled();\n\n /** The number of rows the cell should span. */\n readonly rowSpan: SignalLike<number> = () => this.inputs.rowSpan();\n\n /** The number of columns the cell should span. */\n readonly colSpan: SignalLike<number> = () => this.inputs.colSpan();\n\n /** Whether the cell is active. */\n readonly active: SignalLike<boolean> = computed(() => this.inputs.grid().activeCell() === this);\n\n /** Whether the cell is a selection anchor. */\n readonly anchor: SignalLike<true | undefined> = computed(() =>\n this.inputs.grid().anchorCell() === this ? true : undefined,\n );\n\n /** The `aria-selected` attribute for the cell. */\n readonly ariaSelected: SignalLike<boolean | undefined> = computed(() =>\n this.inputs.grid().inputs.enableSelection() && this.selectable() ? this.selected() : undefined,\n );\n\n /** The `aria-rowindex` attribute for the cell. */\n readonly ariaRowIndex: SignalLike<number | undefined> = computed(\n () =>\n this.inputs.row().rowIndex() ??\n this.inputs.rowIndex() ??\n this.inputs.grid().gridBehavior.rowIndex(this),\n );\n\n /** The `aria-colindex` attribute for the cell. */\n readonly ariaColIndex: SignalLike<number | undefined> = computed(\n () => this.inputs.colIndex() ?? this.inputs.grid().gridBehavior.colIndex(this),\n );\n\n /** The internal tab index calculation for the cell. */\n private readonly _tabIndex: SignalLike<-1 | 0> = computed(() =>\n this.inputs.grid().gridBehavior.cellTabIndex(this),\n );\n\n /** The tab index for the cell. If the cell contains a widget, the cell's tab index is -1. */\n readonly tabIndex: SignalLike<-1 | 0> = computed(() => {\n if (this.singleWidgetMode() || this.navigationActivated()) {\n return -1;\n }\n return this._tabIndex();\n });\n\n // Single/Multi Widget Navigation Setup\n\n /** Whether the cell contains a single widget. */\n readonly singleWidgetMode: SignalLike<boolean> = computed(\n () => this.inputs.widgets().length === 1,\n );\n\n /** Whether the cell contains multiple widgets. */\n readonly multiWidgetMode: SignalLike<boolean> = computed(() => this.inputs.widgets().length > 1);\n\n /** Whether navigation between widgets is disabled. */\n readonly navigationDisabled: SignalLike<boolean> = computed(\n () => !this.multiWidgetMode() || !this.active() || this.inputs.disabled(),\n );\n\n /** The focus behavior for the widgets in the cell. */\n readonly focusBehavior: ListFocus<GridCellWidgetPattern>;\n\n /** The navigation behavior for the widgets in the cell. */\n readonly navigationBehavior: ListNavigation<GridCellWidgetPattern>;\n\n /** The currently active widget in the cell. */\n readonly activeWidget: WritableSignalLike<GridCellWidgetPattern | undefined> = linkedSignal(() =>\n this.inputs.widgets().length > 0 ? this.inputs.widgets()[0] : undefined,\n );\n\n /** Whether navigation between widgets is activated. */\n readonly navigationActivated: WritableSignalLike<boolean> = signal(false);\n\n /** Whether any widget within the cell is activated. */\n readonly widgetActivated: SignalLike<boolean> = computed(() =>\n this.inputs.widgets().some(w => w.isActivated()),\n );\n\n /** Whether the cell or widget inside the cell is activated. */\n readonly isActivated: SignalLike<boolean> = computed(\n () => this.navigationActivated() || this.widgetActivated(),\n );\n\n /** The key used to navigate to the previous widget. */\n readonly prevKey = computed(() => {\n if (this.inputs.orientation() === 'vertical') {\n return 'ArrowUp';\n }\n return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';\n });\n\n /** The key used to navigate to the next widget. */\n readonly nextKey = computed(() => {\n if (this.inputs.orientation() === 'vertical') {\n return 'ArrowDown';\n }\n return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';\n });\n\n /** The keyboard event manager for the cell. */\n readonly keydown = computed(() => {\n const manager = new KeyboardEventManager();\n\n // Before start list navigation.\n if (!this.navigationActivated()) {\n manager.on('Enter', () => this.startNavigation());\n return manager;\n }\n\n // Start list navigation.\n manager\n .on('Escape', () => this.stopNavigation())\n .on(this.prevKey(), () =>\n this._advance(() => this.navigationBehavior.prev({focusElement: false})),\n )\n .on(this.nextKey(), () =>\n this._advance(() => this.navigationBehavior.next({focusElement: false})),\n )\n .on('Home', () => this._advance(() => this.navigationBehavior.next({focusElement: false})))\n .on('End', () => this._advance(() => this.navigationBehavior.next({focusElement: false})));\n\n return manager;\n });\n\n constructor(readonly inputs: GridCellInputs) {\n this.selected = inputs.selected;\n\n const listNavigationInputs: ListNavigationInputs<GridCellWidgetPattern> = {\n ...inputs,\n items: inputs.widgets,\n activeItem: this.activeWidget,\n disabled: this.navigationDisabled,\n focusMode: () => 'roving',\n softDisabled: () => true,\n };\n\n this.focusBehavior = new ListFocus<GridCellWidgetPattern>(listNavigationInputs);\n this.navigationBehavior = new ListNavigation<GridCellWidgetPattern>({\n ...listNavigationInputs,\n focusManager: this.focusBehavior,\n });\n }\n\n /** Handles keydown events for the cell. */\n onKeydown(event: KeyboardEvent): void {\n if (this.disabled() || this.inputs.widgets().length === 0) return;\n\n // No navigation needed if single widget.\n if (this.singleWidgetMode()) {\n this.activeWidget()!.onKeydown(event);\n return;\n }\n\n // Focus is on the cell before the navigation starts.\n if (!this.navigationActivated()) {\n this.keydown().handle(event);\n return;\n }\n\n // Widget activate state can be changed during the widget keydown handling.\n const widgetActivated = this.widgetActivated();\n\n this.activeWidget()!.onKeydown(event);\n\n if (!widgetActivated) {\n this.keydown().handle(event);\n }\n }\n\n /** Handles focusin events for the cell. */\n onFocusIn(event: FocusEvent): void {\n this.isFocused.set(true);\n\n const focusTarget = event.target as Element | null;\n const widget = this.inputs.getWidget(focusTarget);\n if (!widget) return;\n\n // Pass down focusin event to the widget.\n widget.onFocusIn(event);\n\n // Update internal states if the widget(or anything within the widget) is\n // receiving focus by tabbing, pointer, or any programmatic control.\n\n // Update current active widget.\n if (widget !== this.activeWidget()) {\n this.navigationBehavior.goto(widget, {focusElement: false});\n }\n\n // Start widget navigation if multi widget.\n if (this.multiWidgetMode()) {\n this.navigationActivated.set(true);\n }\n }\n\n /** Handles focusout events for the cell. */\n onFocusOut(event: FocusEvent): void {\n const blurTarget = event.target as Element | null;\n const widget = this.inputs.getWidget(blurTarget);\n\n // Pass down focusout event to the widget.\n widget?.onFocusOut(event);\n\n const focusTarget = event.relatedTarget as Element | null;\n if (this.element().contains(focusTarget)) return;\n\n this.isFocused.set(false);\n // Reset navigation state when focus leaving cell.\n this.navigationActivated.set(false);\n }\n\n /** Focuses the cell or the active widget. */\n focus(): void {\n if (this.singleWidgetMode()) {\n this.activeWidget()?.focus();\n } else {\n this.element().focus();\n }\n }\n\n /** Gets the tab index for the widget within the cell. */\n widgetTabIndex(): -1 | 0 {\n if (this.singleWidgetMode()) {\n return this._tabIndex();\n }\n return this.navigationActivated() ? 0 : -1;\n }\n\n /** Starts navigation between widgets. */\n startNavigation(): void {\n if (this.navigationActivated()) return;\n\n this.navigationActivated.set(true);\n this.navigationBehavior.first();\n }\n\n /** Stops navigation between widgets and restores focus to the cell. */\n stopNavigation(): void {\n if (!this.navigationActivated()) return;\n\n this.navigationActivated.set(false);\n this.element().focus();\n }\n\n /** Executes a navigation operation and focuses the new active widget. */\n private _advance(op: () => boolean): void {\n const success = op();\n if (success) {\n this.activeWidget()?.focus();\n }\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, Signal, WritableSignal} from '@angular/core';\nimport {KeyboardEventManager, Modifier} from '../behaviors/event-manager';\nimport {ListNavigationItem} from '../behaviors/list-navigation/list-navigation';\nimport {SignalLike} from '../behaviors/signal-like/signal-like';\nimport type {GridCellPattern} from './cell';\n\n/** The inputs for the `GridCellWidgetPattern`. */\nexport interface GridCellWidgetInputs extends Omit<ListNavigationItem, 'index'> {\n /** The `GridCellPattern` that this widget belongs to. */\n cell: SignalLike<GridCellPattern>;\n\n /** The html element that should receive focus. */\n element: SignalLike<HTMLElement>;\n\n /** The type of widget, which determines how it is activated. */\n widgetType: SignalLike<'simple' | 'complex' | 'editable'>;\n\n /** The element that will receive focus when the widget is activated. */\n focusTarget: SignalLike<HTMLElement | undefined>;\n}\n\n/** The UI pattern for a widget inside a grid cell. */\nexport class GridCellWidgetPattern implements ListNavigationItem {\n /** A unique identifier for the widget. */\n readonly id: SignalLike<string> = () => this.inputs.id();\n\n /** The html element that should receive focus. */\n readonly element: SignalLike<HTMLElement> = () => this.inputs.element();\n\n /** The element that should receive focus. */\n readonly widgetHost: Signal<HTMLElement> = computed(\n () => this.inputs.focusTarget() ?? this.element(),\n );\n\n /** The index of the widget within the cell. */\n readonly index: Signal<number> = computed(() =>\n this.inputs.cell().inputs.widgets().indexOf(this),\n );\n\n /** Whether the widget is disabled. */\n readonly disabled: Signal<boolean> = computed(\n () => this.inputs.disabled() || this.inputs.cell().disabled(),\n );\n\n /** The tab index for the widget. */\n readonly tabIndex: Signal<-1 | 0> = computed(() => this.inputs.cell().widgetTabIndex());\n\n /** Whether the widget is the active item in the widget list. */\n readonly active: Signal<boolean> = computed(() => this.inputs.cell().activeWidget() === this);\n\n /** Whether the widget is currently activated. */\n readonly isActivated: WritableSignal<boolean> = signal(false);\n\n /** The last event that caused the widget to be activated. */\n readonly lastActivateEvent: WritableSignal<KeyboardEvent | FocusEvent | undefined> =\n signal(undefined);\n\n /** The last event that caused the widget to be deactivated. */\n readonly lastDeactivateEvent: WritableSignal<KeyboardEvent | FocusEvent | undefined> =\n signal(undefined);\n\n /** The keyboard event manager for the widget. */\n readonly keydown = computed(() => {\n const manager = new KeyboardEventManager();\n\n // Simple widget does not need to pause default grid behaviors.\n if (this.inputs.widgetType() === 'simple') {\n return manager;\n }\n\n // If a widget is activated, only listen to events that exits activate state.\n if (this.isActivated()) {\n manager.on('Escape', e => {\n this.deactivate(e);\n this.focus();\n });\n\n if (this.inputs.widgetType() === 'editable') {\n manager.on('Enter', e => {\n this.deactivate(e);\n this.focus();\n });\n }\n\n return manager;\n }\n\n // Enter key is used to activate widget for both complex and editable type.\n manager.on('Enter', e => this.activate(e));\n\n if (this.inputs.widgetType() === 'editable') {\n manager.on([Modifier.Shift, Modifier.None], /^[a-zA-Z0-9]$/, e => this.activate(e), {\n preventDefault: false,\n });\n }\n\n return manager;\n });\n\n constructor(readonly inputs: GridCellWidgetInputs) {}\n\n /** Handles keydown events for the widget. */\n onKeydown(event: KeyboardEvent): void {\n if (this.disabled()) return;\n\n this.keydown().handle(event);\n }\n\n /** Handles focusin events for the widget. */\n onFocusIn(event: FocusEvent): void {\n // Simple widget does not have activate state.\n if (this.inputs.widgetType() === 'simple') return;\n\n // Set activate state if the focus is inside of widget.\n const focusTarget = event.target as Element;\n if (this.widgetHost().contains(focusTarget) && this.widgetHost() !== focusTarget) {\n this.activate(event);\n }\n }\n\n /** Handles focusout events for the widget. */\n onFocusOut(event: FocusEvent): void {\n const focusTarget = event.relatedTarget as Element;\n if (this.widgetHost().contains(focusTarget)) return;\n\n // Reset states when focus leaving widget.\n this.deactivate(event);\n }\n\n /** Focuses the widget's host element. */\n focus(): void {\n this.widgetHost().focus();\n }\n\n /** Activates the widget. */\n activate(event?: KeyboardEvent | FocusEvent): void {\n if (this.isActivated()) return;\n if (this.inputs.widgetType() === 'simple') return;\n\n this.isActivated.set(true);\n this.lastActivateEvent.set(event);\n }\n\n /** Deactivates the widget and restores focus to the widget's host element. */\n deactivate(event?: KeyboardEvent | FocusEvent): void {\n if (!this.isActivated()) return;\n\n this.isActivated.set(false);\n this.lastDeactivateEvent.set(event);\n }\n}\n"],"names":["GridData","inputs","cells","maxRowCount","computed","Math","max","_rowCountByCol","values","maxColCount","_colCountsByRow","_coordsMap","coordsMap","Map","visitedCoords","Set","rowIndex","length","colIndex","row","cell","has","rowspan","rowSpan","colspan","colSpan","spanCoords","rowOffset","colOffset","col","add","push","set","coords","_cellMap","cellMap","entries","colCountByRow","_","colCount","get","newColCount","undefined","rowCountByCol","rowCount","newRowCount","constructor","hasCell","getCell","rowCol","getCoords","getAllCoords","getRowCount","getColCount","GridFocus","activeCell","signal","activeCoords","stateEmpty","stateStale","activeCellCoords","grid","activeCoordsCell","activeCellNotValid","activeCellMismatch","activeDescendant","gridDisabled","focusMode","currentActiveCell","id","disabled","gridCells","every","gridTabIndex","getCellTabIndex","isFocusable","softDisabled","focusCell","focusCoordinates","direction","Up","Down","Left","Right","GridNavigation","_maxSteps","gotoCell","gridFocus","gotoCoords","peek","fromCoords","wrap","allowDisabled","rowWrap","colWrap","_peekDirectional","advance","nextCoords","peekFirst","first","peekLast","last","delta","fromCell","rowDelta","colDelta","step","isWrapping","generalDelta","rowStep","colStep","bothWrapping","nextCell","GridSelection","_undoList","undo","oldState","selected","select","toCoords","_updateState","deselect","toggle","selectAll","deselectAll","isSelectable","selectable","_validCells","startRow","min","startCol","endRow","endCol","visited","stateFn","undoList","Grid","data","focusBehavior","navigationBehavior","selectionBehavior","selectionAnchor","linkedSignal","selectionAnchorCell","selectionStabled","allSelected","flat","filter","c","index","cellTabIndex","up","opts","_navigateWithSelection","anchor","_updateSelectionAnchor","down","left","right","firstInRow","lastInRow","selectRow","selectCol","toggleOne","setDefaultState","focusableSelectedCell","find","firstFocusableCoords","resetState","peekFn","success","_updateRangeSelection","_getSelectionCoords","startCoords","endCoords","startCell","endCell","allCoords","allRows","map","allCols","op","selectOne","GridPattern","gridBehavior","tabIndex","anchorCell","enableSelection","multi","pauseNavigation","reduce","res","isActivated","isFocused","hasBeenFocused","dragging","prevColKey","textDirection","nextColKey","keydown","manager","KeyboardEventManager","selectionMode","on","Modifier","Ctrl","enableRangeSelection","Shift","Meta","pointerdown","PointerEventManager","e","target","pointerup","None","_maybeDeletion","_deletion","_stateStale","rows","onKeydown","event","handle","onPointerdown","onPointermove","onPointerup","onFocusIn","onFocusOut","blurTarget","focusTarget","relatedTarget","element","contains","setDefaultStateEffect","resetStateEffect","hasReset","resetFocusEffect","untracked","isRoving","focus","restoreFocusEffect","deletion","focusEffect","gridFocused","cellFocused","GridRowPattern","GridCellPattern","active","ariaSelected","ariaRowIndex","ariaColIndex","_tabIndex","singleWidgetMode","navigationActivated","widgets","multiWidgetMode","navigationDisabled","activeWidget","widgetActivated","some","w","prevKey","orientation","nextKey","startNavigation","stopNavigation","_advance","prev","focusElement","next","listNavigationInputs","items","activeItem","ListFocus","ListNavigation","focusManager","widget","getWidget","goto","widgetTabIndex","GridCellWidgetPattern","widgetHost","indexOf","lastActivateEvent","lastDeactivateEvent","widgetType","deactivate","activate","preventDefault"],"mappings":";;;;MAuCaA,QAAQ,CAAA;EAuFEC,MAAA;EArFZC,KAAK;EAGLC,WAAW,GAAGC,QAAQ,CAAS,MAAMC,IAAI,CAACC,GAAG,CAAC,GAAG,IAAI,CAACC,cAAc,EAAE,CAACC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;EAGpFC,WAAW,GAAGL,QAAQ,CAAS,MAAMC,IAAI,CAACC,GAAG,CAAC,GAAG,IAAI,CAACI,eAAe,EAAE,CAACF,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;EAG7EG,UAAU,GAAGP,QAAQ,CAAiD,MAAK;AAC1F,IAAA,MAAMQ,SAAS,GAAG,IAAIC,GAAG,EAAE;AAC3B,IAAA,MAAMC,aAAa,GAAG,IAAIC,GAAG,EAAE;AAE/B,IAAA,KAAK,IAAIC,QAAQ,GAAG,CAAC,EAAEA,QAAQ,GAAG,IAAI,CAACd,KAAK,EAAE,CAACe,MAAM,EAAED,QAAQ,EAAE,EAAE;MACjE,IAAIE,QAAQ,GAAG,CAAC;MAChB,MAAMC,GAAG,GAAG,IAAI,CAACjB,KAAK,EAAE,CAACc,QAAQ,CAAC;AAElC,MAAA,KAAK,MAAMI,IAAI,IAAID,GAAG,EAAE;QAEtB,OAAOL,aAAa,CAACO,GAAG,CAAC,CAAA,EAAGL,QAAQ,CAAIE,CAAAA,EAAAA,QAAQ,CAAE,CAAA,CAAC,EAAE;AACnDA,UAAAA,QAAQ,EAAE;AACZ;AAEA,QAAA,MAAMI,OAAO,GAAGF,IAAI,CAACG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