@cloudscape-design/components 3.0.1082 → 3.0.1083
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/badge/index.d.ts.map +1 -1
- package/badge/internal-do-not-use-core.js +1 -1
- package/badge/internal-do-not-use-core.js.map +1 -1
- package/box/index.js +13 -20
- package/box/interfaces.d.ts +14 -0
- package/box/interfaces.d.ts.map +1 -1
- package/box/interfaces.js.map +1 -1
- package/box/internal-do-not-use-core.js +25 -0
- package/box/internal.d.ts +1 -0
- package/box/internal.d.ts.map +1 -1
- package/box/internal.js +3 -5
- package/box/internal.js.map +1 -1
- package/button/internal.d.ts.map +1 -1
- package/button/internal.js +3 -3
- package/button/internal.js.map +1 -1
- package/checkbox/internal.d.ts.map +1 -1
- package/checkbox/internal.js +1 -1
- package/checkbox/internal.js.map +1 -1
- package/icon/internal.d.ts.map +1 -1
- package/icon/internal.js +3 -3
- package/icon/internal.js.map +1 -1
- package/internal/base-component/styles.scoped.css +1 -2
- package/internal/components/option/index.js +1 -1
- package/internal/components/option/index.js.map +1 -1
- package/internal/components/option/option-parts.js +1 -1
- package/internal/components/option/option-parts.js.map +1 -1
- package/internal/components/option/styles.css.js +16 -17
- package/internal/components/option/styles.scoped.css +28 -32
- package/internal/components/option/styles.selectors.js +16 -17
- package/internal/environment.js +2 -2
- package/internal/environment.json +2 -2
- package/internal/manifest.json +1 -1
- package/internal/utils/with-native-attributes.d.ts +1 -0
- package/internal/utils/with-native-attributes.d.ts.map +1 -1
- package/internal/utils/with-native-attributes.js +2 -2
- package/internal/utils/with-native-attributes.js.map +1 -1
- package/package.json +1 -1
- package/space-between/index.js +13 -12
- package/space-between/interfaces.d.ts +14 -0
- package/space-between/interfaces.d.ts.map +1 -1
- package/space-between/interfaces.js.map +1 -1
- package/space-between/internal-do-not-use-core.js +17 -0
- package/space-between/internal.d.ts.map +1 -1
- package/space-between/internal.js +3 -2
- package/space-between/internal.js.map +1 -1
- package/spinner/internal.d.ts.map +1 -1
- package/spinner/internal.js +1 -1
- package/spinner/internal.js.map +1 -1
- /package/box/{index.js.map → internal-do-not-use-core.js.map} +0 -0
- /package/space-between/{index.js.map → internal-do-not-use-core.js.map} +0 -0
package/badge/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/badge/index.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,KAAc,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/badge/index.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,KAAc,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,EAAE,UAAU,eAmBvG"}
|
|
@@ -15,7 +15,7 @@ export default function Badge(_a) {
|
|
|
15
15
|
const { __internalRootRef } = useBaseComponent('Badge', { props: { color } });
|
|
16
16
|
const baseProps = getBaseProps(rest);
|
|
17
17
|
const className = clsx(baseProps.className, styles.badge, styles[`badge-color-${color}`]);
|
|
18
|
-
return (React.createElement(WithNativeAttributes, Object.assign({}, baseProps, { tag: "span", nativeAttributes: nativeAttributes, className: className, ref: __internalRootRef, style: getBadgeStyles(style) }), children));
|
|
18
|
+
return (React.createElement(WithNativeAttributes, Object.assign({}, baseProps, { tag: "span", componentName: "Badge", nativeAttributes: nativeAttributes, className: className, ref: __internalRootRef, style: getBadgeStyles(style) }), children));
|
|
19
19
|
}
|
|
20
20
|
applyDisplayName(Badge, 'Badge');
|
|
21
21
|
//# sourceMappingURL=internal-do-not-use-core.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/badge/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,YAAY,CAAC;;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,oBAAoB,MAAM,0CAA0C,CAAC;AAE5E,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAA0E;QAA1E,EAAE,KAAK,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,OAAuB,EAAlB,IAAI,cAA5D,kDAA8D,CAAF;IACxF,MAAM,EAAE,iBAAiB,EAAE,GAAG,gBAAgB,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;IAC9E,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAErC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,eAAe,KAAK,EAAE,CAAC,CAAC,CAAC;IAE1F,OAAO,CACL,oBAAC,oBAAoB,oBACf,SAAS,IACb,GAAG,EAAC,MAAM,EACV,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,iBAAiB,EACtB,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,KAE3B,QAAQ,CACY,CACxB,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';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport WithNativeAttributes from '../internal/utils/with-native-attributes';\nimport { BadgeProps } from './interfaces';\nimport { getBadgeStyles } from './style';\n\nimport styles from './styles.css.js';\n\nexport { BadgeProps };\n\nexport default function Badge({ color = 'grey', children, style, nativeAttributes, ...rest }: BadgeProps) {\n const { __internalRootRef } = useBaseComponent('Badge', { props: { color } });\n const baseProps = getBaseProps(rest);\n\n const className = clsx(baseProps.className, styles.badge, styles[`badge-color-${color}`]);\n\n return (\n <WithNativeAttributes\n {...baseProps}\n tag=\"span\"\n nativeAttributes={nativeAttributes}\n className={className}\n ref={__internalRootRef}\n style={getBadgeStyles(style)}\n >\n {children}\n </WithNativeAttributes>\n );\n}\n\napplyDisplayName(Badge, 'Badge');\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/badge/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,YAAY,CAAC;;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,oBAAoB,MAAM,0CAA0C,CAAC;AAE5E,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAA0E;QAA1E,EAAE,KAAK,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,OAAuB,EAAlB,IAAI,cAA5D,kDAA8D,CAAF;IACxF,MAAM,EAAE,iBAAiB,EAAE,GAAG,gBAAgB,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;IAC9E,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAErC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,eAAe,KAAK,EAAE,CAAC,CAAC,CAAC;IAE1F,OAAO,CACL,oBAAC,oBAAoB,oBACf,SAAS,IACb,GAAG,EAAC,MAAM,EACV,aAAa,EAAC,OAAO,EACrB,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,iBAAiB,EACtB,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,KAE3B,QAAQ,CACY,CACxB,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';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport WithNativeAttributes from '../internal/utils/with-native-attributes';\nimport { BadgeProps } from './interfaces';\nimport { getBadgeStyles } from './style';\n\nimport styles from './styles.css.js';\n\nexport { BadgeProps };\n\nexport default function Badge({ color = 'grey', children, style, nativeAttributes, ...rest }: BadgeProps) {\n const { __internalRootRef } = useBaseComponent('Badge', { props: { color } });\n const baseProps = getBaseProps(rest);\n\n const className = clsx(baseProps.className, styles.badge, styles[`badge-color-${color}`]);\n\n return (\n <WithNativeAttributes\n {...baseProps}\n tag=\"span\"\n componentName=\"Badge\"\n nativeAttributes={nativeAttributes}\n className={className}\n ref={__internalRootRef}\n style={getBadgeStyles(style)}\n >\n {children}\n </WithNativeAttributes>\n );\n}\n\napplyDisplayName(Badge, 'Badge');\n"]}
|
package/box/index.js
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
'use client';
|
|
4
|
-
import { __rest } from "tslib";
|
|
5
3
|
import React from 'react';
|
|
6
|
-
|
|
4
|
+
|
|
5
|
+
import CoreComponent from './internal-do-not-use-core';
|
|
7
6
|
import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
textAlign: props.textAlign,
|
|
19
|
-
variant,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
return React.createElement(InternalBox, Object.assign({ variant: variant, margin: margin, padding: padding }, props, baseComponentProps));
|
|
23
|
-
}
|
|
7
|
+
import { validateProps } from '@cloudscape-design/component-toolkit/internal';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const Box = (props) => {
|
|
12
|
+
validateProps('Box', props, ["nativeAttributes"], {}, 'console');
|
|
13
|
+
return React.createElement(CoreComponent, props);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
|
|
24
17
|
applyDisplayName(Box, 'Box');
|
|
25
|
-
|
|
18
|
+
export default Box;
|
package/box/interfaces.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BaseComponentProps } from '../internal/base-component';
|
|
3
|
+
/**
|
|
4
|
+
* @awsuiSystem core
|
|
5
|
+
*/
|
|
6
|
+
|
|
3
7
|
export interface BoxProps extends BaseComponentProps {
|
|
4
8
|
/**
|
|
5
9
|
* Defines the style of element to display.
|
|
@@ -114,6 +118,16 @@ export interface BoxProps extends BaseComponentProps {
|
|
|
114
118
|
* @displayname content
|
|
115
119
|
*/
|
|
116
120
|
children?: React.ReactNode;
|
|
121
|
+
/**
|
|
122
|
+
* Attributes to add to the native element.
|
|
123
|
+
* Some attributes will be automatically combined with internal attribute values:
|
|
124
|
+
* - `className` will be appended.
|
|
125
|
+
* - Event handlers will be chained, unless the default is prevented.
|
|
126
|
+
*
|
|
127
|
+
* We do not support using this attribute to apply custom styling.
|
|
128
|
+
*
|
|
129
|
+
* @awsuiSystem core
|
|
130
|
+
*/
|
|
117
131
|
}
|
|
118
132
|
export declare namespace BoxProps {
|
|
119
133
|
type Variant = 'div' | 'span' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'p' | 'strong' | 'small' | 'code' | 'pre' | 'samp' | 'awsui-key-label' | 'awsui-gen-ai-label' | 'awsui-value-large';
|
package/box/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/box/interfaces.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/box/interfaces.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAE5E,MAAM,WAAW,QAAS,SAAQ,kBAAkB;IAClD;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;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AChB,QAAQ,GACR,QAAQ,GACR,YAAY,GACZ,WAAW,GACX,WAAW,GACX,WAAW,GACX,YAAY,GACZ,WAAW,CAAC;IAChB,KAAY,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAC/D,KAAY,KAAK,GACb,SAAS,GACT,YAAY,GACZ,qBAAqB,GACrB,mBAAmB,GACnB,qBAAqB,GACrB,kBAAkB,GAClB,sBAAsB,GACtB,qBAAqB,CAAC;IAC1B,KAAY,WAAW,GAAG,GAAG,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM,CAAC;IAChG,UAAiB,OAAO;QACtB,GAAG,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC;QAC3B,KAAK,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC;QAC7B,MAAM,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC;QAC9B,IAAI,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC;QAC5B,UAAU,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC;QAClC,QAAQ,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC;KACjC;CACF"}
|
package/box/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/box/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\n\nexport interface BoxProps extends BaseComponentProps {\n /**\n * Defines the style of element to display.\n *\n * - If you set it to `'div'`, `'span'`, `'h1'`, `'h2'`, `'h3'`, `'h4'`, `'h5'`, `'p'`, `'strong'`, `'small'`, `'code'`, `'pre'`, or `'samp'`, the variant is also used as the HTML tag name.\n * - If you set it to `awsui-key-label`, the component will render a `div`,\n * styled for use as a key label in key-value pairs.\n * - If you set it to `awsui-gen-ai-label`, the component will render a `div`,\n * styled for use as a label indicating that content is produced by generative AI.\n * - If you set it to `awsui-value-large`, the component will render a `span`,\n * styled using \"Display large light\" typography.\n *\n * Override the HTML tag by using property `tagOverride`.\n */\n variant?: BoxProps.Variant;\n /**\n * Overrides the default HTML tag provided by the variant.\n */\n tagOverride?: string;\n /**\n * Overrides the display of the element. You can set it to the following values:\n *\n * - `block` - Specifies block display.\n * - `inline` - Specifies inline display.\n * - `inline-block` - Specifies inline-block display.\n * - `none` - Hides the box.\n *\n * Note: If you don't set it, the display depends on the variant.\n */\n display?: BoxProps.Display;\n /**\n * Adds margins to the element. It can be the following:\n *\n * - A single string with a size. This applies the same margin to all sides (that is, top, right, bottom, left).\n * - An object specifying the size of the margin per side. The object has the following format:\n * ```\n * {\n * top: \"size of top margin\",\n * right: \"size of right margin\",\n * bottom: \"size of bottom margin\",\n * left: \"size of left margin\",\n * horizontal: \"size of left and right margin\",\n * vertical: \"size of top and bottom margin\",\n * }\n * ```\n *\n * The size can be `n`, `xxxs`, `xxs`, `xs`, `s`, `m`, `l`, `xl`, `xxl`, `xxxl`, where `n` stands for none.\n * Sizes are automatically scaled down in compact mode.\n *\n * For example, `margin=\"s\"` adds a small margin to all sides.\n * `margin={{ right: \"l\", bottom: \"s\" }}` adds a small margin to the bottom and a large margin to the right.\n */\n margin?: BoxProps.SpacingSize | BoxProps.Spacing;\n /**\n * Adds padding to the element. It can be the following:\n *\n * - A single string with a size. This applies the same padding to all sides (that is, top, right, bottom, left).\n * - An object specifying the size of padding per side. The object has the following format:\n * ```\n * {\n * top: \"size of top padding\",\n * right: \"size of right padding\",\n * bottom: \"size of bottom padding\",\n * left: \"size of left padding\",\n * horizontal: \"size of left and right padding\",\n * vertical: \"size of top and bottom padding\",\n * }\n * ```\n *\n * The size can be `n`, `xxxs`, `xxs`, `xs`, `s`, `m`, `l`, `xl`, `xxl`, `xxxl`, where `n` stands for none.\n * Sizes are automatically scaled down in compact mode.\n *\n * For example, `padding=\"s\"` adds small padding to all sides.\n * `padding={{ right: \"l\", bottom: \"s\" }}` adds small padding to the bottom and large padding to the right.\n */\n padding?: BoxProps.SpacingSize | BoxProps.Spacing;\n /**\n * Defines the text alignment within the element. You can set it to `left`, `center`, or `right`.\n */\n textAlign?: BoxProps.TextAlign;\n /**\n * Defines the floating behavior. You can set it to `left` or `right`.\n */\n float?: BoxProps.Float;\n /**\n * Overrides the font size and line height. If not set, the font size and line height depend on the variant.\n */\n fontSize?: BoxProps.FontSize;\n /**\n * Overrides the font weight. If not set, the value depends on the variant.\n * @visualrefresh 'heavy'\n */\n fontWeight?: BoxProps.FontWeight;\n /**\n * Overrides the text color. You can set it to the following values:\n *\n * - `inherit` - Inherits the color from the parent element. For example, use this to style content\n * in Flashbars and to style the `empty` and `noMatch` slots of the Table and Cards components.\n * - `text-label` - Specifies the text color for non-form labels. For example, use it for the key in key/value pairs.\n * - `text-body-secondary` - Specifies the color for secondary text.\n * - `text-status-error` - Specifies the color for error text and icons.\n * - `text-status-success` - Specifies the color for success text and icons.\n * - `text-status-info` - Specifies the color for info text and icon.\n * - `text-status-inactive` - Specifies the color for inactive and loading text and icons.\n * - `text-status-warning` - Specifies the color for warning text and icons.\n *\n * Note: If you don't set it, the text color depends on the variant.\n */\n color?: BoxProps.Color;\n /**\n * Content of the box.\n * @displayname content\n */\n children?: React.ReactNode;\n}\n\nexport namespace BoxProps {\n export type Variant =\n | 'div'\n | 'span'\n | 'h1'\n | 'h2'\n | 'h3'\n | 'h4'\n | 'h5'\n | 'p'\n | 'strong'\n | 'small'\n | 'code'\n | 'pre'\n | 'samp'\n | 'awsui-key-label'\n | 'awsui-gen-ai-label'\n | 'awsui-value-large';\n\n export type Display = 'block' | 'inline' | 'inline-block' | 'none';\n export type TextAlign = 'left' | 'center' | 'right';\n export type Float = 'left' | 'right';\n export type FontSize =\n | 'body-s'\n | 'body-m'\n | 'heading-xs'\n | 'heading-s'\n | 'heading-m'\n | 'heading-l'\n | 'heading-xl'\n | 'display-l';\n export type FontWeight = 'light' | 'normal' | 'bold' | 'heavy';\n export type Color =\n | 'inherit'\n | 'text-label'\n | 'text-body-secondary'\n | 'text-status-error'\n | 'text-status-success'\n | 'text-status-info'\n | 'text-status-inactive'\n | 'text-status-warning';\n export type SpacingSize = 'n' | 'xxxs' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';\n export interface Spacing {\n top?: BoxProps.SpacingSize;\n right?: BoxProps.SpacingSize;\n bottom?: BoxProps.SpacingSize;\n left?: BoxProps.SpacingSize;\n horizontal?: BoxProps.SpacingSize;\n vertical?: BoxProps.SpacingSize;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/box/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\n/**\n * @awsuiSystem core\n */\nimport { NativeAttributes } from '../internal/utils/with-native-attributes';\n\nexport interface BoxProps extends BaseComponentProps {\n /**\n * Defines the style of element to display.\n *\n * - If you set it to `'div'`, `'span'`, `'h1'`, `'h2'`, `'h3'`, `'h4'`, `'h5'`, `'p'`, `'strong'`, `'small'`, `'code'`, `'pre'`, or `'samp'`, the variant is also used as the HTML tag name.\n * - If you set it to `awsui-key-label`, the component will render a `div`,\n * styled for use as a key label in key-value pairs.\n * - If you set it to `awsui-gen-ai-label`, the component will render a `div`,\n * styled for use as a label indicating that content is produced by generative AI.\n * - If you set it to `awsui-value-large`, the component will render a `span`,\n * styled using \"Display large light\" typography.\n *\n * Override the HTML tag by using property `tagOverride`.\n */\n variant?: BoxProps.Variant;\n /**\n * Overrides the default HTML tag provided by the variant.\n */\n tagOverride?: string;\n /**\n * Overrides the display of the element. You can set it to the following values:\n *\n * - `block` - Specifies block display.\n * - `inline` - Specifies inline display.\n * - `inline-block` - Specifies inline-block display.\n * - `none` - Hides the box.\n *\n * Note: If you don't set it, the display depends on the variant.\n */\n display?: BoxProps.Display;\n /**\n * Adds margins to the element. It can be the following:\n *\n * - A single string with a size. This applies the same margin to all sides (that is, top, right, bottom, left).\n * - An object specifying the size of the margin per side. The object has the following format:\n * ```\n * {\n * top: \"size of top margin\",\n * right: \"size of right margin\",\n * bottom: \"size of bottom margin\",\n * left: \"size of left margin\",\n * horizontal: \"size of left and right margin\",\n * vertical: \"size of top and bottom margin\",\n * }\n * ```\n *\n * The size can be `n`, `xxxs`, `xxs`, `xs`, `s`, `m`, `l`, `xl`, `xxl`, `xxxl`, where `n` stands for none.\n * Sizes are automatically scaled down in compact mode.\n *\n * For example, `margin=\"s\"` adds a small margin to all sides.\n * `margin={{ right: \"l\", bottom: \"s\" }}` adds a small margin to the bottom and a large margin to the right.\n */\n margin?: BoxProps.SpacingSize | BoxProps.Spacing;\n /**\n * Adds padding to the element. It can be the following:\n *\n * - A single string with a size. This applies the same padding to all sides (that is, top, right, bottom, left).\n * - An object specifying the size of padding per side. The object has the following format:\n * ```\n * {\n * top: \"size of top padding\",\n * right: \"size of right padding\",\n * bottom: \"size of bottom padding\",\n * left: \"size of left padding\",\n * horizontal: \"size of left and right padding\",\n * vertical: \"size of top and bottom padding\",\n * }\n * ```\n *\n * The size can be `n`, `xxxs`, `xxs`, `xs`, `s`, `m`, `l`, `xl`, `xxl`, `xxxl`, where `n` stands for none.\n * Sizes are automatically scaled down in compact mode.\n *\n * For example, `padding=\"s\"` adds small padding to all sides.\n * `padding={{ right: \"l\", bottom: \"s\" }}` adds small padding to the bottom and large padding to the right.\n */\n padding?: BoxProps.SpacingSize | BoxProps.Spacing;\n /**\n * Defines the text alignment within the element. You can set it to `left`, `center`, or `right`.\n */\n textAlign?: BoxProps.TextAlign;\n /**\n * Defines the floating behavior. You can set it to `left` or `right`.\n */\n float?: BoxProps.Float;\n /**\n * Overrides the font size and line height. If not set, the font size and line height depend on the variant.\n */\n fontSize?: BoxProps.FontSize;\n /**\n * Overrides the font weight. If not set, the value depends on the variant.\n * @visualrefresh 'heavy'\n */\n fontWeight?: BoxProps.FontWeight;\n /**\n * Overrides the text color. You can set it to the following values:\n *\n * - `inherit` - Inherits the color from the parent element. For example, use this to style content\n * in Flashbars and to style the `empty` and `noMatch` slots of the Table and Cards components.\n * - `text-label` - Specifies the text color for non-form labels. For example, use it for the key in key/value pairs.\n * - `text-body-secondary` - Specifies the color for secondary text.\n * - `text-status-error` - Specifies the color for error text and icons.\n * - `text-status-success` - Specifies the color for success text and icons.\n * - `text-status-info` - Specifies the color for info text and icon.\n * - `text-status-inactive` - Specifies the color for inactive and loading text and icons.\n * - `text-status-warning` - Specifies the color for warning text and icons.\n *\n * Note: If you don't set it, the text color depends on the variant.\n */\n color?: BoxProps.Color;\n /**\n * Content of the box.\n * @displayname content\n */\n children?: React.ReactNode;\n\n /**\n * Attributes to add to the native element.\n * Some attributes will be automatically combined with internal attribute values:\n * - `className` will be appended.\n * - Event handlers will be chained, unless the default is prevented.\n *\n * We do not support using this attribute to apply custom styling.\n *\n * @awsuiSystem core\n */\n nativeAttributes?: NativeAttributes<React.HTMLAttributes<HTMLElement>>;\n}\n\nexport namespace BoxProps {\n export type Variant =\n | 'div'\n | 'span'\n | 'h1'\n | 'h2'\n | 'h3'\n | 'h4'\n | 'h5'\n | 'p'\n | 'strong'\n | 'small'\n | 'code'\n | 'pre'\n | 'samp'\n | 'awsui-key-label'\n | 'awsui-gen-ai-label'\n | 'awsui-value-large';\n\n export type Display = 'block' | 'inline' | 'inline-block' | 'none';\n export type TextAlign = 'left' | 'center' | 'right';\n export type Float = 'left' | 'right';\n export type FontSize =\n | 'body-s'\n | 'body-m'\n | 'heading-xs'\n | 'heading-s'\n | 'heading-m'\n | 'heading-l'\n | 'heading-xl'\n | 'display-l';\n export type FontWeight = 'light' | 'normal' | 'bold' | 'heavy';\n export type Color =\n | 'inherit'\n | 'text-label'\n | 'text-body-secondary'\n | 'text-status-error'\n | 'text-status-success'\n | 'text-status-info'\n | 'text-status-inactive'\n | 'text-status-warning';\n export type SpacingSize = 'n' | 'xxxs' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';\n export interface Spacing {\n top?: BoxProps.SpacingSize;\n right?: BoxProps.SpacingSize;\n bottom?: BoxProps.SpacingSize;\n left?: BoxProps.SpacingSize;\n horizontal?: BoxProps.SpacingSize;\n vertical?: BoxProps.SpacingSize;\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
'use client';
|
|
4
|
+
import { __rest } from "tslib";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
7
|
+
import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
8
|
+
import InternalBox from './internal';
|
|
9
|
+
export default function Box(_a) {
|
|
10
|
+
var { variant = 'div', margin = {}, padding = {} } = _a, props = __rest(_a, ["variant", "margin", "padding"]);
|
|
11
|
+
const baseComponentProps = useBaseComponent('Box', {
|
|
12
|
+
props: {
|
|
13
|
+
color: props.color,
|
|
14
|
+
display: props.display,
|
|
15
|
+
float: props.float,
|
|
16
|
+
fontSize: props.fontSize,
|
|
17
|
+
fontWeight: props.fontWeight,
|
|
18
|
+
textAlign: props.textAlign,
|
|
19
|
+
variant,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
return React.createElement(InternalBox, Object.assign({ variant: variant, margin: margin, padding: padding }, props, baseComponentProps));
|
|
23
|
+
}
|
|
24
|
+
applyDisplayName(Box, 'Box');
|
|
25
|
+
//# sourceMappingURL=internal-do-not-use-core.js.map
|
package/box/internal.d.ts
CHANGED
package/box/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/box/internal.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/box/internal.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAIxC,KAAK,gBAAgB,GAAG,QAAQ,GAAG,0BAA0B,CAAC;AAE9D,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,OAAe,EACf,WAAW,EACX,MAAW,EACX,OAAY,EACZ,OAAO,EACP,SAAS,EACT,KAAK,EACL,QAAQ,EACR,UAAU,EACV,KAAK,EACL,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,EACjB,GAAG,KAAK,EACT,EAAE,gBAAgB,eAgClB"}
|
package/box/internal.js
CHANGED
|
@@ -4,17 +4,15 @@ import { __rest } from "tslib";
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { getBaseProps } from '../internal/base-component';
|
|
7
|
+
import WithNativeAttributes from '../internal/utils/with-native-attributes';
|
|
7
8
|
import styles from './styles.css.js';
|
|
8
9
|
export default function InternalBox(_a) {
|
|
9
|
-
var { variant = 'div', tagOverride, margin = {}, padding = {}, display, textAlign, float, fontSize, fontWeight, color, children, __internalRootRef } = _a, props = __rest(_a, ["variant", "tagOverride", "margin", "padding", "display", "textAlign", "float", "fontSize", "fontWeight", "color", "children", "__internalRootRef"]);
|
|
10
|
+
var { variant = 'div', tagOverride, margin = {}, padding = {}, display, textAlign, float, fontSize, fontWeight, color, children, nativeAttributes, __internalRootRef } = _a, props = __rest(_a, ["variant", "tagOverride", "margin", "padding", "display", "textAlign", "float", "fontSize", "fontWeight", "color", "children", "nativeAttributes", "__internalRootRef"]);
|
|
10
11
|
const baseProps = getBaseProps(props);
|
|
11
12
|
const marginsClassNamesSuffices = getClassNamesSuffixes(margin);
|
|
12
13
|
const paddingsClassNamesSuffices = getClassNamesSuffixes(padding);
|
|
13
|
-
// This can be any arbitrary string if passed into tagOverride.
|
|
14
|
-
// We appease the compiler with an incorrect type.
|
|
15
|
-
const Tag = getTag(variant, tagOverride);
|
|
16
14
|
const className = clsx(baseProps.className, styles.root, styles.box, styles[`${variant.replace(/^awsui-/, '')}-variant`], marginsClassNamesSuffices.map(suffix => styles[`m-${suffix}`]), paddingsClassNamesSuffices.map(suffix => styles[`p-${suffix}`]), styles[`d-${display}`], styles[`f-${float}`], styles[`color-${color || 'default'}`], styles[`font-size-${fontSize || 'default'}`], styles[`font-weight-${fontWeight || 'default'}`], styles[`t-${textAlign}`]);
|
|
17
|
-
return (React.createElement(
|
|
15
|
+
return (React.createElement(WithNativeAttributes, Object.assign({}, baseProps, { tag: getTag(variant, tagOverride), componentName: "Box", nativeAttributes: nativeAttributes, className: className, ref: __internalRootRef }), children));
|
|
18
16
|
}
|
|
19
17
|
const getClassNamesSuffixes = (value) => {
|
|
20
18
|
if (typeof value === 'string') {
|
package/box/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/box/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/box/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,oBAAoB,MAAM,0CAA0C,CAAC;A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EAAE,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,EACjC,aAAa,EAAC,KAAK,EACnB,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,iBAAiB,KAErB,QAAQ,CACY,CACxB,CAAC;AACJ,CAAC;AAED,MAAM,qBAAqB,GAAG,CAAC,KAA8C,EAAE,EAAE;IAC/E,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,CAAC,KAAK,CAAC,CAAC;KAChB;IACD,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,CAAU,CAAC;IACpF,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACnF,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,OAAyB,EAAE,WAAoC,EAAE,EAAE;IACjF,IAAI,WAAW,EAAE;QACf,OAAO,WAAW,CAAC;KACpB;IAED,IAAI,OAAO,KAAK,mBAAmB,EAAE;QACnC,OAAO,MAAM,CAAC;KACf;IAED,IAAI,OAAO,KAAK,iBAAiB,IAAI,OAAO,KAAK,oBAAoB,EAAE;QACrE,OAAO,KAAK,CAAC;KACd;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport WithNativeAttributes from '../internal/utils/with-native-attributes';\nimport { BoxProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\ntype InternalBoxProps = BoxProps & InternalBaseComponentProps;\n\nexport default function InternalBox({\n variant = 'div',\n tagOverride,\n margin = {},\n padding = {},\n display,\n textAlign,\n float,\n fontSize,\n fontWeight,\n color,\n children,\n nativeAttributes,\n __internalRootRef,\n ...props\n}: InternalBoxProps) {\n const baseProps = getBaseProps(props);\n const marginsClassNamesSuffices = getClassNamesSuffixes(margin);\n const paddingsClassNamesSuffices = getClassNamesSuffixes(padding);\n\n const className = clsx(\n baseProps.className,\n styles.root,\n styles.box,\n styles[`${variant.replace(/^awsui-/, '')}-variant`],\n marginsClassNamesSuffices.map(suffix => styles[`m-${suffix}`]),\n paddingsClassNamesSuffices.map(suffix => styles[`p-${suffix}`]),\n styles[`d-${display}`],\n styles[`f-${float}`],\n styles[`color-${color || 'default'}`],\n styles[`font-size-${fontSize || 'default'}`],\n styles[`font-weight-${fontWeight || 'default'}`],\n styles[`t-${textAlign}`]\n );\n\n return (\n <WithNativeAttributes\n {...baseProps}\n tag={getTag(variant, tagOverride)}\n componentName=\"Box\"\n nativeAttributes={nativeAttributes}\n className={className}\n ref={__internalRootRef}\n >\n {children}\n </WithNativeAttributes>\n );\n}\n\nconst getClassNamesSuffixes = (value: BoxProps.SpacingSize | BoxProps.Spacing) => {\n if (typeof value === 'string') {\n return [value];\n }\n const sides = ['top', 'right', 'bottom', 'left', 'horizontal', 'vertical'] as const;\n return sides.filter(side => !!value[side]).map(side => `${side}-${value[side]}`);\n};\n\nconst getTag = (variant: BoxProps.Variant, tagOverride: BoxProps['tagOverride']) => {\n if (tagOverride) {\n return tagOverride;\n }\n\n if (variant === 'awsui-value-large') {\n return 'span';\n }\n\n if (variant === 'awsui-key-label' || variant === 'awsui-gen-ai-label') {\n return 'div';\n }\n\n return variant;\n};\n"]}
|
package/button/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/button/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA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KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kCAAkC,CAAC,EAAE,OAAO,CAAC;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,8BAA8B,CAAC,EAAE,OAAO,CAAC;IACzC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,GAAG,0BAA0B,CAAC;AAE/B,eAAO,MAAM,cAAc;cAjBrB,WAAW,CAAC,SAAS,CAAC,GACtB,eAAe,GACf,kBAAkB,GAClB,cAAc,GACd,eAAe,GACf,4BAA4B;;;;;;;;;;sEA2TjC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
package/button/internal.js
CHANGED
|
@@ -161,15 +161,15 @@ export const InternalButton = React.forwardRef((_a, ref) => {
|
|
|
161
161
|
return buttonProps.tabIndex;
|
|
162
162
|
};
|
|
163
163
|
return (React.createElement(React.Fragment, null,
|
|
164
|
-
React.createElement(WithNativeAttributes, Object.assign({ tag: "a", nativeAttributes: nativeAnchorAttributes, skipWarnings: __skipNativeAttributesWarnings
|
|
164
|
+
React.createElement(WithNativeAttributes, Object.assign({}, buttonProps, disabledReasonProps, { tag: "a", componentName: "Button", nativeAttributes: nativeAnchorAttributes, skipWarnings: __skipNativeAttributesWarnings, href: isNotInteractive ? undefined : href, role: isNotInteractive ? 'link' : undefined, tabIndex: getAnchorTabIndex(), target: target,
|
|
165
165
|
// security recommendation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target
|
|
166
|
-
rel: rel !== null && rel !== void 0 ? rel : (target === '_blank' ? 'noopener noreferrer' : undefined), "aria-disabled": isNotInteractive ? true : undefined, download: download
|
|
166
|
+
rel: rel !== null && rel !== void 0 ? rel : (target === '_blank' ? 'noopener noreferrer' : undefined), "aria-disabled": isNotInteractive ? true : undefined, download: download, style: stylePropertiesAndVariables }),
|
|
167
167
|
buttonContent,
|
|
168
168
|
isDisabledWithReason && disabledReasonContent),
|
|
169
169
|
loading && loadingText && (React.createElement(InternalLiveRegion, { tagName: "span", hidden: true }, loadingText))));
|
|
170
170
|
}
|
|
171
171
|
return (React.createElement(React.Fragment, null,
|
|
172
|
-
React.createElement(WithNativeAttributes, Object.assign({ tag: "button", nativeAttributes: nativeButtonAttributes, skipWarnings: __skipNativeAttributesWarnings
|
|
172
|
+
React.createElement(WithNativeAttributes, Object.assign({}, buttonProps, disabledReasonProps, { tag: "button", componentName: "Button", nativeAttributes: nativeButtonAttributes, skipWarnings: __skipNativeAttributesWarnings, type: formAction === 'none' ? 'button' : 'submit', disabled: disabled && !__focusable && !isDisabledWithReason, "aria-disabled": hasAriaDisabled ? true : undefined, style: stylePropertiesAndVariables }),
|
|
173
173
|
buttonContent,
|
|
174
174
|
isDisabledWithReason && disabledReasonContent),
|
|
175
175
|
loading && loadingText && (React.createElement(InternalLiveRegion, { tagName: "span", hidden: true }, loadingText))));
|
package/button/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/button/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACpG,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,kEAAkE,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,E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C7C,mBAAmB,IACvB,KAAK,EAAE,2BAA2B;YAEjC,aAAa;YACb,oBAAoB,IAAI,qBAAqB,CACzB;QACtB,OAAO,IAAI,WAAW,IAAI,CACzB,oBAAC,kBAAkB,IAAC,OAAO,EAAC,MAAM,EAAC,MAAM,EAAE,IAAI,IAC5C,WAAW,CACO,CACtB,CACA,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { useSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal';\nimport {\n getAnalyticsLabelAttribute,\n getAnalyticsMetadataAttribute,\n} from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { useInternalI18n } from '../i18n/context';\nimport Icon from '../icon/internal';\nimport { FunnelMetrics } from '../internal/analytics';\nimport { useFunnel, useFunnelStep, useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport {\n DATA_ATTR_FUNNEL_VALUE,\n getFunnelValueSelector,\n getSubStepAllSelector,\n getTextFromSelector,\n} from '../internal/analytics/selectors';\nimport Tooltip from '../internal/components/tooltip/index.js';\nimport { useButtonContext } from '../internal/context/button-context';\nimport { fireCancelableEvent, isPlainLeftClick } from '../internal/events';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport useHiddenDescription from '../internal/hooks/use-hidden-description';\nimport { useModalContextLoadingButtonComponent } from '../internal/hooks/use-modal-component-analytics';\nimport { usePerformanceMarks } from '../internal/hooks/use-performance-marks';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport WithNativeAttributes from '../internal/utils/with-native-attributes';\nimport InternalLiveRegion from '../live-region/internal';\nimport { GeneratedAnalyticsMetadataButtonFragment } from './analytics-metadata/interfaces';\nimport { ButtonIconProps, LeftIcon, RightIcon } from './icon-helper';\nimport { ButtonProps } from './interfaces';\nimport { getButtonStyles } from './style';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\nimport testUtilStyles from './test-classes/styles.css.js';\n\nexport type InternalButtonProps = Omit<ButtonProps, 'variant'> & {\n variant?:\n | ButtonProps['variant']\n | 'flashbar-icon'\n | 'breadcrumb-group'\n | 'menu-trigger'\n | 'modal-dismiss'\n | 'inline-icon-pointer-target';\n badge?: boolean;\n analyticsAction?: string;\n __iconClass?: string;\n __focusable?: boolean;\n __injectAnalyticsComponentMetadata?: boolean;\n __title?: string;\n __emitPerformanceMarks?: boolean;\n __skipNativeAttributesWarnings?: boolean;\n __hideFromTestUtils?: boolean;\n} & InternalBaseComponentProps;\n\nexport const InternalButton = React.forwardRef(\n (\n {\n children,\n iconName,\n __iconClass,\n onClick,\n onFollow,\n iconAlign = 'left',\n iconUrl,\n iconSvg,\n iconAlt,\n variant = 'normal',\n loading = false,\n loadingText,\n disabled = false,\n disabledReason,\n wrapText = true,\n href,\n external,\n target: targetOverride,\n rel,\n download,\n formAction = 'submit',\n ariaLabel,\n ariaDescribedby,\n ariaExpanded,\n ariaControls,\n fullWidth,\n badge,\n i18nStrings,\n style,\n nativeButtonAttributes,\n nativeAnchorAttributes,\n __internalRootRef,\n __focusable = false,\n __injectAnalyticsComponentMetadata = false,\n __title,\n __emitPerformanceMarks = true,\n __skipNativeAttributesWarnings,\n __hideFromTestUtils = false,\n analyticsAction = 'click',\n ...props\n }: InternalButtonProps,\n ref: React.Ref<ButtonProps.Ref>\n ) => {\n const [showTooltip, setShowTooltip] = useState(false);\n\n checkSafeUrl('Button', href);\n const isAnchor = Boolean(href);\n const target = targetOverride ?? (external ? '_blank' : undefined);\n const isNotInteractive = loading || disabled;\n const isDisabledWithReason =\n (variant === 'normal' || variant === 'primary' || variant === 'icon') && !!disabledReason && disabled;\n\n const hasAriaDisabled = (loading && !disabled) || (disabled && __focusable) || isDisabledWithReason;\n const shouldHaveContent =\n children &&\n ['icon', 'inline-icon', 'flashbar-icon', 'modal-dismiss', 'inline-icon-pointer-target'].indexOf(variant) === -1;\n\n if ((iconName || iconUrl || iconSvg) && iconAlign === 'right' && external) {\n warnOnce('Button', 'A right-aligned icon should not be combined with an external icon.');\n }\n\n const buttonRef = useRef<HTMLElement>(null);\n useForwardFocus(ref, buttonRef);\n\n const buttonContext = useButtonContext();\n const i18n = useInternalI18n('button');\n\n const uniqueId = useUniqueId('button');\n const { funnelInteractionId } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n const { subStepSelector, subStepNameSelector } = useFunnelSubStep();\n\n const performanceMarkAttributes = usePerformanceMarks(\n 'primaryButton',\n () => variant === 'primary' && __emitPerformanceMarks && !loading && !disabled,\n buttonRef,\n () => ({\n loading,\n disabled,\n text: buttonRef.current?.innerText,\n }),\n [loading, disabled]\n );\n useModalContextLoadingButtonComponent(variant === 'primary', loading);\n\n const { targetProps, descriptionEl } = useHiddenDescription(disabledReason);\n\n const handleClick = (event: React.MouseEvent) => {\n if (isNotInteractive) {\n return event.preventDefault();\n }\n\n if (isAnchor && isPlainLeftClick(event)) {\n fireCancelableEvent(onFollow, { href, target }, event);\n\n if ((iconName === 'external' || target === '_blank') && funnelInteractionId) {\n const stepName = getTextFromSelector(stepNameSelector);\n const subStepName = getTextFromSelector(subStepNameSelector);\n\n FunnelMetrics.externalLinkInteracted({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepSelector,\n subStepName,\n subStepNameSelector,\n elementSelector: getFunnelValueSelector(uniqueId),\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n }\n\n const { altKey, button, ctrlKey, metaKey, shiftKey } = event;\n fireCancelableEvent(onClick, { altKey, button, ctrlKey, metaKey, shiftKey }, event);\n buttonContext.onClick({ variant });\n };\n\n const buttonClass = clsx(props.className, styles.button, styles[`variant-${variant}`], {\n [testUtilStyles.button]: !__hideFromTestUtils,\n [styles.disabled]: isNotInteractive,\n [styles['disabled-with-reason']]: isDisabledWithReason,\n [styles['button-no-wrap']]: !wrapText,\n [styles['button-no-text']]: !shouldHaveContent,\n [styles['full-width']]: shouldHaveContent && fullWidth,\n [styles.link]: isAnchor,\n });\n\n const explicitTabIndex = nativeButtonAttributes?.tabIndex ?? nativeAnchorAttributes?.tabIndex;\n const { tabIndex } = useSingleTabStopNavigation(buttonRef, {\n tabIndex: isAnchor && isNotInteractive && !isDisabledWithReason ? -1 : explicitTabIndex,\n });\n\n const analyticsMetadata: GeneratedAnalyticsMetadataButtonFragment = disabled\n ? {}\n : {\n action: analyticsAction,\n detail: { label: { root: 'self' } },\n };\n if (__injectAnalyticsComponentMetadata) {\n analyticsMetadata.component = {\n name: 'awsui.Button',\n label: { root: 'self' },\n properties: { variant, disabled: `${disabled}` },\n };\n }\n\n const buttonProps = {\n ...props,\n ...performanceMarkAttributes,\n tabIndex,\n // https://github.com/microsoft/TypeScript/issues/36659\n ref: useMergeRefs(buttonRef, __internalRootRef),\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedby,\n 'aria-expanded': ariaExpanded,\n 'aria-controls': ariaControls,\n // add ariaLabel as `title` as visible hint text\n title: __title ?? ariaLabel,\n className: buttonClass,\n onClick: handleClick,\n [DATA_ATTR_FUNNEL_VALUE]: uniqueId,\n ...getAnalyticsMetadataAttribute(analyticsMetadata),\n ...getAnalyticsLabelAttribute(shouldHaveContent ? `.${analyticsSelectors.label}` : ''),\n } as const;\n\n const iconProps: ButtonIconProps = {\n loading,\n iconName,\n iconAlign,\n iconUrl,\n iconSvg,\n iconAlt,\n variant,\n badge,\n iconClass: __iconClass,\n iconSize: variant === 'modal-dismiss' ? 'medium' : 'normal',\n };\n const buttonContent = (\n <>\n <LeftIcon {...iconProps} />\n {shouldHaveContent && (\n <>\n <span className={clsx(testUtilStyles.content, analyticsSelectors.label)}>{children}</span>\n {external && (\n <>\n \n <Icon\n name=\"external\"\n className={testUtilStyles['external-icon']}\n ariaLabel={i18n('i18nStrings.externalIconAriaLabel', i18nStrings?.externalIconAriaLabel)}\n />\n </>\n )}\n </>\n )}\n <RightIcon {...iconProps} />\n </>\n );\n\n const { loadingButtonCount } = useFunnel();\n useEffect(() => {\n if (loading) {\n loadingButtonCount.current++;\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n loadingButtonCount.current--;\n };\n }\n }, [loading, loadingButtonCount]);\n\n const disabledReasonProps = {\n onFocus: isDisabledWithReason ? () => setShowTooltip(true) : undefined,\n onBlur: isDisabledWithReason ? () => setShowTooltip(false) : undefined,\n onMouseEnter: isDisabledWithReason ? () => setShowTooltip(true) : undefined,\n onMouseLeave: isDisabledWithReason ? () => setShowTooltip(false) : undefined,\n ...(isDisabledWithReason ? targetProps : {}),\n };\n const disabledReasonContent = (\n <>\n {descriptionEl}\n {showTooltip && (\n <Tooltip\n className={testUtilStyles['disabled-reason-tooltip']}\n trackRef={buttonRef}\n value={disabledReason!}\n onDismiss={() => setShowTooltip(false)}\n />\n )}\n </>\n );\n\n const stylePropertiesAndVariables = getButtonStyles(style);\n\n if (isAnchor) {\n const getAnchorTabIndex = () => {\n if (isNotInteractive) {\n // If disabled with a reason, make it focusable so users can access the tooltip\n // Otherwise, resolve to the default button props tabIndex.\n return disabledReason ? 0 : buttonProps.tabIndex;\n }\n return buttonProps.tabIndex;\n };\n\n return (\n <>\n <WithNativeAttributes<HTMLAnchorElement, React.AnchorHTMLAttributes<HTMLAnchorElement>>\n tag=\"a\"\n nativeAttributes={nativeAnchorAttributes}\n skipWarnings={__skipNativeAttributesWarnings}\n {...buttonProps}\n href={isNotInteractive ? undefined : href}\n role={isNotInteractive ? 'link' : undefined}\n tabIndex={getAnchorTabIndex()}\n target={target}\n // security recommendation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target\n rel={rel ?? (target === '_blank' ? 'noopener noreferrer' : undefined)}\n aria-disabled={isNotInteractive ? true : undefined}\n download={download}\n {...disabledReasonProps}\n style={stylePropertiesAndVariables}\n >\n {buttonContent}\n {isDisabledWithReason && disabledReasonContent}\n </WithNativeAttributes>\n {loading && loadingText && (\n <InternalLiveRegion tagName=\"span\" hidden={true}>\n {loadingText}\n </InternalLiveRegion>\n )}\n </>\n );\n }\n\n return (\n <>\n <WithNativeAttributes<HTMLButtonElement, React.ButtonHTMLAttributes<HTMLButtonElement>>\n tag=\"button\"\n nativeAttributes={nativeButtonAttributes}\n skipWarnings={__skipNativeAttributesWarnings}\n {...buttonProps}\n type={formAction === 'none' ? 'button' : 'submit'}\n disabled={disabled && !__focusable && !isDisabledWithReason}\n aria-disabled={hasAriaDisabled ? true : undefined}\n {...disabledReasonProps}\n style={stylePropertiesAndVariables}\n >\n {buttonContent}\n {isDisabledWithReason && disabledReasonContent}\n </WithNativeAttributes>\n {loading && loadingText && (\n <InternalLiveRegion tagName=\"span\" hidden={true}>\n {loadingText}\n </InternalLiveRegion>\n )}\n </>\n );\n }\n);\n\nexport default InternalButton;\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/button/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACpG,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,kEAAkE,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;A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,CAAC,CAAC,CAAC,SAAS,EACjD,KAAK,EAAE,2BAA2B;YAEjC,aAAa;YACb,oBAAoB,IAAI,qBAAqB,CACzB;QACtB,OAAO,IAAI,WAAW,IAAI,CACzB,oBAAC,kBAAkB,IAAC,OAAO,EAAC,MAAM,EAAC,MAAM,EAAE,IAAI,IAC5C,WAAW,CACO,CACtB,CACA,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { useSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal';\nimport {\n getAnalyticsLabelAttribute,\n getAnalyticsMetadataAttribute,\n} from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { useInternalI18n } from '../i18n/context';\nimport Icon from '../icon/internal';\nimport { FunnelMetrics } from '../internal/analytics';\nimport { useFunnel, useFunnelStep, useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport {\n DATA_ATTR_FUNNEL_VALUE,\n getFunnelValueSelector,\n getSubStepAllSelector,\n getTextFromSelector,\n} from '../internal/analytics/selectors';\nimport Tooltip from '../internal/components/tooltip/index.js';\nimport { useButtonContext } from '../internal/context/button-context';\nimport { fireCancelableEvent, isPlainLeftClick } from '../internal/events';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport useHiddenDescription from '../internal/hooks/use-hidden-description';\nimport { useModalContextLoadingButtonComponent } from '../internal/hooks/use-modal-component-analytics';\nimport { usePerformanceMarks } from '../internal/hooks/use-performance-marks';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport WithNativeAttributes from '../internal/utils/with-native-attributes';\nimport InternalLiveRegion from '../live-region/internal';\nimport { GeneratedAnalyticsMetadataButtonFragment } from './analytics-metadata/interfaces';\nimport { ButtonIconProps, LeftIcon, RightIcon } from './icon-helper';\nimport { ButtonProps } from './interfaces';\nimport { getButtonStyles } from './style';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\nimport testUtilStyles from './test-classes/styles.css.js';\n\nexport type InternalButtonProps = Omit<ButtonProps, 'variant'> & {\n variant?:\n | ButtonProps['variant']\n | 'flashbar-icon'\n | 'breadcrumb-group'\n | 'menu-trigger'\n | 'modal-dismiss'\n | 'inline-icon-pointer-target';\n badge?: boolean;\n analyticsAction?: string;\n __iconClass?: string;\n __focusable?: boolean;\n __injectAnalyticsComponentMetadata?: boolean;\n __title?: string;\n __emitPerformanceMarks?: boolean;\n __skipNativeAttributesWarnings?: boolean;\n __hideFromTestUtils?: boolean;\n} & InternalBaseComponentProps;\n\nexport const InternalButton = React.forwardRef(\n (\n {\n children,\n iconName,\n __iconClass,\n onClick,\n onFollow,\n iconAlign = 'left',\n iconUrl,\n iconSvg,\n iconAlt,\n variant = 'normal',\n loading = false,\n loadingText,\n disabled = false,\n disabledReason,\n wrapText = true,\n href,\n external,\n target: targetOverride,\n rel,\n download,\n formAction = 'submit',\n ariaLabel,\n ariaDescribedby,\n ariaExpanded,\n ariaControls,\n fullWidth,\n badge,\n i18nStrings,\n style,\n nativeButtonAttributes,\n nativeAnchorAttributes,\n __internalRootRef,\n __focusable = false,\n __injectAnalyticsComponentMetadata = false,\n __title,\n __emitPerformanceMarks = true,\n __skipNativeAttributesWarnings,\n __hideFromTestUtils = false,\n analyticsAction = 'click',\n ...props\n }: InternalButtonProps,\n ref: React.Ref<ButtonProps.Ref>\n ) => {\n const [showTooltip, setShowTooltip] = useState(false);\n\n checkSafeUrl('Button', href);\n const isAnchor = Boolean(href);\n const target = targetOverride ?? (external ? '_blank' : undefined);\n const isNotInteractive = loading || disabled;\n const isDisabledWithReason =\n (variant === 'normal' || variant === 'primary' || variant === 'icon') && !!disabledReason && disabled;\n\n const hasAriaDisabled = (loading && !disabled) || (disabled && __focusable) || isDisabledWithReason;\n const shouldHaveContent =\n children &&\n ['icon', 'inline-icon', 'flashbar-icon', 'modal-dismiss', 'inline-icon-pointer-target'].indexOf(variant) === -1;\n\n if ((iconName || iconUrl || iconSvg) && iconAlign === 'right' && external) {\n warnOnce('Button', 'A right-aligned icon should not be combined with an external icon.');\n }\n\n const buttonRef = useRef<HTMLElement>(null);\n useForwardFocus(ref, buttonRef);\n\n const buttonContext = useButtonContext();\n const i18n = useInternalI18n('button');\n\n const uniqueId = useUniqueId('button');\n const { funnelInteractionId } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n const { subStepSelector, subStepNameSelector } = useFunnelSubStep();\n\n const performanceMarkAttributes = usePerformanceMarks(\n 'primaryButton',\n () => variant === 'primary' && __emitPerformanceMarks && !loading && !disabled,\n buttonRef,\n () => ({\n loading,\n disabled,\n text: buttonRef.current?.innerText,\n }),\n [loading, disabled]\n );\n useModalContextLoadingButtonComponent(variant === 'primary', loading);\n\n const { targetProps, descriptionEl } = useHiddenDescription(disabledReason);\n\n const handleClick = (event: React.MouseEvent) => {\n if (isNotInteractive) {\n return event.preventDefault();\n }\n\n if (isAnchor && isPlainLeftClick(event)) {\n fireCancelableEvent(onFollow, { href, target }, event);\n\n if ((iconName === 'external' || target === '_blank') && funnelInteractionId) {\n const stepName = getTextFromSelector(stepNameSelector);\n const subStepName = getTextFromSelector(subStepNameSelector);\n\n FunnelMetrics.externalLinkInteracted({\n funnelInteractionId,\n stepNumber,\n stepName,\n stepNameSelector,\n subStepSelector,\n subStepName,\n subStepNameSelector,\n elementSelector: getFunnelValueSelector(uniqueId),\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n }\n\n const { altKey, button, ctrlKey, metaKey, shiftKey } = event;\n fireCancelableEvent(onClick, { altKey, button, ctrlKey, metaKey, shiftKey }, event);\n buttonContext.onClick({ variant });\n };\n\n const buttonClass = clsx(props.className, styles.button, styles[`variant-${variant}`], {\n [testUtilStyles.button]: !__hideFromTestUtils,\n [styles.disabled]: isNotInteractive,\n [styles['disabled-with-reason']]: isDisabledWithReason,\n [styles['button-no-wrap']]: !wrapText,\n [styles['button-no-text']]: !shouldHaveContent,\n [styles['full-width']]: shouldHaveContent && fullWidth,\n [styles.link]: isAnchor,\n });\n\n const explicitTabIndex = nativeButtonAttributes?.tabIndex ?? nativeAnchorAttributes?.tabIndex;\n const { tabIndex } = useSingleTabStopNavigation(buttonRef, {\n tabIndex: isAnchor && isNotInteractive && !isDisabledWithReason ? -1 : explicitTabIndex,\n });\n\n const analyticsMetadata: GeneratedAnalyticsMetadataButtonFragment = disabled\n ? {}\n : {\n action: analyticsAction,\n detail: { label: { root: 'self' } },\n };\n if (__injectAnalyticsComponentMetadata) {\n analyticsMetadata.component = {\n name: 'awsui.Button',\n label: { root: 'self' },\n properties: { variant, disabled: `${disabled}` },\n };\n }\n\n const buttonProps = {\n ...props,\n ...performanceMarkAttributes,\n tabIndex,\n // https://github.com/microsoft/TypeScript/issues/36659\n ref: useMergeRefs(buttonRef, __internalRootRef),\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedby,\n 'aria-expanded': ariaExpanded,\n 'aria-controls': ariaControls,\n // add ariaLabel as `title` as visible hint text\n title: __title ?? ariaLabel,\n className: buttonClass,\n onClick: handleClick,\n [DATA_ATTR_FUNNEL_VALUE]: uniqueId,\n ...getAnalyticsMetadataAttribute(analyticsMetadata),\n ...getAnalyticsLabelAttribute(shouldHaveContent ? `.${analyticsSelectors.label}` : ''),\n } as const;\n\n const iconProps: ButtonIconProps = {\n loading,\n iconName,\n iconAlign,\n iconUrl,\n iconSvg,\n iconAlt,\n variant,\n badge,\n iconClass: __iconClass,\n iconSize: variant === 'modal-dismiss' ? 'medium' : 'normal',\n };\n const buttonContent = (\n <>\n <LeftIcon {...iconProps} />\n {shouldHaveContent && (\n <>\n <span className={clsx(testUtilStyles.content, analyticsSelectors.label)}>{children}</span>\n {external && (\n <>\n \n <Icon\n name=\"external\"\n className={testUtilStyles['external-icon']}\n ariaLabel={i18n('i18nStrings.externalIconAriaLabel', i18nStrings?.externalIconAriaLabel)}\n />\n </>\n )}\n </>\n )}\n <RightIcon {...iconProps} />\n </>\n );\n\n const { loadingButtonCount } = useFunnel();\n useEffect(() => {\n if (loading) {\n loadingButtonCount.current++;\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n loadingButtonCount.current--;\n };\n }\n }, [loading, loadingButtonCount]);\n\n const disabledReasonProps = {\n onFocus: isDisabledWithReason ? () => setShowTooltip(true) : undefined,\n onBlur: isDisabledWithReason ? () => setShowTooltip(false) : undefined,\n onMouseEnter: isDisabledWithReason ? () => setShowTooltip(true) : undefined,\n onMouseLeave: isDisabledWithReason ? () => setShowTooltip(false) : undefined,\n ...(isDisabledWithReason ? targetProps : {}),\n };\n const disabledReasonContent = (\n <>\n {descriptionEl}\n {showTooltip && (\n <Tooltip\n className={testUtilStyles['disabled-reason-tooltip']}\n trackRef={buttonRef}\n value={disabledReason!}\n onDismiss={() => setShowTooltip(false)}\n />\n )}\n </>\n );\n\n const stylePropertiesAndVariables = getButtonStyles(style);\n\n if (isAnchor) {\n const getAnchorTabIndex = () => {\n if (isNotInteractive) {\n // If disabled with a reason, make it focusable so users can access the tooltip\n // Otherwise, resolve to the default button props tabIndex.\n return disabledReason ? 0 : buttonProps.tabIndex;\n }\n return buttonProps.tabIndex;\n };\n\n return (\n <>\n <WithNativeAttributes<HTMLAnchorElement, React.AnchorHTMLAttributes<HTMLAnchorElement>>\n {...buttonProps}\n {...disabledReasonProps}\n tag=\"a\"\n componentName=\"Button\"\n nativeAttributes={nativeAnchorAttributes}\n skipWarnings={__skipNativeAttributesWarnings}\n href={isNotInteractive ? undefined : href}\n role={isNotInteractive ? 'link' : undefined}\n tabIndex={getAnchorTabIndex()}\n target={target}\n // security recommendation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target\n rel={rel ?? (target === '_blank' ? 'noopener noreferrer' : undefined)}\n aria-disabled={isNotInteractive ? true : undefined}\n download={download}\n style={stylePropertiesAndVariables}\n >\n {buttonContent}\n {isDisabledWithReason && disabledReasonContent}\n </WithNativeAttributes>\n {loading && loadingText && (\n <InternalLiveRegion tagName=\"span\" hidden={true}>\n {loadingText}\n </InternalLiveRegion>\n )}\n </>\n );\n }\n\n return (\n <>\n <WithNativeAttributes<HTMLButtonElement, React.ButtonHTMLAttributes<HTMLButtonElement>>\n {...buttonProps}\n {...disabledReasonProps}\n tag=\"button\"\n componentName=\"Button\"\n nativeAttributes={nativeButtonAttributes}\n skipWarnings={__skipNativeAttributesWarnings}\n type={formAction === 'none' ? 'button' : 'submit'}\n disabled={disabled && !__focusable && !isDisabledWithReason}\n aria-disabled={hasAriaDisabled ? true : undefined}\n style={stylePropertiesAndVariables}\n >\n {buttonContent}\n {isDisabledWithReason && disabledReasonContent}\n </WithNativeAttributes>\n {loading && loadingText && (\n <InternalLiveRegion tagName=\"span\" hidden={true}>\n {loadingText}\n </InternalLiveRegion>\n )}\n </>\n );\n }\n);\n\nexport default InternalButton;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/checkbox/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAejD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGlF,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAK7C,UAAU,aAAc,SAAQ,aAAa,EAAE,0BAA0B;IACvE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kCAAkC,CAAC,EAAE,OAAO,CAAC;CAC9C;AAED,QAAA,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/checkbox/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAejD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGlF,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAK7C,UAAU,aAAc,SAAQ,aAAa,EAAE,0BAA0B;IACvE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kCAAkC,CAAC,EAAE,OAAO,CAAC;CAC9C;AAED,QAAA,MAAM,gBAAgB,yFAiHrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
package/checkbox/internal.js
CHANGED
|
@@ -40,7 +40,7 @@ const InternalCheckbox = React.forwardRef((_a, ref) => {
|
|
|
40
40
|
if (!disabled && !readOnly) {
|
|
41
41
|
analyticsMetadata.action = !checked ? 'select' : 'deselect';
|
|
42
42
|
}
|
|
43
|
-
return (React.createElement(AbstractSwitch, Object.assign({}, baseProps, { className: clsx(styles.root, baseProps.className), controlClassName: styles['checkbox-control'], outlineClassName: styles.outline, controlId: controlId, disabled: disabled, readOnly: readOnly, label: children, description: description, descriptionBottomPadding: true, ariaLabel: ariaLabel, ariaLabelledby: ariaLabelledby, ariaDescribedby: ariaDescribedby, ariaControls: ariaControls, showOutline: showOutline, nativeControl: nativeControlProps => (React.createElement(WithNativeAttributes, Object.assign({}, nativeControlProps, { tag: "input", nativeAttributes: nativeInputAttributes, ref: checkboxRef, type: "checkbox", checked: checked, name: name, "aria-required": ariaRequired ? 'true' : undefined, "aria-disabled": readOnly && !disabled ? 'true' : undefined, tabIndex: tabIndex, onFocus: () => fireNonCancelableEvent(onFocus), onBlur: () => fireNonCancelableEvent(onBlur),
|
|
43
|
+
return (React.createElement(AbstractSwitch, Object.assign({}, baseProps, { className: clsx(styles.root, baseProps.className), controlClassName: styles['checkbox-control'], outlineClassName: styles.outline, controlId: controlId, disabled: disabled, readOnly: readOnly, label: children, description: description, descriptionBottomPadding: true, ariaLabel: ariaLabel, ariaLabelledby: ariaLabelledby, ariaDescribedby: ariaDescribedby, ariaControls: ariaControls, showOutline: showOutline, nativeControl: nativeControlProps => (React.createElement(WithNativeAttributes, Object.assign({}, nativeControlProps, { tag: "input", componentName: "Checkbox", nativeAttributes: nativeInputAttributes, ref: checkboxRef, type: "checkbox", checked: checked, name: name, "aria-required": ariaRequired ? 'true' : undefined, "aria-disabled": readOnly && !disabled ? 'true' : undefined, tabIndex: tabIndex, onFocus: () => fireNonCancelableEvent(onFocus), onBlur: () => fireNonCancelableEvent(onBlur),
|
|
44
44
|
// empty handler to suppress React controllability warning
|
|
45
45
|
onChange: () => { } }))), onClick: () => {
|
|
46
46
|
var _a;
|
package/checkbox/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/checkbox/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,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAEL,6BAA6B,GAC9B,MAAM,kEAAkE,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,cAAc,MAAM,wCAAwC,CAAC;AACpE,OAAO,YAAY,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAE9D,OAAO,oBAAoB,MAAM,0CAA0C,CAAC;AAG5E,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEzE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAQrC,MA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E;;YACZ,MAAA,WAAW,CAAC,OAAO,0CAAE,KAAK,EAAE,CAAC;YAC7B,sBAAsB,CACpB,QAAQ;YACR,4EAA4E;YAC5E,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,CACtG,CAAC;QACJ,CAAC,EACD,aAAa,EACX,oBAAC,YAAY,IACX,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,CAAC,GAC/E,EAEJ,KAAK,EAAE,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,CAAC,EACjF,iBAAiB,EAAE,iBAAiB,IAChC,6BAA6B,CAAC,iBAAiB,CAAC,EACpD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,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 { useSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal';\nimport {\n GeneratedAnalyticsMetadataFragment,\n getAnalyticsMetadataAttribute,\n} from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { getBaseProps } from '../internal/base-component';\nimport AbstractSwitch from '../internal/components/abstract-switch';\nimport CheckboxIcon from '../internal/components/checkbox-icon';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport WithNativeAttributes from '../internal/utils/with-native-attributes';\nimport { GeneratedAnalyticsMetadataCheckboxComponent } from './analytics-metadata/interfaces';\nimport { CheckboxProps } from './interfaces';\nimport { getAbstractSwitchStyles, getCheckboxIconStyles } from './style';\n\nimport styles from './styles.css.js';\n\ninterface InternalProps extends CheckboxProps, InternalBaseComponentProps {\n tabIndex?: -1;\n showOutline?: boolean;\n __injectAnalyticsComponentMetadata?: boolean;\n}\n\nconst InternalCheckbox = React.forwardRef<CheckboxProps.Ref, InternalProps>(\n (\n {\n controlId,\n name,\n checked,\n disabled,\n readOnly,\n ariaRequired,\n indeterminate,\n children,\n description,\n ariaLabel,\n onFocus,\n onBlur,\n onChange,\n tabIndex: explicitTabIndex,\n showOutline,\n ariaControls,\n style,\n nativeInputAttributes,\n __internalRootRef,\n __injectAnalyticsComponentMetadata = false,\n ...rest\n },\n ref\n ) => {\n const { ariaDescribedby, ariaLabelledby } = useFormFieldContext(rest);\n const baseProps = getBaseProps(rest);\n const checkboxRef = useRef<HTMLInputElement>(null);\n useForwardFocus(ref, checkboxRef);\n useEffect(() => {\n if (checkboxRef.current) {\n checkboxRef.current.indeterminate = Boolean(indeterminate);\n }\n });\n\n const { tabIndex } = useSingleTabStopNavigation(checkboxRef, { tabIndex: explicitTabIndex });\n\n const analyticsMetadata: GeneratedAnalyticsMetadataFragment = {};\n const analyticsComponentMetadata: GeneratedAnalyticsMetadataCheckboxComponent = {\n name: 'awsui.Checkbox',\n label: { root: 'self' },\n properties: {\n checked: `${!!checked}`,\n },\n };\n if (__injectAnalyticsComponentMetadata) {\n analyticsMetadata.component = analyticsComponentMetadata;\n }\n if (!disabled && !readOnly) {\n analyticsMetadata.action = !checked ? 'select' : 'deselect';\n }\n\n return (\n <AbstractSwitch\n {...baseProps}\n className={clsx(styles.root, baseProps.className)}\n controlClassName={styles['checkbox-control']}\n outlineClassName={styles.outline}\n controlId={controlId}\n disabled={disabled}\n readOnly={readOnly}\n label={children}\n description={description}\n descriptionBottomPadding={true}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n ariaControls={ariaControls}\n showOutline={showOutline}\n nativeControl={nativeControlProps => (\n <WithNativeAttributes<HTMLInputElement, React.InputHTMLAttributes<HTMLInputElement>>\n {...nativeControlProps}\n tag=\"input\"\n nativeAttributes={nativeInputAttributes}\n ref={checkboxRef}\n type=\"checkbox\"\n checked={checked}\n name={name}\n aria-required={ariaRequired ? 'true' : undefined}\n aria-disabled={readOnly && !disabled ? 'true' : undefined}\n tabIndex={tabIndex}\n onFocus={() => fireNonCancelableEvent(onFocus)}\n onBlur={() => fireNonCancelableEvent(onBlur)}\n // empty handler to suppress React controllability warning\n onChange={() => {}}\n />\n )}\n onClick={() => {\n checkboxRef.current?.focus();\n fireNonCancelableEvent(\n onChange,\n // for deterministic transitions \"indeterminate\" -> \"checked\" -> \"unchecked\"\n indeterminate ? { checked: true, indeterminate: false } : { checked: !checked, indeterminate: false }\n );\n }}\n styledControl={\n <CheckboxIcon\n checked={checked}\n indeterminate={indeterminate}\n disabled={disabled}\n readOnly={readOnly}\n style={getCheckboxIconStyles(style, checked, disabled, readOnly, indeterminate)}\n />\n }\n style={getAbstractSwitchStyles(style, checked, disabled, readOnly, indeterminate)}\n __internalRootRef={__internalRootRef}\n {...getAnalyticsMetadataAttribute(analyticsMetadata)}\n />\n );\n }\n);\n\nexport default InternalCheckbox;\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/checkbox/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,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAEL,6BAA6B,GAC9B,MAAM,kEAAkE,CAAC;AAE1E,OAA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All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal';\nimport {\n GeneratedAnalyticsMetadataFragment,\n getAnalyticsMetadataAttribute,\n} from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { getBaseProps } from '../internal/base-component';\nimport AbstractSwitch from '../internal/components/abstract-switch';\nimport CheckboxIcon from '../internal/components/checkbox-icon';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport WithNativeAttributes from '../internal/utils/with-native-attributes';\nimport { GeneratedAnalyticsMetadataCheckboxComponent } from './analytics-metadata/interfaces';\nimport { CheckboxProps } from './interfaces';\nimport { getAbstractSwitchStyles, getCheckboxIconStyles } from './style';\n\nimport styles from './styles.css.js';\n\ninterface InternalProps extends CheckboxProps, InternalBaseComponentProps {\n tabIndex?: -1;\n showOutline?: boolean;\n __injectAnalyticsComponentMetadata?: boolean;\n}\n\nconst InternalCheckbox = React.forwardRef<CheckboxProps.Ref, InternalProps>(\n (\n {\n controlId,\n name,\n checked,\n disabled,\n readOnly,\n ariaRequired,\n indeterminate,\n children,\n description,\n ariaLabel,\n onFocus,\n onBlur,\n onChange,\n tabIndex: explicitTabIndex,\n showOutline,\n ariaControls,\n style,\n nativeInputAttributes,\n __internalRootRef,\n __injectAnalyticsComponentMetadata = false,\n ...rest\n },\n ref\n ) => {\n const { ariaDescribedby, ariaLabelledby } = useFormFieldContext(rest);\n const baseProps = getBaseProps(rest);\n const checkboxRef = useRef<HTMLInputElement>(null);\n useForwardFocus(ref, checkboxRef);\n useEffect(() => {\n if (checkboxRef.current) {\n checkboxRef.current.indeterminate = Boolean(indeterminate);\n }\n });\n\n const { tabIndex } = useSingleTabStopNavigation(checkboxRef, { tabIndex: explicitTabIndex });\n\n const analyticsMetadata: GeneratedAnalyticsMetadataFragment = {};\n const analyticsComponentMetadata: GeneratedAnalyticsMetadataCheckboxComponent = {\n name: 'awsui.Checkbox',\n label: { root: 'self' },\n properties: {\n checked: `${!!checked}`,\n },\n };\n if (__injectAnalyticsComponentMetadata) {\n analyticsMetadata.component = analyticsComponentMetadata;\n }\n if (!disabled && !readOnly) {\n analyticsMetadata.action = !checked ? 'select' : 'deselect';\n }\n\n return (\n <AbstractSwitch\n {...baseProps}\n className={clsx(styles.root, baseProps.className)}\n controlClassName={styles['checkbox-control']}\n outlineClassName={styles.outline}\n controlId={controlId}\n disabled={disabled}\n readOnly={readOnly}\n label={children}\n description={description}\n descriptionBottomPadding={true}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n ariaControls={ariaControls}\n showOutline={showOutline}\n nativeControl={nativeControlProps => (\n <WithNativeAttributes<HTMLInputElement, React.InputHTMLAttributes<HTMLInputElement>>\n {...nativeControlProps}\n tag=\"input\"\n componentName=\"Checkbox\"\n nativeAttributes={nativeInputAttributes}\n ref={checkboxRef}\n type=\"checkbox\"\n checked={checked}\n name={name}\n aria-required={ariaRequired ? 'true' : undefined}\n aria-disabled={readOnly && !disabled ? 'true' : undefined}\n tabIndex={tabIndex}\n onFocus={() => fireNonCancelableEvent(onFocus)}\n onBlur={() => fireNonCancelableEvent(onBlur)}\n // empty handler to suppress React controllability warning\n onChange={() => {}}\n />\n )}\n onClick={() => {\n checkboxRef.current?.focus();\n fireNonCancelableEvent(\n onChange,\n // for deterministic transitions \"indeterminate\" -> \"checked\" -> \"unchecked\"\n indeterminate ? { checked: true, indeterminate: false } : { checked: !checked, indeterminate: false }\n );\n }}\n styledControl={\n <CheckboxIcon\n checked={checked}\n indeterminate={indeterminate}\n disabled={disabled}\n readOnly={readOnly}\n style={getCheckboxIconStyles(style, checked, disabled, readOnly, indeterminate)}\n />\n }\n style={getAbstractSwitchStyles(style, checked, disabled, readOnly, indeterminate)}\n __internalRootRef={__internalRootRef}\n {...getAnalyticsMetadataAttribute(analyticsMetadata)}\n />\n );\n }\n);\n\nexport default InternalCheckbox;\n"]}
|
package/icon/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/icon/internal.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGlF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,KAAK,iBAAiB,GAAG,SAAS,GAChC,0BAA0B,GAAG;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAqBJ,QAAA,MAAM,YAAY,4GAYf,iBAAiB,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/icon/internal.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGlF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,KAAK,iBAAiB,GAAG,SAAS,GAChC,0BAA0B,GAAG;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAqBJ,QAAA,MAAM,YAAY,4GAYf,iBAAiB,gBAkHnB,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC7B,eAAe,YAAY,CAAC"}
|
package/icon/internal.js
CHANGED
|
@@ -60,10 +60,10 @@ const InternalIcon = (_a) => {
|
|
|
60
60
|
if (url) {
|
|
61
61
|
warnOnce('Icon', 'You have specified both `url` and `svg`. `svg` will take precedence and `url` will be ignored.');
|
|
62
62
|
}
|
|
63
|
-
return (React.createElement(WithNativeAttributes, Object.assign({}, baseProps, labelAttributes, { tag: "span", nativeAttributes: nativeAttributes, ref: mergedRef, "aria-hidden": !hasAriaLabel, style: inlineStyles }), svg));
|
|
63
|
+
return (React.createElement(WithNativeAttributes, Object.assign({}, baseProps, labelAttributes, { tag: "span", componentName: "Icon", nativeAttributes: nativeAttributes, ref: mergedRef, "aria-hidden": !hasAriaLabel, style: inlineStyles }), svg));
|
|
64
64
|
}
|
|
65
65
|
if (url) {
|
|
66
|
-
return (React.createElement(WithNativeAttributes, Object.assign({}, baseProps, { tag: "span", nativeAttributes: nativeAttributes, ref: mergedRef, style: inlineStyles }),
|
|
66
|
+
return (React.createElement(WithNativeAttributes, Object.assign({}, baseProps, { tag: "span", componentName: "Icon", nativeAttributes: nativeAttributes, ref: mergedRef, style: inlineStyles }),
|
|
67
67
|
React.createElement("img", { src: url, alt: ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : alt })));
|
|
68
68
|
}
|
|
69
69
|
const validIcon = name && Object.prototype.hasOwnProperty.call(icons, name);
|
|
@@ -76,7 +76,7 @@ const InternalIcon = (_a) => {
|
|
|
76
76
|
return icons[name];
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
return (React.createElement(WithNativeAttributes, Object.assign({}, baseProps, labelAttributes, { tag: "span", nativeAttributes: nativeAttributes, ref: mergedRef, style: inlineStyles }), validIcon ? iconMap(name) : undefined));
|
|
79
|
+
return (React.createElement(WithNativeAttributes, Object.assign({}, baseProps, labelAttributes, { tag: "span", componentName: "Icon", nativeAttributes: nativeAttributes, ref: mergedRef, style: inlineStyles }), validIcon ? iconMap(name) : undefined));
|
|
80
80
|
};
|
|
81
81
|
export default InternalIcon;
|
|
82
82
|
//# sourceMappingURL=internal.js.map
|
package/icon/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/icon/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7E,OAAO,IAAI,MAAM,MAA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B,oBACf,SAAS,EACT,eAAe,IACnB,GAAG,EAAC,MAAM,EACV,gBAAgB,EAAE,gBAAgB,EAClC,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,YAAY,KAElB,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CACjB,CACxB,CAAC;AACJ,CAAC,CAAC;AAGF,eAAe,YAAY,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useLayoutEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { InternalIconContext } from '../icon-provider/context';\nimport { getBaseProps } from '../internal/base-component';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport WithNativeAttributes from '../internal/utils/with-native-attributes';\nimport { IconProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\ntype InternalIconProps = IconProps &\n InternalBaseComponentProps & {\n badge?: boolean;\n };\n\nfunction iconSizeMap(height: number | null) {\n if (height === null) {\n // This is the best guess for the contextual height while server rendering.\n return 'normal';\n }\n\n if (height >= 50) {\n return 'large';\n } else if (height >= 36) {\n return 'big';\n } else if (height >= 24) {\n return 'medium';\n } else if (height <= 16) {\n return 'small';\n } else {\n return 'normal';\n }\n}\n\nconst InternalIcon = ({\n name,\n size = 'normal',\n variant = 'normal',\n url,\n alt,\n ariaLabel,\n svg,\n badge,\n nativeAttributes,\n __internalRootRef,\n ...props\n}: InternalIconProps) => {\n const icons = useContext(InternalIconContext);\n const iconRef = useRef<HTMLElement>(null);\n // To ensure a re-render is triggered on visual mode changes\n useVisualRefresh();\n const [parentHeight, setParentHeight] = useState<number | null>(null);\n const contextualSize = size === 'inherit';\n const iconSize = contextualSize ? iconSizeMap(parentHeight) : size;\n const inlineStyles = contextualSize && parentHeight !== null ? { height: `${parentHeight}px` } : {};\n const baseProps = getBaseProps(props);\n\n baseProps.className = clsx(\n baseProps.className,\n styles.icon,\n contextualSize && styles['icon-flex-height'],\n badge && styles.badge,\n !contextualSize && styles[`size-${iconSize}-mapped-height`],\n styles[`size-${iconSize}`],\n styles[`variant-${variant}`],\n styles[`name-${name}`]\n );\n\n // Possible infinite loop is not a concern here because line\n // height should not change without an external state update.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(() => {\n if (!contextualSize || !iconRef.current) {\n return;\n }\n const { lineHeight } = getComputedStyle(iconRef.current);\n const newParentHeight = parseInt(lineHeight, 10);\n setParentHeight(newParentHeight);\n });\n\n const mergedRef = useMergeRefs(iconRef, __internalRootRef);\n const hasAriaLabel = typeof ariaLabel === 'string';\n const labelAttributes = hasAriaLabel ? { role: 'img', 'aria-label': ariaLabel } : {};\n\n if (svg) {\n if (url) {\n warnOnce(\n 'Icon',\n 'You have specified both `url` and `svg`. `svg` will take precedence and `url` will be ignored.'\n );\n }\n return (\n <WithNativeAttributes\n {...baseProps}\n {...labelAttributes}\n tag=\"span\"\n nativeAttributes={nativeAttributes}\n ref={mergedRef}\n aria-hidden={!hasAriaLabel}\n style={inlineStyles}\n >\n {svg}\n </WithNativeAttributes>\n );\n }\n\n if (url) {\n return (\n <WithNativeAttributes\n {...baseProps}\n tag=\"span\"\n nativeAttributes={nativeAttributes}\n ref={mergedRef}\n style={inlineStyles}\n >\n <img src={url} alt={ariaLabel ?? alt} />\n </WithNativeAttributes>\n );\n }\n\n const validIcon = name && Object.prototype.hasOwnProperty.call(icons, name);\n\n function iconMap(name: IconProps.Name) {\n if (name === 'gen-ai' && iconSize === 'small') {\n return (\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 16 16\"\n xmlns=\"http://www.w3.org/2000/svg\"\n focusable=\"false\"\n aria-hidden=\"true\"\n data-testid=\"gen-ai-filled\"\n >\n <path\n d=\"m8 4.4 1.018 2.582L11.6 8 9.018 9.018 8 11.6 6.982 9.018 4.4 8l2.582-1.018L8 4.4ZM2.405 2.41l.002-.003.003-.002-.003-.002-.002-.003-.002.003-.003.002.003.002.002.003Z\"\n className=\"filled\"\n />\n </svg>\n );\n } else {\n return icons[name];\n }\n }\n\n return (\n <WithNativeAttributes\n {...baseProps}\n {...labelAttributes}\n tag=\"span\"\n nativeAttributes={nativeAttributes}\n ref={mergedRef}\n style={inlineStyles}\n >\n {validIcon ? iconMap(name) : undefined}\n </WithNativeAttributes>\n );\n};\n\nexport { InternalIconProps };\nexport default InternalIcon;\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/icon/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,oBAAoB,MAAM,0CAA0C,CAAC;AAG5E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAOrC,SAAS,WAAW,CAAC,MAAqB;IACxC,IAAI,MAAM,KAAK,IAAI,EAAE;QACnB,2EAA2E;QAC3E,OAAO,QAAQ,CAAC;KACjB;IAED,IAAI,MAAM,IAAI,EAAE,EAAE;QAChB,OAAO,OAAO,CAAC;KAChB;SAAM,IAAI,MAAM,IAAI,EAAE,EAAE;QACvB,OAAO,KAAK,CAAC;KACd;SAAM,IAAI,MAAM,IAAI,EAAE,EAAE;QACvB,OAAO,QAAQ,CAAC;KACjB;SAAM,I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,GAAG,EAAE,GAAG,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,GAAG,GAAI,CACnB,CACxB,CAAC;KACH;IAED,MAAM,SAAS,GAAG,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAE5E,SAAS,OAAO,CAAC,IAAoB;QACnC,IAAI,IAAI,KAAK,QAAQ,IAAI,QAAQ,KAAK,OAAO,EAAE;YAC7C,OAAO,CACL,6BACE,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,4BAA4B,EAClC,SAAS,EAAC,OAAO,iBACL,MAAM,iBACN,eAAe;gBAE3B,8BACE,CAAC,EAAC,wKAAwK,EAC1K,SAAS,EAAC,QAAQ,GAClB,CACE,CACP,CAAC;SACH;aAAM;YACL,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;SACpB;IACH,CAAC;IAED,OAAO,CACL,oBAAC,oBAAoB,oBACf,SAAS,EACT,eAAe,IACnB,GAAG,EAAC,MAAM,EACV,aAAa,EAAC,MAAM,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,YAAY,KAElB,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CACjB,CACxB,CAAC;AACJ,CAAC,CAAC;AAGF,eAAe,YAAY,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useContext, useLayoutEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { InternalIconContext } from '../icon-provider/context';\nimport { getBaseProps } from '../internal/base-component';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport WithNativeAttributes from '../internal/utils/with-native-attributes';\nimport { IconProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\ntype InternalIconProps = IconProps &\n InternalBaseComponentProps & {\n badge?: boolean;\n };\n\nfunction iconSizeMap(height: number | null) {\n if (height === null) {\n // This is the best guess for the contextual height while server rendering.\n return 'normal';\n }\n\n if (height >= 50) {\n return 'large';\n } else if (height >= 36) {\n return 'big';\n } else if (height >= 24) {\n return 'medium';\n } else if (height <= 16) {\n return 'small';\n } else {\n return 'normal';\n }\n}\n\nconst InternalIcon = ({\n name,\n size = 'normal',\n variant = 'normal',\n url,\n alt,\n ariaLabel,\n svg,\n badge,\n nativeAttributes,\n __internalRootRef,\n ...props\n}: InternalIconProps) => {\n const icons = useContext(InternalIconContext);\n const iconRef = useRef<HTMLElement>(null);\n // To ensure a re-render is triggered on visual mode changes\n useVisualRefresh();\n const [parentHeight, setParentHeight] = useState<number | null>(null);\n const contextualSize = size === 'inherit';\n const iconSize = contextualSize ? iconSizeMap(parentHeight) : size;\n const inlineStyles = contextualSize && parentHeight !== null ? { height: `${parentHeight}px` } : {};\n const baseProps = getBaseProps(props);\n\n baseProps.className = clsx(\n baseProps.className,\n styles.icon,\n contextualSize && styles['icon-flex-height'],\n badge && styles.badge,\n !contextualSize && styles[`size-${iconSize}-mapped-height`],\n styles[`size-${iconSize}`],\n styles[`variant-${variant}`],\n styles[`name-${name}`]\n );\n\n // Possible infinite loop is not a concern here because line\n // height should not change without an external state update.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useLayoutEffect(() => {\n if (!contextualSize || !iconRef.current) {\n return;\n }\n const { lineHeight } = getComputedStyle(iconRef.current);\n const newParentHeight = parseInt(lineHeight, 10);\n setParentHeight(newParentHeight);\n });\n\n const mergedRef = useMergeRefs(iconRef, __internalRootRef);\n const hasAriaLabel = typeof ariaLabel === 'string';\n const labelAttributes = hasAriaLabel ? { role: 'img', 'aria-label': ariaLabel } : {};\n\n if (svg) {\n if (url) {\n warnOnce(\n 'Icon',\n 'You have specified both `url` and `svg`. `svg` will take precedence and `url` will be ignored.'\n );\n }\n return (\n <WithNativeAttributes\n {...baseProps}\n {...labelAttributes}\n tag=\"span\"\n componentName=\"Icon\"\n nativeAttributes={nativeAttributes}\n ref={mergedRef}\n aria-hidden={!hasAriaLabel}\n style={inlineStyles}\n >\n {svg}\n </WithNativeAttributes>\n );\n }\n\n if (url) {\n return (\n <WithNativeAttributes\n {...baseProps}\n tag=\"span\"\n componentName=\"Icon\"\n nativeAttributes={nativeAttributes}\n ref={mergedRef}\n style={inlineStyles}\n >\n <img src={url} alt={ariaLabel ?? alt} />\n </WithNativeAttributes>\n );\n }\n\n const validIcon = name && Object.prototype.hasOwnProperty.call(icons, name);\n\n function iconMap(name: IconProps.Name) {\n if (name === 'gen-ai' && iconSize === 'small') {\n return (\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 16 16\"\n xmlns=\"http://www.w3.org/2000/svg\"\n focusable=\"false\"\n aria-hidden=\"true\"\n data-testid=\"gen-ai-filled\"\n >\n <path\n d=\"m8 4.4 1.018 2.582L11.6 8 9.018 9.018 8 11.6 6.982 9.018 4.4 8l2.582-1.018L8 4.4ZM2.405 2.41l.002-.003.003-.002-.003-.002-.002-.003-.002.003-.003.002.003.002.002.003Z\"\n className=\"filled\"\n />\n </svg>\n );\n } else {\n return icons[name];\n }\n }\n\n return (\n <WithNativeAttributes\n {...baseProps}\n {...labelAttributes}\n tag=\"span\"\n componentName=\"Icon\"\n nativeAttributes={nativeAttributes}\n ref={mergedRef}\n style={inlineStyles}\n >\n {validIcon ? iconMap(name) : undefined}\n </WithNativeAttributes>\n );\n};\n\nexport { InternalIconProps };\nexport default InternalIcon;\n"]}
|
|
@@ -609,7 +609,6 @@
|
|
|
609
609
|
--space-layout-toggle-padding-chwlhz:12px;
|
|
610
610
|
--space-modal-content-bottom-nl6ceq:16px;
|
|
611
611
|
--space-modal-horizontal-y5hnwp:20px;
|
|
612
|
-
--space-option-icon-big-top-rs5wgf:0px;
|
|
613
612
|
--space-panel-content-bottom-24c6lu:40px;
|
|
614
613
|
--space-panel-content-top-qvd1dr:20px;
|
|
615
614
|
--space-panel-divider-margin-horizontal-yw31p0:8px;
|
|
@@ -2039,5 +2038,5 @@
|
|
|
2039
2038
|
}
|
|
2040
2039
|
}
|
|
2041
2040
|
:root {
|
|
2042
|
-
--awsui-version-info-
|
|
2041
|
+
--awsui-version-info-52c36f0c: true;
|
|
2043
2042
|
}
|
|
@@ -33,7 +33,7 @@ const Option = (_a) => {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
const className = clsx(styles.option, disabled && styles.disabled, isGroupOption && styles.parent, highlightedOption && styles.highlighted);
|
|
36
|
-
const icon = option.__customIcon || (React.createElement(OptionIcon, { name: option.iconName, url: option.iconUrl, svg: option.iconSvg, alt: option.iconAlt, ariaLabel: option.iconAriaLabel, size:
|
|
36
|
+
const icon = option.__customIcon || (React.createElement(OptionIcon, { name: option.iconName, url: option.iconUrl, svg: option.iconSvg, alt: option.iconAlt, ariaLabel: option.iconAriaLabel, size: "normal" }));
|
|
37
37
|
// The option is conditionally assigned 'title' and 'aria-disabled' attributes to ensure it is viewed as a (generic) group by assistive technology only when necessary.
|
|
38
38
|
// Omitting the props might be necessary if they are provided on the parent element to avoid nested groups.
|
|
39
39
|
// See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/generic_role
|