@cloudscape-design/components 3.0.1076 → 3.0.1077

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.
@@ -2039,5 +2039,5 @@
2039
2039
  }
2040
2040
  }
2041
2041
  :root {
2042
- --awsui-version-info-7d81355c: true;
2042
+ --awsui-version-info-3048a990: true;
2043
2043
  }
@@ -1,6 +1,6 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (7d81355c)";
3
- export var GIT_SHA = "7d81355c";
2
+ export var PACKAGE_VERSION = "3.0.0 (3048a990)";
3
+ export var GIT_SHA = "3048a990";
4
4
  export var THEME = "open-source-visual-refresh";
5
5
  export var SYSTEM = "console";
6
6
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (7d81355c)",
4
- "GIT_SHA": "7d81355c",
3
+ "PACKAGE_VERSION": "3.0.0 (3048a990)",
4
+ "GIT_SHA": "3048a990",
5
5
  "THEME": "open-source-visual-refresh",
6
6
  "SYSTEM": "console",
7
7
  "ALWAYS_VISUAL_REFRESH": true
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "7d81355c6a27162fd6d4ab02a1d730355c89a9b3"
2
+ "commit": "3048a990386e0fc75098832381f6b9b8168afd70"
3
3
  }
package/package.json CHANGED
@@ -150,7 +150,7 @@
150
150
  "./internal/base-component/index.js",
151
151
  "./internal/base-component/styles.css.js"
152
152
  ],
