@cloudscape-design/components-themeable 3.0.813 → 3.0.815

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 (166) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/{internal/components/live-region → live-region}/styles.scss +1 -1
  3. package/lib/internal/scss/live-region/test-classes/styles.scss +12 -0
  4. package/lib/internal/template/attribute-editor/additional-info.js +1 -1
  5. package/lib/internal/template/attribute-editor/additional-info.js.map +1 -1
  6. package/lib/internal/template/attribute-editor/internal.js +1 -1
  7. package/lib/internal/template/attribute-editor/internal.js.map +1 -1
  8. package/lib/internal/template/button/internal.d.ts.map +1 -1
  9. package/lib/internal/template/button/internal.js +1 -1
  10. package/lib/internal/template/button/internal.js.map +1 -1
  11. package/lib/internal/template/button-group/icon-button-item.d.ts.map +1 -1
  12. package/lib/internal/template/button-group/icon-button-item.js +1 -1
  13. package/lib/internal/template/button-group/icon-button-item.js.map +1 -1
  14. package/lib/internal/template/cards/index.js +1 -1
  15. package/lib/internal/template/cards/index.js.map +1 -1
  16. package/lib/internal/template/code-editor/index.js +1 -1
  17. package/lib/internal/template/code-editor/index.js.map +1 -1
  18. package/lib/internal/template/code-editor/status-bar.js +1 -1
  19. package/lib/internal/template/code-editor/status-bar.js.map +1 -1
  20. package/lib/internal/template/date-picker/index.js +1 -1
  21. package/lib/internal/template/date-picker/index.js.map +1 -1
  22. package/lib/internal/template/date-range-picker/calendar/header/index.d.ts.map +1 -1
  23. package/lib/internal/template/date-range-picker/calendar/header/index.js +2 -2
  24. package/lib/internal/template/date-range-picker/calendar/header/index.js.map +1 -1
  25. package/lib/internal/template/date-range-picker/calendar/index.js +1 -1
  26. package/lib/internal/template/date-range-picker/calendar/index.js.map +1 -1
  27. package/lib/internal/template/date-range-picker/dropdown.js +1 -1
  28. package/lib/internal/template/date-range-picker/dropdown.js.map +1 -1
  29. package/lib/internal/template/drawer/implementation.d.ts.map +1 -1
  30. package/lib/internal/template/drawer/implementation.js +1 -1
  31. package/lib/internal/template/drawer/implementation.js.map +1 -1
  32. package/lib/internal/template/flashbar/flash.js +1 -1
  33. package/lib/internal/template/flashbar/flash.js.map +1 -1
  34. package/lib/internal/template/form/internal.d.ts.map +1 -1
  35. package/lib/internal/template/form/internal.js +1 -1
  36. package/lib/internal/template/form/internal.js.map +1 -1
  37. package/lib/internal/template/form-field/internal.js +1 -1
  38. package/lib/internal/template/form-field/internal.js.map +1 -1
  39. package/lib/internal/template/help-panel/implementation.d.ts.map +1 -1
  40. package/lib/internal/template/help-panel/implementation.js +1 -1
  41. package/lib/internal/template/help-panel/implementation.js.map +1 -1
  42. package/lib/internal/template/index.d.ts +1 -0
  43. package/lib/internal/template/index.d.ts.map +1 -1
  44. package/lib/internal/template/index.js +1 -0
  45. package/lib/internal/template/index.js.map +1 -1
  46. package/lib/internal/template/internal/analytics/index.d.ts.map +1 -1
  47. package/lib/internal/template/internal/analytics/index.js +1 -0
  48. package/lib/internal/template/internal/analytics/index.js.map +1 -1
  49. package/lib/internal/template/internal/analytics/interfaces.d.ts +12 -1
  50. package/lib/internal/template/internal/analytics/interfaces.d.ts.map +1 -1
  51. package/lib/internal/template/internal/analytics/interfaces.js.map +1 -1
  52. package/lib/internal/template/internal/base-component/styles.scoped.css +23 -37
  53. package/lib/internal/template/internal/components/chart-plot/index.d.ts.map +1 -1
  54. package/lib/internal/template/internal/components/chart-plot/index.js +1 -1
  55. package/lib/internal/template/internal/components/chart-plot/index.js.map +1 -1
  56. package/lib/internal/template/internal/components/chart-status-container/index.d.ts.map +1 -1
  57. package/lib/internal/template/internal/components/chart-status-container/index.js +1 -1
  58. package/lib/internal/template/internal/components/chart-status-container/index.js.map +1 -1
  59. package/lib/internal/template/internal/components/dropdown-footer/index.js +1 -1
  60. package/lib/internal/template/internal/components/dropdown-footer/index.js.map +1 -1
  61. package/lib/internal/template/internal/environment.js +1 -1
  62. package/lib/internal/template/internal/environment.json +1 -1
  63. package/lib/internal/template/internal/generated/styles/tokens.js +3 -3
  64. package/lib/internal/template/internal/generated/theming/index.cjs +34 -32
  65. package/lib/internal/template/internal/generated/theming/index.cjs.d.ts +16 -0
  66. package/lib/internal/template/internal/generated/theming/index.d.ts +16 -0
  67. package/lib/internal/template/internal/generated/theming/index.js +34 -32
  68. package/lib/internal/template/internal/hooks/use-dom-attribute/index.d.ts +5 -0
  69. package/lib/internal/template/internal/hooks/use-dom-attribute/index.d.ts.map +1 -0
  70. package/lib/internal/template/internal/hooks/use-dom-attribute/index.js +19 -0
  71. package/lib/internal/template/internal/hooks/use-dom-attribute/index.js.map +1 -0
  72. package/lib/internal/template/internal/hooks/use-performance-marks/index.d.ts +1 -1
  73. package/lib/internal/template/internal/hooks/use-performance-marks/index.d.ts.map +1 -1
  74. package/lib/internal/template/internal/hooks/use-performance-marks/index.js +3 -18
  75. package/lib/internal/template/internal/hooks/use-performance-marks/index.js.map +1 -1
  76. package/lib/internal/template/internal/hooks/use-table-interaction-metrics/index.d.ts +8 -1
  77. package/lib/internal/template/internal/hooks/use-table-interaction-metrics/index.d.ts.map +1 -1
  78. package/lib/internal/template/internal/hooks/use-table-interaction-metrics/index.js +24 -6
  79. package/lib/internal/template/internal/hooks/use-table-interaction-metrics/index.js.map +1 -1
  80. package/lib/internal/template/live-region/controller.d.ts.map +1 -0
  81. package/lib/internal/template/{internal/components/live-region → live-region}/controller.js +2 -2
  82. package/lib/internal/template/live-region/controller.js.map +1 -0
  83. package/lib/internal/template/live-region/index.d.ts.map +1 -0
  84. package/lib/internal/template/{internal/components/live-region → live-region}/index.js +3 -5
  85. package/lib/internal/template/live-region/index.js.map +1 -0
  86. package/lib/internal/template/{internal/components/live-region → live-region}/interfaces.d.ts +5 -11
  87. package/lib/internal/template/live-region/interfaces.d.ts.map +1 -0
  88. package/lib/internal/template/live-region/interfaces.js.map +1 -0
  89. package/lib/internal/template/{internal/components/live-region → live-region}/internal.d.ts +1 -1
  90. package/lib/internal/template/live-region/internal.d.ts.map +1 -0
  91. package/lib/internal/template/{internal/components/live-region → live-region}/internal.js +11 -11
  92. package/lib/internal/template/live-region/internal.js.map +1 -0
  93. package/lib/internal/template/live-region/styles.css.js +7 -0
  94. package/lib/internal/template/{internal/components/live-region → live-region}/styles.scoped.css +3 -3
  95. package/lib/internal/template/{internal/components/live-region → live-region}/styles.selectors.js +2 -2
  96. package/lib/internal/template/live-region/test-classes/styles.css.js +7 -0
  97. package/lib/internal/template/live-region/test-classes/styles.scoped.css +11 -0
  98. package/lib/internal/template/live-region/test-classes/styles.selectors.js +8 -0
  99. package/lib/internal/template/package.json +1 -0
  100. package/lib/internal/template/pie-chart/pie-chart.d.ts.map +1 -1
  101. package/lib/internal/template/pie-chart/pie-chart.js +1 -1
  102. package/lib/internal/template/pie-chart/pie-chart.js.map +1 -1
  103. package/lib/internal/template/progress-bar/index.js +1 -1
  104. package/lib/internal/template/progress-bar/index.js.map +1 -1
  105. package/lib/internal/template/property-filter/token-editor.d.ts.map +1 -1
  106. package/lib/internal/template/property-filter/token-editor.js +5 -1
  107. package/lib/internal/template/property-filter/token-editor.js.map +1 -1
  108. package/lib/internal/template/s3-resource-selector/s3-in-context/index.js +2 -2
  109. package/lib/internal/template/s3-resource-selector/s3-in-context/index.js.map +1 -1
  110. package/lib/internal/template/s3-resource-selector/s3-modal/basic-table.d.ts.map +1 -1
  111. package/lib/internal/template/s3-resource-selector/s3-modal/basic-table.js +1 -1
  112. package/lib/internal/template/s3-resource-selector/s3-modal/basic-table.js.map +1 -1
  113. package/lib/internal/template/select/parts/filter.d.ts +1 -1
  114. package/lib/internal/template/table/body-cell/disabled-inline-editor.js +1 -1
  115. package/lib/internal/template/table/body-cell/disabled-inline-editor.js.map +1 -1
  116. package/lib/internal/template/table/body-cell/index.d.ts.map +1 -1
  117. package/lib/internal/template/table/body-cell/index.js +2 -2
  118. package/lib/internal/template/table/body-cell/index.js.map +1 -1
  119. package/lib/internal/template/table/body-cell/inline-editor.d.ts.map +1 -1
  120. package/lib/internal/template/table/body-cell/inline-editor.js +4 -4
  121. package/lib/internal/template/table/body-cell/inline-editor.js.map +1 -1
  122. package/lib/internal/template/table/internal.d.ts.map +1 -1
  123. package/lib/internal/template/table/internal.js +26 -14
  124. package/lib/internal/template/table/internal.js.map +1 -1
  125. package/lib/internal/template/table/no-data-cell.js +1 -1
  126. package/lib/internal/template/table/no-data-cell.js.map +1 -1
  127. package/lib/internal/template/table/progressive-loading/items-loader.js +1 -1
  128. package/lib/internal/template/table/progressive-loading/items-loader.js.map +1 -1
  129. package/lib/internal/template/tag-editor/index.js +1 -1
  130. package/lib/internal/template/tag-editor/index.js.map +1 -1
  131. package/lib/internal/template/test-utils/dom/index.d.ts +3 -0
  132. package/lib/internal/template/test-utils/dom/index.js +10 -2
  133. package/lib/internal/template/test-utils/dom/index.js.map +1 -1
  134. package/lib/internal/template/test-utils/dom/{internal/live-region.js → live-region/index.js} +2 -2
  135. package/lib/internal/template/test-utils/dom/live-region/index.js.map +1 -0
  136. package/lib/internal/template/test-utils/selectors/index.d.ts +3 -0
  137. package/lib/internal/template/test-utils/selectors/index.js +10 -2
  138. package/lib/internal/template/test-utils/selectors/index.js.map +1 -1
  139. package/lib/internal/template/test-utils/selectors/{internal/live-region.js → live-region/index.js} +2 -2
  140. package/lib/internal/template/test-utils/selectors/live-region/index.js.map +1 -0
  141. package/lib/internal/template/test-utils/tsconfig.tsbuildinfo +1 -1
  142. package/lib/internal/template/text-filter/search-results.js +1 -1
  143. package/lib/internal/template/text-filter/search-results.js.map +1 -1
  144. package/lib/internal/template/tutorial-panel/components/tutorial-list/index.js +1 -1
  145. package/lib/internal/template/tutorial-panel/components/tutorial-list/index.js.map +1 -1
  146. package/package.json +1 -1
  147. package/lib/internal/template/internal/components/live-region/controller.d.ts.map +0 -1
  148. package/lib/internal/template/internal/components/live-region/controller.js.map +0 -1
  149. package/lib/internal/template/internal/components/live-region/index.d.ts.map +0 -1
  150. package/lib/internal/template/internal/components/live-region/index.js.map +0 -1
  151. package/lib/internal/template/internal/components/live-region/interfaces.d.ts.map +0 -1
  152. package/lib/internal/template/internal/components/live-region/interfaces.js.map +0 -1
  153. package/lib/internal/template/internal/components/live-region/internal.d.ts.map +0 -1
  154. package/lib/internal/template/internal/components/live-region/internal.js.map +0 -1
  155. package/lib/internal/template/internal/components/live-region/styles.css.js +0 -7
  156. package/lib/internal/template/internal/hooks/use-component-analytics/index.d.ts +0 -8
  157. package/lib/internal/template/internal/hooks/use-component-analytics/index.d.ts.map +0 -1
  158. package/lib/internal/template/internal/hooks/use-component-analytics/index.js +0 -28
  159. package/lib/internal/template/internal/hooks/use-component-analytics/index.js.map +0 -1
  160. package/lib/internal/template/test-utils/dom/internal/live-region.js.map +0 -1
  161. package/lib/internal/template/test-utils/selectors/internal/live-region.js.map +0 -1
  162. /package/lib/internal/template/{internal/components/live-region → live-region}/controller.d.ts +0 -0
  163. /package/lib/internal/template/{internal/components/live-region → live-region}/index.d.ts +0 -0
  164. /package/lib/internal/template/{internal/components/live-region → live-region}/interfaces.js +0 -0
  165. /package/lib/internal/template/test-utils/dom/{internal/live-region.d.ts → live-region/index.d.ts} +0 -0
  166. /package/lib/internal/template/test-utils/selectors/{internal/live-region.d.ts → live-region/index.d.ts} +0 -0
