@cloudscape-design/components-themeable 3.0.165 → 3.0.167

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 (148) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/code-editor/resizable-box/styles.scss +37 -0
  3. package/lib/internal/scss/code-editor/styles.scss +1 -29
  4. package/lib/internal/scss/select/parts/styles.scss +9 -0
  5. package/lib/internal/scss/table/body-cell/styles.scss +131 -29
  6. package/lib/internal/scss/table/header-cell/styles.scss +15 -7
  7. package/lib/internal/template/button/internal.d.ts +1 -0
  8. package/lib/internal/template/button/internal.d.ts.map +1 -1
  9. package/lib/internal/template/button/internal.js +2 -2
  10. package/lib/internal/template/button/internal.js.map +1 -1
  11. package/lib/internal/template/code-editor/index.d.ts.map +1 -1
  12. package/lib/internal/template/code-editor/index.js +5 -8
  13. package/lib/internal/template/code-editor/index.js.map +1 -1
  14. package/lib/internal/template/code-editor/pane.d.ts.map +1 -1
  15. package/lib/internal/template/code-editor/pane.js +4 -4
  16. package/lib/internal/template/code-editor/pane.js.map +1 -1
  17. package/lib/internal/template/code-editor/resizable-box/index.d.ts +9 -0
  18. package/lib/internal/template/code-editor/resizable-box/index.d.ts.map +1 -0
  19. package/lib/internal/template/code-editor/resizable-box/index.js +44 -0
  20. package/lib/internal/template/code-editor/resizable-box/index.js.map +1 -0
  21. package/lib/internal/template/code-editor/resizable-box/styles.css.js +8 -0
  22. package/lib/internal/template/code-editor/resizable-box/styles.scoped.css +62 -0
  23. package/lib/internal/template/code-editor/resizable-box/styles.selectors.js +9 -0
  24. package/lib/internal/template/code-editor/styles.css.js +32 -33
  25. package/lib/internal/template/code-editor/styles.scoped.css +157 -199
  26. package/lib/internal/template/code-editor/styles.selectors.js +32 -33
  27. package/lib/internal/template/form-field/interfaces.d.ts +10 -0
  28. package/lib/internal/template/form-field/interfaces.d.ts.map +1 -1
  29. package/lib/internal/template/form-field/interfaces.js.map +1 -1
  30. package/lib/internal/template/form-field/internal.d.ts +1 -1
  31. package/lib/internal/template/form-field/internal.d.ts.map +1 -1
  32. package/lib/internal/template/form-field/internal.js +5 -4
  33. package/lib/internal/template/form-field/internal.js.map +1 -1
  34. package/lib/internal/template/input/internal.d.ts.map +1 -1
  35. package/lib/internal/template/input/internal.js +16 -4
  36. package/lib/internal/template/input/internal.js.map +1 -1
  37. package/lib/internal/template/internal/components/live-region/index.d.ts +1 -1
  38. package/lib/internal/template/internal/components/live-region/index.d.ts.map +1 -1
  39. package/lib/internal/template/internal/components/live-region/index.js +29 -6
  40. package/lib/internal/template/internal/components/live-region/index.js.map +1 -1
  41. package/lib/internal/template/internal/context/form-field-context.d.ts +6 -2
  42. package/lib/internal/template/internal/context/form-field-context.d.ts.map +1 -1
  43. package/lib/internal/template/internal/context/form-field-context.js +7 -1
  44. package/lib/internal/template/internal/context/form-field-context.js.map +1 -1
  45. package/lib/internal/template/internal/environment.js +1 -1
  46. package/lib/internal/template/internal/hooks/use-telemetry/index.d.ts.map +1 -1
  47. package/lib/internal/template/internal/hooks/use-telemetry/index.js +4 -0
  48. package/lib/internal/template/internal/hooks/use-telemetry/index.js.map +1 -1
  49. package/lib/internal/template/internal/metrics.d.ts +2 -2
  50. package/lib/internal/template/internal/metrics.d.ts.map +1 -1
  51. package/lib/internal/template/internal/metrics.js +20 -17
  52. package/lib/internal/template/internal/metrics.js.map +1 -1
  53. package/lib/internal/template/internal/types.d.ts +9 -0
  54. package/lib/internal/template/internal/types.d.ts.map +1 -1
  55. package/lib/internal/template/internal/types.js +0 -2
  56. package/lib/internal/template/internal/types.js.map +1 -1
  57. package/lib/internal/template/internal/vendor/d3-scale.js +8 -8
  58. package/lib/internal/template/package.json +0 -1
  59. package/lib/internal/template/progress-bar/index.d.ts.map +1 -1
  60. package/lib/internal/template/progress-bar/index.js +14 -3
  61. package/lib/internal/template/progress-bar/index.js.map +1 -1
  62. package/lib/internal/template/select/parts/styles.css.js +9 -9
  63. package/lib/internal/template/select/parts/styles.scoped.css +27 -9
  64. package/lib/internal/template/select/parts/styles.selectors.js +9 -9
  65. package/lib/internal/template/side-navigation/internal.d.ts.map +1 -1
  66. package/lib/internal/template/side-navigation/internal.js +2 -2
  67. package/lib/internal/template/side-navigation/internal.js.map +1 -1
  68. package/lib/internal/template/table/body-cell/click-away.d.ts +9 -0
  69. package/lib/internal/template/table/body-cell/click-away.d.ts.map +1 -0
  70. package/lib/internal/template/table/body-cell/click-away.js +38 -0
  71. package/lib/internal/template/table/body-cell/click-away.js.map +1 -0
  72. package/lib/internal/template/table/body-cell/index.d.ts +10 -19
  73. package/lib/internal/template/table/body-cell/index.d.ts.map +1 -1
  74. package/lib/internal/template/table/body-cell/index.js +49 -9
  75. package/lib/internal/template/table/body-cell/index.js.map +1 -1
  76. package/lib/internal/template/table/body-cell/inline-editor.d.ts +12 -0
  77. package/lib/internal/template/table/body-cell/inline-editor.d.ts.map +1 -0
  78. package/lib/internal/template/table/body-cell/inline-editor.js +88 -0
  79. package/lib/internal/template/table/body-cell/inline-editor.js.map +1 -0
  80. package/lib/internal/template/table/body-cell/styles.css.js +18 -12
  81. package/lib/internal/template/table/body-cell/styles.scoped.css +229 -46
  82. package/lib/internal/template/table/body-cell/styles.selectors.js +18 -12
  83. package/lib/internal/template/table/body-cell/td-element.d.ts +21 -0
  84. package/lib/internal/template/table/body-cell/td-element.d.ts.map +1 -0
  85. package/lib/internal/template/table/body-cell/td-element.js +11 -0
  86. package/lib/internal/template/table/body-cell/td-element.js.map +1 -0
  87. package/lib/internal/template/table/body-cell/use-stable-scroll-position.d.ts +17 -0
  88. package/lib/internal/template/table/body-cell/use-stable-scroll-position.d.ts.map +1 -0
  89. package/lib/internal/template/table/body-cell/use-stable-scroll-position.js +48 -0
  90. package/lib/internal/template/table/body-cell/use-stable-scroll-position.js.map +1 -0
  91. package/lib/internal/template/table/header-cell/index.d.ts +8 -7
  92. package/lib/internal/template/table/header-cell/index.d.ts.map +1 -1
  93. package/lib/internal/template/table/header-cell/index.js +6 -2
  94. package/lib/internal/template/table/header-cell/index.js.map +1 -1
  95. package/lib/internal/template/table/header-cell/styles.css.js +19 -18
  96. package/lib/internal/template/table/header-cell/styles.scoped.css +40 -35
  97. package/lib/internal/template/table/header-cell/styles.selectors.js +19 -18
  98. package/lib/internal/template/table/interfaces.d.ts +73 -6
  99. package/lib/internal/template/table/interfaces.d.ts.map +1 -1
  100. package/lib/internal/template/table/interfaces.js.map +1 -1
  101. package/lib/internal/template/table/internal.d.ts.map +1 -1
  102. package/lib/internal/template/table/internal.js +68 -18
  103. package/lib/internal/template/table/internal.js.map +1 -1
  104. package/lib/internal/template/table/thead.d.ts.map +1 -1
  105. package/lib/internal/template/table/thead.js +1 -1
  106. package/lib/internal/template/table/thead.js.map +1 -1
  107. package/lib/internal/template/table/use-table-focus-navigation.d.ts +16 -0
  108. package/lib/internal/template/table/use-table-focus-navigation.d.ts.map +1 -0
  109. package/lib/internal/template/table/use-table-focus-navigation.js +131 -0
  110. package/lib/internal/template/table/use-table-focus-navigation.js.map +1 -0
  111. package/lib/internal/template/tabs/index.d.ts +1 -1
  112. package/lib/internal/template/tabs/index.d.ts.map +1 -1
  113. package/lib/internal/template/tabs/index.js +2 -2
  114. package/lib/internal/template/tabs/index.js.map +1 -1
  115. package/lib/internal/template/tabs/interfaces.d.ts +14 -0
  116. package/lib/internal/template/tabs/interfaces.d.ts.map +1 -1
  117. package/lib/internal/template/tabs/interfaces.js.map +1 -1
  118. package/lib/internal/template/tabs/tab-header-bar.d.ts +2 -1
  119. package/lib/internal/template/tabs/tab-header-bar.d.ts.map +1 -1
  120. package/lib/internal/template/tabs/tab-header-bar.js +3 -7
  121. package/lib/internal/template/tabs/tab-header-bar.js.map +1 -1
  122. package/lib/internal/template/test-utils/dom/table/index.d.ts +4 -0
  123. package/lib/internal/template/test-utils/dom/table/index.js +21 -5
  124. package/lib/internal/template/test-utils/dom/table/index.js.map +1 -1
  125. package/lib/internal/template/test-utils/selectors/table/index.d.ts +4 -0
  126. package/lib/internal/template/test-utils/selectors/table/index.js +21 -5
  127. package/lib/internal/template/test-utils/selectors/table/index.js.map +1 -1
  128. package/lib/internal/template/test-utils/tsconfig.tsbuildinfo +1 -1
  129. package/lib/internal/template/wizard/internal/analytics.js +3 -3
  130. package/lib/internal/template/wizard/internal/analytics.js.map +1 -1
  131. package/package.json +1 -1
  132. package/lib/internal/template/code-editor/resize-handler.d.ts +0 -3
  133. package/lib/internal/template/code-editor/resize-handler.d.ts.map +0 -1
  134. package/lib/internal/template/code-editor/resize-handler.js +0 -7
  135. package/lib/internal/template/code-editor/resize-handler.js.map +0 -1
  136. package/lib/internal/template/internal/components/dynamic-aria-live/index.d.ts +0 -28
  137. package/lib/internal/template/internal/components/dynamic-aria-live/index.d.ts.map +0 -1
  138. package/lib/internal/template/internal/components/dynamic-aria-live/index.js +0 -38
  139. package/lib/internal/template/internal/components/dynamic-aria-live/index.js.map +0 -1
  140. package/lib/internal/template/internal/components/live-region/aria-liva-tag.d.ts +0 -13
  141. package/lib/internal/template/internal/components/live-region/aria-liva-tag.d.ts.map +0 -1
  142. package/lib/internal/template/internal/components/live-region/aria-liva-tag.js +0 -18
  143. package/lib/internal/template/internal/components/live-region/aria-liva-tag.js.map +0 -1
  144. package/lib/internal/template/internal/components/live-region/utils.d.ts +0 -8
  145. package/lib/internal/template/internal/components/live-region/utils.d.ts.map +0 -1
  146. package/lib/internal/template/internal/components/live-region/utils.js +0 -24
  147. package/lib/internal/template/internal/components/live-region/utils.js.map +0 -1
  148. package/lib/internal/template/package-lock.json +0 -15689
