@cloudscape-design/components 3.0.349 → 3.0.351

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.
@@ -2,74 +2,74 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "background": "awsui_background_hyvsj_1g2nk_93",
6
- "scrolling-background": "awsui_scrolling-background_hyvsj_1g2nk_96",
7
- "sticky-background": "awsui_sticky-background_hyvsj_1g2nk_102",
8
- "has-sticky-notifications": "awsui_has-sticky-notifications_hyvsj_1g2nk_110",
9
- "breadcrumbs": "awsui_breadcrumbs_hyvsj_1g2nk_123",
10
- "has-sticky-background": "awsui_has-sticky-background_hyvsj_1g2nk_133",
11
- "drawers-container": "awsui_drawers-container_hyvsj_1g2nk_145",
12
- "has-open-drawer": "awsui_has-open-drawer_hyvsj_1g2nk_157",
13
- "disable-body-scroll": "awsui_disable-body-scroll_hyvsj_1g2nk_191",
14
- "drawers-desktop-triggers-container": "awsui_drawers-desktop-triggers-container_hyvsj_1g2nk_196",
15
- "has-multiple-triggers": "awsui_has-multiple-triggers_hyvsj_1g2nk_215",
16
- "drawers-trigger-content": "awsui_drawers-trigger-content_hyvsj_1g2nk_247",
17
- "drawers-trigger": "awsui_drawers-trigger_hyvsj_1g2nk_247",
18
- "drawer": "awsui_drawer_hyvsj_1g2nk_145",
19
- "drawer-close-button": "awsui_drawer-close-button_hyvsj_1g2nk_297",
20
- "drawer-content": "awsui_drawer-content_hyvsj_1g2nk_302",
21
- "drawer-slider": "awsui_drawer-slider_hyvsj_1g2nk_307",
22
- "is-drawer-open": "awsui_is-drawer-open_hyvsj_1g2nk_314",
23
- "content": "awsui_content_hyvsj_1g2nk_339",
24
- "layout": "awsui_layout_hyvsj_1g2nk_360",
25
- "has-max-content-width": "awsui_has-max-content-width_hyvsj_1g2nk_443",
26
- "content-type-dashboard": "awsui_content-type-dashboard_hyvsj_1g2nk_458",
27
- "is-overlap-disabled": "awsui_is-overlap-disabled_hyvsj_1g2nk_475",
28
- "has-content-gap-left": "awsui_has-content-gap-left_hyvsj_1g2nk_507",
29
- "has-content-gap-right": "awsui_has-content-gap-right_hyvsj_1g2nk_510",
30
- "content-first-child-notifications": "awsui_content-first-child-notifications_hyvsj_1g2nk_520",
31
- "has-breadcrumbs": "awsui_has-breadcrumbs_hyvsj_1g2nk_523",
32
- "content-first-child-header": "awsui_content-first-child-header_hyvsj_1g2nk_526",
33
- "has-header": "awsui_has-header_hyvsj_1g2nk_526",
34
- "content-first-child-main": "awsui_content-first-child-main_hyvsj_1g2nk_547",
35
- "disable-content-paddings": "awsui_disable-content-paddings_hyvsj_1g2nk_547",
36
- "has-split-panel": "awsui_has-split-panel_hyvsj_1g2nk_590",
37
- "split-panel-position-bottom": "awsui_split-panel-position-bottom_hyvsj_1g2nk_590",
38
- "block-body-scroll": "awsui_block-body-scroll_hyvsj_1g2nk_606",
39
- "unfocusable": "awsui_unfocusable_hyvsj_1g2nk_611",
40
- "container": "awsui_container_hyvsj_1g2nk_621",
41
- "is-navigation-open": "awsui_is-navigation-open_hyvsj_1g2nk_646",
42
- "is-tools-open": "awsui_is-tools-open_hyvsj_1g2nk_649",
43
- "is-split-panel-open": "awsui_is-split-panel-open_hyvsj_1g2nk_649",
44
- "split-panel-position-side": "awsui_split-panel-position-side_hyvsj_1g2nk_649",
45
- "mobile-toolbar": "awsui_mobile-toolbar_hyvsj_1g2nk_658",
46
- "mobile-toolbar-nav": "awsui_mobile-toolbar-nav_hyvsj_1g2nk_674",
47
- "mobile-toolbar-breadcrumbs": "awsui_mobile-toolbar-breadcrumbs_hyvsj_1g2nk_678",
48
- "mobile-toolbar-tools": "awsui_mobile-toolbar-tools_hyvsj_1g2nk_682",
49
- "navigation-container": "awsui_navigation-container_hyvsj_1g2nk_691",
50
- "show-navigation": "awsui_show-navigation_hyvsj_1g2nk_735",
51
- "animating": "awsui_animating_hyvsj_1g2nk_757",
52
- "showButtons": "awsui_showButtons_hyvsj_1g2nk_1",
53
- "navigation": "awsui_navigation_hyvsj_1g2nk_691",
54
- "openNavigation": "awsui_openNavigation_hyvsj_1g2nk_1",
55
- "animated-content": "awsui_animated-content_hyvsj_1g2nk_819",
56
- "hide-navigation": "awsui_hide-navigation_hyvsj_1g2nk_828",
57
- "notifications": "awsui_notifications_hyvsj_1g2nk_838",
58
- "sticky-notifications": "awsui_sticky-notifications_hyvsj_1g2nk_844",
59
- "split-panel-bottom": "awsui_split-panel-bottom_hyvsj_1g2nk_861",
60
- "position-bottom": "awsui_position-bottom_hyvsj_1g2nk_907",
61
- "openSplitPanelBottom": "awsui_openSplitPanelBottom_hyvsj_1g2nk_1",
62
- "split-panel-side": "awsui_split-panel-side_hyvsj_1g2nk_936",
63
- "position-side": "awsui_position-side_hyvsj_1g2nk_964",
64
- "openSplitPanelSide": "awsui_openSplitPanelSide_hyvsj_1g2nk_1",
65
- "tools-container": "awsui_tools-container_hyvsj_1g2nk_1001",
66
- "tools": "awsui_tools_hyvsj_1g2nk_1001",
67
- "openTools": "awsui_openTools_hyvsj_1g2nk_1",
68
- "has-tools-form-persistence": "awsui_has-tools-form-persistence_hyvsj_1g2nk_1096",
69
- "hide-tools": "awsui_hide-tools_hyvsj_1g2nk_1106",
70
- "show-tools": "awsui_show-tools_hyvsj_1g2nk_1118",
71
- "has-tools-form": "awsui_has-tools-form_hyvsj_1g2nk_1096",
72
- "trigger": "awsui_trigger_hyvsj_1g2nk_1185",
73
- "selected": "awsui_selected_hyvsj_1g2nk_1224"
5
+ "background": "awsui_background_hyvsj_11pcv_93",
6
+ "scrolling-background": "awsui_scrolling-background_hyvsj_11pcv_96",
7
+ "sticky-background": "awsui_sticky-background_hyvsj_11pcv_102",
8
+ "has-sticky-notifications": "awsui_has-sticky-notifications_hyvsj_11pcv_110",
9
+ "breadcrumbs": "awsui_breadcrumbs_hyvsj_11pcv_123",
10
+ "has-sticky-background": "awsui_has-sticky-background_hyvsj_11pcv_133",
11
+ "drawers-container": "awsui_drawers-container_hyvsj_11pcv_145",
12
+ "has-open-drawer": "awsui_has-open-drawer_hyvsj_11pcv_157",
13
+ "disable-body-scroll": "awsui_disable-body-scroll_hyvsj_11pcv_191",
14
+ "drawers-desktop-triggers-container": "awsui_drawers-desktop-triggers-container_hyvsj_11pcv_196",
15
+ "has-multiple-triggers": "awsui_has-multiple-triggers_hyvsj_11pcv_215",
16
+ "drawers-trigger-content": "awsui_drawers-trigger-content_hyvsj_11pcv_247",
17
+ "drawers-trigger": "awsui_drawers-trigger_hyvsj_11pcv_247",
18
+ "drawer": "awsui_drawer_hyvsj_11pcv_145",
19
+ "drawer-close-button": "awsui_drawer-close-button_hyvsj_11pcv_297",
20
+ "drawer-content": "awsui_drawer-content_hyvsj_11pcv_302",
21
+ "drawer-slider": "awsui_drawer-slider_hyvsj_11pcv_307",
22
+ "is-drawer-open": "awsui_is-drawer-open_hyvsj_11pcv_314",
23
+ "content": "awsui_content_hyvsj_11pcv_339",
24
+ "layout": "awsui_layout_hyvsj_11pcv_360",
25
+ "has-max-content-width": "awsui_has-max-content-width_hyvsj_11pcv_443",
26
+ "content-type-dashboard": "awsui_content-type-dashboard_hyvsj_11pcv_458",
27
+ "is-overlap-disabled": "awsui_is-overlap-disabled_hyvsj_11pcv_475",
28
+ "has-content-gap-left": "awsui_has-content-gap-left_hyvsj_11pcv_507",
29
+ "has-content-gap-right": "awsui_has-content-gap-right_hyvsj_11pcv_510",
30
+ "content-first-child-notifications": "awsui_content-first-child-notifications_hyvsj_11pcv_520",
31
+ "has-breadcrumbs": "awsui_has-breadcrumbs_hyvsj_11pcv_523",
32
+ "content-first-child-header": "awsui_content-first-child-header_hyvsj_11pcv_526",
33
+ "has-header": "awsui_has-header_hyvsj_11pcv_526",
34
+ "content-first-child-main": "awsui_content-first-child-main_hyvsj_11pcv_547",
35
+ "disable-content-paddings": "awsui_disable-content-paddings_hyvsj_11pcv_547",
36
+ "has-split-panel": "awsui_has-split-panel_hyvsj_11pcv_590",
37
+ "split-panel-position-bottom": "awsui_split-panel-position-bottom_hyvsj_11pcv_590",
38
+ "block-body-scroll": "awsui_block-body-scroll_hyvsj_11pcv_606",
39
+ "unfocusable": "awsui_unfocusable_hyvsj_11pcv_611",
40
+ "container": "awsui_container_hyvsj_11pcv_621",
41
+ "is-navigation-open": "awsui_is-navigation-open_hyvsj_11pcv_646",
42
+ "is-tools-open": "awsui_is-tools-open_hyvsj_11pcv_649",
43
+ "is-split-panel-open": "awsui_is-split-panel-open_hyvsj_11pcv_649",
44
+ "split-panel-position-side": "awsui_split-panel-position-side_hyvsj_11pcv_649",
45
+ "mobile-toolbar": "awsui_mobile-toolbar_hyvsj_11pcv_658",
46
+ "mobile-toolbar-nav": "awsui_mobile-toolbar-nav_hyvsj_11pcv_674",
47
+ "mobile-toolbar-breadcrumbs": "awsui_mobile-toolbar-breadcrumbs_hyvsj_11pcv_678",
48
+ "mobile-toolbar-tools": "awsui_mobile-toolbar-tools_hyvsj_11pcv_682",
49
+ "navigation-container": "awsui_navigation-container_hyvsj_11pcv_691",
50
+ "show-navigation": "awsui_show-navigation_hyvsj_11pcv_735",
51
+ "animating": "awsui_animating_hyvsj_11pcv_757",
52
+ "showButtons": "awsui_showButtons_hyvsj_11pcv_1",
53
+ "navigation": "awsui_navigation_hyvsj_11pcv_691",
54
+ "openNavigation": "awsui_openNavigation_hyvsj_11pcv_1",
55
+ "animated-content": "awsui_animated-content_hyvsj_11pcv_819",
56
+ "hide-navigation": "awsui_hide-navigation_hyvsj_11pcv_828",
57
+ "notifications": "awsui_notifications_hyvsj_11pcv_838",
58
+ "sticky-notifications": "awsui_sticky-notifications_hyvsj_11pcv_844",
59
+ "split-panel-bottom": "awsui_split-panel-bottom_hyvsj_11pcv_861",
60
+ "position-bottom": "awsui_position-bottom_hyvsj_11pcv_907",
61
+ "openSplitPanelBottom": "awsui_openSplitPanelBottom_hyvsj_11pcv_1",
62
+ "split-panel-side": "awsui_split-panel-side_hyvsj_11pcv_936",
63
+ "position-side": "awsui_position-side_hyvsj_11pcv_964",
64
+ "openSplitPanelSide": "awsui_openSplitPanelSide_hyvsj_11pcv_1",
65
+ "tools-container": "awsui_tools-container_hyvsj_11pcv_1001",
66
+ "tools": "awsui_tools_hyvsj_11pcv_1001",
67
+ "openTools": "awsui_openTools_hyvsj_11pcv_1",
68
+ "has-tools-form-persistence": "awsui_has-tools-form-persistence_hyvsj_11pcv_1096",
69
+ "hide-tools": "awsui_hide-tools_hyvsj_11pcv_1106",
70
+ "show-tools": "awsui_show-tools_hyvsj_11pcv_1118",
71
+ "has-tools-form": "awsui_has-tools-form_hyvsj_11pcv_1096",
72
+ "trigger": "awsui_trigger_hyvsj_11pcv_1183",
73
+ "selected": "awsui_selected_hyvsj_11pcv_1222"
74
74
  };
