@cloudscape-design/components 3.0.989 → 3.0.990

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 (51) hide show
  1. package/annotation-context/annotation/styles.css.js +24 -24
  2. package/annotation-context/annotation/styles.scoped.css +34 -34
  3. package/annotation-context/annotation/styles.selectors.js +24 -24
  4. package/button-group/analytics-metadata/interfaces.d.ts +10 -0
  5. package/button-group/analytics-metadata/interfaces.d.ts.map +1 -0
  6. package/button-group/analytics-metadata/interfaces.js +4 -0
  7. package/button-group/analytics-metadata/interfaces.js.map +1 -0
  8. package/button-group/index.d.ts.map +1 -1
  9. package/button-group/index.js +6 -1
  10. package/button-group/index.js.map +1 -1
  11. package/button-group/internal.d.ts.map +1 -1
  12. package/button-group/internal.js +2 -2
  13. package/button-group/internal.js.map +1 -1
  14. package/button-group/item-element.d.ts +1 -0
  15. package/button-group/item-element.d.ts.map +1 -1
  16. package/button-group/item-element.js +7 -4
  17. package/button-group/item-element.js.map +1 -1
  18. package/button-group/menu-dropdown-item.d.ts +1 -0
  19. package/button-group/menu-dropdown-item.d.ts.map +1 -1
  20. package/button-group/menu-dropdown-item.js +3 -2
  21. package/button-group/menu-dropdown-item.js.map +1 -1
  22. package/copy-to-clipboard/interfaces.d.ts +10 -0
  23. package/copy-to-clipboard/interfaces.d.ts.map +1 -1
  24. package/copy-to-clipboard/interfaces.js.map +1 -1
  25. package/copy-to-clipboard/internal.d.ts +1 -1
  26. package/copy-to-clipboard/internal.d.ts.map +1 -1
  27. package/copy-to-clipboard/internal.js +3 -3
  28. package/copy-to-clipboard/internal.js.map +1 -1
  29. package/internal/base-component/styles.scoped.css +14 -0
  30. package/internal/components/drag-handle/button.js +1 -1
  31. package/internal/components/drag-handle/button.js.map +1 -1
  32. package/internal/environment.js +1 -1
  33. package/internal/environment.json +1 -1
  34. package/internal/generated/styles/tokens.d.ts +2 -0
  35. package/internal/generated/styles/tokens.js +2 -0
  36. package/internal/generated/theming/index.cjs +62 -0
  37. package/internal/generated/theming/index.js +62 -0
  38. package/internal/manifest.json +1 -1
  39. package/package.json +1 -1
  40. package/popover/container.d.ts +1 -1
  41. package/popover/container.d.ts.map +1 -1
  42. package/popover/container.js +7 -1
  43. package/popover/container.js.map +1 -1
  44. package/test-utils/dom/autosuggest/index.js +2 -1
  45. package/test-utils/dom/autosuggest/index.js.map +1 -1
  46. package/test-utils/dom/internal/dropdown-host.js +2 -1
  47. package/test-utils/dom/internal/dropdown-host.js.map +1 -1
  48. package/test-utils/selectors/autosuggest/index.js +2 -1
  49. package/test-utils/selectors/autosuggest/index.js.map +1 -1
  50. package/test-utils/selectors/internal/dropdown-host.js +2 -1
  51. package/test-utils/selectors/internal/dropdown-host.js.map +1 -1
@@ -1,29 +1,29 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "arrow": "awsui_arrow_1hpp3_1rese_193",
5
- "arrow-outer": "awsui_arrow-outer_1hpp3_1rese_197",
6
- "arrow-inner": "awsui_arrow-inner_1hpp3_1rese_197",
7
- "arrow-position-right-top": "awsui_arrow-position-right-top_1hpp3_1rese_239",
8
- "arrow-position-right-bottom": "awsui_arrow-position-right-bottom_1hpp3_1rese_239",
9
- "arrow-position-left-top": "awsui_arrow-position-left-top_1hpp3_1rese_242",
10
- "arrow-position-left-bottom": "awsui_arrow-position-left-bottom_1hpp3_1rese_242",
11
- "arrow-position-top-center": "awsui_arrow-position-top-center_1hpp3_1rese_245",
12
- "arrow-position-top-responsive": "awsui_arrow-position-top-responsive_1hpp3_1rese_245",
13
- "arrow-position-bottom-center": "awsui_arrow-position-bottom-center_1hpp3_1rese_248",
14
- "arrow-position-bottom-responsive": "awsui_arrow-position-bottom-responsive_1hpp3_1rese_248",
15
- "annotation": "awsui_annotation_1hpp3_1rese_252",
16
- "next-button": "awsui_next-button_1hpp3_1rese_253",
17
- "previous-button": "awsui_previous-button_1hpp3_1rese_254",
18
- "finish-button": "awsui_finish-button_1hpp3_1rese_255",
19
- "header": "awsui_header_1hpp3_1rese_256",
20
- "step-counter-content": "awsui_step-counter-content_1hpp3_1rese_257",
21
- "content": "awsui_content_1hpp3_1rese_258",
22
- "description": "awsui_description_1hpp3_1rese_262",
23
- "actionBar": "awsui_actionBar_1hpp3_1rese_267",
24
- "stepCounter": "awsui_stepCounter_1hpp3_1rese_274",
25
- "divider": "awsui_divider_1hpp3_1rese_278",
26
- "hotspot": "awsui_hotspot_1hpp3_1rese_282",
27
- "icon": "awsui_icon_1hpp3_1rese_352"
4
+ "arrow": "awsui_arrow_1hpp3_f5f22_193",
5
+ "arrow-outer": "awsui_arrow-outer_1hpp3_f5f22_197",
6
+ "arrow-inner": "awsui_arrow-inner_1hpp3_f5f22_197",
7
+ "arrow-position-right-top": "awsui_arrow-position-right-top_1hpp3_f5f22_239",
8
+ "arrow-position-right-bottom": "awsui_arrow-position-right-bottom_1hpp3_f5f22_239",
9
+ "arrow-position-left-top": "awsui_arrow-position-left-top_1hpp3_f5f22_242",
10
+ "arrow-position-left-bottom": "awsui_arrow-position-left-bottom_1hpp3_f5f22_242",
11
+ "arrow-position-top-center": "awsui_arrow-position-top-center_1hpp3_f5f22_245",
12
+ "arrow-position-top-responsive": "awsui_arrow-position-top-responsive_1hpp3_f5f22_245",
13
+ "arrow-position-bottom-center": "awsui_arrow-position-bottom-center_1hpp3_f5f22_248",
14
+ "arrow-position-bottom-responsive": "awsui_arrow-position-bottom-responsive_1hpp3_f5f22_248",
15
+ "annotation": "awsui_annotation_1hpp3_f5f22_252",
16
+ "next-button": "awsui_next-button_1hpp3_f5f22_253",
17
+ "previous-button": "awsui_previous-button_1hpp3_f5f22_254",
18
+ "finish-button": "awsui_finish-button_1hpp3_f5f22_255",
19
+ "header": "awsui_header_1hpp3_f5f22_256",
20
+ "step-counter-content": "awsui_step-counter-content_1hpp3_f5f22_257",
21
+ "content": "awsui_content_1hpp3_f5f22_258",
22
+ "description": "awsui_description_1hpp3_f5f22_262",
23
+ "actionBar": "awsui_actionBar_1hpp3_f5f22_267",
24
+ "stepCounter": "awsui_stepCounter_1hpp3_f5f22_274",
25
+ "divider": "awsui_divider_1hpp3_f5f22_278",
26
+ "hotspot": "awsui_hotspot_1hpp3_f5f22_282",
27
+ "icon": "awsui_icon_1hpp3_f5f22_352"
28
28
  };
29
29
 
@@ -190,11 +190,11 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
190
190
  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
191
191
  SPDX-License-Identifier: Apache-2.0
192
192
  */
