@cloudscape-design/components 3.0.1392 → 3.0.1394
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/alert/styles.css.js +27 -27
- package/alert/styles.scoped.css +43 -43
- package/alert/styles.selectors.js +27 -27
- package/badge/styles.css.js +10 -10
- package/badge/styles.scoped.css +11 -11
- package/badge/styles.selectors.js +10 -10
- package/button/styles.css.js +23 -23
- package/button/styles.scoped.css +71 -71
- package/button/styles.selectors.js +23 -23
- package/checkbox/styles.css.js +3 -3
- package/checkbox/styles.scoped.css +8 -8
- package/checkbox/styles.selectors.js +3 -3
- package/dropdown/styles.css.js +20 -20
- package/dropdown/styles.scoped.css +38 -38
- package/dropdown/styles.selectors.js +20 -20
- package/input/internal.d.ts.map +1 -1
- package/input/internal.js +3 -4
- package/input/internal.js.map +1 -1
- package/input/styles.css.js +36 -34
- package/input/styles.scoped.css +89 -79
- package/input/styles.selectors.js +36 -34
- package/internal/base-component/styles.scoped.css +1 -1
- package/internal/components/button-trigger/index.d.ts +2 -2
- package/internal/components/button-trigger/index.d.ts.map +1 -1
- package/internal/components/button-trigger/index.js +3 -2
- package/internal/components/button-trigger/index.js.map +1 -1
- package/internal/components/button-trigger/styles.css.js +21 -19
- package/internal/components/button-trigger/styles.scoped.css +49 -39
- package/internal/components/button-trigger/styles.selectors.js +21 -19
- package/internal/components/control-group/grouped-control-styles.d.ts +12 -0
- package/internal/components/control-group/grouped-control-styles.d.ts.map +1 -0
- package/internal/components/control-group/grouped-control-styles.js +14 -0
- package/internal/components/control-group/grouped-control-styles.js.map +1 -0
- package/internal/components/control-group/index.d.ts +3 -0
- package/internal/components/control-group/index.d.ts.map +1 -1
- package/internal/components/control-group/index.js +5 -5
- package/internal/components/control-group/index.js.map +1 -1
- package/internal/components/control-group/styles.css.js +8 -4
- package/internal/components/control-group/styles.scoped.css +13 -4
- package/internal/components/control-group/styles.selectors.js +8 -4
- package/internal/components/focus-lock/index.d.ts +6 -0
- package/internal/components/focus-lock/index.d.ts.map +1 -1
- package/internal/components/focus-lock/index.js +8 -3
- package/internal/components/focus-lock/index.js.map +1 -1
- package/internal/context/control-group-context.d.ts +6 -0
- package/internal/context/control-group-context.d.ts.map +1 -1
- package/internal/context/control-group-context.js +3 -1
- package/internal/context/control-group-context.js.map +1 -1
- package/internal/environment.js +2 -2
- package/internal/environment.json +2 -2
- package/internal/manifest.json +1 -1
- package/key-value-pairs/styles.css.js +8 -8
- package/key-value-pairs/styles.scoped.css +16 -11
- package/key-value-pairs/styles.selectors.js +8 -8
- package/link/styles.css.js +21 -21
- package/link/styles.scoped.css +73 -73
- package/link/styles.selectors.js +21 -21
- package/manifest.json +2 -2
- package/modal/index.d.ts +1 -0
- package/modal/index.d.ts.map +1 -1
- package/modal/index.js +6 -5
- package/modal/index.js.map +1 -1
- package/modal/interfaces.d.ts +7 -0
- package/modal/interfaces.d.ts.map +1 -1
- package/modal/interfaces.js.map +1 -1
- package/modal/internal.js +23 -6
- package/modal/internal.js.map +1 -1
- package/modal/styles.css.js +32 -31
- package/modal/styles.scoped.css +49 -46
- package/modal/styles.selectors.js +32 -31
- package/multiselect/internal.d.ts.map +1 -1
- package/multiselect/internal.js +7 -3
- package/multiselect/internal.js.map +1 -1
- package/package.json +1 -1
- package/prompt-input/styles.css.js +26 -26
- package/prompt-input/styles.scoped.css +57 -53
- package/prompt-input/styles.selectors.js +26 -26
- package/radio-button/styles.css.js +1 -1
- package/radio-button/styles.scoped.css +2 -2
- package/radio-button/styles.selectors.js +1 -1
- package/segmented-control/internal-segmented-control.d.ts +3 -3
- package/segmented-control/internal-segmented-control.d.ts.map +1 -1
- package/segmented-control/internal-segmented-control.js +8 -5
- package/segmented-control/internal-segmented-control.js.map +1 -1
- package/segmented-control/internal.d.ts.map +1 -1
- package/segmented-control/internal.js +4 -6
- package/segmented-control/internal.js.map +1 -1
- package/segmented-control/segment.d.ts +1 -0
- package/segmented-control/segment.d.ts.map +1 -1
- package/segmented-control/segment.js +2 -2
- package/segmented-control/segment.js.map +1 -1
- package/segmented-control/styles.css.js +26 -21
- package/segmented-control/styles.scoped.css +75 -43
- package/segmented-control/styles.selectors.js +26 -21
- package/select/internal.js +2 -2
- package/select/internal.js.map +1 -1
- package/select/parts/trigger.d.ts +2 -2
- package/select/parts/trigger.d.ts.map +1 -1
- package/select/parts/trigger.js +2 -2
- package/select/parts/trigger.js.map +1 -1
- package/space-between/internal.d.ts.map +1 -1
- package/space-between/internal.js +2 -1
- package/space-between/internal.js.map +1 -1
- package/space-between/styles.css.js +24 -23
- package/space-between/styles.scoped.css +29 -24
- package/space-between/styles.selectors.js +24 -23
- package/steps/styles.css.js +17 -17
- package/steps/styles.scoped.css +35 -35
- package/steps/styles.selectors.js +17 -17
- package/toggle/styles.css.js +10 -10
- package/toggle/styles.scoped.css +20 -20
- package/toggle/styles.selectors.js +10 -10
|
@@ -2,31 +2,31 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"root": "
|
|
6
|
-
"textarea-readonly": "awsui_textarea-
|
|
7
|
-
"disabled": "
|
|
8
|
-
"textarea-invalid": "awsui_textarea-
|
|
9
|
-
"textarea-warning": "awsui_textarea-
|
|
10
|
-
"textarea": "
|
|
11
|
-
"placeholder-visible": "awsui_placeholder-
|
|
12
|
-
"invalid": "
|
|
13
|
-
"warning": "
|
|
14
|
-
"textarea-disabled": "awsui_textarea-
|
|
15
|
-
"textarea-wrapper": "awsui_textarea-
|
|
16
|
-
"editable-wrapper": "awsui_editable-
|
|
17
|
-
"editable-element": "awsui_editable-
|
|
18
|
-
"primary-action": "awsui_primary-
|
|
19
|
-
"action-button": "awsui_action-
|
|
20
|
-
"secondary-content": "awsui_secondary-
|
|
21
|
-
"with-paddings": "awsui_with-
|
|
22
|
-
"action-stripe": "awsui_action-
|
|
23
|
-
"secondary-actions": "awsui_secondary-
|
|
24
|
-
"with-paddings-and-actions": "awsui_with-paddings-and-
|
|
25
|
-
"buffer": "
|
|
26
|
-
"token-container": "awsui_token-
|
|
27
|
-
"reference-wrapper": "awsui_reference-
|
|
28
|
-
"trigger-base": "awsui_trigger-
|
|
29
|
-
"trigger-token": "awsui_trigger-
|
|
30
|
-
"paragraph": "
|
|
5
|
+
"root": "awsui_root_55fkh_qnusp_10",
|
|
6
|
+
"textarea-readonly": "awsui_textarea-readonly_55fkh_qnusp_55",
|
|
7
|
+
"disabled": "awsui_disabled_55fkh_qnusp_61",
|
|
8
|
+
"textarea-invalid": "awsui_textarea-invalid_55fkh_qnusp_69",
|
|
9
|
+
"textarea-warning": "awsui_textarea-warning_55fkh_qnusp_97",
|
|
10
|
+
"textarea": "awsui_textarea_55fkh_qnusp_55",
|
|
11
|
+
"placeholder-visible": "awsui_placeholder-visible_55fkh_qnusp_192",
|
|
12
|
+
"invalid": "awsui_invalid_55fkh_qnusp_228",
|
|
13
|
+
"warning": "awsui_warning_55fkh_qnusp_228",
|
|
14
|
+
"textarea-disabled": "awsui_textarea-disabled_55fkh_qnusp_231",
|
|
15
|
+
"textarea-wrapper": "awsui_textarea-wrapper_55fkh_qnusp_248",
|
|
16
|
+
"editable-wrapper": "awsui_editable-wrapper_55fkh_qnusp_253",
|
|
17
|
+
"editable-element": "awsui_editable-element_55fkh_qnusp_259",
|
|
18
|
+
"primary-action": "awsui_primary-action_55fkh_qnusp_266",
|
|
19
|
+
"action-button": "awsui_action-button_55fkh_qnusp_274",
|
|
20
|
+
"secondary-content": "awsui_secondary-content_55fkh_qnusp_279",
|
|
21
|
+
"with-paddings": "awsui_with-paddings_55fkh_qnusp_314",
|
|
22
|
+
"action-stripe": "awsui_action-stripe_55fkh_qnusp_324",
|
|
23
|
+
"secondary-actions": "awsui_secondary-actions_55fkh_qnusp_363",
|
|
24
|
+
"with-paddings-and-actions": "awsui_with-paddings-and-actions_55fkh_qnusp_381",
|
|
25
|
+
"buffer": "awsui_buffer_55fkh_qnusp_385",
|
|
26
|
+
"token-container": "awsui_token-container_55fkh_qnusp_391",
|
|
27
|
+
"reference-wrapper": "awsui_reference-wrapper_55fkh_qnusp_399",
|
|
28
|
+
"trigger-base": "awsui_trigger-base_55fkh_qnusp_403",
|
|
29
|
+
"trigger-token": "awsui_trigger-token_55fkh_qnusp_407",
|
|
30
|
+
"paragraph": "awsui_paragraph_55fkh_qnusp_413"
|
|
31
31
|
};
|
|
32
32
|
|
|
@@ -38,8 +38,8 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
38
38
|
syntax: "*";
|
|
39
39
|
inherits: false;
|
|
40
40
|
}
|
|
41
|
-
/* awsui:style-api-slot name=control tokens=color, background-color, border-color, focus-ring-color, focus-ring-width, focus-ring-radius, focus-ring-gutter-block, focus-ring-gutter-inline */
|
|
42
|
-
.awsui_radio-
|
|
41
|
+
/* awsui:style-api-slot name=control tokens=color, background-color, border-color, focus-ring-color, focus-ring-width, focus-ring-radius, focus-ring-gutter-block, focus-ring-gutter-inline properties= */
|
|
42
|
+
.awsui_radio-button_zdbjz_cw5ye_42:not(#\9) {
|
|
43
43
|
border-collapse: separate;
|
|
44
44
|
border-spacing: 0;
|
|
45
45
|
box-sizing: border-box;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GroupedControlContextProps } from '../internal/context/control-group-context';
|
|
2
2
|
import { SegmentedControlProps } from './interfaces';
|
|
3
3
|
interface InternalSegmentedControlComponentProps extends SegmentedControlProps {
|
|
4
|
-
|
|
4
|
+
groupedControlProps?: GroupedControlContextProps;
|
|
5
5
|
}
|
|
6
6
|
export default function InternalSegmentedControl({
|
|
7
7
|
selectedId,
|
|
@@ -10,6 +10,6 @@ export default function InternalSegmentedControl({
|
|
|
10
10
|
ariaLabelledby,
|
|
11
11
|
onChange,
|
|
12
12
|
style,
|
|
13
|
-
|
|
13
|
+
groupedControlProps
|
|
14
14
|
}: InternalSegmentedControlComponentProps): JSX.Element;
|
|
15
15
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-segmented-control.d.ts","sourceRoot":"","sources":["../../../src/segmented-control/internal-segmented-control.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"internal-segmented-control.d.ts","sourceRoot":"","sources":["../../../src/segmented-control/internal-segmented-control.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAKvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAMrD,UAAU,sCAAuC,SAAQ,qBAAqB;IAC5E,mBAAmB,CAAC,EAAE,0BAA0B,CAAC;CAClD;AAED,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAC/C,UAAU,EACV,OAAO,EACP,KAAK,EACL,cAAc,EACd,QAAQ,EACR,KAAK,EACL,mBAAmB,GACpB,EAAE,sCAAsC,eAwFxC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import React, { useRef } from 'react';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
+
import { getGroupedControlClassNames } from '../internal/components/control-group/grouped-control-styles';
|
|
5
6
|
import { fireNonCancelableEvent } from '../internal/events';
|
|
6
7
|
import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
7
8
|
import { KeyCode } from '../internal/keycode';
|
|
@@ -9,7 +10,7 @@ import handleKey from '../internal/utils/handle-key';
|
|
|
9
10
|
import { Segment } from './segment';
|
|
10
11
|
import { getSegmentedControlRootStyles } from './style';
|
|
11
12
|
import styles from './styles.css.js';
|
|
12
|
-
export default function InternalSegmentedControl({ selectedId, options, label, ariaLabelledby, onChange, style,
|
|
13
|
+
export default function InternalSegmentedControl({ selectedId, options, label, ariaLabelledby, onChange, style, groupedControlProps, }) {
|
|
13
14
|
const segmentByIdRef = useRef({});
|
|
14
15
|
const selectedOptions = (options || []).filter(option => {
|
|
15
16
|
return option.id === selectedId;
|
|
@@ -30,10 +31,12 @@ export default function InternalSegmentedControl({ selectedId, options, label, a
|
|
|
30
31
|
(_a = segmentByIdRef.current[nextSegmentId]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
31
32
|
};
|
|
32
33
|
const isVisualRefresh = useVisualRefresh();
|
|
33
|
-
|
|
34
|
+
const isGrouped = !!(groupedControlProps === null || groupedControlProps === void 0 ? void 0 : groupedControlProps.position);
|
|
35
|
+
const isGroupedVertical = isGrouped && (groupedControlProps === null || groupedControlProps === void 0 ? void 0 : groupedControlProps.direction) === 'vertical';
|
|
36
|
+
const groupedControlClassNames = isGrouped ? getGroupedControlClassNames(styles, groupedControlProps) : [];
|
|
37
|
+
return (React.createElement("div", { className: clsx(styles['segment-part'], styles[`segment-count-${options === null || options === void 0 ? void 0 : options.length}`], ...groupedControlClassNames, {
|
|
34
38
|
[styles.refresh]: isVisualRefresh,
|
|
35
|
-
[styles
|
|
36
|
-
[styles[`grouped-${groupedControlPosition}`]]: !!groupedControlPosition,
|
|
39
|
+
[styles['grouped-vertical']]: isGroupedVertical,
|
|
37
40
|
}), "aria-label": label, "aria-labelledby": ariaLabelledby, role: "toolbar", style: getSegmentedControlRootStyles(style) }, options &&
|
|
38
41
|
options.map((option, index) => {
|
|
39
42
|
const isActive = selectedId === option.id;
|
|
@@ -56,7 +59,7 @@ export default function InternalSegmentedControl({ selectedId, options, label, a
|
|
|
56
59
|
if (selectedId !== option.id) {
|
|
57
60
|
fireNonCancelableEvent(onChange, { selectedId: option.id });
|
|
58
61
|
}
|
|
59
|
-
}, onKeyDown: event => moveHighlight(event, focusableSegmentIndex), style: style }));
|
|
62
|
+
}, onKeyDown: event => moveHighlight(event, focusableSegmentIndex), style: style, fullWidth: isGroupedVertical }));
|
|
60
63
|
})));
|
|
61
64
|
}
|
|
62
65
|
//# sourceMappingURL=internal-segmented-control.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-segmented-control.js","sourceRoot":"","sources":["../../../src/segmented-control/internal-segmented-control.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"internal-segmented-control.js","sourceRoot":"","sources":["../../../src/segmented-control/internal-segmented-control.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,2BAA2B,EAAE,MAAM,6DAA6D,CAAC;AAE1G,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,SAAS,MAAM,8BAA8B,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAMrC,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAC/C,UAAU,EACV,OAAO,EACP,KAAK,EACL,cAAc,EACd,QAAQ,EACR,KAAK,EACL,mBAAmB,GACoB;IACvC,MAAM,cAAc,GAAG,MAAM,CAAsC,EAAE,CAAC,CAAC;IACvE,MAAM,eAAe,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QACtD,OAAO,MAAM,CAAC,EAAE,KAAK,UAAU,CAAC;IAClC,CAAC,CAAC,CAAC;IACH,MAAM,qBAAqB,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,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AAM,CAAC,OAAO,EACvB,OAAO,EAAE,MAAM,CAAC,OAAO,EACvB,OAAO,EAAE,MAAM,CAAC,OAAO,EACvB,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,IAAI,CAAC,EAAE;oBACV,IAAI,IAAI,EAAE,CAAC;wBACT,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;oBAC3C,CAAC;yBAAM,CAAC;wBACN,OAAO,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;oBAC3C,CAAC;gBACH,CAAC,EACD,OAAO,EAAE,GAAG,EAAE;oBACZ,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;wBACpB,OAAO;oBACT,CAAC;oBAED,IAAI,UAAU,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC;wBAC7B,sBAAsB,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;oBAC9D,CAAC;gBACH,CAAC,EACD,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,qBAAqB,CAAC,EAC/D,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,iBAAiB,GAC5B,CACH,CAAC;QACJ,CAAC,CAAC,CACA,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { getGroupedControlClassNames } from '../internal/components/control-group/grouped-control-styles';\nimport { GroupedControlContextProps } from '../internal/context/control-group-context';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { KeyCode } from '../internal/keycode';\nimport handleKey from '../internal/utils/handle-key';\nimport { SegmentedControlProps } from './interfaces';\nimport { Segment } from './segment';\nimport { getSegmentedControlRootStyles } from './style';\n\nimport styles from './styles.css.js';\n\ninterface InternalSegmentedControlComponentProps extends SegmentedControlProps {\n groupedControlProps?: GroupedControlContextProps;\n}\n\nexport default function InternalSegmentedControl({\n selectedId,\n options,\n label,\n ariaLabelledby,\n onChange,\n style,\n groupedControlProps,\n}: InternalSegmentedControlComponentProps) {\n const segmentByIdRef = useRef<{ [id: string]: HTMLButtonElement }>({});\n const selectedOptions = (options || []).filter(option => {\n return option.id === selectedId;\n });\n const currentSelectedOption = selectedOptions.length ? selectedOptions[0] : null;\n const focusableSegments = (options || []).filter(\n option => !option.disabled || (option.disabled && !!option.disabledReason)\n );\n\n const moveHighlight = (event: React.KeyboardEvent<HTMLButtonElement>, activeIndex: number) => {\n if (event.keyCode !== KeyCode.right && event.keyCode !== KeyCode.left) {\n return;\n }\n\n let nextIndex = activeIndex;\n\n handleKey(event, {\n onInlineStart: () => (nextIndex = activeIndex === 0 ? focusableSegments.length - 1 : activeIndex - 1),\n onInlineEnd: () => (nextIndex = activeIndex + 1 === focusableSegments.length ? 0 : activeIndex + 1),\n });\n\n const nextSegmentId = focusableSegments[nextIndex].id;\n segmentByIdRef.current[nextSegmentId]?.focus();\n };\n const isVisualRefresh = useVisualRefresh();\n\n const isGrouped = !!groupedControlProps?.position;\n const isGroupedVertical = isGrouped && groupedControlProps?.direction === 'vertical';\n\n const groupedControlClassNames = isGrouped ? getGroupedControlClassNames(styles, groupedControlProps) : [];\n\n return (\n <div\n className={clsx(styles['segment-part'], styles[`segment-count-${options?.length}`], ...groupedControlClassNames, {\n [styles.refresh]: isVisualRefresh,\n [styles['grouped-vertical']]: isGroupedVertical,\n })}\n aria-label={label}\n aria-labelledby={ariaLabelledby}\n role=\"toolbar\"\n style={getSegmentedControlRootStyles(style)}\n >\n {options &&\n options.map((option: SegmentedControlProps.Option, index) => {\n const isActive = selectedId === option.id;\n const focusableSegmentIndex = focusableSegments.indexOf(option);\n let tabIndex = isActive ? 0 : -1;\n if (currentSelectedOption === null && focusableSegmentIndex === 0) {\n tabIndex = 0;\n }\n return (\n <Segment\n key={index}\n id={option.id}\n disabled={!!option.disabled}\n disabledReason={option.disabledReason}\n iconName={option.iconName}\n iconAlt={option.iconAlt}\n iconUrl={option.iconUrl}\n iconSvg={option.iconSvg}\n text={option.text}\n isActive={isActive}\n tabIndex={tabIndex}\n ref={node => {\n if (node) {\n segmentByIdRef.current[option.id] = node;\n } else {\n delete segmentByIdRef.current[option.id];\n }\n }}\n onClick={() => {\n if (option.disabled) {\n return;\n }\n\n if (selectedId !== option.id) {\n fireNonCancelableEvent(onChange, { selectedId: option.id });\n }\n }}\n onKeyDown={event => moveHighlight(event, focusableSegmentIndex)}\n style={style}\n fullWidth={isGroupedVertical}\n />\n );\n })}\n </div>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/segmented-control/internal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/segmented-control/internal.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAKrD,KAAK,6BAA6B,GAAG,qBAAqB,GAAG,0BAA0B,CAAC;AAExF,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAC/C,UAAU,EACV,OAAO,EACP,KAAK,EACL,cAAc,EACd,QAAQ,EACR,iBAAiB,EACjB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,6BAA6B,eA2C/B"}
|
|
@@ -4,6 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import InternalFormField from '../form-field/internal';
|
|
6
6
|
import { getBaseProps } from '../internal/base-component';
|
|
7
|
+
import { getGroupedControlClassNames } from '../internal/components/control-group/grouped-control-styles';
|
|
7
8
|
import { useGroupedControlContext } from '../internal/context/control-group-context';
|
|
8
9
|
import { fireNonCancelableEvent } from '../internal/events';
|
|
9
10
|
import InternalSelect from '../select/internal';
|
|
@@ -11,7 +12,7 @@ import InternalSegmentedControlComponent from './internal-segmented-control';
|
|
|
11
12
|
import styles from './styles.css.js';
|
|
12
13
|
export default function InternalSegmentedControl({ selectedId, options, label, ariaLabelledby, onChange, __internalRootRef, style, ...props }) {
|
|
13
14
|
const baseProps = getBaseProps(props);
|
|
14
|
-
const
|
|
15
|
+
const groupedControlProps = useGroupedControlContext();
|
|
15
16
|
const selectOptions = (options || []).map(option => {
|
|
16
17
|
const label = option.text || option.iconAlt;
|
|
17
18
|
return { ...option, label, value: option.id };
|
|
@@ -27,11 +28,8 @@ export default function InternalSegmentedControl({ selectedId, options, label, a
|
|
|
27
28
|
onChange: event => fireNonCancelableEvent(onChange, { selectedId: event.detail.selectedOption.value }),
|
|
28
29
|
};
|
|
29
30
|
return (React.createElement("div", { ...baseProps, className: clsx(baseProps.className, styles.root), ref: __internalRootRef },
|
|
30
|
-
React.createElement(InternalSegmentedControlComponent, { selectedId: selectedId, options: options, label: label, ariaLabelledby: ariaLabelledby, onChange: onChange, style: style,
|
|
31
|
-
React.createElement("div", { className: clsx(styles.select,
|
|
32
|
-
[styles.grouped]: !!groupedControlPosition,
|
|
33
|
-
[styles[`grouped-${groupedControlPosition}`]]: !!groupedControlPosition,
|
|
34
|
-
}) },
|
|
31
|
+
React.createElement(InternalSegmentedControlComponent, { selectedId: selectedId, options: options, label: label, ariaLabelledby: ariaLabelledby, onChange: onChange, style: style, groupedControlProps: groupedControlProps }),
|
|
32
|
+
React.createElement("div", { className: clsx(styles.select, ...getGroupedControlClassNames(styles, groupedControlProps)) },
|
|
35
33
|
ariaLabelledby && React.createElement(InternalSelect, { ...selectProps, ariaLabelledby: ariaLabelledby }),
|
|
36
34
|
!ariaLabelledby && label && (React.createElement(InternalFormField, { label: label, stretch: true },
|
|
37
35
|
React.createElement(InternalSelect, { ...selectProps }))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/segmented-control/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,cAAuC,MAAM,oBAAoB,CAAC;AAEzE,OAAO,iCAAiC,MAAM,8BAA8B,CAAC;AAE7E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAC/C,UAAU,EACV,OAAO,EACP,KAAK,EACL,cAAc,EACd,QAAQ,EACR,iBAAiB,EACjB,KAAK,EACL,GAAG,KAAK,EACsB;IAC9B,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/segmented-control/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,6DAA6D,CAAC;AAC1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,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EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,iBAAiB;QAC3F,oBAAC,iCAAiC,IAChC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,mBAAmB,EAAE,mBAAmB,GACxC;QACF,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,2BAA2B,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;YAC7F,cAAc,IAAI,oBAAC,cAAc,OAAK,WAAW,EAAE,cAAc,EAAE,cAAc,GAAI;YACrF,CAAC,cAAc,IAAI,KAAK,IAAI,CAC3B,oBAAC,iBAAiB,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI;gBAC5C,oBAAC,cAAc,OAAK,WAAW,GAAI,CACjB,CACrB;YACA,CAAC,cAAc,IAAI,CAAC,KAAK,IAAI,oBAAC,cAAc,OAAK,WAAW,GAAI,CAC7D,CACF,CACP,CAAC;AACJ,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 InternalFormField from '../form-field/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { getGroupedControlClassNames } from '../internal/components/control-group/grouped-control-styles';\nimport { useGroupedControlContext } from '../internal/context/control-group-context';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport InternalSelect, { InternalSelectProps } from '../select/internal';\nimport { SegmentedControlProps } from './interfaces';\nimport InternalSegmentedControlComponent from './internal-segmented-control';\n\nimport styles from './styles.css.js';\n\ntype InternalSegmentedControlProps = SegmentedControlProps & InternalBaseComponentProps;\n\nexport default function InternalSegmentedControl({\n selectedId,\n options,\n label,\n ariaLabelledby,\n onChange,\n __internalRootRef,\n style,\n ...props\n}: InternalSegmentedControlProps) {\n const baseProps = getBaseProps(props);\n const groupedControlProps = useGroupedControlContext();\n\n const selectOptions = (options || []).map(option => {\n const label = option.text || option.iconAlt;\n return { ...option, label, value: option.id };\n });\n\n const selectedOptions = selectOptions.filter(option => {\n return option.value === selectedId;\n });\n const currentSelectedOption = selectedOptions.length ? selectedOptions[0] : null;\n\n const selectProps: InternalSelectProps = {\n options: selectOptions,\n selectedOption: currentSelectedOption,\n triggerVariant: 'option',\n onChange: event => fireNonCancelableEvent(onChange, { selectedId: event.detail.selectedOption.value! }),\n };\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={__internalRootRef}>\n <InternalSegmentedControlComponent\n selectedId={selectedId}\n options={options}\n label={label}\n ariaLabelledby={ariaLabelledby}\n onChange={onChange}\n style={style}\n groupedControlProps={groupedControlProps}\n />\n <div className={clsx(styles.select, ...getGroupedControlClassNames(styles, groupedControlProps))}>\n {ariaLabelledby && <InternalSelect {...selectProps} ariaLabelledby={ariaLabelledby} />}\n {!ariaLabelledby && label && (\n <InternalFormField label={label} stretch={true}>\n <InternalSelect {...selectProps} />\n </InternalFormField>\n )}\n {!ariaLabelledby && !label && <InternalSelect {...selectProps} />}\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -6,6 +6,7 @@ interface SegmentProps extends SegmentedControlProps.Option {
|
|
|
6
6
|
isActive: boolean;
|
|
7
7
|
tabIndex: number;
|
|
8
8
|
style: SegmentedControlProps['style'];
|
|
9
|
+
fullWidth?: boolean;
|
|
9
10
|
}
|
|
10
11
|
export declare const Segment: React.ForwardRefExoticComponent<SegmentProps & React.RefAttributes<HTMLButtonElement>>;
|
|
11
12
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../../src/segmented-control/segment.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAShD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAKrD,UAAU,YAAa,SAAQ,qBAAqB,CAAC,MAAM;IACzD,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAC9D,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACnE,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../../src/segmented-control/segment.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAShD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAKrD,UAAU,YAAa,SAAQ,qBAAqB,CAAC,MAAM;IACzD,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAC9D,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACnE,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,OAAO,wFAmFnB,CAAC"}
|
|
@@ -9,13 +9,13 @@ import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
|
9
9
|
import Tooltip from '../tooltip/internal.js';
|
|
10
10
|
import { getSegmentedControlSegmentStyles } from './style';
|
|
11
11
|
import styles from './styles.css.js';
|
|
12
|
-
export const Segment = React.forwardRef(({ disabled, disabledReason, text, iconName, iconAlt, iconUrl, iconSvg, isActive, onClick, onKeyDown, tabIndex, id, style, }, ref) => {
|
|
12
|
+
export const Segment = React.forwardRef(({ disabled, disabledReason, text, iconName, iconAlt, iconUrl, iconSvg, isActive, onClick, onKeyDown, tabIndex, id, style, fullWidth, }, ref) => {
|
|
13
13
|
const buttonRef = useRef(null);
|
|
14
14
|
const [showTooltip, setShowTooltip] = useState(false);
|
|
15
15
|
const isDisabledWithReason = disabled && !!disabledReason;
|
|
16
16
|
const { targetProps, descriptionEl } = useHiddenDescription(disabledReason);
|
|
17
17
|
const isVisualRefresh = useVisualRefresh();
|
|
18
|
-
return (React.createElement("button", { className: clsx(styles.segment, { [styles.disabled]: !!disabled }, { [styles.selected]: isActive }, { [styles.refresh]: isVisualRefresh }), ref: useMergeRefs(ref, buttonRef), onClick: onClick, onKeyDown: onKeyDown, disabled: disabled && !disabledReason, "aria-disabled": isDisabledWithReason ? 'true' : undefined, type: "button", tabIndex: tabIndex, "aria-pressed": isActive ? 'true' : 'false', "aria-label": !text ? iconAlt : undefined, onFocus: isDisabledWithReason ? () => setShowTooltip(true) : undefined, onBlur: isDisabledWithReason ? () => setShowTooltip(false) : undefined, onMouseEnter: isDisabledWithReason ? () => setShowTooltip(true) : undefined, onMouseLeave: isDisabledWithReason ? () => setShowTooltip(false) : undefined, ...(isDisabledWithReason ? targetProps : {}), "data-testid": id, "data-awsui-motion-trigger": "hover", "data-awsui-motion-target": "", style: getSegmentedControlSegmentStyles(style) },
|
|
18
|
+
return (React.createElement("button", { className: clsx(styles.segment, { [styles.disabled]: !!disabled }, { [styles.selected]: isActive }, { [styles.refresh]: isVisualRefresh }, { [styles['full-width']]: fullWidth }), ref: useMergeRefs(ref, buttonRef), onClick: onClick, onKeyDown: onKeyDown, disabled: disabled && !disabledReason, "aria-disabled": isDisabledWithReason ? 'true' : undefined, type: "button", tabIndex: tabIndex, "aria-pressed": isActive ? 'true' : 'false', "aria-label": !text ? iconAlt : undefined, onFocus: isDisabledWithReason ? () => setShowTooltip(true) : undefined, onBlur: isDisabledWithReason ? () => setShowTooltip(false) : undefined, onMouseEnter: isDisabledWithReason ? () => setShowTooltip(true) : undefined, onMouseLeave: isDisabledWithReason ? () => setShowTooltip(false) : undefined, ...(isDisabledWithReason ? targetProps : {}), "data-testid": id, "data-awsui-motion-trigger": "hover", "data-awsui-motion-target": "", style: getSegmentedControlSegmentStyles(style) },
|
|
19
19
|
(iconName || iconUrl || iconSvg) && (React.createElement(InternalIcon, { className: clsx(styles.icon, text ? styles['with-text'] : styles['with-no-text']), name: iconName, url: iconUrl, svg: iconSvg, alt: iconAlt, variant: disabled ? 'disabled' : 'normal' })),
|
|
20
20
|
React.createElement("span", null, text),
|
|
21
21
|
isDisabledWithReason && (React.createElement(React.Fragment, null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segment.js","sourceRoot":"","sources":["../../../src/segmented-control/segment.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAE7E,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,oBAAoB,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAE7C,OAAO,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAC;AAE3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"segment.js","sourceRoot":"","sources":["../../../src/segmented-control/segment.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,IAAI,MAAM,MAA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I,EAAE,QAAQ,EACd,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,GACzC,CACH;QACD,kCAAO,IAAI,CAAQ;QAElB,oBAAoB,IAAI,CACvB;YACG,aAAa;YACb,WAAW,IAAI,CACd,oBAAC,OAAO,IACN,SAAS,EAAE,MAAM,CAAC,yBAAyB,CAAC,EAC5C,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,EACjC,OAAO,EAAE,cAAe,EACxB,QAAQ,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,GACrC,CACH,CACA,CACJ,CACM,CACV,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalIcon from '../icon/internal';\nimport useHiddenDescription from '../internal/hooks/use-hidden-description';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport Tooltip from '../tooltip/internal.js';\nimport { SegmentedControlProps } from './interfaces';\nimport { getSegmentedControlSegmentStyles } from './style';\n\nimport styles from './styles.css.js';\n\ninterface SegmentProps extends SegmentedControlProps.Option {\n onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;\n onKeyDown: (event: React.KeyboardEvent<HTMLButtonElement>) => void;\n isActive: boolean;\n tabIndex: number;\n style: SegmentedControlProps['style'];\n fullWidth?: boolean;\n}\n\nexport const Segment = React.forwardRef(\n (\n {\n disabled,\n disabledReason,\n text,\n iconName,\n iconAlt,\n iconUrl,\n iconSvg,\n isActive,\n onClick,\n onKeyDown,\n tabIndex,\n id,\n style,\n fullWidth,\n }: SegmentProps,\n ref: React.Ref<HTMLButtonElement>\n ) => {\n const buttonRef = useRef<HTMLElement>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n const isDisabledWithReason = disabled && !!disabledReason;\n\n const { targetProps, descriptionEl } = useHiddenDescription(disabledReason);\n const isVisualRefresh = useVisualRefresh();\n\n return (\n <button\n className={clsx(\n styles.segment,\n { [styles.disabled]: !!disabled },\n { [styles.selected]: isActive },\n { [styles.refresh]: isVisualRefresh },\n { [styles['full-width']]: fullWidth }\n )}\n ref={useMergeRefs(ref, buttonRef)}\n onClick={onClick}\n onKeyDown={onKeyDown}\n disabled={disabled && !disabledReason}\n aria-disabled={isDisabledWithReason ? 'true' : undefined}\n type=\"button\"\n tabIndex={tabIndex}\n aria-pressed={isActive ? 'true' : 'false'}\n aria-label={!text ? iconAlt : undefined}\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 data-testid={id}\n data-awsui-motion-trigger=\"hover\"\n data-awsui-motion-target=\"\"\n style={getSegmentedControlSegmentStyles(style)}\n >\n {(iconName || iconUrl || iconSvg) && (\n <InternalIcon\n className={clsx(styles.icon, text ? styles['with-text'] : styles['with-no-text'])}\n name={iconName}\n url={iconUrl}\n svg={iconSvg}\n alt={iconAlt}\n variant={disabled ? 'disabled' : 'normal'}\n />\n )}\n <span>{text}</span>\n\n {isDisabledWithReason && (\n <>\n {descriptionEl}\n {showTooltip && (\n <Tooltip\n className={styles['disabled-reason-tooltip']}\n getTrack={() => buttonRef.current}\n content={disabledReason!}\n onEscape={() => setShowTooltip(false)}\n />\n )}\n </>\n )}\n </button>\n );\n }\n);\n"]}
|
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"segment": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"with-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"grouped
|
|
15
|
-
"grouped-
|
|
16
|
-
"grouped-
|
|
17
|
-
"grouped-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
4
|
+
"segment": "awsui_segment_8cbea_qppsy_17",
|
|
5
|
+
"full-width": "awsui_full-width_8cbea_qppsy_44",
|
|
6
|
+
"refresh": "awsui_refresh_8cbea_qppsy_47",
|
|
7
|
+
"disabled": "awsui_disabled_8cbea_qppsy_53",
|
|
8
|
+
"selected": "awsui_selected_8cbea_qppsy_110",
|
|
9
|
+
"icon": "awsui_icon_8cbea_qppsy_120",
|
|
10
|
+
"with-text": "awsui_with-text_8cbea_qppsy_124",
|
|
11
|
+
"with-no-text": "awsui_with-no-text_8cbea_qppsy_130",
|
|
12
|
+
"root": "awsui_root_8cbea_qppsy_135",
|
|
13
|
+
"segment-part": "awsui_segment-part_8cbea_qppsy_167",
|
|
14
|
+
"grouped": "awsui_grouped_8cbea_qppsy_188",
|
|
15
|
+
"grouped-only": "awsui_grouped-only_8cbea_qppsy_188",
|
|
16
|
+
"grouped-vertical": "awsui_grouped-vertical_8cbea_qppsy_192",
|
|
17
|
+
"grouped-horizontal-first": "awsui_grouped-horizontal-first_8cbea_qppsy_203",
|
|
18
|
+
"grouped-horizontal-middle": "awsui_grouped-horizontal-middle_8cbea_qppsy_207",
|
|
19
|
+
"grouped-horizontal-last": "awsui_grouped-horizontal-last_8cbea_qppsy_213",
|
|
20
|
+
"grouped-vertical-first": "awsui_grouped-vertical-first_8cbea_qppsy_217",
|
|
21
|
+
"grouped-vertical-middle": "awsui_grouped-vertical-middle_8cbea_qppsy_221",
|
|
22
|
+
"grouped-vertical-last": "awsui_grouped-vertical-last_8cbea_qppsy_227",
|
|
23
|
+
"select": "awsui_select_8cbea_qppsy_110",
|
|
24
|
+
"segment-count-2": "awsui_segment-count-2_8cbea_qppsy_244",
|
|
25
|
+
"segment-count-3": "awsui_segment-count-3_8cbea_qppsy_251",
|
|
26
|
+
"segment-count-4": "awsui_segment-count-4_8cbea_qppsy_258",
|
|
27
|
+
"segment-count-5": "awsui_segment-count-5_8cbea_qppsy_265",
|
|
28
|
+
"segment-count-6": "awsui_segment-count-6_8cbea_qppsy_272",
|
|
29
|
+
"disabled-reason-tooltip": "awsui_disabled-reason-tooltip_8cbea_qppsy_279"
|
|
25
30
|
};
|
|
26
31
|
|