75
75
 
@@ -9,7 +9,7 @@ import InternalIcon from '../icon/internal';
9
9
  import { TransitionGroup } from 'react-transition-group';
10
10
  import { Transition } from '../internal/components/transition';
11
11
  import styles from './styles.css.js';
12
- import { counterTypes, getFlashTypeCount, getItemType, getVisibleCollapsedItems } from './utils';
12
+ import { counterTypes, getFlashTypeCount, getItemColor, getVisibleCollapsedItems } from './utils';
13
13
  import { animate, getDOMRects } from '../internal/animate';
14
14
  import { useUniqueId } from '../internal/hooks/use-unique-id';
15
15
  import { sendToggleMetric } from './internal/analytics';
@@ -138,7 +138,7 @@ export default function CollapsibleFlashbar(_a) {
138
138
  }, [updateBottomSpacing, getElementsToAnimate, initialAnimationState, isFlashbarStackExpanded]);
139
139
  const isCollapsible = items.length > maxNonCollapsibleItems;
140
140
  const countByType = getFlashTypeCount(items);
141
- const numberOfColorsInStack = new Set(items.map(getItemType)).size;
141
+ const numberOfColorsInStack = new Set(items.map(getItemColor)).size;
142
142
  const maxSlots = Math.max(numberOfColorsInStack, 3);
