@cloudscape-design/components 3.0.1165 → 3.0.1166
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app-layout/visual-refresh/drawers.d.ts.map +1 -1
- package/app-layout/visual-refresh/drawers.js +2 -2
- package/app-layout/visual-refresh/drawers.js.map +1 -1
- package/app-layout/visual-refresh/main.d.ts.map +1 -1
- package/app-layout/visual-refresh/main.js +3 -1
- package/app-layout/visual-refresh/main.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/drawer/local-drawer.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/drawer/local-drawer.js +2 -2
- package/app-layout/visual-refresh-toolbar/drawer/local-drawer.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/skeleton/index.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/skeleton/index.js +2 -1
- package/app-layout/visual-refresh-toolbar/skeleton/index.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/toolbar/index.js +1 -1
- package/app-layout/visual-refresh-toolbar/toolbar/index.js.map +1 -1
- package/attribute-editor/styles.css.js +15 -15
- package/attribute-editor/styles.scoped.css +26 -26
- package/attribute-editor/styles.selectors.js +15 -15
- package/container/internal.d.ts +6 -0
- package/container/internal.d.ts.map +1 -1
- package/container/internal.js +32 -28
- package/container/internal.js.map +1 -1
- package/drawer/implementation.d.ts.map +1 -1
- package/drawer/implementation.js +5 -3
- package/drawer/implementation.js.map +1 -1
- package/error-boundary/fallback.d.ts +5 -0
- package/error-boundary/fallback.d.ts.map +1 -0
- package/error-boundary/fallback.js +61 -0
- package/error-boundary/fallback.js.map +1 -0
- package/error-boundary/index.d.ts +7 -0
- package/error-boundary/index.d.ts.map +1 -0
- package/error-boundary/index.js +22 -0
- package/error-boundary/index.js.map +1 -0
- package/error-boundary/interfaces.d.ts +84 -0
- package/error-boundary/interfaces.d.ts.map +1 -0
- package/error-boundary/interfaces.js +4 -0
- package/error-boundary/interfaces.js.map +1 -0
- package/error-boundary/internal.d.ts +30 -0
- package/error-boundary/internal.d.ts.map +1 -0
- package/error-boundary/internal.js +58 -0
- package/error-boundary/internal.js.map +1 -0
- package/error-boundary/styles.css.js +9 -0
- package/error-boundary/styles.scoped.css +10 -0
- package/error-boundary/styles.selectors.js +10 -0
- package/error-boundary/test-classes/styles.css.js +11 -0
- package/error-boundary/test-classes/styles.scoped.css +12 -0
- package/error-boundary/test-classes/styles.selectors.js +12 -0
- package/error-boundary/utils.d.ts +1 -0
- package/error-boundary/utils.d.ts.map +1 -0
- package/error-boundary/utils.js +7 -0
- package/error-boundary/utils.js.map +1 -0
- package/form/internal.d.ts.map +1 -1
- package/form/internal.js +20 -14
- package/form/internal.js.map +1 -1
- package/i18n/messages-types.d.ts +5 -4
- package/i18n/messages-types.d.ts.map +1 -1
- package/i18n/messages-types.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/internal/base-component/styles.scoped.css +1 -1
- package/internal/environment.js +2 -2
- package/internal/environment.json +2 -2
- package/internal/manifest.json +1 -1
- package/modal/internal.d.ts.map +1 -1
- package/modal/internal.js +8 -5
- package/modal/internal.js.map +1 -1
- package/package.json +2 -1
- package/popover/body.d.ts.map +1 -1
- package/popover/body.js +10 -8
- package/popover/body.js.map +1 -1
- package/split-panel/implementation.d.ts.map +1 -1
- package/split-panel/implementation.js +5 -2
- package/split-panel/implementation.js.map +1 -1
- package/tabs/index.d.ts.map +1 -1
- package/tabs/index.js +1 -1
- package/tabs/index.js.map +1 -1
- package/test-utils/dom/error-boundary/index.d.ts +9 -0
- package/test-utils/dom/error-boundary/index.js +26 -0
- package/test-utils/dom/error-boundary/index.js.map +1 -0
- package/test-utils/dom/index.d.ts +20 -0
- package/test-utils/dom/index.js +16 -2
- package/test-utils/dom/index.js.map +1 -1
- package/test-utils/selectors/error-boundary/index.d.ts +9 -0
- package/test-utils/selectors/error-boundary/index.js +26 -0
- package/test-utils/selectors/error-boundary/index.js.map +1 -0
- package/test-utils/selectors/index.d.ts +18 -0
- package/test-utils/selectors/index.js +16 -2
- package/test-utils/selectors/index.js.map +1 -1
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"empty-appear": "awsui_empty-
|
|
6
|
-
"awsui-motion-fade-in": "awsui_awsui-motion-fade-
|
|
7
|
-
"root": "
|
|
8
|
-
"empty": "
|
|
9
|
-
"row": "
|
|
10
|
-
"divider": "
|
|
11
|
-
"row-control": "awsui_row-
|
|
12
|
-
"field": "
|
|
13
|
-
"additional-info": "awsui_additional-
|
|
14
|
-
"add-row": "awsui_add-
|
|
15
|
-
"add-button": "awsui_add-
|
|
16
|
-
"remove-button-container": "awsui_remove-button-
|
|
17
|
-
"remove-button-field-padding": "awsui_remove-button-field-
|
|
18
|
-
"remove-button-own-row": "awsui_remove-button-own-
|
|
19
|
-
"remove-button": "awsui_remove-
|
|
5
|
+
"empty-appear": "awsui_empty-appear_n4qlp_tbn7a_153",
|
|
6
|
+
"awsui-motion-fade-in": "awsui_awsui-motion-fade-in_n4qlp_tbn7a_1",
|
|
7
|
+
"root": "awsui_root_n4qlp_tbn7a_175",
|
|
8
|
+
"empty": "awsui_empty_n4qlp_tbn7a_153",
|
|
9
|
+
"row": "awsui_row_n4qlp_tbn7a_218",
|
|
10
|
+
"divider": "awsui_divider_n4qlp_tbn7a_222",
|
|
11
|
+
"row-control": "awsui_row-control_n4qlp_tbn7a_227",
|
|
12
|
+
"field": "awsui_field_n4qlp_tbn7a_231",
|
|
13
|
+
"additional-info": "awsui_additional-info_n4qlp_tbn7a_235",
|
|
14
|
+
"add-row": "awsui_add-row_n4qlp_tbn7a_281",
|
|
15
|
+
"add-button": "awsui_add-button_n4qlp_tbn7a_285",
|
|
16
|
+
"remove-button-container": "awsui_remove-button-container_n4qlp_tbn7a_289",
|
|
17
|
+
"remove-button-field-padding": "awsui_remove-button-field-padding_n4qlp_tbn7a_293",
|
|
18
|
+
"remove-button-own-row": "awsui_remove-button-own-row_n4qlp_tbn7a_297",
|
|
19
|
+
"remove-button": "awsui_remove-button_n4qlp_tbn7a_289"
|
|
20
20
|
};
|
|
21
21
|
|
package/container/internal.d.ts
CHANGED
|
@@ -21,6 +21,11 @@ export interface InternalContainerProps extends Omit<ContainerProps, 'variant'>,
|
|
|
21
21
|
variant?: ContainerProps['variant'] | 'embedded' | 'full-page' | 'cards';
|
|
22
22
|
__funnelSubStepProps?: ReturnType<typeof useFunnelSubStep>['funnelSubStepProps'];
|
|
23
23
|
__subStepRef?: ReturnType<typeof useFunnelSubStep>['subStepRef'];
|
|
24
|
+
/**
|
|
25
|
+
* React key attached to the content wrapper. It is used to force content re-mount but not container re-mount, which
|
|
26
|
+
* is necessary for components that use container as a root node internally so that their test-utils wrapper is not detached.
|
|
27
|
+
*/
|
|
28
|
+
__contentKey?: string;
|
|
24
29
|
}
|
|
25
30
|
export declare function InternalContainerAsSubstep(props: InternalContainerProps): JSX.Element;
|
|
26
31
|
export default function InternalContainer({
|
|
@@ -45,5 +50,6 @@ export default function InternalContainer({
|
|
|
45
50
|
__disableStickyMobile,
|
|
46
51
|
__funnelSubStepProps,
|
|
47
52
|
__subStepRef,
|
|
53
|
+
__contentKey,
|
|
48
54
|
...restProps
|
|
49
55
|
}: InternalContainerProps): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/container/internal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/container/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAQtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAI1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGl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EACb,EAAE,sBAAsB,eAwIxB"}
|
package/container/internal.js
CHANGED
|
@@ -4,6 +4,8 @@ import React, { useRef } from 'react';
|
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { useMergeRefs, useUniqueId } from '@cloudscape-design/component-toolkit/internal';
|
|
6
6
|
import { getAnalyticsLabelAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';
|
|
7
|
+
import InternalBox from '../box/internal';
|
|
8
|
+
import { BuiltInErrorBoundary } from '../error-boundary/internal';
|
|
7
9
|
import { useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';
|
|
8
10
|
import { getBaseProps } from '../internal/base-component';
|
|
9
11
|
import { ContainerHeaderContextProvider } from '../internal/context/container-header';
|
|
@@ -20,7 +22,7 @@ export function InternalContainerAsSubstep(props) {
|
|
|
20
22
|
const modalContext = useModalContext();
|
|
21
23
|
return (React.createElement(InternalContainer, { ...props, __subStepRef: (modalContext === null || modalContext === void 0 ? void 0 : modalContext.isInModal) ? { current: null } : subStepRef, __funnelSubStepProps: (modalContext === null || modalContext === void 0 ? void 0 : modalContext.isInModal) ? {} : funnelSubStepProps }));
|
|
22
24
|
}
|
|
23
|
-
export default function InternalContainer({ header, footer, children, variant = 'default', disableHeaderPaddings = false, disableContentPaddings = false, disableFooterPaddings = false, fitHeight, media, style, __stickyOffset, __mobileStickyOffset, __stickyHeader = false, __internalRootRef, __disableFooterDivider = false, __hiddenContent = false, __headerRef, __fullPage = false, __disableStickyMobile = true, __funnelSubStepProps, __subStepRef, ...restProps }) {
|
|
25
|
+
export default function InternalContainer({ header, footer, children, variant = 'default', disableHeaderPaddings = false, disableContentPaddings = false, disableFooterPaddings = false, fitHeight, media, style, __stickyOffset, __mobileStickyOffset, __stickyHeader = false, __internalRootRef, __disableFooterDivider = false, __hiddenContent = false, __headerRef, __fullPage = false, __disableStickyMobile = true, __funnelSubStepProps, __subStepRef, __contentKey, ...restProps }) {
|
|
24
26
|
var _a;
|
|
25
27
|
const isMobile = useMobile();
|
|
26
28
|
const isRefresh = useVisualRefresh();
|
|
@@ -41,32 +43,34 @@ export default function InternalContainer({ header, footer, children, variant =
|
|
|
41
43
|
hasMedia && (React.createElement("div", { className: clsx(styles[`media-${mediaPosition === 'side' ? 'side' : 'top'}`], styles.media), style: mediaPosition === 'top'
|
|
42
44
|
? { ...getMediaStyles(mediaPosition, style), height: (media === null || media === void 0 ? void 0 : media.height) || '' }
|
|
43
45
|
: { ...getMediaStyles(mediaPosition, style), width: (media === null || media === void 0 ? void 0 : media.width) || '' } }, media.content)),
|
|
44
|
-
React.createElement("div", { id: contentId, ref: __subStepRef, className: clsx(styles['content-wrapper'], fitHeight && styles['content-wrapper-fit-height']) },
|
|
45
|
-
|
|
46
|
-
React.createElement(
|
|
47
|
-
React.createElement(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
React.createElement("div", { className: clsx(styles
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
46
|
+
React.createElement("div", { id: contentId, ref: __subStepRef, key: __contentKey, className: clsx(styles['content-wrapper'], fitHeight && styles['content-wrapper-fit-height']) },
|
|
47
|
+
React.createElement(BuiltInErrorBoundary, { wrapper: content => React.createElement(InternalBox, { padding: "m" }, content) },
|
|
48
|
+
header && (React.createElement(ContainerHeaderContextProvider, null,
|
|
49
|
+
React.createElement(StickyHeaderContext.Provider, { value: { isStuck, isStuckAtBottom } },
|
|
50
|
+
React.createElement("div", { className: clsx(isRefresh && styles.refresh, styles.header, analyticsSelectors.header, styles[`header-variant-${variant}`], {
|
|
51
|
+
[styles['header-sticky-disabled']]: __stickyHeader && !isSticky,
|
|
52
|
+
[styles['header-sticky-enabled']]: isSticky,
|
|
53
|
+
[styles['header-dynamic-height']]: hasDynamicHeight,
|
|
54
|
+
[styles['header-stuck']]: isStuck,
|
|
55
|
+
[styles['with-paddings']]: !disableHeaderPaddings,
|
|
56
|
+
[styles['with-hidden-content']]: !children || __hiddenContent,
|
|
57
|
+
[styles['header-with-media']]: hasMedia,
|
|
58
|
+
[styles['header-full-page']]: __fullPage && isRefresh,
|
|
59
|
+
}), ref: headerMergedRef, style: {
|
|
60
|
+
...stickyStyles.style,
|
|
61
|
+
...getHeaderStyles(style),
|
|
62
|
+
} },
|
|
63
|
+
isStuck && !isMobile && isRefresh && __fullPage && React.createElement("div", { className: styles['header-cover'] }),
|
|
64
|
+
header)))),
|
|
65
|
+
React.createElement("div", { className: clsx(styles.content, fitHeight && styles['content-fit-height']) },
|
|
66
|
+
React.createElement("div", { className: clsx(styles['content-inner'], testStyles['content-inner'], {
|
|
67
|
+
[styles['with-paddings']]: !disableContentPaddings,
|
|
68
|
+
[styles['with-header']]: !!header,
|
|
69
|
+
}), style: getContentStyles(style) },
|
|
70
|
+
React.createElement(BuiltInErrorBoundary, { wrapper: content => (React.createElement(InternalBox, { padding: disableContentPaddings ? 'm' : undefined }, content)) }, children))),
|
|
71
|
+
footer && (React.createElement("div", { className: clsx(styles.footer, {
|
|
72
|
+
[styles['with-divider']]: !__disableFooterDivider,
|
|
73
|
+
[styles['with-paddings']]: !disableFooterPaddings,
|
|
74
|
+
}), style: getFooterStyles(style) }, footer))))));
|
|
71
75
|
}
|
|
72
76
|
//# sourceMappingURL=internal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/container/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MA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AAG,eAAe,CAAC,KAAK,CAAC;yBAC1B;wBAEA,OAAO,IAAI,CAAC,QAAQ,IAAI,SAAS,IAAI,UAAU,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC,GAAQ;wBACjG,MAAM,CACH,CACuB,CACA,CAClC;YACD,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,IAAI,MAAM,CAAC,oBAAoB,CAAC,CAAC;gBAC7E,6BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,EAAE;wBACpE,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,sBAAsB;wBAClD,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM;qBAClC,CAAC,EACF,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,IAE7B,QAAQ,CACL,CACF;YACL,MAAM,IAAI,CACT,6BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;oBAC7B,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,sBAAsB;oBACjD,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,qBAAqB;iBAClD,CAAC,EACF,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,IAE5B,MAAM,CACH,CACP,CACG,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\nimport { getAnalyticsLabelAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport { getBaseProps } from '../internal/base-component';\nimport { ContainerHeaderContextProvider } from '../internal/context/container-header';\nimport { useModalContext } from '../internal/context/modal-context';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useMobile } from '../internal/hooks/use-mobile';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { ContainerProps } from './interfaces';\nimport { getContentStyles, getFooterStyles, getHeaderStyles, getMediaStyles, getRootStyles } from './style';\nimport { StickyHeaderContext, useStickyHeader } from './use-sticky-header';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\nimport testStyles from './test-classes/styles.css.js';\n\nexport interface InternalContainerProps extends Omit<ContainerProps, 'variant'>, InternalBaseComponentProps {\n disableFooterPaddings?: boolean;\n __stickyHeader?: boolean;\n __stickyOffset?: number;\n __mobileStickyOffset?: number;\n __disableFooterDivider?: boolean;\n __hiddenContent?: boolean;\n __headerRef?: React.RefObject<HTMLDivElement>;\n __fullPage?: boolean;\n __disableStickyMobile?: boolean;\n /**\n * Additional internal variant:\n * * `embedded` - Use this variant within a parent container (such as a modal,\n * expandable section, container or split panel).\n * * `full-page` – Only for internal use in table, cards and other components\n */\n variant?: ContainerProps['variant'] | 'embedded' | 'full-page' | 'cards';\n\n __funnelSubStepProps?: ReturnType<typeof useFunnelSubStep>['funnelSubStepProps'];\n __subStepRef?: ReturnType<typeof useFunnelSubStep>['subStepRef'];\n}\n\nexport function InternalContainerAsSubstep(props: InternalContainerProps) {\n const { subStepRef, funnelSubStepProps } = useFunnelSubStep();\n const modalContext = useModalContext();\n\n return (\n <InternalContainer\n {...props}\n __subStepRef={modalContext?.isInModal ? { current: null } : subStepRef}\n __funnelSubStepProps={modalContext?.isInModal ? {} : funnelSubStepProps}\n />\n );\n}\n\nexport default function InternalContainer({\n header,\n footer,\n children,\n variant = 'default',\n disableHeaderPaddings = false,\n disableContentPaddings = false,\n disableFooterPaddings = false,\n fitHeight,\n media,\n style,\n __stickyOffset,\n __mobileStickyOffset,\n __stickyHeader = false,\n __internalRootRef,\n __disableFooterDivider = false,\n __hiddenContent = false,\n __headerRef,\n __fullPage = false,\n __disableStickyMobile = true,\n __funnelSubStepProps,\n __subStepRef,\n ...restProps\n}: InternalContainerProps) {\n const isMobile = useMobile();\n const isRefresh = useVisualRefresh();\n const baseProps = getBaseProps(restProps);\n const rootRef = useRef<HTMLDivElement>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n const { isSticky, isStuck, isStuckAtBottom, stickyStyles } = useStickyHeader(\n rootRef,\n headerRef,\n __stickyHeader,\n __stickyOffset,\n __mobileStickyOffset,\n __disableStickyMobile,\n __fullPage && isRefresh && !isMobile\n );\n const contentId = useUniqueId();\n\n const hasDynamicHeight = isRefresh && variant === 'full-page';\n\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n const headerMergedRef = useMergeRefs(headerRef, __headerRef);\n\n // The container is only sticky on mobile if it is the header for the table.\n // In this case we don't want the container to have sticky styles, as only the table header row will show as stuck on scroll.\n const shouldHaveStickyStyles = isSticky && !isMobile;\n\n const hasMedia = !!media?.content;\n const mediaPosition = media?.position ?? 'top';\n\n return (\n <div\n {...baseProps}\n {...__funnelSubStepProps}\n className={clsx(\n baseProps.className,\n styles.root,\n styles[`variant-${variant}`],\n fitHeight && styles['fit-height'],\n hasMedia && (mediaPosition === 'side' ? styles['with-side-media'] : styles['with-top-media']),\n shouldHaveStickyStyles && [styles['sticky-enabled']],\n shouldHaveStickyStyles && isStuck && isStuckAtBottom && [styles['with-stuck-sticky-header-at-bottom']],\n isRefresh && styles.refresh\n )}\n ref={mergedRef}\n {...getAnalyticsLabelAttribute(\n `.${analyticsSelectors.header} h1, .${analyticsSelectors.header} h2, .${analyticsSelectors.header} h3`\n )}\n style={getRootStyles(style)}\n >\n {hasMedia && (\n <div\n className={clsx(styles[`media-${mediaPosition === 'side' ? 'side' : 'top'}`], styles.media)}\n style={\n mediaPosition === 'top'\n ? { ...getMediaStyles(mediaPosition, style), height: media?.height || '' }\n : { ...getMediaStyles(mediaPosition, style), width: media?.width || '' }\n }\n >\n {media.content}\n </div>\n )}\n <div\n id={contentId}\n ref={__subStepRef}\n className={clsx(styles['content-wrapper'], fitHeight && styles['content-wrapper-fit-height'])}\n >\n {header && (\n <ContainerHeaderContextProvider>\n <StickyHeaderContext.Provider value={{ isStuck, isStuckAtBottom }}>\n <div\n className={clsx(\n isRefresh && styles.refresh,\n styles.header,\n analyticsSelectors.header,\n styles[`header-variant-${variant}`],\n {\n [styles['header-sticky-disabled']]: __stickyHeader && !isSticky,\n [styles['header-sticky-enabled']]: isSticky,\n [styles['header-dynamic-height']]: hasDynamicHeight,\n [styles['header-stuck']]: isStuck,\n [styles['with-paddings']]: !disableHeaderPaddings,\n [styles['with-hidden-content']]: !children || __hiddenContent,\n [styles['header-with-media']]: hasMedia,\n [styles['header-full-page']]: __fullPage && isRefresh,\n }\n )}\n ref={headerMergedRef}\n style={{\n ...stickyStyles.style,\n ...getHeaderStyles(style),\n }}\n >\n {isStuck && !isMobile && isRefresh && __fullPage && <div className={styles['header-cover']}></div>}\n {header}\n </div>\n </StickyHeaderContext.Provider>\n </ContainerHeaderContextProvider>\n )}\n <div className={clsx(styles.content, fitHeight && styles['content-fit-height'])}>\n <div\n className={clsx(styles['content-inner'], testStyles['content-inner'], {\n [styles['with-paddings']]: !disableContentPaddings,\n [styles['with-header']]: !!header,\n })}\n style={getContentStyles(style)}\n >\n {children}\n </div>\n </div>\n {footer && (\n <div\n className={clsx(styles.footer, {\n [styles['with-divider']]: !__disableFooterDivider,\n [styles['with-paddings']]: !disableFooterPaddings,\n })}\n style={getFooterStyles(style)}\n >\n {footer}\n </div>\n )}\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/container/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,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,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,qBAAqB;qBAClD,CAAC,EACF,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,IAE5B,MAAM,CACH,CACP,CACoB,CACnB,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\nimport { getAnalyticsLabelAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport InternalBox from '../box/internal';\nimport { BuiltInErrorBoundary } from '../error-boundary/internal';\nimport { useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport { getBaseProps } from '../internal/base-component';\nimport { ContainerHeaderContextProvider } from '../internal/context/container-header';\nimport { useModalContext } from '../internal/context/modal-context';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useMobile } from '../internal/hooks/use-mobile';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { ContainerProps } from './interfaces';\nimport { getContentStyles, getFooterStyles, getHeaderStyles, getMediaStyles, getRootStyles } from './style';\nimport { StickyHeaderContext, useStickyHeader } from './use-sticky-header';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\nimport testStyles from './test-classes/styles.css.js';\n\nexport interface InternalContainerProps extends Omit<ContainerProps, 'variant'>, InternalBaseComponentProps {\n disableFooterPaddings?: boolean;\n __stickyHeader?: boolean;\n __stickyOffset?: number;\n __mobileStickyOffset?: number;\n __disableFooterDivider?: boolean;\n __hiddenContent?: boolean;\n __headerRef?: React.RefObject<HTMLDivElement>;\n __fullPage?: boolean;\n __disableStickyMobile?: boolean;\n /**\n * Additional internal variant:\n * * `embedded` - Use this variant within a parent container (such as a modal,\n * expandable section, container or split panel).\n * * `full-page` – Only for internal use in table, cards and other components\n */\n variant?: ContainerProps['variant'] | 'embedded' | 'full-page' | 'cards';\n\n __funnelSubStepProps?: ReturnType<typeof useFunnelSubStep>['funnelSubStepProps'];\n __subStepRef?: ReturnType<typeof useFunnelSubStep>['subStepRef'];\n\n /**\n * React key attached to the content wrapper. It is used to force content re-mount but not container re-mount, which\n * is necessary for components that use container as a root node internally so that their test-utils wrapper is not detached.\n */\n __contentKey?: string;\n}\n\nexport function InternalContainerAsSubstep(props: InternalContainerProps) {\n const { subStepRef, funnelSubStepProps } = useFunnelSubStep();\n const modalContext = useModalContext();\n\n return (\n <InternalContainer\n {...props}\n __subStepRef={modalContext?.isInModal ? { current: null } : subStepRef}\n __funnelSubStepProps={modalContext?.isInModal ? {} : funnelSubStepProps}\n />\n );\n}\n\nexport default function InternalContainer({\n header,\n footer,\n children,\n variant = 'default',\n disableHeaderPaddings = false,\n disableContentPaddings = false,\n disableFooterPaddings = false,\n fitHeight,\n media,\n style,\n __stickyOffset,\n __mobileStickyOffset,\n __stickyHeader = false,\n __internalRootRef,\n __disableFooterDivider = false,\n __hiddenContent = false,\n __headerRef,\n __fullPage = false,\n __disableStickyMobile = true,\n __funnelSubStepProps,\n __subStepRef,\n __contentKey,\n ...restProps\n}: InternalContainerProps) {\n const isMobile = useMobile();\n const isRefresh = useVisualRefresh();\n const baseProps = getBaseProps(restProps);\n const rootRef = useRef<HTMLDivElement>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n const { isSticky, isStuck, isStuckAtBottom, stickyStyles } = useStickyHeader(\n rootRef,\n headerRef,\n __stickyHeader,\n __stickyOffset,\n __mobileStickyOffset,\n __disableStickyMobile,\n __fullPage && isRefresh && !isMobile\n );\n const contentId = useUniqueId();\n\n const hasDynamicHeight = isRefresh && variant === 'full-page';\n\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n const headerMergedRef = useMergeRefs(headerRef, __headerRef);\n\n // The container is only sticky on mobile if it is the header for the table.\n // In this case we don't want the container to have sticky styles, as only the table header row will show as stuck on scroll.\n const shouldHaveStickyStyles = isSticky && !isMobile;\n\n const hasMedia = !!media?.content;\n const mediaPosition = media?.position ?? 'top';\n\n return (\n <div\n {...baseProps}\n {...__funnelSubStepProps}\n className={clsx(\n baseProps.className,\n styles.root,\n styles[`variant-${variant}`],\n fitHeight && styles['fit-height'],\n hasMedia && (mediaPosition === 'side' ? styles['with-side-media'] : styles['with-top-media']),\n shouldHaveStickyStyles && [styles['sticky-enabled']],\n shouldHaveStickyStyles && isStuck && isStuckAtBottom && [styles['with-stuck-sticky-header-at-bottom']],\n isRefresh && styles.refresh\n )}\n ref={mergedRef}\n {...getAnalyticsLabelAttribute(\n `.${analyticsSelectors.header} h1, .${analyticsSelectors.header} h2, .${analyticsSelectors.header} h3`\n )}\n style={getRootStyles(style)}\n >\n {hasMedia && (\n <div\n className={clsx(styles[`media-${mediaPosition === 'side' ? 'side' : 'top'}`], styles.media)}\n style={\n mediaPosition === 'top'\n ? { ...getMediaStyles(mediaPosition, style), height: media?.height || '' }\n : { ...getMediaStyles(mediaPosition, style), width: media?.width || '' }\n }\n >\n {media.content}\n </div>\n )}\n <div\n id={contentId}\n ref={__subStepRef}\n key={__contentKey}\n className={clsx(styles['content-wrapper'], fitHeight && styles['content-wrapper-fit-height'])}\n >\n {/* We use a wrapper around the boundary to preserve container's paddings. */}\n <BuiltInErrorBoundary wrapper={content => <InternalBox padding=\"m\">{content}</InternalBox>}>\n {header && (\n <ContainerHeaderContextProvider>\n <StickyHeaderContext.Provider value={{ isStuck, isStuckAtBottom }}>\n <div\n className={clsx(\n isRefresh && styles.refresh,\n styles.header,\n analyticsSelectors.header,\n styles[`header-variant-${variant}`],\n {\n [styles['header-sticky-disabled']]: __stickyHeader && !isSticky,\n [styles['header-sticky-enabled']]: isSticky,\n [styles['header-dynamic-height']]: hasDynamicHeight,\n [styles['header-stuck']]: isStuck,\n [styles['with-paddings']]: !disableHeaderPaddings,\n [styles['with-hidden-content']]: !children || __hiddenContent,\n [styles['header-with-media']]: hasMedia,\n [styles['header-full-page']]: __fullPage && isRefresh,\n }\n )}\n ref={headerMergedRef}\n style={{\n ...stickyStyles.style,\n ...getHeaderStyles(style),\n }}\n >\n {isStuck && !isMobile && isRefresh && __fullPage && <div className={styles['header-cover']}></div>}\n {header}\n </div>\n </StickyHeaderContext.Provider>\n </ContainerHeaderContextProvider>\n )}\n <div className={clsx(styles.content, fitHeight && styles['content-fit-height'])}>\n <div\n className={clsx(styles['content-inner'], testStyles['content-inner'], {\n [styles['with-paddings']]: !disableContentPaddings,\n [styles['with-header']]: !!header,\n })}\n style={getContentStyles(style)}\n >\n {/* We use a wrapper around the boundary to preserve paddings in case they were disabled by the consumer.\n That is needed because the consumer-defined paddings that normally come with the content can no longer\n apply since the content failed to render. */}\n <BuiltInErrorBoundary\n wrapper={content => (\n <InternalBox padding={disableContentPaddings ? 'm' : undefined}>{content}</InternalBox>\n )}\n >\n {children}\n </BuiltInErrorBoundary>\n </div>\n </div>\n {footer && (\n <div\n className={clsx(styles.footer, {\n [styles['with-divider']]: !__disableFooterDivider,\n [styles['with-paddings']]: !disableFooterPaddings,\n })}\n style={getFooterStyles(style)}\n >\n {footer}\n </div>\n )}\n </BuiltInErrorBoundary>\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../../../src/drawer/implementation.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../../../src/drawer/implementation.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAIlF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAK3C,KAAK,mBAAmB,GAAG,WAAW,GAAG,0BAA0B,CAAC;AAEpE,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,MAAM,EACN,QAAQ,EACR,OAAO,EACP,WAAW,EACX,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,GAAG,SAAS,EACb,EAAE,mBAAmB,eAqErB;AAED,eAAO,MAAM,sBAAsB,mFAAkD,CAAC"}
|
package/drawer/implementation.js
CHANGED
|
@@ -4,6 +4,7 @@ import React, { useRef } from 'react';
|
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { useRuntimeDrawerContext } from '../app-layout/runtime-drawer/use-runtime-drawer-context';
|
|
6
6
|
import { useAppLayoutToolbarDesignEnabled } from '../app-layout/utils/feature-flags';
|
|
7
|
+
import { BuiltInErrorBoundary } from '../error-boundary/internal';
|
|
7
8
|
import { useInternalI18n } from '../i18n/context';
|
|
8
9
|
import { getBaseProps } from '../internal/base-component';
|
|
9
10
|
import { createWidgetizedComponent } from '../internal/widgets';
|
|
@@ -21,7 +22,7 @@ export function DrawerImplementation({ header, footer, children, loading, i18nSt
|
|
|
21
22
|
};
|
|
22
23
|
const footerRef = useRef(null);
|
|
23
24
|
const runtimeDrawerContext = useRuntimeDrawerContext({ rootRef: __internalRootRef });
|
|
24
|
-
const
|
|
25
|
+
const hasAdditionalDrawerAction = !!(runtimeDrawerContext === null || runtimeDrawerContext === void 0 ? void 0 : runtimeDrawerContext.isExpandable);
|
|
25
26
|
const { isSticky: isFooterSticky } = useStickyFooter({
|
|
26
27
|
drawerRef: __internalRootRef,
|
|
27
28
|
footerRef,
|
|
@@ -29,10 +30,11 @@ export function DrawerImplementation({ header, footer, children, loading, i18nSt
|
|
|
29
30
|
return loading ? (React.createElement("div", { ...containerProps, className: clsx(containerProps.className, styles['content-with-paddings']), ref: __internalRootRef },
|
|
30
31
|
React.createElement(InternalStatusIndicator, { type: "loading" },
|
|
31
32
|
React.createElement(InternalLiveRegion, { tagName: "span" }, i18n('i18nStrings.loadingText', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.loadingText))))) : (React.createElement("div", { ...containerProps, ref: __internalRootRef },
|
|
32
|
-
header && (React.createElement("div", { className: clsx(styles.header, runtimeDrawerContext && styles['with-runtime-context'],
|
|
33
|
+
header && (React.createElement("div", { className: clsx(styles.header, runtimeDrawerContext && styles['with-runtime-context'], hasAdditionalDrawerAction && styles['with-additional-action']) },
|
|
33
34
|
header,
|
|
34
35
|
headerActions && React.createElement("div", { className: styles['header-actions'] }, headerActions))),
|
|
35
|
-
React.createElement("div", { className: clsx(styles['test-utils-drawer-content'], styles.content, !disableContentPaddings && styles['content-with-paddings']) },
|
|
36
|
+
React.createElement("div", { className: clsx(styles['test-utils-drawer-content'], styles.content, !disableContentPaddings && styles['content-with-paddings']) },
|
|
37
|
+
React.createElement(BuiltInErrorBoundary, null, children)),
|
|
36
38
|
footer && (React.createElement("div", { ref: footerRef, className: clsx(styles.footer, {
|
|
37
39
|
[styles['is-sticky']]: isFooterSticky,
|
|
38
40
|
}) }, footer))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../../src/drawer/implementation.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAa,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAE,MAAM,yDAAyD,CAAC;AAClG,OAAO,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AACzD,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC,MAAM,UAAU,oBAAoB,CAAC,EACnC,MAAM,EACN,MAAM,EACN,QAAQ,EACR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AAM,IAC/B,IAAI,CAAC,yBAAyB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,CAAC,CACvC,CACG,CACtB,CACP,CAAC,CAAC,CAAC,CACF,gCAAS,cAAc,EAAE,GAAG,EAAE,iBAAiB;QAC5C,MAAM,IAAI,CACT,6BACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,MAAM,EACb,oBAAoB,IAAI,MAAM,CAAC,sBAAsB,CAAC,EACtD,yBAAyB,IAAI,MAAM,CAAC,wBAAwB,CAAC,CAC9D;YAEA,MAAM;YACN,aAAa,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,IAAG,aAAa,CAAO,CAC7E,CACP;QACD,6BACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,2BAA2B,CAAC,EACnC,MAAM,CAAC,OAAO,EACd,CAAC,sBAAsB,IAAI,MAAM,CAAC,uBAAuB,CAAC,CAC3D;YAED,oBAAC,oBAAoB,QAAE,QAAQ,CAAwB,CACnD;QACL,MAAM,IAAI,CACT,6BACE,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;gBAC7B,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,cAAc;aACtC,CAAC,IAED,MAAM,CACH,CACP,CACG,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC,oBAAoB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { RefObject, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useRuntimeDrawerContext } from '../app-layout/runtime-drawer/use-runtime-drawer-context';\nimport { useAppLayoutToolbarDesignEnabled } from '../app-layout/utils/feature-flags';\nimport { BuiltInErrorBoundary } from '../error-boundary/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { getBaseProps } from '../internal/base-component';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { createWidgetizedComponent } from '../internal/widgets';\nimport InternalLiveRegion from '../live-region/internal';\nimport InternalStatusIndicator from '../status-indicator/internal';\nimport { DrawerProps } from './interfaces';\nimport { useStickyFooter } from './use-sticky-footer';\n\nimport styles from './styles.css.js';\n\ntype DrawerInternalProps = DrawerProps & InternalBaseComponentProps;\n\nexport function DrawerImplementation({\n header,\n footer,\n children,\n loading,\n i18nStrings,\n disableContentPaddings,\n __internalRootRef,\n headerActions,\n ...restProps\n}: DrawerInternalProps) {\n const baseProps = getBaseProps(restProps);\n const isToolbar = useAppLayoutToolbarDesignEnabled();\n const i18n = useInternalI18n('drawer');\n const containerProps = {\n ...baseProps,\n className: clsx(\n baseProps.className,\n styles.drawer,\n isToolbar && styles['with-toolbar'],\n !!footer && styles['with-footer']\n ),\n };\n const footerRef = useRef<HTMLDivElement>(null);\n\n const runtimeDrawerContext = useRuntimeDrawerContext({ rootRef: __internalRootRef as RefObject<HTMLElement> });\n const hasAdditionalDrawerAction = !!runtimeDrawerContext?.isExpandable;\n const { isSticky: isFooterSticky } = useStickyFooter({\n drawerRef: __internalRootRef as RefObject<HTMLElement>,\n footerRef,\n });\n\n return loading ? (\n <div\n {...containerProps}\n className={clsx(containerProps.className, styles['content-with-paddings'])}\n ref={__internalRootRef}\n >\n <InternalStatusIndicator type=\"loading\">\n <InternalLiveRegion tagName=\"span\">\n {i18n('i18nStrings.loadingText', i18nStrings?.loadingText)}\n </InternalLiveRegion>\n </InternalStatusIndicator>\n </div>\n ) : (\n <div {...containerProps} ref={__internalRootRef}>\n {header && (\n <div\n className={clsx(\n styles.header,\n runtimeDrawerContext && styles['with-runtime-context'],\n hasAdditionalDrawerAction && styles['with-additional-action']\n )}\n >\n {header}\n {headerActions && <div className={styles['header-actions']}>{headerActions}</div>}\n </div>\n )}\n <div\n className={clsx(\n styles['test-utils-drawer-content'],\n styles.content,\n !disableContentPaddings && styles['content-with-paddings']\n )}\n >\n <BuiltInErrorBoundary>{children}</BuiltInErrorBoundary>\n </div>\n {footer && (\n <div\n ref={footerRef}\n className={clsx(styles.footer, {\n [styles['is-sticky']]: isFooterSticky,\n })}\n >\n {footer}\n </div>\n )}\n </div>\n );\n}\n\nexport const createWidgetizedDrawer = createWidgetizedComponent(DrawerImplementation);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../../../src/error-boundary/fallback.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAMlD,wBAAgB,qBAAqB,CAAC,EACpC,WAAgB,EAChB,cAAc,GACf,EAAE,IAAI,CAAC,kBAAkB,EAAE,gBAAgB,GAAG,aAAa,CAAC,eA2B5D"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import IntlMessageFormat from 'intl-messageformat';
|
|
6
|
+
import InternalAlert from '../alert/internal';
|
|
7
|
+
import InternalButton from '../button/internal';
|
|
8
|
+
import { useInternalI18n } from '../i18n/context';
|
|
9
|
+
import { refreshPage } from './utils';
|
|
10
|
+
import styles from './styles.css.js';
|
|
11
|
+
import testUtilStyles from './test-classes/styles.css.js';
|
|
12
|
+
export function ErrorBoundaryFallback({ i18nStrings = {}, renderFallback, }) {
|
|
13
|
+
var _a;
|
|
14
|
+
const defaultSlots = {
|
|
15
|
+
header: (React.createElement("div", { className: clsx(styles.header, testUtilStyles.header) },
|
|
16
|
+
React.createElement(DefaultHeaderContent, { i18nStrings: i18nStrings }))),
|
|
17
|
+
description: (React.createElement("div", { className: clsx(styles.description, testUtilStyles.description) },
|
|
18
|
+
React.createElement(DefaultDescriptionContent, { i18nStrings: i18nStrings }))),
|
|
19
|
+
action: (React.createElement("div", { className: clsx(styles.action, testUtilStyles.action) },
|
|
20
|
+
React.createElement(DefaultActionContent, { i18nStrings: i18nStrings }))),
|
|
21
|
+
};
|
|
22
|
+
return (React.createElement("div", { className: testUtilStyles.fallback }, (_a = renderFallback === null || renderFallback === void 0 ? void 0 : renderFallback(defaultSlots)) !== null && _a !== void 0 ? _a : (React.createElement(InternalAlert, { type: "error", header: defaultSlots.header, action: defaultSlots.action }, defaultSlots.description))));
|
|
23
|
+
}
|
|
24
|
+
function DefaultHeaderContent({ i18nStrings }) {
|
|
25
|
+
const i18n = useInternalI18n('error-boundary');
|
|
26
|
+
return React.createElement(React.Fragment, null, i18n('i18nStrings.headerText', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.headerText));
|
|
27
|
+
}
|
|
28
|
+
function DefaultDescriptionContent({ i18nStrings: { descriptionText, components: { Feedback } = {} } = {}, }) {
|
|
29
|
+
const i18n = useInternalI18n('error-boundary');
|
|
30
|
+
// Dependencies for the intl-format function, where the pseudo-tags are declared as functions from parsed chunks.
|
|
31
|
+
const formatArgs = Feedback
|
|
32
|
+
? {
|
|
33
|
+
hasFeedback: true,
|
|
34
|
+
Feedback: (chunks) => {
|
|
35
|
+
var _a;
|
|
36
|
+
return (React.createElement("span", { className: testUtilStyles['feedback-action'] },
|
|
37
|
+
React.createElement(Feedback, null, (_a = chunks[0]) !== null && _a !== void 0 ? _a : '')));
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
: { hasFeedback: false, Feedback: () => React.createElement(React.Fragment, null) };
|
|
41
|
+
// This ensures that the description string provided via i18nStrings also supports the <Feedback> injection,
|
|
42
|
+
// because the i18n() helper propagates the second argument as is, without applying intl-format to it.
|
|
43
|
+
// We wrap the format with try-catch to avoid intl errors caused by incorrectly referenced components.
|
|
44
|
+
function safeFormat(descriptionText) {
|
|
45
|
+
try {
|
|
46
|
+
return descriptionText ? new IntlMessageFormat(descriptionText).format(formatArgs) : undefined;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return descriptionText;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const message = i18n('i18nStrings.descriptionText', safeFormat(descriptionText), format => format(formatArgs));
|
|
53
|
+
// When the description includes <Feedback>, then the translated message is represented as an array of strings and
|
|
54
|
+
// React elements that require keys when rendering to avoid React warnings.
|
|
55
|
+
return (React.createElement(React.Fragment, null, Array.isArray(message) ? message.map((chunk, i) => React.createElement(React.Fragment, { key: i }, chunk)) : message));
|
|
56
|
+
}
|
|
57
|
+
function DefaultActionContent({ i18nStrings }) {
|
|
58
|
+
const i18n = useInternalI18n('error-boundary');
|
|
59
|
+
return (React.createElement(InternalButton, { iconName: "refresh", onClick: refreshPage, className: testUtilStyles['refresh-action'] }, i18n('i18nStrings.refreshActionText', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.refreshActionText)));
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=fallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback.js","sourceRoot":"","sources":["../../../src/error-boundary/fallback.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AAEnD,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,cAAc,MAAM,8BAA8B,CAAC;AAE1D,MAAM,UAAU,qBAAqB,CAAC,EACpC,WAAW,GAAG,EAAE,EAChB,cAAc,GAC6C;;IAC3D,MAAM,YAAY,GAAG;QACnB,MAAM,EAAE,C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C,cAAc,IAAC,QAAQ,EAAC,SAAS,EAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,CAAC,gBAAgB,CAAC,IACjG,IAAI,CAAC,+BAA+B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,iBAAiB,CAAC,CACvD,CAClB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\nimport clsx from 'clsx';\nimport IntlMessageFormat from 'intl-messageformat';\n\nimport InternalAlert from '../alert/internal';\nimport InternalButton from '../button/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { ErrorBoundaryProps } from './interfaces';\nimport { refreshPage } from './utils';\n\nimport styles from './styles.css.js';\nimport testUtilStyles from './test-classes/styles.css.js';\n\nexport function ErrorBoundaryFallback({\n i18nStrings = {},\n renderFallback,\n}: Pick<ErrorBoundaryProps, 'renderFallback' | 'i18nStrings'>) {\n const defaultSlots = {\n header: (\n <div className={clsx(styles.header, testUtilStyles.header)}>\n <DefaultHeaderContent i18nStrings={i18nStrings} />\n </div>\n ),\n description: (\n <div className={clsx(styles.description, testUtilStyles.description)}>\n <DefaultDescriptionContent i18nStrings={i18nStrings} />\n </div>\n ),\n action: (\n <div className={clsx(styles.action, testUtilStyles.action)}>\n <DefaultActionContent i18nStrings={i18nStrings} />\n </div>\n ),\n };\n return (\n <div className={testUtilStyles.fallback}>\n {renderFallback?.(defaultSlots) ?? (\n <InternalAlert type=\"error\" header={defaultSlots.header} action={defaultSlots.action}>\n {defaultSlots.description}\n </InternalAlert>\n )}\n </div>\n );\n}\n\nfunction DefaultHeaderContent({ i18nStrings }: { i18nStrings: ErrorBoundaryProps.I18nStrings }) {\n const i18n = useInternalI18n('error-boundary');\n return <>{i18n('i18nStrings.headerText', i18nStrings?.headerText)}</>;\n}\n\nfunction DefaultDescriptionContent({\n i18nStrings: { descriptionText, components: { Feedback } = {} } = {},\n}: {\n i18nStrings: ErrorBoundaryProps.I18nStrings;\n}) {\n const i18n = useInternalI18n('error-boundary');\n\n // Dependencies for the intl-format function, where the pseudo-tags are declared as functions from parsed chunks.\n const formatArgs = Feedback\n ? {\n hasFeedback: true,\n Feedback: (chunks: React.ReactNode[]) => (\n <span className={testUtilStyles['feedback-action']}>\n <Feedback>{chunks[0] ?? ''}</Feedback>\n </span>\n ),\n }\n : { hasFeedback: false, Feedback: () => <></> };\n\n // This ensures that the description string provided via i18nStrings also supports the <Feedback> injection,\n // because the i18n() helper propagates the second argument as is, without applying intl-format to it.\n // We wrap the format with try-catch to avoid intl errors caused by incorrectly referenced components.\n function safeFormat(descriptionText?: string) {\n try {\n return descriptionText ? new IntlMessageFormat(descriptionText).format(formatArgs) : undefined;\n } catch {\n return descriptionText;\n }\n }\n const message = i18n('i18nStrings.descriptionText', safeFormat(descriptionText), format => format(formatArgs));\n\n // When the description includes <Feedback>, then the translated message is represented as an array of strings and\n // React elements that require keys when rendering to avoid React warnings.\n return (\n <>\n {Array.isArray(message) ? message.map((chunk, i) => <React.Fragment key={i}>{chunk}</React.Fragment>) : message}\n </>\n );\n}\n\nfunction DefaultActionContent({ i18nStrings }: { i18nStrings?: ErrorBoundaryProps.I18nStrings }) {\n const i18n = useInternalI18n('error-boundary');\n return (\n <InternalButton iconName=\"refresh\" onClick={refreshPage} className={testUtilStyles['refresh-action']}>\n {i18n('i18nStrings.refreshActionText', i18nStrings?.refreshActionText)}\n </InternalButton>\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/error-boundary/index.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,iBAAS,aAAa,CAAC,EAAE,cAAsB,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,eAU9E;AAID,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
'use client';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
6
|
+
import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
7
|
+
import { InternalErrorBoundary } from './internal';
|
|
8
|
+
function ErrorBoundary({ suppressNested = false, ...props }) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
const baseComponentProps = useBaseComponent('ErrorBoundary', {
|
|
11
|
+
props: { suppressNested },
|
|
12
|
+
metadata: {
|
|
13
|
+
hasBoundaryId: !!props.errorBoundaryId,
|
|
14
|
+
hasFeedbackAction: !!((_b = (_a = props.i18nStrings) === null || _a === void 0 ? void 0 : _a.components) === null || _b === void 0 ? void 0 : _b.Feedback),
|
|
15
|
+
hasRenderFallback: !!props.renderFallback,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return React.createElement(InternalErrorBoundary, { ...baseComponentProps, ...props, suppressNested: suppressNested });
|
|
19
|
+
}
|
|
20
|
+
applyDisplayName(ErrorBoundary, 'ErrorBoundary');
|
|
21
|
+
export default ErrorBoundary;
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/error-boundary/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,YAAY,CAAC;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAInD,SAAS,aAAa,CAAC,EAAE,cAAc,GAAG,KAAK,EAAE,GAAG,KAAK,EAAsB;;IAC7E,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,eAAe,EAAE;QAC3D,KAAK,EAAE,EAAE,cAAc,EAAE;QACzB,QAAQ,EAAE;YACR,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe;YACtC,iBAAiB,EAAE,CAAC,CAAC,CAAA,MAAA,MAAA,KAAK,CAAC,WAAW,0CAAE,UAAU,0CAAE,QAAQ,CAAA;YAC5D,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc;SAC1C;KACF,CAAC,CAAC;IACH,OAAO,oBAAC,qBAAqB,OAAK,kBAAkB,KAAM,KAAK,EAAE,cAAc,EAAE,cAAc,GAAI,CAAC;AACtG,CAAC;AAED,gBAAgB,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;AAEjD,eAAe,aAAa,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\nimport React from 'react';\n\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { ErrorBoundaryProps } from './interfaces';\nimport { InternalErrorBoundary } from './internal';\n\nexport { ErrorBoundaryProps };\n\nfunction ErrorBoundary({ suppressNested = false, ...props }: ErrorBoundaryProps) {\n const baseComponentProps = useBaseComponent('ErrorBoundary', {\n props: { suppressNested },\n metadata: {\n hasBoundaryId: !!props.errorBoundaryId,\n hasFeedbackAction: !!props.i18nStrings?.components?.Feedback,\n hasRenderFallback: !!props.renderFallback,\n },\n });\n return <InternalErrorBoundary {...baseComponentProps} {...props} suppressNested={suppressNested} />;\n}\n\napplyDisplayName(ErrorBoundary, 'ErrorBoundary');\n\nexport default ErrorBoundary;\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ErrorInfo } from 'react';
|
|
2
|
+
export interface ErrorBoundaryProps {
|
|
3
|
+
/**
|
|
4
|
+
* Optional identifier for the error boundary instance.
|
|
5
|
+
*
|
|
6
|
+
* When provided, the identifier is included in the `onError` callback payload.
|
|
7
|
+
* In the rendered output, the boundary wraps its content in a `<div>` with the
|
|
8
|
+
* attribute `data-awsui-boundary-id={errorBoundaryId}` to support debugging.
|
|
9
|
+
*/
|
|
10
|
+
errorBoundaryId?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Callback invoked when an error is intercepted by the boundary.
|
|
13
|
+
* Use this function to record, log, or report errors (for example, to telemetry or monitoring systems).
|
|
14
|
+
*
|
|
15
|
+
* The callback receives a `detail` object containing:
|
|
16
|
+
* * `error` (Error): The thrown error instance.
|
|
17
|
+
* * `errorInfo` (React.ErrorInfo): Additional metadata captured by React.
|
|
18
|
+
* * `errorBoundaryId` (optional, string): The boundary identifier, if defined.
|
|
19
|
+
*/
|
|
20
|
+
onError: (detail: ErrorBoundaryProps.OnErrorDetail) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Controls how nested error boundaries behave.
|
|
23
|
+
*
|
|
24
|
+
* Several components—such as app layout, container, and modal include built-in
|
|
25
|
+
* error boundaries. These boundaries activate automatically when they detect
|
|
26
|
+
* an ancestor boundary, inheriting configuration from the closest one.
|
|
27
|
+
*
|
|
28
|
+
* When `suppressNested` is set to `true`, nested built-in or standalone
|
|
29
|
+
* boundaries are disabled. In this mode, all errors originating from within
|
|
30
|
+
* the boundary’s content are captured exclusively by this boundary.
|
|
31
|
+
*/
|
|
32
|
+
suppressNested?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Optional custom renderer for the fallback UI displayed when an error occurs.
|
|
35
|
+
*
|
|
36
|
+
* The function receives the default slots derived from i18n configuration:
|
|
37
|
+
* * `header` (ReactNode): The fallback header text.
|
|
38
|
+
* * `description` (ReactNode): The fallback description text.
|
|
39
|
+
* * `action` (ReactNode): The fallback action element (a refresh button by default).
|
|
40
|
+
*
|
|
41
|
+
* Return a React node to fully override the default fallback presentation.
|
|
42
|
+
*/
|
|
43
|
+
renderFallback?: (props: ErrorBoundaryProps.FallbackProps) => React.ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* Localized strings and components used in the fallback UI.
|
|
46
|
+
*
|
|
47
|
+
* * `headerText` (string): Header text displayed in the fallback view.
|
|
48
|
+
* * `descriptionText` (string): Description text displayed in the fallback view. Supports embedding inline
|
|
49
|
+
* feedback actions by including `<Feedback>` pseudo-tags when `components.Feedback` is provided.
|
|
50
|
+
* * `refreshActionText` (string): Text for the default refresh action button.
|
|
51
|
+
* * `components.Feedback` (React.ComponentType<I18nFeedbackProps>): A component used to render
|
|
52
|
+
* inline feedback actions within the description text.
|
|
53
|
+
*
|
|
54
|
+
* @i18n
|
|
55
|
+
*/
|
|
56
|
+
i18nStrings?: ErrorBoundaryProps.I18nStrings;
|
|
57
|
+
/**
|
|
58
|
+
* Child content rendered when no error has been captured.
|
|
59
|
+
*/
|
|
60
|
+
children: React.ReactNode;
|
|
61
|
+
}
|
|
62
|
+
export declare namespace ErrorBoundaryProps {
|
|
63
|
+
interface FallbackProps {
|
|
64
|
+
header?: React.ReactNode;
|
|
65
|
+
description?: React.ReactNode;
|
|
66
|
+
action?: React.ReactNode;
|
|
67
|
+
}
|
|
68
|
+
interface I18nStrings {
|
|
69
|
+
headerText?: string;
|
|
70
|
+
descriptionText?: string;
|
|
71
|
+
refreshActionText?: string;
|
|
72
|
+
components?: {
|
|
73
|
+
Feedback?: React.ComponentType<I18nFeedbackProps>;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
interface I18nFeedbackProps {
|
|
77
|
+
children: React.ReactNode;
|
|
78
|
+
}
|
|
79
|
+
interface OnErrorDetail {
|
|
80
|
+
error: Error;
|
|
81
|
+
errorInfo: ErrorInfo;
|
|
82
|
+
errorBoundaryId?: string;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/error-boundary/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE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../src/error-boundary/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ErrorInfo } from 'react';\n\nexport interface ErrorBoundaryProps {\n /**\n * Optional identifier for the error boundary instance.\n *\n * When provided, the identifier is included in the `onError` callback payload.\n * In the rendered output, the boundary wraps its content in a `<div>` with the\n * attribute `data-awsui-boundary-id={errorBoundaryId}` to support debugging.\n */\n errorBoundaryId?: string;\n\n /**\n * Callback invoked when an error is intercepted by the boundary.\n * Use this function to record, log, or report errors (for example, to telemetry or monitoring systems).\n *\n * The callback receives a `detail` object containing:\n * * `error` (Error): The thrown error instance.\n * * `errorInfo` (React.ErrorInfo): Additional metadata captured by React.\n * * `errorBoundaryId` (optional, string): The boundary identifier, if defined.\n */\n onError: (detail: ErrorBoundaryProps.OnErrorDetail) => void;\n\n /**\n * Controls how nested error boundaries behave.\n *\n * Several components—such as app layout, container, and modal include built-in\n * error boundaries. These boundaries activate automatically when they detect\n * an ancestor boundary, inheriting configuration from the closest one.\n *\n * When `suppressNested` is set to `true`, nested built-in or standalone\n * boundaries are disabled. In this mode, all errors originating from within\n * the boundary’s content are captured exclusively by this boundary.\n */\n suppressNested?: boolean;\n\n /**\n * Optional custom renderer for the fallback UI displayed when an error occurs.\n *\n * The function receives the default slots derived from i18n configuration:\n * * `header` (ReactNode): The fallback header text.\n * * `description` (ReactNode): The fallback description text.\n * * `action` (ReactNode): The fallback action element (a refresh button by default).\n *\n * Return a React node to fully override the default fallback presentation.\n */\n renderFallback?: (props: ErrorBoundaryProps.FallbackProps) => React.ReactNode;\n\n /**\n * Localized strings and components used in the fallback UI.\n *\n * * `headerText` (string): Header text displayed in the fallback view.\n * * `descriptionText` (string): Description text displayed in the fallback view. Supports embedding inline\n * feedback actions by including `<Feedback>` pseudo-tags when `components.Feedback` is provided.\n * * `refreshActionText` (string): Text for the default refresh action button.\n * * `components.Feedback` (React.ComponentType<I18nFeedbackProps>): A component used to render\n * inline feedback actions within the description text.\n *\n * @i18n\n */\n i18nStrings?: ErrorBoundaryProps.I18nStrings;\n\n /**\n * Child content rendered when no error has been captured.\n */\n children: React.ReactNode;\n}\n\nexport namespace ErrorBoundaryProps {\n export interface FallbackProps {\n header?: React.ReactNode;\n description?: React.ReactNode;\n action?: React.ReactNode;\n }\n\n export interface I18nStrings {\n headerText?: string;\n descriptionText?: string;\n refreshActionText?: string;\n components?: {\n Feedback?: React.ComponentType<I18nFeedbackProps>;\n };\n }\n\n export interface I18nFeedbackProps {\n children: React.ReactNode;\n }\n\n export interface OnErrorDetail {\n error: Error;\n errorInfo: ErrorInfo;\n errorBoundaryId?: string;\n }\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
|
|
3
|
+
import { SomeRequired } from '../internal/types';
|
|
4
|
+
import { ErrorBoundaryProps } from './interfaces';
|
|
5
|
+
declare global {
|
|
6
|
+
interface HTMLElement {
|
|
7
|
+
__awsui__?: {
|
|
8
|
+
forceError?(): void;
|
|
9
|
+
clearForcedError?(): void;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
interface InternalErrorBoundaryProps extends SomeRequired<ErrorBoundaryProps, 'suppressNested'>, InternalBaseComponentProps {}
|
|
14
|
+
export declare function InternalErrorBoundary({
|
|
15
|
+
children,
|
|
16
|
+
suppressNested,
|
|
17
|
+
__internalRootRef,
|
|
18
|
+
...props
|
|
19
|
+
}: InternalErrorBoundaryProps): JSX.Element;
|
|
20
|
+
interface BuiltInErrorBoundaryProps {
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
wrapper?: (content: React.ReactNode) => React.ReactNode;
|
|
23
|
+
suppressNested?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function BuiltInErrorBoundary({
|
|
26
|
+
wrapper,
|
|
27
|
+
suppressNested,
|
|
28
|
+
children
|
|
29
|
+
}: BuiltInErrorBoundaryProps): JSX.Element;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/error-boundary/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAI9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAKlD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,WAAW;QACnB,SAAS,CAAC,EAAE;YAAE,UAAU,CAAC,IAAI,IAAI,CAAC;YAAC,gBAAgB,CAAC,IAAI,IAAI,CAAA;SAAE,CAAC;KAChE;CACF;AAaD,UAAU,0BACR,SAAQ,YAAY,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,EACxD,0BAA0B;CAAG;AAEjC,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,GAAG,KAAK,EACT,EAAE,0BAA0B,eA8B5B;AAED,UAAU,yBAAyB;IACjC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS,CAAC;IACxD,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,oBAAoB,CAAC,EAAE,OAAO,EAAE,cAAsB,EAAE,QAAQ,EAAE,EAAE,yBAAyB,eAa5G"}
|