@cloudscape-design/components 3.0.791 → 3.0.792
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-toolbar/skeleton/styles.css.js +19 -19
- package/app-layout/visual-refresh-toolbar/skeleton/styles.scoped.css +40 -40
- package/app-layout/visual-refresh-toolbar/skeleton/styles.selectors.js +19 -19
- package/form/index.d.ts.map +1 -1
- package/form/index.js +3 -3
- package/form/index.js.map +1 -1
- package/internal/analytics/components/analytics-funnel.d.ts +2 -0
- package/internal/analytics/components/analytics-funnel.d.ts.map +1 -1
- package/internal/analytics/components/analytics-funnel.js +48 -5
- package/internal/analytics/components/analytics-funnel.js.map +1 -1
- package/internal/analytics/hooks/use-funnel.d.ts +6 -21
- package/internal/analytics/hooks/use-funnel.d.ts.map +1 -1
- package/internal/analytics/hooks/use-funnel.js +0 -7
- package/internal/analytics/hooks/use-funnel.js.map +1 -1
- package/internal/analytics/interfaces.d.ts +3 -2
- package/internal/analytics/interfaces.d.ts.map +1 -1
- package/internal/analytics/interfaces.js.map +1 -1
- package/internal/base-component/styles.scoped.css +23 -0
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/generated/styles/tokens.d.ts +5 -0
- package/internal/generated/styles/tokens.js +5 -0
- package/internal/generated/theming/index.cjs +134 -0
- package/internal/generated/theming/index.cjs.d.ts +16 -0
- package/internal/generated/theming/index.d.ts +16 -0
- package/internal/generated/theming/index.js +134 -0
- package/internal/manifest.json +1 -1
- package/modal/index.d.ts.map +1 -1
- package/modal/index.js +22 -2
- package/modal/index.js.map +1 -1
- package/modal/interfaces.d.ts +14 -0
- package/modal/interfaces.d.ts.map +1 -1
- package/modal/interfaces.js.map +1 -1
- package/modal/internal.d.ts +9 -0
- package/modal/internal.d.ts.map +1 -1
- package/modal/internal.js +20 -6
- package/modal/internal.js.map +1 -1
- package/package.json +1 -1
package/modal/index.js
CHANGED
|
@@ -2,14 +2,34 @@ import { __rest } from "tslib";
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import React from 'react';
|
|
5
|
+
import { AnalyticsFunnel, AnalyticsFunnelStep, AnalyticsFunnelSubStep, } from '../internal/analytics/components/analytics-funnel';
|
|
6
|
+
import { useFunnel } from '../internal/analytics/hooks/use-funnel';
|
|
7
|
+
import { getAnalyticsMetadataProps } from '../internal/base-component';
|
|
5
8
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
6
9
|
import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
7
|
-
import InternalModal from './internal';
|
|
10
|
+
import InternalModal, { InternalModalAsFunnel } from './internal';
|
|
11
|
+
import styles from './styles.css.js';
|
|
12
|
+
function ModalWithAnalyticsFunnel(_a) {
|
|
13
|
+
var { analyticsMetadata, baseComponentProps, size = 'medium' } = _a, props = __rest(_a, ["analyticsMetadata", "baseComponentProps", "size"]);
|
|
14
|
+
return (React.createElement(AnalyticsFunnel, { mounted: props.visible, funnelIdentifier: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.instanceIdentifier, funnelFlowType: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.flowType, funnelErrorContext: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.errorContext, funnelResourceType: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.resourceType, funnelType: "modal", optionalStepNumbers: [], totalFunnelSteps: 1, funnelNameSelectors: [`.${styles['header--text']}`] },
|
|
15
|
+
React.createElement(AnalyticsFunnelStep, { mounted: props.visible, stepIdentifier: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.instanceIdentifier, stepErrorContext: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.errorContext, stepNumber: 1 },
|
|
16
|
+
React.createElement(AnalyticsFunnelSubStep, { subStepIdentifier: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.instanceIdentifier, subStepErrorContext: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.errorContext },
|
|
17
|
+
React.createElement(InternalModalAsFunnel, Object.assign({ size: size }, props, baseComponentProps, { __injectAnalyticsComponentMetadata: true }))))));
|
|
18
|
+
}
|
|
8
19
|
export default function Modal(_a) {
|
|
9
20
|
var { size = 'medium' } = _a, props = __rest(_a, ["size"]);
|
|
21
|
+
const { isInFunnel } = useFunnel();
|
|
22
|
+
const analyticsMetadata = getAnalyticsMetadataProps(props);
|
|
10
23
|
const baseComponentProps = useBaseComponent('Modal', {
|
|
11
24
|
props: { size, disableContentPaddings: props.disableContentPaddings },
|
|
12
|
-
|
|
25
|
+
metadata: {
|
|
26
|
+
hasResourceType: Boolean(analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.resourceType),
|
|
27
|
+
hasInstanceIdentifier: Boolean(analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.instanceIdentifier),
|
|
28
|
+
},
|
|
29
|
+
}, analyticsMetadata);
|
|
30
|
+
if (!isInFunnel) {
|
|
31
|
+
return (React.createElement(ModalWithAnalyticsFunnel, Object.assign({ analyticsMetadata: analyticsMetadata, baseComponentProps: baseComponentProps, size: size }, props)));
|
|
32
|
+
}
|
|
13
33
|
return React.createElement(InternalModal, Object.assign({ size: size }, props, baseComponentProps, { __injectAnalyticsComponentMetadata: true }));
|
|
14
34
|
}
|
|
15
35
|
applyDisplayName(Modal, 'Modal');
|
package/modal/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modal/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EA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AE,iBAAiB,EACpC,kBAAkB,EAAE,kBAAkB,EACtC,IAAI,EAAE,IAAI,IACN,KAAK,EACT,CACH,CAAC;KACH;IAED,OAAO,oBAAC,aAAa,kBAAC,IAAI,EAAE,IAAI,IAAM,KAAK,EAAM,kBAAkB,IAAE,kCAAkC,EAAE,IAAI,IAAI,CAAC;AACpH,CAAC;AAED,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport {\n AnalyticsFunnel,\n AnalyticsFunnelStep,\n AnalyticsFunnelSubStep,\n} from '../internal/analytics/components/analytics-funnel';\nimport { useFunnel } from '../internal/analytics/hooks/use-funnel';\nimport { BasePropsWithAnalyticsMetadata, getAnalyticsMetadataProps } from '../internal/base-component';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { ModalProps } from './interfaces';\nimport InternalModal, { InternalModalAsFunnel } from './internal';\n\nimport styles from './styles.css.js';\n\nexport { ModalProps };\n\nfunction ModalWithAnalyticsFunnel({\n analyticsMetadata,\n baseComponentProps,\n size = 'medium',\n ...props\n}: ModalProps & { analyticsMetadata: any; baseComponentProps: ReturnType<typeof useBaseComponent> }) {\n return (\n <AnalyticsFunnel\n mounted={props.visible}\n funnelIdentifier={analyticsMetadata?.instanceIdentifier}\n funnelFlowType={analyticsMetadata?.flowType}\n funnelErrorContext={analyticsMetadata?.errorContext}\n funnelResourceType={analyticsMetadata?.resourceType}\n funnelType=\"modal\"\n optionalStepNumbers={[]}\n totalFunnelSteps={1}\n funnelNameSelectors={[`.${styles['header--text']}`]}\n >\n <AnalyticsFunnelStep\n mounted={props.visible}\n stepIdentifier={analyticsMetadata?.instanceIdentifier}\n stepErrorContext={analyticsMetadata?.errorContext}\n stepNumber={1}\n >\n <AnalyticsFunnelSubStep\n subStepIdentifier={analyticsMetadata?.instanceIdentifier}\n subStepErrorContext={analyticsMetadata?.errorContext}\n >\n <InternalModalAsFunnel\n size={size}\n {...props}\n {...baseComponentProps}\n __injectAnalyticsComponentMetadata={true}\n />\n </AnalyticsFunnelSubStep>\n </AnalyticsFunnelStep>\n </AnalyticsFunnel>\n );\n}\n\nexport default function Modal({ size = 'medium', ...props }: ModalProps) {\n const { isInFunnel } = useFunnel();\n const analyticsMetadata = getAnalyticsMetadataProps(props as BasePropsWithAnalyticsMetadata);\n const baseComponentProps = useBaseComponent(\n 'Modal',\n {\n props: { size, disableContentPaddings: props.disableContentPaddings },\n metadata: {\n hasResourceType: Boolean(analyticsMetadata?.resourceType),\n hasInstanceIdentifier: Boolean(analyticsMetadata?.instanceIdentifier),\n },\n },\n analyticsMetadata\n );\n\n if (!isInFunnel) {\n return (\n <ModalWithAnalyticsFunnel\n analyticsMetadata={analyticsMetadata}\n baseComponentProps={baseComponentProps}\n size={size}\n {...props}\n />\n );\n }\n\n return <InternalModal size={size} {...props} {...baseComponentProps} __injectAnalyticsComponentMetadata={true} />;\n}\n\napplyDisplayName(Modal, 'Modal');\n"]}
|
package/modal/interfaces.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { FlowType } from '../internal/analytics/interfaces';
|
|
2
3
|
import { BaseComponentProps } from '../internal/base-component';
|
|
3
4
|
import { NonCancelableEventHandler } from '../internal/events';
|
|
4
5
|
export interface BaseModalProps {
|
|
@@ -60,11 +61,24 @@ export interface ModalProps extends BaseComponentProps, BaseModalProps {
|
|
|
60
61
|
* render to an element under `document.body`.
|
|
61
62
|
*/
|
|
62
63
|
modalRoot?: HTMLElement;
|
|
64
|
+
/**
|
|
65
|
+
* Specifies additional analytics-related metadata.
|
|
66
|
+
* * `instanceIdentifier` - A unique string that identifies this component instance in your application.
|
|
67
|
+
* * `flowType` - Identifies the type of flow represented by the component.
|
|
68
|
+
* * `resourceType` - Identifies the type of resource represented by the flow. **Note:** This API is currently experimental.
|
|
69
|
+
* @analytics
|
|
70
|
+
*/
|
|
71
|
+
analyticsMetadata?: ModalProps.AnalyticsMetadata;
|
|
63
72
|
}
|
|
64
73
|
export declare namespace ModalProps {
|
|
65
74
|
type Size = 'small' | 'medium' | 'large' | 'max';
|
|
66
75
|
interface DismissDetail {
|
|
67
76
|
reason: string;
|
|
68
77
|
}
|
|
78
|
+
interface AnalyticsMetadata {
|
|
79
|
+
instanceIdentifier?: string;
|
|
80
|
+
flowType?: FlowType;
|
|
81
|
+
resourceType?: string;
|
|
82
|
+
}
|
|
69
83
|
}
|
|
70
84
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/modal/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAE1C;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,IAAI,CAAC;CACtD;AAED,MAAM,WAAW,UAAW,SAAQ,kBAAkB,EAAE,cAAc;IACpE;;;;OAIG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC;IACvB;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,C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C;IAExB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC;CAClD;AAED,yBAAiB,UAAU,CAAC;IAC1B,KAAY,IAAI,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;IAExD,UAAiB,aAAa;QAC5B,MAAM,EAAE,MAAM,CAAC;KAChB;IAED,UAAiB,iBAAiB;QAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB;CACF"}
|
package/modal/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/modal/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface BaseModalProps {\n /**\n * Use this property to specify a different dynamic modal root for the dialog.\n * The function will be called when a user clicks on the trigger button.\n */\n getModalRoot?: () => Promise<HTMLElement>;\n\n /**\n * Use this property when `getModalRoot` is used to clean up the modal root\n * element after a user closes the dialog. The function receives the return value\n * of the most recent getModalRoot call as an argument.\n */\n removeModalRoot?: (rootElement: HTMLElement) => void;\n}\n\nexport interface ModalProps extends BaseComponentProps, BaseModalProps {\n /**\n * Sets the width of the modal. `max` uses variable width up to the\n * largest size allowed by the design guidelines. Other sizes\n * (`small`/`medium`/`large`) have fixed widths.\n */\n size?: ModalProps.Size;\n /**\n * Determines whether the modal is displayed on the screen. Modals are hidden by default.\n * Set this property to `true` to show them.\n */\n visible: boolean;\n /**\n * Adds an `aria-label` to the close button, for accessibility.\n * @i18n\n */\n closeAriaLabel?: string;\n /**\n * Specifies a title for the modal. Although this can be empty, we suggest that you always provide a title.\n */\n header?: React.ReactNode;\n /**\n * Body of the modal.\n */\n children?: React.ReactNode;\n /**\n * Specifies a footer for the modal. If empty, the footer isn't displayed.\n */\n footer?: React.ReactNode;\n /**\n * Determines whether the modal content has padding. If `true`, removes the default padding from the content area.\n */\n disableContentPaddings?: boolean;\n /**\n * Called when a user closes the modal by using the close icon button,\n * clicking outside of the modal, or pressing ESC.\n * The event detail contains the `reason`, which can be any of the following:\n * `['closeButton', 'overlay', 'keyboard']`.\n */\n onDismiss?: NonCancelableEventHandler<ModalProps.DismissDetail>;\n /**\n * Specifies the HTML element where the modal is rendered.\n * If neither `modalRoot` or `getModalRoot` properties are provided, the modal will\n * render to an element under `document.body`.\n */\n modalRoot?: HTMLElement;\n}\n\nexport namespace ModalProps {\n export type Size = 'small' | 'medium' | 'large' | 'max';\n\n export interface DismissDetail {\n reason: string;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/modal/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { FlowType } from '../internal/analytics/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface BaseModalProps {\n /**\n * Use this property to specify a different dynamic modal root for the dialog.\n * The function will be called when a user clicks on the trigger button.\n */\n getModalRoot?: () => Promise<HTMLElement>;\n\n /**\n * Use this property when `getModalRoot` is used to clean up the modal root\n * element after a user closes the dialog. The function receives the return value\n * of the most recent getModalRoot call as an argument.\n */\n removeModalRoot?: (rootElement: HTMLElement) => void;\n}\n\nexport interface ModalProps extends BaseComponentProps, BaseModalProps {\n /**\n * Sets the width of the modal. `max` uses variable width up to the\n * largest size allowed by the design guidelines. Other sizes\n * (`small`/`medium`/`large`) have fixed widths.\n */\n size?: ModalProps.Size;\n /**\n * Determines whether the modal is displayed on the screen. Modals are hidden by default.\n * Set this property to `true` to show them.\n */\n visible: boolean;\n /**\n * Adds an `aria-label` to the close button, for accessibility.\n * @i18n\n */\n closeAriaLabel?: string;\n /**\n * Specifies a title for the modal. Although this can be empty, we suggest that you always provide a title.\n */\n header?: React.ReactNode;\n /**\n * Body of the modal.\n */\n children?: React.ReactNode;\n /**\n * Specifies a footer for the modal. If empty, the footer isn't displayed.\n */\n footer?: React.ReactNode;\n /**\n * Determines whether the modal content has padding. If `true`, removes the default padding from the content area.\n */\n disableContentPaddings?: boolean;\n /**\n * Called when a user closes the modal by using the close icon button,\n * clicking outside of the modal, or pressing ESC.\n * The event detail contains the `reason`, which can be any of the following:\n * `['closeButton', 'overlay', 'keyboard']`.\n */\n onDismiss?: NonCancelableEventHandler<ModalProps.DismissDetail>;\n /**\n * Specifies the HTML element where the modal is rendered.\n * If neither `modalRoot` or `getModalRoot` properties are provided, the modal will\n * render to an element under `document.body`.\n */\n modalRoot?: HTMLElement;\n\n /**\n * Specifies additional analytics-related metadata.\n * * `instanceIdentifier` - A unique string that identifies this component instance in your application.\n * * `flowType` - Identifies the type of flow represented by the component.\n * * `resourceType` - Identifies the type of resource represented by the flow. **Note:** This API is currently experimental.\n * @analytics\n */\n analyticsMetadata?: ModalProps.AnalyticsMetadata;\n}\n\nexport namespace ModalProps {\n export type Size = 'small' | 'medium' | 'large' | 'max';\n\n export interface DismissDetail {\n reason: string;\n }\n\n export interface AnalyticsMetadata {\n instanceIdentifier?: string;\n flowType?: FlowType;\n resourceType?: string;\n }\n}\n"]}
|
package/modal/internal.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { FunnelStepContextValue, FunnelSubStepContextValue } from '../internal/analytics/context/analytics-context';
|
|
3
|
+
import { FunnelProps } from '../internal/analytics/hooks/use-funnel';
|
|
4
|
+
import { ButtonContextProps } from '../internal/context/button-context';
|
|
2
5
|
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
|
|
3
6
|
import { SomeRequired } from '../internal/types';
|
|
4
7
|
import { ModalProps } from './interfaces';
|
|
8
|
+
export declare function InternalModalAsFunnel(props: InternalModalProps): JSX.Element;
|
|
5
9
|
type InternalModalProps = SomeRequired<ModalProps, 'size'> & InternalBaseComponentProps & {
|
|
10
|
+
__funnelProps?: FunnelProps;
|
|
11
|
+
__funnelStepProps?: FunnelStepContextValue['funnelStepProps'];
|
|
12
|
+
__subStepRef?: FunnelSubStepContextValue['subStepRef'];
|
|
13
|
+
__subStepFunnelProps?: FunnelSubStepContextValue['funnelSubStepProps'];
|
|
6
14
|
__injectAnalyticsComponentMetadata?: boolean;
|
|
15
|
+
onButtonClick?: ButtonContextProps['onClick'];
|
|
7
16
|
referrerId?: string;
|
|
8
17
|
};
|
|
9
18
|
export default function InternalModal({ modalRoot, getModalRoot, removeModalRoot, ...rest }: InternalModalProps): JSX.Element;
|
package/modal/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/modal/internal.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/modal/internal.tsx"],"names":[],"mappings":";AAWA,OAAO,EAEL,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,WAAW,EAA8C,MAAM,wCAAwC,CAAC;AAIjH,OAAO,EAAiB,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAKvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAMlF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMjD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,kBAAkB,eAqB9D;AAED,KAAK,kBAAkB,GAAG,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,GACxD,0BAA0B,GAAG;IAC3B,aAAa,CAAC,EAAE,WAAW,CAAC;IAC5B,iBAAiB,CAAC,EAAE,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;IAC9D,YAAY,CAAC,EAAE,yBAAyB,CAAC,YAAY,CAAC,CAAC;IACvD,oBAAoB,CAAC,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,CAAC;IACvE,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAC7C,aAAa,CAAC,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEJ,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,GAAG,IAAI,EAAE,EAAE,kBAAkB,eAM9G"}
|
package/modal/internal.js
CHANGED
|
@@ -8,11 +8,12 @@ import { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-tool
|
|
|
8
8
|
import { InternalButton } from '../button/internal';
|
|
9
9
|
import InternalHeader from '../header/internal';
|
|
10
10
|
import { useInternalI18n } from '../i18n/context';
|
|
11
|
-
import { FunnelNameSelectorContext } from '../internal/analytics/context/analytics-context';
|
|
12
|
-
import { useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';
|
|
11
|
+
import { FunnelNameSelectorContext, } from '../internal/analytics/context/analytics-context';
|
|
12
|
+
import { useFunnel, useFunnelStep, useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';
|
|
13
13
|
import { getBaseProps } from '../internal/base-component';
|
|
14
14
|
import FocusLock from '../internal/components/focus-lock';
|
|
15
15
|
import Portal from '../internal/components/portal';
|
|
16
|
+
import { ButtonContext } from '../internal/context/button-context';
|
|
16
17
|
import { ModalContext } from '../internal/context/modal-context';
|
|
17
18
|
import ResetContextsForModal from '../internal/context/reset-contexts-for-modal';
|
|
18
19
|
import { fireNonCancelableEvent } from '../internal/events';
|
|
@@ -25,6 +26,18 @@ import { KeyCode } from '../internal/keycode';
|
|
|
25
26
|
import { disableBodyScrolling, enableBodyScrolling } from './body-scroll';
|
|
26
27
|
import analyticsSelectors from './analytics-metadata/styles.css.js';
|
|
27
28
|
import styles from './styles.css.js';
|
|
29
|
+
export function InternalModalAsFunnel(props) {
|
|
30
|
+
const { funnelProps, funnelSubmit, funnelNextOrSubmitAttempt } = useFunnel();
|
|
31
|
+
const { funnelStepProps } = useFunnelStep();
|
|
32
|
+
const { subStepRef, funnelSubStepProps } = useFunnelSubStep();
|
|
33
|
+
const onButtonClick = ({ variant }) => {
|
|
34
|
+
if (variant === 'primary') {
|
|
35
|
+
funnelNextOrSubmitAttempt();
|
|
36
|
+
funnelSubmit();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
return (React.createElement(InternalModal, Object.assign({ __funnelProps: funnelProps, __funnelStepProps: funnelStepProps, __subStepRef: subStepRef, __subStepFunnelProps: funnelSubStepProps, onButtonClick: onButtonClick }, props)));
|
|
40
|
+
}
|
|
28
41
|
export default function InternalModal(_a) {
|
|
29
42
|
var { modalRoot, getModalRoot, removeModalRoot } = _a, rest = __rest(_a, ["modalRoot", "getModalRoot", "removeModalRoot"]);
|
|
30
43
|
return (React.createElement(Portal, { container: modalRoot, getContainer: getModalRoot, removeContainer: removeModalRoot },
|
|
@@ -34,7 +47,7 @@ export default function InternalModal(_a) {
|
|
|
34
47
|
// useContainerQuery needs its targeted element to exist on the first render in order to work properly.
|
|
35
48
|
function PortaledModal(_a) {
|
|
36
49
|
var _b;
|
|
37
|
-
var { size, visible, header, children, footer, disableContentPaddings, onDismiss, __internalRootRef = null, __injectAnalyticsComponentMetadata, referrerId } = _a, rest = __rest(_a, ["size", "visible", "header", "children", "footer", "disableContentPaddings", "onDismiss", "__internalRootRef", "__injectAnalyticsComponentMetadata", "referrerId"]);
|
|
50
|
+
var { size, visible, header, children, footer, disableContentPaddings, onButtonClick = () => { }, onDismiss, __internalRootRef = null, __injectAnalyticsComponentMetadata, __funnelProps, __funnelStepProps, __subStepRef, __subStepFunnelProps, referrerId } = _a, rest = __rest(_a, ["size", "visible", "header", "children", "footer", "disableContentPaddings", "onButtonClick", "onDismiss", "__internalRootRef", "__injectAnalyticsComponentMetadata", "__funnelProps", "__funnelStepProps", "__subStepRef", "__subStepFunnelProps", "referrerId"]);
|
|
38
51
|
const instanceUniqueId = useUniqueId();
|
|
39
52
|
const headerId = `${rest.id || instanceUniqueId}-header`;
|
|
40
53
|
const lastMouseDownElementRef = useRef(null);
|
|
@@ -100,7 +113,7 @@ function PortaledModal(_a) {
|
|
|
100
113
|
return (React.createElement(FunnelNameSelectorContext.Provider, { value: `.${styles['header--text']}` },
|
|
101
114
|
React.createElement(ResetContextsForModal, null,
|
|
102
115
|
React.createElement(ModalContext.Provider, { value: { isInModal: true } },
|
|
103
|
-
React.createElement("div", Object.assign({}, baseProps, { className: clsx(styles.root, { [styles.hidden]: !visible }, baseProps.className, isRefresh && styles.refresh), role: "dialog", "aria-modal": true, "aria-labelledby": headerId, onMouseDown: onOverlayMouseDown, onClick: onOverlayClick, ref: mergedRef, style: footerHeight ? { scrollPaddingBottom: footerHeight } : undefined, "data-awsui-referrer-id": ((_b = subStepRef.current) === null || _b === void 0 ? void 0 : _b.id) || referrerId }),
|
|
116
|
+
React.createElement("div", Object.assign({}, baseProps, __funnelProps, __funnelStepProps, { className: clsx(styles.root, { [styles.hidden]: !visible }, baseProps.className, isRefresh && styles.refresh), role: "dialog", "aria-modal": true, "aria-labelledby": headerId, onMouseDown: onOverlayMouseDown, onClick: onOverlayClick, ref: mergedRef, style: footerHeight ? { scrollPaddingBottom: footerHeight } : undefined, "data-awsui-referrer-id": ((_b = subStepRef.current) === null || _b === void 0 ? void 0 : _b.id) || referrerId }),
|
|
104
117
|
React.createElement(FocusLock, { disabled: !visible, autoFocus: true, restoreFocus: true, className: styles['focus-lock'] },
|
|
105
118
|
React.createElement("div", Object.assign({ className: clsx(styles.dialog, styles[size], styles[`breakpoint-${breakpoint}`], isRefresh && styles.refresh), onKeyDown: escKeyHandler }, metadataAttribute),
|
|
106
119
|
React.createElement("div", { className: styles.container },
|
|
@@ -110,9 +123,10 @@ function PortaledModal(_a) {
|
|
|
110
123
|
})),
|
|
111
124
|
React.createElement(InternalButton, { ariaLabel: closeAriaLabel, className: styles['dismiss-control'], variant: "modal-dismiss", iconName: "close", formAction: "none", onClick: onCloseButtonClick })) },
|
|
112
125
|
React.createElement("span", { id: headerId, className: styles['header--text'] }, header))),
|
|
113
|
-
React.createElement("div", { className: clsx(styles.content, { [styles['no-paddings']]: disableContentPaddings }) },
|
|
126
|
+
React.createElement("div", Object.assign({ ref: __subStepRef }, __subStepFunnelProps, { className: clsx(styles.content, { [styles['no-paddings']]: disableContentPaddings }) }),
|
|
114
127
|
children,
|
|
115
128
|
React.createElement("div", { ref: stickySentinelRef })),
|
|
116
|
-
footer && (React.createElement(
|
|
129
|
+
footer && (React.createElement(ButtonContext.Provider, { value: { onClick: onButtonClick } },
|
|
130
|
+
React.createElement("div", { ref: footerRef, className: clsx(styles.footer, footerStuck && styles['footer--stuck']) }, footer)))))))))));
|
|
117
131
|
}
|
|
118
132
|
//# sourceMappingURL=internal.js.map
|
package/modal/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/modal/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,yBAAyB,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K,SAAS,EAAE,MAAM,CAAC,SAAS;gCAC9B,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC;oCAC5D,oBAAC,cAAc,IACb,OAAO,EAAC,IAAI,EACZ,wBAAwB,EAAE,IAAI,EAC9B,OAAO,EACL,6CACM,6BAA6B,CAAC;4CAChC,MAAM,EAAE,SAAS;yCACiC,CAAC;4CAErD,oBAAC,cAAc,IACb,SAAS,EAAE,cAAc,EACzB,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC,EACpC,OAAO,EAAC,eAAe,EACvB,QAAQ,EAAC,OAAO,EAChB,UAAU,EAAC,MAAM,EACjB,OAAO,EAAE,kBAAkB,GAC3B,CACE;wCAGR,8BAAM,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC,IAClD,MAAM,CACF,CACQ,CACb;gCACN,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,sBAAsB,EAAE,CAAC;oCACtF,QAAQ;oCACT,6BAAK,GAAG,EAAE,iBAAiB,GAAI,CAC3B;gCACL,MAAM,IAAI,CACT,6BAAK,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,IAAI,MAAM,CAAC,eAAe,CAAC,CAAC,IACxF,MAAM,CACH,CACP,CACG,CACF,CACI,CACR,CACgB,CACF,CACW,CACtC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useContainerQuery } from '@cloudscape-design/component-toolkit';\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { InternalButton } from '../button/internal';\nimport InternalHeader from '../header/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { FunnelNameSelectorContext } from '../internal/analytics/context/analytics-context';\nimport { useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport { getBaseProps } from '../internal/base-component';\nimport FocusLock from '../internal/components/focus-lock';\nimport Portal from '../internal/components/portal';\nimport { ModalContext } from '../internal/context/modal-context';\nimport ResetContextsForModal from '../internal/context/reset-contexts-for-modal';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { useContainerBreakpoints } from '../internal/hooks/container-queries';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useIntersectionObserver } from '../internal/hooks/use-intersection-observer';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { KeyCode } from '../internal/keycode';\nimport { SomeRequired } from '../internal/types';\nimport {\n GeneratedAnalyticsMetadataModalComponent,\n GeneratedAnalyticsMetadataModalDismiss,\n} from './analytics-metadata/interfaces';\nimport { disableBodyScrolling, enableBodyScrolling } from './body-scroll';\nimport { ModalProps } from './interfaces';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\n\ntype InternalModalProps = SomeRequired<ModalProps, 'size'> &\n InternalBaseComponentProps & { __injectAnalyticsComponentMetadata?: boolean; referrerId?: string };\n\nexport default function InternalModal({ modalRoot, getModalRoot, removeModalRoot, ...rest }: InternalModalProps) {\n return (\n <Portal container={modalRoot} getContainer={getModalRoot} removeContainer={removeModalRoot}>\n <PortaledModal {...rest} />\n </Portal>\n );\n}\n\ntype PortaledModalProps = Omit<InternalModalProps, 'modalRoot' | 'getModalRoot' | 'removeModalRoot'>;\n\n// Separate component to prevent the Portal from getting in the way of refs, as it needs extra cycles to render the inner components.\n// useContainerQuery needs its targeted element to exist on the first render in order to work properly.\nfunction PortaledModal({\n size,\n visible,\n header,\n children,\n footer,\n disableContentPaddings,\n onDismiss,\n __internalRootRef = null,\n __injectAnalyticsComponentMetadata,\n referrerId,\n ...rest\n}: PortaledModalProps) {\n const instanceUniqueId = useUniqueId();\n const headerId = `${rest.id || instanceUniqueId}-header`;\n const lastMouseDownElementRef = useRef<HTMLElement | null>(null);\n const [breakpoint, breakpointsRef] = useContainerBreakpoints(['xs']);\n\n const i18n = useInternalI18n('modal');\n const closeAriaLabel = i18n('closeAriaLabel', rest.closeAriaLabel);\n\n const refObject = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs(breakpointsRef, refObject, __internalRootRef);\n\n const isRefresh = useVisualRefresh();\n\n const baseProps = getBaseProps(rest);\n\n const analyticsComponentMetadata: GeneratedAnalyticsMetadataModalComponent = {\n name: 'awsui.Modal',\n label: `.${analyticsSelectors.header} h2`,\n };\n\n const metadataAttribute = __injectAnalyticsComponentMetadata\n ? getAnalyticsMetadataAttribute({ component: analyticsComponentMetadata })\n : {};\n\n // enable body scroll and restore focus if unmounting while visible\n useEffect(() => {\n return () => {\n enableBodyScrolling();\n };\n }, []);\n\n // enable / disable body scroll\n useEffect(() => {\n if (visible) {\n disableBodyScrolling();\n } else {\n enableBodyScrolling();\n }\n }, [visible]);\n\n // Because we hide the element with styles (and not actually detach it from DOM), we need to scroll to top\n useEffect(() => {\n if (visible && refObject.current) {\n refObject.current.scrollTop = 0;\n }\n }, [visible]);\n\n const dismiss = (reason: string) => fireNonCancelableEvent(onDismiss, { reason });\n\n const onOverlayMouseDown = (event: React.MouseEvent) => {\n lastMouseDownElementRef.current = event.target as HTMLElement;\n };\n const onOverlayClick = (event: React.MouseEvent) => {\n const overlay = refObject.current;\n const lastClicked = lastMouseDownElementRef.current;\n\n if (event.target === overlay && lastClicked === overlay) {\n dismiss('overlay');\n }\n };\n const onCloseButtonClick = () => dismiss('closeButton');\n const escKeyHandler = (event: React.KeyboardEvent) => {\n if (event.keyCode === KeyCode.escape) {\n dismiss('keyboard');\n }\n };\n\n // We use an empty div element at the end of the content slot as a sentinel\n // to detect when the user has scrolled to the bottom.\n const { ref: stickySentinelRef, isIntersecting: footerStuck } = useIntersectionObserver();\n\n // Add extra scroll padding to account for the height of the sticky footer,\n // to prevent it from covering focused elements.\n const [footerHeight, footerRef] = useContainerQuery(rect => rect.borderBoxHeight);\n const { subStepRef } = useFunnelSubStep();\n\n return (\n <FunnelNameSelectorContext.Provider value={`.${styles['header--text']}`}>\n <ResetContextsForModal>\n <ModalContext.Provider value={{ isInModal: true }}>\n <div\n {...baseProps}\n className={clsx(\n styles.root,\n { [styles.hidden]: !visible },\n baseProps.className,\n isRefresh && styles.refresh\n )}\n role=\"dialog\"\n aria-modal={true}\n aria-labelledby={headerId}\n onMouseDown={onOverlayMouseDown}\n onClick={onOverlayClick}\n ref={mergedRef}\n style={footerHeight ? { scrollPaddingBottom: footerHeight } : undefined}\n data-awsui-referrer-id={subStepRef.current?.id || referrerId}\n >\n <FocusLock disabled={!visible} autoFocus={true} restoreFocus={true} className={styles['focus-lock']}>\n <div\n className={clsx(\n styles.dialog,\n styles[size],\n styles[`breakpoint-${breakpoint}`],\n isRefresh && styles.refresh\n )}\n onKeyDown={escKeyHandler}\n {...metadataAttribute}\n >\n <div className={styles.container}>\n <div className={clsx(styles.header, analyticsSelectors.header)}>\n <InternalHeader\n variant=\"h2\"\n __disableActionsWrapping={true}\n actions={\n <div\n {...getAnalyticsMetadataAttribute({\n action: 'dismiss',\n } as Partial<GeneratedAnalyticsMetadataModalDismiss>)}\n >\n <InternalButton\n ariaLabel={closeAriaLabel}\n className={styles['dismiss-control']}\n variant=\"modal-dismiss\"\n iconName=\"close\"\n formAction=\"none\"\n onClick={onCloseButtonClick}\n />\n </div>\n }\n >\n <span id={headerId} className={styles['header--text']}>\n {header}\n </span>\n </InternalHeader>\n </div>\n <div className={clsx(styles.content, { [styles['no-paddings']]: disableContentPaddings })}>\n {children}\n <div ref={stickySentinelRef} />\n </div>\n {footer && (\n <div ref={footerRef} className={clsx(styles.footer, footerStuck && styles['footer--stuck'])}>\n {footer}\n </div>\n )}\n </div>\n </div>\n </FocusLock>\n </div>\n </ModalContext.Provider>\n </ResetContextsForModal>\n </FunnelNameSelectorContext.Provider>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/modal/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,yBAAyB,GAG1B,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAe,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AACjH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,SAAS,MAAM,mCAAmC,CAAC;AAC1D,OAAO,MAAM,MAAM,+BAA+B,CAAC;AACnD,OAAO,EAAE,aAAa,EAAsB,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,qBAAqB,MAAM,8CAA8C,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,WAAW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AC,IACxF,MAAM,CACH,CACiB,CAC1B,CACG,CACF,CACI,CACR,CACgB,CACF,CACW,CACtC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useContainerQuery } from '@cloudscape-design/component-toolkit';\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { InternalButton } from '../button/internal';\nimport InternalHeader from '../header/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport {\n FunnelNameSelectorContext,\n FunnelStepContextValue,\n FunnelSubStepContextValue,\n} from '../internal/analytics/context/analytics-context';\nimport { FunnelProps, useFunnel, useFunnelStep, useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport { getBaseProps } from '../internal/base-component';\nimport FocusLock from '../internal/components/focus-lock';\nimport Portal from '../internal/components/portal';\nimport { ButtonContext, ButtonContextProps } from '../internal/context/button-context';\nimport { ModalContext } from '../internal/context/modal-context';\nimport ResetContextsForModal from '../internal/context/reset-contexts-for-modal';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { useContainerBreakpoints } from '../internal/hooks/container-queries';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useIntersectionObserver } from '../internal/hooks/use-intersection-observer';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { KeyCode } from '../internal/keycode';\nimport { SomeRequired } from '../internal/types';\nimport {\n GeneratedAnalyticsMetadataModalComponent,\n GeneratedAnalyticsMetadataModalDismiss,\n} from './analytics-metadata/interfaces';\nimport { disableBodyScrolling, enableBodyScrolling } from './body-scroll';\nimport { ModalProps } from './interfaces';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\n\nexport function InternalModalAsFunnel(props: InternalModalProps) {\n const { funnelProps, funnelSubmit, funnelNextOrSubmitAttempt } = useFunnel();\n const { funnelStepProps } = useFunnelStep();\n const { subStepRef, funnelSubStepProps } = useFunnelSubStep();\n const onButtonClick: ButtonContextProps['onClick'] = ({ variant }) => {\n if (variant === 'primary') {\n funnelNextOrSubmitAttempt();\n funnelSubmit();\n }\n };\n\n return (\n <InternalModal\n __funnelProps={funnelProps}\n __funnelStepProps={funnelStepProps}\n __subStepRef={subStepRef}\n __subStepFunnelProps={funnelSubStepProps}\n onButtonClick={onButtonClick}\n {...props}\n />\n );\n}\n\ntype InternalModalProps = SomeRequired<ModalProps, 'size'> &\n InternalBaseComponentProps & {\n __funnelProps?: FunnelProps;\n __funnelStepProps?: FunnelStepContextValue['funnelStepProps'];\n __subStepRef?: FunnelSubStepContextValue['subStepRef'];\n __subStepFunnelProps?: FunnelSubStepContextValue['funnelSubStepProps'];\n __injectAnalyticsComponentMetadata?: boolean;\n onButtonClick?: ButtonContextProps['onClick'];\n referrerId?: string;\n };\n\nexport default function InternalModal({ modalRoot, getModalRoot, removeModalRoot, ...rest }: InternalModalProps) {\n return (\n <Portal container={modalRoot} getContainer={getModalRoot} removeContainer={removeModalRoot}>\n <PortaledModal {...rest} />\n </Portal>\n );\n}\n\ntype PortaledModalProps = Omit<InternalModalProps, 'modalRoot' | 'getModalRoot' | 'removeModalRoot'>;\n\n// Separate component to prevent the Portal from getting in the way of refs, as it needs extra cycles to render the inner components.\n// useContainerQuery needs its targeted element to exist on the first render in order to work properly.\nfunction PortaledModal({\n size,\n visible,\n header,\n children,\n footer,\n disableContentPaddings,\n onButtonClick = () => {},\n onDismiss,\n __internalRootRef = null,\n __injectAnalyticsComponentMetadata,\n __funnelProps,\n __funnelStepProps,\n __subStepRef,\n __subStepFunnelProps,\n referrerId,\n ...rest\n}: PortaledModalProps) {\n const instanceUniqueId = useUniqueId();\n const headerId = `${rest.id || instanceUniqueId}-header`;\n const lastMouseDownElementRef = useRef<HTMLElement | null>(null);\n const [breakpoint, breakpointsRef] = useContainerBreakpoints(['xs']);\n\n const i18n = useInternalI18n('modal');\n const closeAriaLabel = i18n('closeAriaLabel', rest.closeAriaLabel);\n\n const refObject = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs(breakpointsRef, refObject, __internalRootRef);\n\n const isRefresh = useVisualRefresh();\n\n const baseProps = getBaseProps(rest);\n\n const analyticsComponentMetadata: GeneratedAnalyticsMetadataModalComponent = {\n name: 'awsui.Modal',\n label: `.${analyticsSelectors.header} h2`,\n };\n\n const metadataAttribute = __injectAnalyticsComponentMetadata\n ? getAnalyticsMetadataAttribute({ component: analyticsComponentMetadata })\n : {};\n\n // enable body scroll and restore focus if unmounting while visible\n useEffect(() => {\n return () => {\n enableBodyScrolling();\n };\n }, []);\n\n // enable / disable body scroll\n useEffect(() => {\n if (visible) {\n disableBodyScrolling();\n } else {\n enableBodyScrolling();\n }\n }, [visible]);\n\n // Because we hide the element with styles (and not actually detach it from DOM), we need to scroll to top\n useEffect(() => {\n if (visible && refObject.current) {\n refObject.current.scrollTop = 0;\n }\n }, [visible]);\n\n const dismiss = (reason: string) => fireNonCancelableEvent(onDismiss, { reason });\n\n const onOverlayMouseDown = (event: React.MouseEvent) => {\n lastMouseDownElementRef.current = event.target as HTMLElement;\n };\n const onOverlayClick = (event: React.MouseEvent) => {\n const overlay = refObject.current;\n const lastClicked = lastMouseDownElementRef.current;\n\n if (event.target === overlay && lastClicked === overlay) {\n dismiss('overlay');\n }\n };\n const onCloseButtonClick = () => dismiss('closeButton');\n const escKeyHandler = (event: React.KeyboardEvent) => {\n if (event.keyCode === KeyCode.escape) {\n dismiss('keyboard');\n }\n };\n\n // We use an empty div element at the end of the content slot as a sentinel\n // to detect when the user has scrolled to the bottom.\n const { ref: stickySentinelRef, isIntersecting: footerStuck } = useIntersectionObserver();\n\n // Add extra scroll padding to account for the height of the sticky footer,\n // to prevent it from covering focused elements.\n const [footerHeight, footerRef] = useContainerQuery(rect => rect.borderBoxHeight);\n const { subStepRef } = useFunnelSubStep();\n\n return (\n <FunnelNameSelectorContext.Provider value={`.${styles['header--text']}`}>\n <ResetContextsForModal>\n <ModalContext.Provider value={{ isInModal: true }}>\n <div\n {...baseProps}\n {...__funnelProps}\n {...__funnelStepProps}\n className={clsx(\n styles.root,\n { [styles.hidden]: !visible },\n baseProps.className,\n isRefresh && styles.refresh\n )}\n role=\"dialog\"\n aria-modal={true}\n aria-labelledby={headerId}\n onMouseDown={onOverlayMouseDown}\n onClick={onOverlayClick}\n ref={mergedRef}\n style={footerHeight ? { scrollPaddingBottom: footerHeight } : undefined}\n data-awsui-referrer-id={subStepRef.current?.id || referrerId}\n >\n <FocusLock disabled={!visible} autoFocus={true} restoreFocus={true} className={styles['focus-lock']}>\n <div\n className={clsx(\n styles.dialog,\n styles[size],\n styles[`breakpoint-${breakpoint}`],\n isRefresh && styles.refresh\n )}\n onKeyDown={escKeyHandler}\n {...metadataAttribute}\n >\n <div className={styles.container}>\n <div className={clsx(styles.header, analyticsSelectors.header)}>\n <InternalHeader\n variant=\"h2\"\n __disableActionsWrapping={true}\n actions={\n <div\n {...getAnalyticsMetadataAttribute({\n action: 'dismiss',\n } as Partial<GeneratedAnalyticsMetadataModalDismiss>)}\n >\n <InternalButton\n ariaLabel={closeAriaLabel}\n className={styles['dismiss-control']}\n variant=\"modal-dismiss\"\n iconName=\"close\"\n formAction=\"none\"\n onClick={onCloseButtonClick}\n />\n </div>\n }\n >\n <span id={headerId} className={styles['header--text']}>\n {header}\n </span>\n </InternalHeader>\n </div>\n <div\n ref={__subStepRef}\n {...__subStepFunnelProps}\n className={clsx(styles.content, { [styles['no-paddings']]: disableContentPaddings })}\n >\n {children}\n <div ref={stickySentinelRef} />\n </div>\n {footer && (\n <ButtonContext.Provider value={{ onClick: onButtonClick }}>\n <div ref={footerRef} className={clsx(styles.footer, footerStuck && styles['footer--stuck'])}>\n {footer}\n </div>\n </ButtonContext.Provider>\n )}\n </div>\n </div>\n </FocusLock>\n </div>\n </ModalContext.Provider>\n </ResetContextsForModal>\n </FunnelNameSelectorContext.Provider>\n );\n}\n"]}
|
package/package.json
CHANGED