143
143
  const stackDepth = Math.min(maxSlots, items.length);
144
144
  const itemsToShow = isFlashbarStackExpanded
@@ -1 +1 @@
1
- {"version":3,"file":"collapsible-flashbar.js","sourceRoot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AM;oBAChF,8BAAM,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC,IAClC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CACnD,oBAAC,qBAAqB,IACpB,GAAG,EAAE,IAAI,EACT,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,cAAc,CAAC,SAAS,CAAC,EAChC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,GACxB,CACH,CAAC,CACG,CACF;gBACP,iDACiB,iBAAiB,sBACd,kBAAkB,mBACrB,uBAAuB,gBAC1B,wBAAwB,EACpC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAuB,IAAI,MAAM,CAAC,QAAQ,CAAC;oBAE1E,oBAAC,YAAY,IAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,YAAY,GAAG,CACjE,CACL,CACP;YACA,CAAC,uBAAuB,IAAI,UAAU,EAAE,CACxC,CACC,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,4CAAkB,KAAK,EAAE,IAAI,EAAC,KAAK;YACjC,8BAAM,KAAK,EAAE,KAAK,iBAAc,MAAM;gBACpC,oBAAC,YAAY,IAAC,IAAI,EAAE,QAAQ,GAAI,CAC3B,CACF;QACP,8BAAM,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC,IAAG,KAAK,CAAQ,CAClD,CACR,CAAC;AACJ,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, { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport customCssProps from '../internal/generated/custom-css-properties';\nimport { Flash, focusFlashById } from './flash';\nimport { FlashbarProps } from './interfaces';\nimport InternalIcon from '../icon/internal';\nimport { TransitionGroup } from 'react-transition-group';\nimport { Transition } from '../internal/components/transition';\nimport styles from './styles.css.js';\nimport { counterTypes, getFlashTypeCount, getItemType, getVisibleCollapsedItems, StackableItem } from './utils';\nimport { animate, getDOMRects } from '../internal/animate';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { IconProps } from '../icon/interfaces';\nimport { sendToggleMetric } from './internal/analytics';\nimport { useFlashbar } from './common';\nimport { throttle } from '../internal/utils/throttle';\nimport { scrollElementIntoView } from '../internal/utils/scrollable-containers';\nimport { findUpUntil } from '../internal/utils/dom';\nimport { useInternalI18n } from '../i18n/context';\nimport { getVisualContextClassname } from '../internal/components/visual-context';\n\nexport { FlashbarProps };\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, ...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 { baseProps, breakpoint, isReducedMotion, isVisualRefresh, mergedRef, ref } = 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 const collapsedItemRefs = useRef<Record<string | number, HTMLElement | null>>({});\n const expandedItemRefs = useRef<Record<string | number, HTMLElement | null>>({});\n const [initialAnimationState, setInitialAnimationState] = useState<Record<string | number, 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 if (items.length <= maxNonCollapsibleItems && isFlashbarStackExpanded) {\n setIsFlashbarStackExpanded(false);\n }\n\n const animateFlash = !isReducedMotion;\n\n function toggleCollapseExpand() {\n sendToggleMetric(items.length, !isFlashbarStackExpanded);\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 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 // When collapsing, scroll up if necessary to avoid losing track of the focused button\n if (!isFlashbarStackExpanded && notificationBarRef.current) {\n scrollElementIntoView(notificationBarRef.current);\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(getItemType)).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 <TransitionGroup component={null}>\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 !isFlashbarStackExpanded || transitioning\n ? {\n [customCssProps.flashbarStackIndex]:\n (item as StackableItem).collapsedIndex ?? (item as StackableItem).expandedIndex ?? index,\n }\n : undefined\n }\n key={getItemId(item)}\n >\n {showInnerContent(item) && (\n <Flash\n // eslint-disable-next-line react/forbid-component-props\n className={clsx(\n animateFlash && styles['flash-with-motion'],\n isVisualRefresh && styles['flash-refresh']\n )}\n key={getItemId(item)}\n ref={shouldUseStandardAnimation(item, index) ? transitionRootElement : undefined}\n transitionState={shouldUseStandardAnimation(item, index) ? state : undefined}\n {...item}\n />\n )}\n </li>\n )}\n </Transition>\n ))}\n </TransitionGroup>\n </ul>\n );\n\n return (\n <div\n {...baseProps}\n className={clsx(\n baseProps.className,\n styles.flashbar,\n styles[`breakpoint-${breakpoint}`],\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 >\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 >\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 </>\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 aria-label={label} role=\"img\">\n <span title={label} aria-hidden=\"true\">\n <InternalIcon name={iconName} />\n </span>\n </span>\n <span className={styles['count-number']}>{count}</span>\n </span>\n );\n};\n"]}
1
+ {"version":3,"file":"collapsible-flashbar.js","sourceRoot":"lib/default/","sources":["flashbar/collapsible-flashbar.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,E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AE,EAAE,CAAC,CACnD,oBAAC,qBAAqB,IACpB,GAAG,EAAE,IAAI,EACT,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,cAAc,CAAC,SAAS,CAAC,EAChC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,GACxB,CACH,CAAC,CACG,CACF;gBACP,iDACiB,iBAAiB,sBACd,kBAAkB,mBACrB,uBAAuB,gBAC1B,wBAAwB,EACpC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAuB,IAAI,MAAM,CAAC,QAAQ,CAAC;oBAE1E,oBAAC,YAAY,IAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,YAAY,GAAG,CACjE,CACL,CACP;YACA,CAAC,uBAAuB,IAAI,UAAU,EAAE,CACxC,CACC,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,4CAAkB,KAAK,EAAE,IAAI,EAAC,KAAK;YACjC,8BAAM,KAAK,EAAE,KAAK,iBAAc,MAAM;gBACpC,oBAAC,YAAY,IAAC,IAAI,EAAE,QAAQ,GAAI,CAC3B,CACF;QACP,8BAAM,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC,IAAG,KAAK,CAAQ,CAClD,CACR,CAAC;AACJ,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, { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport customCssProps from '../internal/generated/custom-css-properties';\nimport { Flash, focusFlashById } from './flash';\nimport { FlashbarProps } from './interfaces';\nimport InternalIcon from '../icon/internal';\nimport { TransitionGroup } from 'react-transition-group';\nimport { Transition } from '../internal/components/transition';\nimport styles from './styles.css.js';\nimport { counterTypes, getFlashTypeCount, getItemColor, getVisibleCollapsedItems, StackableItem } from './utils';\nimport { animate, getDOMRects } from '../internal/animate';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { IconProps } from '../icon/interfaces';\nimport { sendToggleMetric } from './internal/analytics';\nimport { useFlashbar } from './common';\nimport { throttle } from '../internal/utils/throttle';\nimport { scrollElementIntoView } from '../internal/utils/scrollable-containers';\nimport { findUpUntil } from '../internal/utils/dom';\nimport { useInternalI18n } from '../i18n/context';\nimport { getVisualContextClassname } from '../internal/components/visual-context';\n\nexport { FlashbarProps };\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, ...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 { baseProps, breakpoint, isReducedMotion, isVisualRefresh, mergedRef, ref } = 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 const collapsedItemRefs = useRef<Record<string | number, HTMLElement | null>>({});\n const expandedItemRefs = useRef<Record<string | number, HTMLElement | null>>({});\n const [initialAnimationState, setInitialAnimationState] = useState<Record<string | number, 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 if (items.length <= maxNonCollapsibleItems && isFlashbarStackExpanded) {\n setIsFlashbarStackExpanded(false);\n }\n\n const animateFlash = !isReducedMotion;\n\n function toggleCollapseExpand() {\n sendToggleMetric(items.length, !isFlashbarStackExpanded);\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 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 // When collapsing, scroll up if necessary to avoid losing track of the focused button\n if (!isFlashbarStackExpanded && notificationBarRef.current) {\n scrollElementIntoView(notificationBarRef.current);\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 <TransitionGroup component={null}>\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 !isFlashbarStackExpanded || transitioning\n ? {\n [customCssProps.flashbarStackIndex]:\n (item as StackableItem).collapsedIndex ?? (item as StackableItem).expandedIndex ?? index,\n }\n : undefined\n }\n key={getItemId(item)}\n >\n {showInnerContent(item) && (\n <Flash\n // eslint-disable-next-line react/forbid-component-props\n className={clsx(\n animateFlash && styles['flash-with-motion'],\n isVisualRefresh && styles['flash-refresh']\n )}\n key={getItemId(item)}\n ref={shouldUseStandardAnimation(item, index) ? transitionRootElement : undefined}\n transitionState={shouldUseStandardAnimation(item, index) ? state : undefined}\n {...item}\n />\n )}\n </li>\n )}\n </Transition>\n ))}\n </TransitionGroup>\n </ul>\n );\n\n return (\n <div\n {...baseProps}\n className={clsx(\n baseProps.className,\n styles.flashbar,\n styles[`breakpoint-${breakpoint}`],\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 >\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 >\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 </>\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 aria-label={label} role=\"img\">\n <span title={label} aria-hidden=\"true\">\n <InternalIcon name={iconName} />\n </span>\n </span>\n <span className={styles['count-number']}>{count}</span>\n </span>\n );\n};\n"]}
@@ -6,6 +6,7 @@ export interface StackableItem extends FlashbarProps.MessageDefinition {
6
6
  collapsedIndex?: number;
7
7
  }
