@cloudscape-design/components 3.0.442 → 3.0.443

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/anchor-navigation/use-scroll-spy.js +1 -1
  2. package/anchor-navigation/use-scroll-spy.js.map +1 -1
  3. package/flashbar/flash.d.ts.map +1 -1
  4. package/flashbar/flash.js +7 -9
  5. package/flashbar/flash.js.map +1 -1
  6. package/internal/components/live-region/index.d.ts +20 -2
  7. package/internal/components/live-region/index.d.ts.map +1 -1
  8. package/internal/components/live-region/index.js +37 -5
  9. package/internal/components/live-region/index.js.map +1 -1
  10. package/internal/components/screenreader-only/index.d.ts +1 -1
  11. package/internal/components/screenreader-only/index.d.ts.map +1 -1
  12. package/internal/components/screenreader-only/index.js.map +1 -1
  13. package/internal/environment.js +1 -1
  14. package/internal/environment.json +1 -1
  15. package/internal/manifest.json +1 -1
  16. package/package.json +1 -1
  17. package/table/column-widths-utils.d.ts +0 -1
  18. package/table/column-widths-utils.d.ts.map +1 -1
  19. package/table/column-widths-utils.js +0 -18
  20. package/table/column-widths-utils.js.map +1 -1
  21. package/table/internal.d.ts.map +1 -1
  22. package/table/internal.js +4 -5
  23. package/table/internal.js.map +1 -1
  24. package/table/sticky-columns/use-sticky-columns.js +1 -1
  25. package/table/sticky-columns/use-sticky-columns.js.map +1 -1
  26. package/table/thead.d.ts +1 -0
  27. package/table/thead.d.ts.map +1 -1
  28. package/table/thead.js +18 -3
  29. package/table/thead.js.map +1 -1
  30. package/table/use-column-widths.d.ts +3 -5
  31. package/table/use-column-widths.d.ts.map +1 -1
  32. package/table/use-column-widths.js +11 -57
  33. package/table/use-column-widths.js.map +1 -1
  34. package/table/use-sticky-header.d.ts.map +1 -1
  35. package/table/use-sticky-header.js +13 -0
  36. package/table/use-sticky-header.js.map +1 -1
@@ -25,7 +25,7 @@ export default function useScrollSpy({ hrefs, scrollSpyOffset, activeHref, }) {
25
25
  setLastAnchorExists(isBrowser && !!document.getElementById((_a = hrefs[hrefs.length - 1]) === null || _a === void 0 ? void 0 : _a.slice(1)));
26
26
  }, [hrefs]);
27
27
  // Get the bounding rectangle of an element by href