@@ -1,8 +1,15 @@
1
1
  import { __assign } from "tslib";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { THEME, PACKAGE_VERSION } from './environment';
4
+ import { PACKAGE_VERSION } from './environment';
5
5
  var oneTimeMetrics = {};
6
+ // In case we need to override the theme for VR
7
+ var theme = '';
8
+ function setTheme(newTheme) {
9
+ theme = newTheme;
10
+ }
11
+ // react is the only framework we're using
12
+ var framework = 'react';
6
13
  var buildMetricHash = function (_a) {
7
14
  var source = _a.source, action = _a.action;
8
15
  return ["src".concat(source), "action".concat(action)].join('_');
@@ -23,7 +30,7 @@ var buildMetricDetail = function (_a) {
23
30
  var detailObject = {
24
31
  o: metricOrigin,
25
32
  s: source,
26
- t: THEME,
33
+ t: theme,
27
34
  a: action,
28
35
  f: framework,
29
36
  v: formatMajorVersionForMetricDetail(version)
@@ -32,7 +39,7 @@ var buildMetricDetail = function (_a) {
32
39
  };
33
40
  var buildMetricName = function (_a) {
34
41
  var source = _a.source, version = _a.version;
35
- return ['awsui', source, "".concat(formatVersionForMetricName(THEME, version))].join('_');
42
+ return ['awsui', source, "".concat(formatVersionForMetricName(theme, version))].join('_');
36
43
  };
37
44
  var findPanorama = function (currentWindow) {
38
45
  try {
@@ -66,20 +73,20 @@ var findAWSC = function (currentWindow) {
66
73
  return undefined;
67
74
  }
68
75
  };
69
- // react is the default framework we're logging, for angular we need to set it explicitly
70
- var framework = 'react';
71
- function setFramework(fwk) {
72
- framework = fwk;
73
- }
74
76
  export var Metrics = {
75
- initMetrics: function (fwk) {
76
- setFramework(fwk);
77
+ initMetrics: function (theme) {
78
+ setTheme(theme);
77
79
  },
78
80
  /**
79
81
  * Calls Console Platform's client logging JS API with provided metric name, value, and detail.
80
82
  * Does nothing if Console Platform client logging JS is not present in page.
81
83
  */
82
84
  sendMetric: function (metricName, value, detail) {
85
+ if (!theme) {
86
+ // Metrics need to be initialized first (initMetrics)
87
+ console.error('Metrics need to be initalized first.');
88
+ return;
89
+ }
83
90
  if (!metricName || !/^[a-zA-Z0-9_-]{1,32}$/.test(metricName)) {
84
91
  console.error("Invalid metric name: ".concat(metricName));
85
92
  return;
@@ -97,16 +104,12 @@ export var Metrics = {
97
104
  * Calls Console Platform's client v2 logging JS API with provided metric name and detail.
98
105
  * Does nothing if Console Platform client logging JS is not present in page.
99
106
  */
100
- sendPanoramaMetric: function (metricName, metric) {
101
- if (!metricName || !/^[a-zA-Z0-9_-]{1,32}$/.test(metricName)) {
102
- console.error("Invalid metric name: ".concat(metricName));
103
- return;
104
- }
107
+ sendPanoramaMetric: function (metric) {
105
108
  if (typeof metric.eventDetail === 'object') {
106
109
  metric.eventDetail = JSON.stringify(metric.eventDetail);
107
110
  }
108
111
  if (metric.eventDetail && metric.eventDetail.length > 200) {
109
- console.error("Detail for metric ".concat(metricName, " is too long: ").concat(metric.eventDetail));
112
+ console.error("Detail for metric is too long: ".concat(metric.eventDetail));
110
113
  return;
111
114
  }
112
115
  if (typeof metric.eventValue === 'object') {
@@ -114,7 +117,7 @@ export var Metrics = {
114
117
  }
115
118
  var panorama = findPanorama(window);
116
119
  if (typeof panorama === 'function') {
117
- panorama(metricName, __assign(__assign({}, metric), { timestamp: Date.now() }));
120
+ panorama('trackCustomEvent', __assign(__assign({}, metric), { timestamp: Date.now() }));
118
121
  }
119
122
  },
120
123
  sendMetricObject: function (metric, value) {
@@ -1 +1 @@
1
- {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/internal/metrics.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AA0BvD,IAAM,cAAc,GAA4B,EAAE,CAAC;AAEnD,IAAM,eAAe,GAAG,UAAC,EAAkC;QAAhC,MAAM,YAAA,EAAE,MAAM,YAAA;IACvC,OAAO,CAAC,aAAM,MAAM,CAAE,EAAE,gBAAS,MAAM,CAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,IAAM,eAAe,GAAG,UAAC,aAAqB;IAC5C,IAAM,iBAAiB,GAAG,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAC7D,OAAO,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CA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AAI,cAAc,EAAE;YACjC,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;SAC7B;IACH,CAAC;IACD,iCAAiC,mCAAA;IACjC,0BAA0B,4BAAA;CAC3B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { THEME, PACKAGE_VERSION } from './environment';\n\nexport interface MetricsLogItem {\n source: string;\n action: string;\n version: string;\n}\n\nexport interface MetricsV2EventItem {\n eventType?: string;\n eventContext?: string;\n eventDetail?: string | Record<string, string | number | boolean>;\n eventValue?: string | Record<string, string | number | boolean>;\n}\n\ninterface AWSC {\n Clog: any;\n}\n\ninterface MetricsWindow extends Window {\n AWSC?: AWSC;\n panorama?: any;\n}\n\ndeclare const AWSUI_METRIC_ORIGIN: string | undefined;\n\nconst oneTimeMetrics: Record<string, boolean> = {};\n\nconst buildMetricHash = ({ source, action }: MetricsLogItem): string => {\n return [`src${source}`, `action${action}`].join('_');\n};\n\nconst getMajorVersion = (versionString: string): string => {\n const majorVersionMatch = versionString.match(/^(\\d+\\.\\d+)/);\n return majorVersionMatch ? majorVersionMatch[1] : '';\n};\n\nconst formatMajorVersionForMetricDetail = (version: string) => {\n return version.replace(/\\s/g, '');\n};\n\nconst formatVersionForMetricName = (theme: string, version: string) => {\n return `${theme.charAt(0)}${getMajorVersion(version).replace('.', '')}`;\n};\n\nconst buildMetricDetail = ({ source, action, version }: MetricsLogItem): string => {\n const metricOrigin = typeof AWSUI_METRIC_ORIGIN !== 'undefined' ? AWSUI_METRIC_ORIGIN : 'main';\n const detailObject = {\n o: metricOrigin,\n s: source,\n t: THEME,\n a: action,\n f: framework,\n v: formatMajorVersionForMetricDetail(version),\n };\n return JSON.stringify(detailObject);\n};\n\nconst buildMetricName = ({ source, version }: MetricsLogItem): string => {\n return ['awsui', source, `${formatVersionForMetricName(THEME, version)}`].join('_');\n};\n\nconst findPanorama = (currentWindow?: MetricsWindow): any | undefined => {\n try {\n if (typeof currentWindow?.panorama === 'function') {\n return currentWindow?.panorama;\n }\n\n if (!currentWindow || currentWindow.parent === currentWindow) {\n // When the window has no more parents, it references itself\n return undefined;\n }\n\n return findPanorama(currentWindow.parent);\n } catch (ex) {\n // Most likely a cross-origin access error\n return undefined;\n }\n};\n\nconst findAWSC = (currentWindow?: MetricsWindow): AWSC | undefined => {\n try {\n if (typeof currentWindow?.AWSC === 'object') {\n return currentWindow?.AWSC;\n }\n\n if (!currentWindow || currentWindow.parent === currentWindow) {\n // When the window has no more parents, it references itself\n return undefined;\n }\n\n return findAWSC(currentWindow.parent);\n } catch (ex) {\n // Most likely a cross-origin access error\n return undefined;\n }\n};\n\n// react is the default framework we're logging, for angular we need to set it explicitly\nlet framework = 'react';\nfunction setFramework(fwk: string) {\n framework = fwk;\n}\n\nexport const Metrics = {\n initMetrics(fwk: string) {\n setFramework(fwk);\n },\n\n /**\n * Calls Console Platform's client logging JS API with provided metric name, value, and detail.\n * Does nothing if Console Platform client logging JS is not present in page.\n */\n sendMetric(metricName: string, value: number, detail?: string): void {\n if (!metricName || !/^[a-zA-Z0-9_-]{1,32}$/.test(metricName)) {\n console.error(`Invalid metric name: ${metricName}`);\n return;\n }\n if (detail && detail.length > 200) {\n console.error(`Detail for metric ${metricName} is too long: ${detail}`);\n return;\n }\n const AWSC = findAWSC(window);\n if (typeof AWSC === 'object' && typeof AWSC.Clog === 'object' && typeof AWSC.Clog.log === 'function') {\n AWSC.Clog.log(metricName, value, detail);\n }\n },\n\n /**\n * Calls Console Platform's client v2 logging JS API with provided metric name and detail.\n * Does nothing if Console Platform client logging JS is not present in page.\n */\n sendPanoramaMetric(metricName: string, metric: MetricsV2EventItem): void {\n if (!metricName || !/^[a-zA-Z0-9_-]{1,32}$/.test(metricName)) {\n console.error(`Invalid metric name: ${metricName}`);\n return;\n }\n if (typeof metric.eventDetail === 'object') {\n metric.eventDetail = JSON.stringify(metric.eventDetail);\n }\n if (metric.eventDetail && metric.eventDetail.length > 200) {\n console.error(`Detail for metric ${metricName} is too long: ${metric.eventDetail}`);\n return;\n }\n if (typeof metric.eventValue === 'object') {\n metric.eventValue = JSON.stringify(metric.eventValue);\n }\n const panorama = findPanorama(window);\n if (typeof panorama === 'function') {\n panorama(metricName, {\n ...metric,\n timestamp: Date.now(),\n });\n }\n },\n\n sendMetricObject(metric: MetricsLogItem, value: number): void {\n this.sendMetric(buildMetricName(metric), value, buildMetricDetail(metric));\n },\n\n sendMetricObjectOnce(metric: MetricsLogItem, value: number): void {\n const metricHash = buildMetricHash(metric);\n if (!oneTimeMetrics[metricHash]) {\n this.sendMetricObject(metric, value);\n oneTimeMetrics[metricHash] = true;\n }\n },\n\n /*\n * Calls Console Platform's client logging only the first time the provided metricName is used.\n * Subsequent calls with the same metricName are ignored.\n */\n sendMetricOnce(metricName: string, value: number, detail?: string): void {\n if (!oneTimeMetrics[metricName]) {\n this.sendMetric(metricName, value, detail);\n oneTimeMetrics[metricName] = true;\n }\n },\n\n /*\n * Reports a metric value 1 to Console Platform's client logging service to indicate that the\n * component was loaded. The component load event will only be reported as used to client logging\n * service once per page view.\n */\n logComponentLoaded() {\n this.sendMetricObjectOnce(\n {\n source: 'components',\n action: 'loaded',\n version: PACKAGE_VERSION,\n },\n 1\n );\n },\n\n /*\n * Reports a metric value 1 to Console Platform's client logging service to indicate that the\n * component was used in the page. A component will only be reported as used to client logging\n * service once per page view.\n */\n logComponentUsed(componentName: string) {\n this.sendMetricObjectOnce(\n {\n source: componentName,\n action: 'used',\n version: PACKAGE_VERSION,\n },\n 1\n );\n },\n};\n\nexport const MetricsTestHelper = {\n resetOneTimeMetricsCache: () => {\n for (const prop in oneTimeMetrics) {\n delete oneTimeMetrics[prop];\n }\n },\n formatMajorVersionForMetricDetail,\n formatVersionForMetricName,\n};\n"]}
1
+ {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/internal/metrics.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,eAA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;;OAIG;IACH,kBAAkB;QAChB,IAAI,CAAC,oBAAoB,CACvB;YACE,MAAM,EAAE,YAAY;YACpB,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE,eAAe;SACzB,EACD,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,gBAAgB,YAAC,aAAqB;QACpC,IAAI,CAAC,oBAAoB,CACvB;YACE,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,eAAe;SACzB,EACD,CAAC,CACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,IAAM,iBAAiB,GAAG;IAC/B,wBAAwB,EAAE;QACxB,KAAK,IAAM,IAAI,IAAI,cAAc,EAAE;YACjC,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;SAC7B;IACH,CAAC;IACD,iCAAiC,mCAAA;IACjC,0BAA0B,4BAAA;CAC3B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { PACKAGE_VERSION } from './environment';\n\nexport interface MetricsLogItem {\n source: string;\n action: string;\n version: string;\n}\n\nexport interface MetricsV2EventItem {\n eventType?: string;\n eventContext?: string;\n eventDetail?: string | Record<string, string | number | boolean>;\n eventValue?: string | Record<string, string | number | boolean>;\n}\n\ninterface AWSC {\n Clog: any;\n}\n\ninterface MetricsWindow extends Window {\n AWSC?: AWSC;\n panorama?: any;\n}\n\ndeclare const AWSUI_METRIC_ORIGIN: string | undefined;\n\nconst oneTimeMetrics: Record<string, boolean> = {};\n\n// In case we need to override the theme for VR\nlet theme = '';\nfunction setTheme(newTheme: string) {\n theme = newTheme;\n}\n\n// react is the only framework we're using\nconst framework = 'react';\n\nconst buildMetricHash = ({ source, action }: MetricsLogItem): string => {\n return [`src${source}`, `action${action}`].join('_');\n};\n\nconst getMajorVersion = (versionString: string): string => {\n const majorVersionMatch = versionString.match(/^(\\d+\\.\\d+)/);\n return majorVersionMatch ? majorVersionMatch[1] : '';\n};\n\nconst formatMajorVersionForMetricDetail = (version: string) => {\n return version.replace(/\\s/g, '');\n};\n\nconst formatVersionForMetricName = (theme: string, version: string) => {\n return `${theme.charAt(0)}${getMajorVersion(version).replace('.', '')}`;\n};\n\nconst buildMetricDetail = ({ source, action, version }: MetricsLogItem): string => {\n const metricOrigin = typeof AWSUI_METRIC_ORIGIN !== 'undefined' ? AWSUI_METRIC_ORIGIN : 'main';\n const detailObject = {\n o: metricOrigin,\n s: source,\n t: theme,\n a: action,\n f: framework,\n v: formatMajorVersionForMetricDetail(version),\n };\n return JSON.stringify(detailObject);\n};\n\nconst buildMetricName = ({ source, version }: MetricsLogItem): string => {\n return ['awsui', source, `${formatVersionForMetricName(theme, version)}`].join('_');\n};\n\nconst findPanorama = (currentWindow?: MetricsWindow): any | undefined => {\n try {\n if (typeof currentWindow?.panorama === 'function') {\n return currentWindow?.panorama;\n }\n\n if (!currentWindow || currentWindow.parent === currentWindow) {\n // When the window has no more parents, it references itself\n return undefined;\n }\n\n return findPanorama(currentWindow.parent);\n } catch (ex) {\n // Most likely a cross-origin access error\n return undefined;\n }\n};\n\nconst findAWSC = (currentWindow?: MetricsWindow): AWSC | undefined => {\n try {\n if (typeof currentWindow?.AWSC === 'object') {\n return currentWindow?.AWSC;\n }\n\n if (!currentWindow || currentWindow.parent === currentWindow) {\n // When the window has no more parents, it references itself\n return undefined;\n }\n\n return findAWSC(currentWindow.parent);\n } catch (ex) {\n // Most likely a cross-origin access error\n return undefined;\n }\n};\n\nexport const Metrics = {\n initMetrics(theme: string) {\n setTheme(theme);\n },\n\n /**\n * Calls Console Platform's client logging JS API with provided metric name, value, and detail.\n * Does nothing if Console Platform client logging JS is not present in page.\n */\n sendMetric(metricName: string, value: number, detail?: string): void {\n if (!theme) {\n // Metrics need to be initialized first (initMetrics)\n console.error('Metrics need to be initalized first.');\n return;\n }\n\n if (!metricName || !/^[a-zA-Z0-9_-]{1,32}$/.test(metricName)) {\n console.error(`Invalid metric name: ${metricName}`);\n return;\n }\n if (detail && detail.length > 200) {\n console.error(`Detail for metric ${metricName} is too long: ${detail}`);\n return;\n }\n const AWSC = findAWSC(window);\n if (typeof AWSC === 'object' && typeof AWSC.Clog === 'object' && typeof AWSC.Clog.log === 'function') {\n AWSC.Clog.log(metricName, value, detail);\n }\n },\n\n /**\n * Calls Console Platform's client v2 logging JS API with provided metric name and detail.\n * Does nothing if Console Platform client logging JS is not present in page.\n */\n sendPanoramaMetric(metric: MetricsV2EventItem): void {\n if (typeof metric.eventDetail === 'object') {\n metric.eventDetail = JSON.stringify(metric.eventDetail);\n }\n if (metric.eventDetail && metric.eventDetail.length > 200) {\n console.error(`Detail for metric is too long: ${metric.eventDetail}`);\n return;\n }\n if (typeof metric.eventValue === 'object') {\n metric.eventValue = JSON.stringify(metric.eventValue);\n }\n const panorama = findPanorama(window);\n if (typeof panorama === 'function') {\n panorama('trackCustomEvent', {\n ...metric,\n timestamp: Date.now(),\n });\n }\n },\n\n sendMetricObject(metric: MetricsLogItem, value: number): void {\n this.sendMetric(buildMetricName(metric), value, buildMetricDetail(metric));\n },\n\n sendMetricObjectOnce(metric: MetricsLogItem, value: number): void {\n const metricHash = buildMetricHash(metric);\n if (!oneTimeMetrics[metricHash]) {\n this.sendMetricObject(metric, value);\n oneTimeMetrics[metricHash] = true;\n }\n },\n\n /*\n * Calls Console Platform's client logging only the first time the provided metricName is used.\n * Subsequent calls with the same metricName are ignored.\n */\n sendMetricOnce(metricName: string, value: number, detail?: string): void {\n if (!oneTimeMetrics[metricName]) {\n this.sendMetric(metricName, value, detail);\n oneTimeMetrics[metricName] = true;\n }\n },\n\n /*\n * Reports a metric value 1 to Console Platform's client logging service to indicate that the\n * component was loaded. The component load event will only be reported as used to client logging\n * service once per page view.\n */\n logComponentLoaded() {\n this.sendMetricObjectOnce(\n {\n source: 'components',\n action: 'loaded',\n version: PACKAGE_VERSION,\n },\n 1\n );\n },\n\n /*\n * Reports a metric value 1 to Console Platform's client logging service to indicate that the\n * component was used in the page. A component will only be reported as used to client logging\n * service once per page view.\n */\n logComponentUsed(componentName: string) {\n this.sendMetricObjectOnce(\n {\n source: componentName,\n action: 'used',\n version: PACKAGE_VERSION,\n },\n 1\n );\n },\n};\n\nexport const MetricsTestHelper = {\n resetOneTimeMetricsCache: () => {\n for (const prop in oneTimeMetrics) {\n delete oneTimeMetrics[prop];\n }\n },\n formatMajorVersionForMetricDetail,\n formatVersionForMetricName,\n};\n"]}
@@ -14,4 +14,13 @@
14
14
  export type SomeRequired<Type, Keys extends keyof Type> = Type & {
15
15
  [Key in Keys]-?: Type[Key];
16
16
  };
17
+ /**
18
+ * Utility type that makes a union of given type and undefined.
19
+ * @example
20
+ * ```
21
+ * type OptionalString = Optional<string>
22
+ * type OptionalStringOrNumber = Optional<string | number>
23
+ * ```
24
+ */
25
+ export type Optional<Type> = Type | undefined;
17
26
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/internal/types.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,CAAC,IAAI,EAAE,IAAI,SAAS,MAAM,IAAI,IAAI,IAAI,GAAG;KAC9D,GAAG,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;CAC3B,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/internal/types.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,CAAC,IAAI,EAAE,IAAI,SAAS,MAAM,IAAI,IAAI,IAAI,GAAG;KAC9D,GAAG,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;CAC3B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,CAAC,IAAI,IAAI,IAAI,GAAG,SAAS,CAAC"}
@@ -1,4 +1,2 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
1
  export {};
4
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/internal/types.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\n/**\n * Makes specified properties required.\n *\n * @example\n * ```\n * import { AlertProps } from '~components/alert/interfaces'\n *\n * type InternalAlertProps = SomeRequired<AlertProps, 'type'>\n *\n * function Alert(props: AlertProps) { ... }\n * function InternalAlert(props: InternalAlertProps) { ... }\n * ```\n */\nexport type SomeRequired<Type, Keys extends keyof Type> = Type & {\n [Key in Keys]-?: Type[Key];\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/internal/types.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Makes specified properties required.\n *\n * @example\n * ```\n * import { AlertProps } from '~components/alert/interfaces'\n *\n * type InternalAlertProps = SomeRequired<AlertProps, 'type'>\n *\n * function Alert(props: AlertProps) { ... }\n * function InternalAlert(props: InternalAlertProps) { ... }\n * ```\n */\nexport type SomeRequired<Type, Keys extends keyof Type> = Type & {\n [Key in Keys]-?: Type[Key];\n};\n\n/**\n * Utility type that makes a union of given type and undefined.\n * @example\n * ```\n * type OptionalString = Optional<string>\n * type OptionalStringOrNumber = Optional<string | number>\n * ```\n */\nexport type Optional<Type> = Type | undefined;\n"]}
@@ -4,7 +4,7 @@
4
4
  * License: ISC
5
5
  * Private: false
6
6
  * Description: Array manipulation, ordering, searching, summarizing, etc.
7
- * Repository: git+https://github.com/d3/d3-array.git
7
+ * Repository: https://github.com/d3/d3-array.git
8
8
  * Homepage: https://d3js.org/d3-array/
9
9
  * Author: Mike Bostock (http://bost.ocks.org/mike)
10
10
  * License Copyright:
@@ -32,7 +32,7 @@
32
32
  * License: ISC
33
33
  * Private: false
34
34
  * Description: Map and Set with automatic key interning
35
- * Repository: git+https://github.com/mbostock/internmap.git
35
+ * Repository: https://github.com/mbostock/internmap.git
36
36
  * Homepage: https://github.com/mbostock/internmap/
37
37
  * Author: Mike Bostock (https://bost.ocks.org/mike)
38
38
  * License Copyright:
@@ -60,7 +60,7 @@
60
60
  * License: ISC
61
61
  * Private: false
62
62
  * Description: Encodings that map abstract data to visual representation.
63
- * Repository: git+https://github.com/d3/d3-scale.git
63
+ * Repository: https://github.com/d3/d3-scale.git
64
64
  * Homepage: https://d3js.org/d3-scale/
65
65
  * Author: Mike Bostock (https://bost.ocks.org/mike)
66
66
  * License Copyright:
@@ -88,7 +88,7 @@
88
88
  * License: ISC
89
89
  * Private: false
90
90
  * Description: Color spaces! RGB, HSL, Cubehelix, Lab and HCL (Lch).
91
- * Repository: git+https://github.com/d3/d3-color.git
91
+ * Repository: https://github.com/d3/d3-color.git
92
92
  * Homepage: https://d3js.org/d3-color/
93
93
  * Author: Mike Bostock (http://bost.ocks.org/mike)
94
94
  * License Copyright:
@@ -116,7 +116,7 @@
116
116
  * License: ISC
117
117
  * Private: false
118
118
  * Description: Interpolate numbers, colors, strings, arrays, objects, whatever!
119
- * Repository: git+https://github.com/d3/d3-interpolate.git
119
+ * Repository: https://github.com/d3/d3-interpolate.git
120
120
  * Homepage: https://d3js.org/d3-interpolate/
121
121
  * Author: Mike Bostock (http://bost.ocks.org/mike)
122
122
  * License Copyright:
@@ -144,7 +144,7 @@
144
144
  * License: ISC
145
145
  * Private: false
146
146
  * Description: Format numbers for human consumption.
147
- * Repository: git+https://github.com/d3/d3-format.git
147
+ * Repository: https://github.com/d3/d3-format.git
148
148
  * Homepage: https://d3js.org/d3-format/
149
149
  * Author: Mike Bostock (http://bost.ocks.org/mike)
150
150
  * License Copyright:
@@ -172,7 +172,7 @@
172
172
  * License: ISC
173
173
  * Private: false
174
174
  * Description: A calculator for humanity’s peculiar conventions of time.
175
- * Repository: git+https://github.com/d3/d3-time.git
175
+ * Repository: https://github.com/d3/d3-time.git
176
176
  * Homepage: https://d3js.org/d3-time/
177
177
  * Author: Mike Bostock (http://bost.ocks.org/mike)
178
178
  * License Copyright:
@@ -200,7 +200,7 @@
200
200
  * License: ISC
201
201
  * Private: false
202
202
  * Description: A JavaScript time formatter and parser inspired by strftime and strptime.
203
- * Repository: git+https://github.com/d3/d3-time-format.git
203
+ * Repository: https://github.com/d3/d3-time-format.git
204
204
  * Homepage: https://d3js.org/d3-time-format/
205
205
  * Author: Mike Bostock (http://bost.ocks.org/mike)
206
206
  * License Copyright:
@@ -103,7 +103,6 @@
103
103
  "mnth": "^2.0.0",
104
104
  "react-focus-lock": "~2.8.1",
105
105
  "react-keyed-flatten-children": "^1.3.0",
106
- "react-resizable": "^1.11.1",
107
106
  "react-transition-group": "^4.4.2",
108
107
  "react-virtual": "^2.8.2",
109
108
  "tslib": "^2.4.0",
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/progress-bar/index.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAQhD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,KAAS,EACT,MAAsB,EACtB,OAAsB,EACtB,gBAAgB,EAChB,KAAK,EACL,WAAW,EACX,cAAc,EACd,UAAU,EACV,mBAAmB,EACnB,GAAG,IAAI,EACR,EAAE,gBAAgB,eAiDlB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/progress-bar/index.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAWhD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,KAAS,EACT,MAAsB,EACtB,OAAsB,EACtB,gBAAgB,EAChB,KAAK,EACL,WAAW,EACX,cAAc,EACd,UAAU,EACV,mBAAmB,EACnB,GAAG,IAAI,EACR,EAAE,gBAAgB,eA4DlB"}
@@ -1,7 +1,7 @@
1
1
  import { __assign, __rest } from "tslib";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import React from 'react';
4
+ import React, { useEffect, useMemo, useState } from 'react';
5
5
  import clsx from 'clsx';
6
6
  import styles from './styles.css.js';
7
7
  import { getBaseProps } from '../internal/base-component';
@@ -11,7 +11,9 @@ import { useUniqueId } from '../internal/hooks/use-unique-id';
11
11
  import { Progress, ResultState, SmallText } from './internal';
12
12
  import { applyDisplayName } from '../internal/utils/apply-display-name';
13
13
  import useBaseComponent from '../internal/hooks/use-base-component';
14
- import DynamicAriaLive from '../internal/components/dynamic-aria-live';
14
+ import { throttle } from '../internal/utils/throttle';
15
+ import LiveRegion from '../internal/components/live-region';
16
+ var ASSERTION_FREQUENCY = 5000; // interval in ms between progress announcements
15
17
  export default function ProgressBar(_a) {
16
18
  var _b = _a.value, value = _b === void 0 ? 0 : _b, _c = _a.status, status = _c === void 0 ? 'in-progress' : _c, _d = _a.variant, variant = _d === void 0 ? 'standalone' : _d, resultButtonText = _a.resultButtonText, label = _a.label, description = _a.description, additionalInfo = _a.additionalInfo, resultText = _a.resultText, onResultButtonClick = _a.onResultButtonClick, rest = __rest(_a, ["value", "status", "variant", "resultButtonText", "label", "description", "additionalInfo", "resultText", "onResultButtonClick"]);
17
19
  var __internalRootRef = useBaseComponent('ProgressBar').__internalRootRef;
@@ -20,6 +22,15 @@ export default function ProgressBar(_a) {
20
22
  var labelId = "".concat(generatedName, "-label");
21
23
  var isInFlash = variant === 'flash';
22
24
  var isInProgressState = status === 'in-progress';
25
+ var _e = useState(''), assertion = _e[0], setAssertion = _e[1];
26
+ var throttledAssertion = useMemo(function () {
27
+ return throttle(function (value) {
28
+ setAssertion("".concat(label !== null && label !== void 0 ? label : '', ": ").concat(value, "%"));
29
+ }, ASSERTION_FREQUENCY);
30
+ }, [label]);
31
+ useEffect(function () {
32
+ throttledAssertion(value);
33
+ }, [throttledAssertion, value]);
23
34
  if (isInFlash && resultButtonText) {
24
35
  warnOnce('ProgressBar', 'The `resultButtonText` is ignored if you set `variant="flash"`, and the result button is not displayed. Use the `buttonText` property and the `onButtonClick` event listener of the flashbar item in which the progress bar component is embedded.');
25
36
  }
@@ -29,7 +40,7 @@ export default function ProgressBar(_a) {
29
40
  description && React.createElement(SmallText, { color: isInFlash ? 'inherit' : undefined }, description),
30
41
  React.createElement("div", null, isInProgressState ? (React.createElement(React.Fragment, null,
31
42
  React.createElement(Progress, { value: value, labelId: labelId, isInFlash: isInFlash }),
32
- React.createElement(DynamicAriaLive, null, "".concat(label !== null && label !== void 0 ? label : '', ": ").concat(value, "%")))) : (React.createElement(ResultState, { resultText: resultText, isInFlash: isInFlash, resultButtonText: resultButtonText, status: status, onClick: function () {
43
+ React.createElement(LiveRegion, { delay: 0 }, assertion))) : (React.createElement(ResultState, { resultText: resultText, isInFlash: isInFlash, resultButtonText: resultButtonText, status: status, onClick: function () {
33
44
  fireNonCancelableEvent(onResultButtonClick);
34
45
  } })))),
35
46
  additionalInfo && React.createElement(SmallText, { color: isInFlash ? 'inherit' : undefined }, additionalInfo)));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/progress-bar/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,sB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tB,6BAAK,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS;YAC/D,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,gBAAS,OAAO,CAAE,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,IAC/E,KAAK,CACF;YACL,WAAW,IAAI,oBAAC,SAAS,IAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,IAAG,WAAW,CAAa;YAC9F,iCACG,iBAAiB,CAAC,CAAC,CAAC,CACnB;gBACE,oBAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAI;gBAClE,oBAAC,eAAe,QAAE,UAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,eAAK,KAAK,MAAG,CAAmB,CAC/D,CACJ,CAAC,CAAC,CAAC,CACF,oBAAC,WAAW,IACV,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;oBACP,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;gBAC9C,CAAC,GACD,CACH,CACG,CACF;QACL,cAAc,IAAI,oBAAC,SAAS,IAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,IAAG,cAAc,CAAa,CAChG,CACP,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport styles from './styles.css.js';\nimport { getBaseProps } from '../internal/base-component';\nimport { warnOnce } from '../internal/logging';\nimport { ProgressBarProps } from './interfaces';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { Progress, ResultState, SmallText } from './internal';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport DynamicAriaLive from '../internal/components/dynamic-aria-live';\n\nexport { ProgressBarProps };\n\nexport default function ProgressBar({\n value = 0,\n status = 'in-progress',\n variant = 'standalone',\n resultButtonText,\n label,\n description,\n additionalInfo,\n resultText,\n onResultButtonClick,\n ...rest\n}: ProgressBarProps) {\n const { __internalRootRef } = useBaseComponent('ProgressBar');\n const baseProps = getBaseProps(rest);\n const generatedName = useUniqueId('awsui-progress-bar-');\n\n const labelId = `${generatedName}-label`;\n const isInFlash = variant === 'flash';\n const isInProgressState = status === 'in-progress';\n\n if (isInFlash && resultButtonText) {\n warnOnce(\n 'ProgressBar',\n 'The `resultButtonText` is ignored if you set `variant=\"flash\"`, and the result button is not displayed. Use the `buttonText` property and the `onButtonClick` event listener of the flashbar item in which the progress bar component is embedded.'\n );\n }\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root, variant && styles[variant])}\n ref={__internalRootRef}\n >\n <div className={isInFlash ? styles['flash-container'] : undefined}>\n <div className={clsx(styles['word-wrap'], styles[`label-${variant}`])} id={labelId}>\n {label}\n </div>\n {description && <SmallText color={isInFlash ? 'inherit' : undefined}>{description}</SmallText>}\n <div>\n {isInProgressState ? (\n <>\n <Progress value={value} labelId={labelId} isInFlash={isInFlash} />\n <DynamicAriaLive>{`${label ?? ''}: ${value}%`}</DynamicAriaLive>\n </>\n ) : (\n <ResultState\n resultText={resultText}\n isInFlash={isInFlash}\n resultButtonText={resultButtonText}\n status={status}\n onClick={() => {\n fireNonCancelableEvent(onResultButtonClick);\n }}\n />\n )}\n </div>\n </div>\n {additionalInfo && <SmallText color={isInFlash ? 'inherit' : undefined}>{additionalInfo}</SmallText>}\n </div>\n );\n}\n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E,OAAO,IAC/E,KAAK,CACF;YACL,WAAW,IAAI,oBAAC,SAAS,IAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,IAAG,WAAW,CAAa;YAC9F,iCACG,iBAAiB,CAAC,CAAC,CAAC,CACnB;gBACE,oBAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAI;gBAClE,oBAAC,UAAU,IAAC,KAAK,EAAE,CAAC,IAAG,SAAS,CAAc,CAC7C,CACJ,CAAC,CAAC,CAAC,CACF,oBAAC,WAAW,IACV,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;oBACP,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;gBAC9C,CAAC,GACD,CACH,CACG,CACF;QACL,cAAc,IAAI,oBAAC,SAAS,IAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,IAAG,cAAc,CAAa,CAChG,CACP,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useMemo, useState } from 'react';\nimport clsx from 'clsx';\n\nimport styles from './styles.css.js';\nimport { getBaseProps } from '../internal/base-component';\nimport { warnOnce } from '../internal/logging';\nimport { ProgressBarProps } from './interfaces';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { Progress, ResultState, SmallText } from './internal';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { throttle } from '../internal/utils/throttle';\nimport LiveRegion from '../internal/components/live-region';\n\nconst ASSERTION_FREQUENCY = 5000; // interval in ms between progress announcements\n\nexport { ProgressBarProps };\n\nexport default function ProgressBar({\n value = 0,\n status = 'in-progress',\n variant = 'standalone',\n resultButtonText,\n label,\n description,\n additionalInfo,\n resultText,\n onResultButtonClick,\n ...rest\n}: ProgressBarProps) {\n const { __internalRootRef } = useBaseComponent('ProgressBar');\n const baseProps = getBaseProps(rest);\n const generatedName = useUniqueId('awsui-progress-bar-');\n\n const labelId = `${generatedName}-label`;\n const isInFlash = variant === 'flash';\n const isInProgressState = status === 'in-progress';\n\n const [assertion, setAssertion] = useState('');\n const throttledAssertion = useMemo(() => {\n return throttle((value: ProgressBarProps['value']) => {\n setAssertion(`${label ?? ''}: ${value}%`);\n }, ASSERTION_FREQUENCY);\n }, [label]);\n\n useEffect(() => {\n throttledAssertion(value);\n }, [throttledAssertion, value]);\n\n if (isInFlash && resultButtonText) {\n warnOnce(\n 'ProgressBar',\n 'The `resultButtonText` is ignored if you set `variant=\"flash\"`, and the result button is not displayed. Use the `buttonText` property and the `onButtonClick` event listener of the flashbar item in which the progress bar component is embedded.'\n );\n }\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root, variant && styles[variant])}\n ref={__internalRootRef}\n >\n <div className={isInFlash ? styles['flash-container'] : undefined}>\n <div className={clsx(styles['word-wrap'], styles[`label-${variant}`])} id={labelId}>\n {label}\n </div>\n {description && <SmallText color={isInFlash ? 'inherit' : undefined}>{description}</SmallText>}\n <div>\n {isInProgressState ? (\n <>\n <Progress value={value} labelId={labelId} isInFlash={isInFlash} />\n <LiveRegion delay={0}>{assertion}</LiveRegion>\n </>\n ) : (\n <ResultState\n resultText={resultText}\n isInFlash={isInFlash}\n resultButtonText={resultButtonText}\n status={status}\n onClick={() => {\n fireNonCancelableEvent(onResultButtonClick);\n }}\n />\n )}\n </div>\n </div>\n {additionalInfo && <SmallText color={isInFlash ? 'inherit' : undefined}>{additionalInfo}</SmallText>}\n </div>\n );\n}\n\napplyDisplayName(ProgressBar, 'ProgressBar');\n"]}
@@ -1,14 +1,14 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "placeholder": "awsui_placeholder_dwuol_mf4fo_93",
5
- "item": "awsui_item_dwuol_mf4fo_98",
6
- "checkbox": "awsui_checkbox_dwuol_mf4fo_102",
7
- "filter": "awsui_filter_dwuol_mf4fo_111",
8
- "trigger": "awsui_trigger_dwuol_mf4fo_116",
9
- "layout-strut": "awsui_layout-strut_dwuol_mf4fo_122",
10
- "list-bottom": "awsui_list-bottom_dwuol_mf4fo_128",
11
- "selected-icon": "awsui_selected-icon_dwuol_mf4fo_132",
12
- "show-label-tag": "awsui_show-label-tag_dwuol_mf4fo_136"
4
+ "placeholder": "awsui_placeholder_dwuol_1dfho_93",
5
+ "item": "awsui_item_dwuol_1dfho_98",
6
+ "checkbox": "awsui_checkbox_dwuol_1dfho_102",
7
+ "filter": "awsui_filter_dwuol_1dfho_111",
8
+ "trigger": "awsui_trigger_dwuol_1dfho_116",
9
+ "layout-strut": "awsui_layout-strut_dwuol_1dfho_140",
10
+ "list-bottom": "awsui_list-bottom_dwuol_1dfho_146",
11
+ "selected-icon": "awsui_selected-icon_dwuol_1dfho_150",
12
+ "show-label-tag": "awsui_show-label-tag_dwuol_1dfho_154"
13
13
  };
14
14
 
@@ -90,16 +90,16 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
90
90
  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
91
91
  SPDX-License-Identifier: Apache-2.0
92
92
  */
93
- .awsui_placeholder_dwuol_mf4fo_93:not(#\9) {
93
+ .awsui_placeholder_dwuol_1dfho_93:not(#\9) {
94
94
  color: var(--color-text-input-placeholder-rtvjp5, #687078);
95
95
  font-style: italic;
96
96
  }
97
97
 
98
- .awsui_item_dwuol_mf4fo_98:not(#\9) {
98
+ .awsui_item_dwuol_1dfho_98:not(#\9) {
99
99
  display: flex;
100
100
  align-items: center;
101
101
  }
102
- .awsui_item_dwuol_mf4fo_98 > .awsui_checkbox_dwuol_mf4fo_102:not(#\9) {
102
+ .awsui_item_dwuol_1dfho_98 > .awsui_checkbox_dwuol_1dfho_102:not(#\9) {
103
103
  position: relative;
104
104
  min-height: var(--size-control-eyly4k, 14px);
105
105
  min-width: var(--size-control-eyly4k, 14px);
@@ -108,31 +108,49 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
108
108
  margin-right: var(--space-field-horizontal-z3i1c8, 8px);
109
109
  }
110
110
 
111
- .awsui_filter_dwuol_mf4fo_111:not(#\9) {
111
+ .awsui_filter_dwuol_1dfho_111:not(#\9) {
112
112
  z-index: 4;
113
113
  flex-shrink: 0;
114
114
  }
115
115
 
116
- .awsui_trigger_dwuol_mf4fo_116:not(#\9) {
116
+ .awsui_trigger_dwuol_1dfho_116:not(#\9) {
117
117
  white-space: nowrap;
118
118
  overflow: hidden;
119
119
  text-overflow: ellipsis;
120
120
  }
121
+ .awsui_trigger_dwuol_1dfho_116[data-awsui-focus-visible=true]:not(#\9):focus {
122
+ position: relative;
123
+ }
124
+ .awsui_trigger_dwuol_1dfho_116[data-awsui-focus-visible=true]:not(#\9):focus {
125
+ outline: 2px dotted transparent;
126
+ outline-offset: calc(calc(-1 * var(--space-scaled-xs-6859qs, 8px)) - 1px);
127
+ }
128
+ .awsui_trigger_dwuol_1dfho_116[data-awsui-focus-visible=true]:not(#\9):focus::before {
129
+ content: " ";
130
+ display: block;
131
+ position: absolute;
132
+ left: calc(-1 * calc(-1 * var(--space-scaled-xs-6859qs, 8px)));
133
+ top: calc(-1 * calc(-1 * var(--space-scaled-xxs-95dhkm, 4px)));
134
+ width: calc(100% + 2 * calc(-1 * var(--space-scaled-xs-6859qs, 8px)));
135
+ height: calc(100% + 2 * calc(-1 * var(--space-scaled-xxs-95dhkm, 4px)));
136
+ border-radius: var(--border-radius-control-default-focus-ring-hekmgc, 2px);
137
+ box-shadow: 0 0 0 2px var(--color-border-item-focused-n5kd8g, #0073bb);
138
+ }
121
139
 
122
- .awsui_layout-strut_dwuol_mf4fo_122:not(#\9) {
140
+ .awsui_layout-strut_dwuol_1dfho_140:not(#\9) {
123
141
  width: 100%;
124
142
  position: relative;
125
143
  transform: translate3d(0, 0, 0);
126
144
  }
127
145
 
128
- .awsui_list-bottom_dwuol_mf4fo_128:not(#\9) {
146
+ .awsui_list-bottom_dwuol_1dfho_146:not(#\9) {
129
147
  /* used in unit-tests */
130
148
  }
131
149
 
132
- .awsui_selected-icon_dwuol_mf4fo_132:not(#\9) {
150
+ .awsui_selected-icon_dwuol_1dfho_150:not(#\9) {
133
151
  color: var(--color-border-item-focused-n5kd8g, #0073bb);
134
152
  }
135
153
 
136
- .awsui_show-label-tag_dwuol_mf4fo_136 > .awsui_selected-icon_dwuol_mf4fo_132:not(#\9) {
154
+ .awsui_show-label-tag_dwuol_1dfho_154 > .awsui_selected-icon_dwuol_1dfho_150:not(#\9) {
137
155
  padding-left: var(--space-scaled-s-cu1hzn, 12px);
138
156
  }
@@ -2,14 +2,14 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "placeholder": "awsui_placeholder_dwuol_mf4fo_93",
6
- "item": "awsui_item_dwuol_mf4fo_98",
7
- "checkbox": "awsui_checkbox_dwuol_mf4fo_102",
8
- "filter": "awsui_filter_dwuol_mf4fo_111",
9
- "trigger": "awsui_trigger_dwuol_mf4fo_116",
10
- "layout-strut": "awsui_layout-strut_dwuol_mf4fo_122",
11
- "list-bottom": "awsui_list-bottom_dwuol_mf4fo_128",
12
- "selected-icon": "awsui_selected-icon_dwuol_mf4fo_132",
13
- "show-label-tag": "awsui_show-label-tag_dwuol_mf4fo_136"
5
+ "placeholder": "awsui_placeholder_dwuol_1dfho_93",
6
+ "item": "awsui_item_dwuol_1dfho_98",
7
+ "checkbox": "awsui_checkbox_dwuol_1dfho_102",
8
+ "filter": "awsui_filter_dwuol_1dfho_111",
9
+ "trigger": "awsui_trigger_dwuol_1dfho_116",
10
+ "layout-strut": "awsui_layout-strut_dwuol_1dfho_140",
11
+ "list-bottom": "awsui_list-bottom_dwuol_1dfho_146",
12
+ "selected-icon": "awsui_selected-icon_dwuol_1dfho_150",
13
+ "show-label-tag": "awsui_show-label-tag_dwuol_1dfho_154"
14
14
  };
15
15
 
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/side-navigation/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAMzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAOnD,UAAU,sBAAsB;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,OAAO,GAAG,mBAAmB,CAAC,mBAAmB,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACrH,UAAU,EAAE,CACV,IAAI,EACA,mBAAmB,CAAC,IAAI,GACxB,mBAAmB,CAAC,MAAM,GAC1B,mBAAmB,CAAC,SAAS,GAC7B,mBAAmB,CAAC,mBAAmB,EAC3C,KAAK,EAAE,KAAK,CAAC,cAAc,GAAG,KAAK,KAChC,IAAI,CAAC;CACX;AAED,MAAM,WAAW,WAAY,SAAQ,sBAAsB;IACzD,UAAU,EAAE,mBAAmB,CAAC,MAAM,CAAC;CACxC;AAED,wBAAgB,MAAM,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,WAAW,eAqCzE;AAED,MAAM,WAAW,aAAc,SAAQ,sBAAsB;IAC3D,KAAK,EAAE,aAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC/C,OAAO,EAAE,SAAS,GAAG,YAAY,GAAG,uBAAuB,GAAG,MAAM,CAAC;CACtE;AAED,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,aAAa,eA2B7F"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/side-navigation/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAMzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAOnD,UAAU,sBAAsB;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,OAAO,GAAG,mBAAmB,CAAC,mBAAmB,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACrH,UAAU,EAAE,CACV,IAAI,EACA,mBAAmB,CAAC,IAAI,GACxB,mBAAmB,CAAC,MAAM,GAC1B,mBAAmB,CAAC,SAAS,GAC7B,mBAAmB,CAAC,mBAAmB,EAC3C,KAAK,EAAE,KAAK,CAAC,cAAc,GAAG,KAAK,KAChC,IAAI,CAAC;CACX;AAED,MAAM,WAAW,WAAY,SAAQ,sBAAsB;IACzD,UAAU,EAAE,mBAAmB,CAAC,MAAM,CAAC;CACxC;AAED,wBAAgB,MAAM,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,WAAW,eAqCzE;AAED,MAAM,WAAW,aAAc,SAAQ,sBAAsB;IAC3D,KAAK,EAAE,aAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC/C,OAAO,EAAE,SAAS,GAAG,YAAY,GAAG,uBAAuB,GAAG,MAAM,CAAC;CACtE;AAED,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,aAAa,eA6B7F"}
@@ -32,11 +32,11 @@ export function Header(_a) {
32
32
  export function ItemList(_a) {
33
33
  var variant = _a.variant, items = _a.items, activeHref = _a.activeHref, fireChange = _a.fireChange, fireFollow = _a.fireFollow;
34
34
  return (React.createElement("ul", { className: clsx(styles.list, styles["list-variant-".concat(variant)]) }, items.map(function (item, i) { return (React.createElement("li", { key: i, className: styles['list-item'] },
35
- item.type === 'divider' && React.createElement(Divider, { variant: "default" }),
36
35
  item.type === 'link' && (React.createElement(Link, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow })),
37
36
  item.type === 'section' && (React.createElement(Section, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow })),
38
37
  item.type === 'link-group' && (React.createElement(LinkGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow })),
39
- item.type === 'expandable-link-group' && (React.createElement(ExpandableLinkGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow })))); })));
38
+ item.type === 'expandable-link-group' && (React.createElement(ExpandableLinkGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow })),
39
+ ((i === 0 && item.type === 'divider') || (items[i + 1] && items[i + 1].type === 'divider')) && (React.createElement(Divider, { variant: "default" })))); })));
40
40
  }
41
41
  function Divider(_a) {
42
42
  var _b = _a.variant, variant = _b === void 0 ? 'default' : _b;
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/side-navigation/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,yBAAyB,MAAM,gCAAgC,CAAC;AACvE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAG5C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAA4B,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,YA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,uBAAuB,CAAC,EAC1C,OAAO,EAAC,YAAY,EACpB,QAAQ,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,QAAQ,EAClC,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EACR,oBAAC,IAAI,IACH,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,EAC1E,QAAQ,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,QAAQ,EAClC,UAAU,EAAE,cAAc,EAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,GACtB;QAGJ,oBAAC,QAAQ,IACP,OAAO,EAAC,uBAAuB,EAC/B,KAAK,EAAE,UAAU,CAAC,KAAK,EACvB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,GACtB,CACwB,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useState, useEffect, useMemo } from 'react';\nimport clsx from 'clsx';\nimport { ExpandableSectionProps } from '../expandable-section/interfaces';\nimport InternalExpandableSection from '../expandable-section/internal';\nimport InternalIcon from '../icon/internal';\n\nimport { SideNavigationProps } from './interfaces';\nimport styles from './styles.css.js';\nimport { NonCancelableCustomEvent, isPlainLeftClick } from '../internal/events';\nimport useFocusVisible from '../internal/hooks/focus-visible';\nimport { hasActiveLink } from './util';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\n\ninterface BaseItemComponentProps {\n activeHref?: string;\n fireChange: (item: SideNavigationProps.Section | SideNavigationProps.ExpandableLinkGroup, expanded: boolean) => void;\n fireFollow: (\n item:\n | SideNavigationProps.Link\n | SideNavigationProps.Header\n | SideNavigationProps.LinkGroup\n | SideNavigationProps.ExpandableLinkGroup,\n event: React.SyntheticEvent | Event\n ) => void;\n}\n\nexport interface HeaderProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Header;\n}\n\nexport function Header({ definition, activeHref, fireFollow }: HeaderProps) {\n checkSafeUrl('SideNavigation', definition.href);\n const focusVisible = useFocusVisible();\n\n const onClick = useCallback(\n (event: React.MouseEvent) => {\n if (isPlainLeftClick(event)) {\n fireFollow(definition, event);\n }\n },\n [fireFollow, definition]\n );\n\n return (\n <>\n <div className={styles.header}>\n <a\n {...focusVisible}\n href={definition.href}\n className={clsx(styles['header-link'], { [styles['header-link--has-logo']]: !!definition.logo })}\n aria-current={definition.href === activeHref ? 'page' : undefined}\n onClick={onClick}\n >\n {definition.logo && (\n <img\n className={clsx(styles['header-logo'], {\n [styles['header-logo--stretched']]: !definition.text,\n })}\n {...definition.logo}\n />\n )}\n <span className={styles['header-link-text']}>{definition.text}</span>\n </a>\n </div>\n <Divider variant=\"header\" />\n </>\n );\n}\n\nexport interface ItemListProps extends BaseItemComponentProps {\n items: ReadonlyArray<SideNavigationProps.Item>;\n variant: 'section' | 'link-group' | 'expandable-link-group' | 'root';\n}\n\nexport function ItemList({ variant, items, activeHref, fireChange, fireFollow }: ItemListProps) {\n return (\n <ul className={clsx(styles.list, styles[`list-variant-${variant}`])}>\n {items.map((item, i) => (\n <li key={i} className={styles['list-item']}>\n {item.type === 'divider' && <Divider variant=\"default\" />}\n {item.type === 'link' && (\n <Link definition={item} activeHref={activeHref} fireChange={fireChange} fireFollow={fireFollow} />\n )}\n {item.type === 'section' && (\n <Section definition={item} activeHref={activeHref} fireChange={fireChange} fireFollow={fireFollow} />\n )}\n {item.type === 'link-group' && (\n <LinkGroup definition={item} activeHref={activeHref} fireChange={fireChange} fireFollow={fireFollow} />\n )}\n {item.type === 'expandable-link-group' && (\n <ExpandableLinkGroup\n definition={item}\n activeHref={activeHref}\n fireChange={fireChange}\n fireFollow={fireFollow}\n />\n )}\n </li>\n ))}\n </ul>\n );\n}\n\ninterface DividerProps {\n variant: 'default' | 'header';\n}\n\nfunction Divider({ variant = 'default' }: DividerProps) {\n return <hr className={clsx(styles.divider, styles[`divider-${variant}`])} />;\n}\n\ninterface LinkProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Link;\n expanded?: boolean;\n}\n\nfunction Link({ definition, expanded, activeHref, fireFollow }: LinkProps) {\n checkSafeUrl('SideNavigation', definition.href);\n const isActive = definition.href === activeHref;\n const focusVisible = useFocusVisible();\n\n const onClick = useCallback(\n (event: React.MouseEvent) => {\n // Prevent the click event from toggling outer expandable sections.\n event.stopPropagation();\n\n if (isPlainLeftClick(event)) {\n fireFollow(definition, event);\n }\n },\n [fireFollow, definition]\n );\n\n return (\n <>\n {/* https://github.com/yannickcr/eslint-plugin-react/issues/2962 */}\n {/* eslint-disable-next-line react/jsx-no-target-blank */}\n <a\n {...focusVisible}\n href={definition.href}\n className={clsx(styles.link, { [styles['link-active']]: isActive })}\n target={definition.external ? '_blank' : undefined}\n rel={definition.external ? 'noopener noreferrer' : undefined}\n aria-expanded={expanded}\n aria-current={definition.href === activeHref ? 'page' : undefined}\n onClick={onClick}\n >\n {definition.text}\n {definition.external && (\n <span\n aria-label={definition.externalIconAriaLabel}\n role={definition.externalIconAriaLabel ? 'img' : undefined}\n >\n <InternalIcon name=\"external\" className={styles['external-icon']} />\n </span>\n )}\n </a>\n {definition.info && <span className={styles.info}>{definition.info}</span>}\n </>\n );\n}\n\ninterface SectionProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Section;\n}\n\nfunction Section({ definition, activeHref, fireFollow, fireChange }: SectionProps) {\n const [expanded, setExpanded] = useState<boolean>(definition.defaultExpanded ?? true);\n\n const onExpandedChange = useCallback(\n (e: NonCancelableCustomEvent<ExpandableSectionProps.ChangeDetail>) => {\n fireChange(definition, e.detail.expanded);\n setExpanded(e.detail.expanded);\n },\n [definition, fireChange]\n );\n\n useEffect(() => {\n setExpanded(definition.defaultExpanded ?? true);\n }, [definition]);\n\n return (\n <InternalExpandableSection\n variant=\"footer\"\n expanded={expanded}\n onChange={onExpandedChange}\n className={styles.section}\n headerText={definition.text}\n >\n <ItemList\n variant=\"section\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </InternalExpandableSection>\n );\n}\n\ninterface LinkGroupProps extends BaseItemComponentProps {\n definition: SideNavigationProps.LinkGroup;\n}\n\nfunction LinkGroup({ definition, activeHref, fireFollow, fireChange }: LinkGroupProps) {\n checkSafeUrl('SideNavigation', definition.href);\n\n return (\n <>\n <Link\n definition={{ type: 'link', href: definition.href, text: definition.text }}\n fireFollow={(_, event) => fireFollow(definition, event)}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n <ItemList\n variant=\"link-group\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </>\n );\n}\n\ninterface ExpandableLinkGroupProps extends BaseItemComponentProps {\n definition: SideNavigationProps.ExpandableLinkGroup;\n}\n\nfunction ExpandableLinkGroup({ definition, fireFollow, fireChange, activeHref }: ExpandableLinkGroupProps) {\n // Check whether the definition contains an active link and memoize it to avoid\n // rechecking every time.\n const containsActiveLink = useMemo(() => {\n return activeHref ? hasActiveLink(definition.items, activeHref) : false;\n }, [activeHref, definition.items]);\n\n const [expanded, setExpanded] = useState<boolean>(() => {\n return definition.defaultExpanded ?? (definition.href === activeHref || containsActiveLink);\n });\n\n const [userExpanded, setUserExpanded] = useState<boolean | undefined>();\n\n // Reset user expansion status when the items property is updated.\n useEffect(() => setUserExpanded(undefined), [definition]);\n\n // By default, the expandable section is open when there's an active link inside.\n useEffect(() => {\n setExpanded(definition.href === activeHref || containsActiveLink);\n }, [definition.href, containsActiveLink, activeHref]);\n\n // If the definition object itself is updated, reset the expansion state to default.\n useEffect(() => {\n if (definition.defaultExpanded !== undefined) {\n setExpanded(definition.defaultExpanded);\n }\n }, [definition]);\n\n const onExpandedChange = useCallback(\n (e: NonCancelableCustomEvent<ExpandableSectionProps.ChangeDetail>) => {\n fireChange(definition, e.detail.expanded);\n setUserExpanded(e.detail.expanded);\n },\n [definition, fireChange]\n );\n\n const onHeaderFollow: LinkProps['fireFollow'] = (_, event) => {\n fireFollow(definition, event);\n setUserExpanded(true);\n if (!expanded) {\n fireChange(definition, true);\n }\n };\n\n return (\n <InternalExpandableSection\n className={styles['expandable-link-group']}\n variant=\"navigation\"\n expanded={userExpanded ?? expanded}\n onChange={onExpandedChange}\n headerText={\n <Link\n definition={{ type: 'link', href: definition.href, text: definition.text }}\n expanded={userExpanded ?? expanded}\n fireFollow={onHeaderFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n }\n >\n <ItemList\n variant=\"expandable-link-group\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </InternalExpandableSection>\n );\n}\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/side-navigation/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,yBAAyB,MAAM,gCAAgC,CAAC;AACvE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAG5C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAA4B,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAmBhE,MAAM,UAAU,MAAM,CAAC,EAAmD;;QAAjD,UAAU,gBAAA,EAAE,UAAU,gBAAA,EAAE,UAAU,gBAAA;IACzD,YAAY,CAAC,gBAAgB,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAChD,IAAM,YA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AAO,EAAC,YAAY,EACpB,QAAQ,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,QAAQ,EAClC,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EACR,oBAAC,IAAI,IACH,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,EAC1E,QAAQ,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,QAAQ,EAClC,UAAU,EAAE,cAAc,EAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,GACtB;QAGJ,oBAAC,QAAQ,IACP,OAAO,EAAC,uBAAuB,EAC/B,KAAK,EAAE,UAAU,CAAC,KAAK,EACvB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,GACtB,CACwB,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useState, useEffect, useMemo } from 'react';\nimport clsx from 'clsx';\nimport { ExpandableSectionProps } from '../expandable-section/interfaces';\nimport InternalExpandableSection from '../expandable-section/internal';\nimport InternalIcon from '../icon/internal';\n\nimport { SideNavigationProps } from './interfaces';\nimport styles from './styles.css.js';\nimport { NonCancelableCustomEvent, isPlainLeftClick } from '../internal/events';\nimport useFocusVisible from '../internal/hooks/focus-visible';\nimport { hasActiveLink } from './util';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\n\ninterface BaseItemComponentProps {\n activeHref?: string;\n fireChange: (item: SideNavigationProps.Section | SideNavigationProps.ExpandableLinkGroup, expanded: boolean) => void;\n fireFollow: (\n item:\n | SideNavigationProps.Link\n | SideNavigationProps.Header\n | SideNavigationProps.LinkGroup\n | SideNavigationProps.ExpandableLinkGroup,\n event: React.SyntheticEvent | Event\n ) => void;\n}\n\nexport interface HeaderProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Header;\n}\n\nexport function Header({ definition, activeHref, fireFollow }: HeaderProps) {\n checkSafeUrl('SideNavigation', definition.href);\n const focusVisible = useFocusVisible();\n\n const onClick = useCallback(\n (event: React.MouseEvent) => {\n if (isPlainLeftClick(event)) {\n fireFollow(definition, event);\n }\n },\n [fireFollow, definition]\n );\n\n return (\n <>\n <div className={styles.header}>\n <a\n {...focusVisible}\n href={definition.href}\n className={clsx(styles['header-link'], { [styles['header-link--has-logo']]: !!definition.logo })}\n aria-current={definition.href === activeHref ? 'page' : undefined}\n onClick={onClick}\n >\n {definition.logo && (\n <img\n className={clsx(styles['header-logo'], {\n [styles['header-logo--stretched']]: !definition.text,\n })}\n {...definition.logo}\n />\n )}\n <span className={styles['header-link-text']}>{definition.text}</span>\n </a>\n </div>\n <Divider variant=\"header\" />\n </>\n );\n}\n\nexport interface ItemListProps extends BaseItemComponentProps {\n items: ReadonlyArray<SideNavigationProps.Item>;\n variant: 'section' | 'link-group' | 'expandable-link-group' | 'root';\n}\n\nexport function ItemList({ variant, items, activeHref, fireChange, fireFollow }: ItemListProps) {\n return (\n <ul className={clsx(styles.list, styles[`list-variant-${variant}`])}>\n {items.map((item, i) => (\n <li key={i} className={styles['list-item']}>\n {item.type === 'link' && (\n <Link definition={item} activeHref={activeHref} fireChange={fireChange} fireFollow={fireFollow} />\n )}\n {item.type === 'section' && (\n <Section definition={item} activeHref={activeHref} fireChange={fireChange} fireFollow={fireFollow} />\n )}\n {item.type === 'link-group' && (\n <LinkGroup definition={item} activeHref={activeHref} fireChange={fireChange} fireFollow={fireFollow} />\n )}\n {item.type === 'expandable-link-group' && (\n <ExpandableLinkGroup\n definition={item}\n activeHref={activeHref}\n fireChange={fireChange}\n fireFollow={fireFollow}\n />\n )}\n {((i === 0 && item.type === 'divider') || (items[i + 1] && items[i + 1].type === 'divider')) && (\n <Divider variant=\"default\" />\n )}\n </li>\n ))}\n </ul>\n );\n}\n\ninterface DividerProps {\n variant: 'default' | 'header';\n}\n\nfunction Divider({ variant = 'default' }: DividerProps) {\n return <hr className={clsx(styles.divider, styles[`divider-${variant}`])} />;\n}\n\ninterface LinkProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Link;\n expanded?: boolean;\n}\n\nfunction Link({ definition, expanded, activeHref, fireFollow }: LinkProps) {\n checkSafeUrl('SideNavigation', definition.href);\n const isActive = definition.href === activeHref;\n const focusVisible = useFocusVisible();\n\n const onClick = useCallback(\n (event: React.MouseEvent) => {\n // Prevent the click event from toggling outer expandable sections.\n event.stopPropagation();\n\n if (isPlainLeftClick(event)) {\n fireFollow(definition, event);\n }\n },\n [fireFollow, definition]\n );\n\n return (\n <>\n {/* https://github.com/yannickcr/eslint-plugin-react/issues/2962 */}\n {/* eslint-disable-next-line react/jsx-no-target-blank */}\n <a\n {...focusVisible}\n href={definition.href}\n className={clsx(styles.link, { [styles['link-active']]: isActive })}\n target={definition.external ? '_blank' : undefined}\n rel={definition.external ? 'noopener noreferrer' : undefined}\n aria-expanded={expanded}\n aria-current={definition.href === activeHref ? 'page' : undefined}\n onClick={onClick}\n >\n {definition.text}\n {definition.external && (\n <span\n aria-label={definition.externalIconAriaLabel}\n role={definition.externalIconAriaLabel ? 'img' : undefined}\n >\n <InternalIcon name=\"external\" className={styles['external-icon']} />\n </span>\n )}\n </a>\n {definition.info && <span className={styles.info}>{definition.info}</span>}\n </>\n );\n}\n\ninterface SectionProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Section;\n}\n\nfunction Section({ definition, activeHref, fireFollow, fireChange }: SectionProps) {\n const [expanded, setExpanded] = useState<boolean>(definition.defaultExpanded ?? true);\n\n const onExpandedChange = useCallback(\n (e: NonCancelableCustomEvent<ExpandableSectionProps.ChangeDetail>) => {\n fireChange(definition, e.detail.expanded);\n setExpanded(e.detail.expanded);\n },\n [definition, fireChange]\n );\n\n useEffect(() => {\n setExpanded(definition.defaultExpanded ?? true);\n }, [definition]);\n\n return (\n <InternalExpandableSection\n variant=\"footer\"\n expanded={expanded}\n onChange={onExpandedChange}\n className={styles.section}\n headerText={definition.text}\n >\n <ItemList\n variant=\"section\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </InternalExpandableSection>\n );\n}\n\ninterface LinkGroupProps extends BaseItemComponentProps {\n definition: SideNavigationProps.LinkGroup;\n}\n\nfunction LinkGroup({ definition, activeHref, fireFollow, fireChange }: LinkGroupProps) {\n checkSafeUrl('SideNavigation', definition.href);\n\n return (\n <>\n <Link\n definition={{ type: 'link', href: definition.href, text: definition.text }}\n fireFollow={(_, event) => fireFollow(definition, event)}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n <ItemList\n variant=\"link-group\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </>\n );\n}\n\ninterface ExpandableLinkGroupProps extends BaseItemComponentProps {\n definition: SideNavigationProps.ExpandableLinkGroup;\n}\n\nfunction ExpandableLinkGroup({ definition, fireFollow, fireChange, activeHref }: ExpandableLinkGroupProps) {\n // Check whether the definition contains an active link and memoize it to avoid\n // rechecking every time.\n const containsActiveLink = useMemo(() => {\n return activeHref ? hasActiveLink(definition.items, activeHref) : false;\n }, [activeHref, definition.items]);\n\n const [expanded, setExpanded] = useState<boolean>(() => {\n return definition.defaultExpanded ?? (definition.href === activeHref || containsActiveLink);\n });\n\n const [userExpanded, setUserExpanded] = useState<boolean | undefined>();\n\n // Reset user expansion status when the items property is updated.\n useEffect(() => setUserExpanded(undefined), [definition]);\n\n // By default, the expandable section is open when there's an active link inside.\n useEffect(() => {\n setExpanded(definition.href === activeHref || containsActiveLink);\n }, [definition.href, containsActiveLink, activeHref]);\n\n // If the definition object itself is updated, reset the expansion state to default.\n useEffect(() => {\n if (definition.defaultExpanded !== undefined) {\n setExpanded(definition.defaultExpanded);\n }\n }, [definition]);\n\n const onExpandedChange = useCallback(\n (e: NonCancelableCustomEvent<ExpandableSectionProps.ChangeDetail>) => {\n fireChange(definition, e.detail.expanded);\n setUserExpanded(e.detail.expanded);\n },\n [definition, fireChange]\n );\n\n const onHeaderFollow: LinkProps['fireFollow'] = (_, event) => {\n fireFollow(definition, event);\n setUserExpanded(true);\n if (!expanded) {\n fireChange(definition, true);\n }\n };\n\n return (\n <InternalExpandableSection\n className={styles['expandable-link-group']}\n variant=\"navigation\"\n expanded={userExpanded ?? expanded}\n onChange={onExpandedChange}\n headerText={\n <Link\n definition={{ type: 'link', href: definition.href, text: definition.text }}\n expanded={userExpanded ?? expanded}\n fireFollow={onHeaderFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n }\n >\n <ItemList\n variant=\"expandable-link-group\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </InternalExpandableSection>\n );\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export declare function useClickAway(onClick: () => void): React.MutableRefObject<any>;
3
+ interface ClickAwayActive {
4
+ onClick: () => void;
5
+ children: React.ReactNode;
6
+ }
7
+ export declare function ClickAway({ onClick, children }: ClickAwayActive): JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=click-away.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"click-away.d.ts","sourceRoot":"","sources":["../../../../src/table/body-cell/click-away.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAIjD,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,IAAI,+BAgB/C;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AACD,wBAAgB,SAAS,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,eAAe,eAa/D"}