8
8
  export declare function getItemType(item: FlashbarProps.MessageDefinition): FlashbarProps.Type;
9
+ export declare function getItemColor(item: FlashbarProps.MessageDefinition): string;
9
10
  export declare function getVisibleCollapsedItems(items: ReadonlyArray<FlashbarProps.MessageDefinition>, desiredLength: number): ReadonlyArray<StackableItem>;
10
11
  export declare function getFlashTypeCount(items: readonly FlashbarProps.MessageDefinition[]): Record<FlashbarProps.Type, number>;
11
12
  export type LabelName = 'errorIconAriaLabel' | 'warningIconAriaLabel' | 'successIconAriaLabel' | 'infoIconAriaLabel' | 'inProgressIconAriaLabel';
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"lib/default/","sources":["flashbar/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAKzC,MAAM,WAAW,aAAc,SAAQ,aAAa,CAAC,iBAAiB;IACpE,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAeD,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,CAAC,iBAAiB,sBAMhE;AAWD,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,iBAAiB,CAAC,EACrD,aAAa,EAAE,MAAM,GACpB,aAAa,CAAC,aAAa,CAAC,CAgD9B;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,SAAS,aAAa,CAAC,iBAAiB,EAAE,GAChD,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAOpC;AAED,MAAM,MAAM,SAAS,GACjB,oBAAoB,GACpB,sBAAsB,GACtB,sBAAsB,GACtB,mBAAmB,GACnB,yBAAyB,CAAC;AAE9B,eAAO,MAAM,YAAY,EAAE;IACzB,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC;IACzB,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC;CAC1B,EAMA,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"lib/default/","sources":["flashbar/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAKzC,MAAM,WAAW,aAAc,SAAQ,aAAa,CAAC,iBAAiB;IACpE,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAeD,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,CAAC,iBAAiB,sBAMhE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,CAAC,iBAAiB,UAEjE;AAOD,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,iBAAiB,CAAC,EACrD,aAAa,EAAE,MAAM,GACpB,aAAa,CAAC,aAAa,CAAC,CAgD9B;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,SAAS,aAAa,CAAC,iBAAiB,EAAE,GAChD,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAOpC;AAED,MAAM,MAAM,SAAS,GACjB,oBAAoB,GACpB,sBAAsB,GACtB,sBAAsB,GACtB,mBAAmB,GACnB,yBAAyB,CAAC;AAE9B,eAAO,MAAM,YAAY,EAAE;IACzB,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC;IACzB,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC;CAC1B,EAMA,CAAC"}
package/flashbar/utils.js CHANGED
@@ -18,7 +18,7 @@ export function getItemType(item) {
18
18
  return item.type || 'info';
19
19
  }
20
20
  }