28
- const getRectByHref = useCallback((href) => {
28
+ const getRectByHref = useCallback(href => {
29
29
  var _a;
30
30
  return (_a = document.getElementById(href.slice(1))) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
31
31
  }, []);
@@ -1 +1 @@
1
- {"version":3,"file":"use-scroll-spy.js","sourceRoot":"lib/default/","sources":["anchor-navigation/use-scroll-spy.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,KAAK,EACL,eAAe,EACf,UAAU,GAKX;IACC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAqB,UAAU,CAAC,CAAC;IAC/E,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhE,SAAS,CAAC,GAAG,EAAE;QACb,cAAc,CAAC,UAAU,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,SAAS,CAAC,GAAG,EAAE;;QACb,mBAAmB,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAA,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,mDAAmD;IACnD,MAAM,aAAa,GAAG,WAAW,CAAC,CAAC,IAAY,EAAE,EAAE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AAG,EAAE;QACpC,IAAI,UAAU,IAAI,CAAC,SAAS,EAAE;YAC5B,OAAO;SACR;QAED,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAE3B,IAAI,QAAQ,CAAC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,IAAI,YAAY,EAAE,EAAE;YACrE,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;SACzC;aAAM;YACL,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;SACtF;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC;IAE1E,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,EAAE;YACb,YAAY,EAAE,CAAC;YACf,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YACnE,OAAO,GAAG,EAAE;gBACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACrD,CAAC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useCallback, useEffect, useState } from 'react';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Hook to implement scroll-spy functionality.\n *\n * @param hrefs An array of href strings that correspond to the IDs of the target elements on the page.\n * The hrefs should be sorted in the order they appear on the page for accurate scroll-spy behavior.\n * @param scrollSpyOffset The number of pixels to offset from the top of the document when activating anchors.\n * Useful for accommodating fixed or sticky headers.\n * @param activeHref The currently active href. If provided, the hook will operate in a controlled manner,\n * and the scroll-spy logic will be disabled.\n *\n * @returns {string | undefined} - The href of the currently active element as per scroll position, or undefined if none is active.\n */\nexport default function useScrollSpy({\n hrefs,\n scrollSpyOffset,\n activeHref,\n}: {\n hrefs: string[];\n scrollSpyOffset: number;\n activeHref?: string;\n}): string | undefined {\n const [currentHref, setCurrentHref] = useState<string | undefined>(activeHref);\n const [lastAnchorExists, setLastAnchorExists] = useState(false);\n\n useEffect(() => {\n setCurrentHref(activeHref);\n }, [activeHref]);\n\n useEffect(() => {\n setLastAnchorExists(isBrowser && !!document.getElementById(hrefs[hrefs.length - 1]?.slice(1)));\n }, [hrefs]);\n\n // Get the bounding rectangle of an element by href\n const getRectByHref = useCallback((href: string) => {\n return document.getElementById(href.slice(1))?.getBoundingClientRect();\n }, []);\n\n // Check if we're scrolled to the bottom of the page\n const isPageBottom = useCallback(() => {\n return lastAnchorExists && Math.ceil(window.scrollY) >= Math.floor(document.body.scrollHeight - window.innerHeight);\n }, [lastAnchorExists]);\n\n // Find the first href for which the element is within the viewport\n const findHrefInView = useCallback(() => {\n return hrefs.find(href => {\n const rect = getRectByHref(href);\n return rect && rect.bottom <= window.innerHeight && rect.top >= scrollSpyOffset;\n });\n }, [getRectByHref, scrollSpyOffset, hrefs]);\n\n // Find the last href where its element is above or within the viewport\n const findLastHrefInView = useCallback(() => {\n return [...hrefs].reverse().find(href => {\n const rect = getRectByHref(href);\n return rect && rect.bottom <= window.innerHeight;\n });\n }, [getRectByHref, hrefs]);\n\n // Scroll event handler\n const handleScroll = useCallback(() => {\n if (activeHref || !isBrowser) {\n return;\n }\n\n const { scrollY } = window;\n\n if (document.body.scrollHeight > window.innerHeight && isPageBottom()) {\n setCurrentHref(hrefs[hrefs.length - 1]);\n } else {\n setCurrentHref(findHrefInView() || (scrollY > 0 ? findLastHrefInView() : undefined));\n }\n }, [activeHref, isPageBottom, findHrefInView, findLastHrefInView, hrefs]);\n\n useEffect(() => {\n if (isBrowser) {\n handleScroll();\n window.addEventListener('scroll', handleScroll, { passive: true });\n return () => {\n window.removeEventListener('scroll', handleScroll);\n };\n }\n }, [handleScroll]);\n\n return currentHref;\n}\n"]}
1
+ {"version":3,"file":"use-scroll-spy.js","sourceRoot":"lib/default/","sources":["anchor-navigation/use-scroll-spy.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,KAAK,EACL,eAAe,EACf,UAAU,GAKX;IACC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAqB,UAAU,CAAC,CAAC;IAC/E,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhE,SAAS,CAAC,GAAG,EAAE;QACb,cAAc,CAAC,UAAU,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,SAAS,CAAC,GAAG,EAAE;;QACb,mBAAmB,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAA,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,mDAAmD;IACnD,MAAM,aAAa,GAAG,WAAW,CAAC,IAAI,CAAC,EAAE;;QACvC,OAAO,MAAA,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,0CAAE,qBAAqB,EAAE,CAAC;IACzE,CAAC,EAAE,EAAE,CAAC,CAAC;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AAC,YAAY,GAAG,MAAM,CAAC,WAAW,IAAI,YAAY,EAAE,EAAE;YACrE,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;SACzC;aAAM;YACL,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;SACtF;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC;IAE1E,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,EAAE;YACb,YAAY,EAAE,CAAC;YACf,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YACnE,OAAO,GAAG,EAAE;gBACV,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACrD,CAAC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useCallback, useEffect, useState } from 'react';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * Hook to implement scroll-spy functionality.\n *\n * @param hrefs An array of href strings that correspond to the IDs of the target elements on the page.\n * The hrefs should be sorted in the order they appear on the page for accurate scroll-spy behavior.\n * @param scrollSpyOffset The number of pixels to offset from the top of the document when activating anchors.\n * Useful for accommodating fixed or sticky headers.\n * @param activeHref The currently active href. If provided, the hook will operate in a controlled manner,\n * and the scroll-spy logic will be disabled.\n *\n * @returns {string | undefined} - The href of the currently active element as per scroll position, or undefined if none is active.\n */\nexport default function useScrollSpy({\n hrefs,\n scrollSpyOffset,\n activeHref,\n}: {\n hrefs: string[];\n scrollSpyOffset: number;\n activeHref?: string;\n}): string | undefined {\n const [currentHref, setCurrentHref] = useState<string | undefined>(activeHref);\n const [lastAnchorExists, setLastAnchorExists] = useState(false);\n\n useEffect(() => {\n setCurrentHref(activeHref);\n }, [activeHref]);\n\n useEffect(() => {\n setLastAnchorExists(isBrowser && !!document.getElementById(hrefs[hrefs.length - 1]?.slice(1)));\n }, [hrefs]);\n\n // Get the bounding rectangle of an element by href\n const getRectByHref = useCallback(href => {\n return document.getElementById(href.slice(1))?.getBoundingClientRect();\n }, []);\n\n // Check if we're scrolled to the bottom of the page\n const isPageBottom = useCallback(() => {\n return lastAnchorExists && Math.ceil(window.scrollY) >= Math.floor(document.body.scrollHeight - window.innerHeight);\n }, [lastAnchorExists]);\n\n // Find the first href for which the element is within the viewport\n const findHrefInView = useCallback(() => {\n return hrefs.find(href => {\n const rect = getRectByHref(href);\n return rect && rect.bottom <= window.innerHeight && rect.top >= scrollSpyOffset;\n });\n }, [getRectByHref, scrollSpyOffset, hrefs]);\n\n // Find the last href where its element is above or within the viewport\n const findLastHrefInView = useCallback(() => {\n return [...hrefs].reverse().find(href => {\n const rect = getRectByHref(href);\n return rect && rect.bottom <= window.innerHeight;\n });\n }, [getRectByHref, hrefs]);\n\n // Scroll event handler\n const handleScroll = useCallback(() => {\n if (activeHref || !isBrowser) {\n return;\n }\n\n const { scrollY } = window;\n\n if (document.body.scrollHeight > window.innerHeight && isPageBottom()) {\n setCurrentHref(hrefs[hrefs.length - 1]);\n } else {\n setCurrentHref(findHrefInView() || (scrollY > 0 ? findLastHrefInView() : undefined));\n }\n }, [activeHref, isPageBottom, findHrefInView, findLastHrefInView, hrefs]);\n\n useEffect(() => {\n if (isBrowser) {\n handleScroll();\n window.addEventListener('scroll', handleScroll, { passive: true });\n return () => {\n window.removeEventListener('scroll', handleScroll);\n };\n }\n }, [handleScroll]);\n\n return currentHref;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"flash.d.ts","sourceRoot":"lib/default/","sources":["flashbar/flash.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAiD1B,eAAO,MAAM,cAAc,mEACf,WAAW,GAAG,IAAI,UAAU,MAAM,UAM7C,CAAC;AAEF,MAAM,WAAW,UAAW,SAAQ,aAAa,CAAC,iBAAiB;IACjE,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;CACzC;AAED,eAAO,MAAM,KAAK,mFAyHjB,CAAC"}
1
+ {"version":3,"file":"flash.d.ts","sourceRoot":"lib/default/","sources":["flashbar/flash.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAiD1B,eAAO,MAAM,cAAc,mEACf,WAAW,GAAG,IAAI,UAAU,MAAM,UAM7C,CAAC;AAEF,MAAM,WAAW,UAAW,SAAQ,aAAa,CAAC,iBAAiB;IACjE,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;CACzC;AAED,eAAO,MAAM,KAAK,mFAsHjB,CAAC"}
package/flashbar/flash.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { __rest } from "tslib";
1
2
  import React from 'react';
2
3
  import InternalSpinner from '../spinner/internal';
3
4
  import InternalIcon from '../icon/internal';
@@ -32,7 +33,8 @@ export const focusFlashById = throttle((element, itemId) => {
32
33
  const selector = `[data-itemid="${CSS.escape(itemId)}"] .${styles['flash-focus-container']}`;
33
34
  (_a = element === null || element === void 0 ? void 0 : element.querySelector(selector)) === null || _a === void 0 ? void 0 : _a.focus();
34
35
  }, FOCUS_THROTTLE_DELAY, { trailing: false });
35
- export const Flash = React.forwardRef(({ id, header, content, dismissible, dismissLabel, statusIconAriaLabel, loading, action, buttonText, onButtonClick, onDismiss, className, transitionState, ariaRole, i18nStrings, type = 'info', }, ref) => {
36
+ export const Flash = React.forwardRef((_a, ref) => {
37
+ var { id, header, content, dismissible, dismissLabel, loading, action, buttonText, onButtonClick, onDismiss, className, transitionState, ariaRole, i18nStrings, type = 'info' } = _a, props = __rest(_a, ["id", "header", "content", "dismissible", "dismissLabel", "loading", "action", "buttonText", "onButtonClick", "onDismiss", "className", "transitionState", "ariaRole", "i18nStrings", "type"]);
36
38
  if (isDevelopment) {
37
39
  if (buttonText && !onButtonClick) {
38
40
  warnOnce('Flashbar', `You provided a \`buttonText\` prop without an \`onButtonClick\` handler. This will render a non-interactive action button.`);
@@ -52,6 +54,8 @@ export const Flash = React.forwardRef(({ id, header, content, dismissible, dismi
52
54
  const analyticsAttributes = {
53
55
  [DATA_ATTR_ANALYTICS_FLASHBAR]: effectiveType,
54
56
  };
57
+ const statusIconAriaLabel = props.statusIconAriaLabel ||
58
+ (i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings[`${loading || type === 'in-progress' ? 'inProgress' : type}IconAriaLabel`]);
55
59
  return (
56
60
  // We're not using "polite" or "assertive" here, just turning default behavior off.
57
61
  // eslint-disable-next-line @cloudscape-design/prefer-live-region
@@ -65,8 +69,7 @@ export const Flash = React.forwardRef(({ id, header, content, dismissible, dismi
65
69
  }, getVisualContextClassname(type === 'warning' && !loading ? 'flashbar-warning' : 'flashbar')) }, analyticsAttributes),
66
70
  React.createElement("div", { className: styles['flash-body'] },
67
71
  React.createElement("div", { className: styles['flash-focus-container'], tabIndex: -1 },
68
- React.createElement("div", { className: clsx(styles['flash-icon'], styles['flash-text']), role: "img", "aria-label": statusIconAriaLabel ||
69
- (i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings[`${loading || type === 'in-progress' ? 'inProgress' : type}IconAriaLabel`]) }, icon),
72
+ React.createElement("div", { className: clsx(styles['flash-icon'], styles['flash-text']), role: "img", "aria-label": statusIconAriaLabel }, icon),
70
73
  React.createElement("div", { className: clsx(styles['flash-message'], styles['flash-text']) },
71
74
  React.createElement("div", { className: styles['flash-header'], ref: headerRef }, header),
72
75
  React.createElement("div", { className: styles['flash-content'], ref: contentRef }, content))),
@@ -75,11 +78,6 @@ export const Flash = React.forwardRef(({ id, header, content, dismissible, dismi
75
78
  actionButton: styles['action-button'],
76
79
  }, action: action, discoveredActions: discoveredActions, buttonText: buttonText, onButtonClick: onButtonClick })),
77
80
  dismissible && dismissButton(dismissLabel, handleDismiss),
78
- ariaRole === 'status' && (React.createElement(LiveRegion, null,
79
- statusIconAriaLabel,
80
- " ",
81
- header,
82
- " ",
83
- content))));
81
+ ariaRole === 'status' && React.createElement(LiveRegion, { source: [statusIconAriaLabel, headerRef, contentRef] })));
84
82
  });
85
83
  //# sourceMappingURL=flash.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flash.js","sourceRoot":"lib/default/","sources":["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,+CAA+C,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,UAAU,MAAM,oCAAoC,CAAC;AAE5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MA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,SAAS,IACnD,MAAM,CACH;oBACN,6BAAK,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,EAAE,GAAG,EAAE,UAAU,IACrD,OAAO,CACJ,CACF,CACF;YACN,oBAAC,cAAc,IACb,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC,EAC1C,eAAe,EAAE;oBACf,UAAU,EAAE,MAAM,CAAC,aAAa,CAAC;oBACjC,YAAY,EAAE,MAAM,CAAC,eAAe,CAAC;iBACtC,EACD,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,iBAAiB,EACpC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,GAC5B,CACE;QACL,WAAW,IAAI,aAAa,CAAC,YAAY,EAAE,aAAa,CAAC;QACzD,QAAQ,KAAK,QAAQ,IAAI,CACxB,oBAAC,UAAU;YACR,mBAAmB;;YAAG,MAAM;;YAAG,OAAO,CAC5B,CACd,CACG,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 '@cloudscape-design/component-toolkit/internal';\nimport { isDevelopment } from '../internal/is-development';\nimport { throttle } from '../internal/utils/throttle';\nimport LiveRegion from '../internal/components/live-region';\nimport { ButtonProps } from '../button/interfaces';\nimport { getVisualContextClassname } from '../internal/components/visual-context';\n\nimport { sendDismissMetric } from './internal/analytics';\n\nimport { FOCUS_THROTTLE_DELAY } from './utils';\nimport { DATA_ATTR_ANALYTICS_FLASHBAR } from '../internal/analytics/selectors';\nimport { createUseDiscoveredAction } from '../internal/plugins/helpers';\nimport { awsuiPluginsInternal } from '../internal/plugins/api';\nimport { ActionsWrapper } from '../alert/actions-wrapper';\n\nconst ICON_TYPES = {\n success: 'status-positive',\n warning: 'status-warning',\n info: 'status-info',\n error: 'status-negative',\n 'in-progress': 'status-in-progress',\n} as const;\n\nconst useDiscoveredAction = createUseDiscoveredAction(awsuiPluginsInternal.flashbar.onActionRegistered);\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 i18nStrings?: FlashbarProps.I18nStrings;\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 i18nStrings,\n type = 'info',\n }: FlashProps,\n ref: React.Ref<HTMLDivElement>\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 { discoveredActions, headerRef, contentRef } = useDiscoveredAction(type);\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 handleDismiss: ButtonProps['onClick'] = event => {\n sendDismissMetric(effectiveType);\n onDismiss && onDismiss(event);\n };\n\n const analyticsAttributes = {\n [DATA_ATTR_ANALYTICS_FLASHBAR]: effectiveType,\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 getVisualContextClassname(type === 'warning' && !loading ? 'flashbar-warning' : 'flashbar')\n )}\n {...analyticsAttributes}\n >\n <div className={styles['flash-body']}>\n <div className={styles['flash-focus-container']} tabIndex={-1}>\n <div\n className={clsx(styles['flash-icon'], styles['flash-text'])}\n role=\"img\"\n aria-label={\n statusIconAriaLabel ||\n i18nStrings?.[`${loading || type === 'in-progress' ? 'inProgress' : type}IconAriaLabel`]\n }\n >\n {icon}\n </div>\n <div className={clsx(styles['flash-message'], styles['flash-text'])}>\n <div className={styles['flash-header']} ref={headerRef}>\n {header}\n </div>\n <div className={styles['flash-content']} ref={contentRef}>\n {content}\n </div>\n </div>\n </div>\n <ActionsWrapper\n className={styles['action-button-wrapper']}\n testUtilClasses={{\n actionSlot: styles['action-slot'],\n actionButton: styles['action-button'],\n }}\n action={action}\n discoveredActions={discoveredActions}\n buttonText={buttonText}\n onButtonClick={onButtonClick}\n />\n </div>\n {dismissible && dismissButton(dismissLabel, handleDismiss)}\n {ariaRole === 'status' && (\n <LiveRegion>\n {statusIconAriaLabel} {header} {content}\n </LiveRegion>\n )}\n </div>\n );\n }\n);\n"]}
1
+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AC,UAAU,IAAC,MAAM,EAAE,CAAC,mBAAmB,EAAE,SAAS,EAAE,UAAU,CAAC,GAAI,CAC1F,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 '@cloudscape-design/component-toolkit/internal';\nimport { isDevelopment } from '../internal/is-development';\nimport { throttle } from '../internal/utils/throttle';\nimport LiveRegion from '../internal/components/live-region';\nimport { ButtonProps } from '../button/interfaces';\nimport { getVisualContextClassname } from '../internal/components/visual-context';\n\nimport { sendDismissMetric } from './internal/analytics';\n\nimport { FOCUS_THROTTLE_DELAY } from './utils';\nimport { DATA_ATTR_ANALYTICS_FLASHBAR } from '../internal/analytics/selectors';\nimport { createUseDiscoveredAction } from '../internal/plugins/helpers';\nimport { awsuiPluginsInternal } from '../internal/plugins/api';\nimport { ActionsWrapper } from '../alert/actions-wrapper';\n\nconst ICON_TYPES = {\n success: 'status-positive',\n warning: 'status-warning',\n info: 'status-info',\n error: 'status-negative',\n 'in-progress': 'status-in-progress',\n} as const;\n\nconst useDiscoveredAction = createUseDiscoveredAction(awsuiPluginsInternal.flashbar.onActionRegistered);\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 i18nStrings?: FlashbarProps.I18nStrings;\n}\n\nexport const Flash = React.forwardRef(\n (\n {\n id,\n header,\n content,\n dismissible,\n dismissLabel,\n loading,\n action,\n buttonText,\n onButtonClick,\n onDismiss,\n className,\n transitionState,\n ariaRole,\n i18nStrings,\n type = 'info',\n ...props\n }: FlashProps,\n ref: React.Ref<HTMLDivElement>\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 { discoveredActions, headerRef, contentRef } = useDiscoveredAction(type);\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 handleDismiss: ButtonProps['onClick'] = event => {\n sendDismissMetric(effectiveType);\n onDismiss && onDismiss(event);\n };\n\n const analyticsAttributes = {\n [DATA_ATTR_ANALYTICS_FLASHBAR]: effectiveType,\n };\n\n const statusIconAriaLabel =\n props.statusIconAriaLabel ||\n i18nStrings?.[`${loading || type === 'in-progress' ? 'inProgress' : type}IconAriaLabel`];\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 getVisualContextClassname(type === 'warning' && !loading ? 'flashbar-warning' : 'flashbar')\n )}\n {...analyticsAttributes}\n >\n <div className={styles['flash-body']}>\n <div 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']} ref={headerRef}>\n {header}\n </div>\n <div className={styles['flash-content']} ref={contentRef}>\n {content}\n </div>\n </div>\n </div>\n <ActionsWrapper\n className={styles['action-button-wrapper']}\n testUtilClasses={{\n actionSlot: styles['action-slot'],\n actionButton: styles['action-button'],\n }}\n action={action}\n discoveredActions={discoveredActions}\n buttonText={buttonText}\n onButtonClick={onButtonClick}\n />\n </div>\n {dismissible && dismissButton(dismissLabel, handleDismiss)}\n {ariaRole === 'status' && <LiveRegion source={[statusIconAriaLabel, headerRef, contentRef]} />}\n </div>\n );\n }\n);\n"]}
@@ -5,8 +5,15 @@ export interface LiveRegionProps extends ScreenreaderOnlyProps {
5
5
  delay?: number;
6
6
  visible?: boolean;
7
7
  tagName?: 'span' | 'div';
8
- children: React.ReactNode;
9
8
  id?: string;
9
+ /**
10
+ * Use a list of strings and/or existing DOM elements for building the
11
+ * announcement text. This avoids rendering separate content just for this
12
+ * LiveRegion.
13
+ *
14
+ * If this property is set, the `children` will be ignored.
15
+ */
16
+ source?: Array<string | React.RefObject<HTMLElement> | undefined>;
10
17
  }
11
18
  /**
12
19
  * The live region is hidden in the layout, but visible for screen readers.
@@ -17,31 +24,42 @@ export interface LiveRegionProps extends ScreenreaderOnlyProps {
17
24
  *
18
25
  * If you notice there are different words being merged together,
19
26
  * check if there are text nodes not being wrapped in elements, like:
27
+ * ```
20
28
  * <LiveRegion>
21
29
  * {title}
22
30
  * <span><Details /></span>
23
31
  * </LiveRegion>
32
+ * ```
24
33
  *
25
34
  * To fix, wrap "title" in an element:
35
+ * ```
26
36
  * <LiveRegion>
27
37
  * <span>{title}</span>
28
38
  * <span><Details /></span>
29
39
  * </LiveRegion>
40
+ * ```
30
41
  *
31
42
  * Or create a single text node if possible:
43
+ * ```
32
44
  * <LiveRegion>
33
45
  * {`${title} ${details}`}
34
46
  * </LiveRegion>
47
+ * ```
35
48
  *
36
49
  * The live region is always atomic, because non-atomic regions can be treated by screen readers
37
50
  * differently and produce unexpected results. To imitate non-atomic announcements simply use
38
51
  * multiple live regions:
52
+ * ```
39
53
  * <>
40
54
  * <LiveRegion>{title}</LiveRegion>
41
55
  * <LiveRegion><Details /></LiveRegion>
42
56
  * </>
57
+ * ```
58
+ *
59
+ * If you place interactive content inside the LiveRegion, the content will still be
60
+ * interactive (e.g. as a tab stop). Consider using the `source` property instead.
43
61
  */
44
62
  declare const _default: React.MemoExoticComponent<typeof LiveRegion>;
45
63
  export default _default;
46
- declare function LiveRegion({ assertive, delay, visible, tagName: TagName, children, id, ...restProps }: LiveRegionProps): JSX.Element;
64
+ declare function LiveRegion({ assertive, delay, visible, tagName: TagName, children, id, source, ...restProps }: LiveRegionProps): JSX.Element;
47
65
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/components/live-region/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAkC,MAAM,OAAO,CAAC;AACvD,OAAyB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAG/E,MAAM,WAAW,eAAgB,SAAQ,qBAAqB;IAC5D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;;AACH,wBAAgC;AAEhC,iBAAS,UAAU,CAAC,EAClB,SAAiB,EACjB,KAAU,EACV,OAAe,EACf,OAAO,EAAE,OAAgB,EACzB,QAAQ,EACR,EAAE,EACF,GAAG,SAAS,EACb,EAAE,eAAe,eA8DjB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/components/live-region/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAkC,MAAM,OAAO,CAAC;AACvD,OAAyB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAG/E,MAAM,WAAW,eAAgB,SAAQ,qBAAqB;IAC5D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC,CAAC;CACnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;;AACH,wBAAgC;AAEhC,iBAAS,UAAU,CAAC,EAClB,SAAiB,EACjB,KAAU,EACV,OAAe,EACf,OAAO,EAAE,OAAgB,EACzB,QAAQ,EACR,EAAE,EACF,MAAM,EACN,GAAG,SAAS,EACb,EAAE,eAAe,eAqFjB"}
@@ -15,33 +15,44 @@ import styles from './styles.css.js';
15
15
  *
16
16
  * If you notice there are different words being merged together,
17
17
  * check if there are text nodes not being wrapped in elements, like:
18
+ * ```
18
19
  * <LiveRegion>
19
20
  * {title}
20
21
  * <span><Details /></span>
21
22
  * </LiveRegion>
23
+ * ```
22
24
  *
23
25
  * To fix, wrap "title" in an element:
26
+ * ```
24
27
  * <LiveRegion>
25
28
  * <span>{title}</span>
26
29
  * <span><Details /></span>
27
30
  * </LiveRegion>
31
+ * ```
28
32
  *
29
33
  * Or create a single text node if possible:
34
+ * ```
30
35
  * <LiveRegion>
31
36
  * {`${title} ${details}`}
32
37
  * </LiveRegion>
38
+ * ```
33
39
  *
34
40
  * The live region is always atomic, because non-atomic regions can be treated by screen readers
35
41
  * differently and produce unexpected results. To imitate non-atomic announcements simply use
36
42
  * multiple live regions:
43
+ * ```
37
44
  * <>
38
45
  * <LiveRegion>{title}</LiveRegion>
39
46
  * <LiveRegion><Details /></LiveRegion>
40
47
  * </>
48
+ * ```
49
+ *
50
+ * If you place interactive content inside the LiveRegion, the content will still be
51
+ * interactive (e.g. as a tab stop). Consider using the `source` property instead.
41
52
  */
42
53
  export default memo(LiveRegion);
43
54
  function LiveRegion(_a) {
44
- var { assertive = false, delay = 10, visible = false, tagName: TagName = 'span', children, id } = _a, restProps = __rest(_a, ["assertive", "delay", "visible", "tagName", "children", "id"]);
55
+ var { assertive = false, delay = 10, visible = false, tagName: TagName = 'span', children, id, source } = _a, restProps = __rest(_a, ["assertive", "delay", "visible", "tagName", "children", "id", "source"]);
45
56
  const sourceRef = useRef(null);
46
57
  const targetRef = useRef(null);
47
58
  /*
@@ -56,9 +67,30 @@ function LiveRegion(_a) {
56
67
  does not impact the performance. If it does, prefer using a string as children prop.
57
68
  */
58
69
  useEffect(() => {
70
+ function getSourceContent() {
71
+ if (source) {
72
+ return source
73
+ .map(item => {
74
+ if (!item) {
75
+ return undefined;
76
+ }
77
+ if (typeof item === 'string') {
78
+ return item;
79
+ }
80
+ if (item.current) {
81
+ return extractInnerText(item.current);
82
+ }
83
+ })
84
+ .filter(Boolean)
85
+ .join(' ');
86
+ }
87
+ if (sourceRef.current) {
88
+ return extractInnerText(sourceRef.current);
89
+ }
90
+ }
59
91
  function updateLiveRegion() {
60
- if (targetRef.current && sourceRef.current) {
61
- const sourceContent = extractInnerText(sourceRef.current);
92
+ const sourceContent = getSourceContent();
93
+ if (targetRef.current && sourceContent) {
62
94
  const targetContent = extractInnerText(targetRef.current);
63
95
  if (targetContent !== sourceContent) {
64
96
  // The aria-atomic does not work properly in Voice Over, causing
@@ -82,9 +114,9 @@ function LiveRegion(_a) {
82
114
  };
83
115
  });
84
116
  return (React.createElement(React.Fragment, null,
85
- visible && (React.createElement(TagName, { ref: sourceRef, id: id }, children)),
117
+ visible && !source && (React.createElement(TagName, { ref: sourceRef, id: id }, children)),
86
118
  React.createElement(ScreenreaderOnly, Object.assign({}, restProps, { className: clsx(styles.root, restProps.className) }),
87
- !visible && (React.createElement(TagName, { ref: sourceRef, "aria-hidden": "true" }, children)),
119
+ !visible && !source && (React.createElement(TagName, { ref: sourceRef, "aria-hidden": "true" }, children)),
88
120
  React.createElement("span", { ref: targetRef, "aria-atomic": "true", "aria-live": assertive ? 'assertive' : 'polite' }))));
89
121
  }
90
122
  // This only extracts text content from the node including all its children which is enough for now.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["internal/components/live-region/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,0DAA0D;AAE1D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,gBAA2C,MAAM,sBAAsB,CAAC;AAC/E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAWrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAe,IAAI,CAAC,UAAU,CAAC,CAAC;AAEhC,SAAS,UAAU,CAAC,EAQF;QARE,EAClB,SAAS,GAAG,KAAK,EACjB,KAAK,GAAG,EAAE,EACV,OAAO,GAAG,KAAK,EACf,OAAO,EAAE,OAA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QAAQ,CACD,CACX;YAED,8BAAM,GAAG,EAAE,SAAS,iBAAc,MAAM,eAAY,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,GAAS,CAC9E,CAClB,CACJ,CAAC;AACJ,CAAC;AAED,oGAAoG;AACpG,oGAAoG;AACpG,0FAA0F;AAC1F,SAAS,gBAAgB,CAAC,IAAiB;IACzC,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC5D,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n/* eslint-disable @cloudscape-design/prefer-live-region */\n\nimport clsx from 'clsx';\nimport React, { memo, useEffect, useRef } from 'react';\nimport ScreenreaderOnly, { ScreenreaderOnlyProps } from '../screenreader-only';\nimport styles from './styles.css.js';\n\nexport interface LiveRegionProps extends ScreenreaderOnlyProps {\n assertive?: boolean;\n delay?: number;\n visible?: boolean;\n tagName?: 'span' | 'div';\n children: React.ReactNode;\n id?: string;\n}\n\n/**\n * The live region is hidden in the layout, but visible for screen readers.\n * It's purpose it to announce changes e.g. when custom navigation logic is used.\n *\n * The way live region works differently in different browsers and screen readers and\n * it is recommended to manually test every new implementation.\n *\n * If you notice there are different words being merged together,\n * check if there are text nodes not being wrapped in elements, like:\n * <LiveRegion>\n * {title}\n * <span><Details /></span>\n * </LiveRegion>\n *\n * To fix, wrap \"title\" in an element:\n * <LiveRegion>\n * <span>{title}</span>\n * <span><Details /></span>\n * </LiveRegion>\n *\n * Or create a single text node if possible:\n * <LiveRegion>\n * {`${title} ${details}`}\n * </LiveRegion>\n *\n * The live region is always atomic, because non-atomic regions can be treated by screen readers\n * differently and produce unexpected results. To imitate non-atomic announcements simply use\n * multiple live regions:\n * <>\n * <LiveRegion>{title}</LiveRegion>\n * <LiveRegion><Details /></LiveRegion>\n * </>\n */\nexport default memo(LiveRegion);\n\nfunction LiveRegion({\n assertive = false,\n delay = 10,\n visible = false,\n tagName: TagName = 'span',\n children,\n id,\n ...restProps\n}: LiveRegionProps) {\n const sourceRef = useRef<HTMLSpanElement & HTMLDivElement>(null);\n const targetRef = useRef<HTMLSpanElement & HTMLDivElement>(null);\n\n /*\n When React state changes, React often produces too many DOM updates, causing NVDA to\n issue many announcements for the same logical event (See https://github.com/nvaccess/nvda/issues/7996).\n\n The code below imitates a debouncing, scheduling a callback every time new React state\n update is detected. When a callback resolves, it copies content from a muted element\n to the live region, which is recognized by screen readers as an update.\n\n If the use case requires no announcement to be ignored, use delay = 0, but ensure it\n does not impact the performance. If it does, prefer using a string as children prop.\n */\n useEffect(() => {\n function updateLiveRegion() {\n if (targetRef.current && sourceRef.current) {\n const sourceContent = extractInnerText(sourceRef.current);\n const targetContent = extractInnerText(targetRef.current);\n if (targetContent !== sourceContent) {\n // The aria-atomic does not work properly in Voice Over, causing\n // certain parts of the content to be ignored. To fix that,\n // we assign the source text content as a single node.\n targetRef.current.innerText = sourceContent;\n }\n }\n }\n\n let timeoutId: null | number;\n if (delay) {\n timeoutId = setTimeout(updateLiveRegion, delay);\n } else {\n updateLiveRegion();\n }\n\n return () => {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n };\n });\n\n return (\n <>\n {visible && (\n <TagName ref={sourceRef} id={id}>\n {children}\n </TagName>\n )}\n\n <ScreenreaderOnly {...restProps} className={clsx(styles.root, restProps.className)}>\n {!visible && (\n <TagName ref={sourceRef} aria-hidden=\"true\">\n {children}\n </TagName>\n )}\n\n <span ref={targetRef} aria-atomic=\"true\" aria-live={assertive ? 'assertive' : 'polite'}></span>\n </ScreenreaderOnly>\n </>\n );\n}\n\n// This only extracts text content from the node including all its children which is enough for now.\n// To make it more powerful, it is possible to create a more sophisticated extractor with respect to\n// ARIA properties to ignore aria-hidden nodes and read ARIA labels from the live content.\nfunction extractInnerText(node: HTMLElement) {\n return (node.innerText || '').replace(/\\s+/g, ' ').trim();\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["internal/components/live-region/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,0DAA0D;AAE1D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,gBAA2C,MAAM,sBAAsB,CAAC;AAC/E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAkBrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAe,IAAI,CAAC,UAAU,CAAC,CAAC;AAEhC,SAAS,UAAU,CAAC,EASF;QATE,EAClB,SAAS,GAAG,KAAK,EACjB,KAAK,GAAG,EAAE,EACV,OAAO,GAAG,KAAK,EACf,OAAO,EAAE,OAAO,GAAG,MAAM,EACzB,QAAQ,EACR,EAAE,EACF,MAAM,OAEU,EADb,SAAS,cARM,wEASnB,CADa;IAEZ,MAAM,SAAS,GAAG,MAAM,CAAmC,IAAI,CAAC,CAAC;IACjE,MAAM,SAAS,GAAG,MAAM,CAAmC,IAAI,CAAC,CAAC;IAEjE;;;;;;;;;;MAUE;IACF,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,gBAAgB;YACvB,IAAI,MAAM,EAAE;gBACV,OAAO,MAAM;qBACV,GAAG,CAAC,IAAI,CAAC,EAAE;oBACV,IAAI,CAAC,IAAI,EAAE;wBACT,OAAO,SAAS,CAAC;qBAClB;oBACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;wBAC5B,OAAO,IAAI,CAAC;qBACb;oBACD,IAAI,IAAI,CAAC,OAAO,EAAE;wBAChB,OAAO,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;qBACvC;gBACH,CAAC,CAAC;qBACD,MAAM,CAAC,OAAO,CAAC;qBACf,IAAI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AC,CAAC,CAAC,QAAQ,GAAS,CAC9E,CAClB,CACJ,CAAC;AACJ,CAAC;AAED,oGAAoG;AACpG,oGAAoG;AACpG,0FAA0F;AAC1F,SAAS,gBAAgB,CAAC,IAAiB;IACzC,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC5D,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n/* eslint-disable @cloudscape-design/prefer-live-region */\n\nimport clsx from 'clsx';\nimport React, { memo, useEffect, useRef } from 'react';\nimport ScreenreaderOnly, { ScreenreaderOnlyProps } from '../screenreader-only';\nimport styles from './styles.css.js';\n\nexport interface LiveRegionProps extends ScreenreaderOnlyProps {\n assertive?: boolean;\n delay?: number;\n visible?: boolean;\n tagName?: 'span' | 'div';\n id?: string;\n /**\n * Use a list of strings and/or existing DOM elements for building the\n * announcement text. This avoids rendering separate content just for this\n * LiveRegion.\n *\n * If this property is set, the `children` will be ignored.\n */\n source?: Array<string | React.RefObject<HTMLElement> | undefined>;\n}\n\n/**\n * The live region is hidden in the layout, but visible for screen readers.\n * It's purpose it to announce changes e.g. when custom navigation logic is used.\n *\n * The way live region works differently in different browsers and screen readers and\n * it is recommended to manually test every new implementation.\n *\n * If you notice there are different words being merged together,\n * check if there are text nodes not being wrapped in elements, like:\n * ```\n * <LiveRegion>\n * {title}\n * <span><Details /></span>\n * </LiveRegion>\n * ```\n *\n * To fix, wrap \"title\" in an element:\n * ```\n * <LiveRegion>\n * <span>{title}</span>\n * <span><Details /></span>\n * </LiveRegion>\n * ```\n *\n * Or create a single text node if possible:\n * ```\n * <LiveRegion>\n * {`${title} ${details}`}\n * </LiveRegion>\n * ```\n *\n * The live region is always atomic, because non-atomic regions can be treated by screen readers\n * differently and produce unexpected results. To imitate non-atomic announcements simply use\n * multiple live regions:\n * ```\n * <>\n * <LiveRegion>{title}</LiveRegion>\n * <LiveRegion><Details /></LiveRegion>\n * </>\n * ```\n *\n * If you place interactive content inside the LiveRegion, the content will still be\n * interactive (e.g. as a tab stop). Consider using the `source` property instead.\n */\nexport default memo(LiveRegion);\n\nfunction LiveRegion({\n assertive = false,\n delay = 10,\n visible = false,\n tagName: TagName = 'span',\n children,\n id,\n source,\n ...restProps\n}: LiveRegionProps) {\n const sourceRef = useRef<HTMLSpanElement & HTMLDivElement>(null);\n const targetRef = useRef<HTMLSpanElement & HTMLDivElement>(null);\n\n /*\n When React state changes, React often produces too many DOM updates, causing NVDA to\n issue many announcements for the same logical event (See https://github.com/nvaccess/nvda/issues/7996).\n\n The code below imitates a debouncing, scheduling a callback every time new React state\n update is detected. When a callback resolves, it copies content from a muted element\n to the live region, which is recognized by screen readers as an update.\n\n If the use case requires no announcement to be ignored, use delay = 0, but ensure it\n does not impact the performance. If it does, prefer using a string as children prop.\n */\n useEffect(() => {\n function getSourceContent() {\n if (source) {\n return source\n .map(item => {\n if (!item) {\n return undefined;\n }\n if (typeof item === 'string') {\n return item;\n }\n if (item.current) {\n return extractInnerText(item.current);\n }\n })\n .filter(Boolean)\n .join(' ');\n }\n\n if (sourceRef.current) {\n return extractInnerText(sourceRef.current);\n }\n }\n function updateLiveRegion() {\n const sourceContent = getSourceContent();\n\n if (targetRef.current && sourceContent) {\n const targetContent = extractInnerText(targetRef.current);\n if (targetContent !== sourceContent) {\n // The aria-atomic does not work properly in Voice Over, causing\n // certain parts of the content to be ignored. To fix that,\n // we assign the source text content as a single node.\n targetRef.current.innerText = sourceContent;\n }\n }\n }\n\n let timeoutId: null | number;\n if (delay) {\n timeoutId = setTimeout(updateLiveRegion, delay);\n } else {\n updateLiveRegion();\n }\n\n return () => {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n };\n });\n\n return (\n <>\n {visible && !source && (\n <TagName ref={sourceRef} id={id}>\n {children}\n </TagName>\n )}\n\n <ScreenreaderOnly {...restProps} className={clsx(styles.root, restProps.className)}>\n {!visible && !source && (\n <TagName ref={sourceRef} aria-hidden=\"true\">\n {children}\n </TagName>\n )}\n\n <span ref={targetRef} aria-atomic=\"true\" aria-live={assertive ? 'assertive' : 'polite'}></span>\n </ScreenreaderOnly>\n </>\n );\n}\n\n// This only extracts text content from the node including all its children which is enough for now.\n// To make it more powerful, it is possible to create a more sophisticated extractor with respect to\n// ARIA properties to ignore aria-hidden nodes and read ARIA labels from the live content.\nfunction extractInnerText(node: HTMLElement) {\n return (node.innerText || '').replace(/\\s+/g, ' ').trim();\n}\n"]}
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  export interface ScreenreaderOnlyProps {
3
3
  id?: string;
4
4
  className?: string;
5
- children: React.ReactNode;
5
+ children?: React.ReactNode;
6
6
  }
7
7
  /**
8
8
  * Makes content now shown on a screen but still announced by screen-reader users.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/components/screenreader-only/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,qBAAqB;IACpC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,eAEpE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/components/screenreader-only/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,qBAAqB;IACpC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,eAEpE"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["internal/components/screenreader-only/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAQrC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,KAA4B;IACnE,OAAO,8CAAU,KAAK,IAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC;AAC5E,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport clsx from 'clsx';\nimport React from 'react';\nimport styles from './styles.css.js';\n\nexport interface ScreenreaderOnlyProps {\n id?: string;\n className?: string;\n children: React.ReactNode;\n}\n\n/**\n * Makes content now shown on a screen but still announced by screen-reader users.\n * The component is suitable when the aria-label cannot be used, e.g. to avoid elemnts being announced as \"blank\".\n *\n * To exclude screenreader-only content use `:not(.${screenreaderOnlyStyles.root})` selector, for example:\n *\n * ```\n * import screenreaderOnlyStyles from '~internal/components/screenreader-only/styles.css.js'\n *\n * let visibleContent = wrapper.find(`${styles.label}`).find(`:not(.${screenreaderOnlyStyles.root})`).getElement().textContent\n *\n * let screenreaderContent = wrapper.find(`${styles.label}`).find(`.${screenreaderOnlyStyles.root}`).getElement().textContent\n * ```\n */\nexport default function ScreenreaderOnly(props: ScreenreaderOnlyProps) {\n return <span {...props} className={clsx(styles.root, props.className)} />;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["internal/components/screenreader-only/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAQrC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,KAA4B;IACnE,OAAO,8CAAU,KAAK,IAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC;AAC5E,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport clsx from 'clsx';\nimport React from 'react';\nimport styles from './styles.css.js';\n\nexport interface ScreenreaderOnlyProps {\n id?: string;\n className?: string;\n children?: React.ReactNode;\n}\n\n/**\n * Makes content now shown on a screen but still announced by screen-reader users.\n * The component is suitable when the aria-label cannot be used, e.g. to avoid elemnts being announced as \"blank\".\n *\n * To exclude screenreader-only content use `:not(.${screenreaderOnlyStyles.root})` selector, for example:\n *\n * ```\n * import screenreaderOnlyStyles from '~internal/components/screenreader-only/styles.css.js'\n *\n * let visibleContent = wrapper.find(`${styles.label}`).find(`:not(.${screenreaderOnlyStyles.root})`).getElement().textContent\n *\n * let screenreaderContent = wrapper.find(`${styles.label}`).find(`.${screenreaderOnlyStyles.root}`).getElement().textContent\n * ```\n */\nexport default function ScreenreaderOnly(props: ScreenreaderOnlyProps) {\n return <span {...props} className={clsx(styles.root, props.className)} />;\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (00c3e7ae)";
2
+ export var PACKAGE_VERSION = "3.0.0 (be8a0396)";
3
3
  export var THEME = "open-source-visual-refresh";
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (00c3e7ae)",
3
+ "PACKAGE_VERSION": "3.0.0 (be8a0396)",
4
4
  "THEME": "default",
5
5
  "ALWAYS_VISUAL_REFRESH": false
6
6
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "00c3e7ae5e175f7ad7a87a9b5e9571bad9aefe22"
2
+ "commit": "be8a0396919c2f0cc51c918ff929d0508c4958f0"
3
3
  }
package/package.json CHANGED
@@ -113,7 +113,7 @@
113
113
  "./internal/base-component/index.js",
114
114
  "./internal/base-component/styles.css.js"
115
115
  ],
116
- "version": "3.0.442",
116
+ "version": "3.0.443",
117
117
  "repository": {
118
118
  "type": "git",
119
119
  "url": "https://github.com/cloudscape-design/components.git"
@@ -1,4 +1,3 @@
1
1
  import { TableProps } from './interfaces';
2
2
  export declare function checkColumnWidths(columnDefinitions: ReadonlyArray<TableProps.ColumnDefinition<any>>): void;
3
- export declare function setElementWidths(element: undefined | HTMLElement, styles: React.CSSProperties): void;
4
3
  //# sourceMappingURL=column-widths-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"column-widths-utils.d.ts","sourceRoot":"lib/default/","sources":["table/column-widths-utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,wBAAgB,iBAAiB,CAAC,iBAAiB,EAAE,aAAa,CAAC,UAAU,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAKnG;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,SAAS,GAAG,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,aAAa,QAiB7F"}
1
+ {"version":3,"file":"column-widths-utils.d.ts","sourceRoot":"lib/default/","sources":["table/column-widths-utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,wBAAgB,iBAAiB,CAAC,iBAAiB,EAAE,aAAa,CAAC,UAAU,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAKnG"}
@@ -7,24 +7,6 @@ export function checkColumnWidths(columnDefinitions) {
7
7
  checkProperty(column, 'width');
8
8
  }
9
9
  }
10
- export function setElementWidths(element, styles) {
11
- function setProperty(property) {
12
- const value = styles[property];
13
- let widthCssValue = '';
14
- if (typeof value === 'number') {
15
- widthCssValue = value + 'px';
16
- }
17
- if (typeof value === 'string') {
18
- widthCssValue = value;
19
- }
20
- if (element && element.style[property] !== widthCssValue) {
21
- element.style[property] = widthCssValue;
22
- }
23
- }
24
- setProperty('width');
25
- setProperty('minWidth');
26
- setProperty('maxWidth');
27
- }
28
10
  function checkProperty(column, name) {
29
11
  const value = column[name];
30
12
  if (typeof value !== 'number' && typeof value !== 'undefined') {
@@ -1 +1 @@
1
- {"version":3,"file":"column-widths-utils.js","sourceRoot":"lib/default/","sources":["table/column-widths-utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAGzE,MAAM,UAAU,iBAAiB,CAAC,iBAAkE;IAClG,KAAK,MAAM,MAAM,IAAI,iBAAiB,EAAE;QACtC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAClC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAChC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAgC,EAAE,MAA2B;IAC5F,SAAS,WAAW,CAAC,QAA2C;QAC9D,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/B,IAAI,aAAa,GAAG,EAAE,CAAC;QACvB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,aAAa,GAAG,KAAK,GAAG,IAAI,CAAC;SAC9B;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,aAAa,GAAG,KAAK,CAAC;SACvB;QACD,IAAI,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,aAAa,EAAE;YACxD,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC;SACzC;IACH,CAAC;IACD,WAAW,CAAC,OAAO,CAAC,CAAC;IACrB,WAAW,CAAC,UAAU,CAAC,CAAC;IACxB,WAAW,CAAC,UAAU,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,aAAa,CAAC,MAAwC,EAAE,IAA0B;IACzF,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;QAC7D,QAAQ,CACN,OAAO,EACP,qCAAqC,IAAI,iCAAiC,KAAK,uCAAuC,CACvH,CAAC;KACH;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { TableProps } from './interfaces';\n\nexport function checkColumnWidths(columnDefinitions: ReadonlyArray<TableProps.ColumnDefinition<any>>) {\n for (const column of columnDefinitions) {\n checkProperty(column, 'minWidth');\n checkProperty(column, 'width');\n }\n}\n\nexport function setElementWidths(element: undefined | HTMLElement, styles: React.CSSProperties) {\n function setProperty(property: 'width' | 'minWidth' | 'maxWidth') {\n const value = styles[property];\n let widthCssValue = '';\n if (typeof value === 'number') {\n widthCssValue = value + 'px';\n }\n if (typeof value === 'string') {\n widthCssValue = value;\n }\n if (element && element.style[property] !== widthCssValue) {\n element.style[property] = widthCssValue;\n }\n }\n setProperty('width');\n setProperty('minWidth');\n setProperty('maxWidth');\n}\n\nfunction checkProperty(column: TableProps.ColumnDefinition<any>, name: 'width' | 'minWidth') {\n const value = column[name];\n if (typeof value !== 'number' && typeof value !== 'undefined') {\n warnOnce(\n 'Table',\n `resizableColumns feature requires ${name} property to be a number, got ${value}. The component may work incorrectly.`\n );\n }\n}\n"]}
1
+ {"version":3,"file":"column-widths-utils.js","sourceRoot":"lib/default/","sources":["table/column-widths-utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAGzE,MAAM,UAAU,iBAAiB,CAAC,iBAAkE;IAClG,KAAK,MAAM,MAAM,IAAI,iBAAiB,EAAE;QACtC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAClC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAChC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,MAAwC,EAAE,IAA0B;IACzF,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;QAC7D,QAAQ,CACN,OAAO,EACP,qCAAqC,IAAI,iCAAiC,KAAK,uCAAuC,CACvH,CAAC;KACH;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { TableProps } from './interfaces';\n\nexport function checkColumnWidths(columnDefinitions: ReadonlyArray<TableProps.ColumnDefinition<any>>) {\n for (const column of columnDefinitions) {\n checkProperty(column, 'minWidth');\n checkProperty(column, 'width');\n }\n}\n\nfunction checkProperty(column: TableProps.ColumnDefinition<any>, name: 'width' | 'minWidth') {\n const value = column[name];\n if (typeof value !== 'number' && typeof value !== 'undefined') {\n warnOnce(\n 'Table',\n `resizableColumns feature requires ${name} property to be a number, got ${value}. The component may work incorrectly.`\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["table/internal.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAc,MAAM,cAAc,CAAC;AA+C/D,eAAO,MAAM,sBAAsB,qBAWX,CAAC;AAEzB,QAAA,MAAM,aAAa,qBAqbK,CAAC;AAEzB,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["table/internal.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAc,MAAM,cAAc,CAAC;AA+C/D,eAAO,MAAM,sBAAsB,qBAWX,CAAC;AAEzB,QAAA,MAAM,aAAa,qBAgbK,CAAC;AAEzB,eAAe,aAAa,CAAC"}
package/table/internal.js CHANGED
@@ -52,8 +52,7 @@ const InternalTable = React.forwardRef((_a, ref) => {
52
52
  stickyHeader = stickyHeader && supportsStickyPosition();
53
53
  const isMobile = useMobile();
54
54
  const [containerWidth, wrapperMeasureRef] = useContainerQuery(rect => rect.contentBoxWidth);
55
- const wrapperMeasureRefObject = useRef(null);
56
- const wrapperMeasureMergedRef = useMergeRefs(wrapperMeasureRef, wrapperMeasureRefObject);
55
+ const wrapperRefObject = useRef(null);
57
56
  const [tableWidth, tableMeasureRef] = useContainerQuery(rect => rect.contentBoxWidth);
58
57
  const tableRefObject = useRef(null);
59
58
  const secondaryWrapperRef = React.useRef(null);
@@ -68,7 +67,6 @@ const InternalTable = React.forwardRef((_a, ref) => {
68
67
  cancelEdit,
69
68
  });
70
69
  }, [cancelEdit]);
71
- const wrapperRefObject = useRef(null);
72
70
  const handleScroll = useScrollSync([wrapperRefObject, scrollbarRef, secondaryWrapperRef]);
73
71
  const { moveFocusDown, moveFocusUp, moveFocus } = useSelectionFocusMove(selectionType, items.length);
74
72
  const { onRowClickHandler, onRowContextMenuHandler } = useRowEvents({ onRowClick, onRowContextMenu });
@@ -130,6 +128,7 @@ const InternalTable = React.forwardRef((_a, ref) => {
130
128
  const hasEditableCells = !!columnDefinitions.find(col => col.editConfig);
131
129
  const tableRole = hasEditableCells ? 'grid-default' : 'table';
132
130
  const theadProps = {
131
+ containerWidth,
133
132
  selectionType,
134
133
  getSelectAllProps,
135
134
  columnDefinitions: visibleColumnDefinitions,
@@ -171,7 +170,7 @@ const InternalTable = React.forwardRef((_a, ref) => {
171
170
  const toolsHeaderHeight = (_f = (_e = toolsHeaderWrapper === null || toolsHeaderWrapper === void 0 ? void 0 : toolsHeaderWrapper.current) === null || _e === void 0 ? void 0 : _e.getBoundingClientRect().height) !== null && _f !== void 0 ? _f : 0;
172
171
  const totalColumnsCount = selectionType ? visibleColumnDefinitions.length + 1 : visibleColumnDefinitions.length;
173
172
  return (React.createElement(LinkDefaultVariantContext.Provider, { value: { defaultVariant: 'primary' } },
174
- React.createElement(ColumnWidthsProvider, { visibleColumns: visibleColumnWidthsWithSelection, resizableColumns: resizableColumns, containerRef: wrapperMeasureRefObject },
173
+ React.createElement(ColumnWidthsProvider, { visibleColumns: visibleColumnWidthsWithSelection, resizableColumns: resizableColumns },
175
174
  React.createElement(InternalContainer, Object.assign({}, baseProps, { __internalRootRef: __internalRootRef, className: clsx(baseProps.className, styles.root), __funnelSubStepProps: __funnelSubStepProps, header: React.createElement(React.Fragment, null,
176
175
  hasHeader && (React.createElement("div", { ref: overlapElement, className: clsx(hasDynamicHeight && [styles['dark-header'], 'awsui-context-content-header']) },
177
176
  React.createElement("div", { ref: toolsHeaderWrapper, className: clsx(styles['header-controls'], styles[`variant-${computedVariant}`]) },
@@ -185,7 +184,7 @@ const InternalTable = React.forwardRef((_a, ref) => {
185
184
  [styles['has-footer']]: hasFooter,
186
185
  [styles['has-header']]: hasHeader,
187
186
  }), style: stickyState.style.wrapper, onScroll: handleScroll }, wrapperProps),
188
- React.createElement("div", { className: styles['wrapper-content-measure'], ref: wrapperMeasureMergedRef }),
187
+ React.createElement("div", { className: styles['wrapper-content-measure'], ref: wrapperMeasureRef }),
189
188
  !!renderAriaLive && !!firstIndex && (React.createElement(LiveRegion, null,
190
189
  React.createElement("span", null, renderAriaLive({ totalItemsCount, firstIndex, lastIndex: firstIndex + items.length - 1 })))),
191
190
  React.createElement("table", Object.assign({ ref: tableRef, className: clsx(styles.table, resizableColumns && styles['table-layout-fixed'], contentDensity === 'compact' && getVisualContextClassname('compact-table')) }, getTableRoleProps({