@cloudscape-design/components 3.0.1307 → 3.0.1309

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 (187) hide show
  1. package/app-layout/visual-refresh-toolbar/drawer/global-ai-drawer.d.ts.map +1 -1
  2. package/app-layout/visual-refresh-toolbar/drawer/global-ai-drawer.js +4 -2
  3. package/app-layout/visual-refresh-toolbar/drawer/global-ai-drawer.js.map +1 -1
  4. package/app-layout/visual-refresh-toolbar/drawer/global-bottom-drawer.d.ts.map +1 -1
  5. package/app-layout/visual-refresh-toolbar/drawer/global-bottom-drawer.js +4 -2
  6. package/app-layout/visual-refresh-toolbar/drawer/global-bottom-drawer.js.map +1 -1
  7. package/app-layout/visual-refresh-toolbar/drawer/global-drawer.d.ts.map +1 -1
  8. package/app-layout/visual-refresh-toolbar/drawer/global-drawer.js +3 -2
  9. package/app-layout/visual-refresh-toolbar/drawer/global-drawer.js.map +1 -1
  10. package/app-layout/visual-refresh-toolbar/drawer/local-drawer.d.ts.map +1 -1
  11. package/app-layout/visual-refresh-toolbar/drawer/local-drawer.js +2 -2
  12. package/app-layout/visual-refresh-toolbar/drawer/local-drawer.js.map +1 -1
  13. package/app-layout/visual-refresh-toolbar/interfaces.d.ts +1 -0
  14. package/app-layout/visual-refresh-toolbar/interfaces.d.ts.map +1 -1
  15. package/app-layout/visual-refresh-toolbar/interfaces.js.map +1 -1
  16. package/app-layout/visual-refresh-toolbar/state/use-app-layout.d.ts.map +1 -1
  17. package/app-layout/visual-refresh-toolbar/state/use-app-layout.js +12 -1
  18. package/app-layout/visual-refresh-toolbar/state/use-app-layout.js.map +1 -1
  19. package/badge/styles.css.js +10 -10
  20. package/badge/styles.scoped.css +29 -16
  21. package/badge/styles.selectors.js +10 -10
  22. package/collection-preferences/content-display/content-display-option.js +1 -1
  23. package/collection-preferences/content-display/content-display-option.js.map +1 -1
  24. package/collection-preferences/content-display/index.d.ts +3 -7
  25. package/collection-preferences/content-display/index.d.ts.map +1 -1
  26. package/collection-preferences/content-display/index.js +63 -27
  27. package/collection-preferences/content-display/index.js.map +1 -1
  28. package/collection-preferences/content-display/utils.d.ts +41 -2
  29. package/collection-preferences/content-display/utils.d.ts.map +1 -1
  30. package/collection-preferences/content-display/utils.js +107 -13
  31. package/collection-preferences/content-display/utils.js.map +1 -1
  32. package/collection-preferences/index.d.ts.map +1 -1
  33. package/collection-preferences/index.js +2 -2
  34. package/collection-preferences/index.js.map +1 -1
  35. package/collection-preferences/interfaces.d.ts +30 -2
  36. package/collection-preferences/interfaces.d.ts.map +1 -1
  37. package/collection-preferences/interfaces.js.map +1 -1
  38. package/collection-preferences/styles.css.js +38 -36
  39. package/collection-preferences/styles.scoped.css +81 -37
  40. package/collection-preferences/styles.selectors.js +38 -36
  41. package/collection-preferences/utils.d.ts +1 -0
  42. package/collection-preferences/utils.d.ts.map +1 -1
  43. package/collection-preferences/utils.js +14 -0
  44. package/collection-preferences/utils.js.map +1 -1
  45. package/expandable-section/styles.css.js +35 -35
  46. package/expandable-section/styles.scoped.css +68 -68
  47. package/expandable-section/styles.selectors.js +35 -35
  48. package/i18n/messages/all.all.js +1 -1
  49. package/i18n/messages/all.all.json +1 -1
  50. package/i18n/messages/all.en.js +1 -1
  51. package/i18n/messages/all.en.json +1 -1
  52. package/i18n/messages-types.d.ts +4 -0
  53. package/i18n/messages-types.d.ts.map +1 -1
  54. package/i18n/messages-types.js.map +1 -1
  55. package/icon/interfaces.d.ts +1 -1
  56. package/icon/interfaces.d.ts.map +1 -1
  57. package/icon/interfaces.js.map +1 -1
  58. package/icon/internal.js +2 -2
  59. package/icon/internal.js.map +1 -1
  60. package/icon/styles.css.js +41 -39
  61. package/icon/styles.scoped.css +104 -85
  62. package/icon/styles.selectors.js +41 -39
  63. package/internal/base-component/styles.scoped.css +35 -3
  64. package/internal/environment.js +2 -2
  65. package/internal/environment.json +2 -2
  66. package/internal/generated/styles/tokens.d.ts +23 -1
  67. package/internal/generated/styles/tokens.js +23 -1
  68. package/internal/generated/theming/index.cjs +476 -4
  69. package/internal/generated/theming/index.cjs.d.ts +216 -0
  70. package/internal/generated/theming/index.d.ts +216 -0
  71. package/internal/generated/theming/index.js +476 -4
  72. package/internal/hooks/use-width-change/index.d.ts +12 -0
  73. package/internal/hooks/use-width-change/index.d.ts.map +1 -0
  74. package/internal/hooks/use-width-change/index.js +33 -0
  75. package/internal/hooks/use-width-change/index.js.map +1 -0
  76. package/internal/manifest.json +1 -1
  77. package/manifest.json +2 -2
  78. package/package.json +1 -1
  79. package/pagination/internal.d.ts.map +1 -1
  80. package/pagination/internal.js +4 -1
  81. package/pagination/internal.js.map +1 -1
  82. package/prompt-input/internal.d.ts.map +1 -1
  83. package/prompt-input/internal.js +9 -2
  84. package/prompt-input/internal.js.map +1 -1
  85. package/prompt-input/tokens/use-token-mode.d.ts.map +1 -1
  86. package/prompt-input/tokens/use-token-mode.js +0 -9
  87. package/prompt-input/tokens/use-token-mode.js.map +1 -1
  88. package/table/column-groups/col-group.d.ts +12 -0
  89. package/table/column-groups/col-group.d.ts.map +1 -0
  90. package/table/column-groups/col-group.js +24 -0
  91. package/table/column-groups/col-group.js.map +1 -0
  92. package/table/column-groups/split-utils.d.ts +31 -0
  93. package/table/column-groups/split-utils.d.ts.map +1 -0
  94. package/table/column-groups/split-utils.js +43 -0
  95. package/table/column-groups/split-utils.js.map +1 -0
  96. package/table/column-groups/use-column-groups.d.ts +7 -0
  97. package/table/column-groups/use-column-groups.d.ts.map +1 -0
  98. package/table/column-groups/use-column-groups.js +23 -0
  99. package/table/column-groups/use-column-groups.js.map +1 -0
  100. package/table/column-groups/utils.d.ts +54 -0
  101. package/table/column-groups/utils.d.ts.map +1 -0
  102. package/table/column-groups/utils.js +204 -0
  103. package/table/column-groups/utils.js.map +1 -0
  104. package/table/header-cell/common-props.d.ts +23 -0
  105. package/table/header-cell/common-props.d.ts.map +1 -0
  106. package/table/header-cell/common-props.js +4 -0
  107. package/table/header-cell/common-props.js.map +1 -0
  108. package/table/header-cell/group-header-cell.d.ts +45 -0
  109. package/table/header-cell/group-header-cell.d.ts.map +1 -0
  110. package/table/header-cell/group-header-cell.js +44 -0
  111. package/table/header-cell/group-header-cell.js.map +1 -0
  112. package/table/header-cell/index.d.ts +12 -22
  113. package/table/header-cell/index.d.ts.map +1 -1
  114. package/table/header-cell/index.js +3 -3
  115. package/table/header-cell/index.js.map +1 -1
  116. package/table/header-cell/styles.css.js +33 -30
  117. package/table/header-cell/styles.scoped.css +92 -68
  118. package/table/header-cell/styles.selectors.js +33 -30
  119. package/table/header-cell/th-element.d.ts +16 -0
  120. package/table/header-cell/th-element.d.ts.map +1 -1
  121. package/table/header-cell/th-element.js +6 -4
  122. package/table/header-cell/th-element.js.map +1 -1
  123. package/table/index.d.ts.map +1 -1
  124. package/table/index.js +5 -2
  125. package/table/index.js.map +1 -1
  126. package/table/interfaces.d.ts +37 -1
  127. package/table/interfaces.d.ts.map +1 -1
  128. package/table/interfaces.js.map +1 -1
  129. package/table/internal.d.ts.map +1 -1
  130. package/table/internal.js +17 -5
  131. package/table/internal.js.map +1 -1
  132. package/table/resizer/index.d.ts +9 -2
  133. package/table/resizer/index.d.ts.map +1 -1
  134. package/table/resizer/index.js +5 -5
  135. package/table/resizer/index.js.map +1 -1
  136. package/table/resizer/styles.css.js +16 -13
  137. package/table/resizer/styles.scoped.css +36 -26
  138. package/table/resizer/styles.selectors.js +16 -13
  139. package/table/sticky-header.d.ts +3 -0
  140. package/table/sticky-header.d.ts.map +1 -1
  141. package/table/sticky-header.js +7 -2
  142. package/table/sticky-header.js.map +1 -1
  143. package/table/sticky-scrolling.d.ts.map +1 -1
  144. package/table/sticky-scrolling.js +6 -1
  145. package/table/sticky-scrolling.js.map +1 -1
  146. package/table/styles.css.js +35 -34
  147. package/table/styles.scoped.css +47 -41
  148. package/table/styles.selectors.js +35 -34
  149. package/table/table-role/grid-navigation.d.ts.map +1 -1
  150. package/table/table-role/grid-navigation.js +5 -7
  151. package/table/table-role/grid-navigation.js.map +1 -1
  152. package/table/table-role/table-role-helper.d.ts +3 -0
  153. package/table/table-role/table-role-helper.d.ts.map +1 -1
  154. package/table/table-role/table-role-helper.js +9 -4
  155. package/table/table-role/table-role-helper.js.map +1 -1
  156. package/table/table-role/utils.d.ts +19 -0
  157. package/table/table-role/utils.d.ts.map +1 -1
  158. package/table/table-role/utils.js +86 -7
  159. package/table/table-role/utils.js.map +1 -1
  160. package/table/thead.d.ts +5 -0
  161. package/table/thead.d.ts.map +1 -1
  162. package/table/thead.js +145 -18
  163. package/table/thead.js.map +1 -1
  164. package/table/use-column-widths.d.ts +4 -0
  165. package/table/use-column-widths.d.ts.map +1 -1
  166. package/table/use-column-widths.js +68 -18
  167. package/table/use-column-widths.js.map +1 -1
  168. package/table/use-sticky-header.d.ts.map +1 -1
  169. package/table/use-sticky-header.js +4 -1
  170. package/table/use-sticky-header.js.map +1 -1
  171. package/table/utils.d.ts.map +1 -1
  172. package/table/utils.js +14 -4
  173. package/table/utils.js.map +1 -1
  174. package/test-utils/dom/collection-preferences/content-display-preference.d.ts +28 -2
  175. package/test-utils/dom/collection-preferences/content-display-preference.js +60 -2
  176. package/test-utils/dom/collection-preferences/content-display-preference.js.map +1 -1
  177. package/test-utils/dom/table/index.d.ts +18 -1
  178. package/test-utils/dom/table/index.js +22 -3
  179. package/test-utils/dom/table/index.js.map +1 -1
  180. package/test-utils/selectors/collection-preferences/content-display-preference.d.ts +28 -2
  181. package/test-utils/selectors/collection-preferences/content-display-preference.js +52 -2
  182. package/test-utils/selectors/collection-preferences/content-display-preference.js.map +1 -1
  183. package/test-utils/selectors/table/index.d.ts +18 -1
  184. package/test-utils/selectors/table/index.js +22 -3
  185. package/test-utils/selectors/table/index.js.map +1 -1
  186. package/wizard/wizard-step-list.js +4 -4
  187. package/wizard/wizard-step-list.js.map +1 -1