21
- function getItemColor(item) {
21
+ export function getItemColor(item) {
22
22
  return getColorFromType(getItemType(item));
23
23
  }
24
24
  /*
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"lib/default/","sources":["flashbar/utils.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAUzC,MAAM,aAAa,GAAuC;IACxD,KAAK,EAAE,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AU,iBAAiB,CAC/B,KAAiD;IAEjD,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC9E,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAC/B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KAClB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AASD,MAAM,CAAC,MAAM,YAAY,GAInB;IACJ,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,QAAQ,EAAE,iBAAiB,EAAE;IAC/E,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,sBAAsB,EAAE,QAAQ,EAAE,gBAAgB,EAAE;IAClF,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,sBAAsB,EAAE,QAAQ,EAAE,iBAAiB,EAAE;IACnF,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,EAAE,QAAQ,EAAE,aAAa,EAAE;IACzE,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,yBAAyB,EAAE,QAAQ,EAAE,oBAAoB,EAAE;CAC9F,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { FlashbarProps } from './interfaces';\nimport { IconProps } from '../icon/interfaces';\n\nexport const FOCUS_THROTTLE_DELAY = 2000;\n\n// Since the position of a notification changes when the Flashbar is collapsed,\n// it is useful on some situations (e.g, for animating) to know the original position of the item\n// in the non-collapsed state.\nexport interface StackableItem extends FlashbarProps.MessageDefinition {\n expandedIndex: number;\n collapsedIndex?: number;\n}\n\nconst typesToColors: Record<FlashbarProps.Type, string> = {\n error: 'red',\n info: 'blue',\n 'in-progress': 'blue',\n success: 'green',\n warning: 'yellow',\n};\n\nfunction getColorFromType(type?: FlashbarProps.Type): string {\n const defaultColor = 'blue';\n return type ? typesToColors[type] || defaultColor : defaultColor;\n}\n\nexport function getItemType(item: FlashbarProps.MessageDefinition) {\n if (item.loading) {\n return 'in-progress';\n } else {\n return item.type || 'info';\n }\n}\n\nfunction getItemColor(item: FlashbarProps.MessageDefinition) {\n return getColorFromType(getItemType(item));\n}\n\n/*\n Returns a selection of notifications, preserving the order when possible but making sure that all different colors in\n the stack are represented in the returned array.\n The order corresponds to how they are represented when using the collapsible feature (newest first, oldest last).\n */\nexport function getVisibleCollapsedItems(\n items: ReadonlyArray<FlashbarProps.MessageDefinition>,\n desiredLength: number\n): ReadonlyArray<StackableItem> {\n // First `desiredLength` items in the original array,\n // together with `isColorRepeated` to tell if they can be subject to be replaced later on if necessary\n const itemsOnTop: { item: StackableItem; isColorRepeated: boolean }[] = [];\n\n // Items that fall outside `desiredIndexLength` but need to be \"promoted\" if possible\n // because they are of a different color which otherwise wouldn't be represented\n const itemsToPromote: StackableItem[] = [];\n\n const addedColors: Set<string> = new Set();\n const allPossibleColors = Object.keys(typesToColors).length;\n const finalLength = Math.min(items.length, desiredLength);\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n const color = getItemColor(item);\n const isColorRepeated = addedColors.has(color);\n if (i < finalLength) {\n itemsOnTop.push({ item: { ...item, expandedIndex: i }, isColorRepeated });\n } else {\n if (addedColors.size === allPossibleColors) {\n // No need to keep looking for unrepresented colors, we can stop looping\n break;\n } else if (!isColorRepeated) {\n itemsToPromote.push({ ...item, expandedIndex: i });\n }\n }\n addedColors.add(color);\n }\n // Generate the new array with the selected items, by picking from both arrays.\n // First, from the non-repeated items within the desired length...\n // We loop `itemsOnTop` starting from the end because we prefer to preserve the first ones rather than the old ones\n const reversedInitialSelection = [];\n let slotsReservedForPromotions = 0;\n for (let j = itemsOnTop.length - 1; j >= 0; j--) {\n const item = itemsOnTop[j];\n if (item.isColorRepeated && slotsReservedForPromotions < itemsToPromote.length) {\n slotsReservedForPromotions += 1;\n } else {\n reversedInitialSelection.push(item.item);\n }\n }\n const selectedItems = reversedInitialSelection.reverse();\n // ...and then complete the selection with as many promotable items as we can fit in the rest of the array\n for (let k = 0; selectedItems.length < desiredLength; k++) {\n selectedItems.push(itemsToPromote[k]);\n }\n return selectedItems;\n}\n\nexport function getFlashTypeCount(\n items: readonly FlashbarProps.MessageDefinition[]\n): Record<FlashbarProps.Type, number> {\n const count = { error: 0, info: 0, 'in-progress': 0, success: 0, warning: 0 };\n for (const item of items) {\n const type = getItemType(item);\n count[type] += 1;\n }\n return count;\n}\n\nexport type LabelName =\n | 'errorIconAriaLabel'\n | 'warningIconAriaLabel'\n | 'successIconAriaLabel'\n | 'infoIconAriaLabel'\n | 'inProgressIconAriaLabel';\n\nexport const counterTypes: {\n type: FlashbarProps.Type;\n labelName: LabelName;\n iconName: IconProps.Name;\n}[] = [\n { type: 'error', labelName: 'errorIconAriaLabel', iconName: 'status-negative' },\n { type: 'warning', labelName: 'warningIconAriaLabel', iconName: 'status-warning' },\n { type: 'success', labelName: 'successIconAriaLabel', iconName: 'status-positive' },\n { type: 'info', labelName: 'infoIconAriaLabel', iconName: 'status-info' },\n { type: 'in-progress', labelName: 'inProgressIconAriaLabel', iconName: 'status-in-progress' },\n];\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"lib/default/","sources":["flashbar/utils.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAUzC,MAAM,aAAa,GAAuC;IACxD,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,MAAM;IACZ,aAAa,EAAE,MAAM;IACrB,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,QAAQ;CAClB,CAAC;AAEF,SAAS,gBAAgB,CAAC,IAAyB;IACjD,MAAM,YAAY,GAAG,MAAM,CAAC;IAC5B,OAAO,IAAI,CAAC,CAAC,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AAI,KAAK,EAAE;QACxB,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAC/B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KAClB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AASD,MAAM,CAAC,MAAM,YAAY,GAInB;IACJ,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,QAAQ,EAAE,iBAAiB,EAAE;IAC/E,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,sBAAsB,EAAE,QAAQ,EAAE,gBAAgB,EAAE;IAClF,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,sBAAsB,EAAE,QAAQ,EAAE,iBAAiB,EAAE;IACnF,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,EAAE,QAAQ,EAAE,aAAa,EAAE;IACzE,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,yBAAyB,EAAE,QAAQ,EAAE,oBAAoB,EAAE;CAC9F,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { FlashbarProps } from './interfaces';\nimport { IconProps } from '../icon/interfaces';\n\nexport const FOCUS_THROTTLE_DELAY = 2000;\n\n// Since the position of a notification changes when the Flashbar is collapsed,\n// it is useful on some situations (e.g, for animating) to know the original position of the item\n// in the non-collapsed state.\nexport interface StackableItem extends FlashbarProps.MessageDefinition {\n expandedIndex: number;\n collapsedIndex?: number;\n}\n\nconst typesToColors: Record<FlashbarProps.Type, string> = {\n error: 'red',\n info: 'blue',\n 'in-progress': 'blue',\n success: 'green',\n warning: 'yellow',\n};\n\nfunction getColorFromType(type?: FlashbarProps.Type): string {\n const defaultColor = 'blue';\n return type ? typesToColors[type] || defaultColor : defaultColor;\n}\n\nexport function getItemType(item: FlashbarProps.MessageDefinition) {\n if (item.loading) {\n return 'in-progress';\n } else {\n return item.type || 'info';\n }\n}\n\nexport function getItemColor(item: FlashbarProps.MessageDefinition) {\n return getColorFromType(getItemType(item));\n}\n\n/*\n Returns a selection of notifications, preserving the order when possible but making sure that all different colors in\n the stack are represented in the returned array.\n The order corresponds to how they are represented when using the collapsible feature (newest first, oldest last).\n */\nexport function getVisibleCollapsedItems(\n items: ReadonlyArray<FlashbarProps.MessageDefinition>,\n desiredLength: number\n): ReadonlyArray<StackableItem> {\n // First `desiredLength` items in the original array,\n // together with `isColorRepeated` to tell if they can be subject to be replaced later on if necessary\n const itemsOnTop: { item: StackableItem; isColorRepeated: boolean }[] = [];\n\n // Items that fall outside `desiredIndexLength` but need to be \"promoted\" if possible\n // because they are of a different color which otherwise wouldn't be represented\n const itemsToPromote: StackableItem[] = [];\n\n const addedColors: Set<string> = new Set();\n const allPossibleColors = Object.keys(typesToColors).length;\n const finalLength = Math.min(items.length, desiredLength);\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n const color = getItemColor(item);\n const isColorRepeated = addedColors.has(color);\n if (i < finalLength) {\n itemsOnTop.push({ item: { ...item, expandedIndex: i }, isColorRepeated });\n } else {\n if (addedColors.size === allPossibleColors) {\n // No need to keep looking for unrepresented colors, we can stop looping\n break;\n } else if (!isColorRepeated) {\n itemsToPromote.push({ ...item, expandedIndex: i });\n }\n }\n addedColors.add(color);\n }\n // Generate the new array with the selected items, by picking from both arrays.\n // First, from the non-repeated items within the desired length...\n // We loop `itemsOnTop` starting from the end because we prefer to preserve the first ones rather than the old ones\n const reversedInitialSelection = [];\n let slotsReservedForPromotions = 0;\n for (let j = itemsOnTop.length - 1; j >= 0; j--) {\n const item = itemsOnTop[j];\n if (item.isColorRepeated && slotsReservedForPromotions < itemsToPromote.length) {\n slotsReservedForPromotions += 1;\n } else {\n reversedInitialSelection.push(item.item);\n }\n }\n const selectedItems = reversedInitialSelection.reverse();\n // ...and then complete the selection with as many promotable items as we can fit in the rest of the array\n for (let k = 0; selectedItems.length < desiredLength; k++) {\n selectedItems.push(itemsToPromote[k]);\n }\n return selectedItems;\n}\n\nexport function getFlashTypeCount(\n items: readonly FlashbarProps.MessageDefinition[]\n): Record<FlashbarProps.Type, number> {\n const count = { error: 0, info: 0, 'in-progress': 0, success: 0, warning: 0 };\n for (const item of items) {\n const type = getItemType(item);\n count[type] += 1;\n }\n return count;\n}\n\nexport type LabelName =\n | 'errorIconAriaLabel'\n | 'warningIconAriaLabel'\n | 'successIconAriaLabel'\n | 'infoIconAriaLabel'\n | 'inProgressIconAriaLabel';\n\nexport const counterTypes: {\n type: FlashbarProps.Type;\n labelName: LabelName;\n iconName: IconProps.Name;\n}[] = [\n { type: 'error', labelName: 'errorIconAriaLabel', iconName: 'status-negative' },\n { type: 'warning', labelName: 'warningIconAriaLabel', iconName: 'status-warning' },\n { type: 'success', labelName: 'successIconAriaLabel', iconName: 'status-positive' },\n { type: 'info', labelName: 'infoIconAriaLabel', iconName: 'status-info' },\n { type: 'in-progress', labelName: 'inProgressIconAriaLabel', iconName: 'status-in-progress' },\n];\n"]}
@@ -0,0 +1,9 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // It's fine for importMessages to raise TypeScript requirements because
5
+ // it will usually be accompanied by the I18nProvider anyway.
6
+ // eslint-disable-next-line @cloudscape-design/ban-files
7
+ import { I18nProviderProps } from './provider';
8
+
9
+ export function importMessages(locale: string): Promise<ReadonlyArray<I18nProviderProps.Messages>>;
@@ -0,0 +1,40 @@
1
+ import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
2
+ import { isDevelopment } from '../internal/is-development';
3
+ import { getMatchableLocales } from './get-matchable-locales';
4
+
5
+ export function importMessages(locale) {
6
+ for (const matchableLocale of getMatchableLocales(locale)) {
7
+ switch (matchableLocale.toLowerCase()) {
8
+ case 'de':
9
+ return import('./messages/all.de.js').then(mod => [mod.default]);
10
+ case 'en-gb':
11
+ return import('./messages/all.en-GB.js').then(mod => [mod.default]);
12
+ case 'en':
13
+ return import('./messages/all.en.js').then(mod => [mod.default]);
14
+ case 'es':
15
+ return import('./messages/all.es.js').then(mod => [mod.default]);
16
+ case 'fr':
17
+ return import('./messages/all.fr.js').then(mod => [mod.default]);
18
+ case 'id':
19
+ return import('./messages/all.id.js').then(mod => [mod.default]);
20
+ case 'it':
21
+ return import('./messages/all.it.js').then(mod => [mod.default]);
22
+ case 'ja':
23
+ return import('./messages/all.ja.js').then(mod => [mod.default]);
24
+ case 'ko':
25
+ return import('./messages/all.ko.js').then(mod => [mod.default]);
26
+ case 'pt-br':
27
+ return import('./messages/all.pt-BR.js').then(mod => [mod.default]);
28
+ case 'zh-cn':
29
+ return import('./messages/all.zh-CN.js').then(mod => [mod.default]);
30
+ case 'zh-tw':
31
+ return import('./messages/all.zh-TW.js').then(mod => [mod.default]);
32
+ }
33
+ }
34
+
35
+ if (isDevelopment) {
36
+ warnOnce('importMessages', `Unknown locale "${locale}" provided to importMessages`);
37
+ }
38
+
39
+ return Promise.resolve([]);
40
+ }
@@ -0,0 +1,2 @@
1
+ export declare function getMatchableLocales(ietfLanguageTag: string): string[];
2
+ //# sourceMappingURL=get-matchable-locales.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-matchable-locales.d.ts","sourceRoot":"lib/default/","sources":["i18n/get-matchable-locales.ts"],"names":[],"mappings":"AAGA,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,EAAE,CAWrE"}
@@ -0,0 +1,14 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export function getMatchableLocales(ietfLanguageTag) {
4
+ const parts = ietfLanguageTag.split('-');
5
+ if (parts.length === 1) {
6
+ return [ietfLanguageTag];
7
+ }
8
+ const localeStrings = [];
9
+ for (let i = parts.length; i > 0; i--) {
10
+ localeStrings.push(parts.slice(0, i).join('-'));
11
+ }
12
+ return localeStrings;
13
+ }
14
+ //# sourceMappingURL=get-matchable-locales.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-matchable-locales.js","sourceRoot":"lib/default/","sources":["i18n/get-matchable-locales.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,MAAM,UAAU,mBAAmB,CAAC,eAAuB;IACzD,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,OAAO,CAAC,eAAe,CAAC,CAAC;KAC1B;IAED,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QACrC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;KACjD;IACD,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function getMatchableLocales(ietfLanguageTag: string): string[] {\n const parts = ietfLanguageTag.split('-');\n if (parts.length === 1) {\n return [ietfLanguageTag];\n }\n\n const localeStrings: string[] = [];\n for (let i = parts.length; i > 0; i--) {\n localeStrings.push(parts.slice(0, i).join('-'));\n }\n return localeStrings;\n}\n"]}
package/i18n/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { I18nProvider as default, I18nProvider, I18nProviderProps } from './provider';
2
+ export { importMessages } from './dynamic';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["i18n/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,IAAI,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["i18n/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,IAAI,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
package/i18n/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  export { I18nProvider as default, I18nProvider } from './provider';
4
+ export { importMessages } from './dynamic';
4
5
  //# sourceMappingURL=index.js.map
package/i18n/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["i18n/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,YAAY,IAAI,OAAO,EAAE,YAAY,EAAqB,MAAM,YAAY,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { I18nProvider as default, I18nProvider, I18nProviderProps } from './provider';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["i18n/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,YAAY,IAAI,OAAO,EAAE,YAAY,EAAqB,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { I18nProvider as default, I18nProvider, I18nProviderProps } from './provider';\nexport { importMessages } from './dynamic';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"lib/default/","sources":["i18n/provider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAqB,MAAM,OAAO,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H,CAAC;KACH;CACF;AASD,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,iBAAiB,eAyE5G"}
package/i18n/provider.js CHANGED
@@ -6,6 +6,7 @@ import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
6
6
  import { useTelemetry } from '../internal/hooks/use-telemetry';
7
7
  import { applyDisplayName } from '../internal/utils/apply-display-name';
8
8
  import { InternalI18nContext } from './context';
9
+ import { getMatchableLocales } from './get-matchable-locales';
9
10
  /**
10
11
  * Context to send parent messages down to child I18nProviders. This isn't
11
12
  * included in the InternalI18nContext to avoid components from depending on
@@ -95,15 +96,4 @@ function mergeMessages(sources) {
95
96
  }
96
97
  return result;
97
98
  }
98
- function getMatchableLocales(ietfLanguageTag) {
99
- const parts = ietfLanguageTag.split('-');
100
- if (parts.length === 1) {
101
- return [ietfLanguageTag];
102
- }
103
- const localeStrings = [];
104
- for (let i = parts.length; i > 0; i--) {
105
- localeStrings.push(parts.slice(0, i).join('-'));
106
- }
107
- return localeStrings;
108
- }
109
99
  //# sourceMappingURL=provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"lib/default/","sources":["i18n/provider.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAiC,MAAM,WAAW,CAAC;AAoB/E;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,KAAK,CAAC,aAAa,CAA6B,EAAE,CAAC,CAAC;AA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affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useContext } from 'react';\nimport IntlMessageFormat from 'intl-messageformat';\nimport { MessageFormatElement } from '@formatjs/icu-messageformat-parser';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useTelemetry } from '../internal/hooks/use-telemetry';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { InternalI18nContext, FormatFunction, CustomHandler } from './context';\n\nexport interface I18nProviderProps {\n messages: ReadonlyArray<I18nProviderProps.Messages>;\n locale?: string;\n children: React.ReactNode;\n}\n\nexport namespace I18nProviderProps {\n export interface Messages {\n [namespace: string]: {\n [locale: string]: {\n [component: string]: {\n [key: string]: string | MessageFormatElement[];\n };\n };\n };\n }\n}\n\n/**\n * Context to send parent messages down to child I18nProviders. This isn't\n * included in the InternalI18nContext to avoid components from depending on\n * MessageFormatElement types.\n */\nconst I18nMessagesContext = React.createContext<I18nProviderProps.Messages>({});\n\nexport function I18nProvider({ messages: messagesArray, locale: providedLocale, children }: I18nProviderProps) {\n useTelemetry('I18nProvider');\n\n if (typeof document === 'undefined' && !providedLocale) {\n warnOnce(\n 'I18nProvider',\n 'An explicit locale was not provided during server rendering. This can lead to a hydration mismatch on the client.'\n );\n }\n\n // The provider accepts an array of configs. We merge parent messages and\n // flatten the tree early on so that accesses by key are simpler and faster.\n const parentMessages = useContext(I18nMessagesContext);\n const messages = mergeMessages([parentMessages, ...messagesArray]);\n\n let locale: string;\n if (providedLocale) {\n // If a locale is explicitly provided, use the string directly.\n // Locales have a recommended case, but are matched case-insensitively,\n // so we lowercase it internally.\n locale = providedLocale.toLowerCase();\n } else if (typeof document !== 'undefined' && document.documentElement.lang) {\n // Otherwise, use the value provided in the HTML tag.\n locale = document.documentElement.lang.toLowerCase();\n } else {\n // Lastly, fall back to English.\n locale = 'en';\n }\n\n const format: FormatFunction = <ReturnValue, FormatFnArgs extends Record<string, string | number>>(\n namespace: string,\n component: string,\n key: string,\n provided: ReturnValue,\n customHandler?: CustomHandler<ReturnValue, FormatFnArgs>\n ): ReturnValue => {\n // A general rule in the library is that undefined is basically\n // treated as \"not provided\". So even if a user explicitly provides an\n // undefined value, it will default to i18n values.\n if (provided !== undefined) {\n return provided;\n }\n\n // Widen the locale string (e.g. en-GB -> en) until we find a locale\n // that contains the message we need.\n let message: string | MessageFormatElement[] | undefined;\n const matchableLocales = getMatchableLocales(locale);\n for (const matchableLocale of matchableLocales) {\n const localeMessage = messages?.[namespace]?.[matchableLocale]?.[component]?.[key];\n if (localeMessage !== undefined) {\n message = localeMessage;\n break;\n }\n }\n\n // If a message wasn't found, exit early.\n if (message === undefined) {\n return provided;\n }\n\n const intlMessageFormat = new IntlMessageFormat(message, locale);\n if (customHandler) {\n return customHandler(args => intlMessageFormat.format(args) as string);\n }\n // Assuming `T extends string` since a customHandler wasn't provided.\n return intlMessageFormat.format() as ReturnValue;\n };\n\n return (\n <InternalI18nContext.Provider value={{ locale, format }}>\n <I18nMessagesContext.Provider value={messages}>{children}</I18nMessagesContext.Provider>\n </InternalI18nContext.Provider>\n );\n}\n\napplyDisplayName(I18nProvider, 'I18nProvider');\n\nfunction mergeMessages(sources: ReadonlyArray<I18nProviderProps.Messages>): I18nProviderProps.Messages {\n const result: I18nProviderProps.Messages = {};\n for (const messages of sources) {\n for (const namespace in messages) {\n if (!(namespace in result)) {\n result[namespace] = {};\n }\n for (const casedLocale in messages[namespace]) {\n const locale = casedLocale.toLowerCase();\n if (!(locale in result[namespace])) {\n result[namespace][locale] = {};\n }\n for (const component in messages[namespace][casedLocale]) {\n if (!(component in result[namespace][locale])) {\n result[namespace][locale][component] = {};\n }\n for (const key in messages[namespace][casedLocale][component]) {\n result[namespace][locale][component][key] = messages[namespace][casedLocale][component][key];\n }\n }\n }\n }\n }\n return result;\n}\n\nfunction getMatchableLocales(ietfLanguageTag: string): string[] {\n const parts = ietfLanguageTag.split('-');\n if (parts.length === 1) {\n return [ietfLanguageTag];\n }\n\n const localeStrings: string[] = [];\n for (let i = parts.length; i > 0; i--) {\n localeStrings.push(parts.slice(0, i).join('-'));\n }\n return localeStrings;\n}\n"]}
1
+ {"version":3,"file":"provider.js","sourceRoot":"lib/default/","sources":["i18n/provider.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAiC,MAAM,WAAW,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAoB9D;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,KAAK,CAAC,aAAa,CAA6B,EAAE,CAAC,CAAC;AAEhF,MAAM,UAAU,YAAY,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAqB;IAC3G,YAAY,CAAC,cAAc,CAAC,CAAC;IAE7B,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,CAAC,cAAc,EAAE;QACtD,QAAQ,CACN,cAAc,EACd,mHAAmH,CACpH,CAAC;KACH;IAED,yEAAyE;IACzE,4EAA4E;IAC5E,MAAM,cAAc,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,aAAa,CAAC,CAAC,cAAc,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC;IAEnE,IAAI,MAAc,CAAC;IACnB,IAAI,cAAc,EAAE;QAClB,+DAA+D;QAC/D,uEAAuE;QACvE,iCAAiC;QACjC,MAAM,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;KACvC;SAAM,IAAI,OAA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,CAAC,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC;qBAC9F;iBACF;aACF;SACF;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useContext } from 'react';\nimport IntlMessageFormat from 'intl-messageformat';\nimport { MessageFormatElement } from '@formatjs/icu-messageformat-parser';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useTelemetry } from '../internal/hooks/use-telemetry';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { InternalI18nContext, FormatFunction, CustomHandler } from './context';\nimport { getMatchableLocales } from './get-matchable-locales';\n\nexport interface I18nProviderProps {\n messages: ReadonlyArray<I18nProviderProps.Messages>;\n locale?: string;\n children: React.ReactNode;\n}\n\nexport namespace I18nProviderProps {\n export interface Messages {\n [namespace: string]: {\n [locale: string]: {\n [component: string]: {\n [key: string]: string | MessageFormatElement[];\n };\n };\n };\n }\n}\n\n/**\n * Context to send parent messages down to child I18nProviders. This isn't\n * included in the InternalI18nContext to avoid components from depending on\n * MessageFormatElement types.\n */\nconst I18nMessagesContext = React.createContext<I18nProviderProps.Messages>({});\n\nexport function I18nProvider({ messages: messagesArray, locale: providedLocale, children }: I18nProviderProps) {\n useTelemetry('I18nProvider');\n\n if (typeof document === 'undefined' && !providedLocale) {\n warnOnce(\n 'I18nProvider',\n 'An explicit locale was not provided during server rendering. This can lead to a hydration mismatch on the client.'\n );\n }\n\n // The provider accepts an array of configs. We merge parent messages and\n // flatten the tree early on so that accesses by key are simpler and faster.\n const parentMessages = useContext(I18nMessagesContext);\n const messages = mergeMessages([parentMessages, ...messagesArray]);\n\n let locale: string;\n if (providedLocale) {\n // If a locale is explicitly provided, use the string directly.\n // Locales have a recommended case, but are matched case-insensitively,\n // so we lowercase it internally.\n locale = providedLocale.toLowerCase();\n } else if (typeof document !== 'undefined' && document.documentElement.lang) {\n // Otherwise, use the value provided in the HTML tag.\n locale = document.documentElement.lang.toLowerCase();\n } else {\n // Lastly, fall back to English.\n locale = 'en';\n }\n\n const format: FormatFunction = <ReturnValue, FormatFnArgs extends Record<string, string | number>>(\n namespace: string,\n component: string,\n key: string,\n provided: ReturnValue,\n customHandler?: CustomHandler<ReturnValue, FormatFnArgs>\n ): ReturnValue => {\n // A general rule in the library is that undefined is basically\n // treated as \"not provided\". So even if a user explicitly provides an\n // undefined value, it will default to i18n values.\n if (provided !== undefined) {\n return provided;\n }\n\n // Widen the locale string (e.g. en-GB -> en) until we find a locale\n // that contains the message we need.\n let message: string | MessageFormatElement[] | undefined;\n const matchableLocales = getMatchableLocales(locale);\n for (const matchableLocale of matchableLocales) {\n const localeMessage = messages?.[namespace]?.[matchableLocale]?.[component]?.[key];\n if (localeMessage !== undefined) {\n message = localeMessage;\n break;\n }\n }\n\n // If a message wasn't found, exit early.\n if (message === undefined) {\n return provided;\n }\n\n const intlMessageFormat = new IntlMessageFormat(message, locale);\n if (customHandler) {\n return customHandler(args => intlMessageFormat.format(args) as string);\n }\n // Assuming `T extends string` since a customHandler wasn't provided.\n return intlMessageFormat.format() as ReturnValue;\n };\n\n return (\n <InternalI18nContext.Provider value={{ locale, format }}>\n <I18nMessagesContext.Provider value={messages}>{children}</I18nMessagesContext.Provider>\n </InternalI18nContext.Provider>\n );\n}\n\napplyDisplayName(I18nProvider, 'I18nProvider');\n\nfunction mergeMessages(sources: ReadonlyArray<I18nProviderProps.Messages>): I18nProviderProps.Messages {\n const result: I18nProviderProps.Messages = {};\n for (const messages of sources) {\n for (const namespace in messages) {\n if (!(namespace in result)) {\n result[namespace] = {};\n }\n for (const casedLocale in messages[namespace]) {\n const locale = casedLocale.toLowerCase();\n if (!(locale in result[namespace])) {\n result[namespace][locale] = {};\n }\n for (const component in messages[namespace][casedLocale]) {\n if (!(component in result[namespace][locale])) {\n result[namespace][locale][component] = {};\n }\n for (const key in messages[namespace][casedLocale][component]) {\n result[namespace][locale][component][key] = messages[namespace][casedLocale][component][key];\n }\n }\n }\n }\n }\n return result;\n}\n"]}
@@ -1,6 +1,4 @@
1
-
2
- export var PACKAGE_SOURCE = 'components';
3
- export var PACKAGE_VERSION = '3.0.0 (a58fb58)';
4
- export var THEME = 'open-source-visual-refresh';
5
- export var ALWAYS_VISUAL_REFRESH = true;
6
-
1
+ export var PACKAGE_SOURCE = "components";
2
+ export var PACKAGE_VERSION = "3.0.0 (b4ed1433)";
3
+ export var THEME = "open-source-visual-refresh";
4
+ export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (a58fb581)",
3
+ "PACKAGE_VERSION": "3.0.0 (b4ed1433)",
4
4
  "THEME": "default",
5
5
  "ALWAYS_VISUAL_REFRESH": false
6
6
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "a58fb58104e3b5bd92f565bcabd283ed619fcf6d"
2
+ "commit": "b4ed1433c9adc91242a6eb97deb18cd6cd06043a"
3
3
  }
package/package.json CHANGED
@@ -109,7 +109,7 @@
109
109
  "./internal/base-component/index.js",
110
110
  "./internal/base-component/styles.css.js"
111
111
  ],
112
- "version": "3.0.349",
112
+ "version": "3.0.351",
113
113
  "repository": {
114
114
  "type": "git",
115
115
  "url": "https://github.com/cloudscape-design/components.git"