153
- "version": "3.0.1076",
153
+ "version": "3.0.1077",
154
154
  "repository": {
155
155
  "type": "git",
156
156
  "url": "https://github.com/cloudscape-design/components.git"
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { SingleTabStopNavigationAPI } from '../../internal/context/single-tab-stop-navigation-context';
2
3
  import { GridNavigationProps } from './interfaces';
3
4
  /**
4
5
  * Makes table navigable with keyboard commands.
@@ -9,4 +10,43 @@ export declare function GridNavigationProvider({
9
10
  pageSize,
10
11
  getTable,
11
12
  children
12
- }: GridNavigationProps): JSX.Element;
13
+ }: GridNavigationProps): JSX.Element;
14
+ /**
15
+ * This helper encapsulates the grid navigation behaviors which are:
16
+ * 1. Responding to keyboard commands and moving the focus accordingly;
17
+ * 2. Muting table interactive elements for only one to be user-focusable at a time;
18
+ * 3. Suppressing the above behaviors when focusing an element inside a dialog or when instructed explicitly.
19
+ */
20
+ export declare class GridNavigationProcessor {
21
+ private _pageSize;
22
+ private _table;
23
+ private _navigationAPI;
24
+ private focusedCell;
25
+ private focusInside;
26
+ private keepUserIndex;
27
+ constructor(navigationAPI: {
28
+ current: null | SingleTabStopNavigationAPI;
29
+ });
30
+ init(table: HTMLTableElement): void;
31
+ cleanup: () => void;
32
+ update({
33
+ pageSize
34
+ }: {
35
+ pageSize: number;
36
+ }): void;
37
+ refresh(): void;
38
+ onRegisterFocusable: (focusableElement: HTMLElement) => void;
39
+ onUnregisterActive: () => void;
40
+ getNextFocusTarget: () => HTMLElement | null;
41
+ isElementSuppressed: (element: null | Element) => boolean;
42
+ private get pageSize();
43
+ private get table();
44
+ private onFocusin;
45
+ private onFocusout;
46
+ private onKeydown;
47
+ private moveFocusBy;
48
+ private isRegistered;
49
+ private updateFocusedCell;
50
+ private getNextFocusable;
51
+ private getFocusablesFrom;
52
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"grid-navigation.d.ts","sourceRoot":"","sources":["../../../../src/table/table-role/grid-navigation.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAe,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAWhE;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,mBAAmB,eAyC/G"}
1
+ {"version":3,"file":"grid-navigation.d.ts","sourceRoot":"","sources":["../../../../src/table/table-role/grid-navigation.tsx"],"names":[],"mappings":";AASA,OAAO,EACL,0BAA0B,EAE3B,MAAM,2DAA2D,CAAC;AAInE,OAAO,EAAe,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAWhE;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,mBAAmB,eAyC/G;AAED;;;;;GAKG;AACH,qBAAa,uBAAuB;IAElC,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,MAAM,CAAiC;IAC/C,OAAO,CAAC,cAAc,CAAiD;IAGvE,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,aAAa,CAAS;gBAElB,aAAa,EAAE;QAAE,OAAO,EAAE,IAAI,GAAG,0BAA0B,CAAA;KAAE;IAIlE,IAAI,CAAC,KAAK,EAAE,gBAAgB;IAa5B,OAAO,aAEZ;IAEK,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE;IAIzC,OAAO;IAWP,mBAAmB,qBAAsB,WAAW,UAUzD;IAEK,kBAAkB,aAMvB;IAEK,kBAAkB,2BAmBvB;IAEK,mBAAmB,YAAa,IAAI,GAAG,OAAO,aAMnD;IAEF,OAAO,KAAK,QAAQ,GAEnB;IAED,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,CAAC,SAAS,CAwBf;IAEF,OAAO,CAAC,UAAU,CAEhB;IAEF,OAAO,CAAC,SAAS,CAsDf;IAEF,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,iBAAiB;IA8BzB,OAAO,CAAC,gBAAgB;IA+CxB,OAAO,CAAC,iBAAiB;CAI1B"}
@@ -23,9 +23,9 @@ export function GridNavigationProvider({ keyboardNavigation, pageSize, getTable,
23
23
  const table = getTableStable();
24
24
  if (table) {
25
25
  gridNavigation.init(table);
26
+ return gridNavigation.cleanup;
26
27
  }
27
28
  }
28
- return () => gridNavigation.cleanup();
29
29
  }, [keyboardNavigation, gridNavigation, getTableStable]);
30
30
  // Notify the processor of the props change.
31
31
  useEffect(() => {
@@ -45,7 +45,7 @@ export function GridNavigationProvider({ keyboardNavigation, pageSize, getTable,
45
45
  * 2. Muting table interactive elements for only one to be user-focusable at a time;
46
46
  * 3. Suppressing the above behaviors when focusing an element inside a dialog or when instructed explicitly.
47
47
  */
48
- class GridNavigationProcessor {
48
+ export class GridNavigationProcessor {
49
49
  constructor(navigationAPI) {
50
50
  // Props
51
51
  this._pageSize = 0;
@@ -54,6 +54,9 @@ class GridNavigationProcessor {
54
54
  this.focusedCell = null;
55
55
  this.focusInside = false;
56
56
  this.keepUserIndex = false;
57
+ this.cleanup = () => {
58
+ // Do nothing before initialized.
59
+ };
57
60
  this.onRegisterFocusable = (focusableElement) => {
58
61
  var _a;
59
62
  if (!this.focusInside) {
@@ -75,6 +78,9 @@ class GridNavigationProcessor {
75
78
  };
76
79
  this.getNextFocusTarget = () => {
77
80
  var _a;
81
+ if (!this.table) {
82
+ return null;
83
+ }
78
84
  const cell = this.focusedCell;
79
85
  const firstTableCell = this.table.querySelector('td,th');
80
86
  // A single element of the table is made user-focusable.
@@ -170,16 +176,13 @@ class GridNavigationProcessor {
170
176
  init(table) {
171
177
  this._table = table;
172
178
  const controller = new AbortController();
173
- this.table.addEventListener('focusin', this.onFocusin, { signal: controller.signal });
174
- this.table.addEventListener('focusout', this.onFocusout, { signal: controller.signal });
175
- this.table.addEventListener('keydown', this.onKeydown, { signal: controller.signal });
179
+ table.addEventListener('focusin', this.onFocusin, { signal: controller.signal });
180
+ table.addEventListener('focusout', this.onFocusout, { signal: controller.signal });
181
+ table.addEventListener('keydown', this.onKeydown, { signal: controller.signal });
176
182
  this.cleanup = () => {
177
183
  controller.abort();
178
184
  };
179
185
  }
180
- cleanup() {
181
- // Do nothing before initialized.
182
- }
183
186
  update({ pageSize }) {
184
187
  this._pageSize = pageSize;
185
188
  }
@@ -198,9 +201,6 @@ class GridNavigationProcessor {
198
201
  return this._pageSize;
199
202
  }
200
203
  get table() {
201
- if (!this._table) {
202
- throw new Error('Invariant violation: GridNavigationProcessor is used before initialization.');
203
- }
204
204
  return this._table;
205
205
  }
206
206
  moveFocusBy(cell, delta) {
@@ -1 +1 @@
1
- {"version":3,"file":"grid-navigation.js","sourceRoot":"","sources":["../../../../src/table/table-role/grid-navigation.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAEL,+BAA+B,GAChC,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,SAAS,EAAE,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAEhE,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,8BAA8B,EAC9B,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,WAAW,GACZ,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAuB;IAC9G,MAAM,aAAa,GAAG,MAAM,CAA6B,IAAI,CAAC,CAAC;IAC/D,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,uBAAuB,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC;IAErF,MAAM,cAAc,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IA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K,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE;YAC/D,UAAU,GAAG,CAAC,CAAC;SAChB;QACD,sEAAsE;QACtE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,QAAQ,EAAE;YAC9D,UAAU,GAAG,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;SAC9C;QAED,OAAO,MAAA,oBAAoB,CAAC,UAAU,CAAC,mCAAI,UAAU,CAAC;IACxD,CAAC;IAEO,iBAAiB,CAAC,MAAmB;QAC3C,MAAM,mBAAmB,GAAG,CAAC,OAAgB,EAAE,EAAE,WAAC,OAAA,MAAA,IAAI,CAAC,cAAc,CAAC,OAAO,0CAAE,YAAY,CAAC,OAAO,CAAC,CAAA,EAAA,CAAC;QACrG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,mBAAmB,CAAC,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC;IAClG,CAAC;CACF","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useRef } from 'react';\nimport { useEffect, useMemo } from 'react';\n\nimport { useStableCallback } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getAllFocusables } from '../../internal/components/focus-lock/utils';\nimport {\n SingleTabStopNavigationAPI,\n SingleTabStopNavigationProvider,\n} from '../../internal/context/single-tab-stop-navigation-context';\nimport { KeyCode } from '../../internal/keycode';\nimport handleKey, { isEventLike } from '../../internal/utils/handle-key';\nimport { nodeBelongs } from '../../internal/utils/node-belongs';\nimport { FocusedCell, GridNavigationProps } from './interfaces';\nimport {\n defaultIsSuppressed,\n findTableRowByAriaRowIndex,\n findTableRowCellByAriaColIndex,\n focusNextElement,\n getClosestCell,\n isElementDisabled,\n isTableCell,\n} from './utils';\n\n/**\n * Makes table navigable with keyboard commands.\n * See grid-navigation.md\n */\nexport function GridNavigationProvider({ keyboardNavigation, pageSize, getTable, children }: GridNavigationProps) {\n const navigationAPI = useRef<SingleTabStopNavigationAPI>(null);\n const gridNavigation = useMemo(() => new GridNavigationProcessor(navigationAPI), []);\n\n const getTableStable = useStableCallback(getTable);\n\n // Initialize the processor with the table container assuming it is mounted synchronously and only once.\n useEffect(() => {\n if (keyboardNavigation) {\n const table = getTableStable();\n if (table) {\n gridNavigation.init(table);\n }\n }\n return () => gridNavigation.cleanup();\n }, [keyboardNavigation, gridNavigation, getTableStable]);\n\n // Notify the processor of the props change.\n useEffect(() => {\n gridNavigation.update({ pageSize });\n }, [gridNavigation, pageSize]);\n\n // Notify the processor of the new render.\n useEffect(() => {\n if (keyboardNavigation) {\n gridNavigation.refresh();\n }\n });\n\n return (\n <SingleTabStopNavigationProvider\n ref={navigationAPI}\n navigationActive={keyboardNavigation}\n getNextFocusTarget={gridNavigation.getNextFocusTarget}\n isElementSuppressed={gridNavigation.isElementSuppressed}\n onRegisterFocusable={gridNavigation.onRegisterFocusable}\n onUnregisterActive={gridNavigation.onUnregisterActive}\n >\n {children}\n </SingleTabStopNavigationProvider>\n );\n}\n\n/**\n * This helper encapsulates the grid navigation behaviors which are:\n * 1. Responding to keyboard commands and moving the focus accordingly;\n * 2. Muting table interactive elements for only one to be user-focusable at a time;\n * 3. Suppressing the above behaviors when focusing an element inside a dialog or when instructed explicitly.\n */\nclass GridNavigationProcessor {\n // Props\n private _pageSize = 0;\n private _table: null | HTMLTableElement = null;\n private _navigationAPI: { current: null | SingleTabStopNavigationAPI };\n\n // State\n private focusedCell: null | FocusedCell = null;\n private focusInside = false;\n private keepUserIndex = false;\n\n constructor(navigationAPI: { current: null | SingleTabStopNavigationAPI }) {\n this._navigationAPI = navigationAPI;\n }\n\n public init(table: HTMLTableElement) {\n this._table = table;\n const controller = new AbortController();\n\n this.table.addEventListener('focusin', this.onFocusin, { signal: controller.signal });\n this.table.addEventListener('focusout', this.onFocusout, { signal: controller.signal });\n this.table.addEventListener('keydown', this.onKeydown, { signal: controller.signal });\n\n this.cleanup = () => {\n controller.abort();\n };\n }\n\n public cleanup() {\n // Do nothing before initialized.\n }\n\n public update({ pageSize }: { pageSize: number }) {\n this._pageSize = pageSize;\n }\n\n public refresh() {\n // Timeout ensures the newly rendered content elements are registered.\n setTimeout(() => {\n if (this._table) {\n // Update focused cell indices in case table rows, columns, or firstIndex change.\n this.updateFocusedCell(this.focusedCell?.element);\n this._navigationAPI.current?.updateFocusTarget();\n }\n }, 0);\n }\n\n public onRegisterFocusable = (focusableElement: HTMLElement) => {\n if (!this.focusInside) {\n return;\n }\n // When newly registered element belongs to the focused cell the focus must transition to it.\n const focusedElement = this.focusedCell?.element;\n if (focusedElement && isTableCell(focusedElement) && focusedElement.contains(focusableElement)) {\n // Scroll is unnecessary when moving focus from a cell to element within the cell.\n focusableElement.focus({ preventScroll: true });\n }\n };\n\n public onUnregisterActive = () => {\n // If the focused cell appears to be no longer attached to the table we need to re-apply\n // focus to a cell with the same or closest position.\n if (this.focusedCell && !nodeBelongs(this.table, this.focusedCell.element)) {\n this.moveFocusBy(this.focusedCell, { x: 0, y: 0 });\n }\n };\n\n public getNextFocusTarget = () => {\n const cell = this.focusedCell;\n const firstTableCell = this.table.querySelector('td,th') as null | HTMLTableCellElement;\n\n // A single element of the table is made user-focusable.\n // It defaults to the first interactive element of the first cell or the first cell itself otherwise.\n let focusTarget: null | HTMLElement =\n (firstTableCell && this.getFocusablesFrom(firstTableCell)[0]) ?? firstTableCell;\n\n // When a navigation-focused element is present in the table it is used for user-navigation instead.\n if (cell) {\n focusTarget = this.getNextFocusable(cell, { x: 0, y: 0 });\n }\n\n return focusTarget;\n };\n\n public isElementSuppressed = (element: null | Element) => {\n // Omit calculation as irrelevant until the table receives focus.\n if (!this.focusedCell) {\n return false;\n }\n return !element || defaultIsSuppressed(element);\n };\n\n private get pageSize() {\n return this._pageSize;\n }\n\n private get table(): HTMLTableElement {\n if (!this._table) {\n throw new Error('Invariant violation: GridNavigationProcessor is used before initialization.');\n }\n return this._table;\n }\n\n private onFocusin = (event: FocusEvent) => {\n this.focusInside = true;\n\n if (!(event.target instanceof HTMLElement)) {\n return;\n }\n\n this.updateFocusedCell(event.target);\n if (!this.focusedCell) {\n return;\n }\n\n this._navigationAPI.current?.updateFocusTarget();\n\n // Focusing on cell is not eligible when it contains focusable elements in the content.\n // If content focusables are available - move the focus to the first one.\n const focusedElement = this.focusedCell.element;\n const nextTarget = isTableCell(focusedElement) ? this.getFocusablesFrom(focusedElement)[0] : null;\n if (nextTarget) {\n // Scroll is unnecessary when moving focus from a cell to element within the cell.\n nextTarget.focus({ preventScroll: true });\n } else {\n this.keepUserIndex = false;\n }\n };\n\n private onFocusout = () => {\n this.focusInside = false;\n };\n\n private onKeydown = (event: KeyboardEvent) => {\n if (!this.focusedCell) {\n return;\n }\n\n const keys = [\n KeyCode.up,\n KeyCode.down,\n KeyCode.left,\n KeyCode.right,\n KeyCode.pageUp,\n KeyCode.pageDown,\n KeyCode.home,\n KeyCode.end,\n ];\n const ctrlKey = event.ctrlKey ? 1 : 0;\n const altKey = event.altKey ? 1 : 0;\n const shiftKey = event.shiftKey ? 1 : 0;\n const metaKey = event.metaKey ? 1 : 0;\n const modifiersPressed = ctrlKey + altKey + shiftKey + metaKey;\n const invalidModifierCombination =\n (modifiersPressed && !event.ctrlKey) ||\n (event.ctrlKey && event.keyCode !== KeyCode.home && event.keyCode !== KeyCode.end);\n\n if (\n invalidModifierCombination ||\n this.isElementSuppressed(document.activeElement) ||\n !this.isRegistered(document.activeElement) ||\n keys.indexOf(event.keyCode) === -1\n ) {\n return;\n }\n\n const from = this.focusedCell;\n event.preventDefault();\n\n if (isEventLike(event)) {\n handleKey(event, {\n onBlockStart: () => this.moveFocusBy(from, { y: -1, x: 0 }),\n onBlockEnd: () => this.moveFocusBy(from, { y: 1, x: 0 }),\n onInlineStart: () => this.moveFocusBy(from, { y: 0, x: -1 }),\n onInlineEnd: () => this.moveFocusBy(from, { y: 0, x: 1 }),\n onPageUp: () => this.moveFocusBy(from, { y: -this.pageSize, x: 0 }),\n onPageDown: () => this.moveFocusBy(from, { y: this.pageSize, x: 0 }),\n onHome: () =>\n event.ctrlKey\n ? this.moveFocusBy(from, { y: -Infinity, x: -Infinity })\n : this.moveFocusBy(from, { y: 0, x: -Infinity }),\n onEnd: () =>\n event.ctrlKey\n ? this.moveFocusBy(from, { y: Infinity, x: Infinity })\n : this.moveFocusBy(from, { y: 0, x: Infinity }),\n });\n }\n };\n\n private moveFocusBy(cell: FocusedCell, delta: { x: number; y: number }) {\n // For vertical moves preserve column- and element indices set by user.\n // It allows keeping indices while moving over disabled actions or cells with colspan > 1.\n if (delta.y !== 0 && delta.x === 0) {\n this.keepUserIndex = true;\n }\n focusNextElement(this.getNextFocusable(cell, delta));\n }\n\n private isRegistered(element: null | Element): boolean {\n return !element || (this._navigationAPI.current?.isRegistered(element) ?? false);\n }\n\n private updateFocusedCell(focusedElement?: HTMLElement): void {\n if (!focusedElement) {\n return;\n }\n\n const cellElement = getClosestCell(focusedElement);\n const rowElement = cellElement?.closest('tr');\n if (!cellElement || !rowElement) {\n return;\n }\n\n const colIndex = parseInt(cellElement.getAttribute('aria-colindex') ?? '');\n const rowIndex = parseInt(rowElement.getAttribute('aria-rowindex') ?? '');\n if (isNaN(colIndex) || isNaN(rowIndex)) {\n return;\n }\n\n const cellFocusables = this.getFocusablesFrom(cellElement);\n const elementIndex = cellFocusables.indexOf(focusedElement);\n\n const prevColIndex = this.focusedCell?.colIndex ?? -1;\n const prevElementIndex = this.focusedCell?.elementIndex ?? -1;\n this.focusedCell = {\n rowIndex,\n colIndex: this.keepUserIndex && prevColIndex !== -1 ? prevColIndex : colIndex,\n elementIndex: this.keepUserIndex && prevElementIndex !== -1 ? prevElementIndex : elementIndex,\n element: focusedElement,\n };\n }\n\n private getNextFocusable(from: FocusedCell, delta: { y: number; x: number }) {\n // Find next row to move focus into (can be null if the top/bottom is reached).\n const targetAriaRowIndex = from.rowIndex + delta.y;\n const targetRow = findTableRowByAriaRowIndex(this.table, targetAriaRowIndex, delta.y);\n if (!targetRow) {\n return null;\n }\n\n // Return next interactive cell content element if available.\n const cellElement = getClosestCell(from.element);\n const cellFocusables = cellElement ? this.getFocusablesFrom(cellElement) : [];\n const nextElementIndex = from.elementIndex + delta.x;\n const isValidDirection = !!delta.x;\n const isValidIndex = from.elementIndex !== -1 && 0 <= nextElementIndex && nextElementIndex < cellFocusables.length;\n const isTargetDifferent = from.element !== cellFocusables[nextElementIndex];\n if (isValidDirection && isValidIndex && isTargetDifferent) {\n return cellFocusables[nextElementIndex];\n }\n\n // Find next cell to focus or move focus into (can be null if the left/right edge is reached).\n const targetAriaColIndex = from.colIndex + delta.x;\n const targetCell = findTableRowCellByAriaColIndex(targetRow, targetAriaColIndex, delta.x);\n if (!targetCell) {\n return null;\n }\n\n // When target cell matches the current cell it means we reached the left or right boundary.\n if (targetCell === cellElement && delta.x !== 0) {\n return null;\n }\n\n const targetCellFocusables = this.getFocusablesFrom(targetCell);\n\n // When delta.x = 0 keep element index if possible.\n let focusIndex = from.elementIndex;\n // Use first element index when moving to the right or to extreme left.\n if ((isFinite(delta.x) && delta.x > 0) || delta.x === -Infinity) {\n focusIndex = 0;\n }\n // Use last element index when moving to the left or to extreme right.\n if ((isFinite(delta.x) && delta.x < 0) || delta.x === Infinity) {\n focusIndex = targetCellFocusables.length - 1;\n }\n\n return targetCellFocusables[focusIndex] ?? targetCell;\n }\n\n private getFocusablesFrom(target: HTMLElement) {\n const isElementRegistered = (element: Element) => this._navigationAPI.current?.isRegistered(element);\n return getAllFocusables(target).filter(el => isElementRegistered(el) && !isElementDisabled(el));\n }\n}\n"]}
1
+ {"version":3,"file":"grid-navigation.js","sourceRoot":"","sources":["../../../../src/table/table-role/grid-navigation.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAE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EO,iBAAiB,CAAC,MAAmB;QAC3C,MAAM,mBAAmB,GAAG,CAAC,OAAgB,EAAE,EAAE,WAAC,OAAA,MAAA,IAAI,CAAC,cAAc,CAAC,OAAO,0CAAE,YAAY,CAAC,OAAO,CAAC,CAAA,EAAA,CAAC;QACrG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,mBAAmB,CAAC,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC;IAClG,CAAC;CACF","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useRef } from 'react';\nimport { useEffect, useMemo } from 'react';\n\nimport { useStableCallback } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getAllFocusables } from '../../internal/components/focus-lock/utils';\nimport {\n SingleTabStopNavigationAPI,\n SingleTabStopNavigationProvider,\n} from '../../internal/context/single-tab-stop-navigation-context';\nimport { KeyCode } from '../../internal/keycode';\nimport handleKey, { isEventLike } from '../../internal/utils/handle-key';\nimport { nodeBelongs } from '../../internal/utils/node-belongs';\nimport { FocusedCell, GridNavigationProps } from './interfaces';\nimport {\n defaultIsSuppressed,\n findTableRowByAriaRowIndex,\n findTableRowCellByAriaColIndex,\n focusNextElement,\n getClosestCell,\n isElementDisabled,\n isTableCell,\n} from './utils';\n\n/**\n * Makes table navigable with keyboard commands.\n * See grid-navigation.md\n */\nexport function GridNavigationProvider({ keyboardNavigation, pageSize, getTable, children }: GridNavigationProps) {\n const navigationAPI = useRef<SingleTabStopNavigationAPI>(null);\n const gridNavigation = useMemo(() => new GridNavigationProcessor(navigationAPI), []);\n\n const getTableStable = useStableCallback(getTable);\n\n // Initialize the processor with the table container assuming it is mounted synchronously and only once.\n useEffect(() => {\n if (keyboardNavigation) {\n const table = getTableStable();\n if (table) {\n gridNavigation.init(table);\n return gridNavigation.cleanup;\n }\n }\n }, [keyboardNavigation, gridNavigation, getTableStable]);\n\n // Notify the processor of the props change.\n useEffect(() => {\n gridNavigation.update({ pageSize });\n }, [gridNavigation, pageSize]);\n\n // Notify the processor of the new render.\n useEffect(() => {\n if (keyboardNavigation) {\n gridNavigation.refresh();\n }\n });\n\n return (\n <SingleTabStopNavigationProvider\n ref={navigationAPI}\n navigationActive={keyboardNavigation}\n getNextFocusTarget={gridNavigation.getNextFocusTarget}\n isElementSuppressed={gridNavigation.isElementSuppressed}\n onRegisterFocusable={gridNavigation.onRegisterFocusable}\n onUnregisterActive={gridNavigation.onUnregisterActive}\n >\n {children}\n </SingleTabStopNavigationProvider>\n );\n}\n\n/**\n * This helper encapsulates the grid navigation behaviors which are:\n * 1. Responding to keyboard commands and moving the focus accordingly;\n * 2. Muting table interactive elements for only one to be user-focusable at a time;\n * 3. Suppressing the above behaviors when focusing an element inside a dialog or when instructed explicitly.\n */\nexport class GridNavigationProcessor {\n // Props\n private _pageSize = 0;\n private _table: null | HTMLTableElement = null;\n private _navigationAPI: { current: null | SingleTabStopNavigationAPI };\n\n // State\n private focusedCell: null | FocusedCell = null;\n private focusInside = false;\n private keepUserIndex = false;\n\n constructor(navigationAPI: { current: null | SingleTabStopNavigationAPI }) {\n this._navigationAPI = navigationAPI;\n }\n\n public init(table: HTMLTableElement) {\n this._table = table;\n const controller = new AbortController();\n\n table.addEventListener('focusin', this.onFocusin, { signal: controller.signal });\n table.addEventListener('focusout', this.onFocusout, { signal: controller.signal });\n table.addEventListener('keydown', this.onKeydown, { signal: controller.signal });\n\n this.cleanup = () => {\n controller.abort();\n };\n }\n\n public cleanup = () => {\n // Do nothing before initialized.\n };\n\n public update({ pageSize }: { pageSize: number }) {\n this._pageSize = pageSize;\n }\n\n public refresh() {\n // Timeout ensures the newly rendered content elements are registered.\n setTimeout(() => {\n if (this._table) {\n // Update focused cell indices in case table rows, columns, or firstIndex change.\n this.updateFocusedCell(this.focusedCell?.element);\n this._navigationAPI.current?.updateFocusTarget();\n }\n }, 0);\n }\n\n public onRegisterFocusable = (focusableElement: HTMLElement) => {\n if (!this.focusInside) {\n return;\n }\n // When newly registered element belongs to the focused cell the focus must transition to it.\n const focusedElement = this.focusedCell?.element;\n if (focusedElement && isTableCell(focusedElement) && focusedElement.contains(focusableElement)) {\n // Scroll is unnecessary when moving focus from a cell to element within the cell.\n focusableElement.focus({ preventScroll: true });\n }\n };\n\n public onUnregisterActive = () => {\n // If the focused cell appears to be no longer attached to the table we need to re-apply\n // focus to a cell with the same or closest position.\n if (this.focusedCell && !nodeBelongs(this.table, this.focusedCell.element)) {\n this.moveFocusBy(this.focusedCell, { x: 0, y: 0 });\n }\n };\n\n public getNextFocusTarget = () => {\n if (!this.table) {\n return null;\n }\n\n const cell = this.focusedCell;\n const firstTableCell = this.table.querySelector('td,th') as null | HTMLTableCellElement;\n\n // A single element of the table is made user-focusable.\n // It defaults to the first interactive element of the first cell or the first cell itself otherwise.\n let focusTarget: null | HTMLElement =\n (firstTableCell && this.getFocusablesFrom(firstTableCell)[0]) ?? firstTableCell;\n\n // When a navigation-focused element is present in the table it is used for user-navigation instead.\n if (cell) {\n focusTarget = this.getNextFocusable(cell, { x: 0, y: 0 });\n }\n\n return focusTarget;\n };\n\n public isElementSuppressed = (element: null | Element) => {\n // Omit calculation as irrelevant until the table receives focus.\n if (!this.focusedCell) {\n return false;\n }\n return !element || defaultIsSuppressed(element);\n };\n\n private get pageSize() {\n return this._pageSize;\n }\n\n private get table(): null | HTMLTableElement {\n return this._table;\n }\n\n private onFocusin = (event: FocusEvent) => {\n this.focusInside = true;\n\n if (!(event.target instanceof HTMLElement)) {\n return;\n }\n\n this.updateFocusedCell(event.target);\n if (!this.focusedCell) {\n return;\n }\n\n this._navigationAPI.current?.updateFocusTarget();\n\n // Focusing on cell is not eligible when it contains focusable elements in the content.\n // If content focusables are available - move the focus to the first one.\n const focusedElement = this.focusedCell.element;\n const nextTarget = isTableCell(focusedElement) ? this.getFocusablesFrom(focusedElement)[0] : null;\n if (nextTarget) {\n // Scroll is unnecessary when moving focus from a cell to element within the cell.\n nextTarget.focus({ preventScroll: true });\n } else {\n this.keepUserIndex = false;\n }\n };\n\n private onFocusout = () => {\n this.focusInside = false;\n };\n\n private onKeydown = (event: KeyboardEvent) => {\n if (!this.focusedCell) {\n return;\n }\n\n const keys = [\n KeyCode.up,\n KeyCode.down,\n KeyCode.left,\n KeyCode.right,\n KeyCode.pageUp,\n KeyCode.pageDown,\n KeyCode.home,\n KeyCode.end,\n ];\n const ctrlKey = event.ctrlKey ? 1 : 0;\n const altKey = event.altKey ? 1 : 0;\n const shiftKey = event.shiftKey ? 1 : 0;\n const metaKey = event.metaKey ? 1 : 0;\n const modifiersPressed = ctrlKey + altKey + shiftKey + metaKey;\n const invalidModifierCombination =\n (modifiersPressed && !event.ctrlKey) ||\n (event.ctrlKey && event.keyCode !== KeyCode.home && event.keyCode !== KeyCode.end);\n\n if (\n invalidModifierCombination ||\n this.isElementSuppressed(document.activeElement) ||\n !this.isRegistered(document.activeElement) ||\n keys.indexOf(event.keyCode) === -1\n ) {\n return;\n }\n\n const from = this.focusedCell;\n event.preventDefault();\n\n if (isEventLike(event)) {\n handleKey(event, {\n onBlockStart: () => this.moveFocusBy(from, { y: -1, x: 0 }),\n onBlockEnd: () => this.moveFocusBy(from, { y: 1, x: 0 }),\n onInlineStart: () => this.moveFocusBy(from, { y: 0, x: -1 }),\n onInlineEnd: () => this.moveFocusBy(from, { y: 0, x: 1 }),\n onPageUp: () => this.moveFocusBy(from, { y: -this.pageSize, x: 0 }),\n onPageDown: () => this.moveFocusBy(from, { y: this.pageSize, x: 0 }),\n onHome: () =>\n event.ctrlKey\n ? this.moveFocusBy(from, { y: -Infinity, x: -Infinity })\n : this.moveFocusBy(from, { y: 0, x: -Infinity }),\n onEnd: () =>\n event.ctrlKey\n ? this.moveFocusBy(from, { y: Infinity, x: Infinity })\n : this.moveFocusBy(from, { y: 0, x: Infinity }),\n });\n }\n };\n\n private moveFocusBy(cell: FocusedCell, delta: { x: number; y: number }) {\n // For vertical moves preserve column- and element indices set by user.\n // It allows keeping indices while moving over disabled actions or cells with colspan > 1.\n if (delta.y !== 0 && delta.x === 0) {\n this.keepUserIndex = true;\n }\n focusNextElement(this.getNextFocusable(cell, delta));\n }\n\n private isRegistered(element: null | Element): boolean {\n return !element || (this._navigationAPI.current?.isRegistered(element) ?? false);\n }\n\n private updateFocusedCell(focusedElement?: HTMLElement): void {\n if (!focusedElement) {\n return;\n }\n\n const cellElement = getClosestCell(focusedElement);\n const rowElement = cellElement?.closest('tr');\n if (!cellElement || !rowElement) {\n return;\n }\n\n const colIndex = parseInt(cellElement.getAttribute('aria-colindex') ?? '');\n const rowIndex = parseInt(rowElement.getAttribute('aria-rowindex') ?? '');\n if (isNaN(colIndex) || isNaN(rowIndex)) {\n return;\n }\n\n const cellFocusables = this.getFocusablesFrom(cellElement);\n const elementIndex = cellFocusables.indexOf(focusedElement);\n\n const prevColIndex = this.focusedCell?.colIndex ?? -1;\n const prevElementIndex = this.focusedCell?.elementIndex ?? -1;\n this.focusedCell = {\n rowIndex,\n colIndex: this.keepUserIndex && prevColIndex !== -1 ? prevColIndex : colIndex,\n elementIndex: this.keepUserIndex && prevElementIndex !== -1 ? prevElementIndex : elementIndex,\n element: focusedElement,\n };\n }\n\n private getNextFocusable(from: FocusedCell, delta: { y: number; x: number }) {\n // Find next row to move focus into (can be null if the top/bottom is reached).\n const targetAriaRowIndex = from.rowIndex + delta.y;\n const targetRow = findTableRowByAriaRowIndex(this.table, targetAriaRowIndex, delta.y);\n if (!targetRow) {\n return null;\n }\n\n // Return next interactive cell content element if available.\n const cellElement = getClosestCell(from.element);\n const cellFocusables = cellElement ? this.getFocusablesFrom(cellElement) : [];\n const nextElementIndex = from.elementIndex + delta.x;\n const isValidDirection = !!delta.x;\n const isValidIndex = from.elementIndex !== -1 && 0 <= nextElementIndex && nextElementIndex < cellFocusables.length;\n const isTargetDifferent = from.element !== cellFocusables[nextElementIndex];\n if (isValidDirection && isValidIndex && isTargetDifferent) {\n return cellFocusables[nextElementIndex];\n }\n\n // Find next cell to focus or move focus into (can be null if the left/right edge is reached).\n const targetAriaColIndex = from.colIndex + delta.x;\n const targetCell = findTableRowCellByAriaColIndex(targetRow, targetAriaColIndex, delta.x);\n if (!targetCell) {\n return null;\n }\n\n // When target cell matches the current cell it means we reached the left or right boundary.\n if (targetCell === cellElement && delta.x !== 0) {\n return null;\n }\n\n const targetCellFocusables = this.getFocusablesFrom(targetCell);\n\n // When delta.x = 0 keep element index if possible.\n let focusIndex = from.elementIndex;\n // Use first element index when moving to the right or to extreme left.\n if ((isFinite(delta.x) && delta.x > 0) || delta.x === -Infinity) {\n focusIndex = 0;\n }\n // Use last element index when moving to the left or to extreme right.\n if ((isFinite(delta.x) && delta.x < 0) || delta.x === Infinity) {\n focusIndex = targetCellFocusables.length - 1;\n }\n\n return targetCellFocusables[focusIndex] ?? targetCell;\n }\n\n private getFocusablesFrom(target: HTMLElement) {\n const isElementRegistered = (element: Element) => this._navigationAPI.current?.isRegistered(element);\n return getAllFocusables(target).filter(el => isElementRegistered(el) && !isElementDisabled(el));\n }\n}\n"]}
@@ -8,7 +8,7 @@ export declare function defaultIsSuppressed(target: Element): boolean;
8
8
  /**
9
9
  * Finds the closest row to the targetAriaRowIndex+delta in the direction of delta.
10
10
  */
11
- export declare function findTableRowByAriaRowIndex(table: HTMLTableElement, targetAriaRowIndex: number, delta: number): HTMLTableRowElement | null;
11
+ export declare function findTableRowByAriaRowIndex(table: null | HTMLTableElement, targetAriaRowIndex: number, delta: number): HTMLTableRowElement | null;
12
12
  /**
13
13
  * Finds the closest column to the targetAriaColIndex+delta in the direction of delta.
14
14
  */
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/table/table-role/utils.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,+BAE9C;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,WAKrD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,WAgBlD;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,8BAqB5G;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,mBAAmB,EAC7B,kBAAkB,EAAE,MAAM,EAC1B,KAAK,EAAE,MAAM,+BAsBd;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,WAE3C;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,IAAI,GAAG,WAAW,QAW3D"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/table/table-role/utils.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,+BAE9C;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,WAKrD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,WAgBlD;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,IAAI,GAAG,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,8BAqBnH;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,mBAAmB,EAC7B,kBAAkB,EAAE,MAAM,EAC1B,KAAK,EAAE,MAAM,+BAsBd;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,WAE3C;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,IAAI,GAAG,WAAW,QAW3D"}
@@ -32,14 +32,14 @@ export function defaultIsSuppressed(target) {
32
32
  * Finds the closest row to the targetAriaRowIndex+delta in the direction of delta.
33
33
  */
34
34
  export function findTableRowByAriaRowIndex(table, targetAriaRowIndex, delta) {
35
- var _a;
35
+ var _a, _b;
36
36
  let targetRow = null;
37
- const rowElements = Array.from(table.querySelectorAll('tr[aria-rowindex]'));
37
+ const rowElements = Array.from((_a = table === null || table === void 0 ? void 0 : table.querySelectorAll('tr[aria-rowindex]')) !== null && _a !== void 0 ? _a : []);
38
38
  if (delta < 0) {
39
39
  rowElements.reverse();
40
40
  }
41
41
  for (const element of rowElements) {
42
- const rowIndex = parseInt((_a = element.getAttribute('aria-rowindex')) !== null && _a !== void 0 ? _a : '');
42
+ const rowIndex = parseInt((_b = element.getAttribute('aria-rowindex')) !== null && _b !== void 0 ? _b : '');
43
43
  targetRow = element;
44
44
  if (rowIndex === targetAriaRowIndex) {
45
45
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/table/table-role/utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAgC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAoB;IACpD,IAAI,OAAO,YAAY,gBAAgB,IAAI,OAAO,YAAY,iBAAiB,EAAE;QAC/E,OAAO,OAAO,CAAC,QAAQ,CAAC;KACzB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAe;IACjD,IAAI,OAAO,GAAmB,MAAM,CAAC;IACrC,OAAO,OAAO,EAAE;QACd,0GAA0G;QAC1G,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE;YACxB,OAAO,KAAK,CAAC;SACd;QACD,IACE,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,QAAQ;YACzC,OAAO,CAAC,YAAY,CAAC,sCAAsC,CAAC,KAAK,MAAM,EACvE;YACA,OAAO,IAAI,CAAC;SACb;QACD,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;KACjC;IACD,OAAO,KAAK,CAAC;AACf,C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,KAAK,kBAAkB,EAAE;YACtC,MAAM;SACP;QACD,IAAI,KAAK,IAAI,CAAC,IAAI,WAAW,GAAG,kBAAkB,EAAE;YAClD,MAAM;SACP;QACD,IAAI,KAAK,GAAG,CAAC,IAAI,WAAW,GAAG,kBAAkB,EAAE;YACjD,MAAM;SACP;KACF;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,OAAO,OAAO,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAA2B;IAC1D,IAAI,OAAO,EAAE;QACX,4FAA4F;QAC5F,4FAA4F;QAC5F,kEAAkE;QAClE,+GAA+G;QAC/G,IAAI,WAAW,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,QAAQ,KAAK,CAAC,EAAE;YAClD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;SACvB;QACD,OAAO,CAAC,KAAK,EAAE,CAAC;KACjB;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function getClosestCell(element: Element) {\n return element.closest('td,th') as null | HTMLTableCellElement;\n}\n\nexport function isElementDisabled(element: HTMLElement) {\n if (element instanceof HTMLInputElement || element instanceof HTMLButtonElement) {\n return element.disabled;\n }\n return false;\n}\n\n/**\n * Returns true if the target element or one of its parents is a dialog or is marked with data-awsui-table-suppress-navigation attribute.\n * This is used to suppress navigation for interactive content without a need to use a custom suppression check.\n */\nexport function defaultIsSuppressed(target: Element) {\n let current: null | Element = target;\n while (current) {\n // Stop checking for parents upon reaching the cell element as the function only aims at the cell content.\n if (isTableCell(current)) {\n return false;\n }\n if (\n current.getAttribute('role') === 'dialog' ||\n current.getAttribute('data-awsui-table-suppress-navigation') === 'true'\n ) {\n return true;\n }\n current = current.parentElement;\n }\n return false;\n}\n\n/**\n * Finds the closest row to the targetAriaRowIndex+delta in the direction of delta.\n */\nexport function findTableRowByAriaRowIndex(table: HTMLTableElement, targetAriaRowIndex: number, delta: number) {\n let targetRow: null | HTMLTableRowElement = null;\n const rowElements = Array.from(table.querySelectorAll('tr[aria-rowindex]'));\n if (delta < 0) {\n rowElements.reverse();\n }\n for (const element of rowElements) {\n const rowIndex = parseInt(element.getAttribute('aria-rowindex') ?? '');\n targetRow = element as HTMLTableRowElement;\n\n if (rowIndex === targetAriaRowIndex) {\n break;\n }\n if (delta >= 0 && rowIndex > targetAriaRowIndex) {\n break;\n }\n if (delta < 0 && rowIndex < targetAriaRowIndex) {\n break;\n }\n }\n return targetRow;\n}\n\n/**\n * Finds the closest column to the targetAriaColIndex+delta in the direction of delta.\n */\nexport function findTableRowCellByAriaColIndex(\n tableRow: HTMLTableRowElement,\n targetAriaColIndex: number,\n delta: number\n) {\n let targetCell: null | HTMLTableCellElement = null;\n const cellElements = Array.from(tableRow.querySelectorAll('td[aria-colindex],th[aria-colindex]'));\n if (delta < 0) {\n cellElements.reverse();\n }\n for (const element of cellElements) {\n const columnIndex = parseInt(element.getAttribute('aria-colindex') ?? '');\n targetCell = element as HTMLTableCellElement;\n\n if (columnIndex === targetAriaColIndex) {\n break;\n }\n if (delta >= 0 && columnIndex > targetAriaColIndex) {\n break;\n }\n if (delta < 0 && columnIndex < targetAriaColIndex) {\n break;\n }\n }\n return targetCell;\n}\n\nexport function isTableCell(element: Element) {\n return element.tagName === 'TD' || element.tagName === 'TH';\n}\n\nexport function focusNextElement(element: null | HTMLElement) {\n if (element) {\n // Table cells are not focusable by default (tabIndex=undefined) so cell.focus() is ignored.\n // To force focusing we have to imperatively set tabIndex to -1. This tabIndex is then to be\n // overridden by the single tab stop context to be 0 or undefined.\n // We cannot make cells have tabIndex=-1 by default due to an associated bug with text selection, see: PR 2158.\n if (isTableCell(element) && element.tabIndex !== 0) {\n element.tabIndex = -1;\n }\n element.focus();\n }\n}\n"]}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MAAM,UAAU,gBAAgB,CAAC,OAA2B;IAC1D,IAAI,OAAO,EAAE;QACX,4FAA4F;QAC5F,4FAA4F;QAC5F,kEAAkE;QAClE,+GAA+G;QAC/G,IAAI,WAAW,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,QAAQ,KAAK,CAAC,EAAE;YAClD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;SACvB;QACD,OAAO,CAAC,KAAK,EAAE,CAAC;KACjB;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function getClosestCell(element: Element) {\n return element.closest('td,th') as null | HTMLTableCellElement;\n}\n\nexport function isElementDisabled(element: HTMLElement) {\n if (element instanceof HTMLInputElement || element instanceof HTMLButtonElement) {\n return element.disabled;\n }\n return false;\n}\n\n/**\n * Returns true if the target element or one of its parents is a dialog or is marked with data-awsui-table-suppress-navigation attribute.\n * This is used to suppress navigation for interactive content without a need to use a custom suppression check.\n */\nexport function defaultIsSuppressed(target: Element) {\n let current: null | Element = target;\n while (current) {\n // Stop checking for parents upon reaching the cell element as the function only aims at the cell content.\n if (isTableCell(current)) {\n return false;\n }\n if (\n current.getAttribute('role') === 'dialog' ||\n current.getAttribute('data-awsui-table-suppress-navigation') === 'true'\n ) {\n return true;\n }\n current = current.parentElement;\n }\n return false;\n}\n\n/**\n * Finds the closest row to the targetAriaRowIndex+delta in the direction of delta.\n */\nexport function findTableRowByAriaRowIndex(table: null | HTMLTableElement, targetAriaRowIndex: number, delta: number) {\n let targetRow: null | HTMLTableRowElement = null;\n const rowElements = Array.from(table?.querySelectorAll('tr[aria-rowindex]') ?? []);\n if (delta < 0) {\n rowElements.reverse();\n }\n for (const element of rowElements) {\n const rowIndex = parseInt(element.getAttribute('aria-rowindex') ?? '');\n targetRow = element as HTMLTableRowElement;\n\n if (rowIndex === targetAriaRowIndex) {\n break;\n }\n if (delta >= 0 && rowIndex > targetAriaRowIndex) {\n break;\n }\n if (delta < 0 && rowIndex < targetAriaRowIndex) {\n break;\n }\n }\n return targetRow;\n}\n\n/**\n * Finds the closest column to the targetAriaColIndex+delta in the direction of delta.\n */\nexport function findTableRowCellByAriaColIndex(\n tableRow: HTMLTableRowElement,\n targetAriaColIndex: number,\n delta: number\n) {\n let targetCell: null | HTMLTableCellElement = null;\n const cellElements = Array.from(tableRow.querySelectorAll('td[aria-colindex],th[aria-colindex]'));\n if (delta < 0) {\n cellElements.reverse();\n }\n for (const element of cellElements) {\n const columnIndex = parseInt(element.getAttribute('aria-colindex') ?? '');\n targetCell = element as HTMLTableCellElement;\n\n if (columnIndex === targetAriaColIndex) {\n break;\n }\n if (delta >= 0 && columnIndex > targetAriaColIndex) {\n break;\n }\n if (delta < 0 && columnIndex < targetAriaColIndex) {\n break;\n }\n }\n return targetCell;\n}\n\nexport function isTableCell(element: Element) {\n return element.tagName === 'TD' || element.tagName === 'TH';\n}\n\nexport function focusNextElement(element: null | HTMLElement) {\n if (element) {\n // Table cells are not focusable by default (tabIndex=undefined) so cell.focus() is ignored.\n // To force focusing we have to imperatively set tabIndex to -1. This tabIndex is then to be\n // overridden by the single tab stop context to be 0 or undefined.\n // We cannot make cells have tabIndex=-1 by default due to an associated bug with text selection, see: PR 2158.\n if (isTableCell(element) && element.tabIndex !== 0) {\n element.tabIndex = -1;\n }\n element.focus();\n }\n}\n"]}