@angular/aria 21.1.0-next.2 → 21.1.0-next.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 (76) hide show
  1. package/fesm2022/_accordion-chunk.mjs +108 -0
  2. package/fesm2022/_accordion-chunk.mjs.map +1 -0
  3. package/fesm2022/_combobox-chunk.mjs +2 -2
  4. package/fesm2022/_combobox-chunk.mjs.map +1 -1
  5. package/fesm2022/_combobox-listbox-chunk.mjs +4 -286
  6. package/fesm2022/_combobox-listbox-chunk.mjs.map +1 -1
  7. package/fesm2022/_combobox-tree-chunk.mjs +331 -0
  8. package/fesm2022/_combobox-tree-chunk.mjs.map +1 -0
  9. package/fesm2022/_deferred-content-chunk.mjs +124 -0
  10. package/fesm2022/_deferred-content-chunk.mjs.map +1 -0
  11. package/fesm2022/_expansion-chunk.mjs +41 -0
  12. package/fesm2022/_expansion-chunk.mjs.map +1 -0
  13. package/fesm2022/_list-chunk.mjs +287 -0
  14. package/fesm2022/_list-chunk.mjs.map +1 -0
  15. package/fesm2022/_list-navigation-chunk.mjs +1 -1
  16. package/fesm2022/_list-navigation-chunk.mjs.map +1 -1
  17. package/fesm2022/_menu-chunk.mjs +515 -0
  18. package/fesm2022/_menu-chunk.mjs.map +1 -0
  19. package/fesm2022/_pointer-event-manager-chunk.mjs +2 -82
  20. package/fesm2022/_pointer-event-manager-chunk.mjs.map +1 -1
  21. package/fesm2022/_signal-like-chunk.mjs +118 -0
  22. package/fesm2022/_signal-like-chunk.mjs.map +1 -0
  23. package/fesm2022/_tabs-chunk.mjs +159 -0
  24. package/fesm2022/_tabs-chunk.mjs.map +1 -0
  25. package/fesm2022/_toolbar-widget-group-chunk.mjs +148 -0
  26. package/fesm2022/_toolbar-widget-group-chunk.mjs.map +1 -0
  27. package/fesm2022/_widget-chunk.mjs +3 -2
  28. package/fesm2022/_widget-chunk.mjs.map +1 -1
  29. package/fesm2022/accordion.mjs +10 -5
  30. package/fesm2022/accordion.mjs.map +1 -1
  31. package/fesm2022/aria.mjs +1 -1
  32. package/fesm2022/aria.mjs.map +1 -1
  33. package/fesm2022/combobox.mjs +50 -13
  34. package/fesm2022/combobox.mjs.map +1 -1
  35. package/fesm2022/grid.mjs +3 -1
  36. package/fesm2022/grid.mjs.map +1 -1
  37. package/fesm2022/listbox.mjs +9 -7
  38. package/fesm2022/listbox.mjs.map +1 -1
  39. package/fesm2022/menu.mjs +9 -5
  40. package/fesm2022/menu.mjs.map +1 -1
  41. package/fesm2022/private.mjs +13 -1402
  42. package/fesm2022/private.mjs.map +1 -1
  43. package/fesm2022/tabs.mjs +14 -6
  44. package/fesm2022/tabs.mjs.map +1 -1
  45. package/fesm2022/toolbar.mjs +5 -1
  46. package/fesm2022/toolbar.mjs.map +1 -1
  47. package/fesm2022/tree.mjs +13 -5
  48. package/fesm2022/tree.mjs.map +1 -1
  49. package/package.json +2 -2
  50. package/types/_accordion-chunk.d.ts +100 -0
  51. package/types/_combobox-chunk.d.ts +187 -91
  52. package/types/_deferred-content-chunk.d.ts +42 -0
  53. package/types/_expansion-chunk.d.ts +40 -0
  54. package/types/_grid-chunk.d.ts +41 -41
  55. package/types/_keyboard-event-manager-chunk.d.ts +68 -0
  56. package/types/_list-chunk.d.ts +8 -9
  57. package/types/_list-navigation-chunk.d.ts +8 -101
  58. package/types/_listbox-chunk.d.ts +17 -16
  59. package/types/_menu-chunk.d.ts +267 -0
  60. package/types/_pointer-event-manager-chunk.d.ts +34 -0
  61. package/types/_tabs-chunk.d.ts +153 -0
  62. package/types/_toolbar-chunk.d.ts +124 -0
  63. package/types/_tree-chunk.d.ts +185 -0
  64. package/types/accordion.d.ts +13 -5
  65. package/types/aria.d.ts +1 -1
  66. package/types/combobox.d.ts +122 -6
  67. package/types/grid.d.ts +10 -0
  68. package/types/listbox.d.ts +17 -5
  69. package/types/menu.d.ts +23 -5
  70. package/types/private.d.ts +25 -885
  71. package/types/tabs.d.ts +24 -8
  72. package/types/toolbar.d.ts +12 -4
  73. package/types/tree.d.ts +16 -5
  74. package/fesm2022/_combobox-popup-chunk.mjs +0 -46
  75. package/fesm2022/_combobox-popup-chunk.mjs.map +0 -1
  76. package/types/_combobox-chunk.d2.ts +0 -193
