@cloudscape-design/components-themeable 3.0.1383 → 3.0.1384

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/internal/components/control-group/styles.scss +27 -10
  3. package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
  4. package/lib/internal/scss/internal/styles/forms/mixins.scss +37 -22
  5. package/lib/internal/scss/modal/styles.scss +6 -0
  6. package/lib/internal/scss/prompt-input/styles.scss +4 -0
  7. package/lib/internal/scss/segmented-control/segment.scss +5 -0
  8. package/lib/internal/scss/segmented-control/styles.scss +12 -2
  9. package/lib/internal/scss/steps/styles.scss +1 -1
  10. package/lib/internal/template/input/internal.d.ts.map +1 -1
  11. package/lib/internal/template/input/internal.js +3 -4
  12. package/lib/internal/template/input/internal.js.map +1 -1
  13. package/lib/internal/template/input/styles.css.js +36 -34
  14. package/lib/internal/template/input/styles.scoped.css +89 -79
  15. package/lib/internal/template/input/styles.selectors.js +36 -34
  16. package/lib/internal/template/internal/base-component/styles.scoped.css +1 -1
  17. package/lib/internal/template/internal/components/button-trigger/index.d.ts +2 -2
  18. package/lib/internal/template/internal/components/button-trigger/index.d.ts.map +1 -1
  19. package/lib/internal/template/internal/components/button-trigger/index.js +3 -2
  20. package/lib/internal/template/internal/components/button-trigger/index.js.map +1 -1
  21. package/lib/internal/template/internal/components/button-trigger/styles.css.js +21 -19
  22. package/lib/internal/template/internal/components/button-trigger/styles.scoped.css +49 -39
  23. package/lib/internal/template/internal/components/button-trigger/styles.selectors.js +21 -19
  24. package/lib/internal/template/internal/components/control-group/grouped-control-styles.d.ts +10 -0
  25. package/lib/internal/template/internal/components/control-group/grouped-control-styles.d.ts.map +1 -0
  26. package/lib/internal/template/internal/components/control-group/grouped-control-styles.js +14 -0
  27. package/lib/internal/template/internal/components/control-group/grouped-control-styles.js.map +1 -0
  28. package/lib/internal/template/internal/components/control-group/index.d.ts +3 -1
  29. package/lib/internal/template/internal/components/control-group/index.d.ts.map +1 -1
  30. package/lib/internal/template/internal/components/control-group/index.js +5 -5
  31. package/lib/internal/template/internal/components/control-group/index.js.map +1 -1
  32. package/lib/internal/template/internal/components/control-group/styles.css.js +8 -4
  33. package/lib/internal/template/internal/components/control-group/styles.scoped.css +13 -4
  34. package/lib/internal/template/internal/components/control-group/styles.selectors.js +8 -4
  35. package/lib/internal/template/internal/components/focus-lock/index.d.ts +6 -0
  36. package/lib/internal/template/internal/components/focus-lock/index.d.ts.map +1 -1
  37. package/lib/internal/template/internal/components/focus-lock/index.js +8 -3
  38. package/lib/internal/template/internal/components/focus-lock/index.js.map +1 -1
  39. package/lib/internal/template/internal/context/control-group-context.d.ts +6 -0
  40. package/lib/internal/template/internal/context/control-group-context.d.ts.map +1 -1
  41. package/lib/internal/template/internal/context/control-group-context.js +3 -1
  42. package/lib/internal/template/internal/context/control-group-context.js.map +1 -1
  43. package/lib/internal/template/internal/environment.js +2 -2
  44. package/lib/internal/template/internal/environment.json +2 -2
  45. package/lib/internal/template/modal/index.d.ts +1 -1
  46. package/lib/internal/template/modal/index.d.ts.map +1 -1
  47. package/lib/internal/template/modal/index.js +6 -5
  48. package/lib/internal/template/modal/index.js.map +1 -1
  49. package/lib/internal/template/modal/interfaces.d.ts +7 -0
  50. package/lib/internal/template/modal/interfaces.d.ts.map +1 -1
  51. package/lib/internal/template/modal/interfaces.js.map +1 -1
  52. package/lib/internal/template/modal/internal.js +23 -6
  53. package/lib/internal/template/modal/internal.js.map +1 -1
  54. package/lib/internal/template/modal/styles.css.js +32 -31
  55. package/lib/internal/template/modal/styles.scoped.css +49 -46
  56. package/lib/internal/template/modal/styles.selectors.js +32 -31
  57. package/lib/internal/template/multiselect/internal.d.ts.map +1 -1
  58. package/lib/internal/template/multiselect/internal.js +7 -3
  59. package/lib/internal/template/multiselect/internal.js.map +1 -1
  60. package/lib/internal/template/prompt-input/styles.css.js +26 -26
  61. package/lib/internal/template/prompt-input/styles.scoped.css +57 -53
  62. package/lib/internal/template/prompt-input/styles.selectors.js +26 -26
  63. package/lib/internal/template/segmented-control/internal-segmented-control.d.ts +3 -3
  64. package/lib/internal/template/segmented-control/internal-segmented-control.d.ts.map +1 -1
  65. package/lib/internal/template/segmented-control/internal-segmented-control.js +8 -5
  66. package/lib/internal/template/segmented-control/internal-segmented-control.js.map +1 -1
  67. package/lib/internal/template/segmented-control/internal.d.ts.map +1 -1
  68. package/lib/internal/template/segmented-control/internal.js +4 -6
  69. package/lib/internal/template/segmented-control/internal.js.map +1 -1
  70. package/lib/internal/template/segmented-control/segment.d.ts +1 -0
  71. package/lib/internal/template/segmented-control/segment.d.ts.map +1 -1
  72. package/lib/internal/template/segmented-control/segment.js +2 -2
  73. package/lib/internal/template/segmented-control/segment.js.map +1 -1
  74. package/lib/internal/template/segmented-control/styles.css.js +26 -21
  75. package/lib/internal/template/segmented-control/styles.scoped.css +75 -43
  76. package/lib/internal/template/segmented-control/styles.selectors.js +26 -21
  77. package/lib/internal/template/select/internal.js +2 -2
  78. package/lib/internal/template/select/internal.js.map +1 -1
  79. package/lib/internal/template/select/parts/trigger.d.ts +2 -2
  80. package/lib/internal/template/select/parts/trigger.d.ts.map +1 -1
  81. package/lib/internal/template/select/parts/trigger.js +2 -2
  82. package/lib/internal/template/select/parts/trigger.js.map +1 -1
  83. package/lib/internal/template/steps/styles.css.js +17 -17
  84. package/lib/internal/template/steps/styles.scoped.css +35 -35
  85. package/lib/internal/template/steps/styles.selectors.js +17 -17
  86. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/focus-lock/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7F,OAAO,EAAE,WAAW,E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E,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,GAAI;QAChH,6BAAK,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,IACtC,QAAQ,CACL;QACN,oBAAC,OAAO,IAAC,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,GAAI,CAC/G,CACJ,CAAC;AACJ,CAAC;AAED,eAAe,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';\n\nimport { nodeBelongs } from '@cloudscape-design/component-toolkit/dom';\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport TabTrap from '../tab-trap/index';\nimport { getFirstFocusable, getLastFocusable } from './utils';\n\nexport interface FocusLockProps {\n className?: string;\n disabled?: boolean;\n autoFocus?: boolean;\n restoreFocus?: boolean;\n children: React.ReactNode;\n}\n\nexport interface FocusLockRef {\n /**\n * Focuses the first element in the component.\n */\n focusFirst(): void;\n}\n\nfunction FocusLock(\n { className, disabled, autoFocus, restoreFocus, children }: FocusLockProps,\n ref: React.Ref<FocusLockRef>\n) {\n const restoreFocusTargetRef = useRef<HTMLOrSVGElement | null>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n const focusFirst = () => {\n if (containerRef.current) {\n getFirstFocusable(containerRef.current)?.focus();\n }\n };\n\n const focusLast = () => {\n if (containerRef.current) {\n getLastFocusable(containerRef.current)?.focus();\n }\n };\n\n // Captures focus when `autoFocus` is set, and the component is mounted or\n // `disabled` changes from true to false.\n useEffect(() => {\n const assignRestoreFocusTarget = () => {\n if (document.activeElement && !containerRef.current?.contains(document.activeElement as Node)) {\n restoreFocusTargetRef.current = document.activeElement as unknown as HTMLOrSVGElement;\n }\n };\n if (autoFocus && !disabled) {\n assignRestoreFocusTarget();\n focusFirst();\n }\n }, [autoFocus, disabled]);\n\n // Restore focus if `restoreFocus` is set, and `disabled` changes from false to true.\n const [previouslyDisabled, setPreviouslyDisabled] = useState(!!disabled);\n useEffect(() => {\n if (previouslyDisabled !== !!disabled) {\n setPreviouslyDisabled(!!disabled);\n if (restoreFocus && disabled) {\n restoreFocusTargetRef.current?.focus();\n restoreFocusTargetRef.current = null;\n }\n }\n }, [previouslyDisabled, disabled, restoreFocus]);\n\n // Restore focus if `restoreFocus` is set and the component is unmounted.\n // Using a callback ref for this is safer than using useEffect cleanups.\n const restoreFocusHandler = useCallback(\n (elem: HTMLDivElement | null) => {\n if (elem === null && restoreFocus) {\n restoreFocusTargetRef.current?.focus();\n restoreFocusTargetRef.current = null;\n }\n },\n [restoreFocus]\n );\n\n useImperativeHandle(ref, () => ({ focusFirst }));\n const mergedRef = useMergeRefs(containerRef, restoreFocusHandler);\n\n const isFocusInside = (event: React.FocusEvent) => nodeBelongs(containerRef.current, event.relatedTarget);\n return (\n <>\n <TabTrap disabled={disabled} focusNextCallback={event => (isFocusInside(event) ? focusLast() : focusFirst())} />\n <div className={className} ref={mergedRef}>\n {children}\n </div>\n <TabTrap disabled={disabled} focusNextCallback={event => (isFocusInside(event) ? focusFirst() : focusLast())} />\n </>\n );\n}\n\nexport default React.forwardRef(FocusLock);\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/focus-lock/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7F,OAAO,EAAE,WAAW,EAAE,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E,CAAC,WAAW,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC1G,OAAO,CACL;QACE,oBAAC,OAAO,IAAC,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,GAAI;QAChH,6BAAK,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,IACtC,QAAQ,CACL;QACN,oBAAC,OAAO,IAAC,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,GAAI,CAC/G,CACJ,CAAC;AACJ,CAAC;AAED,eAAe,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';\n\nimport { nodeBelongs } from '@cloudscape-design/component-toolkit/dom';\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport TabTrap from '../tab-trap/index';\nimport { getFirstFocusable, getLastFocusable } from './utils';\n\nexport interface FocusLockProps {\n className?: string;\n disabled?: boolean;\n autoFocus?: boolean;\n restoreFocus?: boolean;\n /**\n * Element to focus when `autoFocus` captures focus. Defaults to the first\n * focusable element in the container. Use this to focus an element that isn't\n * keyboard-reachable, such as a heading with `tabIndex={-1}`.\n */\n autoFocusTarget?: React.RefObject<HTMLElement>;\n children: React.ReactNode;\n}\n\nexport interface FocusLockRef {\n /**\n * Focuses the first element in the component.\n */\n focusFirst(): void;\n}\n\nfunction FocusLock(\n { className, disabled, autoFocus, restoreFocus, autoFocusTarget, children }: FocusLockProps,\n ref: React.Ref<FocusLockRef>\n) {\n const restoreFocusTargetRef = useRef<HTMLOrSVGElement | null>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n const focusFirst = () => {\n if (containerRef.current) {\n getFirstFocusable(containerRef.current)?.focus();\n }\n };\n\n const focusLast = () => {\n if (containerRef.current) {\n getLastFocusable(containerRef.current)?.focus();\n }\n };\n\n // Captures focus when `autoFocus` is set, and the component is mounted or\n // `disabled` changes from true to false.\n useEffect(() => {\n const assignRestoreFocusTarget = () => {\n if (document.activeElement && !containerRef.current?.contains(document.activeElement as Node)) {\n restoreFocusTargetRef.current = document.activeElement as unknown as HTMLOrSVGElement;\n }\n };\n if (autoFocus && !disabled) {\n assignRestoreFocusTarget();\n if (autoFocusTarget?.current) {\n autoFocusTarget.current.focus();\n } else {\n focusFirst();\n }\n }\n }, [autoFocus, disabled, autoFocusTarget]);\n\n // Restore focus if `restoreFocus` is set, and `disabled` changes from false to true.\n const [previouslyDisabled, setPreviouslyDisabled] = useState(!!disabled);\n useEffect(() => {\n if (previouslyDisabled !== !!disabled) {\n setPreviouslyDisabled(!!disabled);\n if (restoreFocus && disabled) {\n restoreFocusTargetRef.current?.focus();\n restoreFocusTargetRef.current = null;\n }\n }\n }, [previouslyDisabled, disabled, restoreFocus]);\n\n // Restore focus if `restoreFocus` is set and the component is unmounted.\n // Using a callback ref for this is safer than using useEffect cleanups.\n const restoreFocusHandler = useCallback(\n (elem: HTMLDivElement | null) => {\n if (elem === null && restoreFocus) {\n restoreFocusTargetRef.current?.focus();\n restoreFocusTargetRef.current = null;\n }\n },\n [restoreFocus]\n );\n\n useImperativeHandle(ref, () => ({ focusFirst }));\n const mergedRef = useMergeRefs(containerRef, restoreFocusHandler);\n\n const isFocusInside = (event: React.FocusEvent) => nodeBelongs(containerRef.current, event.relatedTarget);\n return (\n <>\n <TabTrap disabled={disabled} focusNextCallback={event => (isFocusInside(event) ? focusLast() : focusFirst())} />\n <div className={className} ref={mergedRef}>\n {children}\n </div>\n <TabTrap disabled={disabled} focusNextCallback={event => (isFocusInside(event) ? focusFirst() : focusLast())} />\n </>\n );\n}\n\nexport default React.forwardRef(FocusLock);\n"]}
@@ -1,11 +1,17 @@
1
1
  import React from 'react';
2
2
  export type GroupedControlPosition = 'first' | 'middle' | 'last' | 'only';
3
+ export type GroupedControlDirection = 'horizontal' | 'vertical';
3
4
  export interface GroupedControlContextProps {
4
5
  /**
5
6
  * The control's position within a control group,
6
7
  * or `null` when the control is not in a control group.
7
8
  */
8
9
  position: GroupedControlPosition | null;
10
+ /**
11
+ * The axis along which the surrounding control group lays out its
12
+ * controls.
13
+ */
14
+ direction: GroupedControlDirection;
9
15
  }
10
16
  export declare const GroupedControlContext: React.Context<GroupedControlContextProps>;
11
17
  export declare function useGroupedControlContext(): GroupedControlContextProps;
@@ -1 +1 @@
1
- {"version":3,"file":"control-group-context.d.ts","sourceRoot":"","sources":["../../../../src/internal/context/control-group-context.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1E,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,QAAQ,EAAE,sBAAsB,GAAG,IAAI,CAAC;CACzC;AAED,eAAO,MAAM,qBAAqB,2CAEhC,CAAC;AAEH,wBAAgB,wBAAwB,+BAEvC;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,eAErF"}
1
+ {"version":3,"file":"control-group-context.d.ts","sourceRoot":"","sources":["../../../../src/internal/context/control-group-context.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1E,MAAM,MAAM,uBAAuB,GAAG,YAAY,GAAG,UAAU,CAAC;AAEhE,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,QAAQ,EAAE,sBAAsB,GAAG,IAAI,CAAC;IACxC;;;OAGG;IACH,SAAS,EAAE,uBAAuB,CAAC;CACpC;AAED,eAAO,MAAM,qBAAqB,2CAGhC,CAAC;AAEH,wBAAgB,wBAAwB,+BAEvC;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,eAKrF"}
@@ -3,6 +3,7 @@
3
3
  import React, { createContext, useContext } from 'react';
4
4
  export const GroupedControlContext = createContext({
5
5
  position: null,
6
+ direction: 'horizontal',
6
7
  });
7
8
  export function useGroupedControlContext() {
8
9
  return useContext(GroupedControlContext);
@@ -17,6 +18,7 @@ export function useGroupedControlContext() {
17
18
  * where adjacent borders lose their border radii.
18
19
  */
19
20
  export function ResetGroupedControlContext({ children }) {
20
- return React.createElement(GroupedControlContext.Provider, { value: { position: null } }, children);
21
+ const { direction } = useGroupedControlContext();
22
+ return (React.createElement(GroupedControlContext.Provider, { value: { position: null, direction } }, children));
21
23
  }
22
24
  //# sourceMappingURL=control-group-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"control-group-context.js","sourceRoot":"","sources":["../../../../src/internal/context/control-group-context.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAYzD,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAA6B;IAC7E,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC;AAEH,MAAM,UAAU,wBAAwB;IACtC,OAAO,UAAU,CAAC,qBAAqB,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CAAC,EAAE,QAAQ,EAAiC;IACpF,OAAO,oBAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAG,QAAQ,CAAkC,CAAC;AAChH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { createContext, useContext } from 'react';\n\nexport type GroupedControlPosition = 'first' | 'middle' | 'last' | 'only';\n\nexport interface GroupedControlContextProps {\n /**\n * The control's position within a control group,\n * or `null` when the control is not in a control group.\n */\n position: GroupedControlPosition | null;\n}\n\nexport const GroupedControlContext = createContext<GroupedControlContextProps>({\n position: null,\n});\n\nexport function useGroupedControlContext() {\n return useContext(GroupedControlContext);\n}\n\n/**\n * Resets the grouped-control context back to \"not in a group\" for a subtree.\n *\n * Controls that render caller-supplied content (for example, custom dropdown\n * content) should wrap that content with this provider. Otherwise a nested\n * control rendered inside such a slot would inherit the surrounding group's\n * `position` and incorrectly pick up the grouped-control styling\n * where adjacent borders lose their border radii.\n */\nexport function ResetGroupedControlContext({ children }: { children: React.ReactNode }) {\n return <GroupedControlContext.Provider value={{ position: null }}>{children}</GroupedControlContext.Provider>;\n}\n"]}
1
+ {"version":3,"file":"control-group-context.js","sourceRoot":"","sources":["../../../../src/internal/context/control-group-context.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAmBzD,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAA6B;IAC7E,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,YAAY;CACxB,CAAC,CAAC;AAEH,MAAM,UAAU,wBAAwB;IACtC,OAAO,UAAU,CAAC,qBAAqB,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CAAC,EAAE,QAAQ,EAAiC;IACpF,MAAM,EAAE,SAAS,EAAE,GAAG,wBAAwB,EAAE,CAAC;IACjD,OAAO,CACL,oBAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAG,QAAQ,CAAkC,CAClH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { createContext, useContext } from 'react';\n\nexport type GroupedControlPosition = 'first' | 'middle' | 'last' | 'only';\n\nexport type GroupedControlDirection = 'horizontal' | 'vertical';\n\nexport interface GroupedControlContextProps {\n /**\n * The control's position within a control group,\n * or `null` when the control is not in a control group.\n */\n position: GroupedControlPosition | null;\n /**\n * The axis along which the surrounding control group lays out its\n * controls.\n */\n direction: GroupedControlDirection;\n}\n\nexport const GroupedControlContext = createContext<GroupedControlContextProps>({\n position: null,\n direction: 'horizontal',\n});\n\nexport function useGroupedControlContext() {\n return useContext(GroupedControlContext);\n}\n\n/**\n * Resets the grouped-control context back to \"not in a group\" for a subtree.\n *\n * Controls that render caller-supplied content (for example, custom dropdown\n * content) should wrap that content with this provider. Otherwise a nested\n * control rendered inside such a slot would inherit the surrounding group's\n * `position` and incorrectly pick up the grouped-control styling\n * where adjacent borders lose their border radii.\n */\nexport function ResetGroupedControlContext({ children }: { children: React.ReactNode }) {\n const { direction } = useGroupedControlContext();\n return (\n <GroupedControlContext.Provider value={{ position: null, direction }}>{children}</GroupedControlContext.Provider>\n );\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (3bc1f014)";
3
- export var GIT_SHA = "3bc1f014";
2
+ export var PACKAGE_VERSION = "3.0.0 (ea381b71)";
3
+ export var GIT_SHA = "ea381b71";
4
4
  export var THEME = "open-source-visual-refresh";
5
5
  export var SYSTEM = "core";
6
6
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (3bc1f014)",
4
- "GIT_SHA": "3bc1f014",
3
+ "PACKAGE_VERSION": "3.0.0 (ea381b71)",
4
+ "GIT_SHA": "ea381b71",
5
5
  "THEME": "default",
6
6
  "SYSTEM": "core",
7
7
  "ALWAYS_VISUAL_REFRESH": false,
@@ -1,4 +1,4 @@
1
1
  import { ModalProps } from './interfaces';
2
2
  export { ModalProps };
3
- export default function Modal({ size, position, width, height, ...props }: ModalProps): JSX.Element;
3
+ export default function Modal({ size, position, hideDismissButton, width, height, ...props }: ModalProps): JSX.Element;
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modal/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAkDtB,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,IAAe,EAAE,QAAmB,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,eA+C1G"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modal/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAoDtB,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,IAAe,EACf,QAAmB,EACnB,iBAAyB,EACzB,KAAK,EACL,MAAM,EACN,GAAG,KAAK,EACT,EAAE,UAAU,eAkDZ"}
@@ -11,7 +11,7 @@ import useBaseComponent from '../internal/hooks/use-base-component';
11
11
  import { applyDisplayName } from '../internal/utils/apply-display-name';
12
12
  import InternalModal, { InternalModalAsFunnel } from './internal';
13
13
  import styles from './styles.css.js';
14
- function ModalWithAnalyticsFunnel({ analyticsMetadata, baseComponentProps, size = 'medium', ...props }) {
14
+ function ModalWithAnalyticsFunnel({ analyticsMetadata, baseComponentProps, size = 'medium', hideDismissButton, ...props }) {
15
15
  const modalId = useUniqueId();
16
16
  const dataAttributes = {
17
17
  [DATA_ATTR_MODAL_ID]: modalId,
@@ -24,15 +24,16 @@ function ModalWithAnalyticsFunnel({ analyticsMetadata, baseComponentProps, size
24
24
  } },
25
25
  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 },
26
26
  React.createElement(AnalyticsFunnelSubStep, { subStepIdentifier: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.instanceIdentifier, subStepErrorContext: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.errorContext },
27
- React.createElement(InternalModalAsFunnel, { size: size, ...props, ...baseComponentProps, ...dataAttributes, __injectAnalyticsComponentMetadata: true })))));
27
+ React.createElement(InternalModalAsFunnel, { size: size, hideDismissButton: hideDismissButton, ...props, ...baseComponentProps, ...dataAttributes, __injectAnalyticsComponentMetadata: true })))));
28
28
  }
