@cloudscape-design/components 3.0.1272 → 3.0.1273

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.
@@ -24,9 +24,9 @@ export interface CopyToClipboardProps extends BaseComponentProps {
24
24
  */
25
25
  textToCopy: string;
26
26
  /**
27
- * The text content to display next to the copy button when `variant="inline"`. If not provided, `textToCopy` will be displayed instead.
27
+ * The content to display next to the copy button when `variant="inline"`. If not provided, `textToCopy` will be displayed instead.
28
28
  */
29
- textToDisplay?: string;
29
+ textToDisplay?: React.ReactNode;
30
30
  /**
31
31
  * The message shown when the text is copied successfully.
32
32
  */
@@ -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,MAAM,CAAC;IAEvB;;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;IACnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,aAAa,CAAC,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,iBAAiB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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 text content to display next to the copy button when `variant=\"inline\"`. If not provided, `textToCopy` will be displayed instead.\n */\n textToDisplay?: string;\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 * 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 * 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"]}
@@ -59,6 +59,6 @@ export default function InternalCopyToClipboard({ variant = 'button', copyButton
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
60
  return (React.createElement("span", { ...baseProps, ref: __internalRootRef, className: clsx(baseProps.className, styles.root, testStyles.root) }, isInline ? (React.createElement("span", { className: styles['inline-container'] },
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 !== null && textToDisplay !== void 0 ? textToDisplay : textToCopy))) : (trigger)));
62
+ React.createElement("span", { className: clsx(testStyles['text-to-display'], testStyles['text-to-copy']) }, 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,OAAO,eAAe,MAAM,qBAAqB,CAAC;AAClD,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AAGnE,OAAO,MAAM,MAAM,iBAAiB,CA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BAAuB,IAAC,IAAI,EAAE,MAAM,IAAG,UAAU,CAA2B,EACtF,QAAQ,EAAE,OAAO,IAEhB,MAAM,CACS,CACnB,CAAC;IAEF,OAAO,CACL,iCAAU,SAAS,EAAE,GAAG,EAAE,iBAAiB,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,IAC5G,QAAQ,CAAC,CAAC,CAAC,CACV,8BAAM,SAAS,EAAE,MAAM,CAAC,kBAAkB,CAAC;QACzC,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,CAAC,IAC7E,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,UAAU,CACvB,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 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={styles['inline-container']}>\n <span className={styles['inline-container-trigger']}>{trigger}</span>\n <span className={clsx(testStyles['text-to-display'], testStyles['text-to-copy'])}>\n {textToDisplay ?? textToCopy}\n </span>\n </span>\n ) : (\n trigger\n )}\n </span>\n );\n}\n"]}
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,OAAO,eAAe,MAAM,qBAAqB,CAAC;AAClD,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AAGnE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,UAAU,MAAM,8BAA8B,CAAC;AAItD,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAC,EAC9C,OAAO,GAAG,QAAQ,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,EACiB;IAC7B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAkC,SAAS,CAAC,CAAC;IACjF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC;IAE9D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,CAAC,WAAW,EAAE,CAAC;YAC1B,SAAS,CAAC,WAAW;iBAClB,KAAK,CAAC,EAAE,IAAI,EAAE,iBAAmC,EAAE,CAAC;iBACpD,IAAI,CAAC,MAAM,CAAC,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ACF,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 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={styles['inline-container']}>\n <span className={styles['inline-container-trigger']}>{trigger}</span>\n <span className={clsx(testStyles['text-to-display'], testStyles['text-to-copy'])}>\n {textToDisplay !== undefined ? textToDisplay : textToCopy}\n </span>\n </span>\n ) : (\n trigger\n )}\n </span>\n );\n}\n"]}
@@ -2154,5 +2154,5 @@ body {
2154
2154
  }
2155
2155
  }
2156
2156
  :root {
2157
- --awsui-version-info-10ec7cdf: true;
2157
+ --awsui-version-info-7029006d: true;
2158
2158
  }
@@ -1,6 +1,6 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (10ec7cdf)";
3
- export var GIT_SHA = "10ec7cdf";
2
+ export var PACKAGE_VERSION = "3.0.0 (7029006d)";
3
+ export var GIT_SHA = "7029006d";
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 (10ec7cdf)",
4
- "GIT_SHA": "10ec7cdf",
3
+ "PACKAGE_VERSION": "3.0.0 (7029006d)",
4
+ "GIT_SHA": "7029006d",
5
5
  "THEME": "open-source-visual-refresh",
6
6
  "SYSTEM": "core",
7
7
  "ALWAYS_VISUAL_REFRESH": true
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "10ec7cdf2d7ea791fb43453e5fb4591270128272"
2
+ "commit": "7029006dd727c97699995fd347f834bb73f6ebdc"
3
3
  }
package/package.json CHANGED
@@ -163,7 +163,7 @@
163
163
  "./internal/base-component/index.js",
164
164
  "./internal/base-component/styles.css.js"
165
165
  ],
166
- "version": "3.0.1272",
166
+ "version": "3.0.1273",
167
167
  "repository": {
168
168
  "type": "git",
169
169
  "url": "https://github.com/cloudscape-design/components.git"