@@ -1 +1 @@
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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,CAACH,WAAW,CAAC,EAAE;AAG7C,IAAA,IAAI,CAACyD,UAAU,CAACjE,KAAK,CAAC;AACxB;AAGAkB,EAAAA,KAAKA,GAAA;AACH,IAAA,IAAI,CAAC0C,UAAU,EAAE,CAAC1C,KAAK,EAAE;AAC3B;EAGAgD,QAAQA,CAAClE,KAAkC,EAAA;AACzC,IAAA,IAAI,IAAI,CAAC5B,WAAW,EAAE,EAAE;IACxB,IAAI,IAAI,CAAC/L,MAAM,CAAC2R,UAAU,EAAE,KAAK,QAAQ,EAAE;AAE3C,IAAA,IAAI,CAAC5F,WAAW,CAAChK,GAAG,CAAC,IAAI,CAAC;AAC1B,IAAA,IAAI,CAAC0P,iBAAiB,CAAC1P,GAAG,CAAC4L,KAAK,CAAC;AACnC;EAGAiE,UAAUA,CAACjE,KAAkC,EAAA;AAC3C,IAAA,IAAI,CAAC,IAAI,CAAC5B,WAAW,EAAE,EAAE;AAEzB,IAAA,IAAI,CAACA,WAAW,CAAChK,GAAG,CAAC,KAAK,CAAC;AAC3B,IAAA,IAAI,CAAC2P,mBAAmB,CAAC3P,GAAG,CAAC4L,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, 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, WritableSignalLike, 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: WritableSignalLike<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 {SignalLike, computed} 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 {GridFocus, GridFocusCell, GridFocusInputs} from './grid-focus';\nimport {GridData, RowCol} from './grid-data';\nimport {SignalLike, WritableSignalLike, signal} from '../signal-like/signal-like';\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 {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 {computed, linkedSignal, signal, 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 {SignalLike, computed, signal, untracked} 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 {KeyboardEventManager} from '../behaviors/event-manager';\nimport {ListFocus} from '../behaviors/list-focus/list-focus';\nimport {ListNavigation, ListNavigationInputs} from '../behaviors/list-navigation/list-navigation';\nimport {\n computed,\n signal,\n linkedSignal,\n SignalLike,\n WritableSignalLike,\n} 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: WritableSignalLike<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 {KeyboardEventManager, Modifier} from '../behaviors/event-manager';\nimport {ListNavigationItem} from '../behaviors/list-navigation/list-navigation';\nimport {\n SignalLike,\n computed,\n signal,\n WritableSignalLike,\n} 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: SignalLike<HTMLElement> = computed(\n () => this.inputs.focusTarget() ?? this.element(),\n );\n\n /** The index of the widget within the cell. */\n readonly index: SignalLike<number> = computed(() =>\n this.inputs.cell().inputs.widgets().indexOf(this),\n );\n\n /** Whether the widget is disabled. */\n readonly disabled: SignalLike<boolean> = computed(\n () => this.inputs.disabled() || this.inputs.cell().disabled(),\n );\n\n /** The tab index for the widget. */\n readonly tabIndex: SignalLike<-1 | 0> = computed(() => this.inputs.cell().widgetTabIndex());\n\n /** Whether the widget is the active item in the widget list. */\n readonly active: SignalLike<boolean> = computed(() => this.inputs.cell().activeWidget() === this);\n\n /** Whether the widget is currently activated. */\n readonly isActivated: WritableSignalLike<boolean> = signal(false);\n\n /** The last event that caused the widget to be activated. */\n readonly lastActivateEvent: WritableSignalLike<KeyboardEvent | FocusEvent | undefined> =\n signal(undefined);\n\n /** The last event that caused the widget to be deactivated. */\n readonly lastDeactivateEvent: WritableSignalLike<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":";;;;;MAsCaA,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;QAEt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