193
- .awsui_arrow_1hpp3_1rese_193:not(#\9) {
193
+ .awsui_arrow_1hpp3_f5f22_193:not(#\9) {
194
194
  inline-size: 20px;
195
195
  block-size: 10px;
196
196
  }
197
- .awsui_arrow-outer_1hpp3_1rese_197:not(#\9), .awsui_arrow-inner_1hpp3_1rese_197:not(#\9) {
197
+ .awsui_arrow-outer_1hpp3_f5f22_197:not(#\9), .awsui_arrow-inner_1hpp3_f5f22_197:not(#\9) {
198
198
  position: absolute;
199
199
  overflow: hidden;
200
200
  inline-size: 20px;
@@ -203,7 +203,7 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
203
203
  inset-inline-start: 0;
204
204
  /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
205
205
  }
206
- .awsui_arrow-outer_1hpp3_1rese_197:not(#\9)::after, .awsui_arrow-inner_1hpp3_1rese_197:not(#\9)::after {
206
+ .awsui_arrow-outer_1hpp3_f5f22_197:not(#\9)::after, .awsui_arrow-inner_1hpp3_f5f22_197:not(#\9)::after {
207
207
  content: "";
208
208
  box-sizing: border-box;
209
209
  display: inline-block;
@@ -219,67 +219,67 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
219
219
  transform: rotate(45deg);
220
220
  transform-origin: 0 100%;
221
221
  }
222
- .awsui_arrow-outer_1hpp3_1rese_197:not(#\9):dir(rtl)::after, .awsui_arrow-inner_1hpp3_1rese_197:not(#\9):dir(rtl)::after {
222
+ .awsui_arrow-outer_1hpp3_f5f22_197:not(#\9):dir(rtl)::after, .awsui_arrow-inner_1hpp3_f5f22_197:not(#\9):dir(rtl)::after {
223
223
  transform: rotate(-45deg);
224
224
  transform-origin: 100% 100%;
225
225
  }
226
- .awsui_arrow-outer_1hpp3_1rese_197:not(#\9)::after {
226
+ .awsui_arrow-outer_1hpp3_f5f22_197:not(#\9)::after {
227
227
  background-color: var(--color-border-status-info-2zt73n, #006ce0);
228
228
  }
229
- .awsui_arrow-inner_1hpp3_1rese_197:not(#\9) {
229
+ .awsui_arrow-inner_1hpp3_f5f22_197:not(#\9) {
230
230
  inset-block-start: 2px;
231
231
  }
232
- .awsui_arrow-inner_1hpp3_1rese_197:not(#\9)::after {
232
+ .awsui_arrow-inner_1hpp3_f5f22_197:not(#\9)::after {
233
233
  border-start-start-radius: 1px;
234
234
  border-start-end-radius: 0;
235
235
  border-end-start-radius: 0;
236
236
  border-end-end-radius: 0;
237
237
  background-color: var(--color-background-status-info-j2xxem, #f0fbff);
238
238
  }
239
- .awsui_arrow-position-right-top_1hpp3_1rese_239 > .awsui_arrow-outer_1hpp3_1rese_197:not(#\9)::after, .awsui_arrow-position-right-bottom_1hpp3_1rese_239 > .awsui_arrow-outer_1hpp3_1rese_197:not(#\9)::after {
239
+ .awsui_arrow-position-right-top_1hpp3_f5f22_239 > .awsui_arrow-outer_1hpp3_f5f22_197:not(#\9)::after, .awsui_arrow-position-right-bottom_1hpp3_f5f22_239 > .awsui_arrow-outer_1hpp3_f5f22_197:not(#\9)::after {
240
240
  box-shadow: -0.71px 0.71px 4px -2px var(--color-shadow-default-08gb4j, rgba(15, 20, 26, 0.12));
241
241
  }
242
- .awsui_arrow-position-left-top_1hpp3_1rese_242 > .awsui_arrow-outer_1hpp3_1rese_197:not(#\9)::after, .awsui_arrow-position-left-bottom_1hpp3_1rese_242 > .awsui_arrow-outer_1hpp3_1rese_197:not(#\9)::after {
242
+ .awsui_arrow-position-left-top_1hpp3_f5f22_242 > .awsui_arrow-outer_1hpp3_f5f22_197:not(#\9)::after, .awsui_arrow-position-left-bottom_1hpp3_f5f22_242 > .awsui_arrow-outer_1hpp3_f5f22_197:not(#\9)::after {
243
243
  box-shadow: 0.71px -0.71px 4px -2px var(--color-shadow-default-08gb4j, rgba(15, 20, 26, 0.12));
244
244
  }
245
- .awsui_arrow-position-top-center_1hpp3_1rese_245 > .awsui_arrow-outer_1hpp3_1rese_197:not(#\9)::after, .awsui_arrow-position-top-responsive_1hpp3_1rese_245 > .awsui_arrow-outer_1hpp3_1rese_197:not(#\9)::after {
245
+ .awsui_arrow-position-top-center_1hpp3_f5f22_245 > .awsui_arrow-outer_1hpp3_f5f22_197:not(#\9)::after, .awsui_arrow-position-top-responsive_1hpp3_f5f22_245 > .awsui_arrow-outer_1hpp3_f5f22_197:not(#\9)::after {
246
246
  box-shadow: -0.71px -0.71px 4px -2px var(--color-shadow-default-08gb4j, rgba(15, 20, 26, 0.12));
247
247
  }
248
- .awsui_arrow-position-bottom-center_1hpp3_1rese_248 > .awsui_arrow-outer_1hpp3_1rese_197:not(#\9)::after, .awsui_arrow-position-bottom-responsive_1hpp3_1rese_248 > .awsui_arrow-outer_1hpp3_1rese_197:not(#\9)::after {
248
+ .awsui_arrow-position-bottom-center_1hpp3_f5f22_248 > .awsui_arrow-outer_1hpp3_f5f22_197:not(#\9)::after, .awsui_arrow-position-bottom-responsive_1hpp3_f5f22_248 > .awsui_arrow-outer_1hpp3_f5f22_197:not(#\9)::after {
249
249
  box-shadow: 0.71px 0.71px 4px -2px var(--color-shadow-default-08gb4j, rgba(15, 20, 26, 0.12));
250
250
  }
251
251
 
252
- .awsui_annotation_1hpp3_1rese_252:not(#\9),
253
- .awsui_next-button_1hpp3_1rese_253:not(#\9),
254
- .awsui_previous-button_1hpp3_1rese_254:not(#\9),
255
- .awsui_finish-button_1hpp3_1rese_255:not(#\9),
256
- .awsui_header_1hpp3_1rese_256:not(#\9),
257
- .awsui_step-counter-content_1hpp3_1rese_257:not(#\9),
258
- .awsui_content_1hpp3_1rese_258:not(#\9) {
252
+ .awsui_annotation_1hpp3_f5f22_252:not(#\9),
253
+ .awsui_next-button_1hpp3_f5f22_253:not(#\9),
254
+ .awsui_previous-button_1hpp3_f5f22_254:not(#\9),
255
+ .awsui_finish-button_1hpp3_f5f22_255:not(#\9),
256
+ .awsui_header_1hpp3_f5f22_256:not(#\9),
257
+ .awsui_step-counter-content_1hpp3_f5f22_257:not(#\9),
258
+ .awsui_content_1hpp3_f5f22_258:not(#\9) {
259
259
  /* used in test-utils */
260
260
  }
261
261
 
262
- .awsui_description_1hpp3_1rese_262:not(#\9) {
262
+ .awsui_description_1hpp3_f5f22_262:not(#\9) {
263
263
  overflow: hidden;
264
264
  margin-block-start: var(--space-xxs-hwfkai, 4px);
265
265
  }
266
266
 
267
- .awsui_actionBar_1hpp3_1rese_267:not(#\9) {
267
+ .awsui_actionBar_1hpp3_f5f22_267:not(#\9) {
268
268
  display: flex;
269
269
  justify-content: space-between;
270
270
  align-items: center;
271
271
  position: relative;
272
272
  }
273
273
 
274
- .awsui_stepCounter_1hpp3_1rese_274:not(#\9) {
274
+ .awsui_stepCounter_1hpp3_f5f22_274:not(#\9) {
275
275
  margin-inline-end: 20px;
276
276
  }
277
277
 
278
- .awsui_divider_1hpp3_1rese_278:not(#\9) {
278
+ .awsui_divider_1hpp3_f5f22_278:not(#\9) {
279
279
  border-block-end: var(--border-divider-section-width-uwo8my, 1px) solid var(--color-border-divider-default-jm73jm, #c6c6cd);
280
280
  }
281
281
 
282
- .awsui_hotspot_1hpp3_1rese_282:not(#\9) {
282
+ .awsui_hotspot_1hpp3_f5f22_282:not(#\9) {
283
283
  border-collapse: separate;
284
284
  border-spacing: 0;
285
285
  box-sizing: border-box;
@@ -321,22 +321,22 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
321
321
  inline-size: 16px;
322
322
  block-size: 16px;
323
323
  }
324
- .awsui_hotspot_1hpp3_1rese_282:not(#\9):before {
324
+ .awsui_hotspot_1hpp3_f5f22_282:not(#\9):before {
325
325
  content: "";
326
326
  position: absolute;
327
327
  inset: calc(-1 * var(--space-xxs-hwfkai, 4px));
328
328
  }
329
- .awsui_hotspot_1hpp3_1rese_282:not(#\9):focus {
329
+ .awsui_hotspot_1hpp3_f5f22_282:not(#\9):focus {
330
330
  outline: none;
331
331
  }
332
- body[data-awsui-focus-visible=true] .awsui_hotspot_1hpp3_1rese_282:not(#\9):focus {
332
+ body[data-awsui-focus-visible=true] .awsui_hotspot_1hpp3_f5f22_282:not(#\9):focus {
333
333
  position: relative;
334
334
  }
335
- body[data-awsui-focus-visible=true] .awsui_hotspot_1hpp3_1rese_282:not(#\9):focus {
335
+ body[data-awsui-focus-visible=true] .awsui_hotspot_1hpp3_f5f22_282:not(#\9):focus {
336
336
  outline: 2px dotted transparent;
337
337
  outline-offset: calc(2px - 1px);
338
338
  }
339
- body[data-awsui-focus-visible=true] .awsui_hotspot_1hpp3_1rese_282:not(#\9):focus::before {
339
+ body[data-awsui-focus-visible=true] .awsui_hotspot_1hpp3_f5f22_282:not(#\9):focus::before {
340
340
  content: " ";
341
341
  display: block;
342
342
  position: absolute;
@@ -350,13 +350,13 @@ body[data-awsui-focus-visible=true] .awsui_hotspot_1hpp3_1rese_282:not(#\9):focu
350
350
  border-end-end-radius: var(--border-radius-control-circular-focus-ring-yjhscw, 4px);
351
351
  box-shadow: 0 0 0 2px var(--color-border-item-focused-8bi903, #006ce0);
352
352
  }
353
- .awsui_hotspot_1hpp3_1rese_282 > .awsui_icon_1hpp3_1rese_352:not(#\9) {
353
+ .awsui_hotspot_1hpp3_f5f22_282 > .awsui_icon_1hpp3_f5f22_352:not(#\9) {
354
354
  position: relative;
355
- stroke: var(--color-text-link-default-dsa7ac, #006ce0);
355
+ stroke: var(--color-text-tutorial-hotspot-default-aq2wj8, #006ce0);
356
356
  }
357
- .awsui_hotspot_1hpp3_1rese_282:not(#\9):hover > .awsui_icon_1hpp3_1rese_352 {
358
- stroke: var(--color-text-link-hover-nut5c6, #002b66);
357
+ .awsui_hotspot_1hpp3_f5f22_282:not(#\9):hover > .awsui_icon_1hpp3_f5f22_352 {
358
+ stroke: var(--color-text-tutorial-hotspot-hover-93wlda, #002b66);
359
359
  }
360
- .awsui_hotspot_1hpp3_1rese_282:not(#\9):active > .awsui_icon_1hpp3_1rese_352 {
361
- stroke: var(--color-text-link-default-dsa7ac, #006ce0);
360
+ .awsui_hotspot_1hpp3_f5f22_282:not(#\9):active > .awsui_icon_1hpp3_f5f22_352 {
361
+ stroke: var(--color-text-tutorial-hotspot-default-aq2wj8, #006ce0);
362
362
  }
@@ -2,29 +2,29 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "arrow": "awsui_arrow_1hpp3_1rese_193",
6
- "arrow-outer": "awsui_arrow-outer_1hpp3_1rese_197",
7
- "arrow-inner": "awsui_arrow-inner_1hpp3_1rese_197",
8
- "arrow-position-right-top": "awsui_arrow-position-right-top_1hpp3_1rese_239",
9
- "arrow-position-right-bottom": "awsui_arrow-position-right-bottom_1hpp3_1rese_239",
10
- "arrow-position-left-top": "awsui_arrow-position-left-top_1hpp3_1rese_242",
11
- "arrow-position-left-bottom": "awsui_arrow-position-left-bottom_1hpp3_1rese_242",
12
- "arrow-position-top-center": "awsui_arrow-position-top-center_1hpp3_1rese_245",
13
- "arrow-position-top-responsive": "awsui_arrow-position-top-responsive_1hpp3_1rese_245",
14
- "arrow-position-bottom-center": "awsui_arrow-position-bottom-center_1hpp3_1rese_248",
15
- "arrow-position-bottom-responsive": "awsui_arrow-position-bottom-responsive_1hpp3_1rese_248",
16
- "annotation": "awsui_annotation_1hpp3_1rese_252",
17
- "next-button": "awsui_next-button_1hpp3_1rese_253",
18
- "previous-button": "awsui_previous-button_1hpp3_1rese_254",
19
- "finish-button": "awsui_finish-button_1hpp3_1rese_255",
20
- "header": "awsui_header_1hpp3_1rese_256",
21
- "step-counter-content": "awsui_step-counter-content_1hpp3_1rese_257",
22
- "content": "awsui_content_1hpp3_1rese_258",
23
- "description": "awsui_description_1hpp3_1rese_262",
24
- "actionBar": "awsui_actionBar_1hpp3_1rese_267",
25
- "stepCounter": "awsui_stepCounter_1hpp3_1rese_274",
26
- "divider": "awsui_divider_1hpp3_1rese_278",
27
- "hotspot": "awsui_hotspot_1hpp3_1rese_282",
28
- "icon": "awsui_icon_1hpp3_1rese_352"
5
+ "arrow": "awsui_arrow_1hpp3_f5f22_193",
6
+ "arrow-outer": "awsui_arrow-outer_1hpp3_f5f22_197",
7
+ "arrow-inner": "awsui_arrow-inner_1hpp3_f5f22_197",
8
+ "arrow-position-right-top": "awsui_arrow-position-right-top_1hpp3_f5f22_239",
9
+ "arrow-position-right-bottom": "awsui_arrow-position-right-bottom_1hpp3_f5f22_239",
10
+ "arrow-position-left-top": "awsui_arrow-position-left-top_1hpp3_f5f22_242",
11
+ "arrow-position-left-bottom": "awsui_arrow-position-left-bottom_1hpp3_f5f22_242",
12
+ "arrow-position-top-center": "awsui_arrow-position-top-center_1hpp3_f5f22_245",
13
+ "arrow-position-top-responsive": "awsui_arrow-position-top-responsive_1hpp3_f5f22_245",
14
+ "arrow-position-bottom-center": "awsui_arrow-position-bottom-center_1hpp3_f5f22_248",
15
+ "arrow-position-bottom-responsive": "awsui_arrow-position-bottom-responsive_1hpp3_f5f22_248",
16
+ "annotation": "awsui_annotation_1hpp3_f5f22_252",
17
+ "next-button": "awsui_next-button_1hpp3_f5f22_253",
18
+ "previous-button": "awsui_previous-button_1hpp3_f5f22_254",
19
+ "finish-button": "awsui_finish-button_1hpp3_f5f22_255",
20
+ "header": "awsui_header_1hpp3_f5f22_256",
21
+ "step-counter-content": "awsui_step-counter-content_1hpp3_f5f22_257",
22
+ "content": "awsui_content_1hpp3_f5f22_258",
23
+ "description": "awsui_description_1hpp3_f5f22_262",
24
+ "actionBar": "awsui_actionBar_1hpp3_f5f22_267",
25
+ "stepCounter": "awsui_stepCounter_1hpp3_f5f22_274",
26
+ "divider": "awsui_divider_1hpp3_f5f22_278",
27
+ "hotspot": "awsui_hotspot_1hpp3_f5f22_282",
28
+ "icon": "awsui_icon_1hpp3_f5f22_352"
29
29
  };
30
30
 
@@ -0,0 +1,10 @@
1
+ import { LabelIdentifier } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';
2
+ import { GeneratedAnalyticsMetadataButtonDropdownClick, GeneratedAnalyticsMetadataButtonDropdownCollapse, GeneratedAnalyticsMetadataButtonDropdownExpand } from '../../button-dropdown/analytics-metadata/interfaces';
3
+ export type GeneratedAnalyticsMetadataButtonGroupClick = GeneratedAnalyticsMetadataButtonDropdownClick;
4
+ export type GeneratedAnalyticsMetadataButtonGroupExpand = GeneratedAnalyticsMetadataButtonDropdownExpand;
5
+ export type GeneratedAnalyticsMetadataButtonGroupCollapse = GeneratedAnalyticsMetadataButtonDropdownCollapse;
6
+ export interface GeneratedAnalyticsMetadataButtonGroupComponent {
7
+ name: 'awsui.ButtonGroup';
8
+ label: string | LabelIdentifier;
9
+ }
10
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/button-group/analytics-metadata/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,kEAAkE,CAAC;AAEnG,OAAO,EACL,6CAA6C,EAC7C,gDAAgD,EAChD,8CAA8C,EAC/C,MAAM,qDAAqD,CAAC;AAE7D,MAAM,MAAM,0CAA0C,GAAG,6CAA6C,CAAC;AACvG,MAAM,MAAM,2CAA2C,GAAG,8CAA8C,CAAC;AACzG,MAAM,MAAM,6CAA6C,GAAG,gDAAgD,CAAC;AAE7G,MAAM,WAAW,8CAA8C;IAC7D,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE,MAAM,GAAG,eAAe,CAAC;CACjC"}
@@ -0,0 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
4
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/button-group/analytics-metadata/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { LabelIdentifier } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport {\n GeneratedAnalyticsMetadataButtonDropdownClick,\n GeneratedAnalyticsMetadataButtonDropdownCollapse,\n GeneratedAnalyticsMetadataButtonDropdownExpand,\n} from '../../button-dropdown/analytics-metadata/interfaces';\n\nexport type GeneratedAnalyticsMetadataButtonGroupClick = GeneratedAnalyticsMetadataButtonDropdownClick;\nexport type GeneratedAnalyticsMetadataButtonGroupExpand = GeneratedAnalyticsMetadataButtonDropdownExpand;\nexport type GeneratedAnalyticsMetadataButtonGroupCollapse = GeneratedAnalyticsMetadataButtonDropdownCollapse;\n\nexport interface GeneratedAnalyticsMetadataButtonGroupComponent {\n name: 'awsui.ButtonGroup';\n label: string | LabelIdentifier;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/button-group/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,QAAA,MAAM,WAAW,+FA8BhB,CAAC;AAoBF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/button-group/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,QAAA,MAAM,WAAW,+FAqChB,CAAC;AAoBF,eAAe,WAAW,CAAC"}
@@ -2,6 +2,7 @@ import { __rest } from "tslib";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  import React from 'react';
5
+ import { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';
5
6
  import { getBaseProps } from '../internal/base-component';
6
7
  import useBaseComponent from '../internal/hooks/use-base-component';
7
8
  import { applyDisplayName } from '../internal/utils/apply-display-name';
@@ -25,7 +26,11 @@ const ButtonGroup = React.forwardRef((_a, ref) => {
25
26
  },
26
27
  });
27
28
  const externalProps = getExternalProps(rest);
28
- return (React.createElement(InternalButtonGroup, Object.assign({}, baseProps, baseComponentProps, externalProps, { ref: ref, variant: variant, dropdownExpandToViewport: dropdownExpandToViewport })));
29
+ const componentMetadata = {
30
+ name: 'awsui.ButtonGroup',
31
+ label: { root: 'self' },
32
+ };
33
+ return (React.createElement(InternalButtonGroup, Object.assign({}, baseProps, baseComponentProps, externalProps, { ref: ref, variant: variant, dropdownExpandToViewport: dropdownExpandToViewport }, getAnalyticsMetadataAttribute({ component: componentMetadata }))));
29
34
  });
30
35
  function getItemCounts(allItems = []) {
31
36
  const counters = { 'icon-button': 0, 'icon-toggle-button': 0, 'icon-file-input': 0, 'menu-dropdown': 0, group: 0 };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/button-group/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAA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KAAK,CAAC,KAA8C;QAC3D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEzB,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE;gBACzB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACnB;SACF;IACH,CAAC;IACD,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEhB,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,gBAAgB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;AAC7C,eAAe,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { getBaseProps } from '../internal/base-component';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { getExternalProps } from '../internal/utils/external-props';\nimport { ButtonGroupProps } from './interfaces';\nimport InternalButtonGroup from './internal';\n\nexport { ButtonGroupProps };\n\nconst ButtonGroup = React.forwardRef(\n ({ variant, dropdownExpandToViewport = false, ...rest }: ButtonGroupProps, ref: React.Ref<ButtonGroupProps.Ref>) => {\n const baseProps = getBaseProps(rest);\n const itemCounts = getItemCounts(rest.items);\n const baseComponentProps = useBaseComponent('ButtonGroup', {\n props: {\n variant,\n dropdownExpandToViewport,\n },\n metadata: {\n iconButtonsCount: itemCounts['icon-button'],\n iconToggleButtonsCount: itemCounts['icon-toggle-button'],\n iconFileInputsCount: itemCounts['icon-file-input'],\n menuDropdownsCount: itemCounts['menu-dropdown'],\n groupsCount: itemCounts.group,\n },\n });\n\n const externalProps = getExternalProps(rest);\n return (\n <InternalButtonGroup\n {...baseProps}\n {...baseComponentProps}\n {...externalProps}\n ref={ref}\n variant={variant}\n dropdownExpandToViewport={dropdownExpandToViewport}\n />\n );\n }\n);\n\nfunction getItemCounts(allItems: readonly ButtonGroupProps.ItemOrGroup[] = []) {\n const counters = { 'icon-button': 0, 'icon-toggle-button': 0, 'icon-file-input': 0, 'menu-dropdown': 0, group: 0 };\n\n function count(items: readonly ButtonGroupProps.ItemOrGroup[]) {\n for (const item of items) {\n counters[item.type] += 1;\n\n if (item.type === 'group') {\n count(item.items);\n }\n }\n }\n count(allItems);\n\n return counters;\n}\n\napplyDisplayName(ButtonGroup, 'ButtonGroup');\nexport default ButtonGroup;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/button-group/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,OAAO,mBAAmB,MAAM,YAAY,CAAC;AAI7C,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAClC,CAAC,EAAwE,EAAE,GAAoC,EAAE,EAAE;QAAlH,EAAE,OAAO,EAAE,wBAAwB,GAAG,KAAK,OAA6B,EAAxB,IAAI,cAApD,uCAAsD,CAAF;IACnD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,aAAa,EAAE;QACzD,KAAK,EAAE;YACL,OAAO;YACP,wBAAwB;SACzB;QACD,QAAQ,EAAE;YACR,gBAAgB,EAAE,UAAU,CAAC,aAAa,CAAC;YAC3C,sBAAsB,EAAE,UAAU,CAAC,oBAAoB,CAAC;YACxD,mBAAmB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apache-2.0\nimport React from 'react';\n\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { getBaseProps } from '../internal/base-component';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { getExternalProps } from '../internal/utils/external-props';\nimport { GeneratedAnalyticsMetadataButtonGroupComponent } from './analytics-metadata/interfaces';\nimport { ButtonGroupProps } from './interfaces';\nimport InternalButtonGroup from './internal';\n\nexport { ButtonGroupProps };\n\nconst ButtonGroup = React.forwardRef(\n ({ variant, dropdownExpandToViewport = false, ...rest }: ButtonGroupProps, ref: React.Ref<ButtonGroupProps.Ref>) => {\n const baseProps = getBaseProps(rest);\n const itemCounts = getItemCounts(rest.items);\n const baseComponentProps = useBaseComponent('ButtonGroup', {\n props: {\n variant,\n dropdownExpandToViewport,\n },\n metadata: {\n iconButtonsCount: itemCounts['icon-button'],\n iconToggleButtonsCount: itemCounts['icon-toggle-button'],\n iconFileInputsCount: itemCounts['icon-file-input'],\n menuDropdownsCount: itemCounts['menu-dropdown'],\n groupsCount: itemCounts.group,\n },\n });\n\n const externalProps = getExternalProps(rest);\n\n const componentMetadata: GeneratedAnalyticsMetadataButtonGroupComponent = {\n name: 'awsui.ButtonGroup',\n label: { root: 'self' },\n };\n\n return (\n <InternalButtonGroup\n {...baseProps}\n {...baseComponentProps}\n {...externalProps}\n ref={ref}\n variant={variant}\n dropdownExpandToViewport={dropdownExpandToViewport}\n {...getAnalyticsMetadataAttribute({ component: componentMetadata })}\n />\n );\n }\n);\n\nfunction getItemCounts(allItems: readonly ButtonGroupProps.ItemOrGroup[] = []) {\n const counters = { 'icon-button': 0, 'icon-toggle-button': 0, 'icon-file-input': 0, 'menu-dropdown': 0, group: 0 };\n\n function count(items: readonly ButtonGroupProps.ItemOrGroup[]) {\n for (const item of items) {\n counters[item.type] += 1;\n\n if (item.type === 'group') {\n count(item.items);\n }\n }\n }\n count(allItems);\n\n return counters;\n}\n\napplyDisplayName(ButtonGroup, 'ButtonGroup');\nexport default ButtonGroup;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/button-group/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuE,MAAM,OAAO,CAAC;AAgB5F,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAM1E,QAAA,MAAM,mBAAmB,uGAsKxB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/button-group/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuE,MAAM,OAAO,CAAC;AAgB5F,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAM1E,QAAA,MAAM,mBAAmB,uGAuKxB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -105,7 +105,7 @@ const InternalButtonGroup = forwardRef((_a, ref) => {
105
105
  return (React.createElement("div", Object.assign({}, baseProps, { className: clsx(styles.root, testUtilStyles['button-group'], baseProps.className), ref: containerRef, role: "toolbar", "aria-label": ariaLabel, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown }),
106
106
  React.createElement(SingleTabStopNavigationProvider, { ref: navigationAPI, navigationActive: true, getNextFocusTarget: getNextFocusTarget, onUnregisterActive: onUnregisterActive }, items.map((itemOrGroup, index) => {
107
107
  var _a;
108
- const itemContent = (item) => (React.createElement(ItemElement, { key: item.id, item: item, dropdownExpandToViewport: dropdownExpandToViewport, tooltip: tooltip, setTooltip: setTooltip, onItemClick: onItemClick, onFilesChange: onFilesChange, ref: element => (itemsRef.current[item.id] = element) }));
108
+ const itemContent = (item, position) => (React.createElement(ItemElement, { key: item.id, item: item, dropdownExpandToViewport: dropdownExpandToViewport, tooltip: tooltip, setTooltip: setTooltip, onItemClick: onItemClick, onFilesChange: onFilesChange, ref: element => (itemsRef.current[item.id] = element), position: position }));
109
109
  const isGroupBefore = ((_a = items[index - 1]) === null || _a === void 0 ? void 0 : _a.type) === 'group';
110
110
  const currentItem = items[index];
111
111
  const isGroupNow = (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) === 'group';
@@ -115,7 +115,7 @@ const InternalButtonGroup = forwardRef((_a, ref) => {
115
115
  }
116
116
  return (React.createElement(React.Fragment, { key: itemOrGroup.type === 'group' ? index : itemOrGroup.id },
117
117
  shouldAddDivider && React.createElement("div", { className: styles.divider }),
118
- itemOrGroup.type === 'group' ? (React.createElement("div", { key: index, role: "group", "aria-label": itemOrGroup.text, className: styles.group }, itemOrGroup.items.map(item => itemContent(item)))) : (itemContent(itemOrGroup))));
118
+ itemOrGroup.type === 'group' ? (React.createElement("div", { key: index, role: "group", "aria-label": itemOrGroup.text, className: styles.group }, itemOrGroup.items.map((item, subIndex) => itemContent(item, `${index + 1},${subIndex + 1}`)))) : (itemContent(itemOrGroup, `${index + 1}`))));
119
119
  }))));
120
120
  });
121
121
  export default InternalButtonGroup;
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/button-group/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5F,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAGvF,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAEL,+BAA+B,GAChC,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CA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AI,CAAC,CAAC,CAC7C,CACP,CAAC,CAAC,CAAC,CACF,WAAW,CAAC,WAAW,CAAC,CACzB,CACc,CAClB,CAAC;QACJ,CAAC,CAAC,CAC8B,CAC9B,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { ButtonProps } from '../button/interfaces';\nimport { getBaseProps } from '../internal/base-component';\nimport { getAllFocusables } from '../internal/components/focus-lock/utils';\nimport {\n SingleTabStopNavigationAPI,\n SingleTabStopNavigationProvider,\n} from '../internal/context/single-tab-stop-navigation-context';\nimport { hasModifierKeys } from '../internal/events';\nimport { KeyCode } from '../internal/keycode';\nimport { circleIndex } from '../internal/utils/circle-index';\nimport handleKey from '../internal/utils/handle-key';\nimport { ButtonGroupProps, InternalButtonGroupProps } from './interfaces';\nimport ItemElement from './item-element.js';\n\nimport styles from './styles.css.js';\nimport testUtilStyles from './test-classes/styles.css.js';\n\nconst InternalButtonGroup = forwardRef(\n (\n {\n items = [],\n onItemClick,\n onFilesChange,\n ariaLabel,\n dropdownExpandToViewport,\n __internalRootRef = null,\n ...props\n }: InternalButtonGroupProps,\n ref: React.Ref<ButtonGroupProps.Ref>\n ) => {\n const baseProps = getBaseProps(props);\n const focusedIdRef = useRef<null | string>(null);\n const navigationAPI = useRef<SingleTabStopNavigationAPI>(null);\n const containerObjectRef = useRef<HTMLDivElement>(null);\n const containerRef = useMergeRefs(containerObjectRef, __internalRootRef);\n const itemsRef = useRef<Record<string, ButtonProps.Ref | null>>({});\n const [tooltip, setTooltip] = useState<null | { item: string; feedback: boolean }>(null);\n\n useImperativeHandle(ref, () => ({\n focus: id => {\n itemsRef.current[id]?.focus();\n },\n }));\n\n function getNextFocusTarget(): null | HTMLElement {\n if (containerObjectRef.current) {\n const buttons: HTMLButtonElement[] = Array.from(\n containerObjectRef.current.querySelectorAll(`.${testUtilStyles.item}`)\n );\n const activeButtons = buttons.filter(button => !button.disabled);\n return activeButtons.find(button => button.dataset.itemid === focusedIdRef.current) ?? activeButtons[0] ?? null;\n }\n return null;\n }\n\n function onUnregisterActive(focusableElement: HTMLElement) {\n // Only refocus when the node is actually removed (no such ID anymore).\n const target = navigationAPI.current?.getFocusTarget();\n\n if (target && target.dataset.itemid !== focusableElement.dataset.itemid) {\n target.focus();\n }\n }\n\n useEffect(() => {\n navigationAPI.current?.updateFocusTarget();\n });\n\n function onFocus(event: React.FocusEvent) {\n if (event.target instanceof HTMLElement && event.target.dataset.itemid) {\n focusedIdRef.current = event.target.dataset.itemid;\n }\n\n navigationAPI.current?.updateFocusTarget();\n }\n\n function onBlur() {\n navigationAPI.current?.updateFocusTarget();\n }\n\n function onKeyDown(event: React.KeyboardEvent) {\n const focusTarget = navigationAPI.current?.getFocusTarget();\n const specialKeys = [KeyCode.right, KeyCode.left, KeyCode.end, KeyCode.home, KeyCode.pageUp, KeyCode.pageDown];\n if (hasModifierKeys(event) || specialKeys.indexOf(event.keyCode) === -1) {\n return;\n }\n if (!containerObjectRef.current || !focusTarget) {\n return;\n }\n // Ignore navigation when the focused element is not an item.\n if (document.activeElement && !document.activeElement.matches(`.${testUtilStyles.item}`)) {\n return;\n }\n event.preventDefault();\n\n const focusables = getFocusablesFrom(containerObjectRef.current);\n const activeIndex = focusables.indexOf(focusTarget);\n handleKey(event as any, {\n onHome: () => focusElement(focusables[0]),\n onEnd: () => focusElement(focusables[focusables.length - 1]),\n onInlineStart: () => focusElement(focusables[circleIndex(activeIndex - 1, [0, focusables.length - 1])]),\n onInlineEnd: () => focusElement(focusables[circleIndex(activeIndex + 1, [0, focusables.length - 1])]),\n });\n }\n\n function focusElement(element: HTMLElement) {\n element.focus();\n }\n\n // List all non-disabled and registered focusables: those are eligible for keyboard navigation.\n function getFocusablesFrom(target: HTMLElement) {\n function isElementRegistered(element: HTMLElement) {\n return navigationAPI.current?.isRegistered(element) ?? false;\n }\n\n function isElementDisabled(element: HTMLElement) {\n if (element instanceof HTMLButtonElement) {\n return element.disabled;\n }\n\n return false;\n }\n\n return getAllFocusables(target).filter(el => isElementRegistered(el) && !isElementDisabled(el));\n }\n\n return (\n <div\n {...baseProps}\n className={clsx(styles.root, testUtilStyles['button-group'], baseProps.className)}\n ref={containerRef}\n role=\"toolbar\"\n aria-label={ariaLabel}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n >\n <SingleTabStopNavigationProvider\n ref={navigationAPI}\n navigationActive={true}\n getNextFocusTarget={getNextFocusTarget}\n onUnregisterActive={onUnregisterActive}\n >\n {items.map((itemOrGroup, index) => {\n const itemContent = (item: ButtonGroupProps.Item) => (\n <ItemElement\n key={item.id}\n item={item}\n dropdownExpandToViewport={dropdownExpandToViewport}\n tooltip={tooltip}\n setTooltip={setTooltip}\n onItemClick={onItemClick}\n onFilesChange={onFilesChange}\n ref={element => (itemsRef.current[item.id] = element)}\n />\n );\n\n const isGroupBefore = items[index - 1]?.type === 'group';\n const currentItem = items[index];\n const isGroupNow = currentItem?.type === 'group';\n const shouldAddDivider = isGroupBefore || (!isGroupBefore && isGroupNow && index !== 0);\n\n if (isGroupNow && currentItem.items.length === 0) {\n warnOnce('ButtonGroup', 'Empty group detected. Empty groups are not allowed.');\n }\n\n return (\n <React.Fragment key={itemOrGroup.type === 'group' ? index : itemOrGroup.id}>\n {shouldAddDivider && <div className={styles.divider} />}\n {itemOrGroup.type === 'group' ? (\n <div key={index} role=\"group\" aria-label={itemOrGroup.text} className={styles.group}>\n {itemOrGroup.items.map(item => itemContent(item))}\n </div>\n ) : (\n itemContent(itemOrGroup)\n )}\n </React.Fragment>\n );\n })}\n </SingleTabStopNavigationProvider>\n </div>\n );\n }\n);\n\nexport default InternalButtonGroup;\n"]}
1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AC,CAAC;YAExF,IAAI,UAAU,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;gBAChD,QAAQ,CAAC,aAAa,EAAE,qDAAqD,CAAC,CAAC;aAChF;YAED,OAAO,CACL,oBAAC,KAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,WAAW,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE;gBACvE,gBAAgB,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,OAAO,GAAI;gBACtD,WAAW,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAC9B,6BAAK,GAAG,EAAE,KAAK,EAAE,IAAI,EAAC,OAAO,gBAAa,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,IAChF,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC,CAAC,CACzF,CACP,CAAC,CAAC,CAAC,CACF,WAAW,CAAC,WAAW,EAAE,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC,CACzC,CACc,CAClB,CAAC;QACJ,CAAC,CAAC,CAC8B,CAC9B,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { ButtonProps } from '../button/interfaces';\nimport { getBaseProps } from '../internal/base-component';\nimport { getAllFocusables } from '../internal/components/focus-lock/utils';\nimport {\n SingleTabStopNavigationAPI,\n SingleTabStopNavigationProvider,\n} from '../internal/context/single-tab-stop-navigation-context';\nimport { hasModifierKeys } from '../internal/events';\nimport { KeyCode } from '../internal/keycode';\nimport { circleIndex } from '../internal/utils/circle-index';\nimport handleKey from '../internal/utils/handle-key';\nimport { ButtonGroupProps, InternalButtonGroupProps } from './interfaces';\nimport ItemElement from './item-element.js';\n\nimport styles from './styles.css.js';\nimport testUtilStyles from './test-classes/styles.css.js';\n\nconst InternalButtonGroup = forwardRef(\n (\n {\n items = [],\n onItemClick,\n onFilesChange,\n ariaLabel,\n dropdownExpandToViewport,\n __internalRootRef = null,\n ...props\n }: InternalButtonGroupProps,\n ref: React.Ref<ButtonGroupProps.Ref>\n ) => {\n const baseProps = getBaseProps(props);\n const focusedIdRef = useRef<null | string>(null);\n const navigationAPI = useRef<SingleTabStopNavigationAPI>(null);\n const containerObjectRef = useRef<HTMLDivElement>(null);\n const containerRef = useMergeRefs(containerObjectRef, __internalRootRef);\n const itemsRef = useRef<Record<string, ButtonProps.Ref | null>>({});\n const [tooltip, setTooltip] = useState<null | { item: string; feedback: boolean }>(null);\n\n useImperativeHandle(ref, () => ({\n focus: id => {\n itemsRef.current[id]?.focus();\n },\n }));\n\n function getNextFocusTarget(): null | HTMLElement {\n if (containerObjectRef.current) {\n const buttons: HTMLButtonElement[] = Array.from(\n containerObjectRef.current.querySelectorAll(`.${testUtilStyles.item}`)\n );\n const activeButtons = buttons.filter(button => !button.disabled);\n return activeButtons.find(button => button.dataset.itemid === focusedIdRef.current) ?? activeButtons[0] ?? null;\n }\n return null;\n }\n\n function onUnregisterActive(focusableElement: HTMLElement) {\n // Only refocus when the node is actually removed (no such ID anymore).\n const target = navigationAPI.current?.getFocusTarget();\n\n if (target && target.dataset.itemid !== focusableElement.dataset.itemid) {\n target.focus();\n }\n }\n\n useEffect(() => {\n navigationAPI.current?.updateFocusTarget();\n });\n\n function onFocus(event: React.FocusEvent) {\n if (event.target instanceof HTMLElement && event.target.dataset.itemid) {\n focusedIdRef.current = event.target.dataset.itemid;\n }\n\n navigationAPI.current?.updateFocusTarget();\n }\n\n function onBlur() {\n navigationAPI.current?.updateFocusTarget();\n }\n\n function onKeyDown(event: React.KeyboardEvent) {\n const focusTarget = navigationAPI.current?.getFocusTarget();\n const specialKeys = [KeyCode.right, KeyCode.left, KeyCode.end, KeyCode.home, KeyCode.pageUp, KeyCode.pageDown];\n if (hasModifierKeys(event) || specialKeys.indexOf(event.keyCode) === -1) {\n return;\n }\n if (!containerObjectRef.current || !focusTarget) {\n return;\n }\n // Ignore navigation when the focused element is not an item.\n if (document.activeElement && !document.activeElement.matches(`.${testUtilStyles.item}`)) {\n return;\n }\n event.preventDefault();\n\n const focusables = getFocusablesFrom(containerObjectRef.current);\n const activeIndex = focusables.indexOf(focusTarget);\n handleKey(event as any, {\n onHome: () => focusElement(focusables[0]),\n onEnd: () => focusElement(focusables[focusables.length - 1]),\n onInlineStart: () => focusElement(focusables[circleIndex(activeIndex - 1, [0, focusables.length - 1])]),\n onInlineEnd: () => focusElement(focusables[circleIndex(activeIndex + 1, [0, focusables.length - 1])]),\n });\n }\n\n function focusElement(element: HTMLElement) {\n element.focus();\n }\n\n // List all non-disabled and registered focusables: those are eligible for keyboard navigation.\n function getFocusablesFrom(target: HTMLElement) {\n function isElementRegistered(element: HTMLElement) {\n return navigationAPI.current?.isRegistered(element) ?? false;\n }\n\n function isElementDisabled(element: HTMLElement) {\n if (element instanceof HTMLButtonElement) {\n return element.disabled;\n }\n\n return false;\n }\n\n return getAllFocusables(target).filter(el => isElementRegistered(el) && !isElementDisabled(el));\n }\n\n return (\n <div\n {...baseProps}\n className={clsx(styles.root, testUtilStyles['button-group'], baseProps.className)}\n ref={containerRef}\n role=\"toolbar\"\n aria-label={ariaLabel}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n >\n <SingleTabStopNavigationProvider\n ref={navigationAPI}\n navigationActive={true}\n getNextFocusTarget={getNextFocusTarget}\n onUnregisterActive={onUnregisterActive}\n >\n {items.map((itemOrGroup, index) => {\n const itemContent = (item: ButtonGroupProps.Item, position: string) => (\n <ItemElement\n key={item.id}\n item={item}\n dropdownExpandToViewport={dropdownExpandToViewport}\n tooltip={tooltip}\n setTooltip={setTooltip}\n onItemClick={onItemClick}\n onFilesChange={onFilesChange}\n ref={element => (itemsRef.current[item.id] = element)}\n position={position}\n />\n );\n\n const isGroupBefore = items[index - 1]?.type === 'group';\n const currentItem = items[index];\n const isGroupNow = currentItem?.type === 'group';\n const shouldAddDivider = isGroupBefore || (!isGroupBefore && isGroupNow && index !== 0);\n\n if (isGroupNow && currentItem.items.length === 0) {\n warnOnce('ButtonGroup', 'Empty group detected. Empty groups are not allowed.');\n }\n\n return (\n <React.Fragment key={itemOrGroup.type === 'group' ? index : itemOrGroup.id}>\n {shouldAddDivider && <div className={styles.divider} />}\n {itemOrGroup.type === 'group' ? (\n <div key={index} role=\"group\" aria-label={itemOrGroup.text} className={styles.group}>\n {itemOrGroup.items.map((item, subIndex) => itemContent(item, `${index + 1},${subIndex + 1}`))}\n </div>\n ) : (\n itemContent(itemOrGroup, `${index + 1}`)\n )}\n </React.Fragment>\n );\n })}\n </SingleTabStopNavigationProvider>\n </div>\n );\n }\n);\n\nexport default InternalButtonGroup;\n"]}
@@ -15,6 +15,7 @@ interface ItemElementProps {
15
15
  }) => void;
16
16
  onItemClick?: NonCancelableEventHandler<ButtonGroupProps.ItemClickDetails> | undefined;
17
17
  onFilesChange?: NonCancelableEventHandler<ButtonGroupProps.FilesChangeDetails> | undefined;
18
+ position: string;
18
19
  }
19
20
  declare const ItemElement: React.ForwardRefExoticComponent<ItemElementProps & React.RefAttributes<ButtonProps.Ref>>;
20
21
  export default ItemElement;
@@ -1 +1 @@
1
- {"version":3,"file":"item-element.d.ts","sourceRoot":"","sources":["../../../src/button-group/item-element.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6D,MAAM,OAAO,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AA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AI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IAC1E,WAAW,CAAC,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC;IACvF,aAAa,CAAC,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,SAAS,CAAC;IAC3F,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,QAAA,MAAM,WAAW,0FA+IhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,6 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
4
+ import { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';
4
5
  import { fireCancelableEvent } from '../internal/events';
5
6
  import { nodeBelongs } from '../internal/utils/node-belongs';
6
7
  import FileInputItem from './file-input-item';
@@ -8,7 +9,7 @@ import IconButtonItem from './icon-button-item';
8
9
  import IconToggleButtonItem from './icon-toggle-button-item.js';
9
10
  import MenuDropdownItem from './menu-dropdown-item';
10
11
  import styles from './styles.css.js';
11
- const ItemElement = forwardRef(({ item, dropdownExpandToViewport, tooltip, setTooltip, onItemClick, onFilesChange }, ref) => {
12
+ const ItemElement = forwardRef(({ item, dropdownExpandToViewport, tooltip, setTooltip, onItemClick, onFilesChange, position }, ref) => {
12
13
  const containerRef = useRef(null);
13
14
  const buttonRef = useRef(null);
14
15
  const fileInputRef = useRef(null);
@@ -69,18 +70,20 @@ const ItemElement = forwardRef(({ item, dropdownExpandToViewport, tooltip, setTo
69
70
  fireCancelableEvent(onFilesChange, event.detail, event);
70
71
  setTooltip(null);
71
72
  };
72
- return (React.createElement("div", { key: item.id, className: styles['item-wrapper'], ref: containerRef, onPointerEnter: () => onShowTooltipSoft(true), onPointerLeave: () => onShowTooltipSoft(false), onFocus: event => {
73
+ return (React.createElement("div", Object.assign({ key: item.id, className: styles['item-wrapper'], ref: containerRef, onPointerEnter: () => onShowTooltipSoft(true), onPointerLeave: () => onShowTooltipSoft(false), onFocus: event => {
73
74
  // Showing no tooltip when the focus comes from inside the container.
74
75
  // This is needed to prevent the tooltip after a menu closes with item selection or Escape.
75
76
  if (event && event.relatedTarget && nodeBelongs(containerRef.current, event.relatedTarget)) {
76
77
  return;
77
78
  }
78
79
  onShowTooltipHard(true);
79
- }, onBlur: () => onShowTooltipHard(false) },
80
+ }, onBlur: () => onShowTooltipHard(false) }, (item.type === 'menu-dropdown' || item.disabled
81
+ ? {}
82
+ : getAnalyticsMetadataAttribute({ detail: { position, id: item.id } }))),
80
83
  item.type === 'icon-button' && (React.createElement(IconButtonItem, { ref: buttonRef, item: item, onItemClick: onClickHandler, showTooltip: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.item) === item.id, showFeedback: !!(tooltip === null || tooltip === void 0 ? void 0 : tooltip.feedback), onTooltipDismiss: () => setTooltip(null) })),
81
84
  item.type === 'icon-toggle-button' && (React.createElement(IconToggleButtonItem, { ref: buttonRef, item: item, onItemClick: onClickHandler, showTooltip: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.item) === item.id, showFeedback: !!(tooltip === null || tooltip === void 0 ? void 0 : tooltip.feedback), onTooltipDismiss: () => setTooltip(null) })),
82
85
  item.type === 'icon-file-input' && (React.createElement(FileInputItem, { ref: fileInputRef, item: item, onFilesChange: onFilesChangeHandler, showTooltip: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.item) === item.id, onTooltipDismiss: () => setTooltip(null) })),
83
- item.type === 'menu-dropdown' && (React.createElement(MenuDropdownItem, { ref: buttonDropdownRef, item: item, showTooltip: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.item) === item.id, onItemClick: onClickHandler, expandToViewport: dropdownExpandToViewport, onTooltipDismiss: () => setTooltip(null) }))));
86
+ item.type === 'menu-dropdown' && (React.createElement(MenuDropdownItem, { ref: buttonDropdownRef, item: item, showTooltip: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.item) === item.id, onItemClick: onClickHandler, expandToViewport: dropdownExpandToViewport, onTooltipDismiss: () => setTooltip(null), position: position }))));
84
87
  });
85
88
  export default ItemElement;
86
89
  //# sourceMappingURL=item-element.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"item-element.js","sourceRoot":"","sources":["../../../src/button-group/item-element.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAKlF,OAAO,EAAE,mBAAmB,EAA6B,MAAM,oBAAoB,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAEhE,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AAEpD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAWrC,MAAM,WAAW,GAAG,UAAU,CAC5B,CACE,EAAE,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAoB,EACrG,GAA+B,EAC/B,EAAE;IACF,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,MAAM,CAAkB,IAAI,CAAC,CAAC;IAChD,MAAM,YAAY,GAAG,MAAM,CAAqB,IAAI,CAAC,CAAC;IACtD,MAAM,iBAAiB,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAC;IAEhE,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,KAAK,EAAE,GAAG,EAAE;;YACV,MAAA,SAAS,CAAC,OAAO,0C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AAC,IAAI,CAAC,GACxC,CACH;QACA,IAAI,CAAC,IAAI,KAAK,iBAAiB,IAAI,CAClC,oBAAC,aAAa,IACZ,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,oBAAoB,EACnC,WAAW,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,IAAI,CAAC,EAAE,EACtC,gBAAgB,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,GACxC,CACH;QACA,IAAI,CAAC,IAAI,KAAK,eAAe,IAAI,CAChC,oBAAC,gBAAgB,IACf,GAAG,EAAE,iBAAiB,EACtB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,IAAI,CAAC,EAAE,EACtC,WAAW,EAAE,cAAc,EAC3B,gBAAgB,EAAE,wBAAwB,EAC1C,gBAAgB,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,GACxC,CACH,CACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';\n\nimport { ButtonProps } from '../button/interfaces.js';\nimport { ButtonDropdownProps } from '../button-dropdown/interfaces.js';\nimport { FileInputProps } from '../file-input/interfaces';\nimport { fireCancelableEvent, NonCancelableEventHandler } from '../internal/events';\nimport { nodeBelongs } from '../internal/utils/node-belongs';\nimport FileInputItem from './file-input-item';\nimport IconButtonItem from './icon-button-item';\nimport IconToggleButtonItem from './icon-toggle-button-item.js';\nimport { ButtonGroupProps } from './interfaces';\nimport MenuDropdownItem from './menu-dropdown-item';\n\nimport styles from './styles.css.js';\n\ninterface ItemElementProps {\n item: ButtonGroupProps.Item;\n dropdownExpandToViewport?: boolean;\n tooltip: null | { item: string; feedback: boolean };\n setTooltip: (tooltip: null | { item: string; feedback: boolean }) => void;\n onItemClick?: NonCancelableEventHandler<ButtonGroupProps.ItemClickDetails> | undefined;\n onFilesChange?: NonCancelableEventHandler<ButtonGroupProps.FilesChangeDetails> | undefined;\n}\n\nconst ItemElement = forwardRef(\n (\n { item, dropdownExpandToViewport, tooltip, setTooltip, onItemClick, onFilesChange }: ItemElementProps,\n ref: React.Ref<ButtonProps.Ref>\n ) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const buttonRef = useRef<ButtonProps.Ref>(null);\n const fileInputRef = useRef<FileInputProps.Ref>(null);\n const buttonDropdownRef = useRef<ButtonDropdownProps.Ref>(null);\n\n useImperativeHandle(ref, () => ({\n focus: () => {\n buttonRef.current?.focus();\n fileInputRef.current?.focus();\n buttonDropdownRef.current?.focus();\n },\n }));\n\n useEffect(() => {\n if (tooltip?.item !== item.id) {\n return;\n }\n\n const close = () => {\n setTooltip(null);\n };\n\n const handlePointerDownEvent = (event: PointerEvent) => {\n if (event.target && containerRef.current?.contains(event.target as HTMLElement)) {\n return;\n }\n\n close();\n };\n\n const handleKeyDownEvent = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n close();\n }\n };\n\n const controller = new AbortController();\n window.addEventListener('pointerdown', handlePointerDownEvent, { signal: controller.signal });\n window.addEventListener('keydown', handleKeyDownEvent, { signal: controller.signal });\n\n return () => {\n controller.abort();\n };\n }, [item.id, tooltip, setTooltip]);\n\n const onShowTooltipSoft = (show: boolean) => {\n if (!tooltip?.feedback) {\n setTooltip(show ? { item: item.id, feedback: false } : null);\n }\n };\n\n const onShowTooltipHard = (show: boolean) => {\n if (!show && item.id !== tooltip?.item) {\n return;\n }\n\n setTooltip(show ? { item: item.id, feedback: false } : null);\n };\n\n const onClickHandler = (event: CustomEvent<ButtonGroupProps.ItemClickDetails>) => {\n const hasPopoverFeedback = 'popoverFeedback' in item && item.popoverFeedback;\n\n if (hasPopoverFeedback) {\n setTooltip({ item: item.id, feedback: true });\n }\n\n fireCancelableEvent(onItemClick, event.detail, event);\n };\n\n const onFilesChangeHandler = (event: CustomEvent<ButtonGroupProps.FilesChangeDetails>) => {\n fireCancelableEvent(onFilesChange, event.detail, event);\n\n setTooltip(null);\n };\n\n return (\n <div\n key={item.id}\n className={styles['item-wrapper']}\n ref={containerRef}\n onPointerEnter={() => onShowTooltipSoft(true)}\n onPointerLeave={() => onShowTooltipSoft(false)}\n onFocus={event => {\n // Showing no tooltip when the focus comes from inside the container.\n // This is needed to prevent the tooltip after a menu closes with item selection or Escape.\n if (event && event.relatedTarget && nodeBelongs(containerRef.current, event.relatedTarget)) {\n return;\n }\n onShowTooltipHard(true);\n }}\n onBlur={() => onShowTooltipHard(false)}\n >\n {item.type === 'icon-button' && (\n <IconButtonItem\n ref={buttonRef}\n item={item}\n onItemClick={onClickHandler}\n showTooltip={tooltip?.item === item.id}\n showFeedback={!!tooltip?.feedback}\n onTooltipDismiss={() => setTooltip(null)}\n />\n )}\n {item.type === 'icon-toggle-button' && (\n <IconToggleButtonItem\n ref={buttonRef}\n item={item}\n onItemClick={onClickHandler}\n showTooltip={tooltip?.item === item.id}\n showFeedback={!!tooltip?.feedback}\n onTooltipDismiss={() => setTooltip(null)}\n />\n )}\n {item.type === 'icon-file-input' && (\n <FileInputItem\n ref={fileInputRef}\n item={item}\n onFilesChange={onFilesChangeHandler}\n showTooltip={tooltip?.item === item.id}\n onTooltipDismiss={() => setTooltip(null)}\n />\n )}\n {item.type === 'menu-dropdown' && (\n <MenuDropdownItem\n ref={buttonDropdownRef}\n item={item}\n showTooltip={tooltip?.item === item.id}\n onItemClick={onClickHandler}\n expandToViewport={dropdownExpandToViewport}\n onTooltipDismiss={() => setTooltip(null)}\n />\n )}\n </div>\n );\n }\n);\n\nexport default ItemElement;\n"]}
1
+ {"version":3,"file":"item-element.js","sourceRoot":"","sources":["../../../src/button-group/item-element.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAs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,IAAI,KAAK,iBAAiB,IAAI,CAClC,oBAAC,aAAa,IACZ,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,oBAAoB,EACnC,WAAW,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,IAAI,CAAC,EAAE,EACtC,gBAAgB,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,GACxC,CACH;QACA,IAAI,CAAC,IAAI,KAAK,eAAe,IAAI,CAChC,oBAAC,gBAAgB,IACf,GAAG,EAAE,iBAAiB,EACtB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,IAAI,CAAC,EAAE,EACtC,WAAW,EAAE,cAAc,EAC3B,gBAAgB,EAAE,wBAAwB,EAC1C,gBAAgB,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EACxC,QAAQ,EAAE,QAAQ,GAClB,CACH,CACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';\n\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { ButtonProps } from '../button/interfaces.js';\nimport { ButtonDropdownProps } from '../button-dropdown/interfaces.js';\nimport { FileInputProps } from '../file-input/interfaces';\nimport { fireCancelableEvent, NonCancelableEventHandler } from '../internal/events';\nimport { nodeBelongs } from '../internal/utils/node-belongs';\nimport FileInputItem from './file-input-item';\nimport IconButtonItem from './icon-button-item';\nimport IconToggleButtonItem from './icon-toggle-button-item.js';\nimport { ButtonGroupProps } from './interfaces';\nimport MenuDropdownItem from './menu-dropdown-item';\n\nimport styles from './styles.css.js';\n\ninterface ItemElementProps {\n item: ButtonGroupProps.Item;\n dropdownExpandToViewport?: boolean;\n tooltip: null | { item: string; feedback: boolean };\n setTooltip: (tooltip: null | { item: string; feedback: boolean }) => void;\n onItemClick?: NonCancelableEventHandler<ButtonGroupProps.ItemClickDetails> | undefined;\n onFilesChange?: NonCancelableEventHandler<ButtonGroupProps.FilesChangeDetails> | undefined;\n position: string;\n}\n\nconst ItemElement = forwardRef(\n (\n { item, dropdownExpandToViewport, tooltip, setTooltip, onItemClick, onFilesChange, position }: ItemElementProps,\n ref: React.Ref<ButtonProps.Ref>\n ) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const buttonRef = useRef<ButtonProps.Ref>(null);\n const fileInputRef = useRef<FileInputProps.Ref>(null);\n const buttonDropdownRef = useRef<ButtonDropdownProps.Ref>(null);\n\n useImperativeHandle(ref, () => ({\n focus: () => {\n buttonRef.current?.focus();\n fileInputRef.current?.focus();\n buttonDropdownRef.current?.focus();\n },\n }));\n\n useEffect(() => {\n if (tooltip?.item !== item.id) {\n return;\n }\n\n const close = () => {\n setTooltip(null);\n };\n\n const handlePointerDownEvent = (event: PointerEvent) => {\n if (event.target && containerRef.current?.contains(event.target as HTMLElement)) {\n return;\n }\n\n close();\n };\n\n const handleKeyDownEvent = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n close();\n }\n };\n\n const controller = new AbortController();\n window.addEventListener('pointerdown', handlePointerDownEvent, { signal: controller.signal });\n window.addEventListener('keydown', handleKeyDownEvent, { signal: controller.signal });\n\n return () => {\n controller.abort();\n };\n }, [item.id, tooltip, setTooltip]);\n\n const onShowTooltipSoft = (show: boolean) => {\n if (!tooltip?.feedback) {\n setTooltip(show ? { item: item.id, feedback: false } : null);\n }\n };\n\n const onShowTooltipHard = (show: boolean) => {\n if (!show && item.id !== tooltip?.item) {\n return;\n }\n\n setTooltip(show ? { item: item.id, feedback: false } : null);\n };\n\n const onClickHandler = (event: CustomEvent<ButtonGroupProps.ItemClickDetails>) => {\n const hasPopoverFeedback = 'popoverFeedback' in item && item.popoverFeedback;\n\n if (hasPopoverFeedback) {\n setTooltip({ item: item.id, feedback: true });\n }\n\n fireCancelableEvent(onItemClick, event.detail, event);\n };\n\n const onFilesChangeHandler = (event: CustomEvent<ButtonGroupProps.FilesChangeDetails>) => {\n fireCancelableEvent(onFilesChange, event.detail, event);\n\n setTooltip(null);\n };\n\n return (\n <div\n key={item.id}\n className={styles['item-wrapper']}\n ref={containerRef}\n onPointerEnter={() => onShowTooltipSoft(true)}\n onPointerLeave={() => onShowTooltipSoft(false)}\n onFocus={event => {\n // Showing no tooltip when the focus comes from inside the container.\n // This is needed to prevent the tooltip after a menu closes with item selection or Escape.\n if (event && event.relatedTarget && nodeBelongs(containerRef.current, event.relatedTarget)) {\n return;\n }\n onShowTooltipHard(true);\n }}\n onBlur={() => onShowTooltipHard(false)}\n {...(item.type === 'menu-dropdown' || (item as ButtonGroupProps.IconButton).disabled\n ? {}\n : getAnalyticsMetadataAttribute({ detail: { position, id: item.id } }))}\n >\n {item.type === 'icon-button' && (\n <IconButtonItem\n ref={buttonRef}\n item={item}\n onItemClick={onClickHandler}\n showTooltip={tooltip?.item === item.id}\n showFeedback={!!tooltip?.feedback}\n onTooltipDismiss={() => setTooltip(null)}\n />\n )}\n {item.type === 'icon-toggle-button' && (\n <IconToggleButtonItem\n ref={buttonRef}\n item={item}\n onItemClick={onClickHandler}\n showTooltip={tooltip?.item === item.id}\n showFeedback={!!tooltip?.feedback}\n onTooltipDismiss={() => setTooltip(null)}\n />\n )}\n {item.type === 'icon-file-input' && (\n <FileInputItem\n ref={fileInputRef}\n item={item}\n onFilesChange={onFilesChangeHandler}\n showTooltip={tooltip?.item === item.id}\n onTooltipDismiss={() => setTooltip(null)}\n />\n )}\n {item.type === 'menu-dropdown' && (\n <MenuDropdownItem\n ref={buttonDropdownRef}\n item={item}\n showTooltip={tooltip?.item === item.id}\n onItemClick={onClickHandler}\n expandToViewport={dropdownExpandToViewport}\n onTooltipDismiss={() => setTooltip(null)}\n position={position}\n />\n )}\n </div>\n );\n }\n);\n\nexport default ItemElement;\n"]}
@@ -8,6 +8,7 @@ interface MenuDropdownItemProps {
8
8
  onTooltipDismiss: () => void;
9
9
  onItemClick?: CancelableEventHandler<ButtonGroupProps.ItemClickDetails>;
10
10
  expandToViewport?: boolean;
11
+ position: string;
11
12
  }
12
13
  declare const MenuDropdownItem: React.ForwardRefExoticComponent<MenuDropdownItemProps & React.RefAttributes<ButtonDropdownProps.Ref>>;
13
14
  export default MenuDropdownItem;
@@ -1 +1 @@
1
- {"version":3,"file":"menu-dropdown-item.d.ts","sourceRoot":"","sources":["../../../src/button-group/menu-dropdown-item.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGpE,OAAO,EAAE,sBAAsB,EAAuB,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,UAAU,qBAAqB;IAC7B,IAAI,EAAE,gBAAgB,CAAC,YAAY,CAAC;IACpC,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,WAAW,CAAC,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACxE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,QAAA,MAAM,gBAAgB,uGAmDrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"menu-dropdown-item.d.ts","sourceRoot":"","sources":["../../../src/button-group/menu-dropdown-item.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGpE,OAAO,EAAE,sBAAsB,EAAuB,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,UAAU,qBAAqB;IAC7B,IAAI,EAAE,gBAAgB,CAAC,YAAY,CAAC;IACpC,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,WAAW,CAAC,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACxE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,QAAA,MAAM,gBAAgB,uGAqDrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -2,17 +2,18 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import React from 'react';
4
4
  import clsx from 'clsx';
5
+ import { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';
5
6
  import InternalButton from '../button/internal';
6
7
  import ButtonDropdown from '../button-dropdown/internal';
7
8
  import Tooltip from '../internal/components/tooltip';
8
9
  import { fireCancelableEvent } from '../internal/events';
9
10
  import testUtilStyles from './test-classes/styles.css.js';
10
- const MenuDropdownItem = React.forwardRef(({ item, showTooltip, onItemClick, onTooltipDismiss, expandToViewport }, ref) => {
11
+ const MenuDropdownItem = React.forwardRef(({ item, showTooltip, onItemClick, onTooltipDismiss, expandToViewport, position }, ref) => {
11
12
  const containerRef = React.useRef(null);
12
13
  const onClickHandler = (event) => {
13
14
  fireCancelableEvent(onItemClick, { id: event.detail.id, checked: event.detail.checked }, event);
14
15
  };
15
- return (React.createElement(ButtonDropdown, { ref: ref, variant: "icon", items: item.items, onItemClick: onClickHandler, expandToViewport: expandToViewport, ariaLabel: item.text, className: testUtilStyles['button-group-item'], "data-testid": item.id, customTriggerBuilder: ({ onClick, isOpen, triggerRef, ariaLabel, ariaExpanded, testUtilsClass }) => (React.createElement("div", { ref: containerRef },
16
+ return (React.createElement(ButtonDropdown, { ref: ref, variant: "icon", items: item.items, onItemClick: onClickHandler, expandToViewport: expandToViewport, ariaLabel: item.text, className: testUtilStyles['button-group-item'], position: position, "data-testid": item.id, disabled: item.disabled, customTriggerBuilder: ({ onClick, isOpen, triggerRef, ariaLabel, ariaExpanded, testUtilsClass }) => (React.createElement("div", Object.assign({ ref: containerRef }, (item.disabled ? {} : getAnalyticsMetadataAttribute({ detail: { position } }))),
16
17
  !isOpen && showTooltip && !item.disabled && !item.loading && (React.createElement(Tooltip, { trackRef: containerRef, trackKey: item.id, value: item.text, className: clsx(testUtilStyles.tooltip, testUtilStyles['button-group-tooltip']), onDismiss: onTooltipDismiss })),
17
18
  React.createElement(InternalButton, { ref: triggerRef, variant: "icon", ariaLabel: ariaLabel, "data-itemid": item.id, ariaExpanded: ariaExpanded, className: clsx(testUtilStyles.item, testUtilsClass), iconName: "ellipsis", loading: item.loading, loadingText: item.loadingText, disabled: item.disabled, disabledReason: item.disabledReason, onClick: onClick, __title: "" }))) }));
18
19
  });