@cloudscape-design/components 3.0.1298 → 3.0.1299
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/attribute-editor/styles.css.js +15 -15
- package/attribute-editor/styles.scoped.css +29 -28
- package/attribute-editor/styles.selectors.js +15 -15
- package/breadcrumb-group/item/styles.css.js +7 -7
- package/breadcrumb-group/item/styles.scoped.css +30 -29
- package/breadcrumb-group/item/styles.selectors.js +7 -7
- package/breadcrumb-group/styles.css.js +14 -14
- package/breadcrumb-group/styles.scoped.css +25 -25
- package/breadcrumb-group/styles.selectors.js +14 -14
- package/button-dropdown/category-elements/category-element.js +1 -1
- package/button-dropdown/category-elements/category-element.js.map +1 -1
- package/button-dropdown/category-elements/expandable-category-element.js +1 -1
- package/button-dropdown/category-elements/expandable-category-element.js.map +1 -1
- package/button-dropdown/category-elements/mobile-expandable-category-element.js +1 -1
- package/button-dropdown/category-elements/mobile-expandable-category-element.js.map +1 -1
- package/button-dropdown/item-element/index.js +1 -1
- package/button-dropdown/item-element/index.js.map +1 -1
- package/button-dropdown/item-element/styles.css.js +21 -21
- package/button-dropdown/item-element/styles.scoped.css +38 -37
- package/button-dropdown/item-element/styles.selectors.js +21 -21
- package/copy-to-clipboard/index.d.ts +1 -0
- package/copy-to-clipboard/index.d.ts.map +1 -1
- package/copy-to-clipboard/index.js +2 -2
- package/copy-to-clipboard/index.js.map +1 -1
- package/copy-to-clipboard/interfaces.d.ts +5 -0
- package/copy-to-clipboard/interfaces.d.ts.map +1 -1
- package/copy-to-clipboard/interfaces.js.map +1 -1
- package/copy-to-clipboard/internal.d.ts +1 -0
- package/copy-to-clipboard/internal.d.ts.map +1 -1
- package/copy-to-clipboard/internal.js +3 -3
- package/copy-to-clipboard/internal.js.map +1 -1
- package/copy-to-clipboard/styles.css.js +5 -3
- package/copy-to-clipboard/styles.scoped.css +18 -3
- package/copy-to-clipboard/styles.selectors.js +5 -3
- package/drawer/implementation.d.ts +3 -3
- package/drawer/implementation.d.ts.map +1 -1
- package/drawer/implementation.js +3 -2
- package/drawer/implementation.js.map +1 -1
- package/drawer/index.d.ts +2 -10
- package/drawer/index.d.ts.map +1 -1
- package/drawer/index.js +21 -9
- package/drawer/index.js.map +1 -1
- package/drawer/interfaces.d.ts +45 -18
- package/drawer/interfaces.d.ts.map +1 -1
- package/drawer/interfaces.js.map +1 -1
- package/drawer/styles.css.js +29 -25
- package/drawer/styles.scoped.css +43 -34
- package/drawer/styles.selectors.js +29 -25
- package/drawer/utils.d.ts +2 -2
- package/drawer/utils.d.ts.map +1 -1
- package/drawer/utils.js +6 -5
- package/drawer/utils.js.map +1 -1
- package/form-field/styles.css.js +24 -24
- package/form-field/styles.scoped.css +41 -41
- package/form-field/styles.selectors.js +24 -24
- package/help-panel/styles.css.js +6 -6
- package/help-panel/styles.scoped.css +73 -71
- package/help-panel/styles.selectors.js +6 -6
- package/internal/base-component/styles.scoped.css +25 -13
- package/internal/components/token-list/styles.css.js +10 -10
- package/internal/components/token-list/styles.scoped.css +24 -23
- package/internal/components/token-list/styles.selectors.js +10 -10
- package/internal/environment.js +2 -2
- package/internal/environment.json +2 -2
- package/internal/generated/styles/tokens.d.ts +24 -12
- package/internal/generated/styles/tokens.js +24 -12
- package/internal/generated/theming/index.cjs +164 -58
- package/internal/generated/theming/index.cjs.d.ts +225 -99
- package/internal/generated/theming/index.d.ts +225 -99
- package/internal/generated/theming/index.js +164 -58
- package/internal/manifest.json +1 -1
- package/key-value-pairs/styles.css.js +8 -8
- package/key-value-pairs/styles.scoped.css +12 -12
- package/key-value-pairs/styles.selectors.js +8 -8
- package/link/internal.js +1 -1
- package/link/internal.js.map +1 -1
- package/link/styles.css.js +21 -21
- package/link/styles.scoped.css +94 -84
- package/link/styles.selectors.js +21 -21
- package/package.json +1 -1
- package/pagination/index.d.ts.map +1 -1
- package/pagination/index.js +4 -1
- package/pagination/index.js.map +1 -1
- package/status-indicator/internal.js +1 -1
- package/status-indicator/internal.js.map +1 -1
- package/table/body-cell/td-element.js +1 -1
- package/table/body-cell/td-element.js.map +1 -1
- package/tag-editor/styles.css.js +3 -3
- package/tag-editor/styles.scoped.css +12 -11
- package/tag-editor/styles.selectors.js +3 -3
- package/test-utils/dom/drawer/index.d.ts +2 -0
- package/test-utils/dom/drawer/index.js +6 -0
- package/test-utils/dom/drawer/index.js.map +1 -1
- package/test-utils/selectors/drawer/index.d.ts +2 -0
- package/test-utils/selectors/drawer/index.js +6 -0
- package/test-utils/selectors/drawer/index.js.map +1 -1
- package/text-content/styles.css.js +1 -1
- package/text-content/styles.scoped.css +68 -66
- package/text-content/styles.selectors.js +1 -1
- package/tooltip/index.d.ts +0 -3
- package/tooltip/index.d.ts.map +1 -1
- package/tooltip/index.js +0 -3
- package/tooltip/index.js.map +1 -1
- package/drawer/next.d.ts +0 -5
- package/drawer/next.d.ts.map +0 -1
- package/drawer/next.js +0 -38
- package/drawer/next.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/copy-to-clipboard/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,YAAY,CAAC;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,uBAAuB,MAAM,YAAY,CAAC;AAIjD,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,OAAO,GAAG,QAAQ,EAClB,uBAAuB,GAAG,KAAK,EAC/B,GAAG,SAAS,EACS;IACrB,MAAM,SAAS,GAAG,gBAAgB,CAAC,iBAAiB,EAAE;QACpD,KAAK,EAAE,EAAE,OAAO,EAAE;KACnB,CAAC,CAAC;IACH,MAAM,aAAa,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAElD,OAAO,CACL,oBAAC,uBAAuB,IACtB,OAAO,EAAE,OAAO,EAChB,uBAAuB,EAAE,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/copy-to-clipboard/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,YAAY,CAAC;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,uBAAuB,MAAM,YAAY,CAAC;AAIjD,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,OAAO,GAAG,QAAQ,EAClB,uBAAuB,GAAG,KAAK,EAC/B,QAAQ,GAAG,IAAI,EACf,GAAG,SAAS,EACS;IACrB,MAAM,SAAS,GAAG,gBAAgB,CAAC,iBAAiB,EAAE;QACpD,KAAK,EAAE,EAAE,OAAO,EAAE;KACnB,CAAC,CAAC;IACH,MAAM,aAAa,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAElD,OAAO,CACL,oBAAC,uBAAuB,IACtB,OAAO,EAAE,OAAO,EAChB,uBAAuB,EAAE,uBAAuB,EAChD,QAAQ,EAAE,QAAQ,KACd,SAAS,KACT,aAAa,GACjB,CACH,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,eAAe,EAAE,iBAAiB,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 useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { getExternalProps } from '../internal/utils/external-props';\nimport { CopyToClipboardProps } from './interfaces';\nimport InternalCopyToClipboard from './internal';\n\nexport { CopyToClipboardProps };\n\nexport default function CopyToClipboard({\n variant = 'button',\n popoverRenderWithPortal = false,\n wrapText = true,\n ...restProps\n}: CopyToClipboardProps) {\n const baseProps = useBaseComponent('CopyToClipboard', {\n props: { variant },\n });\n const filteredProps = getExternalProps(restProps);\n\n return (\n <InternalCopyToClipboard\n variant={variant}\n popoverRenderWithPortal={popoverRenderWithPortal}\n wrapText={wrapText}\n {...baseProps}\n {...filteredProps}\n />\n );\n}\n\napplyDisplayName(CopyToClipboard, 'CopyToClipboard');\n"]}
|
|
@@ -27,6 +27,11 @@ export interface CopyToClipboardProps extends BaseComponentProps {
|
|
|
27
27
|
* The content to display next to the copy button when `variant="inline"`. If not provided, `textToCopy` will be displayed instead.
|
|
28
28
|
*/
|
|
29
29
|
textToDisplay?: React.ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Specifies if the `textToDisplay` content should wrap. If you set it to false, it prevents the text
|
|
32
|
+
* from wrapping and truncates it with an ellipsis. Only applies to `variant="inline"`.
|
|
33
|
+
*/
|
|
34
|
+
wrapText?: boolean;
|
|
30
35
|
/**
|
|
31
36
|
* The message shown when the text is copied successfully.
|
|
32
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/copy-to-clipboard/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,oBAAoB,CAAC,OAAO,CAAC;IAEvC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK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,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;;;OAMG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,aAAa,CAAC,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IAElF;;;OAGG;IACH,aAAa,CAAC,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;CACnF;AAED,yBAAiB,oBAAoB,CAAC;IACpC,KAAY,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;IAEnD,UAAiB,iBAAiB;QAChC,gDAAgD;QAChD,IAAI,EAAE,MAAM,CAAC;KACd;IAED,UAAiB,iBAAiB;QAChC,oDAAoD;QACpD,IAAI,EAAE,MAAM,CAAC;KACd;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/copy-to-clipboard/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface CopyToClipboardProps extends BaseComponentProps {\n /** Determines the general styling of the copy button as follows:\n *\n * * `button` to display a standalone secondary button with an icon, and `copyButtonText` as text.\n * * `icon` to display a standalone icon-only (no text) button.\n * * `inline` to display an icon-only (no text) button within a text context.\n *\n * Defaults to `button`.\n */\n variant?: CopyToClipboardProps.Variant;\n\n /**\n * The text of the copy button (for variant=\"button\").\n */\n copyButtonText?: string;\n\n /**\n * Adds `aria-label` to the copy button. Use this to provide an accessible name for buttons that don't have visible text,\n * and to distinguish between multiple buttons with identical visible text. The text will also be added to the `title` attribute of the button.\n */\n copyButtonAriaLabel?: string;\n\n /**\n * The text content to be copied. It is displayed next to the copy button when `variant=\"inline\"` unless when `content` is specified, and is not shown otherwise.\n */\n textToCopy: string;\n\n /**\n * The content to display next to the copy button when `variant=\"inline\"`. If not provided, `textToCopy` will be displayed instead.\n */\n textToDisplay?: React.ReactNode;\n\n /**\n * The message shown when the text is copied successfully.\n */\n copySuccessText: string;\n\n /**\n * The message shown when the text is not copied due to an error, see [https://w3c.github.io/clipboard-apis/#dom-clipboard-writetext](https://w3c.github.io/clipboard-apis/#dom-clipboard-writetext).\n */\n copyErrorText: string;\n\n /**\n * By default, the popover is constrained to fit inside its parent\n * [stacking context](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context).\n * Enabling this property will allow the popover to be rendered in the root stack context using\n * [React Portals](https://reactjs.org/docs/portals.html).\n * Enable this setting if you need the popover to ignore its parent stacking context.\n */\n popoverRenderWithPortal?: boolean;\n\n /**\n * Renders the copy to clipboard button as disabled and prevents clicks.\n */\n disabled?: boolean;\n\n /**\n * Provides a reason why the copy to clipboard button is disabled (only when `disabled` is `true`).\n * If provided, the copy to clipboard button becomes focusable.\n * Applicable for all variants except inline.\n */\n disabledReason?: string;\n\n /**\n * Called when the text is successfully copied to the clipboard.\n * The event `detail` contains the text that was copied.\n */\n onCopySuccess?: NonCancelableEventHandler<CopyToClipboardProps.CopySuccessDetail>;\n\n /**\n * Called when the copy operation fails.\n * The event `detail` contains the text that failed to copy.\n */\n onCopyFailure?: NonCancelableEventHandler<CopyToClipboardProps.CopyFailureDetail>;\n}\n\nexport namespace CopyToClipboardProps {\n export type Variant = 'button' | 'icon' | 'inline';\n\n export interface CopySuccessDetail {\n /** The text that was copied to the clipboard */\n text: string;\n }\n\n export interface CopyFailureDetail {\n /** The text that failed to copy to the clipboard */\n text: string;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/copy-to-clipboard/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface CopyToClipboardProps extends BaseComponentProps {\n /** Determines the general styling of the copy button as follows:\n *\n * * `button` to display a standalone secondary button with an icon, and `copyButtonText` as text.\n * * `icon` to display a standalone icon-only (no text) button.\n * * `inline` to display an icon-only (no text) button within a text context.\n *\n * Defaults to `button`.\n */\n variant?: CopyToClipboardProps.Variant;\n\n /**\n * The text of the copy button (for variant=\"button\").\n */\n copyButtonText?: string;\n\n /**\n * Adds `aria-label` to the copy button. Use this to provide an accessible name for buttons that don't have visible text,\n * and to distinguish between multiple buttons with identical visible text. The text will also be added to the `title` attribute of the button.\n */\n copyButtonAriaLabel?: string;\n\n /**\n * The text content to be copied. It is displayed next to the copy button when `variant=\"inline\"` unless when `content` is specified, and is not shown otherwise.\n */\n textToCopy: string;\n\n /**\n * The content to display next to the copy button when `variant=\"inline\"`. If not provided, `textToCopy` will be displayed instead.\n */\n textToDisplay?: React.ReactNode;\n\n /**\n * Specifies if the `textToDisplay` content should wrap. If you set it to false, it prevents the text\n * from wrapping and truncates it with an ellipsis. Only applies to `variant=\"inline\"`.\n */\n wrapText?: boolean;\n\n /**\n * The message shown when the text is copied successfully.\n */\n copySuccessText: string;\n\n /**\n * The message shown when the text is not copied due to an error, see [https://w3c.github.io/clipboard-apis/#dom-clipboard-writetext](https://w3c.github.io/clipboard-apis/#dom-clipboard-writetext).\n */\n copyErrorText: string;\n\n /**\n * By default, the popover is constrained to fit inside its parent\n * [stacking context](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context).\n * Enabling this property will allow the popover to be rendered in the root stack context using\n * [React Portals](https://reactjs.org/docs/portals.html).\n * Enable this setting if you need the popover to ignore its parent stacking context.\n */\n popoverRenderWithPortal?: boolean;\n\n /**\n * Renders the copy to clipboard button as disabled and prevents clicks.\n */\n disabled?: boolean;\n\n /**\n * Provides a reason why the copy to clipboard button is disabled (only when `disabled` is `true`).\n * If provided, the copy to clipboard button becomes focusable.\n * Applicable for all variants except inline.\n */\n disabledReason?: string;\n\n /**\n * Called when the text is successfully copied to the clipboard.\n * The event `detail` contains the text that was copied.\n */\n onCopySuccess?: NonCancelableEventHandler<CopyToClipboardProps.CopySuccessDetail>;\n\n /**\n * Called when the copy operation fails.\n * The event `detail` contains the text that failed to copy.\n */\n onCopyFailure?: NonCancelableEventHandler<CopyToClipboardProps.CopyFailureDetail>;\n}\n\nexport namespace CopyToClipboardProps {\n export type Variant = 'button' | 'icon' | 'inline';\n\n export interface CopySuccessDetail {\n /** The text that was copied to the clipboard */\n text: string;\n }\n\n export interface CopyFailureDetail {\n /** The text that failed to copy to the clipboard */\n text: string;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/copy-to-clipboard/internal.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGlF,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAKpD,UAAU,4BAA6B,SAAQ,oBAAoB,EAAE,0BAA0B;CAAG;AAElG,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAC,EAC9C,OAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,aAAa,EACb,UAAU,EACV,aAAa,EACb,uBAAuB,EACvB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,GAAG,SAAS,EACb,EAAE,4BAA4B,eAmG9B"}
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/copy-to-clipboard/internal.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGlF,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAKpD,UAAU,4BAA6B,SAAQ,oBAAoB,EAAE,0BAA0B;CAAG;AAElG,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAC,EAC9C,OAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,aAAa,EACb,UAAU,EACV,aAAa,EACb,QAAe,EACf,uBAAuB,EACvB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,GAAG,SAAS,EACb,EAAE,4BAA4B,eAmG9B"}
|
|
@@ -9,7 +9,7 @@ import InternalPopover from '../popover/internal';
|
|
|
9
9
|
import InternalStatusIndicator from '../status-indicator/internal';
|
|
10
10
|
import styles from './styles.css.js';
|
|
11
11
|
import testStyles from './test-classes/styles.css.js';
|
|
12
|
-
export default function InternalCopyToClipboard({ variant = 'button', copyButtonAriaLabel, copyButtonText, copySuccessText, copyErrorText, textToCopy, textToDisplay, popoverRenderWithPortal, disabled, disabledReason, onCopySuccess, onCopyFailure, __internalRootRef, ...restProps }) {
|
|
12
|
+
export default function InternalCopyToClipboard({ variant = 'button', copyButtonAriaLabel, copyButtonText, copySuccessText, copyErrorText, textToCopy, textToDisplay, wrapText = true, popoverRenderWithPortal, disabled, disabledReason, onCopySuccess, onCopyFailure, __internalRootRef, ...restProps }) {
|
|
13
13
|
const [status, setStatus] = useState('success');
|
|
14
14
|
const [statusText, setStatusText] = useState(copySuccessText);
|
|
15
15
|
useEffect(() => {
|
|
@@ -57,8 +57,8 @@ export default function InternalCopyToClipboard({ variant = 'button', copyButton
|
|
|
57
57
|
const isInline = variant === 'inline';
|
|
58
58
|
const button = (React.createElement(InternalButton, { ariaLabel: copyButtonAriaLabel !== null && copyButtonAriaLabel !== void 0 ? copyButtonAriaLabel : copyButtonText, iconName: "copy", variant: triggerVariant, wrapText: false, formAction: "none", disabled: disabled, disabledReason: disabledReason }, copyButtonText));
|
|
59
59
|
const trigger = disabled ? (button) : (React.createElement(InternalPopover, { isInline: isInline, size: "medium", position: "top", triggerType: "custom", dismissButton: false, renderWithPortal: popoverRenderWithPortal, content: React.createElement(InternalStatusIndicator, { type: status }, statusText), __onOpen: onClick }, button));
|
|
60
|
-
return (React.createElement("span", { ...baseProps, ref: __internalRootRef, className: clsx(baseProps.className, styles.root, testStyles.root) }, isInline ? (React.createElement("span", { className: styles['inline-container'] },
|
|
60
|
+
return (React.createElement("span", { ...baseProps, ref: __internalRootRef, className: clsx(baseProps.className, styles.root, testStyles.root) }, isInline ? (React.createElement("span", { className: clsx(styles['inline-container'], !wrapText && styles['inline-container-no-wrap']) },
|
|
61
61
|
React.createElement("span", { className: styles['inline-container-trigger'] }, trigger),
|
|
62
|
-
React.createElement("span", { className: clsx(testStyles['text-to-display'], testStyles['text-to-copy']) }, textToDisplay !== undefined ? textToDisplay : textToCopy))) : (trigger)));
|
|
62
|
+
React.createElement("span", { className: clsx(testStyles['text-to-display'], testStyles['text-to-copy'], styles['text-to-display']) }, textToDisplay !== undefined ? textToDisplay : textToCopy))) : (trigger)));
|
|
63
63
|
}
|
|
64
64
|
//# sourceMappingURL=internal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/copy-to-clipboard/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OA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C5G,QAAQ,CAAC,CAAC,CAAC,CACV,8BAAM,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,CAAC,QAAQ,IAAI,MAAM,CAAC,0BAA0B,CAAC,CAAC;QAChG,8BAAM,SAAS,EAAE,MAAM,CAAC,0BAA0B,CAAC,IAAG,OAAO,CAAQ;QACrE,8BAAM,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC,IACxG,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CACpD,CACF,CACR,CAAC,CAAC,CAAC,CACF,OAAO,CACR,CACI,CACR,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useState } from 'react';\nimport clsx from 'clsx';\n\nimport InternalButton from '../button/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport InternalPopover from '../popover/internal';\nimport InternalStatusIndicator from '../status-indicator/internal';\nimport { CopyToClipboardProps } from './interfaces';\n\nimport styles from './styles.css.js';\nimport testStyles from './test-classes/styles.css.js';\n\ninterface InternalCopyToClipboardProps extends CopyToClipboardProps, InternalBaseComponentProps {}\n\nexport default function InternalCopyToClipboard({\n variant = 'button',\n copyButtonAriaLabel,\n copyButtonText,\n copySuccessText,\n copyErrorText,\n textToCopy,\n textToDisplay,\n wrapText = true,\n popoverRenderWithPortal,\n disabled,\n disabledReason,\n onCopySuccess,\n onCopyFailure,\n __internalRootRef,\n ...restProps\n}: InternalCopyToClipboardProps) {\n const [status, setStatus] = useState<'pending' | 'success' | 'error'>('success');\n const [statusText, setStatusText] = useState(copySuccessText);\n\n useEffect(() => {\n if (navigator.permissions) {\n navigator.permissions\n .query({ name: 'clipboard-write' as PermissionName })\n .then(result => {\n if (result.state === 'denied') {\n setStatus('error');\n setStatusText(copyErrorText);\n }\n })\n .catch(() => {\n // Permissions API not supported or failed.\n });\n }\n }, [copyErrorText]);\n\n const baseProps = getBaseProps(restProps);\n const onClick = () => {\n if (!navigator.clipboard) {\n // The clipboard API is not available in insecure contexts.\n setStatus('error');\n setStatusText(copyErrorText);\n fireNonCancelableEvent(onCopyFailure, { text: textToCopy });\n return;\n }\n\n navigator.clipboard\n .writeText(textToCopy)\n .then(() => {\n setStatus('success');\n setStatusText(copySuccessText);\n fireNonCancelableEvent(onCopySuccess, { text: textToCopy });\n })\n .catch(() => {\n setStatus('error');\n setStatusText(copyErrorText);\n fireNonCancelableEvent(onCopyFailure, { text: textToCopy });\n });\n };\n\n const triggerVariant = (\n {\n button: 'normal',\n icon: 'icon',\n inline: 'inline-icon',\n } as const\n )[variant];\n\n const isInline = variant === 'inline';\n\n const button = (\n <InternalButton\n ariaLabel={copyButtonAriaLabel ?? copyButtonText}\n iconName=\"copy\"\n variant={triggerVariant}\n wrapText={false}\n formAction=\"none\"\n disabled={disabled}\n disabledReason={disabledReason}\n >\n {copyButtonText}\n </InternalButton>\n );\n\n const trigger = disabled ? (\n button\n ) : (\n <InternalPopover\n isInline={isInline}\n size=\"medium\"\n position=\"top\"\n triggerType=\"custom\"\n dismissButton={false}\n renderWithPortal={popoverRenderWithPortal}\n content={<InternalStatusIndicator type={status}>{statusText}</InternalStatusIndicator>}\n __onOpen={onClick}\n >\n {button}\n </InternalPopover>\n );\n\n return (\n <span {...baseProps} ref={__internalRootRef} className={clsx(baseProps.className, styles.root, testStyles.root)}>\n {isInline ? (\n <span className={clsx(styles['inline-container'], !wrapText && styles['inline-container-no-wrap'])}>\n <span className={styles['inline-container-trigger']}>{trigger}</span>\n <span className={clsx(testStyles['text-to-display'], testStyles['text-to-copy'], styles['text-to-display'])}>\n {textToDisplay !== undefined ? textToDisplay : textToCopy}\n </span>\n </span>\n ) : (\n trigger\n )}\n </span>\n );\n}\n"]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"root": "
|
|
5
|
-
"inline-container": "awsui_inline-
|
|
6
|
-
"inline-container-trigger": "awsui_inline-container-
|
|
4
|
+
"root": "awsui_root_5a145_1cjru_9",
|
|
5
|
+
"inline-container": "awsui_inline-container_5a145_1cjru_13",
|
|
6
|
+
"inline-container-trigger": "awsui_inline-container-trigger_5a145_1cjru_16",
|
|
7
|
+
"inline-container-no-wrap": "awsui_inline-container-no-wrap_5a145_1cjru_19",
|
|
8
|
+
"text-to-display": "awsui_text-to-display_5a145_1cjru_28"
|
|
7
9
|
};
|
|
8
10
|
|
|
@@ -6,13 +6,28 @@
|
|
|
6
6
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
7
|
SPDX-License-Identifier: Apache-2.0
|
|
8
8
|
*/
|
|
9
|
-
.
|
|
9
|
+
.awsui_root_5a145_1cjru_9:not(#\9) {
|
|
10
10
|
display: contents;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
.awsui_inline-
|
|
13
|
+
.awsui_inline-container_5a145_1cjru_13:not(#\9) {
|
|
14
14
|
word-break: break-all;
|
|
15
15
|
}
|
|
16
|
-
.awsui_inline-container-
|
|
16
|
+
.awsui_inline-container-trigger_5a145_1cjru_16:not(#\9) {
|
|
17
17
|
margin-inline-end: var(--space-scaled-xxs-pfm1nx, 4px);
|
|
18
|
+
}
|
|
19
|
+
.awsui_inline-container-no-wrap_5a145_1cjru_19:not(#\9) {
|
|
20
|
+
display: inline-flex;
|
|
21
|
+
align-items: start;
|
|
22
|
+
max-inline-size: 100%;
|
|
23
|
+
word-break: normal;
|
|
24
|
+
}
|
|
25
|
+
.awsui_inline-container-no-wrap_5a145_1cjru_19 > .awsui_inline-container-trigger_5a145_1cjru_16:not(#\9) {
|
|
26
|
+
flex-shrink: 0;
|
|
27
|
+
}
|
|
28
|
+
.awsui_inline-container-no-wrap_5a145_1cjru_19 > .awsui_text-to-display_5a145_1cjru_28:not(#\9) {
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
text-overflow: ellipsis;
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
min-inline-size: 0;
|
|
18
33
|
}
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"root": "
|
|
6
|
-
"inline-container": "awsui_inline-
|
|
7
|
-
"inline-container-trigger": "awsui_inline-container-
|
|
5
|
+
"root": "awsui_root_5a145_1cjru_9",
|
|
6
|
+
"inline-container": "awsui_inline-container_5a145_1cjru_13",
|
|
7
|
+
"inline-container-trigger": "awsui_inline-container-trigger_5a145_1cjru_16",
|
|
8
|
+
"inline-container-no-wrap": "awsui_inline-container-no-wrap_5a145_1cjru_19",
|
|
9
|
+
"text-to-display": "awsui_text-to-display_5a145_1cjru_28"
|
|
8
10
|
};
|
|
9
11
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
|
|
3
|
-
import {
|
|
4
|
-
type DrawerInternalProps =
|
|
5
|
-
__ref?: React.Ref<
|
|
3
|
+
import { DrawerProps } from './interfaces';
|
|
4
|
+
type DrawerInternalProps = DrawerProps & InternalBaseComponentProps & {
|
|
5
|
+
__ref?: React.Ref<DrawerProps.Ref>;
|
|
6
6
|
};
|
|
7
7
|
export declare function DrawerImplementation({
|
|
8
8
|
header,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../../../src/drawer/implementation.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAcjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAKlF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../../../src/drawer/implementation.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAcjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAKlF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAO3C,KAAK,mBAAmB,GAAG,WAAW,GACpC,0BAA0B,GAAG;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;CACpC,CAAC;AAEJ,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,MAAM,EACN,QAAQ,EACR,OAAO,EACP,WAAW,EACX,sBAAsB,EACtB,iBAAiB,EACjB,KAAK,EACL,aAAa,EACb,QAAmB,EACnB,SAAiB,EACjB,MAAM,EACN,YAAY,EACZ,MAAM,EACN,WAAW,EACX,eAAuB,EACvB,QAAgB,EAChB,IAAI,EACJ,OAAO,EACP,SAAS,EACT,cAAc,EACd,aAAa,EACb,IAAI,EACJ,GAAG,SAAS,EACb,EAAE,mBAAmB,eA0KrB;AAED,eAAO,MAAM,sBAAsB,mFAAkD,CAAC"}
|
package/drawer/implementation.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import React, { useEffect, useImperativeHandle, useRef } from 'react';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
-
import { useStableCallback, useUniqueId } from '@cloudscape-design/component-toolkit/internal';
|
|
5
|
+
import { Portal, useStableCallback, useUniqueId } from '@cloudscape-design/component-toolkit/internal';
|
|
6
6
|
import { useRuntimeDrawerContext } from '../app-layout/runtime-drawer/use-runtime-drawer-context';
|
|
7
7
|
import { useAppLayoutToolbarDesignEnabled } from '../app-layout/utils/feature-flags';
|
|
8
8
|
import InternalButton from '../button/internal';
|
|
@@ -99,7 +99,7 @@ export function DrawerImplementation({ header, footer, children, loading, i18nSt
|
|
|
99
99
|
document.addEventListener('keydown', onKeyDown);
|
|
100
100
|
return () => document.removeEventListener('keydown', onKeyDown);
|
|
101
101
|
}, [showBackdrop, handleClose]);
|
|
102
|
-
|
|
102
|
+
const drawer = (React.createElement("div", { ...baseProps, className: clsx(baseProps.className, styles.root, testClasses.root, open === false && styles.hidden), ref: __internalRootRef },
|
|
103
103
|
showBackdrop && (React.createElement("div", { className: clsx(styles.backdrop, testClasses.backdrop, styles[`backdrop-${position}`]), style: { zIndex }, onClick: () => handleClose('backdrop-click') })),
|
|
104
104
|
React.createElement(FocusLock, { disabled: !trapFocus, className: styles['focus-trap'] },
|
|
105
105
|
React.createElement("div", { ...containerProps }, loading ? (React.createElement(InternalStatusIndicator, { type: "loading" },
|
|
@@ -114,6 +114,7 @@ export function DrawerImplementation({ header, footer, children, loading, i18nSt
|
|
|
114
114
|
footer && (React.createElement("div", { ref: footerRef, className: clsx(styles.footer, {
|
|
115
115
|
[styles['is-sticky']]: isFooterSticky,
|
|
116
116
|
}) }, footer))))))));
|
|
117
|
+
return position === 'fixed' ? React.createElement(Portal, null, drawer) : drawer;
|
|
117
118
|
}
|
|
118
119
|
export const createWidgetizedDrawer = createWidgetizedComponent(DrawerImplementation);
|
|
119
120
|
//# sourceMappingURL=implementation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../../src/drawer/implementation.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAa,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE/F,OAAO,EAAE,uBAAuB,EAAE,MAAM,yDAAyD,CAAC;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B,IAAI,MAAM,CAAC,sBAAsB,CAAC,EACtD,yBAAyB,IAAI,MAAM,CAAC,wBAAwB,CAAC,EAC7D,eAAe,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAC/C;oBAED,8BAAM,EAAE,EAAE,QAAQ,IAAG,MAAM,CAAQ;oBAClC,aAAa,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,IAAG,aAAa,CAAO,CAC7E,CACP;gBACA,WAAW,IAAI,CAAC,eAAe,IAAI,CAClC,6BAAK,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC;oBACpC,oBAAC,cAAc,IACb,OAAO,EAAC,MAAM,EACd,QAAQ,EAAC,OAAO,KACZ,WAAW,EACf,SAAS,EAAE,WAAW,CAAC,cAAc,CAAC,EACtC,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,cAAc,CAAC,GAC1C,CACE,CACP;gBACD,6BACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,2BAA2B,CAAC,EACnC,MAAM,CAAC,OAAO,EACd,CAAC,sBAAsB,IAAI,MAAM,CAAC,uBAAuB,CAAC,CAC3D;oBAED,oBAAC,oBAAoB,QAAE,QAAQ,CAAwB,CACnD;gBACL,MAAM,IAAI,CACT,6BACE,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;wBAC7B,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,cAAc;qBACtC,CAAC,IAED,MAAM,CACH,CACP,CACA,CACJ,CACG,CACI,CACR,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC,oBAAoB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { RefObject, useEffect, useImperativeHandle, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useStableCallback, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useRuntimeDrawerContext } from '../app-layout/runtime-drawer/use-runtime-drawer-context';\nimport { useAppLayoutToolbarDesignEnabled } from '../app-layout/utils/feature-flags';\nimport InternalButton from '../button/internal';\nimport { BuiltInErrorBoundary } from '../error-boundary/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { getBaseProps } from '../internal/base-component';\nimport FocusLock from '../internal/components/focus-lock';\nimport { getAllFocusables, isFocusable } from '../internal/components/focus-lock/utils';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useEffectOnUpdate } from '../internal/hooks/use-effect-on-update';\nimport { createWidgetizedComponent } from '../internal/widgets';\nimport InternalLiveRegion from '../live-region/internal';\nimport InternalStatusIndicator from '../status-indicator/internal';\nimport { NextDrawerProps } from './interfaces';\nimport { useStickyFooter } from './use-sticky-footer';\nimport { getPositionStyles } from './utils';\n\nimport styles from './styles.css.js';\nimport testClasses from './test-classes/styles.css.js';\n\ntype DrawerInternalProps = NextDrawerProps &\n InternalBaseComponentProps & {\n __ref?: React.Ref<NextDrawerProps.Ref>;\n };\n\nexport function DrawerImplementation({\n header,\n footer,\n children,\n loading,\n i18nStrings,\n disableContentPaddings,\n __internalRootRef,\n __ref,\n headerActions,\n position = 'static',\n placement = 'end',\n offset,\n stickyOffset,\n zIndex,\n closeAction,\n hideCloseAction = false,\n backdrop = false,\n open,\n onClose,\n ariaLabel,\n ariaLabelledby,\n focusBehavior,\n role,\n ...restProps\n}: DrawerInternalProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const footerRef = useRef<HTMLDivElement>(null);\n const returnFocusTargetRef = useRef<HTMLElement | null>(null);\n\n const baseProps = getBaseProps(restProps);\n const isToolbar = useAppLayoutToolbarDesignEnabled();\n const i18n = useInternalI18n('drawer');\n const positionStyles = getPositionStyles({ position, placement, offset, stickyOffset, zIndex });\n const headerId = useUniqueId('drawer-header');\n const defaultRegionLabelledBy = header ? headerId : undefined;\n ariaLabelledby = ariaLabelledby ?? (ariaLabel ? undefined : defaultRegionLabelledBy);\n role = role ?? (position === 'static' ? 'presentation' : 'region');\n const roleProps =\n role === 'region'\n ? { role: 'region', tabIndex: -1, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby }\n : {};\n const containerProps = {\n ref: containerRef,\n ...roleProps,\n style: positionStyles.style,\n className: clsx(\n styles.drawer,\n loading && styles['content-with-paddings'],\n isToolbar && styles['with-toolbar'],\n !!footer && styles['with-footer'],\n closeAction && !hideCloseAction && styles['has-close-action'],\n positionStyles.className\n ),\n };\n\n const focusIn = useStableCallback(() => {\n returnFocusTargetRef.current = document.activeElement as HTMLElement;\n if (containerRef.current && isFocusable(containerRef.current)) {\n containerRef.current.focus();\n } else if (containerRef.current) {\n getAllFocusables(containerRef.current)[0]?.focus();\n }\n });\n\n const focusOut = useStableCallback(() => {\n if (focusBehavior?.returnFocus) {\n focusBehavior.returnFocus();\n } else if (returnFocusTargetRef.current && returnFocusTargetRef.current.isConnected) {\n returnFocusTargetRef.current.focus();\n }\n returnFocusTargetRef.current = null;\n });\n\n const autoFocusRef = useRef(false);\n autoFocusRef.current = focusBehavior?.autoFocus ?? true;\n\n // The use-effect-on-update ensures no focus transition on component's initial render.\n // If focus transition is needed - the drawerRef.current.focus() should be used instead.\n useEffectOnUpdate(() => {\n if (open === undefined) {\n return;\n }\n if (open && autoFocusRef.current) {\n focusIn();\n }\n if (!open) {\n focusOut();\n }\n }, [open, focusIn, focusOut]);\n\n const handleClose = useStableCallback((method: 'close-action' | 'backdrop-click' | 'escape') =>\n fireNonCancelableEvent(onClose, { method })\n );\n\n useImperativeHandle(__ref, () => ({ focus: () => containerRef.current?.focus() }), []);\n\n const runtimeDrawerContext = useRuntimeDrawerContext({ rootRef: __internalRootRef as RefObject<HTMLElement> });\n const hasAdditionalDrawerAction = !!runtimeDrawerContext?.isExpandable;\n const { isSticky: isFooterSticky } = useStickyFooter({\n rootRef: __internalRootRef as RefObject<HTMLElement>,\n drawerRef: containerRef,\n footerRef,\n });\n\n const showBackdrop = backdrop && (position === 'fixed' || position === 'absolute');\n const trapFocus = focusBehavior?.trapFocus ?? showBackdrop;\n\n useEffect(() => {\n if (!showBackdrop) {\n return;\n }\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n handleClose('escape');\n }\n };\n document.addEventListener('keydown', onKeyDown);\n return () => document.removeEventListener('keydown', onKeyDown);\n }, [showBackdrop, handleClose]);\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root, testClasses.root, open === false && styles.hidden)}\n ref={__internalRootRef}\n >\n {showBackdrop && (\n <div\n className={clsx(styles.backdrop, testClasses.backdrop, styles[`backdrop-${position}`])}\n style={{ zIndex }}\n onClick={() => handleClose('backdrop-click')}\n />\n )}\n <FocusLock disabled={!trapFocus} className={styles['focus-trap']}>\n <div {...containerProps}>\n {loading ? (\n <InternalStatusIndicator type=\"loading\">\n <InternalLiveRegion tagName=\"span\">\n {i18n('i18nStrings.loadingText', i18nStrings?.loadingText)}\n </InternalLiveRegion>\n </InternalStatusIndicator>\n ) : (\n <>\n {header && (\n <div\n className={clsx(\n styles.header,\n runtimeDrawerContext && styles['with-runtime-context'],\n hasAdditionalDrawerAction && styles['with-additional-action'],\n hideCloseAction && styles['hide-close-action']\n )}\n >\n <span id={headerId}>{header}</span>\n {headerActions && <div className={styles['header-actions']}>{headerActions}</div>}\n </div>\n )}\n {closeAction && !hideCloseAction && (\n <div className={styles['close-action']}>\n <InternalButton\n variant=\"icon\"\n iconName=\"close\"\n {...closeAction}\n className={testClasses['close-action']}\n onClick={() => handleClose('close-action')}\n />\n </div>\n )}\n <div\n className={clsx(\n styles['test-utils-drawer-content'],\n styles.content,\n !disableContentPaddings && styles['content-with-paddings']\n )}\n >\n <BuiltInErrorBoundary>{children}</BuiltInErrorBoundary>\n </div>\n {footer && (\n <div\n ref={footerRef}\n className={clsx(styles.footer, {\n [styles['is-sticky']]: isFooterSticky,\n })}\n >\n {footer}\n </div>\n )}\n </>\n )}\n </div>\n </FocusLock>\n </div>\n );\n}\n\nexport const createWidgetizedDrawer = createWidgetizedComponent(DrawerImplementation);\n"]}
|
|
1
|
+
{"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../../src/drawer/implementation.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAa,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAEvG,OAAO,EAAE,uBAAuB,EAAE,MAAM,yDAAyD,CAAC;AAClG,OAAO,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AACrF,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,SAAS,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AACzD,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAC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oB,QAAE,QAAQ,CAAwB,CACnD;gBACL,MAAM,IAAI,CACT,6BACE,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;wBAC7B,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,cAAc;qBACtC,CAAC,IAED,MAAM,CACH,CACP,CACA,CACJ,CACG,CACI,CACR,CACP,CAAC;IAEF,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,oBAAC,MAAM,QAAE,MAAM,CAAU,CAAC,CAAC,CAAC,MAAM,CAAC;AACnE,CAAC;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC,oBAAoB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { RefObject, useEffect, useImperativeHandle, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { Portal, useStableCallback, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useRuntimeDrawerContext } from '../app-layout/runtime-drawer/use-runtime-drawer-context';\nimport { useAppLayoutToolbarDesignEnabled } from '../app-layout/utils/feature-flags';\nimport InternalButton from '../button/internal';\nimport { BuiltInErrorBoundary } from '../error-boundary/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { getBaseProps } from '../internal/base-component';\nimport FocusLock from '../internal/components/focus-lock';\nimport { getAllFocusables, isFocusable } from '../internal/components/focus-lock/utils';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useEffectOnUpdate } from '../internal/hooks/use-effect-on-update';\nimport { createWidgetizedComponent } from '../internal/widgets';\nimport InternalLiveRegion from '../live-region/internal';\nimport InternalStatusIndicator from '../status-indicator/internal';\nimport { DrawerProps } from './interfaces';\nimport { useStickyFooter } from './use-sticky-footer';\nimport { getPositionStyles } from './utils';\n\nimport styles from './styles.css.js';\nimport testClasses from './test-classes/styles.css.js';\n\ntype DrawerInternalProps = DrawerProps &\n InternalBaseComponentProps & {\n __ref?: React.Ref<DrawerProps.Ref>;\n };\n\nexport function DrawerImplementation({\n header,\n footer,\n children,\n loading,\n i18nStrings,\n disableContentPaddings,\n __internalRootRef,\n __ref,\n headerActions,\n position = 'static',\n placement = 'end',\n offset,\n stickyOffset,\n zIndex,\n closeAction,\n hideCloseAction = false,\n backdrop = false,\n open,\n onClose,\n ariaLabel,\n ariaLabelledby,\n focusBehavior,\n role,\n ...restProps\n}: DrawerInternalProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const footerRef = useRef<HTMLDivElement>(null);\n const returnFocusTargetRef = useRef<HTMLElement | null>(null);\n\n const baseProps = getBaseProps(restProps);\n const isToolbar = useAppLayoutToolbarDesignEnabled();\n const i18n = useInternalI18n('drawer');\n const positionStyles = getPositionStyles({ position, placement, offset, stickyOffset, zIndex });\n const headerId = useUniqueId('drawer-header');\n const defaultRegionLabelledBy = header ? headerId : undefined;\n ariaLabelledby = ariaLabelledby ?? (ariaLabel ? undefined : defaultRegionLabelledBy);\n role = role ?? (position === 'static' ? 'presentation' : 'region');\n const roleProps =\n role === 'region'\n ? { role: 'region', tabIndex: -1, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby }\n : {};\n const containerProps = {\n ref: containerRef,\n ...roleProps,\n style: positionStyles.style,\n className: clsx(\n styles.drawer,\n loading && styles['content-with-paddings'],\n isToolbar && styles['with-toolbar'],\n !!footer && styles['with-footer'],\n closeAction && !hideCloseAction && styles['has-close-action'],\n positionStyles.className\n ),\n };\n\n const focusIn = useStableCallback(() => {\n returnFocusTargetRef.current = document.activeElement as HTMLElement;\n if (containerRef.current && isFocusable(containerRef.current)) {\n containerRef.current.focus();\n } else if (containerRef.current) {\n getAllFocusables(containerRef.current)[0]?.focus();\n }\n });\n\n const focusOut = useStableCallback(() => {\n if (focusBehavior?.returnFocus) {\n focusBehavior.returnFocus();\n } else if (returnFocusTargetRef.current && returnFocusTargetRef.current.isConnected) {\n returnFocusTargetRef.current.focus();\n }\n returnFocusTargetRef.current = null;\n });\n\n const autoFocusRef = useRef(false);\n autoFocusRef.current = focusBehavior?.autoFocus ?? true;\n\n // The use-effect-on-update ensures no focus transition on component's initial render.\n // If focus transition is needed - the drawerRef.current.focus() should be used instead.\n useEffectOnUpdate(() => {\n if (open === undefined) {\n return;\n }\n if (open && autoFocusRef.current) {\n focusIn();\n }\n if (!open) {\n focusOut();\n }\n }, [open, focusIn, focusOut]);\n\n const handleClose = useStableCallback((method: 'close-action' | 'backdrop-click' | 'escape') =>\n fireNonCancelableEvent(onClose, { method })\n );\n\n useImperativeHandle(__ref, () => ({ focus: () => containerRef.current?.focus() }), []);\n\n const runtimeDrawerContext = useRuntimeDrawerContext({ rootRef: __internalRootRef as RefObject<HTMLElement> });\n const hasAdditionalDrawerAction = !!runtimeDrawerContext?.isExpandable;\n const { isSticky: isFooterSticky } = useStickyFooter({\n rootRef: __internalRootRef as RefObject<HTMLElement>,\n drawerRef: containerRef,\n footerRef,\n });\n\n const showBackdrop = backdrop && (position === 'fixed' || position === 'absolute');\n const trapFocus = focusBehavior?.trapFocus ?? showBackdrop;\n\n useEffect(() => {\n if (!showBackdrop) {\n return;\n }\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n handleClose('escape');\n }\n };\n document.addEventListener('keydown', onKeyDown);\n return () => document.removeEventListener('keydown', onKeyDown);\n }, [showBackdrop, handleClose]);\n\n const drawer = (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root, testClasses.root, open === false && styles.hidden)}\n ref={__internalRootRef}\n >\n {showBackdrop && (\n <div\n className={clsx(styles.backdrop, testClasses.backdrop, styles[`backdrop-${position}`])}\n style={{ zIndex }}\n onClick={() => handleClose('backdrop-click')}\n />\n )}\n <FocusLock disabled={!trapFocus} className={styles['focus-trap']}>\n <div {...containerProps}>\n {loading ? (\n <InternalStatusIndicator type=\"loading\">\n <InternalLiveRegion tagName=\"span\">\n {i18n('i18nStrings.loadingText', i18nStrings?.loadingText)}\n </InternalLiveRegion>\n </InternalStatusIndicator>\n ) : (\n <>\n {header && (\n <div\n className={clsx(\n styles.header,\n runtimeDrawerContext && styles['with-runtime-context'],\n hasAdditionalDrawerAction && styles['with-additional-action'],\n hideCloseAction && styles['hide-close-action']\n )}\n >\n <span id={headerId}>{header}</span>\n {headerActions && <div className={styles['header-actions']}>{headerActions}</div>}\n </div>\n )}\n {closeAction && !hideCloseAction && (\n <div className={styles['close-action']}>\n <InternalButton\n variant=\"icon\"\n iconName=\"close\"\n {...closeAction}\n className={testClasses['close-action']}\n onClick={() => handleClose('close-action')}\n />\n </div>\n )}\n <div\n className={clsx(\n styles['test-utils-drawer-content'],\n styles.content,\n !disableContentPaddings && styles['content-with-paddings']\n )}\n >\n <BuiltInErrorBoundary>{children}</BuiltInErrorBoundary>\n </div>\n {footer && (\n <div\n ref={footerRef}\n className={clsx(styles.footer, {\n [styles['is-sticky']]: isFooterSticky,\n })}\n >\n {footer}\n </div>\n )}\n </>\n )}\n </div>\n </FocusLock>\n </div>\n );\n\n return position === 'fixed' ? <Portal>{drawer}</Portal> : drawer;\n}\n\nexport const createWidgetizedDrawer = createWidgetizedComponent(DrawerImplementation);\n"]}
|
package/drawer/index.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { DrawerProps } from './interfaces';
|
|
2
3
|
export { DrawerProps };
|
|
3
|
-
declare const Drawer:
|
|
4
|
-
header,
|
|
5
|
-
headerActions,
|
|
6
|
-
footer,
|
|
7
|
-
disableContentPaddings,
|
|
8
|
-
loading,
|
|
9
|
-
children,
|
|
10
|
-
i18nStrings,
|
|
11
|
-
...props
|
|
12
|
-
}: DrawerProps) => JSX.Element;
|
|
4
|
+
declare const Drawer: React.ForwardRefExoticComponent<DrawerProps & React.RefAttributes<DrawerProps.Ref>>;
|
|
13
5
|
export default Drawer;
|
package/drawer/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/drawer/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/drawer/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAO1C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAE,WAAW,EAAE,CAAC;AAKvB,QAAA,MAAM,MAAM,qFAwEV,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
package/drawer/index.js
CHANGED
|
@@ -1,25 +1,37 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
'use client';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import {
|
|
4
|
+
import React, { forwardRef } from 'react';
|
|
5
|
+
import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
|
|
6
6
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
7
7
|
import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
8
|
+
import { getExternalProps } from '../internal/utils/external-props';
|
|
8
9
|
import { InternalDrawer } from './internal';
|
|
9
|
-
|
|
10
|
+
// Matches App Layout drawers z-index.
|
|
11
|
+
const DEFAULT_Z_INDEX = 830;
|
|
12
|
+
const Drawer = forwardRef(function Drawer({ header, headerActions, footer, disableContentPaddings = false, loading = false, position = 'static', placement = 'end', offset, stickyOffset, zIndex = DEFAULT_Z_INDEX, closeAction, hideCloseAction = false, open, backdrop = false, onClose, focusBehavior, role, ...props }, ref) {
|
|
13
|
+
if (backdrop && position !== 'fixed' && position !== 'absolute') {
|
|
14
|
+
warnOnce('Drawer', `\`backdrop\` is not supported with position="${position}" and will be ignored.`);
|
|
15
|
+
}
|
|
16
|
+
if (open !== undefined && !onClose) {
|
|
17
|
+
warnOnce('Drawer', 'You provided `open` without an `onClose` handler. The drawer will not respond to close actions.');
|
|
18
|
+
}
|
|
10
19
|
const baseComponentProps = useBaseComponent('Drawer', {
|
|
11
|
-
props: {
|
|
12
|
-
disableContentPaddings,
|
|
13
|
-
loading,
|
|
14
|
-
},
|
|
20
|
+
props: { disableContentPaddings, loading, placement, position, zIndex, hideCloseAction, backdrop, role },
|
|
15
21
|
metadata: {
|
|
16
22
|
hasHeader: !!header,
|
|
17
23
|
hasHeaderActions: !!headerActions,
|
|
18
24
|
hasFooter: !!footer,
|
|
25
|
+
hasOffset: !!offset,
|
|
26
|
+
hasStickyOffset: !!stickyOffset,
|
|
27
|
+
hasCloseAction: !!closeAction,
|
|
28
|
+
autoFocus: !!(focusBehavior === null || focusBehavior === void 0 ? void 0 : focusBehavior.autoFocus),
|
|
29
|
+
trapFocus: !!(focusBehavior === null || focusBehavior === void 0 ? void 0 : focusBehavior.trapFocus),
|
|
30
|
+
returnFocus: !!(focusBehavior === null || focusBehavior === void 0 ? void 0 : focusBehavior.returnFocus),
|
|
19
31
|
},
|
|
20
32
|
});
|
|
21
|
-
return (React.createElement(InternalDrawer, { ...
|
|
22
|
-
};
|
|
33
|
+
return (React.createElement(InternalDrawer, { ...getExternalProps(props), ...baseComponentProps, __ref: ref, header: header, headerActions: headerActions, footer: footer, disableContentPaddings: disableContentPaddings, loading: loading, placement: placement, position: position, offset: offset, stickyOffset: stickyOffset, zIndex: zIndex, closeAction: closeAction, hideCloseAction: hideCloseAction, open: open, backdrop: backdrop, onClose: onClose, focusBehavior: focusBehavior, role: role }));
|
|
34
|
+
});
|
|
23
35
|
export default Drawer;
|
|
24
36
|
applyDisplayName(Drawer, 'Drawer');
|
|
25
37
|
//# sourceMappingURL=index.js.map
|
package/drawer/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drawer/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAs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eAAe,MAAM,CAAC;AAEtB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\nimport React, { forwardRef } from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { getExternalProps } from '../internal/utils/external-props';\nimport { DrawerProps } from './interfaces';\nimport { InternalDrawer } from './internal';\n\nexport { DrawerProps };\n\n// Matches App Layout drawers z-index.\nconst DEFAULT_Z_INDEX = 830;\n\nconst Drawer = forwardRef(function Drawer(\n {\n header,\n headerActions,\n footer,\n disableContentPaddings = false,\n loading = false,\n position = 'static',\n placement = 'end',\n offset,\n stickyOffset,\n zIndex = DEFAULT_Z_INDEX,\n closeAction,\n hideCloseAction = false,\n open,\n backdrop = false,\n onClose,\n focusBehavior,\n role,\n ...props\n }: DrawerProps,\n ref: React.Ref<DrawerProps.Ref>\n) {\n if (backdrop && position !== 'fixed' && position !== 'absolute') {\n warnOnce('Drawer', `\\`backdrop\\` is not supported with position=\"${position}\" and will be ignored.`);\n }\n if (open !== undefined && !onClose) {\n warnOnce(\n 'Drawer',\n 'You provided `open` without an `onClose` handler. The drawer will not respond to close actions.'\n );\n }\n\n const baseComponentProps = useBaseComponent('Drawer', {\n props: { disableContentPaddings, loading, placement, position, zIndex, hideCloseAction, backdrop, role },\n metadata: {\n hasHeader: !!header,\n hasHeaderActions: !!headerActions,\n hasFooter: !!footer,\n hasOffset: !!offset,\n hasStickyOffset: !!stickyOffset,\n hasCloseAction: !!closeAction,\n autoFocus: !!focusBehavior?.autoFocus,\n trapFocus: !!focusBehavior?.trapFocus,\n returnFocus: !!focusBehavior?.returnFocus,\n },\n });\n\n return (\n <InternalDrawer\n {...getExternalProps(props)}\n {...baseComponentProps}\n __ref={ref}\n header={header}\n headerActions={headerActions}\n footer={footer}\n disableContentPaddings={disableContentPaddings}\n loading={loading}\n placement={placement}\n position={position}\n offset={offset}\n stickyOffset={stickyOffset}\n zIndex={zIndex}\n closeAction={closeAction}\n hideCloseAction={hideCloseAction}\n open={open}\n backdrop={backdrop}\n onClose={onClose}\n focusBehavior={focusBehavior}\n role={role}\n />\n );\n});\n\nexport default Drawer;\n\napplyDisplayName(Drawer, 'Drawer');\n"]}
|
package/drawer/interfaces.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { IconProps } from '../icon/interfaces';
|
|
3
3
|
import { BaseComponentProps } from '../internal/base-component';
|
|
4
4
|
import { NonCancelableEventHandler } from '../internal/events';
|
|
5
5
|
export interface DrawerProps extends BaseComponentProps {
|
|
@@ -38,13 +38,6 @@ export interface DrawerProps extends BaseComponentProps {
|
|
|
38
38
|
* to ensure content remains accessible (not covered by the footer).
|
|
39
39
|
*/
|
|
40
40
|
footer?: React.ReactNode;
|
|
41
|
-
}
|
|
42
|
-
export declare namespace DrawerProps {
|
|
43
|
-
interface I18nStrings {
|
|
44
|
-
loadingText?: string;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export interface NextDrawerProps extends DrawerProps {
|
|
48
41
|
/**
|
|
49
42
|
* Sets the ARIA role of the drawer.
|
|
50
43
|
* - `"region"` (default for non-`static` positions) — exposes the drawer as a
|
|
@@ -76,16 +69,20 @@ export interface NextDrawerProps extends DrawerProps {
|
|
|
76
69
|
* Using `sticky` with `placement="start"` or `placement="end"` falls back to `static`.
|
|
77
70
|
* * `absolute` - The drawer is positioned relative to its nearest positioned ancestor.
|
|
78
71
|
* * `fixed` - The drawer is positioned relative to the viewport.
|
|
72
|
+
*
|
|
73
|
+
* Do not use this property when using drawers inside app layout.
|
|
79
74
|
*/
|
|
80
|
-
position?:
|
|
75
|
+
position?: DrawerProps.Position;
|
|
81
76
|
/**
|
|
82
77
|
* Specifies which edge of its container the drawer is anchored to, and supports these options:
|
|
83
78
|
* * `start` - Anchored to the inline-start edge.
|
|
84
79
|
* * `end` - (default) Anchored to the inline-end edge.
|
|
85
80
|
* * `top` - Anchored to the top edge.
|
|
86
81
|
* * `bottom` - Anchored to the bottom edge.
|
|
82
|
+
*
|
|
83
|
+
* Do not use this property when using drawers inside app layout.
|
|
87
84
|
*/
|
|
88
|
-
placement?:
|
|
85
|
+
placement?: DrawerProps.Placement;
|
|
89
86
|
/**
|
|
90
87
|
* Specifies the distance in pixels between the drawer and the edges of its container.
|
|
91
88
|
* Applicable when using `position="absolute"` or `position="fixed"`.
|
|
@@ -94,33 +91,43 @@ export interface NextDrawerProps extends DrawerProps {
|
|
|
94
91
|
* * `end` - Distance from the inline-end edge. Not applicable when `placement` is `"start"`.
|
|
95
92
|
* * `top` - Distance from the top edge. Not applicable when `placement` is `"bottom"`.
|
|
96
93
|
* * `bottom` - Distance from the bottom edge. Not applicable when `placement` is `"top"`.
|
|
94
|
+
*
|
|
95
|
+
* Do not use this property when using drawers inside app layout.
|
|
97
96
|
*/
|
|
98
|
-
offset?:
|
|
97
|
+
offset?: DrawerProps.Offset;
|
|
99
98
|
/**
|
|
100
99
|
* Specifies the distance in pixels from the top or bottom edge of the scrolling container
|
|
101
100
|
* at which the drawer sticks. Applicable only when using `position="sticky"` with `placement="top"` or `placement="bottom"`.
|
|
102
101
|
* * Supported properties:
|
|
103
102
|
* * `top` - Distance from the top of the scrolling container.
|
|
104
103
|
* * `bottom` - Distance from the bottom of the scrolling container.
|
|
104
|
+
*
|
|
105
|
+
* Do not use this property when using drawers inside app layout.
|
|
105
106
|
*/
|
|
106
|
-
stickyOffset?:
|
|
107
|
+
stickyOffset?: DrawerProps.StickyOffset;
|
|
107
108
|
/**
|
|
108
109
|
* Sets the CSS `z-index` of the drawer. Use this to control stacking order when the drawer
|
|
109
110
|
* overlaps other positioned elements on the page.
|
|
110
111
|
*
|
|
111
|
-
* Applicable when using `position="sticky"`, `position="absolute"`, or `position="fixed"`.
|
|
112
|
+
* Applicable when using `position="sticky"`, `position="absolute"`, or `position="fixed"`. Defaults to 830.
|
|
113
|
+
*
|
|
114
|
+
* Do not use this property when using drawers inside app layout.
|
|
112
115
|
*/
|
|
113
116
|
zIndex?: number;
|
|
114
117
|
/**
|
|
115
118
|
* When defined, renders a close button in the header with the provided configuration.
|
|
116
119
|
* The close button fires the `onClose` event with method `'close-action'` when
|
|
117
120
|
* clicked.
|
|
121
|
+
*
|
|
122
|
+
* Do not use this property when using drawers inside app layout.
|
|
118
123
|
*/
|
|
119
|
-
closeAction?:
|
|
124
|
+
closeAction?: DrawerProps.CloseActionProps;
|
|
120
125
|
/**
|
|
121
126
|
* Hides the close action slot next to the header actions, which is present even
|
|
122
127
|
* when close action is not set. Use it when a close action is not needed, or a
|
|
123
128
|
* custom close action implementation is used.
|
|
129
|
+
*
|
|
130
|
+
* Do not use this property when using drawers inside app layout.
|
|
124
131
|
*/
|
|
125
132
|
hideCloseAction?: boolean;
|
|
126
133
|
/**
|
|
@@ -128,13 +135,17 @@ export interface NextDrawerProps extends DrawerProps {
|
|
|
128
135
|
* * `'close-action'` - The close button was clicked.
|
|
129
136
|
* * `'backdrop-click'` - The backdrop was clicked (only when `backdrop=true`).
|
|
130
137
|
* * `'escape'` - The Escape key was pressed (only when `backdrop=true`).
|
|
138
|
+
*
|
|
139
|
+
* Do not use this property when using drawers inside app layout.
|
|
131
140
|
*/
|
|
132
|
-
onClose?: NonCancelableEventHandler<
|
|
141
|
+
onClose?: NonCancelableEventHandler<DrawerProps.CloseDetail>;
|
|
133
142
|
/**
|
|
134
143
|
* Drawer open state. Set to `true` to show the drawer, `false` to hide it.
|
|
135
144
|
* Handle the `onClose` event to update this value when the user requests to close the drawer.
|
|
136
145
|
*
|
|
137
146
|
* When the property is unset - the drawer is always visible, and the built-in focus in/out behaviors are disabled.
|
|
147
|
+
*
|
|
148
|
+
* Do not use this property when using drawers inside app layout.
|
|
138
149
|
*/
|
|
139
150
|
open?: boolean;
|
|
140
151
|
/**
|
|
@@ -144,6 +155,8 @@ export interface NextDrawerProps extends DrawerProps {
|
|
|
144
155
|
* When a backdrop is set, the keyboard focus is trapped inside the drawer by default
|
|
145
156
|
* to prevent it from moving to elements covered by the backdrop. This can be overridden
|
|
146
157
|
* with `focusBehavior.trapFocus`.
|
|
158
|
+
*
|
|
159
|
+
* Do not use this property when using drawers inside app layout.
|
|
147
160
|
*/
|
|
148
161
|
backdrop?: boolean;
|
|
149
162
|
/**
|
|
@@ -160,10 +173,15 @@ export interface NextDrawerProps extends DrawerProps {
|
|
|
160
173
|
* Use this to override where focus lands on close (e.g. a specific trigger element).
|
|
161
174
|
* If omitted, focus returns to the element that was focused when the drawer opened.
|
|
162
175
|
* If that element is no longer in the DOM, the behavior silently no-ops.
|
|
176
|
+
*
|
|
177
|
+
* Do not use this property when using drawers inside app layout.
|
|
163
178
|
*/
|
|
164
|
-
focusBehavior?:
|
|
179
|
+
focusBehavior?: DrawerProps.FocusBehavior;
|
|
165
180
|
}
|
|
166
|
-
export declare namespace
|
|
181
|
+
export declare namespace DrawerProps {
|
|
182
|
+
interface I18nStrings {
|
|
183
|
+
loadingText?: string;
|
|
184
|
+
}
|
|
167
185
|
type Position = 'static' | 'sticky' | 'absolute' | 'fixed';
|
|
168
186
|
type Placement = 'start' | 'end' | 'top' | 'bottom';
|
|
169
187
|
interface Offset {
|
|
@@ -176,6 +194,15 @@ export declare namespace NextDrawerProps {
|
|
|
176
194
|
top?: number;
|
|
177
195
|
bottom?: number;
|
|
178
196
|
}
|
|
197
|
+
interface CloseActionProps {
|
|
198
|
+
ariaLabel?: string;
|
|
199
|
+
disabled?: boolean;
|
|
200
|
+
disabledReason?: string;
|
|
201
|
+
iconName?: IconProps.Name;
|
|
202
|
+
iconUrl?: string;
|
|
203
|
+
iconSvg?: React.ReactNode;
|
|
204
|
+
iconAlt?: string;
|
|
205
|
+
}
|
|
179
206
|
interface CloseDetail {
|
|
180
207
|
method: 'close-action' | 'backdrop-click' | 'escape';
|
|
181
208
|
}
|
|
@@ -186,7 +213,7 @@ export declare namespace NextDrawerProps {
|
|
|
186
213
|
}
|
|
187
214
|
interface Ref {
|
|
188
215
|
/**
|
|
189
|
-
* Moves focus to the drawer element. Use
|
|
216
|
+
* Moves focus to the drawer element. Use when `focusBehavior.autoFocus`
|
|
190
217
|
* is disabled and you need to manage focus manually, or to focus a drawer, initially rendered
|
|
191
218
|
* with `open=true`. The drawer with `role="presentation"` cannot be focused.
|
|
192
219
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/drawer/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/drawer/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,WAAY,SAAQ,kBAAkB;IACrD;;;;OAIG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC;IAEtC;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEhC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;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