@cloudscape-design/components-themeable 3.0.1077 → 3.0.1078
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.
- package/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
- package/lib/internal/scss/split-panel/styles.scss +81 -16
- package/lib/internal/scss/split-panel/test-classes/styles.scss +4 -0
- package/lib/internal/template/app-layout/visual-refresh-toolbar/skeleton/multi-layout.d.ts.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh-toolbar/skeleton/multi-layout.js +19 -1
- package/lib/internal/template/app-layout/visual-refresh-toolbar/skeleton/multi-layout.js.map +1 -1
- package/lib/internal/template/flashbar/collapsible-flashbar.d.ts.map +1 -1
- package/lib/internal/template/flashbar/collapsible-flashbar.js +5 -3
- package/lib/internal/template/flashbar/collapsible-flashbar.js.map +1 -1
- package/lib/internal/template/flashbar/common.d.ts.map +1 -1
- package/lib/internal/template/flashbar/common.js +5 -2
- package/lib/internal/template/flashbar/common.js.map +1 -1
- package/lib/internal/template/flashbar/flash.d.ts +1 -1
- package/lib/internal/template/flashbar/flash.d.ts.map +1 -1
- package/lib/internal/template/flashbar/flash.js +2 -4
- package/lib/internal/template/flashbar/flash.js.map +1 -1
- package/lib/internal/template/flashbar/utils.d.ts +1 -1
- package/lib/internal/template/flashbar/utils.d.ts.map +1 -1
- package/lib/internal/template/flashbar/utils.js +1 -1
- package/lib/internal/template/flashbar/utils.js.map +1 -1
- package/lib/internal/template/internal/base-component/styles.scoped.css +1 -1
- package/lib/internal/template/internal/environment.js +2 -2
- package/lib/internal/template/internal/environment.json +2 -2
- package/lib/internal/template/split-panel/bottom.d.ts +2 -1
- package/lib/internal/template/split-panel/bottom.d.ts.map +1 -1
- package/lib/internal/template/split-panel/bottom.js +4 -3
- package/lib/internal/template/split-panel/bottom.js.map +1 -1
- package/lib/internal/template/split-panel/implementation.d.ts +1 -1
- package/lib/internal/template/split-panel/implementation.d.ts.map +1 -1
- package/lib/internal/template/split-panel/implementation.js +30 -11
- package/lib/internal/template/split-panel/implementation.js.map +1 -1
- package/lib/internal/template/split-panel/index.d.ts.map +1 -1
- package/lib/internal/template/split-panel/index.js +6 -0
- package/lib/internal/template/split-panel/index.js.map +1 -1
- package/lib/internal/template/split-panel/interfaces.d.ts +24 -3
- package/lib/internal/template/split-panel/interfaces.d.ts.map +1 -1
- package/lib/internal/template/split-panel/interfaces.js.map +1 -1
- package/lib/internal/template/split-panel/side.d.ts +1 -1
- package/lib/internal/template/split-panel/side.d.ts.map +1 -1
- package/lib/internal/template/split-panel/side.js +2 -2
- package/lib/internal/template/split-panel/side.js.map +1 -1
- package/lib/internal/template/split-panel/styles.css.js +38 -27
- package/lib/internal/template/split-panel/styles.scoped.css +93 -56
- package/lib/internal/template/split-panel/styles.selectors.js +38 -27
- package/lib/internal/template/split-panel/test-classes/styles.css.js +12 -8
- package/lib/internal/template/split-panel/test-classes/styles.scoped.css +12 -8
- package/lib/internal/template/split-panel/test-classes/styles.selectors.js +12 -8
- package/lib/internal/template/test-utils/dom/split-panel/index.d.ts +4 -0
- package/lib/internal/template/test-utils/dom/split-panel/index.js +12 -0
- package/lib/internal/template/test-utils/dom/split-panel/index.js.map +1 -1
- package/lib/internal/template/test-utils/selectors/split-panel/index.d.ts +4 -0
- package/lib/internal/template/test-utils/selectors/split-panel/index.js +12 -0
- package/lib/internal/template/test-utils/selectors/split-panel/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -21,11 +21,8 @@ $app-layout-drawer-width: calc(#{awsui.$space-layout-toggle-diameter} + 2 * #{aw
|
|
|
21
21
|
background-color: awsui.$color-background-layout-panel-content;
|
|
22
22
|
// should be above tools and navigation panels to avoid their shadows
|
|
23
23
|
z-index: 840;
|
|
24
|
-
&-closed {
|
|
25
|
-
|
|
26
|
-
&:not(.refresh) {
|
|
27
|
-
min-inline-size: constants.$sidebar-size-closed;
|
|
28
|
-
}
|
|
24
|
+
&-closed:not(.refresh) {
|
|
25
|
+
min-inline-size: constants.$sidebar-size-closed;
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
28
|
|
|
@@ -73,7 +70,8 @@ $app-layout-drawer-width: calc(#{awsui.$space-layout-toggle-diameter} + 2 * #{aw
|
|
|
73
70
|
&.drawer-closed {
|
|
74
71
|
overflow: hidden;
|
|
75
72
|
}
|
|
76
|
-
&.drawer-closed:hover {
|
|
73
|
+
&.drawer-closed.drawer-clickable:hover {
|
|
74
|
+
cursor: pointer;
|
|
77
75
|
background: awsui.$color-background-layout-panel-hover;
|
|
78
76
|
}
|
|
79
77
|
& > .drawer-content-bottom > [aria-hidden='true'] {
|
|
@@ -229,11 +227,8 @@ $app-layout-drawer-width: calc(#{awsui.$space-layout-toggle-diameter} + 2 * #{aw
|
|
|
229
227
|
}
|
|
230
228
|
|
|
231
229
|
.header {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
flex-direction: row;
|
|
235
|
-
align-items: flex-start;
|
|
236
|
-
justify-content: space-between;
|
|
230
|
+
$vertical-margin: calc(#{awsui.$space-scaled-xxs} + 1px);
|
|
231
|
+
|
|
237
232
|
inline-size: 100%;
|
|
238
233
|
margin-block: awsui.$size-vertical-panel-icon-offset;
|
|
239
234
|
margin-inline: 0;
|
|
@@ -241,17 +236,87 @@ $app-layout-drawer-width: calc(#{awsui.$space-layout-toggle-diameter} + 2 * #{aw
|
|
|
241
236
|
margin-block: constants.$toolbar-vertical-panel-icon-offset;
|
|
242
237
|
}
|
|
243
238
|
|
|
239
|
+
&-main-row,
|
|
240
|
+
&-main-content {
|
|
241
|
+
display: flex;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Area containing the before-header slot, the header text, the info link, the actions slot
|
|
245
|
+
// and the built-in panel buttons.
|
|
246
|
+
&-main-row {
|
|
247
|
+
// Make sure that the panel buttons are always anchored to the block start,
|
|
248
|
+
// even if the main content (before-header slot, header text, actions) wraps into multiple lines.
|
|
249
|
+
align-items: flex-start;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Area containing the before-header slot, the header text, the info link and the actions slot
|
|
253
|
+
// --not the description nor the built-in panel buttons.
|
|
254
|
+
&-main-content {
|
|
255
|
+
flex: auto;
|
|
256
|
+
flex-direction: row;
|
|
257
|
+
column-gap: awsui.$space-scaled-xs;
|
|
258
|
+
row-gap: awsui.$space-scaled-xxs;
|
|
259
|
+
justify-content: space-between;
|
|
260
|
+
// Keep the actions slot always at the block start,
|
|
261
|
+
// even if the heading and the info slot wrap into multiple lines.
|
|
262
|
+
align-items: flex-start;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Header tag and info link
|
|
266
|
+
&-tag-and-info {
|
|
267
|
+
flex-grow: 1;
|
|
268
|
+
margin-block-start: $vertical-margin;
|
|
269
|
+
// The line height of the header text might not be respected in non-high pixel density screens
|
|
270
|
+
// unless it is set to a smaller value in its parent container.
|
|
271
|
+
line-height: awsui.$line-height-body-s;
|
|
272
|
+
&.with-description {
|
|
273
|
+
margin-block-end: awsui.$space-scaled-xxxs;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
&-tag.with-info,
|
|
278
|
+
&-text {
|
|
279
|
+
display: inline;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// The h2 tag, which contains the elements in the `headerBefore` slot, if defined, and the header text
|
|
283
|
+
&-tag {
|
|
284
|
+
margin-block: 0;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
&-before-slot,
|
|
244
288
|
&-text {
|
|
245
289
|
@include styles.font-panel-header;
|
|
246
|
-
|
|
247
|
-
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
&-before-slot {
|
|
293
|
+
margin-block-start: calc(-1 * #{$vertical-margin});
|
|
294
|
+
.header-tag.with-info > &,
|
|
295
|
+
&.with-header-text {
|
|
296
|
+
display: inline-block;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
&-before-slot.with-header-text,
|
|
301
|
+
&-tag.with-info {
|
|
302
|
+
margin-inline-end: awsui.$space-scaled-xs;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
&-actions-slot {
|
|
306
|
+
display: flex;
|
|
307
|
+
flex-shrink: 0;
|
|
308
|
+
align-items: center;
|
|
309
|
+
min-block-size: calc(#{awsui.$font-panel-header-line-height} + 2 * #{$vertical-margin});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
&-description {
|
|
313
|
+
color: awsui.$color-text-heading-secondary;
|
|
314
|
+
@include styles.font-body-m;
|
|
248
315
|
margin-block: 0;
|
|
249
|
-
margin-inline: 0;
|
|
250
|
-
margin-block-start: calc(#{awsui.$space-scaled-xxs} + 1px);
|
|
251
316
|
}
|
|
252
317
|
}
|
|
253
318
|
|
|
254
|
-
.header-
|
|
319
|
+
.header-buttons {
|
|
255
320
|
display: flex;
|
|
256
321
|
flex-direction: row;
|
|
257
322
|
justify-content: space-between;
|
package/lib/internal/template/app-layout/visual-refresh-toolbar/skeleton/multi-layout.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-layout.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/skeleton/multi-layout.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"multi-layout.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/skeleton/multi-layout.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,KAAK,CAAC;AAE9E,wBAAgB,iBAAiB,CAC/B,sBAAsB,EAAE,iBAAiB,EACzC,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,WAAW,EAClB,UAAU,EAAE,UAAU,GACrB;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAAA;CAAE,CA8C5D"}
|
|
@@ -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
|
-
import { useLayoutEffect, useState } from 'react';
|
|
3
|
+
import { useEffect, useLayoutEffect, useState } from 'react';
|
|
4
|
+
import { metrics } from '../../../internal/metrics';
|
|
4
5
|
import { awsuiPluginsInternal } from '../../../internal/plugins/api';
|
|
5
6
|
import { useAppLayoutFlagEnabled } from '../../utils/feature-flags';
|
|
6
7
|
export function useMultiAppLayout(forceDeduplicationType, isEnabled, props, mergeProps) {
|
|
@@ -25,6 +26,11 @@ export function useMultiAppLayout(forceDeduplicationType, isEnabled, props, merg
|
|
|
25
26
|
registration.update(props);
|
|
26
27
|
}
|
|
27
28
|
});
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (registration) {
|
|
31
|
+
reportMultiLayoutMetric(registration);
|
|
32
|
+
}
|
|
33
|
+
}, [registration]);
|
|
28
34
|
if (!isToolbar) {
|
|
29
35
|
return {
|
|
30
36
|
registered: true,
|
|
@@ -38,4 +44,16 @@ export function useMultiAppLayout(forceDeduplicationType, isEnabled, props, merg
|
|
|
38
44
|
toolbarProps: (registration === null || registration === void 0 ? void 0 : registration.type) === 'primary' ? mergeProps(props, registration.discoveredProps) : null,
|
|
39
45
|
};
|
|
40
46
|
}
|
|
47
|
+
function reportMultiLayoutMetric(registration) {
|
|
48
|
+
if (registration.type === 'primary' && registration.discoveredProps.length > 0) {
|
|
49
|
+
metrics.sendOpsMetricObject('awsui-multi-layout-usage-primary', {
|
|
50
|
+
// temporary workaround for missing typings
|
|
51
|
+
// https://github.com/cloudscape-design/component-toolkit/pull/153
|
|
52
|
+
instancesCount: registration.discoveredProps.length,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else if (registration.type === 'suspended') {
|
|
56
|
+
metrics.sendOpsMetricObject('awsui-multi-layout-usage-suspended', {});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
41
59
|
//# sourceMappingURL=multi-layout.js.map
|
package/lib/internal/template/app-layout/visual-refresh-toolbar/skeleton/multi-layout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-layout.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/skeleton/multi-layout.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"multi-layout.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh-toolbar/skeleton/multi-layout.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAMpE,MAAM,UAAU,iBAAiB,CAC/B,sBAAyC,EACzC,SAAkB,EAClB,KAAkB,EAClB,UAAsB;IAEtB,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAwC,IAAI,CAAC,CAAC;IAC9F,MAAM,SAAS,GAAG,uBAAuB,EAAE,CAAC;IAE5C,eAAe,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,SAAS,IAAI,sBAAsB,KAAK,WAAW,IAAI,CAAC,SAAS,EAAE;YACtE,OAAO;SACR;QACD,IAAI,sBAAsB,KAAK,KAAK,EAAE;YACpC,eAAe,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC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I,YAAY,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE;QAC9E,OAAO,CAAC,mBAAmB,CAAC,kCAAkC,EAAE;YAC9D,2CAA2C;YAC3C,kEAAkE;YAClE,cAAc,EAAE,YAAY,CAAC,eAAe,CAAC,MAAa;SAC3D,CAAC,CAAC;KACJ;SAAM,IAAI,YAAY,CAAC,IAAI,KAAK,WAAW,EAAE;QAC5C,OAAO,CAAC,mBAAmB,CAAC,oCAAoC,EAAE,EAAE,CAAC,CAAC;KACvE;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useEffect, useLayoutEffect, useState } from 'react';\n\nimport { metrics } from '../../../internal/metrics';\nimport { awsuiPluginsInternal } from '../../../internal/plugins/api';\nimport { RegistrationState } from '../../../internal/plugins/controllers/app-layout-widget';\nimport { useAppLayoutFlagEnabled } from '../../utils/feature-flags';\nimport { MergeProps, SharedProps } from '../state/interfaces';\nimport { ToolbarProps } from '../toolbar';\n\nexport type DeduplicationType = 'primary' | 'secondary' | 'suspended' | 'off';\n\nexport function useMultiAppLayout(\n forceDeduplicationType: DeduplicationType,\n isEnabled: boolean,\n props: SharedProps,\n mergeProps: MergeProps\n): { registered: boolean; toolbarProps: ToolbarProps | null } {\n const [registration, setRegistration] = useState<RegistrationState<SharedProps> | null>(null);\n const isToolbar = useAppLayoutFlagEnabled();\n\n useLayoutEffect(() => {\n if (!isEnabled || forceDeduplicationType === 'suspended' || !isToolbar) {\n return;\n }\n if (forceDeduplicationType === 'off') {\n setRegistration({ type: 'primary', discoveredProps: [] });\n return;\n }\n const unregister = awsuiPluginsInternal.appLayoutWidget.register(forceDeduplicationType, props =>\n setRegistration(props as RegistrationState<SharedProps>)\n );\n return () => {\n unregister();\n setRegistration({ type: 'suspended' });\n };\n }, [forceDeduplicationType, isEnabled, isToolbar]);\n\n useLayoutEffect(() => {\n if (registration?.type === 'secondary') {\n registration.update(props);\n }\n });\n\n useEffect(() => {\n if (registration) {\n reportMultiLayoutMetric(registration);\n }\n }, [registration]);\n\n if (!isToolbar) {\n return {\n registered: true,\n // mergeProps is needed here because the toolbar's behavior depends on reconciliation logic\n // in this function. For example, navigation trigger visibility\n toolbarProps: mergeProps(props, []),\n };\n }\n\n return {\n registered: !!registration?.type,\n toolbarProps: registration?.type === 'primary' ? mergeProps(props, registration.discoveredProps) : null,\n };\n}\n\nfunction reportMultiLayoutMetric(registration: RegistrationState<SharedProps>) {\n if (registration.type === 'primary' && registration.discoveredProps.length > 0) {\n metrics.sendOpsMetricObject('awsui-multi-layout-usage-primary', {\n // temporary workaround for missing typings\n // https://github.com/cloudscape-design/component-toolkit/pull/153\n instancesCount: registration.discoveredProps.length as any,\n });\n } else if (registration.type === 'suspended') {\n metrics.sendOpsMetricObject('awsui-multi-layout-usage-suspended', {});\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collapsible-flashbar.d.ts","sourceRoot":"","sources":["../../../src/flashbar/collapsible-flashbar.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"collapsible-flashbar.d.ts","sourceRoot":"","sources":["../../../src/flashbar/collapsible-flashbar.tsx"],"names":[],"mappings":";AA4BA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAmB7C,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,EAAE,aAAa,eAqVxF"}
|
|
@@ -13,6 +13,7 @@ import { animate, getDOMRects } from '../internal/animate';
|
|
|
13
13
|
import { Transition } from '../internal/components/transition';
|
|
14
14
|
import { getVisualContextClassname } from '../internal/components/visual-context';
|
|
15
15
|
import customCssProps from '../internal/generated/custom-css-properties';
|
|
16
|
+
import { useDebounceCallback } from '../internal/hooks/use-debounce-callback';
|
|
16
17
|
import { useEffectOnUpdate } from '../internal/hooks/use-effect-on-update';
|
|
17
18
|
import { scrollElementIntoView } from '../internal/utils/scrollable-containers';
|
|
18
19
|
import { throttle } from '../internal/utils/throttle';
|
|
@@ -20,7 +21,7 @@ import { getComponentsAnalyticsMetadata, getItemAnalyticsMetadata } from './anal
|
|
|
20
21
|
import { useFlashbar } from './common';
|
|
21
22
|
import { Flash, focusFlashById } from './flash';
|
|
22
23
|
import { getCollapsibleFlashStyles, getNotificationBarStyles } from './style';
|
|
23
|
-
import { counterTypes, getFlashTypeCount, getItemColor, getVisibleCollapsedItems } from './utils';
|
|
24
|
+
import { counterTypes, FOCUS_DEBOUNCE_DELAY, getFlashTypeCount, getItemColor, getVisibleCollapsedItems, } from './utils';
|
|
24
25
|
import styles from './styles.css.js';
|
|
25
26
|
// If the number of items is equal or less than this value,
|
|
26
27
|
// the toggle element will not be displayed and the Flashbar will look like a regular single-item Flashbar.
|
|
@@ -69,16 +70,17 @@ export default function CollapsibleFlashbar(_a) {
|
|
|
69
70
|
}
|
|
70
71
|
setIsFlashbarStackExpanded(prev => !prev);
|
|
71
72
|
}
|
|
73
|
+
const debouncedFocus = useDebounceCallback(focusFlashById, FOCUS_DEBOUNCE_DELAY);
|
|
72
74
|
useLayoutEffect(() => {
|
|
73
75
|
if (isFlashbarStackExpanded && (items === null || items === void 0 ? void 0 : items.length)) {
|
|
74
76
|
const mostRecentItem = items[0];
|
|
75
77
|
if (mostRecentItem.id !== undefined) {
|
|
76
|
-
|
|
78
|
+
debouncedFocus(ref.current, mostRecentItem.id);
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
// Run this after expanding, but not every time the items change.
|
|
80
82
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
81
|
-
}, [isFlashbarStackExpanded]);
|
|
83
|
+
}, [debouncedFocus, isFlashbarStackExpanded]);
|
|
82
84
|
// When collapsing, scroll up if necessary to avoid losing track of the focused button
|
|
83
85
|
useEffectOnUpdate(() => {
|
|
84
86
|
if (!isFlashbarStackExpanded && notificationBarRef.current) {
|
|
@@ -1 +1 @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reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { ReactNode, useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { TransitionGroup } from 'react-transition-group';\nimport clsx from 'clsx';\n\nimport { findUpUntil } from '@cloudscape-design/component-toolkit/dom';\nimport { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { IconProps } from '../icon/interfaces';\nimport InternalIcon from '../icon/internal';\nimport { animate, getDOMRects } from '../internal/animate';\nimport { Transition } from '../internal/components/transition';\nimport { getVisualContextClassname } from '../internal/components/visual-context';\nimport customCssProps from '../internal/generated/custom-css-properties';\nimport { useEffectOnUpdate } from '../internal/hooks/use-effect-on-update';\nimport { scrollElementIntoView } from '../internal/utils/scrollable-containers';\nimport { throttle } from '../internal/utils/throttle';\nimport {\n GeneratedAnalyticsMetadataFlashbarCollapse,\n GeneratedAnalyticsMetadataFlashbarExpand,\n} from './analytics-metadata/interfaces';\nimport { getComponentsAnalyticsMetadata, getItemAnalyticsMetadata } from './analytics-metadata/utils';\nimport { useFlashbar } from './common';\nimport { Flash, focusFlashById } from './flash';\nimport { FlashbarProps } from './interfaces';\nimport { getCollapsibleFlashStyles, getNotificationBarStyles } from './style';\nimport { counterTypes, getFlashTypeCount, getItemColor, getVisibleCollapsedItems, StackableItem } from './utils';\n\nimport styles from './styles.css.js';\n\n// If the number of items is equal or less than this value,\n// the toggle element will not be displayed and the Flashbar will look like a regular single-item Flashbar.\nconst maxNonCollapsibleItems = 1;\n\nconst resizeListenerThrottleDelay = 100;\n\nexport default function CollapsibleFlashbar({ items, style, ...restProps }: FlashbarProps) {\n const [enteringItems, setEnteringItems] = useState<ReadonlyArray<FlashbarProps.MessageDefinition>>([]);\n const [exitingItems, setExitingItems] = useState<ReadonlyArray<FlashbarProps.MessageDefinition>>([]);\n const [isFlashbarStackExpanded, setIsFlashbarStackExpanded] = useState(false);\n\n const getElementsToAnimate = useCallback(() => {\n const flashElements = isFlashbarStackExpanded ? expandedItemRefs.current : collapsedItemRefs.current;\n return { ...flashElements, notificationBar: notificationBarRef.current };\n }, [isFlashbarStackExpanded]);\n\n const prepareAnimations = useCallback(() => {\n const rects = getDOMRects(getElementsToAnimate());\n setInitialAnimationState(rects);\n }, [getElementsToAnimate]);\n\n const collapsedItemRefs = useRef<Record<string, HTMLElement | null>>({});\n const expandedItemRefs = useRef<Record<string, HTMLElement | null>>({});\n const [initialAnimationState, setInitialAnimationState] = useState<Record<string, DOMRect> | null>(null);\n const listElementRef = useRef<HTMLUListElement | null>(null);\n const notificationBarRef = useRef<HTMLDivElement | null>(null);\n const [transitioning, setTransitioning] = useState(false);\n const flashbarElementId = useUniqueId('flashbar');\n const itemCountElementId = useUniqueId('item-count');\n\n const { baseProps, isReducedMotion, isVisualRefresh, mergedRef, ref, flashRefs, handleFlashDismissed } = useFlashbar({\n items,\n ...restProps,\n onItemsAdded: newItems => {\n setEnteringItems([...enteringItems, ...newItems]);\n },\n onItemsChanged: options => {\n // If not all items have ID, we can still animate collapse/expand transitions\n // because we can rely on each item's index in the original array,\n // but we can't do that when elements are added or removed, since the index changes.\n if (options?.allItemsHaveId && !options?.isReducedMotion) {\n prepareAnimations();\n }\n },\n onItemsRemoved: removedItems => {\n setExitingItems([...exitingItems, ...removedItems]);\n },\n });\n\n if (items.length <= maxNonCollapsibleItems && isFlashbarStackExpanded) {\n setIsFlashbarStackExpanded(false);\n }\n\n const animateFlash = !isReducedMotion;\n\n function toggleCollapseExpand() {\n if (!isReducedMotion) {\n prepareAnimations();\n }\n setIsFlashbarStackExpanded(prev => !prev);\n }\n\n useLayoutEffect(() => {\n if (isFlashbarStackExpanded && items?.length) {\n const mostRecentItem = items[0];\n if (mostRecentItem.id !== undefined) {\n focusFlashById(ref.current, mostRecentItem.id);\n }\n }\n // Run this after expanding, but not every time the items change.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isFlashbarStackExpanded]);\n\n // When collapsing, scroll up if necessary to avoid losing track of the focused button\n useEffectOnUpdate(() => {\n if (!isFlashbarStackExpanded && notificationBarRef.current) {\n scrollElementIntoView(notificationBarRef.current);\n }\n }, [isFlashbarStackExpanded]);\n\n const updateBottomSpacing = useMemo(\n () =>\n throttle(() => {\n // Allow vertical space between Flashbar and page bottom only when the Flashbar is reaching the end of the page,\n // otherwise avoid spacing with eventual sticky elements below.\n const listElement = listElementRef?.current;\n const flashbar = listElement?.parentElement;\n if (listElement && flashbar) {\n // Make sure the bottom padding is present when we make the calculations,\n // then we might decide to remove it or not.\n flashbar.classList.remove(styles.floating);\n const windowHeight = window.innerHeight;\n // Take the parent region into account if using the App Layout, because it might have additional margins.\n // Otherwise we use the Flashbar component for this calculation.\n const outerElement = findUpUntil(flashbar, element => element.getAttribute('role') === 'region') || flashbar;\n const applySpacing =\n isFlashbarStackExpanded && Math.ceil(outerElement.getBoundingClientRect().bottom) >= windowHeight;\n if (!applySpacing) {\n flashbar.classList.add(styles.floating);\n }\n }\n }, resizeListenerThrottleDelay),\n [isFlashbarStackExpanded]\n );\n\n useLayoutEffect(() => {\n window.addEventListener('resize', updateBottomSpacing);\n return () => {\n window.removeEventListener('resize', updateBottomSpacing);\n updateBottomSpacing.cancel();\n };\n }, [updateBottomSpacing]);\n\n const { i18nStrings } = restProps;\n\n const i18n = useInternalI18n('flashbar');\n const ariaLabel = i18n('i18nStrings.ariaLabel', i18nStrings?.ariaLabel);\n const notificationBarText = i18n('i18nStrings.notificationBarText', i18nStrings?.notificationBarText);\n const notificationBarAriaLabel = i18n('i18nStrings.notificationBarAriaLabel', i18nStrings?.notificationBarAriaLabel);\n const iconAriaLabels = {\n errorIconAriaLabel: i18n('i18nStrings.errorIconAriaLabel', i18nStrings?.errorIconAriaLabel),\n inProgressIconAriaLabel: i18n('i18nStrings.inProgressIconAriaLabel', i18nStrings?.inProgressIconAriaLabel),\n infoIconAriaLabel: i18n('i18nStrings.infoIconAriaLabel', i18nStrings?.infoIconAriaLabel),\n successIconAriaLabel: i18n('i18nStrings.successIconAriaLabel', i18nStrings?.successIconAriaLabel),\n warningIconAriaLabel: i18n('i18nStrings.warningIconAriaLabel', i18nStrings?.warningIconAriaLabel),\n };\n\n useLayoutEffect(() => {\n // When `useLayoutEffect` is called, the DOM is updated but has not been painted yet,\n // so it's a good moment to trigger animations that will make calculations based on old and new DOM state.\n // The old state is kept in `initialAnimationState`\n // and the new state can be retrieved from the current DOM elements.\n\n if (initialAnimationState) {\n updateBottomSpacing();\n\n animate({\n elements: getElementsToAnimate(),\n oldState: initialAnimationState,\n newElementInitialState: ({ top }) => ({ scale: 0.9, y: -0.2 * top }),\n onTransitionsEnd: () => setTransitioning(false),\n });\n\n setTransitioning(true);\n setInitialAnimationState(null);\n }\n }, [updateBottomSpacing, getElementsToAnimate, initialAnimationState, isFlashbarStackExpanded]);\n\n const isCollapsible = items.length > maxNonCollapsibleItems;\n\n const countByType = getFlashTypeCount(items);\n\n const numberOfColorsInStack = new Set(items.map(getItemColor)).size;\n const maxSlots = Math.max(numberOfColorsInStack, 3);\n const stackDepth = Math.min(maxSlots, items.length);\n\n const itemsToShow = isFlashbarStackExpanded\n ? items.map((item, index) => ({ ...item, expandedIndex: index }))\n : getVisibleCollapsedItems(items, stackDepth).map((item: StackableItem, index: number) => ({\n ...item,\n collapsedIndex: index,\n }));\n\n const getItemId = (item: StackableItem | FlashbarProps.MessageDefinition) =>\n item.id ?? (item as StackableItem).expandedIndex ?? 0;\n\n // This check allows us to use the standard \"enter\" Transition only when the notification was not existing before.\n // If instead it was moved to the top of the stack but was already present in the array\n // (e.g, after dismissing another notification),\n // we need to use different, more custom and more controlled animations.\n const hasEntered = (item: StackableItem | FlashbarProps.MessageDefinition) =>\n enteringItems.some(_item => _item.id && _item.id === item.id);\n const hasLeft = (item: StackableItem | FlashbarProps.MessageDefinition) => !('expandedIndex' in item);\n const hasEnteredOrLeft = (item: StackableItem | FlashbarProps.MessageDefinition) => hasEntered(item) || hasLeft(item);\n\n const showInnerContent = (item: StackableItem | FlashbarProps.MessageDefinition) =>\n isFlashbarStackExpanded || hasLeft(item) || ('expandedIndex' in item && item.expandedIndex === 0);\n\n const shouldUseStandardAnimation = (item: StackableItem, index: number) => index === 0 && hasEnteredOrLeft(item);\n\n const getAnimationElementId = (item: StackableItem) => `flash-${getItemId(item)}`;\n\n const renderList = () => (\n <ul\n ref={listElementRef}\n className={clsx(\n styles['flash-list'],\n isFlashbarStackExpanded ? styles.expanded : styles.collapsed,\n transitioning && styles['animation-running'],\n initialAnimationState && styles['animation-ready'],\n isVisualRefresh && styles['visual-refresh']\n )}\n id={flashbarElementId}\n aria-label={ariaLabel}\n aria-describedby={isCollapsible ? itemCountElementId : undefined}\n style={\n !isFlashbarStackExpanded || transitioning\n ? {\n [customCssProps.flashbarStackDepth]: stackDepth,\n }\n : undefined\n }\n >\n <ListWrapper withMotion={!isReducedMotion}>\n {itemsToShow.map((item: StackableItem, index: number) => (\n <Transition\n key={getItemId(item)}\n in={!hasLeft(item)}\n onStatusChange={status => {\n if (status === 'entered') {\n setEnteringItems([]);\n } else if (status === 'exited') {\n setExitingItems([]);\n }\n }}\n >\n {(state: string, transitionRootElement: React.Ref<HTMLDivElement> | undefined) => (\n <li\n aria-hidden={!showInnerContent(item)}\n className={\n showInnerContent(item)\n ? clsx(\n styles['flash-list-item'],\n !isFlashbarStackExpanded && styles.item,\n !collapsedItemRefs.current[getAnimationElementId(item)] && styles['expanded-only']\n )\n : clsx(styles.flash, styles[`flash-type-${item.type ?? 'info'}`], styles.item)\n }\n ref={element => {\n if (isFlashbarStackExpanded) {\n expandedItemRefs.current[getAnimationElementId(item)] = element;\n } else {\n collapsedItemRefs.current[getAnimationElementId(item)] = element;\n }\n }}\n style={{\n ...(index > 0 && !isFlashbarStackExpanded && getCollapsibleFlashStyles(style, item.type)),\n ...((!isFlashbarStackExpanded || transitioning) && {\n [customCssProps.flashbarStackIndex]:\n (item as StackableItem).collapsedIndex ?? (item as StackableItem).expandedIndex ?? index,\n }),\n }}\n key={getItemId(item)}\n {...getAnalyticsMetadataAttribute(getItemAnalyticsMetadata(index + 1, item.type || 'info', item.id))}\n >\n {showInnerContent(item) && (\n <Flash\n className={clsx(\n animateFlash && styles['flash-with-motion'],\n isVisualRefresh && styles['flash-refresh']\n )}\n key={getItemId(item)}\n ref={(el: HTMLDivElement | null) => {\n // Store the Flash element reference for focus management\n flashRefs.current[getItemId(item)] = el;\n\n if (shouldUseStandardAnimation(item, index) && transitionRootElement) {\n if (typeof transitionRootElement === 'function') {\n transitionRootElement(el);\n } else if (\n transitionRootElement &&\n typeof transitionRootElement === 'object' &&\n 'current' in transitionRootElement\n ) {\n (transitionRootElement as React.MutableRefObject<HTMLDivElement | null>).current = el;\n }\n }\n }}\n transitionState={shouldUseStandardAnimation(item, index) ? state : undefined}\n i18nStrings={iconAriaLabels}\n style={style}\n onDismissed={handleFlashDismissed}\n {...item}\n />\n )}\n </li>\n )}\n </Transition>\n ))}\n </ListWrapper>\n </ul>\n );\n\n return (\n <div\n {...baseProps}\n className={clsx(\n baseProps.className,\n styles.flashbar,\n styles.stack,\n isCollapsible && styles.collapsible,\n items.length === 2 && styles['short-list'],\n isFlashbarStackExpanded && styles.expanded,\n isVisualRefresh && styles['visual-refresh']\n )}\n ref={mergedRef}\n {...getAnalyticsMetadataAttribute(getComponentsAnalyticsMetadata(items.length, true, isFlashbarStackExpanded))}\n >\n {isFlashbarStackExpanded && renderList()}\n {isCollapsible && (\n <div\n className={clsx(\n styles['notification-bar'],\n isVisualRefresh && styles['visual-refresh'],\n isFlashbarStackExpanded ? styles.expanded : styles.collapsed,\n transitioning && styles['animation-running'],\n items.length === 2 && styles['short-list'],\n getVisualContextClassname('flashbar') // Visual context is needed for focus ring to be white\n )}\n onClick={toggleCollapseExpand}\n ref={notificationBarRef}\n style={getNotificationBarStyles(style)}\n {...getAnalyticsMetadataAttribute({\n action: !isFlashbarStackExpanded ? 'expand' : 'collapse',\n detail: {\n label: 'h2',\n },\n } as GeneratedAnalyticsMetadataFlashbarExpand | GeneratedAnalyticsMetadataFlashbarCollapse)}\n >\n <span aria-live=\"polite\" className={styles.status} role=\"status\" id={itemCountElementId}>\n {notificationBarText && <h2 className={styles.header}>{notificationBarText}</h2>}\n <span className={styles['item-count']}>\n {counterTypes.map(({ type, labelName, iconName }) => (\n <NotificationTypeCount\n key={type}\n iconName={iconName}\n label={iconAriaLabels[labelName]}\n count={countByType[type]}\n />\n ))}\n </span>\n </span>\n <button\n aria-controls={flashbarElementId}\n aria-describedby={itemCountElementId}\n aria-expanded={isFlashbarStackExpanded}\n aria-label={notificationBarAriaLabel}\n className={clsx(styles.button, isFlashbarStackExpanded && styles.expanded)}\n >\n <InternalIcon className={styles.icon} size=\"normal\" name=\"angle-down\" />\n </button>\n </div>\n )}\n {!isFlashbarStackExpanded && renderList()}\n </div>\n );\n}\n\nconst NotificationTypeCount = ({\n iconName,\n label,\n count,\n}: {\n iconName: IconProps.Name;\n label?: string;\n count: number;\n}) => {\n return (\n <span className={styles['type-count']}>\n <span title={label}>\n <InternalIcon name={iconName} ariaLabel={label} />\n </span>\n <span className={styles['count-number']}>{count}</span>\n </span>\n );\n};\n\nconst ListWrapper = ({ children, withMotion }: { children: ReactNode; withMotion: boolean }) =>\n withMotion ? <TransitionGroup component={null}>{children}</TransitionGroup> : <>{children}</>;\n"]}
|
|
1
|
+
{"version":3,"file":"collapsible-flashbar.js","sourceRoot":"","sources":["../../../src/flashbar/collapsible-flashbar.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAa,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C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CAAC,IAAI,CAAC,GACxB,CACH,CAAC,CACG,CACF;YACP,iDACiB,iBAAiB,sBACd,kBAAkB,mBACrB,uBAAuB,gBAC1B,wBAAwB,EACpC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAuB,IAAI,MAAM,CAAC,QAAQ,CAAC;gBAE1E,oBAAC,YAAY,IAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,YAAY,GAAG,CACjE,CACL,CACP;QACA,CAAC,uBAAuB,IAAI,UAAU,EAAE,CACrC,CACP,CAAC;AACJ,CAAC;AAED,MAAM,qBAAqB,GAAG,CAAC,EAC7B,QAAQ,EACR,KAAK,EACL,KAAK,GAKN,EAAE,EAAE;IACH,OAAO,CACL,8BAAM,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC;QACnC,8BAAM,KAAK,EAAE,KAAK;YAChB,oBAAC,YAAY,IAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,GAAI,CAC7C;QACP,8BAAM,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC,IAAG,KAAK,CAAQ,CAClD,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAgD,EAAE,EAAE,CAC7F,UAAU,CAAC,CAAC,CAAC,oBAAC,eAAe,IAAC,SAAS,EAAE,IAAI,IAAG,QAAQ,CAAmB,CAAC,CAAC,CAAC,0CAAG,QAAQ,CAAI,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { ReactNode, useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { TransitionGroup } from 'react-transition-group';\nimport clsx from 'clsx';\n\nimport { findUpUntil } from '@cloudscape-design/component-toolkit/dom';\nimport { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { IconProps } from '../icon/interfaces';\nimport InternalIcon from '../icon/internal';\nimport { animate, getDOMRects } from '../internal/animate';\nimport { Transition } from '../internal/components/transition';\nimport { getVisualContextClassname } from '../internal/components/visual-context';\nimport customCssProps from '../internal/generated/custom-css-properties';\nimport { useDebounceCallback } from '../internal/hooks/use-debounce-callback';\nimport { useEffectOnUpdate } from '../internal/hooks/use-effect-on-update';\nimport { scrollElementIntoView } from '../internal/utils/scrollable-containers';\nimport { throttle } from '../internal/utils/throttle';\nimport {\n GeneratedAnalyticsMetadataFlashbarCollapse,\n GeneratedAnalyticsMetadataFlashbarExpand,\n} from './analytics-metadata/interfaces';\nimport { getComponentsAnalyticsMetadata, getItemAnalyticsMetadata } from './analytics-metadata/utils';\nimport { useFlashbar } from './common';\nimport { Flash, focusFlashById } from './flash';\nimport { FlashbarProps } from './interfaces';\nimport { getCollapsibleFlashStyles, getNotificationBarStyles } from './style';\nimport {\n counterTypes,\n FOCUS_DEBOUNCE_DELAY,\n getFlashTypeCount,\n getItemColor,\n getVisibleCollapsedItems,\n StackableItem,\n} from './utils';\n\nimport styles from './styles.css.js';\n\n// If the number of items is equal or less than this value,\n// the toggle element will not be displayed and the Flashbar will look like a regular single-item Flashbar.\nconst maxNonCollapsibleItems = 1;\n\nconst resizeListenerThrottleDelay = 100;\n\nexport default function CollapsibleFlashbar({ items, style, ...restProps }: FlashbarProps) {\n const [enteringItems, setEnteringItems] = useState<ReadonlyArray<FlashbarProps.MessageDefinition>>([]);\n const [exitingItems, setExitingItems] = useState<ReadonlyArray<FlashbarProps.MessageDefinition>>([]);\n const [isFlashbarStackExpanded, setIsFlashbarStackExpanded] = useState(false);\n\n const getElementsToAnimate = useCallback(() => {\n const flashElements = isFlashbarStackExpanded ? expandedItemRefs.current : collapsedItemRefs.current;\n return { ...flashElements, notificationBar: notificationBarRef.current };\n }, [isFlashbarStackExpanded]);\n\n const prepareAnimations = useCallback(() => {\n const rects = getDOMRects(getElementsToAnimate());\n setInitialAnimationState(rects);\n }, [getElementsToAnimate]);\n\n const collapsedItemRefs = useRef<Record<string, HTMLElement | null>>({});\n const expandedItemRefs = useRef<Record<string, HTMLElement | null>>({});\n const [initialAnimationState, setInitialAnimationState] = useState<Record<string, DOMRect> | null>(null);\n const listElementRef = useRef<HTMLUListElement | null>(null);\n const notificationBarRef = useRef<HTMLDivElement | null>(null);\n const [transitioning, setTransitioning] = useState(false);\n const flashbarElementId = useUniqueId('flashbar');\n const itemCountElementId = useUniqueId('item-count');\n\n const { baseProps, isReducedMotion, isVisualRefresh, mergedRef, ref, flashRefs, handleFlashDismissed } = useFlashbar({\n items,\n ...restProps,\n onItemsAdded: newItems => {\n setEnteringItems([...enteringItems, ...newItems]);\n },\n onItemsChanged: options => {\n // If not all items have ID, we can still animate collapse/expand transitions\n // because we can rely on each item's index in the original array,\n // but we can't do that when elements are added or removed, since the index changes.\n if (options?.allItemsHaveId && !options?.isReducedMotion) {\n prepareAnimations();\n }\n },\n onItemsRemoved: removedItems => {\n setExitingItems([...exitingItems, ...removedItems]);\n },\n });\n\n if (items.length <= maxNonCollapsibleItems && isFlashbarStackExpanded) {\n setIsFlashbarStackExpanded(false);\n }\n\n const animateFlash = !isReducedMotion;\n\n function toggleCollapseExpand() {\n if (!isReducedMotion) {\n prepareAnimations();\n }\n setIsFlashbarStackExpanded(prev => !prev);\n }\n\n const debouncedFocus = useDebounceCallback(focusFlashById, FOCUS_DEBOUNCE_DELAY);\n useLayoutEffect(() => {\n if (isFlashbarStackExpanded && items?.length) {\n const mostRecentItem = items[0];\n if (mostRecentItem.id !== undefined) {\n debouncedFocus(ref.current, mostRecentItem.id);\n }\n }\n // Run this after expanding, but not every time the items change.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [debouncedFocus, isFlashbarStackExpanded]);\n\n // When collapsing, scroll up if necessary to avoid losing track of the focused button\n useEffectOnUpdate(() => {\n if (!isFlashbarStackExpanded && notificationBarRef.current) {\n scrollElementIntoView(notificationBarRef.current);\n }\n }, [isFlashbarStackExpanded]);\n\n const updateBottomSpacing = useMemo(\n () =>\n throttle(() => {\n // Allow vertical space between Flashbar and page bottom only when the Flashbar is reaching the end of the page,\n // otherwise avoid spacing with eventual sticky elements below.\n const listElement = listElementRef?.current;\n const flashbar = listElement?.parentElement;\n if (listElement && flashbar) {\n // Make sure the bottom padding is present when we make the calculations,\n // then we might decide to remove it or not.\n flashbar.classList.remove(styles.floating);\n const windowHeight = window.innerHeight;\n // Take the parent region into account if using the App Layout, because it might have additional margins.\n // Otherwise we use the Flashbar component for this calculation.\n const outerElement = findUpUntil(flashbar, element => element.getAttribute('role') === 'region') || flashbar;\n const applySpacing =\n isFlashbarStackExpanded && Math.ceil(outerElement.getBoundingClientRect().bottom) >= windowHeight;\n if (!applySpacing) {\n flashbar.classList.add(styles.floating);\n }\n }\n }, resizeListenerThrottleDelay),\n [isFlashbarStackExpanded]\n );\n\n useLayoutEffect(() => {\n window.addEventListener('resize', updateBottomSpacing);\n return () => {\n window.removeEventListener('resize', updateBottomSpacing);\n updateBottomSpacing.cancel();\n };\n }, [updateBottomSpacing]);\n\n const { i18nStrings } = restProps;\n\n const i18n = useInternalI18n('flashbar');\n const ariaLabel = i18n('i18nStrings.ariaLabel', i18nStrings?.ariaLabel);\n const notificationBarText = i18n('i18nStrings.notificationBarText', i18nStrings?.notificationBarText);\n const notificationBarAriaLabel = i18n('i18nStrings.notificationBarAriaLabel', i18nStrings?.notificationBarAriaLabel);\n const iconAriaLabels = {\n errorIconAriaLabel: i18n('i18nStrings.errorIconAriaLabel', i18nStrings?.errorIconAriaLabel),\n inProgressIconAriaLabel: i18n('i18nStrings.inProgressIconAriaLabel', i18nStrings?.inProgressIconAriaLabel),\n infoIconAriaLabel: i18n('i18nStrings.infoIconAriaLabel', i18nStrings?.infoIconAriaLabel),\n successIconAriaLabel: i18n('i18nStrings.successIconAriaLabel', i18nStrings?.successIconAriaLabel),\n warningIconAriaLabel: i18n('i18nStrings.warningIconAriaLabel', i18nStrings?.warningIconAriaLabel),\n };\n\n useLayoutEffect(() => {\n // When `useLayoutEffect` is called, the DOM is updated but has not been painted yet,\n // so it's a good moment to trigger animations that will make calculations based on old and new DOM state.\n // The old state is kept in `initialAnimationState`\n // and the new state can be retrieved from the current DOM elements.\n\n if (initialAnimationState) {\n updateBottomSpacing();\n\n animate({\n elements: getElementsToAnimate(),\n oldState: initialAnimationState,\n newElementInitialState: ({ top }) => ({ scale: 0.9, y: -0.2 * top }),\n onTransitionsEnd: () => setTransitioning(false),\n });\n\n setTransitioning(true);\n setInitialAnimationState(null);\n }\n }, [updateBottomSpacing, getElementsToAnimate, initialAnimationState, isFlashbarStackExpanded]);\n\n const isCollapsible = items.length > maxNonCollapsibleItems;\n\n const countByType = getFlashTypeCount(items);\n\n const numberOfColorsInStack = new Set(items.map(getItemColor)).size;\n const maxSlots = Math.max(numberOfColorsInStack, 3);\n const stackDepth = Math.min(maxSlots, items.length);\n\n const itemsToShow = isFlashbarStackExpanded\n ? items.map((item, index) => ({ ...item, expandedIndex: index }))\n : getVisibleCollapsedItems(items, stackDepth).map((item: StackableItem, index: number) => ({\n ...item,\n collapsedIndex: index,\n }));\n\n const getItemId = (item: StackableItem | FlashbarProps.MessageDefinition) =>\n item.id ?? (item as StackableItem).expandedIndex ?? 0;\n\n // This check allows us to use the standard \"enter\" Transition only when the notification was not existing before.\n // If instead it was moved to the top of the stack but was already present in the array\n // (e.g, after dismissing another notification),\n // we need to use different, more custom and more controlled animations.\n const hasEntered = (item: StackableItem | FlashbarProps.MessageDefinition) =>\n enteringItems.some(_item => _item.id && _item.id === item.id);\n const hasLeft = (item: StackableItem | FlashbarProps.MessageDefinition) => !('expandedIndex' in item);\n const hasEnteredOrLeft = (item: StackableItem | FlashbarProps.MessageDefinition) => hasEntered(item) || hasLeft(item);\n\n const showInnerContent = (item: StackableItem | FlashbarProps.MessageDefinition) =>\n isFlashbarStackExpanded || hasLeft(item) || ('expandedIndex' in item && item.expandedIndex === 0);\n\n const shouldUseStandardAnimation = (item: StackableItem, index: number) => index === 0 && hasEnteredOrLeft(item);\n\n const getAnimationElementId = (item: StackableItem) => `flash-${getItemId(item)}`;\n\n const renderList = () => (\n <ul\n ref={listElementRef}\n className={clsx(\n styles['flash-list'],\n isFlashbarStackExpanded ? styles.expanded : styles.collapsed,\n transitioning && styles['animation-running'],\n initialAnimationState && styles['animation-ready'],\n isVisualRefresh && styles['visual-refresh']\n )}\n id={flashbarElementId}\n aria-label={ariaLabel}\n aria-describedby={isCollapsible ? itemCountElementId : undefined}\n style={\n !isFlashbarStackExpanded || transitioning\n ? {\n [customCssProps.flashbarStackDepth]: stackDepth,\n }\n : undefined\n }\n >\n <ListWrapper withMotion={!isReducedMotion}>\n {itemsToShow.map((item: StackableItem, index: number) => (\n <Transition\n key={getItemId(item)}\n in={!hasLeft(item)}\n onStatusChange={status => {\n if (status === 'entered') {\n setEnteringItems([]);\n } else if (status === 'exited') {\n setExitingItems([]);\n }\n }}\n >\n {(state: string, transitionRootElement: React.Ref<HTMLDivElement> | undefined) => (\n <li\n aria-hidden={!showInnerContent(item)}\n className={\n showInnerContent(item)\n ? clsx(\n styles['flash-list-item'],\n !isFlashbarStackExpanded && styles.item,\n !collapsedItemRefs.current[getAnimationElementId(item)] && styles['expanded-only']\n )\n : clsx(styles.flash, styles[`flash-type-${item.type ?? 'info'}`], styles.item)\n }\n ref={element => {\n if (isFlashbarStackExpanded) {\n expandedItemRefs.current[getAnimationElementId(item)] = element;\n } else {\n collapsedItemRefs.current[getAnimationElementId(item)] = element;\n }\n }}\n style={{\n ...(index > 0 && !isFlashbarStackExpanded && getCollapsibleFlashStyles(style, item.type)),\n ...((!isFlashbarStackExpanded || transitioning) && {\n [customCssProps.flashbarStackIndex]:\n (item as StackableItem).collapsedIndex ?? (item as StackableItem).expandedIndex ?? index,\n }),\n }}\n key={getItemId(item)}\n {...getAnalyticsMetadataAttribute(getItemAnalyticsMetadata(index + 1, item.type || 'info', item.id))}\n >\n {showInnerContent(item) && (\n <Flash\n className={clsx(\n animateFlash && styles['flash-with-motion'],\n isVisualRefresh && styles['flash-refresh']\n )}\n key={getItemId(item)}\n ref={(el: HTMLDivElement | null) => {\n // Store the Flash element reference for focus management\n flashRefs.current[getItemId(item)] = el;\n\n if (shouldUseStandardAnimation(item, index) && transitionRootElement) {\n if (typeof transitionRootElement === 'function') {\n transitionRootElement(el);\n } else if (\n transitionRootElement &&\n typeof transitionRootElement === 'object' &&\n 'current' in transitionRootElement\n ) {\n (transitionRootElement as React.MutableRefObject<HTMLDivElement | null>).current = el;\n }\n }\n }}\n transitionState={shouldUseStandardAnimation(item, index) ? state : undefined}\n i18nStrings={iconAriaLabels}\n style={style}\n onDismissed={handleFlashDismissed}\n {...item}\n />\n )}\n </li>\n )}\n </Transition>\n ))}\n </ListWrapper>\n </ul>\n );\n\n return (\n <div\n {...baseProps}\n className={clsx(\n baseProps.className,\n styles.flashbar,\n styles.stack,\n isCollapsible && styles.collapsible,\n items.length === 2 && styles['short-list'],\n isFlashbarStackExpanded && styles.expanded,\n isVisualRefresh && styles['visual-refresh']\n )}\n ref={mergedRef}\n {...getAnalyticsMetadataAttribute(getComponentsAnalyticsMetadata(items.length, true, isFlashbarStackExpanded))}\n >\n {isFlashbarStackExpanded && renderList()}\n {isCollapsible && (\n <div\n className={clsx(\n styles['notification-bar'],\n isVisualRefresh && styles['visual-refresh'],\n isFlashbarStackExpanded ? styles.expanded : styles.collapsed,\n transitioning && styles['animation-running'],\n items.length === 2 && styles['short-list'],\n getVisualContextClassname('flashbar') // Visual context is needed for focus ring to be white\n )}\n onClick={toggleCollapseExpand}\n ref={notificationBarRef}\n style={getNotificationBarStyles(style)}\n {...getAnalyticsMetadataAttribute({\n action: !isFlashbarStackExpanded ? 'expand' : 'collapse',\n detail: {\n label: 'h2',\n },\n } as GeneratedAnalyticsMetadataFlashbarExpand | GeneratedAnalyticsMetadataFlashbarCollapse)}\n >\n <span aria-live=\"polite\" className={styles.status} role=\"status\" id={itemCountElementId}>\n {notificationBarText && <h2 className={styles.header}>{notificationBarText}</h2>}\n <span className={styles['item-count']}>\n {counterTypes.map(({ type, labelName, iconName }) => (\n <NotificationTypeCount\n key={type}\n iconName={iconName}\n label={iconAriaLabels[labelName]}\n count={countByType[type]}\n />\n ))}\n </span>\n </span>\n <button\n aria-controls={flashbarElementId}\n aria-describedby={itemCountElementId}\n aria-expanded={isFlashbarStackExpanded}\n aria-label={notificationBarAriaLabel}\n className={clsx(styles.button, isFlashbarStackExpanded && styles.expanded)}\n >\n <InternalIcon className={styles.icon} size=\"normal\" name=\"angle-down\" />\n </button>\n </div>\n )}\n {!isFlashbarStackExpanded && renderList()}\n </div>\n );\n}\n\nconst NotificationTypeCount = ({\n iconName,\n label,\n count,\n}: {\n iconName: IconProps.Name;\n label?: string;\n count: number;\n}) => {\n return (\n <span className={styles['type-count']}>\n <span title={label}>\n <InternalIcon name={iconName} ariaLabel={label} />\n </span>\n <span className={styles['count-number']}>{count}</span>\n </span>\n );\n};\n\nconst ListWrapper = ({ children, withMotion }: { children: ReactNode; withMotion: boolean }) =>\n withMotion ? <TransitionGroup component={null}>{children}</TransitionGroup> : <>{children}</>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/flashbar/common.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/flashbar/common.tsx"],"names":[],"mappings":";AAYA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAM7C,eAAO,MAAM,4BAA4B,gBAC1B,MAAM,GAAG,SAAS,SACxB,cAAc,cAAc,iBAAiB,CAAC,GAAG,SAAS,cACrD,cAAc,GAAG,IAAI,oBACf,OAAO,MAAM,GAAG,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC,SA8CjE,CAAC;AAGF,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,GAAG,SAAS,EACb,EAAE,aAAa,GAAG;IACjB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,iBAAiB,EAAE,KAAK,IAAI,CAAC;IAClE,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,iBAAiB,EAAE,KAAK,IAAI,CAAC;IACpE,cAAc,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,OAAO,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;CAC9F;;;;;;;;yCAiD6C,MAAM;EAcnD"}
|
|
@@ -5,9 +5,11 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
|
|
5
5
|
import { useMergeRefs, useReducedMotion, warnOnce } from '@cloudscape-design/component-toolkit/internal';
|
|
6
6
|
import { getBaseProps } from '../internal/base-component';
|
|
7
7
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
8
|
+
import { useDebounceCallback } from '../internal/hooks/use-debounce-callback';
|
|
8
9
|
import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
9
10
|
import { isDevelopment } from '../internal/is-development';
|
|
10
11
|
import { focusFlashById, focusFlashFocusableArea } from './flash';
|
|
12
|
+
import { FOCUS_DEBOUNCE_DELAY } from './utils';
|
|
11
13
|
import styles from './styles.css.js';
|
|
12
14
|
// Exported for testing
|
|
13
15
|
export const handleFlashDismissedInternal = (dismissedId, items, refCurrent, flashRefsCurrent) => {
|
|
@@ -87,11 +89,12 @@ export function useFlashbar(_a) {
|
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
}
|
|
92
|
+
const debouncedFocus = useDebounceCallback(focusFlashById, FOCUS_DEBOUNCE_DELAY);
|
|
90
93
|
useEffect(() => {
|
|
91
94
|
if (nextFocusId) {
|
|
92
|
-
|
|
95
|
+
debouncedFocus(ref.current, nextFocusId);
|
|
93
96
|
}
|
|
94
|
-
}, [nextFocusId, ref]);
|
|
97
|
+
}, [debouncedFocus, nextFocusId, ref]);
|
|
95
98
|
const handleFlashDismissed = (dismissedId) => {
|
|
96
99
|
handleFlashDismissedInternal(dismissedId, items, ref.current, flashRefs.current);
|
|
97
100
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/flashbar/common.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzG,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAGlE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,uBAAuB;AACvB,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,WAA+B,EAC/B,KAAiE,EACjE,UAAiC,EACjC,gBAAgE,EAChE,EAAE;;IACF,IAAI,CAAC,KAAK,IAAI,CAAC,WAAW,IAAI,CAAC,UAAU,EAAE;QACzC,OAAO;KACR;IAED,MAAM,cAAc,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,WAAC,OAAA,CAAC,MAAA,IAAI,CAAC,EAAE,mCAAI,EAAE,CAAC,KAAK,WAAW,CAAA,EAAA,CAAC,CAAC;IAChF,IAAI,cAAc,KAAK,CAAC,CAAC,EAAE;QACzB,OAAO;K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,WAAoB,EAAE,EAAE;QACpD,4BAA4B,CAAC,WAAW,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACnF,CAAC,CAAC;IAEF,OAAO;QACL,cAAc;QACd,SAAS;QACT,eAAe;QACf,eAAe;QACf,SAAS;QACT,GAAG;QACH,SAAS;QACT,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useEffect, useMemo, useRef, useState } from 'react';\n\nimport { useMergeRefs, useReducedMotion, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getBaseProps } from '../internal/base-component';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { isDevelopment } from '../internal/is-development';\nimport { focusFlashById, focusFlashFocusableArea } from './flash';\nimport { FlashbarProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\n// Exported for testing\nexport const handleFlashDismissedInternal = (\n dismissedId: string | undefined,\n items: ReadonlyArray<FlashbarProps.MessageDefinition> | undefined,\n refCurrent: HTMLDivElement | null,\n flashRefsCurrent: Record<string | number, HTMLDivElement | null>\n) => {\n if (!items || !dismissedId || !refCurrent) {\n return;\n }\n\n const dismissedIndex = items.findIndex(item => (item.id ?? '') === dismissedId);\n if (dismissedIndex === -1) {\n return;\n }\n\n let nextItemIndex = dismissedIndex + 1;\n if (nextItemIndex >= items.length) {\n nextItemIndex = dismissedIndex - 1;\n }\n\n // If there's no next item, focus the first instance of the main element (or element with role=main)\n if (nextItemIndex < 0 || nextItemIndex >= items.length) {\n const mainElement = document.querySelector('main') ?? document.querySelector('[role=\"main\"]');\n mainElement?.focus();\n return;\n }\n\n const nextItemId = items[nextItemIndex].id ?? nextItemIndex;\n\n // Try to focus on the next item, but with a small delay to ensure the DOM is updated\n // This is especially important for collapsible flashbars where the next item might become visible\n const attemptFocus = () => {\n const nextFlashElement = flashRefsCurrent[nextItemId];\n if (!nextFlashElement) {\n // If the next flash element is not available, it might be because the flashbar is collapsed\n // In that case, try to focus on the notification bar button or the main element\n const notificationBarButton = refCurrent?.querySelector(`.${styles.button}`);\n if (notificationBarButton) {\n (notificationBarButton as HTMLElement).focus();\n return;\n }\n\n const mainElement = document.querySelector('main') ?? document.querySelector('[role=\"main\"]');\n mainElement?.focus();\n return;\n }\n focusFlashFocusableArea(nextFlashElement);\n };\n\n setTimeout(attemptFocus, 0);\n};\n\n// Common logic for collapsible and non-collapsible Flashbar\nexport function useFlashbar({\n items,\n onItemsAdded,\n onItemsChanged,\n onItemsRemoved,\n ...restProps\n}: FlashbarProps & {\n onItemsAdded?: (items: FlashbarProps.MessageDefinition[]) => void;\n onItemsRemoved?: (items: FlashbarProps.MessageDefinition[]) => void;\n onItemsChanged?: (options?: { allItemsHaveId?: boolean; isReducedMotion?: boolean }) => void;\n}) {\n const { __internalRootRef } = useBaseComponent('Flashbar', {\n props: { stackItems: restProps.stackItems },\n });\n const allItemsHaveId = useMemo(() => items.every(item => 'id' in item), [items]);\n const baseProps = getBaseProps(restProps);\n const ref = useRef<HTMLDivElement | null>(null);\n const flashRefs = useRef<Record<string | number, HTMLDivElement | null>>({});\n const mergedRef = useMergeRefs(ref, __internalRootRef);\n const isReducedMotion = useReducedMotion(ref);\n const isVisualRefresh = useVisualRefresh();\n const [previousItems, setPreviousItems] = useState<ReadonlyArray<FlashbarProps.MessageDefinition>>(items);\n const [nextFocusId, setNextFocusId] = useState<string | null>(null);\n\n if (isDevelopment) {\n if (items?.some(item => item.ariaRole === 'alert' && !item.id)) {\n warnOnce(\n 'Flashbar',\n `You provided \\`ariaRole=\"alert\"\\` for a flashbar item without providing an \\`id\\`. Focus will not be moved to the newly added flash message.`\n );\n }\n }\n\n // Track new or removed item IDs in state to only trigger focus changes for newly added items.\n // https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops\n if (items) {\n const newItems = items.filter(({ id }) => id && !previousItems.some(item => item.id === id));\n const removedItems = previousItems.filter(({ id }) => id && !items.some(item => item.id === id));\n if (newItems.length > 0 || removedItems.length > 0) {\n setPreviousItems(items);\n onItemsAdded?.(newItems);\n onItemsRemoved?.(removedItems);\n onItemsChanged?.({ allItemsHaveId, isReducedMotion });\n\n const newFocusItems = newItems.filter(({ ariaRole }) => ariaRole === 'alert');\n if (newFocusItems.length > 0) {\n setNextFocusId(newFocusItems[0].id!);\n }\n }\n }\n\n useEffect(() => {\n if (nextFocusId) {\n focusFlashById(ref.current, nextFocusId);\n }\n }, [nextFocusId, ref]);\n\n const handleFlashDismissed = (dismissedId?: string) => {\n handleFlashDismissedInternal(dismissedId, items, ref.current, flashRefs.current);\n };\n\n return {\n allItemsHaveId,\n baseProps,\n isReducedMotion,\n isVisualRefresh,\n mergedRef,\n ref,\n flashRefs,\n handleFlashDismissed,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/flashbar/common.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzG,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,OAAO,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GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;YAC9E,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC5B,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAG,CAAC,CAAC;aACtC;SACF;KACF;IAED,MAAM,cAAc,GAAG,mBAAmB,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAC;IAEjF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,WAAW,EAAE;YACf,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;SAC1C;IACH,CAAC,EAAE,CAAC,cAAc,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC;IAEvC,MAAM,oBAAoB,GAAG,CAAC,WAAoB,EAAE,EAAE;QACpD,4BAA4B,CAAC,WAAW,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACnF,CAAC,CAAC;IAEF,OAAO;QACL,cAAc;QACd,SAAS;QACT,eAAe;QACf,eAAe;QACf,SAAS;QACT,GAAG;QACH,SAAS;QACT,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useEffect, useMemo, useRef, useState } from 'react';\n\nimport { useMergeRefs, useReducedMotion, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getBaseProps } from '../internal/base-component';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useDebounceCallback } from '../internal/hooks/use-debounce-callback';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { isDevelopment } from '../internal/is-development';\nimport { focusFlashById, focusFlashFocusableArea } from './flash';\nimport { FlashbarProps } from './interfaces';\nimport { FOCUS_DEBOUNCE_DELAY } from './utils';\n\nimport styles from './styles.css.js';\n\n// Exported for testing\nexport const handleFlashDismissedInternal = (\n dismissedId: string | undefined,\n items: ReadonlyArray<FlashbarProps.MessageDefinition> | undefined,\n refCurrent: HTMLDivElement | null,\n flashRefsCurrent: Record<string | number, HTMLDivElement | null>\n) => {\n if (!items || !dismissedId || !refCurrent) {\n return;\n }\n\n const dismissedIndex = items.findIndex(item => (item.id ?? '') === dismissedId);\n if (dismissedIndex === -1) {\n return;\n }\n\n let nextItemIndex = dismissedIndex + 1;\n if (nextItemIndex >= items.length) {\n nextItemIndex = dismissedIndex - 1;\n }\n\n // If there's no next item, focus the first instance of the main element (or element with role=main)\n if (nextItemIndex < 0 || nextItemIndex >= items.length) {\n const mainElement = document.querySelector('main') ?? document.querySelector('[role=\"main\"]');\n mainElement?.focus();\n return;\n }\n\n const nextItemId = items[nextItemIndex].id ?? nextItemIndex;\n\n // Try to focus on the next item, but with a small delay to ensure the DOM is updated\n // This is especially important for collapsible flashbars where the next item might become visible\n const attemptFocus = () => {\n const nextFlashElement = flashRefsCurrent[nextItemId];\n if (!nextFlashElement) {\n // If the next flash element is not available, it might be because the flashbar is collapsed\n // In that case, try to focus on the notification bar button or the main element\n const notificationBarButton = refCurrent?.querySelector(`.${styles.button}`);\n if (notificationBarButton) {\n (notificationBarButton as HTMLElement).focus();\n return;\n }\n\n const mainElement = document.querySelector('main') ?? document.querySelector('[role=\"main\"]');\n mainElement?.focus();\n return;\n }\n focusFlashFocusableArea(nextFlashElement);\n };\n\n setTimeout(attemptFocus, 0);\n};\n\n// Common logic for collapsible and non-collapsible Flashbar\nexport function useFlashbar({\n items,\n onItemsAdded,\n onItemsChanged,\n onItemsRemoved,\n ...restProps\n}: FlashbarProps & {\n onItemsAdded?: (items: FlashbarProps.MessageDefinition[]) => void;\n onItemsRemoved?: (items: FlashbarProps.MessageDefinition[]) => void;\n onItemsChanged?: (options?: { allItemsHaveId?: boolean; isReducedMotion?: boolean }) => void;\n}) {\n const { __internalRootRef } = useBaseComponent('Flashbar', {\n props: { stackItems: restProps.stackItems },\n });\n const allItemsHaveId = useMemo(() => items.every(item => 'id' in item), [items]);\n const baseProps = getBaseProps(restProps);\n const ref = useRef<HTMLDivElement | null>(null);\n const flashRefs = useRef<Record<string | number, HTMLDivElement | null>>({});\n const mergedRef = useMergeRefs(ref, __internalRootRef);\n const isReducedMotion = useReducedMotion(ref);\n const isVisualRefresh = useVisualRefresh();\n const [previousItems, setPreviousItems] = useState<ReadonlyArray<FlashbarProps.MessageDefinition>>(items);\n const [nextFocusId, setNextFocusId] = useState<string | null>(null);\n\n if (isDevelopment) {\n if (items?.some(item => item.ariaRole === 'alert' && !item.id)) {\n warnOnce(\n 'Flashbar',\n `You provided \\`ariaRole=\"alert\"\\` for a flashbar item without providing an \\`id\\`. Focus will not be moved to the newly added flash message.`\n );\n }\n }\n\n // Track new or removed item IDs in state to only trigger focus changes for newly added items.\n // https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops\n if (items) {\n const newItems = items.filter(({ id }) => id && !previousItems.some(item => item.id === id));\n const removedItems = previousItems.filter(({ id }) => id && !items.some(item => item.id === id));\n if (newItems.length > 0 || removedItems.length > 0) {\n setPreviousItems(items);\n onItemsAdded?.(newItems);\n onItemsRemoved?.(removedItems);\n onItemsChanged?.({ allItemsHaveId, isReducedMotion });\n\n const newFocusItems = newItems.filter(({ ariaRole }) => ariaRole === 'alert');\n if (newFocusItems.length > 0) {\n setNextFocusId(newFocusItems[0].id!);\n }\n }\n }\n\n const debouncedFocus = useDebounceCallback(focusFlashById, FOCUS_DEBOUNCE_DELAY);\n\n useEffect(() => {\n if (nextFocusId) {\n debouncedFocus(ref.current, nextFocusId);\n }\n }, [debouncedFocus, nextFocusId, ref]);\n\n const handleFlashDismissed = (dismissedId?: string) => {\n handleFlashDismissedInternal(dismissedId, items, ref.current, flashRefs.current);\n };\n\n return {\n allItemsHaveId,\n baseProps,\n isReducedMotion,\n isVisualRefresh,\n mergedRef,\n ref,\n flashRefs,\n handleFlashDismissed,\n };\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FlashbarProps } from './interfaces';
|
|
3
3
|
export declare const focusFlashFocusableArea: (flash: HTMLElement | null) => void;
|
|
4
|
-
export declare
|
|
4
|
+
export declare function focusFlashById(element: HTMLElement | null, itemId: string): void;
|
|
5
5
|
interface FlashProps extends FlashbarProps.MessageDefinition {
|
|
6
6
|
className: string;
|
|
7
7
|
transitionState?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flash.d.ts","sourceRoot":"","sources":["../../../src/flashbar/flash.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"flash.d.ts","sourceRoot":"","sources":["../../../src/flashbar/flash.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AA6BtC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAmD7C,eAAO,MAAM,uBAAuB,UAAW,WAAW,GAAG,IAAI,SAYhE,CAAC;AAEF,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,QAYzE;AAED,UAAU,UAAW,SAAQ,aAAa,CAAC,iBAAiB;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;IACxC,KAAK,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC;IAC5B,OAAO,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED,eAAO,MAAM,KAAK,mFA6KjB,CAAC"}
|
|
@@ -14,12 +14,10 @@ import { PACKAGE_VERSION } from '../internal/environment';
|
|
|
14
14
|
import { isDevelopment } from '../internal/is-development';
|
|
15
15
|
import { awsuiPluginsInternal } from '../internal/plugins/api';
|
|
16
16
|
import { createUseDiscoveredAction, createUseDiscoveredContent } from '../internal/plugins/helpers';
|
|
17
|
-
import { throttle } from '../internal/utils/throttle';
|
|
18
17
|
import useContainerWidth from '../internal/utils/use-container-width';
|
|
19
18
|
import InternalLiveRegion from '../live-region/internal';
|
|
20
19
|
import InternalSpinner from '../spinner/internal';
|
|
21
20
|
import { getDismissButtonStyles, getFlashStyles } from './style';
|
|
22
|
-
import { FOCUS_THROTTLE_DELAY } from './utils';
|
|
23
21
|
import analyticsSelectors from './analytics-metadata/styles.css.js';
|
|
24
22
|
import styles from './styles.css.js';
|
|
25
23
|
const ICON_TYPES = {
|
|
@@ -55,7 +53,7 @@ export const focusFlashFocusableArea = (flash) => {
|
|
|
55
53
|
focusContainer.focus();
|
|
56
54
|
}
|
|
57
55
|
};
|
|
58
|
-
export
|
|
56
|
+
export function focusFlashById(element, itemId) {
|
|
59
57
|
if (!element) {
|
|
60
58
|
return;
|
|
61
59
|
}
|
|
@@ -65,7 +63,7 @@ export const focusFlashById = throttle((element, itemId) => {
|
|
|
65
63
|
}
|
|
66
64
|
const focusContainer = flashElement.querySelector(`.${styles['flash-focus-container']}`);
|
|
67
65
|
focusContainer === null || focusContainer === void 0 ? void 0 : focusContainer.focus();
|
|
68
|
-
}
|
|
66
|
+
}
|
|
69
67
|
export const Flash = React.forwardRef((_a, ref) => {
|
|
70
68
|
var { id, header, content, dismissible, dismissLabel, loading, action, buttonText, onButtonClick, onDismiss, className, transitionState, ariaRole, i18nStrings, type = 'info', analyticsMetadata, style, rootRef, onDismissed } = _a, props = __rest(_a, ["id", "header", "content", "dismissible", "dismissLabel", "loading", "action", "buttonText", "onButtonClick", "onDismiss", "className", "transitionState", "ariaRole", "i18nStrings", "type", "analyticsMetadata", "style", "rootRef", "onDismissed"]);
|
|
71
69
|
if (isDevelopment) {
|