@@ -150,7 +150,7 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
150
150
  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
151
151
  SPDX-License-Identifier: Apache-2.0
152
152
  */
153
- .awsui_root_wih1l_1y83p_153:not(#\9) {
153
+ .awsui_root_wih1l_1ru4o_153:not(#\9) {
154
154
  font-size: var(--font-size-body-m-a7nh2n, 14px);
155
155
  line-height: var(--line-height-body-m-2mh3ke, 20px);
156
156
  color: var(--color-text-body-default-vvtq8u, #0f141a);
@@ -161,7 +161,7 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
161
161
  inline-size: 100%;
162
162
  }
163
163
 
164
- .awsui_tools_wih1l_1y83p_164:not(#\9) {
164
+ .awsui_tools_wih1l_1ru4o_164:not(#\9) {
165
165
  display: flex;
166
166
  align-items: flex-end;
167
167
  flex-wrap: wrap;
@@ -170,64 +170,64 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
170
170
  padding-block-end: var(--space-table-header-tools-bottom-d9u5kf, 0px);
171
171
  padding-inline: 0;
172
172
  }
173
- .awsui_tools-filtering_wih1l_1y83p_173:not(#\9) {
173
+ .awsui_tools-filtering_wih1l_1ru4o_173:not(#\9) {
174
174
  max-inline-size: 100%;
175
175
  }
176
176
  @supports (flex-basis: fit-content) {
177
- .awsui_tools-filtering_wih1l_1y83p_173:not(#\9) {
177
+ .awsui_tools-filtering_wih1l_1ru4o_173:not(#\9) {
178
178
  flex: 1 1 fit-content;
179
179
  }
180
180
  }
181
181
  @supports not (flex-basis: fit-content) {
182
- .awsui_tools-filtering_wih1l_1y83p_173:not(#\9) {
182
+ .awsui_tools-filtering_wih1l_1ru4o_173:not(#\9) {
183
183
  flex: 1 1 auto;
184
184
  }
185
185
  }
186
- .awsui_tools-align-right_wih1l_1y83p_186:not(#\9) {
186
+ .awsui_tools-align-right_wih1l_1ru4o_186:not(#\9) {
187
187
  display: flex;
188
188
  margin-inline-start: auto;
189
189
  }
190
- .awsui_tools-pagination_wih1l_1y83p_190 + .awsui_tools-preferences_wih1l_1y83p_190:not(#\9) {
190
+ .awsui_tools-pagination_wih1l_1ru4o_190 + .awsui_tools-preferences_wih1l_1ru4o_190:not(#\9) {
191
191
  border-inline-start: var(--border-divider-section-width-uwo8my, 1px) solid var(--color-border-divider-default-nr68jt, #c6c6cd);
192
192
  box-sizing: border-box;
193
193
  margin-inline-start: var(--space-xs-ymlm0b, 8px);
194
194
  padding-inline-start: var(--space-xs-ymlm0b, 8px);
195
195
  }
196
- .awsui_tools-small_wih1l_1y83p_196 > .awsui_tools-filtering_wih1l_1y83p_173:not(#\9) {
196
+ .awsui_tools-small_wih1l_1ru4o_196 > .awsui_tools-filtering_wih1l_1ru4o_173:not(#\9) {
197
197
  flex-basis: 100%;
198
198
  }
199
199
 
200
- .awsui_table_wih1l_1y83p_200:not(#\9) {
200
+ .awsui_table_wih1l_1ru4o_200:not(#\9) {
201
201
  inline-size: 100%;
202
202
  border-spacing: 0;
203
203
  position: relative;
204
204
  box-sizing: border-box;
205
205
  }
206
- .awsui_table-layout-fixed_wih1l_1y83p_206:not(#\9) {
206
+ .awsui_table-layout-fixed_wih1l_1ru4o_206:not(#\9) {
207
207
  table-layout: fixed;
208
208
  }
209
209
 
210
- .awsui_wrapper_wih1l_1y83p_210:not(#\9) {
210
+ .awsui_wrapper_wih1l_1ru4o_210:not(#\9) {
211
211
  position: relative;
212
212
  box-sizing: border-box;
213
213
  inline-size: 100%;
214
214
  overflow-x: auto;
215
215
  scrollbar-width: none; /* Hide scrollbar in Firefox */
216
216
  }
217
- .awsui_wrapper_wih1l_1y83p_210.awsui_variant-stacked_wih1l_1y83p_217 > .awsui_table_wih1l_1y83p_200:not(#\9), .awsui_wrapper_wih1l_1y83p_210.awsui_variant-stacked_wih1l_1y83p_217 > .awsui_wrapper-content-measure_wih1l_1y83p_217:not(#\9), .awsui_wrapper_wih1l_1y83p_210.awsui_variant-container_wih1l_1y83p_217 > .awsui_table_wih1l_1y83p_200:not(#\9), .awsui_wrapper_wih1l_1y83p_210.awsui_variant-container_wih1l_1y83p_217 > .awsui_wrapper-content-measure_wih1l_1y83p_217:not(#\9) {
217
+ .awsui_wrapper_wih1l_1ru4o_210.awsui_variant-stacked_wih1l_1ru4o_217 > .awsui_table_wih1l_1ru4o_200:not(#\9), .awsui_wrapper_wih1l_1ru4o_210.awsui_variant-stacked_wih1l_1ru4o_217 > .awsui_wrapper-content-measure_wih1l_1ru4o_217:not(#\9), .awsui_wrapper_wih1l_1ru4o_210.awsui_variant-container_wih1l_1ru4o_217 > .awsui_table_wih1l_1ru4o_200:not(#\9), .awsui_wrapper_wih1l_1ru4o_210.awsui_variant-container_wih1l_1ru4o_217 > .awsui_wrapper-content-measure_wih1l_1ru4o_217:not(#\9) {
218
218
  padding-inline: var(--space-table-horizontal-suurzj, 20px);
219
219
  }
220
- .awsui_wrapper_wih1l_1y83p_210.awsui_variant-stacked_wih1l_1y83p_217:not(#\9):not(.awsui_has-footer_wih1l_1y83p_220), .awsui_wrapper_wih1l_1y83p_210.awsui_variant-container_wih1l_1y83p_217:not(#\9):not(.awsui_has-footer_wih1l_1y83p_220) {
220
+ .awsui_wrapper_wih1l_1ru4o_210.awsui_variant-stacked_wih1l_1ru4o_217:not(#\9):not(.awsui_has-footer_wih1l_1ru4o_220), .awsui_wrapper_wih1l_1ru4o_210.awsui_variant-container_wih1l_1ru4o_217:not(#\9):not(.awsui_has-footer_wih1l_1ru4o_220) {
221
221
  padding-block-end: var(--space-table-content-bottom-tlfqmq, 4px);
222
222
  }
223
- .awsui_wrapper_wih1l_1y83p_210:not(#\9):not(.awsui_has-header_wih1l_1y83p_223) {
223
+ .awsui_wrapper_wih1l_1ru4o_210:not(#\9):not(.awsui_has-header_wih1l_1ru4o_223) {
224
224
  border-start-end-radius: var(--border-radius-container-nsfwmm, 16px);
225
225
  border-start-start-radius: var(--border-radius-container-nsfwmm, 16px);
226
226
  }
227
- .awsui_wrapper_wih1l_1y83p_210:not(#\9)::-webkit-scrollbar {
227
+ .awsui_wrapper_wih1l_1ru4o_210:not(#\9)::-webkit-scrollbar {
228
228
  display: none; /* Hide scrollbar in Safari and Chrome */
229
229
  }
230
- body[data-awsui-focus-visible=true] .awsui_wrapper_wih1l_1y83p_210:not(#\9):focus {
230
+ body[data-awsui-focus-visible=true] .awsui_wrapper_wih1l_1ru4o_210:not(#\9):focus {
231
231
  outline: 2px dotted transparent;
232
232
  outline-offset: 2px;
233
233
  border-start-start-radius: var(--border-radius-container-nsfwmm, 16px);
@@ -237,19 +237,19 @@ body[data-awsui-focus-visible=true] .awsui_wrapper_wih1l_1y83p_210:not(#\9):focu
237
237
  box-shadow: 0 0 0 2px var(--color-border-item-focused-uk47pl, #006ce0);
238
238
  }
239
239
 
240
- .awsui_cell-merged_wih1l_1y83p_240:not(#\9) {
240
+ .awsui_cell-merged_wih1l_1ru4o_240:not(#\9) {
241
241
  text-align: center;
242
242
  padding-block: 0;
243
243
  padding-inline: 0;
244
244
  }
245
- .awsui_cell-merged_wih1l_1y83p_240.awsui_has-footer_wih1l_1y83p_220:not(#\9) {
245
+ .awsui_cell-merged_wih1l_1ru4o_240.awsui_has-footer_wih1l_1ru4o_220:not(#\9) {
246
246
  /*
247
247
  Add a bottom border to the body cell of an empty table as a separator between the
248
248
  table and the footer
249
249
  */
250
250
  border-block-end: var(--border-divider-section-width-uwo8my, 1px) solid var(--color-border-divider-default-nr68jt, #c6c6cd);
251
251
  }
252
- .awsui_cell-merged-content_wih1l_1y83p_252:not(#\9) {
252
+ .awsui_cell-merged-content_wih1l_1ru4o_252:not(#\9) {
253
253
  box-sizing: border-box;
254
254
  inline-size: 100%;
255
255
  padding-block-start: var(--space-scaled-m-m892r9, 16px);
@@ -257,7 +257,7 @@ body[data-awsui-focus-visible=true] .awsui_wrapper_wih1l_1y83p_210:not(#\9):focu
257
257
  padding-inline: var(--space-l-2ud1p3, 20px);
258
258
  }
259
259
  @supports (position: sticky) {
260
- .awsui_cell-merged-content_wih1l_1y83p_252:not(#\9) {
260
+ .awsui_cell-merged-content_wih1l_1ru4o_252:not(#\9) {
261
261
  position: sticky;
262
262
  inset-inline-start: 0;
263
263
  margin-block: 0;
@@ -265,11 +265,11 @@ body[data-awsui-focus-visible=true] .awsui_wrapper_wih1l_1y83p_210:not(#\9):focu
265
265
  }
266
266
  }
267
267
 
268
- .awsui_empty_wih1l_1y83p_268:not(#\9) {
268
+ .awsui_empty_wih1l_1ru4o_268:not(#\9) {
269
269
  color: var(--color-text-empty-tlohug, #656871);
270
270
  }
271
271
 
272
- .awsui_loading_wih1l_1y83p_272:not(#\9) {
272
+ .awsui_loading_wih1l_1ru4o_272:not(#\9) {
273
273
  /* used in test-utils */
274
274
  }
275
275
 
@@ -278,20 +278,26 @@ The min/max/width token values in Visual Refresh should align
278
278
  the table header and body cells selection control with the table
279
279
  filter search icon.
280
280
  */
281
- .awsui_selection-control_wih1l_1y83p_281:not(#\9) {
281
+ .awsui_selection-control_wih1l_1ru4o_281:not(#\9) {
282
282
  box-sizing: border-box;
283
283
  max-inline-size: var(--size-table-selection-horizontal-qqiajd, 40px);
284
284
  min-inline-size: var(--size-table-selection-horizontal-qqiajd, 40px);
285
285
  position: relative;
286
286
  inline-size: var(--size-table-selection-horizontal-qqiajd, 40px);
287
287
  }
288
- .awsui_selection-control_wih1l_1y83p_281.awsui_selection-control-header_wih1l_1y83p_288:not(#\9) {
288
+ .awsui_selection-control_wih1l_1ru4o_281.awsui_selection-control-header_wih1l_1ru4o_288:not(#\9) {
289
289
  padding-block: var(--space-scaled-xs-xwoogq, 8px);
290
290
  padding-inline: var(--space-scaled-l-sej05l, 20px);
291
291
  border-inline-start: var(--border-width-item-selected-yv93vd, 2px) solid transparent;
292
292
  }
293
+ .awsui_selection-control-content-spans-rows_wih1l_1ru4o_293:not(#\9) {
294
+ display: flex;
295
+ flex-direction: column;
296
+ justify-content: flex-end;
297
+ block-size: 100%;
298
+ }
293
299
 
294
- .awsui_header-secondary_wih1l_1y83p_294:not(#\9) {
300
+ .awsui_header-secondary_wih1l_1ru4o_300:not(#\9) {
295
301
  overflow: auto;
296
302
  scrollbar-width: none; /* Firefox */
297
303
  box-sizing: border-box;
@@ -302,46 +308,46 @@ filter search icon.
302
308
  border-end-end-radius: 0;
303
309
  background: var(--color-background-table-header-hdjxos, #ffffff);
304
310
  }
305
- .awsui_header-secondary_wih1l_1y83p_294.awsui_variant-full-page_wih1l_1y83p_305:not(#\9) {
311
+ .awsui_header-secondary_wih1l_1ru4o_300.awsui_variant-full-page_wih1l_1ru4o_311:not(#\9) {
306
312
  background: var(--color-background-layout-main-5ilwcb, #ffffff);
307
313
  }
308
- .awsui_header-secondary_wih1l_1y83p_294.awsui_variant-stacked_wih1l_1y83p_217 > .awsui_table_wih1l_1y83p_200:not(#\9), .awsui_header-secondary_wih1l_1y83p_294.awsui_variant-container_wih1l_1y83p_217 > .awsui_table_wih1l_1y83p_200:not(#\9) {
314
+ .awsui_header-secondary_wih1l_1ru4o_300.awsui_variant-stacked_wih1l_1ru4o_217 > .awsui_table_wih1l_1ru4o_200:not(#\9), .awsui_header-secondary_wih1l_1ru4o_300.awsui_variant-container_wih1l_1ru4o_217 > .awsui_table_wih1l_1ru4o_200:not(#\9) {
309
315
  padding-inline: var(--space-table-horizontal-suurzj, 20px);
310
316
  }
311
- .awsui_header-secondary_wih1l_1y83p_294.awsui_variant-stacked_wih1l_1y83p_217:not(#\9):not(.awsui_table-has-header_wih1l_1y83p_311), .awsui_header-secondary_wih1l_1y83p_294.awsui_variant-container_wih1l_1y83p_217:not(#\9):not(.awsui_table-has-header_wih1l_1y83p_311) {
317
+ .awsui_header-secondary_wih1l_1ru4o_300.awsui_variant-stacked_wih1l_1ru4o_217:not(#\9):not(.awsui_table-has-header_wih1l_1ru4o_317), .awsui_header-secondary_wih1l_1ru4o_300.awsui_variant-container_wih1l_1ru4o_217:not(#\9):not(.awsui_table-has-header_wih1l_1ru4o_317) {
312
318
  border-start-start-radius: var(--border-radius-container-nsfwmm, 16px);
313
319
  border-start-end-radius: var(--border-radius-container-nsfwmm, 16px);
314
320
  }
315
- .awsui_header-secondary_wih1l_1y83p_294:not(#\9)::-webkit-scrollbar {
321
+ .awsui_header-secondary_wih1l_1ru4o_300:not(#\9)::-webkit-scrollbar {
316
322
  display: none; /* Safari and Chrome */
317
323
  }
318
- .awsui_header-secondary_wih1l_1y83p_294.awsui_table-has-header_wih1l_1y83p_311:not(#\9) {
324
+ .awsui_header-secondary_wih1l_1ru4o_300.awsui_table-has-header_wih1l_1ru4o_317:not(#\9) {
319
325
  border-block-start: var(--border-divider-list-width-tdfx1x, 1px) solid var(--color-border-container-divider-9huz1a, transparent);
320
326
  }
321
327
 
322
- .awsui_header-controls_wih1l_1y83p_322:not(#\9) {
328
+ .awsui_header-controls_wih1l_1ru4o_328:not(#\9) {
323
329
  padding-block: var(--space-container-header-top-am4vzw, 12px) var(--space-container-header-bottom-2taq8v, 8px);
324
330
  }
325
- .awsui_header-controls_wih1l_1y83p_322.awsui_variant-full-page_wih1l_1y83p_305:not(#\9) {
331
+ .awsui_header-controls_wih1l_1ru4o_328.awsui_variant-full-page_wih1l_1ru4o_311:not(#\9) {
326
332
  padding-block: 0 calc(var(--space-container-header-bottom-2taq8v, 8px) + var(--space-table-header-tools-full-page-bottom-9m47g6, 4px));
327
333
  }
328
- .awsui_header-controls_wih1l_1y83p_322.awsui_variant-stacked_wih1l_1y83p_217:not(#\9), .awsui_header-controls_wih1l_1y83p_322.awsui_variant-container_wih1l_1y83p_217:not(#\9) {
334
+ .awsui_header-controls_wih1l_1ru4o_328.awsui_variant-stacked_wih1l_1ru4o_217:not(#\9), .awsui_header-controls_wih1l_1ru4o_328.awsui_variant-container_wih1l_1ru4o_217:not(#\9) {
329
335
  padding-inline: calc(var(--space-table-horizontal-suurzj, 20px) + var(--space-table-header-horizontal-kb5ww2, 0px));
330
336
  }
331
- .awsui_header-controls_wih1l_1y83p_322.awsui_variant-embedded_wih1l_1y83p_331:not(#\9), .awsui_header-controls_wih1l_1y83p_322.awsui_variant-borderless_wih1l_1y83p_331:not(#\9) {
337
+ .awsui_header-controls_wih1l_1ru4o_328.awsui_variant-embedded_wih1l_1ru4o_337:not(#\9), .awsui_header-controls_wih1l_1ru4o_328.awsui_variant-borderless_wih1l_1ru4o_337:not(#\9) {
332
338
  padding-inline: var(--space-table-header-horizontal-kb5ww2, 0px);
333
339
  padding-block-start: var(--space-table-embedded-header-top-twu628, 0px);
334
340
  }
335
341
 
336
- .awsui_footer-wrapper_wih1l_1y83p_336.awsui_variant-stacked_wih1l_1y83p_217:not(#\9), .awsui_footer-wrapper_wih1l_1y83p_336.awsui_variant-container_wih1l_1y83p_217:not(#\9) {
342
+ .awsui_footer-wrapper_wih1l_1ru4o_342.awsui_variant-stacked_wih1l_1ru4o_217:not(#\9), .awsui_footer-wrapper_wih1l_1ru4o_342.awsui_variant-container_wih1l_1ru4o_217:not(#\9) {
337
343
  padding-inline: var(--space-table-horizontal-suurzj, 20px);
338
344
  }
339
345
 
340
- .awsui_footer_wih1l_1y83p_336:not(#\9) {
346
+ .awsui_footer_wih1l_1ru4o_342:not(#\9) {
341
347
  padding-block: var(--space-scaled-s-8ozaad, 12px);
342
348
  padding-inline: var(--space-table-footer-horizontal-l5g495, 0px);
343
349
  }
344
- .awsui_footer-with-pagination_wih1l_1y83p_344:not(#\9) {
350
+ .awsui_footer-with-pagination_wih1l_1ru4o_350:not(#\9) {
345
351
  display: flex;
346
352
  flex-direction: row;
347
353
  justify-content: space-between;
@@ -349,12 +355,12 @@ filter search icon.
349
355
  flex-wrap: wrap;
350
356
  gap: var(--space-scaled-s-8ozaad, 12px);
351
357
  }
352
- .awsui_footer-pagination_wih1l_1y83p_352:not(#\9) {
358
+ .awsui_footer-pagination_wih1l_1ru4o_358:not(#\9) {
353
359
  margin-inline-start: auto;
354
360
  }
355
361
 
356
- .awsui_thead-active_wih1l_1y83p_356:not(#\9),
357
- .awsui_row_wih1l_1y83p_357:not(#\9),
358
- .awsui_row-selected_wih1l_1y83p_358:not(#\9) {
362
+ .awsui_thead-active_wih1l_1ru4o_362:not(#\9),
363
+ .awsui_row_wih1l_1ru4o_363:not(#\9),
364
+ .awsui_row-selected_wih1l_1ru4o_364:not(#\9) {
359
365
  /* used in test-utils */
360
366
  }
@@ -2,39 +2,40 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "root": "awsui_root_wih1l_1y83p_153",
6
- "tools": "awsui_tools_wih1l_1y83p_164",
7
- "tools-filtering": "awsui_tools-filtering_wih1l_1y83p_173",
8
- "tools-align-right": "awsui_tools-align-right_wih1l_1y83p_186",
9
- "tools-pagination": "awsui_tools-pagination_wih1l_1y83p_190",
10
- "tools-preferences": "awsui_tools-preferences_wih1l_1y83p_190",
11
- "tools-small": "awsui_tools-small_wih1l_1y83p_196",
12
- "table": "awsui_table_wih1l_1y83p_200",
13
- "table-layout-fixed": "awsui_table-layout-fixed_wih1l_1y83p_206",
14
- "wrapper": "awsui_wrapper_wih1l_1y83p_210",
15
- "variant-stacked": "awsui_variant-stacked_wih1l_1y83p_217",
16
- "wrapper-content-measure": "awsui_wrapper-content-measure_wih1l_1y83p_217",
17
- "variant-container": "awsui_variant-container_wih1l_1y83p_217",
18
- "has-footer": "awsui_has-footer_wih1l_1y83p_220",
19
- "has-header": "awsui_has-header_wih1l_1y83p_223",
20
- "cell-merged": "awsui_cell-merged_wih1l_1y83p_240",
21
- "cell-merged-content": "awsui_cell-merged-content_wih1l_1y83p_252",
22
- "empty": "awsui_empty_wih1l_1y83p_268",
23
- "loading": "awsui_loading_wih1l_1y83p_272",
24
- "selection-control": "awsui_selection-control_wih1l_1y83p_281",
25
- "selection-control-header": "awsui_selection-control-header_wih1l_1y83p_288",
26
- "header-secondary": "awsui_header-secondary_wih1l_1y83p_294",
27
- "variant-full-page": "awsui_variant-full-page_wih1l_1y83p_305",
28
- "table-has-header": "awsui_table-has-header_wih1l_1y83p_311",
29
- "header-controls": "awsui_header-controls_wih1l_1y83p_322",
30
- "variant-embedded": "awsui_variant-embedded_wih1l_1y83p_331",
31
- "variant-borderless": "awsui_variant-borderless_wih1l_1y83p_331",
32
- "footer-wrapper": "awsui_footer-wrapper_wih1l_1y83p_336",
33
- "footer": "awsui_footer_wih1l_1y83p_336",
34
- "footer-with-pagination": "awsui_footer-with-pagination_wih1l_1y83p_344",
35
- "footer-pagination": "awsui_footer-pagination_wih1l_1y83p_352",
36
- "thead-active": "awsui_thead-active_wih1l_1y83p_356",
37
- "row": "awsui_row_wih1l_1y83p_357",
38
- "row-selected": "awsui_row-selected_wih1l_1y83p_358"
5
+ "root": "awsui_root_wih1l_1ru4o_153",
6
+ "tools": "awsui_tools_wih1l_1ru4o_164",
7
+ "tools-filtering": "awsui_tools-filtering_wih1l_1ru4o_173",
8
+ "tools-align-right": "awsui_tools-align-right_wih1l_1ru4o_186",
9
+ "tools-pagination": "awsui_tools-pagination_wih1l_1ru4o_190",
10
+ "tools-preferences": "awsui_tools-preferences_wih1l_1ru4o_190",
11
+ "tools-small": "awsui_tools-small_wih1l_1ru4o_196",
12
+ "table": "awsui_table_wih1l_1ru4o_200",
13
+ "table-layout-fixed": "awsui_table-layout-fixed_wih1l_1ru4o_206",
14
+ "wrapper": "awsui_wrapper_wih1l_1ru4o_210",
15
+ "variant-stacked": "awsui_variant-stacked_wih1l_1ru4o_217",
16
+ "wrapper-content-measure": "awsui_wrapper-content-measure_wih1l_1ru4o_217",
17
+ "variant-container": "awsui_variant-container_wih1l_1ru4o_217",
18
+ "has-footer": "awsui_has-footer_wih1l_1ru4o_220",
19
+ "has-header": "awsui_has-header_wih1l_1ru4o_223",
20
+ "cell-merged": "awsui_cell-merged_wih1l_1ru4o_240",
21
+ "cell-merged-content": "awsui_cell-merged-content_wih1l_1ru4o_252",
22
+ "empty": "awsui_empty_wih1l_1ru4o_268",
23
+ "loading": "awsui_loading_wih1l_1ru4o_272",
24
+ "selection-control": "awsui_selection-control_wih1l_1ru4o_281",
25
+ "selection-control-header": "awsui_selection-control-header_wih1l_1ru4o_288",
26
+ "selection-control-content-spans-rows": "awsui_selection-control-content-spans-rows_wih1l_1ru4o_293",
27
+ "header-secondary": "awsui_header-secondary_wih1l_1ru4o_300",
28
+ "variant-full-page": "awsui_variant-full-page_wih1l_1ru4o_311",
29
+ "table-has-header": "awsui_table-has-header_wih1l_1ru4o_317",
30
+ "header-controls": "awsui_header-controls_wih1l_1ru4o_328",
31
+ "variant-embedded": "awsui_variant-embedded_wih1l_1ru4o_337",
32
+ "variant-borderless": "awsui_variant-borderless_wih1l_1ru4o_337",
33
+ "footer-wrapper": "awsui_footer-wrapper_wih1l_1ru4o_342",
34
+ "footer": "awsui_footer_wih1l_1ru4o_342",
35
+ "footer-with-pagination": "awsui_footer-with-pagination_wih1l_1ru4o_350",
36
+ "footer-pagination": "awsui_footer-pagination_wih1l_1ru4o_358",
37
+ "thead-active": "awsui_thead-active_wih1l_1ru4o_362",
38
+ "row": "awsui_row_wih1l_1ru4o_363",
39
+ "row-selected": "awsui_row-selected_wih1l_1ru4o_364"
39
40
  };
40
41
 
@@ -1 +1 @@
1
- {"version":3,"file":"grid-navigation.d.ts","sourceRoot":"","sources":["../../../../src/table/table-role/grid-navigation.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,0BAA0B,EAE3B,MAAM,+CAA+C,CAAC;AAMvD,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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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,GAAI,kBAAkB,WAAW,UAUzD;IAEK,kBAAkB,aAMvB;IAEK,kBAAkB,2BAmBvB;IAEK,mBAAmB,GAAI,SAAS,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;IA6CxB,OAAO,CAAC,iBAAiB;CAI1B"}
@@ -8,7 +8,7 @@ import { getAllFocusables } from '../../internal/components/focus-lock/utils';
8
8
  import { KeyCode } from '../../internal/keycode';
9
9
  import handleKey, { isEventLike } from '../../internal/utils/handle-key';
10
10
  import { nodeBelongs } from '../../internal/utils/node-belongs';
11
- import { defaultIsSuppressed, findTableRowByAriaRowIndex, findTableRowCellByAriaColIndex, focusNextElement, getClosestCell, isElementDisabled, isTableCell, } from './utils';
11
+ import { defaultIsSuppressed, findNextCell, findTableRowByAriaRowIndex, focusNextElement, getClosestCell, isElementDisabled, isTableCell, } from './utils';
12
12
  /**
13
13
  * Makes table navigable with keyboard commands.
14
14
  * See grid-navigation.md
@@ -259,16 +259,14 @@ export class GridNavigationProcessor {
259
259
  if (isValidDirection && isValidIndex && isTargetDifferent) {
260
260
  return cellFocusables[nextElementIndex];
261
261
  }
262
- // Find next cell to focus or move focus into (can be null if the left/right edge is reached).
262
+ // Find next cell to focus or move focus into.
263
263
  const targetAriaColIndex = from.colIndex + delta.x;
264
- const targetCell = findTableRowCellByAriaColIndex(targetRow, targetAriaColIndex, delta.x);
264
+ const targetCell = this.table
265
+ ? findNextCell(this.table, targetRow, targetAriaColIndex, delta, cellElement)
266
+ : null;
265
267
  if (!targetCell) {
266
268
  return null;
267
269
  }
268
- // When target cell matches the current cell it means we reached the left or right boundary.
269
- if (targetCell === cellElement && delta.x !== 0) {
270
- return null;
271
- }
272
270
  const targetCellFocusables = this.getFocusablesFrom(targetCell);
273
271
  // When delta.x = 0 keep element index if possible.
274
272
  let focusIndex = from.elementIndex;
@@ -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;AAClF,OAAO,EAEL,+BAA+B,GAChC,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,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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from 'react';\nimport { useEffect, useMemo } from 'react';\n\nimport { useStableCallback } from '@cloudscape-design/component-toolkit/internal';\nimport {\n SingleTabStopNavigationAPI,\n SingleTabStopNavigationProvider,\n} from '@cloudscape-design/component-toolkit/internal';\n\nimport { getAllFocusables } from '../../internal/components/focus-lock/utils';\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"]}
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;AAClF,OAAO,EAEL,+BAA+B,GAChC,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,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,YAAY,EACZ,0BAA0B,EAC1B,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;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ACd,CAAC;QAED,MAAM,oBAAoB,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAEhE,mDAAmD;QACnD,IAAI,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC;QACnC,uEAAuE;QACvE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YAChE,UAAU,GAAG,CAAC,CAAC;QACjB,CAAC;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,CAAC;YAC/D,UAAU,GAAG,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/C,CAAC;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';\nimport {\n SingleTabStopNavigationAPI,\n SingleTabStopNavigationProvider,\n} from '@cloudscape-design/component-toolkit/internal';\n\nimport { getAllFocusables } from '../../internal/components/focus-lock/utils';\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 findNextCell,\n findTableRowByAriaRowIndex,\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.\n const targetAriaColIndex = from.colIndex + delta.x;\n\n const targetCell = this.table\n ? findNextCell(this.table, targetRow, targetAriaColIndex, delta, cellElement as HTMLTableCellElement | null)\n : null;\n if (!targetCell) {\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"]}
@@ -6,6 +6,7 @@ export declare function getTableRoleProps(options: {
6
6
  ariaLabelledby?: string;
7
7
  totalItemsCount?: number;
8
8
  totalColumnsCount?: number;
9
+ headerRowCount?: number;
9
10
  }): React.TableHTMLAttributes<HTMLTableElement>;
10
11
  export declare function getTableWrapperRoleProps(options: {
11
12
  tableRole: TableRole;
@@ -15,11 +16,13 @@ export declare function getTableWrapperRoleProps(options: {
15
16
  }): import("react").HTMLAttributes<HTMLDivElement>;
16
17
  export declare function getTableHeaderRowRoleProps(options: {
17
18
  tableRole: TableRole;
19
+ rowIndex?: number;
18
20
  }): import("react").HTMLAttributes<HTMLTableRowElement>;
19
21
  export declare function getTableRowRoleProps(options: {
20
22
  tableRole: TableRole;
21
23
  rowIndex: number;
22
24
  firstIndex?: number;
25
+ headerRowCount?: number;
23
26
  level?: number;
24
27
  setSize?: number;
25
28
  posInSet?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"table-role-helper.d.ts","sourceRoot":"","sources":["../../../../src/table/table-role/table-role-helper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,KAAK,aAAa,GAAG,UAAU,GAAG,WAAW,GAAG,YAAY,CAAC;AAa7D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,GAAG,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAyB9C;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CA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wBAAwB,CAAC,OAAO,EAAE;IAChD,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,kDAYA;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,uDAS9F;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAC5C,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,uDAuBA;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE;IAClD,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,0DAcA;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,0DAY/G"}
@@ -10,6 +10,7 @@ const getAriaSort = (sortingState) => stateToAriaSort[sortingState];
10
10
  // ARIA role of the table component ("table", "grid", "treegrid") but also roles and other semantic attributes
11
11
  // of the child elements. The TableRole helper encapsulates table's semantic structure.
12
12
  export function getTableRoleProps(options) {
13
+ var _a;
13
14
  const nativeProps = {};
14
15
  // Browsers have weird mechanism to guess whether it's a data table or a layout table.
15
16
  // If we state explicitly, they get it always correctly even with low number of rows.
@@ -17,8 +18,9 @@ export function getTableRoleProps(options) {
17
18
  nativeProps['aria-label'] = options.ariaLabel;
18
19
  nativeProps['aria-labelledby'] = options.ariaLabelledby;
19
20
  // Incrementing the total count by one to account for the header row.
21
+ const headerRows = (_a = options.headerRowCount) !== null && _a !== void 0 ? _a : 1;
20
22
  if (typeof options.totalItemsCount === 'number' && options.totalItemsCount > 0) {
21
- nativeProps['aria-rowcount'] = options.totalItemsCount + 1;
23
+ nativeProps['aria-rowcount'] = options.totalItemsCount + headerRows;
22
24
  }
23
25
  if (options.tableRole === 'grid' || options.tableRole === 'treegrid') {
24
26
  nativeProps['aria-colcount'] = options.totalColumnsCount;
@@ -41,22 +43,25 @@ export function getTableWrapperRoleProps(options) {
41
43
  return nativeProps;
42
44
  }
43
45
  export function getTableHeaderRowRoleProps(options) {
46
+ var _a;
44
47
  const nativeProps = {};
45
48
  // For grids headers are treated similar to data rows and are indexed accordingly.
46
49
  if (options.tableRole === 'grid' || options.tableRole === 'grid-default' || options.tableRole === 'treegrid') {
47
- nativeProps['aria-rowindex'] = 1;
50
+ nativeProps['aria-rowindex'] = ((_a = options.rowIndex) !== null && _a !== void 0 ? _a : 0) + 1;
48
51
  }
49
52
  return nativeProps;
50
53
  }
51
54
  export function getTableRowRoleProps(options) {
55
+ var _a;
52
56
  const nativeProps = {};
53
57
  // The data cell indices are incremented by 1 to account for the header cells.
58
+ const headerRows = (_a = options.headerRowCount) !== null && _a !== void 0 ? _a : 1;
54
59
  if (options.tableRole === 'grid' || options.tableRole === 'treegrid') {
55
- nativeProps['aria-rowindex'] = (options.firstIndex || 1) + options.rowIndex + 1;
60
+ nativeProps['aria-rowindex'] = (options.firstIndex || 1) + options.rowIndex + headerRows;
56
61
  }
57
62
  // For tables indices are only added when the first index is not 0 (not the first page/frame).
58
63
  else if (options.firstIndex !== undefined) {
59
- nativeProps['aria-rowindex'] = options.firstIndex + options.rowIndex + 1;
64
+ nativeProps['aria-rowindex'] = options.firstIndex + options.rowIndex + headerRows;
60
65
  }
61
66
  if (options.tableRole === 'treegrid' && options.level && options.level !== 0) {
62
67
  nativeProps['aria-level'] = options.level;
@@ -1 +1 @@
1
- {"version":3,"file":"table-role-helper.js","sourceRoot":"","sources":["../../../../src/table/table-role/table-role-helper.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAMtC,MAAM,eAAe,GAAG;IACtB,QAAQ,EAAE,MAAM;IAChB,SAAS,EAAE,WAAW;IACtB,UAAU,EAAE,YAAY;CAChB,CAAC;AACX,MAAM,WAAW,GAAG,CAAC,YAA2B,EAAE,EAAE,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;AAEnF,mGAAmG;AACnG,8GAA8G;AAC9G,uFAAuF;AAEvF,MAAM,UAAU,iBAAiB,CAAC,OAMjC;IACC,MAAM,WAAW,GAAgD,EAAE,CAAC;IAEpE,sFAAsF;IACtF,qFAAqF;IACrF,WAAW,CAAC,IAAI,GAAG,OAAO,CAAC,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAErF,WAAW,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IAC9C,WAAW,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IAExD,qEAAqE;IACrE,IAAI,OAAO,OAAO,CAAC,eAAe,KAAK,QAAQ,IAAI,OAAO,CAAC,eAAe,GAAG,CAAC,EAAE,CAAC;QAC/E,WAAW,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,eAAe,GAAG,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,KAAK,MAAM,IAAI,OAAO,CAAC,SAAS,KAAK,UAAU,EAAE,CAAC;QACrE,WAAW,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAC3D,CAAC;IAED,sGAAsG;IACtG,IAAI,OAAO,CAAC,SAAS,KAAK,MAAM,IAAI,OAAO,CAAC,SAAS,KAAK,UAAU,EAAE,CAAC;QACrE,WAAW,CAA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AAG,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { TableRole } from './interfaces';\n\ntype SortingStatus = 'sortable' | 'ascending' | 'descending';\n\nconst stateToAriaSort = {\n sortable: 'none',\n ascending: 'ascending',\n descending: 'descending',\n} as const;\nconst getAriaSort = (sortingState: SortingStatus) => stateToAriaSort[sortingState];\n\n// Depending on its content the table can have different semantic representation which includes the\n// ARIA role of the table component (\"table\", \"grid\", \"treegrid\") but also roles and other semantic attributes\n// of the child elements. The TableRole helper encapsulates table's semantic structure.\n\nexport function getTableRoleProps(options: {\n tableRole: TableRole;\n ariaLabel?: string;\n ariaLabelledby?: string;\n totalItemsCount?: number;\n totalColumnsCount?: number;\n}): React.TableHTMLAttributes<HTMLTableElement> {\n const nativeProps: React.TableHTMLAttributes<HTMLTableElement> = {};\n\n // Browsers have weird mechanism to guess whether it's a data table or a layout table.\n // If we state explicitly, they get it always correctly even with low number of rows.\n nativeProps.role = options.tableRole === 'grid-default' ? 'grid' : options.tableRole;\n\n nativeProps['aria-label'] = options.ariaLabel;\n nativeProps['aria-labelledby'] = options.ariaLabelledby;\n\n // Incrementing the total count by one to account for the header row.\n if (typeof options.totalItemsCount === 'number' && options.totalItemsCount > 0) {\n nativeProps['aria-rowcount'] = options.totalItemsCount + 1;\n }\n\n if (options.tableRole === 'grid' || options.tableRole === 'treegrid') {\n nativeProps['aria-colcount'] = options.totalColumnsCount;\n }\n\n // Make table component programmatically focusable to attach focusin/focusout for keyboard navigation.\n if (options.tableRole === 'grid' || options.tableRole === 'treegrid') {\n nativeProps.tabIndex = -1;\n }\n\n return nativeProps;\n}\n\nexport function getTableWrapperRoleProps(options: {\n tableRole: TableRole;\n isScrollable: boolean;\n ariaLabel?: string;\n ariaLabelledby?: string;\n}) {\n const nativeProps: React.HTMLAttributes<HTMLDivElement> = {};\n\n // When the table is scrollable, the wrapper is made focusable so that keyboard users can scroll it horizontally with arrow keys.\n if (options.isScrollable) {\n nativeProps.role = 'region';\n nativeProps.tabIndex = 0;\n nativeProps['aria-label'] = options.ariaLabel;\n nativeProps['aria-labelledby'] = options.ariaLabelledby;\n }\n\n return nativeProps;\n}\n\nexport function getTableHeaderRowRoleProps(options: { tableRole: TableRole }) {\n const nativeProps: React.HTMLAttributes<HTMLTableRowElement> = {};\n\n // For grids headers are treated similar to data rows and are indexed accordingly.\n if (options.tableRole === 'grid' || options.tableRole === 'grid-default' || options.tableRole === 'treegrid') {\n nativeProps['aria-rowindex'] = 1;\n }\n\n return nativeProps;\n}\n\nexport function getTableRowRoleProps(options: {\n tableRole: TableRole;\n rowIndex: number;\n firstIndex?: number;\n level?: number;\n setSize?: number;\n posInSet?: number;\n}) {\n const nativeProps: React.HTMLAttributes<HTMLTableRowElement> = {};\n\n // The data cell indices are incremented by 1 to account for the header cells.\n if (options.tableRole === 'grid' || options.tableRole === 'treegrid') {\n nativeProps['aria-rowindex'] = (options.firstIndex || 1) + options.rowIndex + 1;\n }\n // For tables indices are only added when the first index is not 0 (not the first page/frame).\n else if (options.firstIndex !== undefined) {\n nativeProps['aria-rowindex'] = options.firstIndex + options.rowIndex + 1;\n }\n if (options.tableRole === 'treegrid' && options.level && options.level !== 0) {\n nativeProps['aria-level'] = options.level;\n }\n if (options.tableRole === 'treegrid' && options.setSize) {\n nativeProps['aria-setsize'] = options.setSize;\n }\n if (options.tableRole === 'treegrid' && options.posInSet) {\n nativeProps['aria-posinset'] = options.posInSet;\n }\n\n return nativeProps;\n}\n\nexport function getTableColHeaderRoleProps(options: {\n tableRole: TableRole;\n colIndex: number;\n sortingStatus?: SortingStatus;\n}) {\n const nativeProps: React.ThHTMLAttributes<HTMLTableCellElement> = {};\n\n nativeProps.scope = 'col';\n\n if (options.tableRole === 'grid' || options.tableRole === 'treegrid') {\n nativeProps['aria-colindex'] = options.colIndex + 1;\n }\n\n if (options.sortingStatus) {\n nativeProps['aria-sort'] = getAriaSort(options.sortingStatus);\n }\n\n return nativeProps;\n}\n\nexport function getTableCellRoleProps(options: { tableRole: TableRole; colIndex: number; isRowHeader?: boolean }) {\n const nativeProps: React.TdHTMLAttributes<HTMLTableCellElement> = {};\n\n if (options.tableRole === 'grid' || options.tableRole === 'treegrid') {\n nativeProps['aria-colindex'] = options.colIndex + 1;\n }\n\n if (options.isRowHeader) {\n nativeProps.scope = 'row';\n }\n\n return nativeProps;\n}\n"]}
1
+ {"version":3,"file":"table-role-helper.js","sourceRoot":"","sources":["../../../../src/table/table-role/table-role-helper.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAMtC,MAAM,eAAe,GAAG;IACtB,QAAQ,EAAE,MAAM;IAChB,SAAS,EAAE,WAAW;IACtB,UAAU,EAAE,YAAY;CAChB,CAAC;AACX,MAAM,WAAW,GAAG,CAAC,YAA2B,EAAE,EAAE,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;AAEnF,mGAAmG;AACnG,8GAA8G;AAC9G,uFAAuF;AAEvF,MAAM,UAAU,iBAAiB,CAAC,OAOjC;;IACC,MAAM,WAAW,GAAgD,EAAE,CAAC;IAEpE,sFAAsF;IACtF,qFAAqF;IACrF,WAAW,CAAC,IAAI,GAAG,OAAO,CAAC,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAErF,WAAW,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IAC9C,WAAW,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IAExD,qEAAqE;IACrE,MAAM,UAAU,GAAG,MAAA,OAAO,CAAC,cAAc,mCAAI,CAAC,CAAC;IAC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E,CAAC;IAErE,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC;IAE1B,IAAI,OAAO,CAAC,SAAS,KAAK,MAAM,IAAI,OAAO,CAAC,SAAS,KAAK,UAAU,EAAE,CAAC;QACrE,WAAW,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;QAC1B,WAAW,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAA0E;IAC9G,MAAM,WAAW,GAAiD,EAAE,CAAC;IAErE,IAAI,OAAO,CAAC,SAAS,KAAK,MAAM,IAAI,OAAO,CAAC,SAAS,KAAK,UAAU,EAAE,CAAC;QACrE,WAAW,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { TableRole } from './interfaces';\n\ntype SortingStatus = 'sortable' | 'ascending' | 'descending';\n\nconst stateToAriaSort = {\n sortable: 'none',\n ascending: 'ascending',\n descending: 'descending',\n} as const;\nconst getAriaSort = (sortingState: SortingStatus) => stateToAriaSort[sortingState];\n\n// Depending on its content the table can have different semantic representation which includes the\n// ARIA role of the table component (\"table\", \"grid\", \"treegrid\") but also roles and other semantic attributes\n// of the child elements. The TableRole helper encapsulates table's semantic structure.\n\nexport function getTableRoleProps(options: {\n tableRole: TableRole;\n ariaLabel?: string;\n ariaLabelledby?: string;\n totalItemsCount?: number;\n totalColumnsCount?: number;\n headerRowCount?: number;\n}): React.TableHTMLAttributes<HTMLTableElement> {\n const nativeProps: React.TableHTMLAttributes<HTMLTableElement> = {};\n\n // Browsers have weird mechanism to guess whether it's a data table or a layout table.\n // If we state explicitly, they get it always correctly even with low number of rows.\n nativeProps.role = options.tableRole === 'grid-default' ? 'grid' : options.tableRole;\n\n nativeProps['aria-label'] = options.ariaLabel;\n nativeProps['aria-labelledby'] = options.ariaLabelledby;\n\n // Incrementing the total count by one to account for the header row.\n const headerRows = options.headerRowCount ?? 1;\n if (typeof options.totalItemsCount === 'number' && options.totalItemsCount > 0) {\n nativeProps['aria-rowcount'] = options.totalItemsCount + headerRows;\n }\n\n if (options.tableRole === 'grid' || options.tableRole === 'treegrid') {\n nativeProps['aria-colcount'] = options.totalColumnsCount;\n }\n\n // Make table component programmatically focusable to attach focusin/focusout for keyboard navigation.\n if (options.tableRole === 'grid' || options.tableRole === 'treegrid') {\n nativeProps.tabIndex = -1;\n }\n\n return nativeProps;\n}\n\nexport function getTableWrapperRoleProps(options: {\n tableRole: TableRole;\n isScrollable: boolean;\n ariaLabel?: string;\n ariaLabelledby?: string;\n}) {\n const nativeProps: React.HTMLAttributes<HTMLDivElement> = {};\n\n // When the table is scrollable, the wrapper is made focusable so that keyboard users can scroll it horizontally with arrow keys.\n if (options.isScrollable) {\n nativeProps.role = 'region';\n nativeProps.tabIndex = 0;\n nativeProps['aria-label'] = options.ariaLabel;\n nativeProps['aria-labelledby'] = options.ariaLabelledby;\n }\n\n return nativeProps;\n}\n\nexport function getTableHeaderRowRoleProps(options: { tableRole: TableRole; rowIndex?: number }) {\n const nativeProps: React.HTMLAttributes<HTMLTableRowElement> = {};\n\n // For grids headers are treated similar to data rows and are indexed accordingly.\n if (options.tableRole === 'grid' || options.tableRole === 'grid-default' || options.tableRole === 'treegrid') {\n nativeProps['aria-rowindex'] = (options.rowIndex ?? 0) + 1;\n }\n\n return nativeProps;\n}\n\nexport function getTableRowRoleProps(options: {\n tableRole: TableRole;\n rowIndex: number;\n firstIndex?: number;\n headerRowCount?: number;\n level?: number;\n setSize?: number;\n posInSet?: number;\n}) {\n const nativeProps: React.HTMLAttributes<HTMLTableRowElement> = {};\n\n // The data cell indices are incremented by 1 to account for the header cells.\n const headerRows = options.headerRowCount ?? 1;\n if (options.tableRole === 'grid' || options.tableRole === 'treegrid') {\n nativeProps['aria-rowindex'] = (options.firstIndex || 1) + options.rowIndex + headerRows;\n }\n // For tables indices are only added when the first index is not 0 (not the first page/frame).\n else if (options.firstIndex !== undefined) {\n nativeProps['aria-rowindex'] = options.firstIndex + options.rowIndex + headerRows;\n }\n if (options.tableRole === 'treegrid' && options.level && options.level !== 0) {\n nativeProps['aria-level'] = options.level;\n }\n if (options.tableRole === 'treegrid' && options.setSize) {\n nativeProps['aria-setsize'] = options.setSize;\n }\n if (options.tableRole === 'treegrid' && options.posInSet) {\n nativeProps['aria-posinset'] = options.posInSet;\n }\n\n return nativeProps;\n}\n\nexport function getTableColHeaderRoleProps(options: {\n tableRole: TableRole;\n colIndex: number;\n sortingStatus?: SortingStatus;\n}) {\n const nativeProps: React.ThHTMLAttributes<HTMLTableCellElement> = {};\n\n nativeProps.scope = 'col';\n\n if (options.tableRole === 'grid' || options.tableRole === 'treegrid') {\n nativeProps['aria-colindex'] = options.colIndex + 1;\n }\n\n if (options.sortingStatus) {\n nativeProps['aria-sort'] = getAriaSort(options.sortingStatus);\n }\n\n return nativeProps;\n}\n\nexport function getTableCellRoleProps(options: { tableRole: TableRole; colIndex: number; isRowHeader?: boolean }) {\n const nativeProps: React.TdHTMLAttributes<HTMLTableCellElement> = {};\n\n if (options.tableRole === 'grid' || options.tableRole === 'treegrid') {\n nativeProps['aria-colindex'] = options.colIndex + 1;\n }\n\n if (options.isRowHeader) {\n nativeProps.scope = 'row';\n }\n\n return nativeProps;\n}\n"]}