29
- export default function Modal({ size = 'medium', position = 'center', width, height, ...props }) {
29
+ export default function Modal({ size = 'medium', position = 'center', hideDismissButton = false, width, height, ...props }) {
30
30
  const { isInFunnel } = useFunnel();
31
31
  const analyticsMetadata = getAnalyticsMetadataProps(props);
32
32
  const baseComponentProps = useBaseComponent('Modal', {
33
33
  props: {
34
34
  size,
35
35
  position,
36
+ hideDismissButton,
36
37
  disableContentPaddings: props.disableContentPaddings,
37
38
  flowType: analyticsMetadata.flowType,
38
39
  width,
@@ -44,9 +45,9 @@ export default function Modal({ size = 'medium', position = 'center', width, hei
44
45
  },
45
46
  }, analyticsMetadata);
46
47
  if (!isInFunnel) {
47
- return (React.createElement(ModalWithAnalyticsFunnel, { analyticsMetadata: analyticsMetadata, baseComponentProps: baseComponentProps, size: size, position: position, width: width, height: height, ...props }));
48
+ return (React.createElement(ModalWithAnalyticsFunnel, { analyticsMetadata: analyticsMetadata, baseComponentProps: baseComponentProps, size: size, position: position, hideDismissButton: hideDismissButton, width: width, height: height, ...props }));
48
49
  }
49
- return (React.createElement(InternalModal, { size: size, position: position, width: width, height: height, ...props, ...baseComponentProps, __injectAnalyticsComponentMetadata: true }));
50
+ return (React.createElement(InternalModal, { size: size, position: position, hideDismissButton: hideDismissButton, width: width, height: height, ...props, ...baseComponentProps, __injectAnalyticsComponentMetadata: true }));
50
51
  }
51
52
  applyDisplayName(Modal, 'Modal');
52
53
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modal/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,YAAY,CAAC;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE5E,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAkC,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvG,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,aAAa,EAAE,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAElE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC,SAAS,wBAAwB,CAAC,EAChC,iBAAiB,EACjB,kBAAkB,EAClB,IAAI,GAAG,QAAQ,EACf,G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AAI,GACxC,CACH,CAAC;AACJ,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\n'use client';\nimport React from 'react';\n\nimport { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport {\n AnalyticsFunnel,\n AnalyticsFunnelStep,\n AnalyticsFunnelSubStep,\n} from '../internal/analytics/components/analytics-funnel';\nimport { useFunnel } from '../internal/analytics/hooks/use-funnel';\nimport { DATA_ATTR_MODAL_ID } from '../internal/analytics/selectors';\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 const modalId = useUniqueId();\n const dataAttributes = {\n [DATA_ATTR_MODAL_ID]: modalId,\n };\n\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={() => [\n `[${DATA_ATTR_MODAL_ID}=\"${window?.CSS?.escape(modalId)}\"] .${styles['header--text']}`,\n ]}\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 {...dataAttributes}\n __injectAnalyticsComponentMetadata={true}\n />\n </AnalyticsFunnelSubStep>\n </AnalyticsFunnelStep>\n </AnalyticsFunnel>\n );\n}\n\nexport default function Modal({ size = 'medium', position = 'center', width, height, ...props }: ModalProps) {\n const { isInFunnel } = useFunnel();\n const analyticsMetadata = getAnalyticsMetadataProps(props as BasePropsWithAnalyticsMetadata);\n const baseComponentProps = useBaseComponent(\n 'Modal',\n {\n props: {\n size,\n position,\n disableContentPaddings: props.disableContentPaddings,\n flowType: analyticsMetadata.flowType,\n width,\n height,\n },\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 position={position}\n width={width}\n height={height}\n {...props}\n />\n );\n }\n\n return (\n <InternalModal\n size={size}\n position={position}\n width={width}\n height={height}\n {...props}\n {...baseComponentProps}\n __injectAnalyticsComponentMetadata={true}\n />\n );\n}\n\napplyDisplayName(Modal, 'Modal');\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modal/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,YAAY,CAAC;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE5E,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,i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,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,CACL,oBAAC,wBAAwB,IACvB,iBAAiB,EAAE,iBAAiB,EACpC,kBAAkB,EAAE,kBAAkB,EACtC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,iBAAiB,EACpC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,KACV,KAAK,GACT,CACH,CAAC;IACJ,CAAC;IAED,OAAO,CACL,oBAAC,aAAa,IACZ,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,iBAAiB,EACpC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,KACV,KAAK,KACL,kBAAkB,EACtB,kCAAkC,EAAE,IAAI,GACxC,CACH,CAAC;AACJ,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\n'use client';\nimport React from 'react';\n\nimport { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport {\n AnalyticsFunnel,\n AnalyticsFunnelStep,\n AnalyticsFunnelSubStep,\n} from '../internal/analytics/components/analytics-funnel';\nimport { useFunnel } from '../internal/analytics/hooks/use-funnel';\nimport { DATA_ATTR_MODAL_ID } from '../internal/analytics/selectors';\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 hideDismissButton,\n ...props\n}: ModalProps & { analyticsMetadata: any; baseComponentProps: ReturnType<typeof useBaseComponent> }) {\n const modalId = useUniqueId();\n const dataAttributes = {\n [DATA_ATTR_MODAL_ID]: modalId,\n };\n\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={() => [\n `[${DATA_ATTR_MODAL_ID}=\"${window?.CSS?.escape(modalId)}\"] .${styles['header--text']}`,\n ]}\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 hideDismissButton={hideDismissButton}\n {...props}\n {...baseComponentProps}\n {...dataAttributes}\n __injectAnalyticsComponentMetadata={true}\n />\n </AnalyticsFunnelSubStep>\n </AnalyticsFunnelStep>\n </AnalyticsFunnel>\n );\n}\n\nexport default function Modal({\n size = 'medium',\n position = 'center',\n hideDismissButton = false,\n width,\n height,\n ...props\n}: ModalProps) {\n const { isInFunnel } = useFunnel();\n const analyticsMetadata = getAnalyticsMetadataProps(props as BasePropsWithAnalyticsMetadata);\n const baseComponentProps = useBaseComponent(\n 'Modal',\n {\n props: {\n size,\n position,\n hideDismissButton,\n disableContentPaddings: props.disableContentPaddings,\n flowType: analyticsMetadata.flowType,\n width,\n height,\n },\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 position={position}\n hideDismissButton={hideDismissButton}\n width={width}\n height={height}\n {...props}\n />\n );\n }\n\n return (\n <InternalModal\n size={size}\n position={position}\n hideDismissButton={hideDismissButton}\n width={width}\n height={height}\n {...props}\n {...baseComponentProps}\n __injectAnalyticsComponentMetadata={true}\n />\n );\n}\n\napplyDisplayName(Modal, 'Modal');\n"]}
@@ -47,6 +47,13 @@ export interface ModalProps extends BaseComponentProps, BaseModalProps {
47
47
  * vertical repositioning that can cause users to lose context.
48
48
  */
49
49
  position?: ModalProps.Position;
50
+ /**
51
+ * Determines whether the close button is displayed in the header.
52
+ * When set to `true`, the close button isn't rendered, and the user resolves
53
+ * the modal by choosing one of the actions in the footer.
54
+ * ESC and clicks outside the modal still call `onDismiss`.
55
+ */
56
+ hideDismissButton?: boolean;
50
57
  /**
51
58
  * Determines whether the modal is displayed on the screen. Modals are hidden by default.
52
59
  * Set this property to `true` to show them.
@@ -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,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;IAE3C;;;;OAIG;IACH,eAAe,CAAC,EAAE,WAAW,CAAC,iBAAiB,CAAC,CAAC;CAClD;AAED,MAAM,WAAW,UAAW,SAAQ,kBAAkB,EAAE,cAAc;IACpE;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,MAAM,CAAC,EAAE,M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;IAC1B,KAAY,IAAI,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,KAAK,CAAC;IACjF,KAAY,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAC;IAExC,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"}
@@ -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 { PortalProps } from '@cloudscape-design/component-toolkit/internal';\n\nimport { FlowType } from '../types/analytics';\nimport { BaseComponentProps } from '../types/base-component';\nimport { NonCancelableEventHandler } from '../types/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?: PortalProps['getContainer'];\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?: PortalProps['removeContainer'];\n}\n\nexport interface ModalProps extends BaseComponentProps, BaseModalProps {\n /**\n * Specifies the width of the modal. When provided, takes precedence over the `size` property.\n * If the specified width exceeds available viewport space, the modal will use the maximum available space.\n * The minimum width is 320px (equivalent to the `small` size).\n */\n width?: number;\n\n /**\n * Specifies the height of the modal. When provided, the modal content becomes scrollable if it exceeds the specified height.\n * If the specified height exceeds available viewport space, the modal will use the maximum available space.\n * To make sure the content is accessible, the component will apply a minimum height of 60px for the content area,\n * plus the header height and the footer height.\n */\n height?: number;\n\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 have fixed widths:\n * `small` (320px), `medium` (600px), `large` (820px), `x-large` (1024px), `xx-large` (1280px).\n */\n size?: ModalProps.Size;\n /**\n * Controls the vertical positioning of the modal.\n *\n * - `center` (default) - The modal is vertically centered in the viewport and re-centers\n * when content height changes. Use for dialogs with static, predictable content.\n *\n * - `top` - The modal anchors at fixed distance and grows downward\n * as content expands. Use when the content changes dynamically to prevent disruptive\n * vertical repositioning that can cause users to lose context.\n */\n position?: ModalProps.Position;\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' | 'x-large' | 'xx-large' | 'max';\n export type Position = 'center' | 'top';\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"]}
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 { PortalProps } from '@cloudscape-design/component-toolkit/internal';\n\nimport { FlowType } from '../types/analytics';\nimport { BaseComponentProps } from '../types/base-component';\nimport { NonCancelableEventHandler } from '../types/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?: PortalProps['getContainer'];\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?: PortalProps['removeContainer'];\n}\n\nexport interface ModalProps extends BaseComponentProps, BaseModalProps {\n /**\n * Specifies the width of the modal. When provided, takes precedence over the `size` property.\n * If the specified width exceeds available viewport space, the modal will use the maximum available space.\n * The minimum width is 320px (equivalent to the `small` size).\n */\n width?: number;\n\n /**\n * Specifies the height of the modal. When provided, the modal content becomes scrollable if it exceeds the specified height.\n * If the specified height exceeds available viewport space, the modal will use the maximum available space.\n * To make sure the content is accessible, the component will apply a minimum height of 60px for the content area,\n * plus the header height and the footer height.\n */\n height?: number;\n\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 have fixed widths:\n * `small` (320px), `medium` (600px), `large` (820px), `x-large` (1024px), `xx-large` (1280px).\n */\n size?: ModalProps.Size;\n /**\n * Controls the vertical positioning of the modal.\n *\n * - `center` (default) - The modal is vertically centered in the viewport and re-centers\n * when content height changes. Use for dialogs with static, predictable content.\n *\n * - `top` - The modal anchors at fixed distance and grows downward\n * as content expands. Use when the content changes dynamically to prevent disruptive\n * vertical repositioning that can cause users to lose context.\n */\n position?: ModalProps.Position;\n /**\n * Determines whether the close button is displayed in the header.\n * When set to `true`, the close button isn't rendered, and the user resolves\n * the modal by choosing one of the actions in the footer.\n * ESC and clicks outside the modal still call `onDismiss`.\n */\n hideDismissButton?: boolean;\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' | 'x-large' | 'xx-large' | 'max';\n export type Position = 'center' | 'top';\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"]}
@@ -44,7 +44,7 @@ export default function InternalModal({ modalRoot, getModalRoot, removeModalRoot
44
44
  }
45
45
  // Separate component to prevent the Portal from getting in the way of refs, as it needs extra cycles to render the inner components.
46
46
  // useContainerQuery needs its targeted element to exist on the first render in order to work properly.
47
- function PortaledModal({ size, visible, header, children, footer, disableContentPaddings, position = 'center', onButtonClick = () => { }, onDismiss, width, height, __internalRootRef, __injectAnalyticsComponentMetadata, __funnelProps, __funnelStepProps, __subStepRef, __subStepFunnelProps, referrerId, ...rest }) {
47
+ function PortaledModal({ size, hideDismissButton = false, visible, header, children, footer, disableContentPaddings, position = 'center', onButtonClick = () => { }, onDismiss, width, height, __internalRootRef, __injectAnalyticsComponentMetadata, __funnelProps, __funnelStepProps, __subStepRef, __subStepFunnelProps, referrerId, ...rest }) {
48
48
  var _a;
49
49
  const instanceUniqueId = useUniqueId();
50
50
  const headerId = `${rest.id || instanceUniqueId}-header`;
@@ -54,6 +54,7 @@ function PortaledModal({ size, visible, header, children, footer, disableContent
54
54
  const closeAriaLabel = i18n('closeAriaLabel', rest.closeAriaLabel);
55
55
  const refObject = useRef(null);
56
56
  const mergedRef = useMergeRefs(breakpointsRef, refObject, __internalRootRef);
57
+ const dialogRef = useRef(null);
57
58
  const isRefresh = useVisualRefresh();
58
59
  const baseProps = getBaseProps(rest);
59
60
  const analyticsComponentMetadata = {
@@ -122,6 +123,13 @@ function PortaledModal({ size, visible, header, children, footer, disableContent
122
123
  const dismiss = (reason) => fireNonCancelableEvent(onDismiss, { reason });
123
124
  const onOverlayMouseDown = (event) => {
124
125
  lastMouseDownElementRef.current = event.target;
126
+ // The overlay can't hold focus, so pressing it would blur whatever is focused inside the
127
+ // dialog and leave focus on the document body. That takes focus out of the dialog, which
128
+ // breaks focus containment and stops ESC from reaching the handler on the dialog element.
129
+ // Preventing the default action keeps focus where it is.
130
+ if (event.target === refObject.current) {
131
+ event.preventDefault();
132
+ }
125
133
  };
126
134
  const onOverlayClick = (event) => {
127
135
  const overlay = refObject.current;
@@ -140,7 +148,13 @@ function PortaledModal({ size, visible, header, children, footer, disableContent
140
148
  // to detect when the user has scrolled to the bottom.
141
149
  const { ref: stickySentinelRef, isIntersecting: footerStuck } = useIntersectionObserver();
142
150
  const headerTextRef = useRef(null);
151
+ const headingTagRef = useRef(null);
143
152
  const { subStepRef } = useFunnelSubStep();
153
+ // Without a dismiss button there is no predictable first focusable element, so focus the
154
+ // heading to announce what the modal is about. When no header is given, fall back to the
155
+ // dialog.
156
+ const hasHeader = header !== undefined && header !== null && header !== false && header !== '';
157
+ const autoFocusTarget = hideDismissButton ? (hasHeader ? headingTagRef : dialogRef) : undefined;
144
158
  const { footerRef, headerRef, hasCustomHeight, hasCustomWidth, dialogCustomStyles, footerHeight } = useModalDimensions({
145
159
  height,
146
160
  width,
@@ -153,15 +167,18 @@ function PortaledModal({ size, visible, header, children, footer, disableContent
153
167
  componentLoadingCount,
154
168
  emitTimeToContentReadyInModal,
155
169
  } },
156
- React.createElement("div", { ...baseProps, ...__funnelProps, ...__funnelStepProps, className: clsx(styles.root, { [styles.hidden]: !visible }, baseProps.className, isRefresh && styles.refresh), role: "dialog", "aria-labelledby": headerId, onMouseDown: onOverlayMouseDown, onClick: onOverlayClick, ref: mergedRef, style: footerHeight ? { scrollPaddingBottom: footerHeight } : undefined, "data-awsui-referrer-id": ((_a = subStepRef.current) === null || _a === void 0 ? void 0 : _a.id) || referrerId },
157
- React.createElement(FocusLock, { disabled: !visible, autoFocus: true, restoreFocus: true, className: clsx(styles['focus-lock'], styles[`position-${position}`]) },
158
- React.createElement("div", { className: clsx(styles.dialog, !hasCustomWidth && styles[size], styles[`breakpoint-${breakpoint}`], isRefresh && styles.refresh, hasCustomWidth && styles['custom-width'], hasCustomHeight && styles['custom-height']), style: dialogCustomStyles, onKeyDown: escKeyHandler, ...metadataAttribute },
170
+ React.createElement("div", { ...baseProps, ...__funnelProps, ...__funnelStepProps, className: clsx(styles.root, { [styles.hidden]: !visible }, hideDismissButton && styles['hide-dismiss-button'], baseProps.className, isRefresh && styles.refresh), role: "dialog", "aria-labelledby": headerId, onMouseDown: onOverlayMouseDown, onClick: onOverlayClick, ref: mergedRef, style: footerHeight ? { scrollPaddingBottom: footerHeight } : undefined, "data-awsui-referrer-id": ((_a = subStepRef.current) === null || _a === void 0 ? void 0 : _a.id) || referrerId },
171
+ React.createElement(FocusLock, { disabled: !visible, autoFocus: true, restoreFocus: true, autoFocusTarget: autoFocusTarget, className: clsx(styles['focus-lock'], styles[`position-${position}`]) },
172
+ React.createElement("div", { className: clsx(styles.dialog, !hasCustomWidth && styles[size], styles[`breakpoint-${breakpoint}`], isRefresh && styles.refresh, hasCustomWidth && styles['custom-width'], hasCustomHeight && styles['custom-height']), ref: dialogRef, style: dialogCustomStyles, onKeyDown: escKeyHandler,
173
+ // Keeps the dialog focusable so that clicking a non-focusable area inside it moves
174
+ // focus to the dialog rather than the document body.
175
+ tabIndex: -1, ...metadataAttribute },
159
176
  React.createElement("div", { className: clsx(styles.container, hasCustomHeight && styles['custom-height-container']) },
160
177
  React.createElement("div", { ref: headerRef, className: clsx(styles.header, analyticsSelectors.header) },
161
- React.createElement(InternalHeader, { variant: "h2", __disableActionsWrapping: true, actions: React.createElement("div", { ...getAnalyticsMetadataAttribute({
178
+ React.createElement(InternalHeader, { variant: "h2", __disableActionsWrapping: true, __headingTagRef: headingTagRef, __headingTagTabIndex: -1, actions: hideDismissButton ? undefined : (React.createElement("div", { ...getAnalyticsMetadataAttribute({
162
179
  action: 'dismiss',
163
180
  }) },
164
- React.createElement(InternalButton, { ariaLabel: closeAriaLabel, className: styles['dismiss-control'], variant: "modal-dismiss", iconName: "close", formAction: "none", onClick: onCloseButtonClick })) },
181
+ React.createElement(InternalButton, { ariaLabel: closeAriaLabel, className: styles['dismiss-control'], variant: "modal-dismiss", iconName: "close", formAction: "none", onClick: onCloseButtonClick }))) },
165
182
  React.createElement("span", { ref: headerTextRef, id: headerId, className: styles['header--text'] }, header))),
166
183
  React.createElement(BuiltInErrorBoundary, { wrapper: content => React.createElement(InternalBox, { padding: { bottom: 'm', horizontal: 'l' } }, content) },
167
184
  React.createElement("div", { ref: __subStepRef, ...__subStepFunnelProps, className: clsx(styles.content, { [styles['no-paddings']]: disableContentPaddings }, hasCustomHeight && styles['custom-height-content']), ...(hasCustomHeight && {
@@ -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,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAClG,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,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,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,oBA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AAQ,EAAE,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC,IACtE,MAAM,CACF,CACQ,CACb;gCACN,oBAAC,oBAAoB,IACnB,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,oBAAC,WAAW,IAAC,OAAO,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,IAAG,OAAO,CAAe;oCAEnG,6BACE,GAAG,EAAE,YAAY,KACb,oBAAoB,EACxB,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,OAAO,EACd,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,sBAAsB,EAAE,EACnD,eAAe,IAAI,MAAM,CAAC,uBAAuB,CAAC,CACnD,KACG,CAAC,eAAe,IAAI;4CACtB,QAAQ,EAAE,CAAC;4CACX,IAAI,EAAE,QAAQ;4CACd,iBAAiB,EAAE,QAAQ;yCAC5B,CAAC;wCAED,QAAQ;wCACT,6BAAK,GAAG,EAAE,iBAAiB,GAAI,CAC3B;oCACL,MAAM,IAAI,CACT,oBAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE;wCACvD,6BACE,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,WAAW,IAAI,eAAe,CAAC,IAAI,MAAM,CAAC,iBAAiB,CAAC,CAAC,IAE5F,MAAM,CACH,CACiB,CAC1B,CACoB,CACnB,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 { Portal, useMergeRefs, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport InternalBox from '../box/internal';\nimport { InternalButton } from '../button/internal';\nimport { BuiltInErrorBoundary } from '../error-boundary/internal';\nimport InternalHeader from '../header/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { PerformanceMetrics } from '../internal/analytics';\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 { 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 { 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';\nimport { useModalDimensions } from './use-modal-dimensions';\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 width?: number;\n height?: number;\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 position = 'center',\n onButtonClick = () => {},\n onDismiss,\n width,\n height,\n __internalRootRef,\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 const metadataAttribute = __injectAnalyticsComponentMetadata\n ? getAnalyticsMetadataAttribute({ component: analyticsComponentMetadata })\n : {};\n const loadStartTime = useRef<number>(0);\n const loadCompleteTime = useRef<number>(0);\n const componentLoadingCount = useRef<number>(0);\n const performanceMetricLogged = useRef<boolean>(false);\n\n // enable body scroll and restore focus if unmounting while visible\n useEffect(() => {\n return () => {\n enableBodyScrolling();\n };\n }, []);\n\n const resetModalPerformanceData = () => {\n loadStartTime.current = performance.now();\n loadCompleteTime.current = 0;\n performanceMetricLogged.current = false;\n };\n\n const emitTimeToContentReadyInModal = (loadCompleteTime: number) => {\n if (\n componentLoadingCount.current === 0 &&\n loadStartTime.current &&\n loadStartTime.current !== 0 &&\n !performanceMetricLogged.current\n ) {\n const timeToContentReadyInModal = loadCompleteTime - loadStartTime.current;\n PerformanceMetrics.modalPerformanceData({\n timeToContentReadyInModal,\n instanceIdentifier: instanceUniqueId,\n componentIdentifier: headerTextRef.current?.textContent || '',\n });\n performanceMetricLogged.current = true;\n }\n };\n\n const MODAL_READY_TIMEOUT = 100;\n /**\n * This useEffect is triggered when the visible attribute of modal changes.\n * When modal becomes visible, modal performance metrics are reset marking the beginning loading process.\n * To ensure that the modal component ready metric is always emitted, a setTimeout is implemented.\n * This setTimeout automatically emits the component ready metric after a specified duration.\n */\n useEffect(() => {\n if (visible) {\n disableBodyScrolling();\n resetModalPerformanceData();\n setTimeout(() => {\n emitTimeToContentReadyInModal(loadStartTime.current);\n }, MODAL_READY_TIMEOUT);\n } else {\n enableBodyScrolling();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\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 const headerTextRef = useRef<HTMLSpanElement>(null);\n const { subStepRef } = useFunnelSubStep();\n\n const { footerRef, headerRef, hasCustomHeight, hasCustomWidth, dialogCustomStyles, footerHeight } =\n useModalDimensions({\n height,\n width,\n hasFooter: !!footer,\n });\n\n return (\n <FunnelNameSelectorContext.Provider value={`.${styles['header--text']}`}>\n <ResetContextsForModal>\n <ModalContext.Provider\n value={{\n isInModal: true,\n componentLoadingCount,\n emitTimeToContentReadyInModal,\n }}\n >\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-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\n disabled={!visible}\n autoFocus={true}\n restoreFocus={true}\n className={clsx(styles['focus-lock'], styles[`position-${position}`])}\n >\n <div\n className={clsx(\n styles.dialog,\n !hasCustomWidth && styles[size],\n styles[`breakpoint-${breakpoint}`],\n isRefresh && styles.refresh,\n hasCustomWidth && styles['custom-width'],\n hasCustomHeight && styles['custom-height']\n )}\n style={dialogCustomStyles}\n onKeyDown={escKeyHandler}\n {...metadataAttribute}\n >\n <div className={clsx(styles.container, hasCustomHeight && styles['custom-height-container'])}>\n <div ref={headerRef} 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 ref={headerTextRef} id={headerId} className={styles['header--text']}>\n {header}\n </span>\n </InternalHeader>\n </div>\n <BuiltInErrorBoundary\n wrapper={content => <InternalBox padding={{ bottom: 'm', horizontal: 'l' }}>{content}</InternalBox>}\n >\n <div\n ref={__subStepRef}\n {...__subStepFunnelProps}\n className={clsx(\n styles.content,\n { [styles['no-paddings']]: disableContentPaddings },\n hasCustomHeight && styles['custom-height-content']\n )}\n {...(hasCustomHeight && {\n tabIndex: 0,\n role: 'region',\n 'aria-labelledby': headerId,\n })}\n >\n {children}\n <div ref={stickySentinelRef} />\n </div>\n {footer && (\n <ButtonContext.Provider value={{ onClick: onButtonClick }}>\n <div\n ref={footerRef}\n className={clsx(styles.footer, (footerStuck || hasCustomHeight) && styles['footer--rounded'])}\n >\n {footer}\n </div>\n </ButtonContext.Provider>\n )}\n </BuiltInErrorBoundary>\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;AA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,EAAE,SAAS,EACd,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,WAAW,IAAI,eAAe,CAAC,IAAI,MAAM,CAAC,iBAAiB,CAAC,CAAC,IAE5F,MAAM,CACH,CACiB,CAC1B,CACoB,CACnB,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 { Portal, useMergeRefs, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport InternalBox from '../box/internal';\nimport { InternalButton } from '../button/internal';\nimport { BuiltInErrorBoundary } from '../error-boundary/internal';\nimport InternalHeader from '../header/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { PerformanceMetrics } from '../internal/analytics';\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 { 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 { 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';\nimport { useModalDimensions } from './use-modal-dimensions';\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 width?: number;\n height?: number;\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 hideDismissButton = false,\n visible,\n header,\n children,\n footer,\n disableContentPaddings,\n position = 'center',\n onButtonClick = () => {},\n onDismiss,\n width,\n height,\n __internalRootRef,\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 const dialogRef = useRef<HTMLDivElement>(null);\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 const metadataAttribute = __injectAnalyticsComponentMetadata\n ? getAnalyticsMetadataAttribute({ component: analyticsComponentMetadata })\n : {};\n const loadStartTime = useRef<number>(0);\n const loadCompleteTime = useRef<number>(0);\n const componentLoadingCount = useRef<number>(0);\n const performanceMetricLogged = useRef<boolean>(false);\n\n // enable body scroll and restore focus if unmounting while visible\n useEffect(() => {\n return () => {\n enableBodyScrolling();\n };\n }, []);\n\n const resetModalPerformanceData = () => {\n loadStartTime.current = performance.now();\n loadCompleteTime.current = 0;\n performanceMetricLogged.current = false;\n };\n\n const emitTimeToContentReadyInModal = (loadCompleteTime: number) => {\n if (\n componentLoadingCount.current === 0 &&\n loadStartTime.current &&\n loadStartTime.current !== 0 &&\n !performanceMetricLogged.current\n ) {\n const timeToContentReadyInModal = loadCompleteTime - loadStartTime.current;\n PerformanceMetrics.modalPerformanceData({\n timeToContentReadyInModal,\n instanceIdentifier: instanceUniqueId,\n componentIdentifier: headerTextRef.current?.textContent || '',\n });\n performanceMetricLogged.current = true;\n }\n };\n\n const MODAL_READY_TIMEOUT = 100;\n /**\n * This useEffect is triggered when the visible attribute of modal changes.\n * When modal becomes visible, modal performance metrics are reset marking the beginning loading process.\n * To ensure that the modal component ready metric is always emitted, a setTimeout is implemented.\n * This setTimeout automatically emits the component ready metric after a specified duration.\n */\n useEffect(() => {\n if (visible) {\n disableBodyScrolling();\n resetModalPerformanceData();\n setTimeout(() => {\n emitTimeToContentReadyInModal(loadStartTime.current);\n }, MODAL_READY_TIMEOUT);\n } else {\n enableBodyScrolling();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\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 // The overlay can't hold focus, so pressing it would blur whatever is focused inside the\n // dialog and leave focus on the document body. That takes focus out of the dialog, which\n // breaks focus containment and stops ESC from reaching the handler on the dialog element.\n // Preventing the default action keeps focus where it is.\n if (event.target === refObject.current) {\n event.preventDefault();\n }\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 const headerTextRef = useRef<HTMLSpanElement>(null);\n const headingTagRef = useRef<HTMLHeadingElement | null>(null);\n const { subStepRef } = useFunnelSubStep();\n\n // Without a dismiss button there is no predictable first focusable element, so focus the\n // heading to announce what the modal is about. When no header is given, fall back to the\n // dialog.\n const hasHeader = header !== undefined && header !== null && header !== false && header !== '';\n const autoFocusTarget = hideDismissButton ? (hasHeader ? headingTagRef : dialogRef) : undefined;\n\n const { footerRef, headerRef, hasCustomHeight, hasCustomWidth, dialogCustomStyles, footerHeight } =\n useModalDimensions({\n height,\n width,\n hasFooter: !!footer,\n });\n\n return (\n <FunnelNameSelectorContext.Provider value={`.${styles['header--text']}`}>\n <ResetContextsForModal>\n <ModalContext.Provider\n value={{\n isInModal: true,\n componentLoadingCount,\n emitTimeToContentReadyInModal,\n }}\n >\n <div\n {...baseProps}\n {...__funnelProps}\n {...__funnelStepProps}\n className={clsx(\n styles.root,\n { [styles.hidden]: !visible },\n hideDismissButton && styles['hide-dismiss-button'],\n baseProps.className,\n isRefresh && styles.refresh\n )}\n role=\"dialog\"\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\n disabled={!visible}\n autoFocus={true}\n restoreFocus={true}\n autoFocusTarget={autoFocusTarget}\n className={clsx(styles['focus-lock'], styles[`position-${position}`])}\n >\n <div\n className={clsx(\n styles.dialog,\n !hasCustomWidth && styles[size],\n styles[`breakpoint-${breakpoint}`],\n isRefresh && styles.refresh,\n hasCustomWidth && styles['custom-width'],\n hasCustomHeight && styles['custom-height']\n )}\n ref={dialogRef}\n style={dialogCustomStyles}\n onKeyDown={escKeyHandler}\n // Keeps the dialog focusable so that clicking a non-focusable area inside it moves\n // focus to the dialog rather than the document body.\n tabIndex={-1}\n {...metadataAttribute}\n >\n <div className={clsx(styles.container, hasCustomHeight && styles['custom-height-container'])}>\n <div ref={headerRef} className={clsx(styles.header, analyticsSelectors.header)}>\n <InternalHeader\n variant=\"h2\"\n __disableActionsWrapping={true}\n __headingTagRef={headingTagRef}\n __headingTagTabIndex={-1}\n actions={\n hideDismissButton ? undefined : (\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 >\n <span ref={headerTextRef} id={headerId} className={styles['header--text']}>\n {header}\n </span>\n </InternalHeader>\n </div>\n <BuiltInErrorBoundary\n wrapper={content => <InternalBox padding={{ bottom: 'm', horizontal: 'l' }}>{content}</InternalBox>}\n >\n <div\n ref={__subStepRef}\n {...__subStepFunnelProps}\n className={clsx(\n styles.content,\n { [styles['no-paddings']]: disableContentPaddings },\n hasCustomHeight && styles['custom-height-content']\n )}\n {...(hasCustomHeight && {\n tabIndex: 0,\n role: 'region',\n 'aria-labelledby': headerId,\n })}\n >\n {children}\n <div ref={stickySentinelRef} />\n </div>\n {footer && (\n <ButtonContext.Provider value={{ onClick: onButtonClick }}>\n <div\n ref={footerRef}\n className={clsx(styles.footer, (footerStuck || hasCustomHeight) && styles['footer--rounded'])}\n >\n {footer}\n </div>\n </ButtonContext.Provider>\n )}\n </BuiltInErrorBoundary>\n </div>\n </div>\n </FocusLock>\n </div>\n </ModalContext.Provider>\n </ResetContextsForModal>\n </FunnelNameSelectorContext.Provider>\n );\n}\n"]}
@@ -1,36 +1,37 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "dialog": "awsui_dialog_1d2i7_10ig3_25",
5
- "modal-slide-up": "awsui_modal-slide-up_1d2i7_10ig3_1",
6
- "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_1d2i7_10ig3_1",
7
- "refresh": "awsui_refresh_1d2i7_10ig3_48",
8
- "awsui-motion-scale-popup": "awsui_awsui-motion-scale-popup_1d2i7_10ig3_1",
9
- "root": "awsui_root_1d2i7_10ig3_81",
10
- "awsui-motion-fade-in": "awsui_awsui-motion-fade-in_1d2i7_10ig3_1",
11
- "hidden": "awsui_hidden_1d2i7_10ig3_158",
12
- "focus-lock": "awsui_focus-lock_1d2i7_10ig3_162",
13
- "position-top": "awsui_position-top_1d2i7_10ig3_170",
14
- "position-center": "awsui_position-center_1d2i7_10ig3_173",
15
- "small": "awsui_small_1d2i7_10ig3_187",
16
- "medium": "awsui_medium_1d2i7_10ig3_190",
17
- "large": "awsui_large_1d2i7_10ig3_193",
18
- "x-large": "awsui_x-large_1d2i7_10ig3_196",
19
- "xx-large": "awsui_xx-large_1d2i7_10ig3_199",
20
- "custom-width": "awsui_custom-width_1d2i7_10ig3_202",
21
- "max": "awsui_max_1d2i7_10ig3_205",
22
- "breakpoint-xs": "awsui_breakpoint-xs_1d2i7_10ig3_205",
23
- "custom-height": "awsui_custom-height_1d2i7_10ig3_210",
24
- "container": "awsui_container_1d2i7_10ig3_215",
25
- "custom-height-container": "awsui_custom-height-container_1d2i7_10ig3_255",
26
- "content": "awsui_content_1d2i7_10ig3_261",
27
- "no-paddings": "awsui_no-paddings_1d2i7_10ig3_266",
28
- "custom-height-content": "awsui_custom-height-content_1d2i7_10ig3_270",
29
- "header": "awsui_header_1d2i7_10ig3_275",
30
- "header--text": "awsui_header--text_1d2i7_10ig3_287",
31
- "footer": "awsui_footer_1d2i7_10ig3_291",
32
- "footer--rounded": "awsui_footer--rounded_1d2i7_10ig3_300",
33
- "dismiss-control": "awsui_dismiss-control_1d2i7_10ig3_312",
34
- "modal-open": "awsui_modal-open_1d2i7_10ig3_316"
4
+ "dialog": "awsui_dialog_1d2i7_1ls09_25",
5
+ "modal-slide-up": "awsui_modal-slide-up_1d2i7_1ls09_1",
6
+ "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_1d2i7_1ls09_1",
7
+ "refresh": "awsui_refresh_1d2i7_1ls09_48",
8
+ "awsui-motion-scale-popup": "awsui_awsui-motion-scale-popup_1d2i7_1ls09_1",
9
+ "root": "awsui_root_1d2i7_1ls09_81",
10
+ "awsui-motion-fade-in": "awsui_awsui-motion-fade-in_1d2i7_1ls09_1",
11
+ "hide-dismiss-button": "awsui_hide-dismiss-button_1d2i7_1ls09_158",
12
+ "hidden": "awsui_hidden_1d2i7_1ls09_161",
13
+ "focus-lock": "awsui_focus-lock_1d2i7_1ls09_165",
14
+ "position-top": "awsui_position-top_1d2i7_1ls09_173",
15
+ "position-center": "awsui_position-center_1d2i7_1ls09_176",
16
+ "small": "awsui_small_1d2i7_1ls09_190",
17
+ "medium": "awsui_medium_1d2i7_1ls09_193",
18
+ "large": "awsui_large_1d2i7_1ls09_196",
19
+ "x-large": "awsui_x-large_1d2i7_1ls09_199",
20
+ "xx-large": "awsui_xx-large_1d2i7_1ls09_202",
21
+ "custom-width": "awsui_custom-width_1d2i7_1ls09_205",
22
+ "max": "awsui_max_1d2i7_1ls09_208",
23
+ "breakpoint-xs": "awsui_breakpoint-xs_1d2i7_1ls09_208",
24
+ "custom-height": "awsui_custom-height_1d2i7_1ls09_213",
25
+ "container": "awsui_container_1d2i7_1ls09_218",
26
+ "custom-height-container": "awsui_custom-height-container_1d2i7_1ls09_258",
27
+ "content": "awsui_content_1d2i7_1ls09_264",
28
+ "no-paddings": "awsui_no-paddings_1d2i7_1ls09_269",
29
+ "custom-height-content": "awsui_custom-height-content_1d2i7_1ls09_273",
30
+ "header": "awsui_header_1d2i7_1ls09_278",
31
+ "header--text": "awsui_header--text_1d2i7_1ls09_290",
32
+ "footer": "awsui_footer_1d2i7_1ls09_294",
33
+ "footer--rounded": "awsui_footer--rounded_1d2i7_1ls09_303",
34
+ "dismiss-control": "awsui_dismiss-control_1d2i7_1ls09_315",
35
+ "modal-open": "awsui_modal-open_1d2i7_1ls09_319"
35
36
  };
36
37