@@ -1078,12 +1078,12 @@ export var preset = {
1078
1078
  "dark": "{colorGrey850}"
1079
1079
  },
1080
1080
  "colorTextChatBubbleOutgoing": {
1081
- "light": "{colorTextBodyDefault}",
1082
- "dark": "{colorTextBodyDefault}"
1081
+ "light": "{colorTextBodySecondary}",
1082
+ "dark": "{colorTextBodySecondary}"
1083
1083
  },
1084
1084
  "colorTextChatBubbleIncoming": {
1085
- "light": "{colorTextBodyDefault}",
1086
- "dark": "{colorTextBodyDefault}"
1085
+ "light": "{colorTextBodySecondary}",
1086
+ "dark": "{colorTextBodySecondary}"
1087
1087
  },
1088
1088
  "colorBorderButtonNormalActive": {
1089
1089
  "light": "{colorBlue800}",
@@ -1871,7 +1871,7 @@ export var preset = {
1871
1871
  "borderRadiusTabsFocusRing": "20px",
1872
1872
  "borderRadiusTiles": "{borderRadiusInput}",
1873
1873
  "borderRadiusToken": "{borderRadiusInput}",
1874
- "borderRadiusChatBubble": "2px",
1874
+ "borderRadiusChatBubble": "8px",
1875
1875
  "borderRadiusTutorialPanelItem": "{borderRadiusInput}",
1876
1876
  "borderTableStickyWidth": "1px",
1877
1877
  "borderLinkFocusRingOutline": "0",
@@ -3313,12 +3313,12 @@ export var preset = {
3313
3313
  "dark": "{colorGrey850}"
3314
3314
  },
3315
3315
  "colorTextChatBubbleOutgoing": {
3316
- "light": "{colorTextBodyDefault}",
3317
- "dark": "{colorTextBodyDefault}"
3316
+ "light": "{colorTextBodySecondary}",
3317
+ "dark": "{colorTextBodySecondary}"
3318
3318
  },
3319
3319
  "colorTextChatBubbleIncoming": {
3320
- "light": "{colorTextBodyDefault}",
3321
- "dark": "{colorTextBodyDefault}"
3320
+ "light": "{colorTextBodySecondary}",
3321
+ "dark": "{colorTextBodySecondary}"
3322
3322
  },
3323
3323
  "colorBorderButtonNormalActive": {
3324
3324
  "light": "{colorBlue400}",
@@ -4467,12 +4467,12 @@ export var preset = {
4467
4467
  "dark": "{colorGrey850}"
4468
4468
  },
4469
4469
  "colorTextChatBubbleOutgoing": {
4470
- "light": "{colorTextBodyDefault}",
4471
- "dark": "{colorTextBodyDefault}"
4470
+ "light": "{colorTextBodySecondary}",
4471
+ "dark": "{colorTextBodySecondary}"
4472
4472
  },
4473
4473
  "colorTextChatBubbleIncoming": {
4474
- "light": "{colorTextBodyDefault}",
4475
- "dark": "{colorTextBodyDefault}"
4474
+ "light": "{colorTextBodySecondary}",
4475
+ "dark": "{colorTextBodySecondary}"
4476
4476
  },
4477
4477
  "colorBorderButtonNormalActive": {
4478
4478
  "light": "{colorBlue400}",
@@ -5553,12 +5553,12 @@ export var preset = {
5553
5553
  "dark": "{colorGrey850}"
5554
5554
  },
5555
5555
  "colorTextChatBubbleOutgoing": {
5556
- "light": "{colorTextBodyDefault}",
5557
- "dark": "{colorTextBodyDefault}"
5556
+ "light": "{colorTextBodySecondary}",
5557
+ "dark": "{colorTextBodySecondary}"
5558
5558
  },
5559
5559
  "colorTextChatBubbleIncoming": {
5560
- "light": "{colorTextBodyDefault}",
5561
- "dark": "{colorTextBodyDefault}"
5560
+ "light": "{colorTextBodySecondary}",
5561
+ "dark": "{colorTextBodySecondary}"
5562
5562
  },
5563
5563
  "colorBorderButtonNormalActive": {
5564
5564
  "light": "{colorWhite}",
@@ -6639,12 +6639,12 @@ export var preset = {
6639
6639
  "dark": "{colorGrey850}"
6640
6640
  },
6641
6641
  "colorTextChatBubbleOutgoing": {
6642
- "light": "{colorTextBodyDefault}",
6643
- "dark": "{colorTextBodyDefault}"
6642
+ "light": "{colorTextBodySecondary}",
6643
+ "dark": "{colorTextBodySecondary}"
6644
6644
  },
6645
6645
  "colorTextChatBubbleIncoming": {
6646
- "light": "{colorTextBodyDefault}",
6647
- "dark": "{colorTextBodyDefault}"
6646
+ "light": "{colorTextBodySecondary}",
6647
+ "dark": "{colorTextBodySecondary}"
6648
6648
  },
6649
6649
  "colorBorderButtonNormalActive": {
6650
6650
  "light": "{colorTextButtonNormalHover}",
@@ -7725,12 +7725,12 @@ export var preset = {
7725
7725
  "dark": "{colorGrey850}"
7726
7726
  },
7727
7727
  "colorTextChatBubbleOutgoing": {
7728
- "light": "{colorTextBodyDefault}",
7729
- "dark": "{colorTextBodyDefault}"
7728
+ "light": "{colorTextBodySecondary}",
7729
+ "dark": "{colorTextBodySecondary}"
7730
7730
  },
7731
7731
  "colorTextChatBubbleIncoming": {
7732
- "light": "{colorTextBodyDefault}",
7733
- "dark": "{colorTextBodyDefault}"
7732
+ "light": "{colorTextBodySecondary}",
7733
+ "dark": "{colorTextBodySecondary}"
7734
7734
  },
7735
7735
  "colorBorderButtonNormalActive": {
7736
7736
  "light": "{colorTextButtonNormalHover}",
@@ -8813,12 +8813,12 @@ export var preset = {
8813
8813
  "dark": "{colorGrey850}"
8814
8814
  },
8815
8815
  "colorTextChatBubbleOutgoing": {
8816
- "light": "{colorTextBodyDefault}",
8817
- "dark": "{colorTextBodyDefault}"
8816
+ "light": "{colorTextBodySecondary}",
8817
+ "dark": "{colorTextBodySecondary}"
8818
8818
  },
8819
8819
  "colorTextChatBubbleIncoming": {
8820
- "light": "{colorTextBodyDefault}",
8821
- "dark": "{colorTextBodyDefault}"
8820
+ "light": "{colorTextBodySecondary}",
8821
+ "dark": "{colorTextBodySecondary}"
8822
8822
  },
8823
8823
  "colorBorderButtonNormalActive": {
8824
8824
  "light": "{colorTextButtonNormalHover}",
@@ -10226,6 +10226,8 @@ export var preset = {
10226
10226
  "colorBackgroundStatusSuccess",
10227
10227
  "colorBackgroundStatusWarning",
10228
10228
  "colorBackgroundToggleCheckedDisabled",
10229
+ "colorBackgroundChatBubbleOutgoing",
10230
+ "colorBackgroundChatBubbleIncoming",
10229
10231
  "colorTextChatBubbleOutgoing",
10230
10232
  "colorTextChatBubbleIncoming",
10231
10233
  "colorBorderButtonNormalActive",
@@ -11751,8 +11753,8 @@ export var preset = {
11751
11753
  "colorBackgroundLoadingBarGenAi": "--color-background-loading-bar-gen-ai-7qfi9s",
11752
11754
  "colorBackgroundChatBubbleOutgoing": "--color-background-chat-bubble-outgoing-pfqan2",
11753
11755
  "colorBackgroundChatBubbleIncoming": "--color-background-chat-bubble-incoming-brq006",
11754
- "colorTextChatBubbleOutgoing": "--color-text-chat-bubble-outgoing-bvbr0v",
11755
- "colorTextChatBubbleIncoming": "--color-text-chat-bubble-incoming-x2kig8",
11756
+ "colorTextChatBubbleOutgoing": "--color-text-chat-bubble-outgoing-25z5e0",
11757
+ "colorTextChatBubbleIncoming": "--color-text-chat-bubble-incoming-t2slde",
11756
11758
  "colorBorderButtonNormalActive": "--color-border-button-normal-active-mn0ayd",
11757
11759
  "colorBorderButtonNormalDefault": "--color-border-button-normal-default-uzqi0v",
11758
11760
  "colorBorderToggleButtonNormalPressed": "--color-border-toggle-button-normal-pressed-lylxt2",
@@ -12011,7 +12013,7 @@ export var preset = {
12011
12013
  "borderRadiusTabsFocusRing": "--border-radius-tabs-focus-ring-1q0rjo",
12012
12014
  "borderRadiusTiles": "--border-radius-tiles-60y8e6",
12013
12015
  "borderRadiusToken": "--border-radius-token-923jqq",
12014
- "borderRadiusChatBubble": "--border-radius-chat-bubble-ur269r",
12016
+ "borderRadiusChatBubble": "--border-radius-chat-bubble-qvkt36",
12015
12017
  "borderRadiusTutorialPanelItem": "--border-radius-tutorial-panel-item-b44p0a",
12016
12018
  "borderTableStickyWidth": "--border-table-sticky-width-87kf12",
12017
12019
  "borderLinkFocusRingOutline": "--border-link-focus-ring-outline-kkfop6",
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export declare function useDOMAttribute(elementRef: React.RefObject<HTMLElement>, attributeName: string, value: string): {
3
+ [x: string]: string | undefined;
4
+ };
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-dom-attribute/index.tsx"],"names":[],"mappings":";AAQA,wBAAgB,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;EAY7G"}
@@ -0,0 +1,19 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { useEffect, useRef } from 'react';
4
+ /*
5
+ * This hook allows setting an DOM attribute after the first render, without rerendering the component.
6
+ */
7
+ export function useDOMAttribute(elementRef, attributeName, value) {
8
+ const attributeValueRef = useRef();
9
+ useEffect(() => {
10
+ var _a;
11
+ // With this effect, we apply the attribute only on the client, to avoid hydration errors.
12
+ attributeValueRef.current = value;
13
+ (_a = elementRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute(attributeName, value);
14
+ }, [attributeName, value, elementRef]);
15
+ return {
16
+ [attributeName]: attributeValueRef.current,
17
+ };
18
+ }
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-dom-attribute/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,UAAwC,EAAE,aAAqB,EAAE,KAAa;IAC5G,MAAM,iBAAiB,GAAG,MAAM,EAAsB,CAAC;IAEvD,SAAS,CAAC,GAAG,EAAE;;QACb,0FAA0F;QAC1F,iBAAiB,CAAC,OAAO,GAAG,KAAK,CAAC;QAClC,MAAA,UAAU,CAAC,OAAO,0CAAE,YAAY,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC,EAAE,CAAC,aAAa,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;IAEvC,OAAO;QACL,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC,OAAO;KAC3C,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useEffect, useRef } from 'react';\n\n/*\n * This hook allows setting an DOM attribute after the first render, without rerendering the component.\n */\nexport function useDOMAttribute(elementRef: React.RefObject<HTMLElement>, attributeName: string, value: string) {\n const attributeValueRef = useRef<string | undefined>();\n\n useEffect(() => {\n // With this effect, we apply the attribute only on the client, to avoid hydration errors.\n attributeValueRef.current = value;\n elementRef.current?.setAttribute(attributeName, value);\n }, [attributeName, value, elementRef]);\n\n return {\n [attributeName]: attributeValueRef.current,\n };\n}\n"]}
@@ -5,6 +5,6 @@
5
5
  * correctly.
6
6
  */
7
7
  export declare function usePerformanceMarks(name: string, enabled: boolean, elementRef: React.RefObject<HTMLElement>, getDetails: () => Record<string, string | boolean | number | undefined>, dependencies: React.DependencyList): {
8
- "data-analytics-performance-mark": string | undefined;
8
+ [x: string]: string | undefined;
9
9
  };
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-performance-marks/index.ts"],"names":[],"mappings":";AA4BA;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,EACxC,UAAU,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,EACvE,YAAY,EAAE,KAAK,CAAC,cAAc;;EAyDnC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-performance-marks/index.ts"],"names":[],"mappings":";AAUA;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,EACxC,UAAU,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,EACvE,YAAY,EAAE,KAAK,CAAC,cAAc;;EA0DnC"}
@@ -1,25 +1,10 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { useEffect, useRef } from 'react';
3
+ import { useEffect } from 'react';
4
4
  import { useModalContext } from '../../context/modal-context';
5
+ import { useDOMAttribute } from '../use-dom-attribute';
5
6
  import { useEffectOnUpdate } from '../use-effect-on-update';
6
7
  import { useRandomId } from '../use-unique-id';
7
- /*
8
- This hook allows setting an HTML attribute after the first render, without rerendering the component.
9
- */
10
- function usePerformanceMarkAttribute(elementRef, value) {
11
- const attributeName = 'data-analytics-performance-mark';
12
- const attributeValueRef = useRef();
13
- useEffect(() => {
14
- var _a;
15
- // With this effect, we apply the attribute only on the client, to avoid hydration errors.
16
- attributeValueRef.current = value;
17
- (_a = elementRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute(attributeName, value);
18
- }, [value, elementRef]);
19
- return {
20
- [attributeName]: attributeValueRef.current,
21
- };
22
- }
23
8
  /**
24
9
  * This function returns an object that needs to be spread onto the same
25
10
  * element as the `elementRef`, so that the data attribute is applied
@@ -28,7 +13,7 @@ function usePerformanceMarkAttribute(elementRef, value) {
28
13
  export function usePerformanceMarks(name, enabled, elementRef, getDetails, dependencies) {
29
14
  const id = useRandomId();
30
15
  const { isInModal } = useModalContext();
31
- const attributes = usePerformanceMarkAttribute(elementRef, id);
16
+ const attributes = useDOMAttribute(elementRef, 'data-analytics-performance-mark', id);
32
17
  useEffect(() => {
33
18
  if (!enabled || !elementRef.current || isInModal) {
34
19
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-performance-marks/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;EAEE;AACF,SAAS,2BAA2B,CAAC,UAAwC,EAAE,KAAa;IAC1F,MAAM,aAAa,GAAG,iCAAiC,CAAC;IAExD,MAAM,iBAAiB,GAAG,MAAM,EAAsB,CAAC;IAEvD,SAAS,CAAC,GAAG,EAAE;;QACb,0FAA0F;QAC1F,iBAAiB,CAAC,OAAO,GAAG,KAAK,CAAC;QAClC,MAAA,UAAU,CAAC,OAAO,0CAAE,YAAY,CAAC,aAAa,EAAE,KAAK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CAAC,OAAO,CAAC,YAAY,GAAG,CAAC;YACnC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,UAAU,KAAK,QAAQ,CAAC;QAE/D,IAAI,CAAC,cAAc,EAAE;YACnB,OAAO;SACR;QAED,MAAM,eAAe,GAAG,GAAG,IAAI,SAAS,CAAC;QAEzC,WAAW,CAAC,IAAI,CAAC,eAAe,EAAE;YAChC,MAAM,kBACJ,MAAM,EAAE,OAAO,EACf,kBAAkB,EAAE,EAAE,IACnB,UAAU,EAAE,CAChB;SACF,CAAC,CAAC;QACH,uDAAuD;IACzD,CAAC,EAAE,YAAY,CAAC,CAAC;IAEjB,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useEffect, useRef } from 'react';\n\nimport { useModalContext } from '../../context/modal-context';\nimport { useEffectOnUpdate } from '../use-effect-on-update';\nimport { useRandomId } from '../use-unique-id';\n\n/*\nThis hook allows setting an HTML attribute after the first render, without rerendering the component.\n*/\nfunction usePerformanceMarkAttribute(elementRef: React.RefObject<HTMLElement>, value: string) {\n const attributeName = 'data-analytics-performance-mark';\n\n const attributeValueRef = useRef<string | undefined>();\n\n useEffect(() => {\n // With this effect, we apply the attribute only on the client, to avoid hydration errors.\n attributeValueRef.current = value;\n elementRef.current?.setAttribute(attributeName, value);\n }, [value, elementRef]);\n\n return {\n [attributeName]: attributeValueRef.current,\n };\n}\n\n/**\n * This function returns an object that needs to be spread onto the same\n * element as the `elementRef`, so that the data attribute is applied\n * correctly.\n */\nexport function usePerformanceMarks(\n name: string,\n enabled: boolean,\n elementRef: React.RefObject<HTMLElement>,\n getDetails: () => Record<string, string | boolean | number | undefined>,\n dependencies: React.DependencyList\n) {\n const id = useRandomId();\n const { isInModal } = useModalContext();\n const attributes = usePerformanceMarkAttribute(elementRef, id);\n useEffect(() => {\n if (!enabled || !elementRef.current || isInModal) {\n return;\n }\n\n const elementVisible =\n elementRef.current.offsetWidth > 0 &&\n elementRef.current.offsetHeight > 0 &&\n getComputedStyle(elementRef.current).visibility !== 'hidden';\n\n if (!elementVisible) {\n return;\n }\n\n const renderedMarkName = `${name}Rendered`;\n\n performance.mark(renderedMarkName, {\n detail: {\n source: 'awsui',\n instanceIdentifier: id,\n ...getDetails(),\n },\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffectOnUpdate(() => {\n if (!enabled || !elementRef.current || isInModal) {\n return;\n }\n const elementVisible =\n elementRef.current.offsetWidth > 0 &&\n elementRef.current.offsetHeight > 0 &&\n getComputedStyle(elementRef.current).visibility !== 'hidden';\n\n if (!elementVisible) {\n return;\n }\n\n const updatedMarkName = `${name}Updated`;\n\n performance.mark(updatedMarkName, {\n detail: {\n source: 'awsui',\n instanceIdentifier: id,\n ...getDetails(),\n },\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, dependencies);\n\n return attributes;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-performance-marks/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAY,EACZ,OAAgB,EAChB,UAAwC,EACxC,UAAuE,EACvE,YAAkC;IAElC,MAAM,EAAE,GAAG,WAAW,EAAE,CAAC;IACzB,MAAM,EAAE,SAAS,EAAE,GAAG,eAAe,EAAE,CAAC;IACxC,MAAM,UAAU,GAAG,eAAe,CAAC,UAAU,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CAAC,CAAC;IAEjB,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useEffect } from 'react';\n\nimport { useModalContext } from '../../context/modal-context';\nimport { useDOMAttribute } from '../use-dom-attribute';\nimport { useEffectOnUpdate } from '../use-effect-on-update';\nimport { useRandomId } from '../use-unique-id';\n\n/**\n * This function returns an object that needs to be spread onto the same\n * element as the `elementRef`, so that the data attribute is applied\n * correctly.\n */\nexport function usePerformanceMarks(\n name: string,\n enabled: boolean,\n elementRef: React.RefObject<HTMLElement>,\n getDetails: () => Record<string, string | boolean | number | undefined>,\n dependencies: React.DependencyList\n) {\n const id = useRandomId();\n const { isInModal } = useModalContext();\n const attributes = useDOMAttribute(elementRef, 'data-analytics-performance-mark', id);\n\n useEffect(() => {\n if (!enabled || !elementRef.current || isInModal) {\n return;\n }\n\n const elementVisible =\n elementRef.current.offsetWidth > 0 &&\n elementRef.current.offsetHeight > 0 &&\n getComputedStyle(elementRef.current).visibility !== 'hidden';\n\n if (!elementVisible) {\n return;\n }\n\n const renderedMarkName = `${name}Rendered`;\n\n performance.mark(renderedMarkName, {\n detail: {\n source: 'awsui',\n instanceIdentifier: id,\n ...getDetails(),\n },\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffectOnUpdate(() => {\n if (!enabled || !elementRef.current || isInModal) {\n return;\n }\n const elementVisible =\n elementRef.current.offsetWidth > 0 &&\n elementRef.current.offsetHeight > 0 &&\n getComputedStyle(elementRef.current).visibility !== 'hidden';\n\n if (!elementVisible) {\n return;\n }\n\n const updatedMarkName = `${name}Updated`;\n\n performance.mark(updatedMarkName, {\n detail: {\n source: 'awsui',\n instanceIdentifier: id,\n ...getDetails(),\n },\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, dependencies);\n\n return attributes;\n}\n"]}
@@ -1,11 +1,18 @@
1
+ /// <reference types="react" />
2
+ import { JSONObject } from '../../analytics/interfaces';
1
3
  export interface UseTableInteractionMetricsProps {
4
+ elementRef: React.RefObject<HTMLElement>;
2
5
  instanceIdentifier: string | undefined;
3
6
  loading: boolean | undefined;
4
7
  itemCount: number;
5
8
  getComponentIdentifier: () => string | undefined;
9
+ getComponentConfiguration: () => JSONObject;
6
10
  interactionMetadata: () => string;
7
11
  }
8
- export declare function useTableInteractionMetrics({ itemCount, instanceIdentifier, getComponentIdentifier, loading, interactionMetadata, }: UseTableInteractionMetricsProps): {
12
+ export declare function useTableInteractionMetrics({ elementRef, itemCount, instanceIdentifier, getComponentIdentifier, getComponentConfiguration, loading, interactionMetadata, }: UseTableInteractionMetricsProps): {
13
+ tableInteractionAttributes: {
14
+ [x: string]: string | undefined;
15
+ };
9
16
  setLastUserAction: (name: string) => undefined;
10
17
  };
11
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-table-interaction-metrics/index.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,+BAA+B;IAC9C,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACjD,mBAAmB,EAAE,MAAM,MAAM,CAAC;CACnC;AAED,wBAAgB,0BAA0B,CAAC,EACzC,SAAS,EACT,kBAAkB,EAClB,sBAAsB,EACtB,OAAe,EACf,mBAAmB,GACpB,EAAE,+BAA+B;8BAoCJ,MAAM;EAEnC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-table-interaction-metrics/index.ts"],"names":[],"mappings":";AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAWxD,MAAM,WAAW,+BAA+B;IAC9C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACzC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACjD,yBAAyB,EAAE,MAAM,UAAU,CAAC;IAC5C,mBAAmB,EAAE,MAAM,MAAM,CAAC;CACnC;AAED,wBAAgB,0BAA0B,CAAC,EACzC,UAAU,EACV,SAAS,EACT,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,EACzB,OAAe,EACf,mBAAmB,GACpB,EAAE,+BAA+B;;;;8BA2DJ,MAAM;EAEnC"}
@@ -1,19 +1,30 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { useEffect, useRef } from 'react';
4
- import { PerformanceMetrics } from '../../analytics';
4
+ import { ComponentMetrics, PerformanceMetrics } from '../../analytics';
5
+ import { useDOMAttribute } from '../use-dom-attribute';
5
6
  import { useEffectOnUpdate } from '../use-effect-on-update';
7
+ import { useRandomId } from '../use-unique-id';
6
8
  /*
7
9
  If the last user interaction is more than this time ago, it is not considered
8
10
  to be the cause of the current loading state.
9
11
  */
10
12
  const USER_ACTION_TIME_LIMIT = 1000;
11
- export function useTableInteractionMetrics({ itemCount, instanceIdentifier, getComponentIdentifier, loading = false, interactionMetadata, }) {
13
+ export function useTableInteractionMetrics({ elementRef, itemCount, instanceIdentifier, getComponentIdentifier, getComponentConfiguration, loading = false, interactionMetadata, }) {
14
+ const taskInteractionId = useRandomId();
15
+ const tableInteractionAttributes = useDOMAttribute(elementRef, 'data-analytics-task-interaction-id', taskInteractionId);
12
16
  const lastUserAction = useRef(null);
13
17
  const capturedUserAction = useRef(null);
14
18
  const loadingStartTime = useRef(null);
15
- const metadata = useRef({ itemCount, getComponentIdentifier, interactionMetadata });
16
- metadata.current = { itemCount, getComponentIdentifier, interactionMetadata };
19
+ const metadata = useRef({ itemCount, getComponentIdentifier, getComponentConfiguration, interactionMetadata });
20
+ metadata.current = { itemCount, getComponentIdentifier, getComponentConfiguration, interactionMetadata };
21
+ useEffect(() => {
22
+ ComponentMetrics.componentMounted({
23
+ taskInteractionId,
24
+ componentName: 'table',
25
+ componentConfiguration: metadata.current.getComponentConfiguration(),
26
+ });
27
+ }, [taskInteractionId]);
17
28
  useEffect(() => {
18
29
  if (loading) {
19
30
  loadingStartTime.current = performance.now();
@@ -26,7 +37,7 @@ export function useTableInteractionMetrics({ itemCount, instanceIdentifier, getC
26
37
  }
27
38
  }, [loading]);
28
39
  useEffectOnUpdate(() => {
29
- var _a;
40
+ var _a, _b;
30
41
  if (!loading && loadingStartTime.current !== null) {
31
42
  const loadingDuration = performance.now() - loadingStartTime.current;
32
43
  loadingStartTime.current = null;
@@ -38,9 +49,16 @@ export function useTableInteractionMetrics({ itemCount, instanceIdentifier, getC
38
49
  instanceIdentifier,
39
50
  noOfResourcesInTable: metadata.current.itemCount,
40
51
  });
52
+ ComponentMetrics.componentUpdated({
53
+ taskInteractionId,
54
+ componentName: 'table',
55
+ actionType: (_b = capturedUserAction.current) !== null && _b !== void 0 ? _b : '',
56
+ componentConfiguration: metadata.current.getComponentConfiguration(),
57
+ });
41
58
  }
42
- }, [instanceIdentifier, loading]);
59
+ }, [instanceIdentifier, loading, taskInteractionId]);
43
60
  return {
61
+ tableInteractionAttributes,
44
62
  setLastUserAction: (name) => void (lastUserAction.current = { name, time: performance.now() }),
45
63
  };
46
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-table-interaction-metrics/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;A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kB,CAAC,gBAAgB,CAAC;gBAClC,UAAU,EAAE,MAAA,kBAAkB,CAAC,OAAO,mCAAI,EAAE;gBAC5C,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC;gBAC5C,mBAAmB,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,EAAE;gBAC3D,mBAAmB,EAAE,QAAQ,CAAC,OAAO,CAAC,sBAAsB,EAAE;gBAC9D,kBAAkB;gBAClB,oBAAoB,EAAE,QAAQ,CAAC,OAAO,CAAC,SAAS;aACjD,CAAC,CAAC;SACJ;IACH,CAAC,EAAE,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,CAAC;IAElC,OAAO;QACL,iBAAiB,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,EAAE,EAAE,CAAC;KACvG,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useEffect, useRef } from 'react';\n\nimport { PerformanceMetrics } from '../../analytics';\nimport { useEffectOnUpdate } from '../use-effect-on-update';\n\n/*\nIf the last user interaction is more than this time ago, it is not considered\nto be the cause of the current loading state.\n*/\nconst USER_ACTION_TIME_LIMIT = 1_000;\n\nexport interface UseTableInteractionMetricsProps {\n instanceIdentifier: string | undefined;\n loading: boolean | undefined;\n itemCount: number;\n getComponentIdentifier: () => string | undefined;\n interactionMetadata: () => string;\n}\n\nexport function useTableInteractionMetrics({\n itemCount,\n instanceIdentifier,\n getComponentIdentifier,\n loading = false,\n interactionMetadata,\n}: UseTableInteractionMetricsProps) {\n const lastUserAction = useRef<{ name: string; time: number } | null>(null);\n const capturedUserAction = useRef<string | null>(null);\n const loadingStartTime = useRef<number | null>(null);\n\n const metadata = useRef({ itemCount, getComponentIdentifier, interactionMetadata });\n metadata.current = { itemCount, getComponentIdentifier, interactionMetadata };\n useEffect(() => {\n if (loading) {\n loadingStartTime.current = performance.now();\n\n if (lastUserAction.current && lastUserAction.current.time > performance.now() - USER_ACTION_TIME_LIMIT) {\n capturedUserAction.current = lastUserAction.current.name;\n } else {\n capturedUserAction.current = null;\n }\n }\n }, [loading]);\n\n useEffectOnUpdate(() => {\n if (!loading && loadingStartTime.current !== null) {\n const loadingDuration = performance.now() - loadingStartTime.current;\n loadingStartTime.current = null;\n\n PerformanceMetrics.tableInteraction({\n userAction: capturedUserAction.current ?? '',\n interactionTime: Math.round(loadingDuration),\n interactionMetadata: metadata.current.interactionMetadata(),\n componentIdentifier: metadata.current.getComponentIdentifier(),\n instanceIdentifier,\n noOfResourcesInTable: metadata.current.itemCount,\n });\n }\n }, [instanceIdentifier, loading]);\n\n return {\n setLastUserAction: (name: string) => void (lastUserAction.current = { name, time: performance.now() }),\n };\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-table-interaction-metrics/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;EAGE;AACF,MAAM,sBAAsB,GAAG,IAAK,CAAC;AAYrC,MAAM,UAAU,0BAA0B,CAAC,EACzC,UAAU,EACV,SAAS,EACT,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,EACzB,OAAO,GAAG,KAAK,EACf,mBAAmB,GACa;IAChC,MAAM,iBAAiB,GAAG,WAAW,EAAE,CAAC;IACxC,MAAM,0BAA0B,GA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AAG,EAAE,GAAG,gBAAgB,CAAC,OAAO,CAAC;YACrE,gBAAgB,CAAC,OAAO,GAAG,IAAI,CAAC;YAEhC,kBAAkB,CAAC,gBAAgB,CAAC;gBAClC,UAAU,EAAE,MAAA,kBAAkB,CAAC,OAAO,mCAAI,EAAE;gBAC5C,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC;gBAC5C,mBAAmB,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,EAAE;gBAC3D,mBAAmB,EAAE,QAAQ,CAAC,OAAO,CAAC,sBAAsB,EAAE;gBAC9D,kBAAkB;gBAClB,oBAAoB,EAAE,QAAQ,CAAC,OAAO,CAAC,SAAS;aACjD,CAAC,CAAC;YAEH,gBAAgB,CAAC,gBAAgB,CAAC;gBAChC,iBAAiB;gBACjB,aAAa,EAAE,OAAO;gBACtB,UAAU,EAAE,MAAA,kBAAkB,CAAC,OAAO,mCAAI,EAAE;gBAC5C,sBAAsB,EAAE,QAAQ,CAAC,OAAO,CAAC,yBAAyB,EAAE;aACrE,CAAC,CAAC;SACJ;IACH,CAAC,EAAE,CAAC,kBAAkB,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAErD,OAAO;QACL,0BAA0B;QAC1B,iBAAiB,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,EAAE,EAAE,CAAC;KACvG,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useEffect, useRef } from 'react';\n\nimport { ComponentMetrics, PerformanceMetrics } from '../../analytics';\nimport { JSONObject } from '../../analytics/interfaces';\nimport { useDOMAttribute } from '../use-dom-attribute';\nimport { useEffectOnUpdate } from '../use-effect-on-update';\nimport { useRandomId } from '../use-unique-id';\n\n/*\nIf the last user interaction is more than this time ago, it is not considered\nto be the cause of the current loading state.\n*/\nconst USER_ACTION_TIME_LIMIT = 1_000;\n\nexport interface UseTableInteractionMetricsProps {\n elementRef: React.RefObject<HTMLElement>;\n instanceIdentifier: string | undefined;\n loading: boolean | undefined;\n itemCount: number;\n getComponentIdentifier: () => string | undefined;\n getComponentConfiguration: () => JSONObject;\n interactionMetadata: () => string;\n}\n\nexport function useTableInteractionMetrics({\n elementRef,\n itemCount,\n instanceIdentifier,\n getComponentIdentifier,\n getComponentConfiguration,\n loading = false,\n interactionMetadata,\n}: UseTableInteractionMetricsProps) {\n const taskInteractionId = useRandomId();\n const tableInteractionAttributes = useDOMAttribute(\n elementRef,\n 'data-analytics-task-interaction-id',\n taskInteractionId\n );\n const lastUserAction = useRef<{ name: string; time: number } | null>(null);\n const capturedUserAction = useRef<string | null>(null);\n const loadingStartTime = useRef<number | null>(null);\n\n const metadata = useRef({ itemCount, getComponentIdentifier, getComponentConfiguration, interactionMetadata });\n metadata.current = { itemCount, getComponentIdentifier, getComponentConfiguration, interactionMetadata };\n\n useEffect(() => {\n ComponentMetrics.componentMounted({\n taskInteractionId,\n componentName: 'table',\n componentConfiguration: metadata.current.getComponentConfiguration(),\n });\n }, [taskInteractionId]);\n\n useEffect(() => {\n if (loading) {\n loadingStartTime.current = performance.now();\n\n if (lastUserAction.current && lastUserAction.current.time > performance.now() - USER_ACTION_TIME_LIMIT) {\n capturedUserAction.current = lastUserAction.current.name;\n } else {\n capturedUserAction.current = null;\n }\n }\n }, [loading]);\n\n useEffectOnUpdate(() => {\n if (!loading && loadingStartTime.current !== null) {\n const loadingDuration = performance.now() - loadingStartTime.current;\n loadingStartTime.current = null;\n\n PerformanceMetrics.tableInteraction({\n userAction: capturedUserAction.current ?? '',\n interactionTime: Math.round(loadingDuration),\n interactionMetadata: metadata.current.interactionMetadata(),\n componentIdentifier: metadata.current.getComponentIdentifier(),\n instanceIdentifier,\n noOfResourcesInTable: metadata.current.itemCount,\n });\n\n ComponentMetrics.componentUpdated({\n taskInteractionId,\n componentName: 'table',\n actionType: capturedUserAction.current ?? '',\n componentConfiguration: metadata.current.getComponentConfiguration(),\n });\n }\n }, [instanceIdentifier, loading, taskInteractionId]);\n\n return {\n tableInteractionAttributes,\n setLastUserAction: (name: string) => void (lastUserAction.current = { name, time: performance.now() }),\n };\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/live-region/controller.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,qBAAa,oBAAoB;aAeb,UAAU,EAAE,QAAQ,GAAG,WAAW;aAClC,KAAK;IAfvB;;;;OAIG;IACH,OAAc,YAAY,SAAK;IAE/B,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,iBAAiB,CAAqB;IAC9C,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,iBAAiB,CAAM;gBAGb,UAAU,EAAE,QAAQ,GAAG,WAAW,EAClC,KAAK,SAAoC;IAS3D;;OAEG;IACH,OAAO;IAQP,QAAQ,CAAC,EAAE,OAAO,EAAE,eAAuB,EAAE,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE;IAkB9G,OAAO,CAAC,cAAc;CAqBvB"}
@@ -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 styles from './styles.css.js';
4
+ import testUtilStyles from './test-classes/styles.css.js';
4
5
  /**
5
6
  * The controller that manages a single live region container. It has a timer
6
7
  * to make sure announcements are throttled correctly. It can also make sure
@@ -16,10 +17,9 @@ export class LiveRegionController {
16
17
  this._addedTerminalPeriod = false;
17
18
  this._nextAnnouncement = '';
18
19
  this._element = document.createElement('div');
19
- this._element.className = styles.announcer;
20
+ this._element.className = `${styles.announcer} ${testUtilStyles.announcer}`;
20
21
  this._element.setAttribute('aria-live', this.politeness);
21
22
  this._element.setAttribute('aria-atomic', 'true');
22
- this._element.setAttribute('data-awsui-live-announcer', 'true');
23
23
  document.body.appendChild(this._element);
24
24
  }
25
25
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/live-region/controller.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,cAAc,MAAM,8BAA8B,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,OAAO,oBAAoB;IAc/B,YACkB,UAAkC,EAClC,QAAQ,oBAAoB,CAAC,YAAY;QADzC,eAAU,GAAV,UAAU,CAAwB;QAClC,UAAK,GAAL,KAAK,CAAoC;QALnD,yBAAoB,GAAG,KAAK,CAAC;QAC7B,sBAAiB,GAAG,EAAE,CAAC;QAM7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,CAAC,SAAS,GAAG,GAAG,MAAM,CAAC,SAAS,IAAI,cAAc,CAAC,SAAS,EAAE,CAAC;QAC5E,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAClD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,OAAO;;QACL,MAAA,IAAI,CAAC,QAAQ,0CAAE,MAAM,EAAE,CAAC;QACxB,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE;YACjC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC9B,IAAI,CA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CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;;AAzED;;;;GAIG;AACW,iCAAY,GAAG,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport styles from './styles.css.js';\nimport testUtilStyles from './test-classes/styles.css.js';\n\n/**\n * The controller that manages a single live region container. It has a timer\n * to make sure announcements are throttled correctly. It can also make sure\n * that a message is announced again even if it matches the previous content\n * of the live region.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions\n */\nexport class LiveRegionController {\n /**\n * The default delay for announcements when no delay is explicitly provided.\n * During internal unit testing, you can import this and explicitly set it to\n * 0 to make the live region update the DOM without waiting for a timer.\n */\n public static defaultDelay = 2;\n\n private _element: HTMLElement;\n private _timeoutId: number | undefined;\n private _lastAnnouncement: string | undefined;\n private _addedTerminalPeriod = false;\n private _nextAnnouncement = '';\n\n constructor(\n public readonly politeness: 'polite' | 'assertive',\n public readonly delay = LiveRegionController.defaultDelay\n ) {\n this._element = document.createElement('div');\n this._element.className = `${styles.announcer} ${testUtilStyles.announcer}`;\n this._element.setAttribute('aria-live', this.politeness);\n this._element.setAttribute('aria-atomic', 'true');\n document.body.appendChild(this._element);\n }\n\n /**\n * Reset the state of the controller and clear any active announcements.\n */\n destroy() {\n this._element?.remove();\n if (this._timeoutId !== undefined) {\n clearTimeout(this._timeoutId);\n this._timeoutId = undefined;\n }\n }\n\n announce({ message, forceReannounce = false }: { message?: string; delay?: number; forceReannounce?: boolean }) {\n if (!message) {\n return;\n }\n\n this._nextAnnouncement = message.trim();\n\n if (this.delay === 0 || forceReannounce) {\n // If the delay is 0, just skip the timeout shenanigans and update the\n // element synchronously. Great for tests.\n return this._updateElement(forceReannounce);\n }\n\n if (this._timeoutId === undefined) {\n this._timeoutId = setTimeout(() => this._updateElement(false), this.delay * 1000);\n }\n }\n\n private _updateElement(forceReannounce: boolean) {\n if (this._nextAnnouncement !== this._lastAnnouncement) {\n // The aria-atomic does not work properly in Voice Over, causing\n // certain parts of the content to be ignored. To fix that,\n // we assign the source text content as a single node.\n this._element.textContent = this._nextAnnouncement;\n this._addedTerminalPeriod = false;\n } else if (forceReannounce) {\n // A (generally) safe way of forcing re-announcements is toggling the\n // terminal period. If we only keep adding periods, it's going to be\n // eventually interpreted as an ellipsis.\n this._element.textContent = this._nextAnnouncement + (this._addedTerminalPeriod ? '' : '.');\n this._addedTerminalPeriod = !this._addedTerminalPeriod;\n }\n\n // Track the announced text for deduplication.\n this._lastAnnouncement = this._nextAnnouncement;\n\n // Reset the state for the next announcement.\n this._timeoutId = undefined;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/live-region/index.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,iBAAS,UAAU,CAAC,EAAE,SAAiB,EAAE,MAAc,EAAE,OAAe,EAAE,GAAG,SAAS,EAAE,EAAE,eAAe,eAYxG;AAID,eAAe,UAAU,CAAC"}
@@ -2,14 +2,12 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { __rest } from "tslib";
4
4
  import React from 'react';
5
- // import useBaseComponent from '../../hooks/use-base-component';
6
- import { applyDisplayName } from '../../utils/apply-display-name';
5
+ import useBaseComponent from '../internal/hooks/use-base-component';
6
+ import { applyDisplayName } from '../internal/utils/apply-display-name';
7
7
  import InternalLiveRegion from './internal';
8
8
  function LiveRegion(_a) {
9
9
  var { assertive = false, hidden = false, tagName = 'div' } = _a, restProps = __rest(_a, ["assertive", "hidden", "tagName"]);
10
- // TODO: Switch this out when moving this component out of internal
11
- // const baseComponentProps = useBaseComponent('LiveRegion');
12
- const baseComponentProps = { __internalRootRef: React.useRef() };
10
+ const baseComponentProps = useBaseComponent('LiveRegion', { props: { assertive, hidden } });
13
11
  return (React.createElement(InternalLiveRegion, Object.assign({ assertive: assertive, hidden: hidden, tagName: tagName }, baseComponentProps, restProps)));
14
12
  }
15
13
  applyDisplayName(LiveRegion, 'LiveRegion');
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/live-region/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,kBAAkB,MAAM,YAAY,CAAC;AAI5C,SAAS,UAAU,CAAC,EAAqF;QAArF,EAAE,SAAS,GAAG,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,OAAO,GAAG,KAAK,OAAiC,EAA5B,SAAS,cAAlE,kCAAoE,CAAF;IACpF,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IAE5F,OAAO,CACL,oBAAC,kBAAkB,kBACjB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,IACZ,kBAAkB,EAClB,SAAS,EACb,CACH,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAE3C,eAAe,UAAU,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\n\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { LiveRegionProps } from './interfaces';\nimport InternalLiveRegion from './internal';\n\nexport { LiveRegionProps };\n\nfunction LiveRegion({ assertive = false, hidden = false, tagName = 'div', ...restProps }: LiveRegionProps) {\n const baseComponentProps = useBaseComponent('LiveRegion', { props: { assertive, hidden } });\n\n return (\n <InternalLiveRegion\n assertive={assertive}\n hidden={hidden}\n tagName={tagName}\n {...baseComponentProps}\n {...restProps}\n />\n );\n}\n\napplyDisplayName(LiveRegion, 'LiveRegion');\n\nexport default LiveRegion;\n"]}
@@ -1,13 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { BaseComponentProps } from '../../base-component';
2
+ import { BaseComponentProps } from '../internal/base-component';
3
3
  export interface LiveRegionProps extends BaseComponentProps {
4
- /**
5
- * The string for the aria-live announcement text. When this content
6
- * changes, the text will be re-announced to assistive technologies. If this
7
- * property is provided, it will be used for the live announcement instead of
8
- * the `children` slot.
9
- */
10
- message?: string;
11
4
  /**
12
5
  * Whether the announcements should be made using assertive aria-live.
13
6
  * Assertive announcements interrupt the user's action, so they should only
@@ -19,12 +12,13 @@ export interface LiveRegionProps extends BaseComponentProps {
19
12
  */
20
13
  tagName?: LiveRegionProps.TagName;
21
14
  /**
22
- * Defines whether to visually hide the contents of the `children` slot.
15
+ * Determines whether to visually hide the contents of the `children` slot.
23
16
  */
24
17
  hidden?: boolean;
25
18
  /**
26
- * Use the rendered content as the source for the announcement text.
27
- * Prefer `message` if announcement text can be provided as a string.
19
+ * Use the rendered content as the source for the announcement text. When the
20
+ * text content inside this slot changes, it will be re-announced to
21
+ * assistive technologies.
28
22
  */
29
23
  children?: React.ReactNode;
30
24
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/live-region/interfaces.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,MAAM,WAAW,eAAgB,SAAQ,kBAAkB;IACzD;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC;IAElC;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,yBAAiB,eAAe,CAAC;IAC/B,KAAY,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;CACtC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/live-region/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 { BaseComponentProps } from '../internal/base-component';\n\nexport interface LiveRegionProps extends BaseComponentProps {\n /**\n * Whether the announcements should be made using assertive aria-live.\n * Assertive announcements interrupt the user's action, so they should only\n * be used when absolutely necessary.\n */\n assertive?: boolean;\n\n /**\n * The tag name to use for the wrapper around the `children` slot.\n */\n tagName?: LiveRegionProps.TagName;\n\n /**\n * Determines whether to visually hide the contents of the `children` slot.\n */\n hidden?: boolean;\n\n /**\n * Use the rendered content as the source for the announcement text. When the\n * text content inside this slot changes, it will be re-announced to\n * assistive technologies.\n */\n children?: React.ReactNode;\n}\n\nexport namespace LiveRegionProps {\n export type TagName = 'span' | 'div';\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { InternalBaseComponentProps } from '../../hooks/use-base-component';
2
+ import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
3
3
  import { LiveRegionProps } from './interfaces';
4
4
  export interface InternalLiveRegionProps extends InternalBaseComponentProps, LiveRegionProps {
5
5
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/live-region/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAItE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGlF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/C,MAAM,WAAW,uBAAwB,SAAQ,0BAA0B,EAAE,eAAe;IAC1F;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC,CAAC;CAC5E;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;;;;OAOG;IACH,UAAU,IAAI,IAAI,CAAC;CACpB;;AAED,wBAyEG"}
@@ -3,12 +3,13 @@
3
3
  import { __rest } from "tslib";
4
4
  import React, { useEffect, useImperativeHandle, useRef } from 'react';
5
5
  import clsx from 'clsx';
6
- import { getBaseProps } from '../../base-component';
7
- import { useMergeRefs } from '../../hooks/use-merge-refs';
6
+ import { getBaseProps } from '../internal/base-component';
7
+ import { useMergeRefs } from '../internal/hooks/use-merge-refs';
8
8
  import { LiveRegionController } from './controller';
9
9
  import styles from './styles.css.js';
10
+ import testUtilStyles from './test-classes/styles.css.js';
10
11
  export default React.forwardRef(function InternalLiveRegion(_a, ref) {
11
- var { assertive = false, hidden = false, tagName: TagName = 'div', delay, sources, message, children, __internalRootRef, className } = _a, restProps = __rest(_a, ["assertive", "hidden", "tagName", "delay", "sources", "message", "children", "__internalRootRef", "className"]);
12
+ var { assertive = false, hidden = false, tagName: TagName = 'div', delay, sources, children, __internalRootRef, className } = _a, restProps = __rest(_a, ["assertive", "hidden", "tagName", "delay", "sources", "children", "__internalRootRef", "className"]);
12
13
  const baseProps = getBaseProps(restProps);
13
14
  const childrenRef = useRef(null);
14
15
  const mergedRef = useMergeRefs(childrenRef, __internalRootRef);
@@ -35,13 +36,12 @@ export default React.forwardRef(function InternalLiveRegion(_a, ref) {
35
36
  };
36
37
  }, [assertive]);
37
38
  const getContent = () => {
38
- return sources
39
- ? getSourceContent(sources)
40
- : message
41
- ? message
42
- : childrenRef.current
43
- ? extractTextContent(childrenRef.current)
44
- : undefined;
39
+ if (sources) {
40
+ return getSourceContent(sources);
41
+ }
42
+ if (childrenRef.current) {
43
+ return extractTextContent(childrenRef.current);
44
+ }
45
45
  };
46
46
  // Call the controller on every render. The controller will deduplicate the
47
47
  // message against the previous announcement internally.
@@ -55,7 +55,7 @@ export default React.forwardRef(function InternalLiveRegion(_a, ref) {
55
55
  (_a = liveRegionControllerRef.current) === null || _a === void 0 ? void 0 : _a.announce({ message: getContent(), delay, forceReannounce: true });
56
56
  },
57
57
  }));
58
- return (React.createElement(TagName, Object.assign({ ref: mergedRef }, baseProps, { className: clsx(styles.root, className), hidden: hidden }), children));
58
+ return (React.createElement(TagName, Object.assign({ ref: mergedRef }, baseProps, { className: clsx(styles.root, testUtilStyles.root, className), hidden: hidden }), children));
59
59
  });
60
60
  function extractTextContent(node) {
61
61
  // We use the text content of the node as the announcement text.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/live-region/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGpD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,cAAc,MAAM,8BAA8B,CAAC;AA8B1D,eAAe,KAAK,CAAC,UAAU,CAAC,SAAS,kBAAkB,CACzD,EAU0B,EAC1B,GAAqC;QAXrC,EACE,SAAS,GAAG,KAAK,EACjB,MAAM,GAAG,KAAK,EACd,OAAO,EAAE,OAAO,GAAG,KAAK,EACxB,KAAK,EACL,OAAO,EACP,QAAQ,EACR,iBAAiB,EACjB,SAAS,OAEe,EADrB,SAAS,cATd,oGAUC,CADa;IAId,MAAM,SAA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AAE,KAAK,EAAE,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,UAAU;;YACR,MAAA,uBAAuB,CAAC,OAAO,0CAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;QACrG,CAAC;KACF,CAAC,CAAC,CAAC;IAEJ,OAAO,CACL,oBAAC,OAAO,kBACN,GAAG,EAAE,SAAS,IACV,SAAS,IACb,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,EAC5D,MAAM,EAAE,MAAM,KAEb,QAAQ,CACD,CACX,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,SAAS,kBAAkB,CAAC,IAAiB;IAC3C,gEAAgE;IAChE,oGAAoG;IACpG,oGAAoG;IACpG,0FAA0F;IAC1F,OAAO,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9D,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAwE;IAChG,OAAO,MAAM;SACV,GAAG,CAAC,IAAI,CAAC,EAAE;QACV,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YACrC,OAAO,IAAI,CAAC;SACb;QACD,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,OAAO,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACzC;IACH,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useImperativeHandle, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { LiveRegionController } from './controller';\nimport { LiveRegionProps } from './interfaces';\n\nimport styles from './styles.css.js';\nimport testUtilStyles from './test-classes/styles.css.js';\n\nexport interface InternalLiveRegionProps extends InternalBaseComponentProps, LiveRegionProps {\n /**\n * The delay between each announcement from this live region. You should\n * leave this set to the default unless this live region is commonly\n * interrupted by other actions (like text entry in text filtering).\n */\n delay?: number;\n\n /**\n * Use a list of strings and/or refs to existing elements for building the\n * announcement text. If this property is set, `children` and `message` will\n * be ignored.\n */\n sources?: ReadonlyArray<string | React.RefObject<HTMLElement> | undefined>;\n}\n\nexport interface InternalLiveRegionRef {\n /**\n * Force the live region to announce the message, even if it's the same as\n * the previously announced message.\n *\n * This is useful when making status updates after a change (e.g. filtering)\n * where the new message might be the same as the old one, but the announcement\n * also serves to tell screen reader users that the action was performed.\n */\n reannounce(): void;\n}\n\nexport default React.forwardRef(function InternalLiveRegion(\n {\n assertive = false,\n hidden = false,\n tagName: TagName = 'div',\n delay,\n sources,\n children,\n __internalRootRef,\n className,\n ...restProps\n }: InternalLiveRegionProps,\n ref: React.Ref<InternalLiveRegionRef>\n) {\n const baseProps = getBaseProps(restProps);\n const childrenRef = useRef<HTMLSpanElement & HTMLDivElement>(null);\n const mergedRef = useMergeRefs(childrenRef, __internalRootRef);\n\n useEffect(() => {\n // We have to do this because `inert` isn't properly supported until\n // React 19 and this seems much more maintainable than version detection.\n // `inert` is better than `hidden` because it also blocks pointer and\n // focus events as well as hiding the contents from screen readers.\n // https://github.com/facebook/react/issues/17157\n if (childrenRef.current) {\n childrenRef.current.inert = hidden;\n }\n }, [hidden]);\n\n // Initialize the live region controller inside an effect. We have to do this\n // because the controller depends on DOM elements, which aren't available on the\n // server.\n const liveRegionControllerRef = useRef<LiveRegionController | undefined>();\n useEffect(() => {\n const liveRegionController = new LiveRegionController(assertive ? 'assertive' : 'polite');\n liveRegionControllerRef.current = liveRegionController;\n return () => {\n liveRegionController.destroy();\n liveRegionControllerRef.current = undefined;\n };\n }, [assertive]);\n\n const getContent = () => {\n if (sources) {\n return getSourceContent(sources);\n }\n if (childrenRef.current) {\n return extractTextContent(childrenRef.current);\n }\n };\n\n // Call the controller on every render. The controller will deduplicate the\n // message against the previous announcement internally.\n useEffect(() => {\n liveRegionControllerRef.current?.announce({ message: getContent(), delay });\n });\n\n useImperativeHandle(ref, () => ({\n reannounce() {\n liveRegionControllerRef.current?.announce({ message: getContent(), delay, forceReannounce: true });\n },\n }));\n\n return (\n <TagName\n ref={mergedRef}\n {...baseProps}\n className={clsx(styles.root, testUtilStyles.root, className)}\n hidden={hidden}\n >\n {children}\n </TagName>\n );\n});\n\nfunction extractTextContent(node: HTMLElement): string {\n // We use the text content of the node as the announcement text.\n // This only extracts text content from the node including all its children which is enough for now.\n // To make it more powerful, it is possible to create a more sophisticated extractor with respect to\n // ARIA properties to ignore aria-hidden nodes and read ARIA labels from the live content.\n return (node.textContent || '').replace(/\\s+/g, ' ').trim();\n}\n\nfunction getSourceContent(source: ReadonlyArray<string | React.RefObject<HTMLElement> | undefined>): string {\n return source\n .map(item => {\n if (!item || typeof item === 'string') {\n return item;\n }\n if (item.current) {\n return extractTextContent(item.current);\n }\n })\n .filter(Boolean)\n .join(' ');\n}\n"]}
@@ -0,0 +1,7 @@
1
+
2
+ import './styles.scoped.css';
3
+ export default {
4
+ "root": "awsui_root_1iee7_di2un_141",
5
+ "announcer": "awsui_announcer_1iee7_di2un_149"
6
+ };
7
+
@@ -138,15 +138,15 @@
138
138
  */
139
139
  /* Style used for links in slots/components that are text heavy, to help links stand out among
140
140
  surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
141
- .awsui_root_3bgfn_di2un_141:not(#\9) {
141
+ .awsui_root_1iee7_di2un_141:not(#\9) {
142
142
  display: contents;
143
143
  }
144
144
 
145
- .awsui_root_3bgfn_di2un_141[hidden]:not(#\9) {
145
+ .awsui_root_1iee7_di2un_141[hidden]:not(#\9) {
146
146
  display: none;
147
147
  }
148
148
 
149
- .awsui_announcer_3bgfn_di2un_149:not(#\9) {
149
+ .awsui_announcer_1iee7_di2un_149:not(#\9) {
150
150
  position: absolute !important;
151
151
  inset-block-start: -9999px !important;
152
152
  inset-inline-start: -9999px !important;