@cloudscape-design/components 3.0.183 → 3.0.185
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/collection-preferences/styles.css.js +20 -20
- package/collection-preferences/styles.scoped.css +22 -21
- package/collection-preferences/styles.selectors.js +20 -20
- package/collection-preferences/visible-content.js +1 -1
- package/collection-preferences/visible-content.js.map +1 -1
- package/flashbar/collapsible-flashbar.d.ts +4 -0
- package/flashbar/collapsible-flashbar.d.ts.map +1 -0
- package/flashbar/collapsible-flashbar.js +209 -0
- package/flashbar/collapsible-flashbar.js.map +1 -0
- package/flashbar/common.d.ts +19 -0
- package/flashbar/common.d.ts.map +1 -0
- package/flashbar/common.js +63 -0
- package/flashbar/common.js.map +1 -0
- package/flashbar/flash.d.ts.map +1 -1
- package/flashbar/flash.js +8 -3
- package/flashbar/flash.js.map +1 -1
- package/flashbar/index.d.ts +2 -2
- package/flashbar/index.d.ts.map +1 -1
- package/flashbar/index.js +14 -159
- package/flashbar/index.js.map +1 -1
- package/flashbar/interfaces.d.ts +14 -7
- package/flashbar/interfaces.d.ts.map +1 -1
- package/flashbar/interfaces.js.map +1 -1
- package/flashbar/internal/analytics.d.ts +5 -0
- package/flashbar/internal/analytics.d.ts.map +1 -0
- package/flashbar/internal/analytics.js +29 -0
- package/flashbar/internal/analytics.js.map +1 -0
- package/flashbar/non-collapsible-flashbar.d.ts +4 -0
- package/flashbar/non-collapsible-flashbar.d.ts.map +1 -0
- package/flashbar/non-collapsible-flashbar.js +70 -0
- package/flashbar/non-collapsible-flashbar.js.map +1 -0
- package/flashbar/styles.css.js +43 -33
- package/flashbar/styles.scoped.css +329 -225
- package/flashbar/styles.selectors.js +43 -33
- package/flashbar/utils.d.ts +17 -0
- package/flashbar/utils.d.ts.map +1 -0
- package/flashbar/utils.js +95 -0
- package/flashbar/utils.js.map +1 -0
- package/internal/animate.d.ts +11 -0
- package/internal/animate.d.ts.map +1 -0
- package/internal/animate.js +104 -0
- package/internal/animate.js.map +1 -0
- package/internal/base-component/styles.scoped.css +1 -0
- package/internal/environment.js +1 -1
- package/internal/generated/theming/index.cjs +11 -0
- package/internal/generated/theming/index.js +11 -0
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
package/flashbar/flash.js
CHANGED
|
@@ -10,7 +10,8 @@ import { isDevelopment } from '../internal/is-development';
|
|
|
10
10
|
import { throttle } from '../internal/utils/throttle';
|
|
11
11
|
import useFocusVisible from '../internal/hooks/focus-visible';
|
|
12
12
|
import LiveRegion from '../internal/components/live-region';
|
|
13
|
-
|
|
13
|
+
import { sendDismissMetric } from './internal/analytics';
|
|
14
|
+
import { FOCUS_THROTTLE_DELAY } from './utils';
|
|
14
15
|
var ICON_TYPES = {
|
|
15
16
|
success: 'status-positive',
|
|
16
17
|
warning: 'status-warning',
|
|
@@ -46,6 +47,10 @@ export var Flash = React.forwardRef(function (_a, ref) {
|
|
|
46
47
|
var icon = loading ? React.createElement(InternalSpinner, null) : React.createElement(InternalIcon, { name: iconType });
|
|
47
48
|
var effectiveType = loading ? 'info' : type;
|
|
48
49
|
var announcement = [statusIconAriaLabel, header, content].filter(Boolean).join(' ');
|
|
50
|
+
var handleDismiss = function (event) {
|
|
51
|
+
sendDismissMetric(effectiveType);
|
|
52
|
+
onDismiss && onDismiss(event);
|
|
53
|
+
};
|
|
49
54
|
return (
|
|
50
55
|
// We're not using "polite" or "assertive" here, just turning default behavior off.
|
|
51
56
|
// eslint-disable-next-line @cloudscape-design/prefer-live-region
|
|
@@ -58,13 +63,13 @@ export var Flash = React.forwardRef(function (_a, ref) {
|
|
|
58
63
|
_b[styles.exited] = transitionState === 'exited',
|
|
59
64
|
_b)) },
|
|
60
65
|
React.createElement("div", { className: styles['flash-body'] },
|
|
61
|
-
React.createElement("div", __assign({}, focusVisible, { className: styles['flash-focus-container'], tabIndex:
|
|
66
|
+
React.createElement("div", __assign({}, focusVisible, { className: styles['flash-focus-container'], tabIndex: -1 }),
|
|
62
67
|
React.createElement("div", { className: clsx(styles['flash-icon'], styles['flash-text']), role: "img", "aria-label": statusIconAriaLabel }, icon),
|
|
63
68
|
React.createElement("div", { className: clsx(styles['flash-message'], styles['flash-text']) },
|
|
64
69
|
React.createElement("div", { className: styles['flash-header'] }, header),
|
|
65
70
|
React.createElement("div", { className: styles['flash-content'] }, content))),
|
|
66
71
|
button && React.createElement("div", { className: styles['action-button-wrapper'] }, button)),
|
|
67
|
-
dismissible && dismissButton(dismissLabel,
|
|
72
|
+
dismissible && dismissButton(dismissLabel, handleDismiss),
|
|
68
73
|
ariaRole === 'status' && React.createElement(LiveRegion, null, announcement)));
|
|
69
74
|
});
|
|
70
75
|
//# sourceMappingURL=flash.js.map
|
package/flashbar/flash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flash.js","sourceRoot":"","sources":["../../../src/flashbar/flash.tsx"],"names":[],"mappings":";AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,MAAM,qBAAqB,CAAC;AAClD,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,UAAU,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"flash.js","sourceRoot":"","sources":["../../../src/flashbar/flash.tsx"],"names":[],"mappings":";AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,MAAM,qBAAqB,CAAC;AAClD,OAAO,YAAY,MAAM,kBAAkB,CAAC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AAC,KAAK,gBACE,mBAAmB,IAE9B,IAAI,CACD;gBACN,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;oBACjE,6BAAK,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC,IAAG,MAAM,CAAO;oBACtD,6BAAK,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,IAAG,OAAO,CAAO,CACpD,CACF;YACL,MAAM,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC,IAAG,MAAM,CAAO,CACtE;QACL,WAAW,IAAI,aAAa,CAAC,YAAY,EAAE,aAAa,CAAC;QACzD,QAAQ,KAAK,QAAQ,IAAI,oBAAC,UAAU,QAAE,YAAY,CAAc,CAC7D,CACP,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { FlashbarProps } from './interfaces';\nimport React from 'react';\nimport InternalSpinner from '../spinner/internal';\nimport InternalIcon from '../icon/internal';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport { InternalButton } from '../button/internal';\nimport { warnOnce } from '../internal/logging';\nimport { isDevelopment } from '../internal/is-development';\nimport { throttle } from '../internal/utils/throttle';\nimport useFocusVisible from '../internal/hooks/focus-visible';\nimport LiveRegion from '../internal/components/live-region';\nimport { ButtonProps } from '../button/interfaces';\n\nimport { sendDismissMetric } from './internal/analytics';\n\nimport { FOCUS_THROTTLE_DELAY } from './utils';\n\nconst ICON_TYPES = {\n success: 'status-positive',\n warning: 'status-warning',\n info: 'status-info',\n error: 'status-negative',\n} as const;\n\nfunction actionButton(\n buttonText: FlashbarProps.MessageDefinition['buttonText'],\n onButtonClick: FlashbarProps.MessageDefinition['onButtonClick']\n) {\n return (\n <InternalButton onClick={onButtonClick} className={styles['action-button']} formAction=\"none\">\n {buttonText}\n </InternalButton>\n );\n}\n\nfunction dismissButton(\n dismissLabel: FlashbarProps.MessageDefinition['dismissLabel'],\n onDismiss: FlashbarProps.MessageDefinition['onDismiss']\n) {\n return (\n <div className={styles['dismiss-button-wrapper']}>\n <InternalButton\n onClick={onDismiss}\n className={styles['dismiss-button']}\n variant=\"flashbar-icon\"\n iconName=\"close\"\n formAction=\"none\"\n ariaLabel={dismissLabel}\n />\n </div>\n );\n}\n\nexport const focusFlashById = throttle(\n (element: HTMLElement | null, itemId: string) => {\n const selector = `[data-itemid=\"${CSS.escape(itemId)}\"] .${styles['flash-focus-container']}`;\n element?.querySelector<HTMLElement>(selector)?.focus();\n },\n FOCUS_THROTTLE_DELAY,\n { trailing: false }\n);\n\nexport interface FlashProps extends FlashbarProps.MessageDefinition {\n className: string;\n transitionState?: string;\n}\n\nexport const Flash = React.forwardRef(\n (\n {\n id,\n header,\n content,\n dismissible,\n dismissLabel,\n statusIconAriaLabel,\n loading,\n action,\n buttonText,\n onButtonClick,\n onDismiss,\n className,\n transitionState,\n ariaRole,\n type = 'info',\n }: FlashProps,\n ref: React.Ref<HTMLDivElement>\n ) => {\n const focusVisible = useFocusVisible();\n\n if (isDevelopment) {\n if (buttonText && !onButtonClick) {\n warnOnce(\n 'Flashbar',\n `You provided a \\`buttonText\\` prop without an \\`onButtonClick\\` handler. This will render a non-interactive action button.`\n );\n }\n\n if (dismissible && !onDismiss) {\n warnOnce(\n 'Flashbar',\n `You have set the \\`dismissible\\` prop without an \\`onDismiss\\` handler. This will render a non-interactive dismiss button.`\n );\n }\n }\n\n const button = action || (buttonText && actionButton(buttonText, onButtonClick));\n\n const iconType = ICON_TYPES[type];\n\n const icon = loading ? <InternalSpinner /> : <InternalIcon name={iconType} />;\n\n const effectiveType = loading ? 'info' : type;\n\n const announcement = [statusIconAriaLabel, header, content].filter(Boolean).join(' ');\n\n const handleDismiss: ButtonProps['onClick'] = event => {\n sendDismissMetric(effectiveType);\n onDismiss && onDismiss(event);\n };\n\n return (\n // We're not using \"polite\" or \"assertive\" here, just turning default behavior off.\n // eslint-disable-next-line @cloudscape-design/prefer-live-region\n <div\n ref={ref}\n role={ariaRole}\n aria-live={ariaRole ? 'off' : undefined}\n data-itemid={id}\n className={clsx(\n styles.flash,\n styles[`flash-type-${effectiveType}`],\n className,\n transitionState && {\n [styles.enter]: transitionState === 'enter',\n [styles.entering]: transitionState === 'entering',\n [styles.entered]: transitionState === 'entered',\n [styles.exit]: transitionState === 'exit',\n [styles.exiting]: transitionState === 'exiting',\n [styles.exited]: transitionState === 'exited',\n }\n )}\n >\n <div className={styles['flash-body']}>\n <div {...focusVisible} className={styles['flash-focus-container']} tabIndex={-1}>\n <div\n className={clsx(styles['flash-icon'], styles['flash-text'])}\n role=\"img\"\n aria-label={statusIconAriaLabel}\n >\n {icon}\n </div>\n <div className={clsx(styles['flash-message'], styles['flash-text'])}>\n <div className={styles['flash-header']}>{header}</div>\n <div className={styles['flash-content']}>{content}</div>\n </div>\n </div>\n {button && <div className={styles['action-button-wrapper']}>{button}</div>}\n </div>\n {dismissible && dismissButton(dismissLabel, handleDismiss)}\n {ariaRole === 'status' && <LiveRegion>{announcement}</LiveRegion>}\n </div>\n );\n }\n);\n"]}
|
package/flashbar/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FlashbarProps } from './interfaces';
|
|
1
|
+
import { FlashbarProps, CollapsibleFlashbarProps } from './interfaces';
|
|
2
2
|
export { FlashbarProps };
|
|
3
|
-
export default function Flashbar(
|
|
3
|
+
export default function Flashbar(props: FlashbarProps | CollapsibleFlashbarProps): JSX.Element;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/flashbar/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/flashbar/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/flashbar/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAMvE,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,wBAAwB,eAY/E"}
|
package/flashbar/index.js
CHANGED
|
@@ -1,171 +1,26 @@
|
|
|
1
|
-
import { __assign
|
|
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
|
|
5
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import React, { useEffect } from 'react';
|
|
6
5
|
import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import { TIMEOUT_FOR_ENTERING_ANIMATION } from './constant';
|
|
12
|
-
import { TransitionGroup } from 'react-transition-group';
|
|
13
|
-
import { Transition } from '../internal/components/transition';
|
|
14
|
-
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
15
|
-
import { useContainerBreakpoints } from '../internal/hooks/container-queries';
|
|
16
|
-
import useFocusVisible from '../internal/hooks/focus-visible';
|
|
17
|
-
import { useMergeRefs } from '../internal/hooks/use-merge-refs';
|
|
18
|
-
import { useReducedMotion, useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
19
|
-
import { getVisualContextClassname } from '../internal/components/visual-context';
|
|
20
|
-
import styles from './styles.css.js';
|
|
21
|
-
export default function Flashbar(_a) {
|
|
22
|
-
var items = _a.items, restProps = __rest(_a, ["items"]);
|
|
23
|
-
var __internalRootRef = useBaseComponent('Flashbar').__internalRootRef;
|
|
24
|
-
var baseProps = getBaseProps(restProps);
|
|
25
|
-
var ref = useRef(null);
|
|
26
|
-
var _b = useContainerBreakpoints(['xs']), breakpoint = _b[0], breakpointRef = _b[1];
|
|
27
|
-
var mergedRef = useMergeRefs(ref, breakpointRef, __internalRootRef);
|
|
28
|
-
var isFocusVisible = useFocusVisible();
|
|
29
|
-
var isVisualRefresh = useVisualRefresh();
|
|
30
|
-
var _c = useState(items), previousItems = _c[0], setPreviousItems = _c[1];
|
|
31
|
-
var _d = useState(null), nextFocusId = _d[0], setNextFocusId = _d[1];
|
|
32
|
-
// Track new or removed item IDs in state to only trigger focus changes for newly added items.
|
|
33
|
-
// https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops
|
|
34
|
-
if (items) {
|
|
35
|
-
var newItems = items.filter(function (_a) {
|
|
36
|
-
var id = _a.id;
|
|
37
|
-
return id && !previousItems.some(function (item) { return item.id === id; });
|
|
38
|
-
});
|
|
39
|
-
var removedItems = previousItems.filter(function (_a) {
|
|
40
|
-
var id = _a.id;
|
|
41
|
-
return id && !items.some(function (item) { return item.id === id; });
|
|
42
|
-
});
|
|
43
|
-
if (newItems.length > 0 || removedItems.length > 0) {
|
|
44
|
-
setPreviousItems(items);
|
|
45
|
-
var newFocusItems = newItems.filter(function (_a) {
|
|
46
|
-
var ariaRole = _a.ariaRole;
|
|
47
|
-
return ariaRole === 'alert';
|
|
48
|
-
});
|
|
49
|
-
if (newFocusItems.length > 0) {
|
|
50
|
-
setNextFocusId(newFocusItems[0].id);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
6
|
+
import CollapsibleFlashbar from './collapsible-flashbar';
|
|
7
|
+
import NonCollapsibleFlashbar from './non-collapsible-flashbar';
|
|
8
|
+
import { sendRenderMetric } from './internal/analytics';
|
|
9
|
+
export default function Flashbar(props) {
|
|
54
10
|
useEffect(function () {
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
}, [nextFocusId]);
|
|
59
|
-
/**
|
|
60
|
-
* All the flash items should have ids so we can identify which DOM element is being
|
|
61
|
-
* removed from the DOM to animate it. Motion will be disabled if any of the provided
|
|
62
|
-
* flash messages does not contain an `id`.
|
|
63
|
-
*/
|
|
64
|
-
var motionDisabled = useReducedMotion(breakpointRef) || !isVisualRefresh || (items && !items.every(function (item) { return 'id' in item; }));
|
|
65
|
-
/**
|
|
66
|
-
* The `stackItems` property is a hidden boolean that allows for teams
|
|
67
|
-
* to beta test the flashbar stacking feature.
|
|
68
|
-
*/
|
|
69
|
-
var stackItems = isStackedFlashbar(restProps);
|
|
70
|
-
var ariaLabels = stackItems ? restProps.ariaLabels : {};
|
|
71
|
-
var isFlashbarStacked = stackItems && (items === null || items === void 0 ? void 0 : items.length) > 3;
|
|
72
|
-
var _e = useState(false), isFlashbarStackExpanded = _e[0], setIsFlashbarStackExpanded = _e[1];
|
|
73
|
-
/**
|
|
74
|
-
* Compute the appropriate aria label for the stacked notifications toggle button
|
|
75
|
-
* based on the expanded/collapsed state of the stack and the presence of
|
|
76
|
-
* corresponding aria label properties.
|
|
77
|
-
*/
|
|
78
|
-
function getStackButtonAriaLabel() {
|
|
79
|
-
var _a, _b;
|
|
80
|
-
var stackButtonAriaLabel;
|
|
81
|
-
if (isFlashbarStackExpanded) {
|
|
82
|
-
stackButtonAriaLabel = (_a = ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.stackCollapseLabel) !== null && _a !== void 0 ? _a : 'Collapse stacked notifications';
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
stackButtonAriaLabel = (_b = ariaLabels === null || ariaLabels === void 0 ? void 0 : ariaLabels.stackExpandLabel) !== null && _b !== void 0 ? _b : 'Expand stacked notifications';
|
|
86
|
-
}
|
|
87
|
-
return stackButtonAriaLabel;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* If the `isFlashbarStacked` is true (which is only possible if `stackItems` is true)
|
|
91
|
-
* then the first item should be rendered followed by two dummy items that visually indicate
|
|
92
|
-
* two, three, or more items exist in the stack.
|
|
93
|
-
*/
|
|
94
|
-
function renderStackedItems() {
|
|
95
|
-
var _a;
|
|
96
|
-
if (!isFlashbarStacked) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
var stackDepth = Math.min(3, items.length);
|
|
100
|
-
var stackedItems = items.slice(0, stackDepth);
|
|
101
|
-
return (React.createElement("div", { className: styles.stack, style: (_a = {}, _a[customCssProps.flashbarStackDepth] = stackDepth, _a) },
|
|
102
|
-
!isFlashbarStackExpanded && (React.createElement("div", { className: clsx(styles.collapsed, isVisualRefresh && styles['visual-refresh']) }, stackedItems.map(function (item, index) {
|
|
103
|
-
var _a;
|
|
104
|
-
var _b, _c;
|
|
105
|
-
return (React.createElement("div", { className: styles.item, style: (_a = {}, _a[customCssProps.flashbarStackIndex] = index, _a), key: index },
|
|
106
|
-
index === 0 && (React.createElement("ul", { className: styles['flash-list'] },
|
|
107
|
-
React.createElement("li", { className: styles['flash-list-item'] }, renderItem(item, (_b = item.id) !== null && _b !== void 0 ? _b : index)))),
|
|
108
|
-
index > 0 && React.createElement("div", { className: clsx(styles.flash, styles["flash-type-".concat((_c = item.type) !== null && _c !== void 0 ? _c : 'info')]) })));
|
|
109
|
-
}))),
|
|
110
|
-
isFlashbarStackExpanded && (React.createElement("ul", { className: clsx(styles['flash-list'], styles.expanded) }, items.map(function (item, index) {
|
|
111
|
-
var _a, _b;
|
|
112
|
-
return (React.createElement("li", { key: (_a = item.id) !== null && _a !== void 0 ? _a : index, className: styles['flash-list-item'] }, renderItem(item, (_b = item.id) !== null && _b !== void 0 ? _b : index)));
|
|
113
|
-
}))),
|
|
114
|
-
React.createElement("button", __assign({ "aria-label": getStackButtonAriaLabel(), className: clsx(styles.toggle, isVisualRefresh && styles['visual-refresh']), onClick: function () { return setIsFlashbarStackExpanded(!isFlashbarStackExpanded); } }, isFocusVisible),
|
|
115
|
-
React.createElement("span", { className: clsx(styles.icon, isFlashbarStackExpanded && styles.expanded) },
|
|
116
|
-
React.createElement(InternalIcon, { size: "small", name: "angle-down" })))));
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* If the flashbar is flat and motion is `enabled` then the adding and removing of items
|
|
120
|
-
* from the flashbar will render with visual transitions.
|
|
121
|
-
*/
|
|
122
|
-
function renderFlatItemsWithTransitions() {
|
|
123
|
-
if (isFlashbarStacked || motionDisabled || !items) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
return (
|
|
127
|
-
// This is a proxy for <ul>, so we're not applying a class to another actual component.
|
|
128
|
-
// eslint-disable-next-line react/forbid-component-props
|
|
129
|
-
React.createElement(TransitionGroup, { component: "ul", className: styles['flash-list'] }, items &&
|
|
130
|
-
items.map(function (item, index) {
|
|
131
|
-
var _a;
|
|
132
|
-
return (React.createElement(Transition, { transitionChangeDelay: { entering: TIMEOUT_FOR_ENTERING_ANIMATION }, key: (_a = item.id) !== null && _a !== void 0 ? _a : index, "in": true }, function (state, transitionRootElement) {
|
|
133
|
-
var _a;
|
|
134
|
-
return (React.createElement("li", { className: styles['flash-list-item'] }, renderItem(item, (_a = item.id) !== null && _a !== void 0 ? _a : index, transitionRootElement, state)));
|
|
135
|
-
}));
|
|
136
|
-
})));
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* If the flashbar is flat and motion is `disabled` then the adding and removing of items
|
|
140
|
-
* from the flashbar will render without visual transitions.
|
|
141
|
-
*/
|
|
142
|
-
function renderFlatItemsWithoutTransitions() {
|
|
143
|
-
if (isFlashbarStacked || !motionDisabled || !items) {
|
|
144
|
-
return;
|
|
11
|
+
if (props.items.length > 0) {
|
|
12
|
+
sendRenderMetric(props.items);
|
|
145
13
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
})));
|
|
14
|
+
}, [props.items]);
|
|
15
|
+
if (isStackedFlashbar(props)) {
|
|
16
|
+
return React.createElement(CollapsibleFlashbar, __assign({}, props));
|
|
150
17
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
* by the stacking, motion, and non-motion item group render functions.
|
|
154
|
-
*/
|
|
155
|
-
function renderItem(item, key, transitionRootElement, transitionState) {
|
|
156
|
-
return (React.createElement(Flash
|
|
157
|
-
// eslint-disable-next-line react/forbid-component-props
|
|
158
|
-
, __assign({
|
|
159
|
-
// eslint-disable-next-line react/forbid-component-props
|
|
160
|
-
className: clsx(getVisualContextClassname('flashbar'), isVisualRefresh ? styles['flash-refresh'] : ''), key: key, ref: transitionRootElement, transitionState: transitionState }, item)));
|
|
18
|
+
else {
|
|
19
|
+
return React.createElement(NonCollapsibleFlashbar, __assign({}, props));
|
|
161
20
|
}
|
|
162
|
-
return (React.createElement("div", __assign({}, baseProps, { className: clsx(baseProps.className, styles.flashbar, styles["breakpoint-".concat(breakpoint)]), ref: mergedRef }),
|
|
163
|
-
renderStackedItems(),
|
|
164
|
-
renderFlatItemsWithTransitions(),
|
|
165
|
-
renderFlatItemsWithoutTransitions()));
|
|
166
21
|
}
|
|
167
22
|
function isStackedFlashbar(props) {
|
|
168
|
-
return 'stackItems' in props &&
|
|
23
|
+
return 'stackItems' in props && props.stackItems;
|
|
169
24
|
}
|
|
170
25
|
applyDisplayName(Flashbar, 'Flashbar');
|
|
171
26
|
//# sourceMappingURL=index.js.map
|
package/flashbar/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/flashbar/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,cAAc,MAAM,6CAA6C,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,8BAA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BAAI,GAAG,EAAE,MAAA,IAAI,CAAC,EAAE,mCAAI,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC,IAC5D,UAAU,CAAC,IAAI,EAAE,MAAA,IAAI,CAAC,EAAE,mCAAI,KAAK,CAAC,CAChC,CACN,CAAA;SAAA,CAAC,CACC,CACN,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,SAAS,UAAU,CACjB,IAAqC,EACrC,GAAoB,EACpB,qBAA6D,EAC7D,eAAoC;QAEpC,OAAO,CACL,oBAAC,KAAK;QACJ,wDAAwD;;YAAxD,wDAAwD;YACxD,SAAS,EAAE,IAAI,CAAC,yBAAyB,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EACtG,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,qBAAqB,EAC1B,eAAe,EAAE,eAAe,IAC5B,IAAI,EACR,CACH,CAAC;IACJ,CAAC;IAED,OAAO,CACL,wCACM,SAAS,IACb,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,qBAAc,UAAU,CAAE,CAAC,CAAC,EACzF,GAAG,EAAE,SAAS;QAEb,kBAAkB,EAAE;QACpB,8BAA8B,EAAE;QAChC,iCAAiC,EAAE,CAChC,CACP,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAU;IACnC,OAAO,YAAY,IAAI,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;AACrD,CAAC;AAED,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport customCssProps from '../internal/generated/custom-css-properties';\nimport { Flash, focusFlashById } from './flash';\nimport { FlashbarProps, StackedFlashbarProps } from './interfaces';\nimport { getBaseProps } from '../internal/base-component';\nimport InternalIcon from '../icon/internal';\nimport { TIMEOUT_FOR_ENTERING_ANIMATION } from './constant';\nimport { TransitionGroup } from 'react-transition-group';\nimport { Transition } from '../internal/components/transition';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useContainerBreakpoints } from '../internal/hooks/container-queries';\nimport useFocusVisible from '../internal/hooks/focus-visible';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { useReducedMotion, useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { getVisualContextClassname } from '../internal/components/visual-context';\n\nimport styles from './styles.css.js';\n\nexport { FlashbarProps };\n\nexport default function Flashbar({ items, ...restProps }: FlashbarProps) {\n const { __internalRootRef } = useBaseComponent('Flashbar');\n const baseProps = getBaseProps(restProps);\n\n const ref = useRef<HTMLDivElement | null>(null);\n const [breakpoint, breakpointRef] = useContainerBreakpoints(['xs']);\n const mergedRef = useMergeRefs(ref, breakpointRef, __internalRootRef);\n\n const isFocusVisible = useFocusVisible();\n const isVisualRefresh = useVisualRefresh();\n\n const [previousItems, setPreviousItems] = useState<ReadonlyArray<FlashbarProps.MessageDefinition>>(items);\n const [nextFocusId, setNextFocusId] = useState<string | null>(null);\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 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]);\n\n /**\n * All the flash items should have ids so we can identify which DOM element is being\n * removed from the DOM to animate it. Motion will be disabled if any of the provided\n * flash messages does not contain an `id`.\n */\n const motionDisabled =\n useReducedMotion(breakpointRef as any) || !isVisualRefresh || (items && !items.every(item => 'id' in item));\n\n /**\n * The `stackItems` property is a hidden boolean that allows for teams\n * to beta test the flashbar stacking feature.\n */\n const stackItems = isStackedFlashbar(restProps);\n const ariaLabels = stackItems ? restProps.ariaLabels : {};\n const isFlashbarStacked = stackItems && items?.length > 3;\n const [isFlashbarStackExpanded, setIsFlashbarStackExpanded] = useState(false);\n\n /**\n * Compute the appropriate aria label for the stacked notifications toggle button\n * based on the expanded/collapsed state of the stack and the presence of\n * corresponding aria label properties.\n */\n function getStackButtonAriaLabel() {\n let stackButtonAriaLabel;\n\n if (isFlashbarStackExpanded) {\n stackButtonAriaLabel = ariaLabels?.stackCollapseLabel ?? 'Collapse stacked notifications';\n } else {\n stackButtonAriaLabel = ariaLabels?.stackExpandLabel ?? 'Expand stacked notifications';\n }\n\n return stackButtonAriaLabel;\n }\n\n /**\n * If the `isFlashbarStacked` is true (which is only possible if `stackItems` is true)\n * then the first item should be rendered followed by two dummy items that visually indicate\n * two, three, or more items exist in the stack.\n */\n function renderStackedItems() {\n if (!isFlashbarStacked) {\n return;\n }\n\n const stackDepth = Math.min(3, items.length);\n const stackedItems = items.slice(0, stackDepth);\n\n return (\n <div className={styles.stack} style={{ [customCssProps.flashbarStackDepth]: stackDepth }}>\n {!isFlashbarStackExpanded && (\n <div className={clsx(styles.collapsed, isVisualRefresh && styles['visual-refresh'])}>\n {stackedItems.map((item, index) => (\n <div className={styles.item} style={{ [customCssProps.flashbarStackIndex]: index }} key={index}>\n {index === 0 && (\n <ul className={styles['flash-list']}>\n <li className={styles['flash-list-item']}>{renderItem(item, item.id ?? index)}</li>\n </ul>\n )}\n {index > 0 && <div className={clsx(styles.flash, styles[`flash-type-${item.type ?? 'info'}`])} />}\n </div>\n ))}\n </div>\n )}\n\n {isFlashbarStackExpanded && (\n <ul className={clsx(styles['flash-list'], styles.expanded)}>\n {items.map((item, index) => (\n <li key={item.id ?? index} className={styles['flash-list-item']}>\n {renderItem(item, item.id ?? index)}\n </li>\n ))}\n </ul>\n )}\n\n <button\n aria-label={getStackButtonAriaLabel()}\n className={clsx(styles.toggle, isVisualRefresh && styles['visual-refresh'])}\n onClick={() => setIsFlashbarStackExpanded(!isFlashbarStackExpanded)}\n {...isFocusVisible}\n >\n <span className={clsx(styles.icon, isFlashbarStackExpanded && styles.expanded)}>\n <InternalIcon size=\"small\" name=\"angle-down\" />\n </span>\n </button>\n </div>\n );\n }\n\n /**\n * If the flashbar is flat and motion is `enabled` then the adding and removing of items\n * from the flashbar will render with visual transitions.\n */\n function renderFlatItemsWithTransitions() {\n if (isFlashbarStacked || motionDisabled || !items) {\n return;\n }\n\n return (\n // This is a proxy for <ul>, so we're not applying a class to another actual component.\n // eslint-disable-next-line react/forbid-component-props\n <TransitionGroup component=\"ul\" className={styles['flash-list']}>\n {items &&\n items.map((item, index) => (\n <Transition\n transitionChangeDelay={{ entering: TIMEOUT_FOR_ENTERING_ANIMATION }}\n key={item.id ?? index}\n in={true}\n >\n {(state: string, transitionRootElement: React.Ref<HTMLDivElement> | undefined) => (\n <li className={styles['flash-list-item']}>\n {renderItem(item, item.id ?? index, transitionRootElement, state)}\n </li>\n )}\n </Transition>\n ))}\n </TransitionGroup>\n );\n }\n\n /**\n * If the flashbar is flat and motion is `disabled` then the adding and removing of items\n * from the flashbar will render without visual transitions.\n */\n function renderFlatItemsWithoutTransitions() {\n if (isFlashbarStacked || !motionDisabled || !items) {\n return;\n }\n\n return (\n <ul className={styles['flash-list']}>\n {items.map((item, index) => (\n <li key={item.id ?? index} className={styles['flash-list-item']}>\n {renderItem(item, item.id ?? index)}\n </li>\n ))}\n </ul>\n );\n }\n\n /**\n * This is a shared render function for a single flashbar item to be used\n * by the stacking, motion, and non-motion item group render functions.\n */\n function renderItem(\n item: FlashbarProps.MessageDefinition,\n key: string | number,\n transitionRootElement?: React.Ref<HTMLDivElement> | undefined,\n transitionState?: string | undefined\n ) {\n return (\n <Flash\n // eslint-disable-next-line react/forbid-component-props\n className={clsx(getVisualContextClassname('flashbar'), isVisualRefresh ? styles['flash-refresh'] : '')}\n key={key}\n ref={transitionRootElement}\n transitionState={transitionState}\n {...item}\n />\n );\n }\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.flashbar, styles[`breakpoint-${breakpoint}`])}\n ref={mergedRef}\n >\n {renderStackedItems()}\n {renderFlatItemsWithTransitions()}\n {renderFlatItemsWithoutTransitions()}\n </div>\n );\n}\n\nfunction isStackedFlashbar(props: any): props is StackedFlashbarProps {\n return 'stackItems' in props && !!props.stackItems;\n}\n\napplyDisplayName(Flashbar, 'Flashbar');\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/flashbar/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,mBAAmB,MAAM,wBAAwB,CAAC;AACzD,OAAO,sBAAsB,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAIxD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,KAA+C;IAC9E,SAAS,CAAC;QACR,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC/B;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAElB,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE;QAC5B,OAAO,oBAAC,mBAAmB,eAAK,KAAK,EAAI,CAAC;KAC3C;SAAM;QACL,OAAO,oBAAC,sBAAsB,eAAK,KAAK,EAAI,CAAC;KAC9C;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAU;IACnC,OAAO,YAAY,IAAI,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC;AACnD,CAAC;AAED,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect } from 'react';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { FlashbarProps, CollapsibleFlashbarProps } from './interfaces';\nimport CollapsibleFlashbar from './collapsible-flashbar';\nimport NonCollapsibleFlashbar from './non-collapsible-flashbar';\n\nimport { sendRenderMetric } from './internal/analytics';\n\nexport { FlashbarProps };\n\nexport default function Flashbar(props: FlashbarProps | CollapsibleFlashbarProps) {\n useEffect(() => {\n if (props.items.length > 0) {\n sendRenderMetric(props.items);\n }\n }, [props.items]);\n\n if (isStackedFlashbar(props)) {\n return <CollapsibleFlashbar {...props} />;\n } else {\n return <NonCollapsibleFlashbar {...props} />;\n }\n}\n\nfunction isStackedFlashbar(props: any): props is CollapsibleFlashbarProps {\n return 'stackItems' in props && props.stackItems;\n}\n\napplyDisplayName(Flashbar, 'Flashbar');\n"]}
|
package/flashbar/interfaces.d.ts
CHANGED
|
@@ -50,15 +50,22 @@ export interface FlashbarProps extends BaseComponentProps {
|
|
|
50
50
|
*/
|
|
51
51
|
items: ReadonlyArray<FlashbarProps.MessageDefinition>;
|
|
52
52
|
}
|
|
53
|
-
export
|
|
54
|
-
|
|
55
|
-
ariaLabels?: StackedFlashbarProps.AriaLabels;
|
|
53
|
+
export type FlashType = FlashbarProps.Type | 'progress';
|
|
54
|
+
export interface CollapsibleFlashbarProps {
|
|
56
55
|
items: ReadonlyArray<FlashbarProps.MessageDefinition>;
|
|
56
|
+
stackItems: boolean;
|
|
57
|
+
i18nStrings?: CollapsibleFlashbarProps.I18nStrings;
|
|
57
58
|
}
|
|
58
|
-
export declare namespace
|
|
59
|
-
interface
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
export declare namespace CollapsibleFlashbarProps {
|
|
60
|
+
interface I18nStrings {
|
|
61
|
+
ariaLabel: string;
|
|
62
|
+
toggleButtonAriaLabel: string;
|
|
63
|
+
toggleButtonText: string;
|
|
64
|
+
errorCountAriaLabel?: string;
|
|
65
|
+
warningCountAriaLabel?: string;
|
|
66
|
+
successCountAriaLabel?: string;
|
|
67
|
+
infoCountAriaLabel?: string;
|
|
68
|
+
inProgressCountAriaLabel?: string;
|
|
62
69
|
}
|
|
63
70
|
}
|
|
64
71
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/flashbar/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,yBAAiB,aAAa,CAAC;IAC7B,UAAiB,iBAAiB;QAChC,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QACzB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,IAAI,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC;QAC1B,QAAQ,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC;QAClC,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QACzB,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,UAAU,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,C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,SAAS,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;KACpC;IAED,KAAY,IAAI,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;IAC5D,KAAY,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;CAC3C;AAED,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACvD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;CACvD;AAED,MAAM,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,GAAG,UAAU,CAAC;AAExD,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACtD,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,wBAAwB,CAAC,WAAW,CAAC;CACpD;AAED,yBAAiB,wBAAwB,CAAC;IACxC,UAAiB,WAAW;QAC1B,SAAS,EAAE,MAAM,CAAC;QAClB,qBAAqB,EAAE,MAAM,CAAC;QAC9B,gBAAgB,EAAE,MAAM,CAAC;QACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,wBAAwB,CAAC,EAAE,MAAM,CAAC;KACnC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/flashbar/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport React from 'react';\nimport { ButtonProps } from '../button/interfaces';\n\nexport namespace FlashbarProps {\n export interface MessageDefinition {\n header?: React.ReactNode;\n content?: React.ReactNode;\n dismissible?: boolean;\n dismissLabel?: string;\n statusIconAriaLabel?: string;\n loading?: boolean;\n type?: FlashbarProps.Type;\n ariaRole?: FlashbarProps.AriaRole;\n action?: React.ReactNode;\n id?: string;\n buttonText?: ButtonProps['children'];\n onButtonClick?: ButtonProps['onClick'];\n onDismiss?: ButtonProps['onClick'];\n }\n\n export type Type = 'success' | 'warning' | 'info' | 'error';\n export type AriaRole = 'alert' | 'status';\n}\n\nexport interface FlashbarProps extends BaseComponentProps {\n /**\n * Specifies flash messages that appear in the same order that they are listed.\n * The value is an array of flash message definition objects.\n *\n * A flash message object contains the following properties:\n * * `header` (ReactNode) - Specifies the heading text.\n * * `content` (ReactNode) - Specifies the primary text displayed in the flash element.\n * * `type` (string) - Indicates the type of the message to be displayed. Allowed values are as follows: `success, error, warning, info`. The default is `info`.\n * * `loading` (boolean) - Replaces the status icon with a spinner and forces the type to `info`.\n * * `dismissible` (boolean) - Determines whether the component includes a close button icon. By default, the close button is not included.\n * When a user clicks on this button the `onDismiss` handler is called.\n * * `dismissLabel` (string) - Specifies an `aria-label` for to the dismiss icon button for improved accessibility.\n * * `statusIconAriaLabel` (string) - Specifies an `aria-label` for to the status icon for improved accessibility.\n * * `ariaRole` (string) - For flash messages added after page load, specifies how this message is communicated to assistive\n * technology. Use \"status\" for status updates or informational content. Use \"alert\" for important messages that need the\n * user's attention.\n * * `action` (ReactNode) - Specifies an action for the flash message. Although it is technically possible to insert any content,\n * our UX guidelines only allow you to add a button.\n * * `buttonText` (string) - Specifies that an action button should be displayed, with the specified text.\n * When a user clicks on this button the `onButtonClick` handler is called.\n * If the `action` property is set, this property is ignored. **Deprecated**, replaced by `action`.\n * * `onButtonClick` (event => void) - Called when a user clicks on the action button. This is not called if you create a custom button\n * using the `action` property. **Deprecated**, replaced by `action`.\n * * `id` (string) - Specifies a unique flash message identifier. This property is used in two ways:\n * 1. As a [keys](https://reactjs.org/docs/lists-and-keys.html#keys) source for React rendering.\n * 2. To identify which flash message will be removed from the DOM when it is dismissed, to animate it out.\n */\n items: ReadonlyArray<FlashbarProps.MessageDefinition>;\n}\n\nexport interface
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/flashbar/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport React from 'react';\nimport { ButtonProps } from '../button/interfaces';\n\nexport namespace FlashbarProps {\n export interface MessageDefinition {\n header?: React.ReactNode;\n content?: React.ReactNode;\n dismissible?: boolean;\n dismissLabel?: string;\n statusIconAriaLabel?: string;\n loading?: boolean;\n type?: FlashbarProps.Type;\n ariaRole?: FlashbarProps.AriaRole;\n action?: React.ReactNode;\n id?: string;\n buttonText?: ButtonProps['children'];\n onButtonClick?: ButtonProps['onClick'];\n onDismiss?: ButtonProps['onClick'];\n }\n\n export type Type = 'success' | 'warning' | 'info' | 'error';\n export type AriaRole = 'alert' | 'status';\n}\n\nexport interface FlashbarProps extends BaseComponentProps {\n /**\n * Specifies flash messages that appear in the same order that they are listed.\n * The value is an array of flash message definition objects.\n *\n * A flash message object contains the following properties:\n * * `header` (ReactNode) - Specifies the heading text.\n * * `content` (ReactNode) - Specifies the primary text displayed in the flash element.\n * * `type` (string) - Indicates the type of the message to be displayed. Allowed values are as follows: `success, error, warning, info`. The default is `info`.\n * * `loading` (boolean) - Replaces the status icon with a spinner and forces the type to `info`.\n * * `dismissible` (boolean) - Determines whether the component includes a close button icon. By default, the close button is not included.\n * When a user clicks on this button the `onDismiss` handler is called.\n * * `dismissLabel` (string) - Specifies an `aria-label` for to the dismiss icon button for improved accessibility.\n * * `statusIconAriaLabel` (string) - Specifies an `aria-label` for to the status icon for improved accessibility.\n * * `ariaRole` (string) - For flash messages added after page load, specifies how this message is communicated to assistive\n * technology. Use \"status\" for status updates or informational content. Use \"alert\" for important messages that need the\n * user's attention.\n * * `action` (ReactNode) - Specifies an action for the flash message. Although it is technically possible to insert any content,\n * our UX guidelines only allow you to add a button.\n * * `buttonText` (string) - Specifies that an action button should be displayed, with the specified text.\n * When a user clicks on this button the `onButtonClick` handler is called.\n * If the `action` property is set, this property is ignored. **Deprecated**, replaced by `action`.\n * * `onButtonClick` (event => void) - Called when a user clicks on the action button. This is not called if you create a custom button\n * using the `action` property. **Deprecated**, replaced by `action`.\n * * `id` (string) - Specifies a unique flash message identifier. This property is used in two ways:\n * 1. As a [keys](https://reactjs.org/docs/lists-and-keys.html#keys) source for React rendering.\n * 2. To identify which flash message will be removed from the DOM when it is dismissed, to animate it out.\n */\n items: ReadonlyArray<FlashbarProps.MessageDefinition>;\n}\n\nexport type FlashType = FlashbarProps.Type | 'progress';\n\nexport interface CollapsibleFlashbarProps {\n items: ReadonlyArray<FlashbarProps.MessageDefinition>;\n stackItems: boolean;\n i18nStrings?: CollapsibleFlashbarProps.I18nStrings;\n}\n\nexport namespace CollapsibleFlashbarProps {\n export interface I18nStrings {\n ariaLabel: string;\n toggleButtonAriaLabel: string;\n toggleButtonText: string;\n errorCountAriaLabel?: string;\n warningCountAriaLabel?: string;\n successCountAriaLabel?: string;\n infoCountAriaLabel?: string;\n inProgressCountAriaLabel?: string;\n }\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FlashbarProps } from '../interfaces';
|
|
2
|
+
export declare const sendRenderMetric: (items: FlashbarProps['items']) => void;
|
|
3
|
+
export declare const sendToggleMetric: (itemsCount: number, expanded: boolean) => void;
|
|
4
|
+
export declare const sendDismissMetric: (itemType: string) => void;
|
|
5
|
+
//# sourceMappingURL=analytics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../../src/flashbar/internal/analytics.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK9C,eAAO,MAAM,gBAAgB,UAAW,aAAa,CAAC,OAAO,CAAC,SAS7D,CAAC;AAEF,eAAO,MAAM,gBAAgB,eAAgB,MAAM,YAAY,OAAO,SAMrE,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAc,MAAM,SAMjD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Metrics } from '../../internal/metrics';
|
|
4
|
+
import { getFlashTypeCount } from '../utils';
|
|
5
|
+
var eventContext = 'csa_flashbar';
|
|
6
|
+
export var sendRenderMetric = function (items) {
|
|
7
|
+
var countByType = getFlashTypeCount(items);
|
|
8
|
+
Metrics.sendPanoramaMetric({
|
|
9
|
+
eventContext: eventContext,
|
|
10
|
+
eventType: 'render',
|
|
11
|
+
eventValue: items.length.toString(),
|
|
12
|
+
eventDetail: countByType
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
export var sendToggleMetric = function (itemsCount, expanded) {
|
|
16
|
+
Metrics.sendPanoramaMetric({
|
|
17
|
+
eventContext: eventContext,
|
|
18
|
+
eventType: expanded ? 'expand' : 'collapse',
|
|
19
|
+
eventValue: itemsCount.toString()
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export var sendDismissMetric = function (itemType) {
|
|
23
|
+
Metrics.sendPanoramaMetric({
|
|
24
|
+
eventContext: eventContext,
|
|
25
|
+
eventType: 'dismiss',
|
|
26
|
+
eventValue: itemType
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=analytics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../../../src/flashbar/internal/analytics.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,IAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,MAAM,CAAC,IAAM,gBAAgB,GAAG,UAAC,KAA6B;IAC5D,IAAM,WAAW,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAE7C,OAAO,CAAC,kBAAkB,CAAC;QACzB,YAAY,cAAA;QACZ,SAAS,EAAE,QAAQ;QACnB,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE;QACnC,WAAW,EAAE,WAAW;KACzB,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,gBAAgB,GAAG,UAAC,UAAkB,EAAE,QAAiB;IACpE,OAAO,CAAC,kBAAkB,CAAC;QACzB,YAAY,cAAA;QACZ,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU;QAC3C,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE;KAClC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,iBAAiB,GAAG,UAAC,QAAgB;IAChD,OAAO,CAAC,kBAAkB,CAAC;QACzB,YAAY,cAAA;QACZ,SAAS,EAAE,SAAS;QACpB,UAAU,EAAE,QAAQ;KACrB,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Metrics } from '../../internal/metrics';\nimport { FlashbarProps } from '../interfaces';\nimport { getFlashTypeCount } from '../utils';\n\nconst eventContext = 'csa_flashbar';\n\nexport const sendRenderMetric = (items: FlashbarProps['items']) => {\n const countByType = getFlashTypeCount(items);\n\n Metrics.sendPanoramaMetric({\n eventContext,\n eventType: 'render',\n eventValue: items.length.toString(),\n eventDetail: countByType,\n });\n};\n\nexport const sendToggleMetric = (itemsCount: number, expanded: boolean) => {\n Metrics.sendPanoramaMetric({\n eventContext,\n eventType: expanded ? 'expand' : 'collapse',\n eventValue: itemsCount.toString(),\n });\n};\n\nexport const sendDismissMetric = (itemType: string) => {\n Metrics.sendPanoramaMetric({\n eventContext,\n eventType: 'dismiss',\n eventValue: itemType,\n });\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-collapsible-flashbar.d.ts","sourceRoot":"","sources":["../../../src/flashbar/non-collapsible-flashbar.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAS7C,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,EAAE,aAAa,eAqGpF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { Flash } from './flash';
|
|
7
|
+
import { TIMEOUT_FOR_ENTERING_ANIMATION } from './constant';
|
|
8
|
+
import { TransitionGroup } from 'react-transition-group';
|
|
9
|
+
import { Transition } from '../internal/components/transition';
|
|
10
|
+
import { getVisualContextClassname } from '../internal/components/visual-context';
|
|
11
|
+
import styles from './styles.css.js';
|
|
12
|
+
import { useFlashbar } from './common';
|
|
13
|
+
export default function NonCollapsibleFlashbar(_a) {
|
|
14
|
+
var items = _a.items, restProps = __rest(_a, ["items"]);
|
|
15
|
+
var _b = useFlashbar(__assign({ items: items }, restProps)), allItemsHaveId = _b.allItemsHaveId, baseProps = _b.baseProps, breakpoint = _b.breakpoint, isReducedMotion = _b.isReducedMotion, isVisualRefresh = _b.isVisualRefresh, mergedRef = _b.mergedRef;
|
|
16
|
+
/**
|
|
17
|
+
* All the flash items should have ids so we can identify which DOM element is being
|
|
18
|
+
* removed from the DOM to animate it. Motion will be disabled if any of the provided
|
|
19
|
+
* flash messages does not contain an `id`.
|
|
20
|
+
*/
|
|
21
|
+
var motionDisabled = isReducedMotion || !isVisualRefresh || !allItemsHaveId;
|
|
22
|
+
var animateFlash = !isReducedMotion && isVisualRefresh;
|
|
23
|
+
/**
|
|
24
|
+
* If the flashbar is flat and motion is `enabled` then the adding and removing of items
|
|
25
|
+
* from the flashbar will render with visual transitions.
|
|
26
|
+
*/
|
|
27
|
+
function renderFlatItemsWithTransitions() {
|
|
28
|
+
if (motionDisabled || !items) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
return (
|
|
32
|
+
// This is a proxy for <ul>, so we're not applying a class to another actual component.
|
|
33
|
+
// eslint-disable-next-line react/forbid-component-props
|
|
34
|
+
React.createElement(TransitionGroup, { component: "ul", className: styles['flash-list'] }, items.map(function (item, index) {
|
|
35
|
+
var _a;
|
|
36
|
+
return (React.createElement(Transition, { transitionChangeDelay: { entering: TIMEOUT_FOR_ENTERING_ANIMATION }, key: (_a = item.id) !== null && _a !== void 0 ? _a : index, "in": true }, function (state, transitionRootElement) {
|
|
37
|
+
var _a;
|
|
38
|
+
return (React.createElement("li", { className: styles['flash-list-item'] }, renderItem(item, (_a = item.id) !== null && _a !== void 0 ? _a : index, transitionRootElement, state)));
|
|
39
|
+
}));
|
|
40
|
+
})));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* If the flashbar is flat and motion is `disabled` then the adding and removing of items
|
|
44
|
+
* from the flashbar will render without visual transitions.
|
|
45
|
+
*/
|
|
46
|
+
function renderFlatItemsWithoutTransitions() {
|
|
47
|
+
if (!motionDisabled || !items) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
return (React.createElement("ul", { className: styles['flash-list'] }, items.map(function (item, index) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
return (React.createElement("li", { key: (_a = item.id) !== null && _a !== void 0 ? _a : index, className: styles['flash-list-item'] }, renderItem(item, (_b = item.id) !== null && _b !== void 0 ? _b : index)));
|
|
53
|
+
})));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* This is a shared render function for a single flashbar item to be used
|
|
57
|
+
* by the stacking, motion, and non-motion item group render functions.
|
|
58
|
+
*/
|
|
59
|
+
function renderItem(item, key, transitionRootElement, transitionState) {
|
|
60
|
+
return (React.createElement(Flash
|
|
61
|
+
// eslint-disable-next-line react/forbid-component-props
|
|
62
|
+
, __assign({
|
|
63
|
+
// eslint-disable-next-line react/forbid-component-props
|
|
64
|
+
className: clsx(getVisualContextClassname('flashbar'), animateFlash && styles['flash-with-motion'], isVisualRefresh && styles['flash-refresh']), key: key, ref: transitionRootElement, transitionState: transitionState }, item)));
|
|
65
|
+
}
|
|
66
|
+
return (React.createElement("div", __assign({}, baseProps, { className: clsx(baseProps.className, styles.flashbar, styles["breakpoint-".concat(breakpoint)]), ref: mergedRef }),
|
|
67
|
+
renderFlatItemsWithTransitions(),
|
|
68
|
+
renderFlatItemsWithoutTransitions()));
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=non-collapsible-flashbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-collapsible-flashbar.js","sourceRoot":"","sources":["../../../src/flashbar/non-collapsible-flashbar.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAElF,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,WAA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c,IAAI,CAAC,KAAK,EAAE;YAC7B,OAAO;SACR;QAED,OAAO,CACL,4BAAI,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC,IAChC,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,KAAK;;YAAK,OAAA,CAC1B,4BAAI,GAAG,EAAE,MAAA,IAAI,CAAC,EAAE,mCAAI,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC,IAC5D,UAAU,CAAC,IAAI,EAAE,MAAA,IAAI,CAAC,EAAE,mCAAI,KAAK,CAAC,CAChC,CACN,CAAA;SAAA,CAAC,CACC,CACN,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,SAAS,UAAU,CACjB,IAAqC,EACrC,GAAoB,EACpB,qBAA6D,EAC7D,eAAoC;QAEpC,OAAO,CACL,oBAAC,KAAK;QACJ,wDAAwD;;YAAxD,wDAAwD;YACxD,SAAS,EAAE,IAAI,CACb,yBAAyB,CAAC,UAAU,CAAC,EACrC,YAAY,IAAI,MAAM,CAAC,mBAAmB,CAAC,EAC3C,eAAe,IAAI,MAAM,CAAC,eAAe,CAAC,CAC3C,EACD,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,qBAAqB,EAC1B,eAAe,EAAE,eAAe,IAC5B,IAAI,EACR,CACH,CAAC;IACJ,CAAC;IAED,OAAO,CACL,wCACM,SAAS,IACb,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,qBAAc,UAAU,CAAE,CAAC,CAAC,EACzF,GAAG,EAAE,SAAS;QAEb,8BAA8B,EAAE;QAChC,iCAAiC,EAAE,CAChC,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React from 'react';\nimport { Flash } from './flash';\nimport { FlashbarProps } from './interfaces';\nimport { TIMEOUT_FOR_ENTERING_ANIMATION } from './constant';\nimport { TransitionGroup } from 'react-transition-group';\nimport { Transition } from '../internal/components/transition';\nimport { getVisualContextClassname } from '../internal/components/visual-context';\n\nimport styles from './styles.css.js';\nimport { useFlashbar } from './common';\n\nexport { FlashbarProps };\n\nexport default function NonCollapsibleFlashbar({ items, ...restProps }: FlashbarProps) {\n const { allItemsHaveId, baseProps, breakpoint, isReducedMotion, isVisualRefresh, mergedRef } = useFlashbar({\n items,\n ...restProps,\n });\n\n /**\n * All the flash items should have ids so we can identify which DOM element is being\n * removed from the DOM to animate it. Motion will be disabled if any of the provided\n * flash messages does not contain an `id`.\n */\n const motionDisabled = isReducedMotion || !isVisualRefresh || !allItemsHaveId;\n\n const animateFlash = !isReducedMotion && isVisualRefresh;\n\n /**\n * If the flashbar is flat and motion is `enabled` then the adding and removing of items\n * from the flashbar will render with visual transitions.\n */\n function renderFlatItemsWithTransitions() {\n if (motionDisabled || !items) {\n return;\n }\n\n return (\n // This is a proxy for <ul>, so we're not applying a class to another actual component.\n // eslint-disable-next-line react/forbid-component-props\n <TransitionGroup component=\"ul\" className={styles['flash-list']}>\n {items.map((item, index) => (\n <Transition\n transitionChangeDelay={{ entering: TIMEOUT_FOR_ENTERING_ANIMATION }}\n key={item.id ?? index}\n in={true}\n >\n {(state: string, transitionRootElement: React.Ref<HTMLDivElement> | undefined) => (\n <li className={styles['flash-list-item']}>\n {renderItem(item, item.id ?? index, transitionRootElement, state)}\n </li>\n )}\n </Transition>\n ))}\n </TransitionGroup>\n );\n }\n\n /**\n * If the flashbar is flat and motion is `disabled` then the adding and removing of items\n * from the flashbar will render without visual transitions.\n */\n function renderFlatItemsWithoutTransitions() {\n if (!motionDisabled || !items) {\n return;\n }\n\n return (\n <ul className={styles['flash-list']}>\n {items.map((item, index) => (\n <li key={item.id ?? index} className={styles['flash-list-item']}>\n {renderItem(item, item.id ?? index)}\n </li>\n ))}\n </ul>\n );\n }\n\n /**\n * This is a shared render function for a single flashbar item to be used\n * by the stacking, motion, and non-motion item group render functions.\n */\n function renderItem(\n item: FlashbarProps.MessageDefinition,\n key: string | number,\n transitionRootElement?: React.Ref<HTMLDivElement> | undefined,\n transitionState?: string | undefined\n ) {\n return (\n <Flash\n // eslint-disable-next-line react/forbid-component-props\n className={clsx(\n getVisualContextClassname('flashbar'),\n animateFlash && styles['flash-with-motion'],\n isVisualRefresh && styles['flash-refresh']\n )}\n key={key}\n ref={transitionRootElement}\n transitionState={transitionState}\n {...item}\n />\n );\n }\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.flashbar, styles[`breakpoint-${breakpoint}`])}\n ref={mergedRef}\n >\n {renderFlatItemsWithTransitions()}\n {renderFlatItemsWithoutTransitions()}\n </div>\n );\n}\n"]}
|