@cloudscape-design/components-themeable 3.0.690 → 3.0.692
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/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/tabs/tab-header-bar.scss +86 -48
- package/lib/internal/template/button-dropdown/index.d.ts.map +1 -1
- package/lib/internal/template/button-dropdown/index.js +5 -0
- package/lib/internal/template/button-dropdown/index.js.map +1 -1
- package/lib/internal/template/button-dropdown/utils/create-items-tree.d.ts +1 -0
- package/lib/internal/template/button-dropdown/utils/create-items-tree.d.ts.map +1 -1
- package/lib/internal/template/button-dropdown/utils/create-items-tree.js +1 -1
- package/lib/internal/template/button-dropdown/utils/create-items-tree.js.map +1 -1
- package/lib/internal/template/button-dropdown/utils/utils.d.ts +1 -0
- package/lib/internal/template/button-dropdown/utils/utils.d.ts.map +1 -1
- package/lib/internal/template/button-dropdown/utils/utils.js +10 -0
- package/lib/internal/template/button-dropdown/utils/utils.js.map +1 -1
- package/lib/internal/template/i18n/messages/all.all.js +1 -1
- package/lib/internal/template/i18n/messages/all.all.json +1 -1
- package/lib/internal/template/i18n/messages/all.de.js +1 -1
- package/lib/internal/template/i18n/messages/all.de.json +1 -1
- package/lib/internal/template/i18n/messages/all.en-GB.js +1 -1
- package/lib/internal/template/i18n/messages/all.en-GB.json +1 -1
- package/lib/internal/template/i18n/messages/all.en.js +1 -1
- package/lib/internal/template/i18n/messages/all.en.json +1 -1
- package/lib/internal/template/i18n/messages/all.es.js +1 -1
- package/lib/internal/template/i18n/messages/all.es.json +1 -1
- package/lib/internal/template/i18n/messages/all.fr.js +1 -1
- package/lib/internal/template/i18n/messages/all.fr.json +1 -1
- package/lib/internal/template/i18n/messages/all.id.js +1 -1
- package/lib/internal/template/i18n/messages/all.id.json +1 -1
- package/lib/internal/template/i18n/messages/all.it.js +1 -1
- package/lib/internal/template/i18n/messages/all.it.json +1 -1
- package/lib/internal/template/i18n/messages/all.ja.js +1 -1
- package/lib/internal/template/i18n/messages/all.ja.json +1 -1
- package/lib/internal/template/i18n/messages/all.ko.js +1 -1
- package/lib/internal/template/i18n/messages/all.ko.json +1 -1
- package/lib/internal/template/i18n/messages/all.pt-BR.js +1 -1
- package/lib/internal/template/i18n/messages/all.pt-BR.json +1 -1
- package/lib/internal/template/i18n/messages/all.tr.js +1 -1
- package/lib/internal/template/i18n/messages/all.tr.json +1 -1
- package/lib/internal/template/i18n/messages/all.zh-CN.js +1 -1
- package/lib/internal/template/i18n/messages/all.zh-CN.json +1 -1
- package/lib/internal/template/i18n/messages/all.zh-TW.js +1 -1
- package/lib/internal/template/i18n/messages/all.zh-TW.json +1 -1
- package/lib/internal/template/i18n/messages-types.d.ts +1 -0
- package/lib/internal/template/i18n/messages-types.d.ts.map +1 -1
- package/lib/internal/template/i18n/messages-types.js.map +1 -1
- package/lib/internal/template/internal/environment.js +1 -1
- package/lib/internal/template/internal/environment.json +1 -1
- package/lib/internal/template/tabs/interfaces.d.ts +36 -0
- package/lib/internal/template/tabs/interfaces.d.ts.map +1 -1
- package/lib/internal/template/tabs/interfaces.js.map +1 -1
- package/lib/internal/template/tabs/styles.css.js +25 -22
- package/lib/internal/template/tabs/styles.scoped.css +107 -77
- package/lib/internal/template/tabs/styles.selectors.js +25 -22
- package/lib/internal/template/tabs/tab-header-bar.d.ts.map +1 -1
- package/lib/internal/template/tabs/tab-header-bar.js +106 -17
- package/lib/internal/template/tabs/tab-header-bar.js.map +1 -1
- package/lib/internal/template/test-utils/dom/tabs/index.d.ts +38 -1
- package/lib/internal/template/test-utils/dom/tabs/index.js +53 -2
- package/lib/internal/template/test-utils/dom/tabs/index.js.map +1 -1
- package/lib/internal/template/test-utils/selectors/tabs/index.d.ts +38 -1
- package/lib/internal/template/test-utils/selectors/tabs/index.js +53 -2
- package/lib/internal/template/test-utils/selectors/tabs/index.js.map +1 -1
- package/lib/internal/template/test-utils/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
@use '../internal/hooks/focus-visible' as focus-visible;
|
|
10
10
|
|
|
11
11
|
$separator-color: awsui.$color-border-tabs-divider;
|
|
12
|
-
$label-horizontal-spacing: awsui.$space-
|
|
12
|
+
$label-horizontal-spacing: awsui.$space-xs;
|
|
13
13
|
|
|
14
14
|
.tabs-header {
|
|
15
15
|
margin-block: 0;
|
|
@@ -73,29 +73,91 @@ $label-horizontal-spacing: awsui.$space-l;
|
|
|
73
73
|
|
|
74
74
|
flex-shrink: 0;
|
|
75
75
|
display: flex;
|
|
76
|
-
max-inline-size: calc(90% -
|
|
77
|
-
|
|
78
|
-
& > button {
|
|
79
|
-
background-color: transparent;
|
|
80
|
-
}
|
|
76
|
+
max-inline-size: calc(90% - awsui.$space-l);
|
|
81
77
|
}
|
|
82
78
|
|
|
83
79
|
.tabs-tab-label {
|
|
84
80
|
display: flex;
|
|
85
81
|
align-items: center;
|
|
86
|
-
padding-block: awsui.$space-scaled-2x-xxs;
|
|
87
82
|
padding-inline: $label-horizontal-spacing;
|
|
83
|
+
padding-block: awsui.$space-scaled-2x-xxs;
|
|
88
84
|
text-align: start;
|
|
89
85
|
position: relative;
|
|
90
86
|
|
|
91
87
|
@include styles.text-wrapping;
|
|
92
88
|
}
|
|
93
89
|
|
|
90
|
+
.tabs-tab-dismiss,
|
|
91
|
+
.tabs-tab-action {
|
|
92
|
+
/* Used as a selector for tests */
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.tabs-tab-header-container {
|
|
96
|
+
position: relative;
|
|
97
|
+
|
|
98
|
+
border-block: awsui.$border-divider-section-width solid transparent;
|
|
99
|
+
border-inline: awsui.$border-divider-section-width solid transparent;
|
|
100
|
+
|
|
101
|
+
padding-inline: $label-horizontal-spacing;
|
|
102
|
+
display: flex;
|
|
103
|
+
align-items: stretch;
|
|
104
|
+
|
|
105
|
+
&,
|
|
106
|
+
& > button {
|
|
107
|
+
background-color: transparent;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
& > .tabs-tab-dismiss,
|
|
111
|
+
& > .tabs-tab-action {
|
|
112
|
+
display: flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&.refresh > span:first-of-type {
|
|
117
|
+
margin-inline-start: calc(-1 * awsui.$space-scaled-xs);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.tabs-tab-header-container:not(.tabs-tab-disabled) {
|
|
122
|
+
// This is the underline for the currently selected tab.
|
|
123
|
+
&:after {
|
|
124
|
+
content: '';
|
|
125
|
+
position: absolute;
|
|
126
|
+
inset-inline-start: 0;
|
|
127
|
+
inline-size: calc(100% - 1px);
|
|
128
|
+
inset-block-end: calc(-1 * #{awsui.$border-divider-section-width});
|
|
129
|
+
block-size: awsui.$border-active-width;
|
|
130
|
+
border-start-start-radius: awsui.$border-radius-tabs-focus-ring;
|
|
131
|
+
border-start-end-radius: awsui.$border-radius-tabs-focus-ring;
|
|
132
|
+
border-end-start-radius: awsui.$border-radius-tabs-focus-ring;
|
|
133
|
+
border-end-end-radius: awsui.$border-radius-tabs-focus-ring;
|
|
134
|
+
background: awsui.$color-border-tabs-underline;
|
|
135
|
+
opacity: 0;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
&.refresh {
|
|
139
|
+
&:after {
|
|
140
|
+
@include styles.with-motion {
|
|
141
|
+
transition: opacity awsui.$motion-duration-refresh-only-medium awsui.$motion-easing-refresh-only-c;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
94
147
|
.tabs-tab:not(:last-child) {
|
|
95
|
-
& >
|
|
96
|
-
& > button > .tabs-tab-label {
|
|
148
|
+
& > .tabs-tab-header-container {
|
|
97
149
|
margin-inline-end: calc(-1 * #{awsui.$border-divider-section-width});
|
|
98
|
-
|
|
150
|
+
&:before {
|
|
151
|
+
content: '';
|
|
152
|
+
position: absolute;
|
|
153
|
+
border-inline-end: awsui.$border-divider-section-width solid $separator-color;
|
|
154
|
+
inset: calc(#{awsui.$space-scaled-s}) 0;
|
|
155
|
+
opacity: 1;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&.refresh:before {
|
|
159
|
+
inset: calc(#{awsui.$space-scaled-s} - #{awsui.$border-active-width}) 0;
|
|
160
|
+
}
|
|
99
161
|
}
|
|
100
162
|
}
|
|
101
163
|
|
|
@@ -105,8 +167,9 @@ $label-horizontal-spacing: awsui.$space-l;
|
|
|
105
167
|
align-items: stretch;
|
|
106
168
|
text-decoration: none;
|
|
107
169
|
cursor: pointer;
|
|
108
|
-
padding-block-start: calc(#{awsui.$space-scaled-s} -
|
|
109
|
-
padding-block-end: awsui.$space-scaled-s;
|
|
170
|
+
padding-block-start: calc(#{awsui.$space-scaled-s} - 2px);
|
|
171
|
+
padding-block-end: calc(#{awsui.$space-scaled-s} - 1px);
|
|
172
|
+
|
|
110
173
|
padding-inline: 0;
|
|
111
174
|
margin-block-start: 1px;
|
|
112
175
|
border-block: awsui.$border-divider-section-width solid transparent;
|
|
@@ -116,10 +179,15 @@ $label-horizontal-spacing: awsui.$space-l;
|
|
|
116
179
|
line-height: awsui.$font-tabs-line-height;
|
|
117
180
|
font-weight: awsui.$font-wayfinding-link-active-weight;
|
|
118
181
|
color: awsui.$color-text-interactive-default;
|
|
182
|
+
|
|
183
|
+
padding-inline-start: calc(#{awsui.$space-xxs} - 1px);
|
|
184
|
+
padding-inline-end: awsui.$space-xxs;
|
|
185
|
+
|
|
119
186
|
&.refresh {
|
|
120
187
|
padding-block-start: calc(awsui.$space-static-xs - 1px);
|
|
121
|
-
padding-block-end: awsui.$space-static-xs;
|
|
122
|
-
|
|
188
|
+
padding-block-end: calc(awsui.$space-static-xs - 1px);
|
|
189
|
+
|
|
190
|
+
margin-block-start: 0;
|
|
123
191
|
}
|
|
124
192
|
|
|
125
193
|
&:hover {
|
|
@@ -129,23 +197,20 @@ $label-horizontal-spacing: awsui.$space-l;
|
|
|
129
197
|
&:focus {
|
|
130
198
|
outline: none;
|
|
131
199
|
}
|
|
200
|
+
|
|
132
201
|
@include styles.font-smoothing;
|
|
133
202
|
|
|
134
203
|
@include focus-visible.when-visible {
|
|
135
204
|
z-index: 1;
|
|
136
205
|
@include styles.focus-highlight(awsui.$space-tabs-focus-outline-gutter);
|
|
137
|
-
|
|
138
|
-
& > button > .tabs-tab-label {
|
|
139
|
-
border-inline-end-color: transparent;
|
|
140
|
-
}
|
|
206
|
+
border-inline-end-color: transparent;
|
|
141
207
|
}
|
|
142
208
|
}
|
|
143
209
|
|
|
144
210
|
// Remediate focus shadow
|
|
145
211
|
.tabs-tab:first-child {
|
|
146
212
|
margin-inline-start: 1px;
|
|
147
|
-
& >
|
|
148
|
-
& > button > .tabs-tab-label {
|
|
213
|
+
& > .tabs-tab-header-container {
|
|
149
214
|
padding-inline-start: calc(#{$label-horizontal-spacing} - 1px);
|
|
150
215
|
}
|
|
151
216
|
}
|
|
@@ -153,8 +218,7 @@ $label-horizontal-spacing: awsui.$space-l;
|
|
|
153
218
|
// Remediate focus shadow
|
|
154
219
|
.tabs-tab:last-child {
|
|
155
220
|
margin-inline-end: 1px;
|
|
156
|
-
& >
|
|
157
|
-
& > button > .tabs-tab-label {
|
|
221
|
+
& > .tabs-tab-header-container {
|
|
158
222
|
padding-inline-end: calc(#{$label-horizontal-spacing} - 1px);
|
|
159
223
|
}
|
|
160
224
|
}
|
|
@@ -169,32 +233,6 @@ $label-horizontal-spacing: awsui.$space-l;
|
|
|
169
233
|
}
|
|
170
234
|
}
|
|
171
235
|
|
|
172
|
-
.tabs-tab-link:not(.tabs-tab-disabled) {
|
|
173
|
-
// This is the underline for the currently selected tab.
|
|
174
|
-
&:after {
|
|
175
|
-
content: '';
|
|
176
|
-
position: absolute;
|
|
177
|
-
inset-inline-start: 0;
|
|
178
|
-
inline-size: 100%;
|
|
179
|
-
inset-block-end: calc(-1 * #{awsui.$border-divider-section-width});
|
|
180
|
-
block-size: awsui.$border-active-width;
|
|
181
|
-
border-start-start-radius: awsui.$border-radius-tabs-focus-ring;
|
|
182
|
-
border-start-end-radius: awsui.$border-radius-tabs-focus-ring;
|
|
183
|
-
border-end-start-radius: awsui.$border-radius-tabs-focus-ring;
|
|
184
|
-
border-end-end-radius: awsui.$border-radius-tabs-focus-ring;
|
|
185
|
-
background: awsui.$color-border-tabs-underline;
|
|
186
|
-
opacity: 0;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
&.refresh {
|
|
190
|
-
&:after {
|
|
191
|
-
@include styles.with-motion {
|
|
192
|
-
transition: opacity awsui.$motion-duration-refresh-only-medium awsui.$motion-easing-refresh-only-c;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
236
|
.tabs-tab-active:not(.tabs-tab-disabled) {
|
|
199
237
|
color: awsui.$color-text-accent;
|
|
200
238
|
&:after {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/button-dropdown/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/button-dropdown/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAOnD,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,QAAA,MAAM,cAAc,qGAgDnB,CAAC;AAGF,eAAe,cAAc,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { __rest } from "tslib";
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import InternalButtonDropdown from './internal';
|
|
6
|
+
import { hasCheckboxItems } from './utils/utils';
|
|
6
7
|
import { getBaseProps } from '../internal/base-component';
|
|
7
8
|
import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
8
9
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
@@ -10,6 +11,10 @@ const ButtonDropdown = React.forwardRef((_a, ref) => {
|
|
|
10
11
|
var { items, variant = 'normal', loading = false, loadingText, disabled = false, expandableGroups = false, expandToViewport = false, ariaLabel, children, onItemClick, onItemFollow, mainAction } = _a, props = __rest(_a, ["items", "variant", "loading", "loadingText", "disabled", "expandableGroups", "expandToViewport", "ariaLabel", "children", "onItemClick", "onItemFollow", "mainAction"]);
|
|
11
12
|
const baseComponentProps = useBaseComponent('ButtonDropdown', {
|
|
12
13
|
props: { expandToViewport, expandableGroups, variant },
|
|
14
|
+
metadata: {
|
|
15
|
+
mainAction: !!mainAction,
|
|
16
|
+
checkboxItems: hasCheckboxItems(items),
|
|
17
|
+
},
|
|
13
18
|
});
|
|
14
19
|
const baseProps = getBaseProps(props);
|
|
15
20
|
return (React.createElement(InternalButtonDropdown, Object.assign({}, baseProps, baseComponentProps, { ref: ref, items: items, variant: variant, loading: loading, loadingText: loadingText, disabled: disabled, expandableGroups: expandableGroups, expandToViewport: expandToViewport, ariaLabel: ariaLabel, onItemClick: onItemClick, onItemFollow: onItemFollow, mainAction: mainAction }), children));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/button-dropdown/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,sBAAsB,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAIpE,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CACrC,CACE,EAcsB,EACtB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D,QAAQ,EAAE;YACR,UAAU,EAAE,CAAC,CAAC,UAAU;YACxB,aAAa,EAAE,gBAAgB,CAAC,KAAK,CAAC;SACvC;KACF,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,CACL,oBAAC,sBAAsB,oBACjB,SAAS,EACT,kBAAkB,IACtB,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,KAErB,QAAQ,CACc,CAC1B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;AACnD,eAAe,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 { ButtonDropdownProps } from './interfaces';\nimport InternalButtonDropdown from './internal';\nimport { hasCheckboxItems } from './utils/utils';\nimport { getBaseProps } from '../internal/base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\n\nexport { ButtonDropdownProps };\n\nconst ButtonDropdown = React.forwardRef(\n (\n {\n items,\n variant = 'normal',\n loading = false,\n loadingText,\n disabled = false,\n expandableGroups = false,\n expandToViewport = false,\n ariaLabel,\n children,\n onItemClick,\n onItemFollow,\n mainAction,\n ...props\n }: ButtonDropdownProps,\n ref: React.Ref<ButtonDropdownProps.Ref>\n ) => {\n const baseComponentProps = useBaseComponent('ButtonDropdown', {\n props: { expandToViewport, expandableGroups, variant },\n metadata: {\n mainAction: !!mainAction,\n checkboxItems: hasCheckboxItems(items),\n },\n });\n const baseProps = getBaseProps(props);\n return (\n <InternalButtonDropdown\n {...baseProps}\n {...baseComponentProps}\n ref={ref}\n items={items}\n variant={variant}\n loading={loading}\n loadingText={loadingText}\n disabled={disabled}\n expandableGroups={expandableGroups}\n expandToViewport={expandToViewport}\n ariaLabel={ariaLabel}\n onItemClick={onItemClick}\n onItemFollow={onItemFollow}\n mainAction={mainAction}\n >\n {children}\n </InternalButtonDropdown>\n );\n }\n);\n\napplyDisplayName(ButtonDropdown, 'ButtonDropdown');\nexport default ButtonDropdown;\n"]}
|
|
@@ -7,5 +7,6 @@ interface ItemsTreeApi {
|
|
|
7
7
|
getParentIndex: (item: ButtonDropdownProps.ItemOrGroup) => TreeIndex | null;
|
|
8
8
|
}
|
|
9
9
|
export default function createItemsTree(items: ButtonDropdownProps.Items): ItemsTreeApi;
|
|
10
|
+
export declare function traverseItems(items: ButtonDropdownProps.Items, act: (item: ButtonDropdownProps.ItemOrGroup, index: TreeIndex) => void, parentIndex?: TreeIndex): void;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=create-items-tree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-items-tree.d.ts","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/create-items-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAMpD,MAAM,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC;AAEjC,UAAU,YAAY;IAEpB,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,mBAAmB,CAAC,WAAW,GAAG,IAAI,CAAC;IAGtE,YAAY,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,WAAW,KAAK,SAAS,CAAC;IAEnE,kBAAkB,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,SAAS,GAAG,IAAI,CAAC;IAE9E,cAAc,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,WAAW,KAAK,SAAS,GAAG,IAAI,CAAC;CAC7E;AAED,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAK,EAAE,mBAAmB,CAAC,KAAK,GAAG,YAAY,CAwDtF"}
|
|
1
|
+
{"version":3,"file":"create-items-tree.d.ts","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/create-items-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAMpD,MAAM,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC;AAEjC,UAAU,YAAY;IAEpB,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,mBAAmB,CAAC,WAAW,GAAG,IAAI,CAAC;IAGtE,YAAY,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,WAAW,KAAK,SAAS,CAAC;IAEnE,kBAAkB,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,SAAS,GAAG,IAAI,CAAC;IAE9E,cAAc,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,WAAW,KAAK,SAAS,GAAG,IAAI,CAAC;CAC7E;AAED,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAK,EAAE,mBAAmB,CAAC,KAAK,GAAG,YAAY,CAwDtF;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,mBAAmB,CAAC,KAAK,EAChC,GAAG,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,WAAW,EAAE,KAAK,EAAE,SAAS,KAAK,IAAI,EACtE,WAAW,GAAE,SAAc,QAU5B"}
|
|
@@ -46,7 +46,7 @@ export default function createItemsTree(items) {
|
|
|
46
46
|
},
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
function traverseItems(items, act, parentIndex = []) {
|
|
49
|
+
export function traverseItems(items, act, parentIndex = []) {
|
|
50
50
|
items.forEach((item, index) => {
|
|
51
51
|
const itemIndex = [...parentIndex, index];
|
|
52
52
|
act(item, itemIndex);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-items-tree.js","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/create-items-tree.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAqBtC,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAgC;IACtE,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2C,CAAC;IACvE,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2C,CAAC;IACvE,MAAM,WAAW,GAAa,EAAE,CAAC;IAEjC,aAAa,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACnC,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;QACvC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAChC,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAChC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,CAAC,KAAgB,EAA0C,EAAE;YACpE,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;YAEvC,OAAO,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC;QAC3C,CAAC;QACD,YAAY,EAAE,CAAC,IAAqC,EAAa,EAAE;YACjE,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAEvC,IAAI,CAAC,QAAQ,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;aAC5D;YAED,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC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EvC,IAAI,CAAC,QAAQ,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;aAC5D;YAED,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;YAEnC,YAAY;YACZ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;gBACtB,OAAO,IAAI,CAAC;aACb;YAED,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC1C,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,KAAgC,EAChC,GAAsE,EACtE,cAAyB,EAAE;IAE3B,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5B,MAAM,SAAS,GAAG,CAAC,GAAG,WAAW,EAAE,KAAK,CAAC,CAAC;QAC1C,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAErB,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE;YACrB,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;SAC3C;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAC,KAAgB;IACtC,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAClD,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { isItemGroup } from './utils';\nimport { ButtonDropdownProps } from '../interfaces';\n\n// The function turns a tree of items into a structure optimized for lookup of\n// items and corresponding indices as well as iteration on indices in the given order.\n\n// As trees are multidimensional, the index is represented as an array\nexport type TreeIndex = number[];\n\ninterface ItemsTreeApi {\n // Returns an item for the given tree index or null if not found\n getItem: (index: TreeIndex) => ButtonDropdownProps.ItemOrGroup | null;\n // Returns the tree index of the given item. The item must be present\n // in the tree (referential comparison), or an error will be thrown\n getItemIndex: (item: ButtonDropdownProps.ItemOrGroup) => TreeIndex;\n // Returns the index of next or previous sequential node or null if out of bounds\n getSequentialIndex: (index: TreeIndex, direction: -1 | 1) => TreeIndex | null;\n // Returns parent tree index of a given item or null if no parent is present\n getParentIndex: (item: ButtonDropdownProps.ItemOrGroup) => TreeIndex | null;\n}\n\nexport default function createItemsTree(items: ButtonDropdownProps.Items): ItemsTreeApi {\n const itemToIndex = new Map<ButtonDropdownProps.ItemOrGroup, string>();\n const indexToItem = new Map<string, ButtonDropdownProps.ItemOrGroup>();\n const flatIndices: string[] = [];\n\n traverseItems(items, (item, index) => {\n const indexKey = stringifyIndex(index);\n itemToIndex.set(item, indexKey);\n indexToItem.set(indexKey, item);\n flatIndices.push(indexKey);\n });\n\n return {\n getItem: (index: TreeIndex): ButtonDropdownProps.ItemOrGroup | null => {\n const indexKey = stringifyIndex(index);\n\n return indexToItem.get(indexKey) || null;\n },\n getItemIndex: (item: ButtonDropdownProps.ItemOrGroup): TreeIndex => {\n const indexKey = itemToIndex.get(item);\n\n if (!indexKey) {\n throw new Error('Invariant violation: item is not found.');\n }\n\n return parseIndex(indexKey);\n },\n getSequentialIndex: (index: TreeIndex, direction: -1 | 1): TreeIndex | null => {\n const indexKey = stringifyIndex(index);\n const position = flatIndices.indexOf(indexKey);\n\n const nextIndexKey = flatIndices[position + direction];\n\n if (!nextIndexKey) {\n return null;\n }\n\n return parseIndex(nextIndexKey);\n },\n getParentIndex: (item: ButtonDropdownProps.ItemOrGroup): TreeIndex | null => {\n const indexKey = itemToIndex.get(item);\n\n if (!indexKey) {\n throw new Error('Invariant violation: item is not found.');\n }\n\n const index = parseIndex(indexKey);\n\n // No parent\n if (index.length === 1) {\n return null;\n }\n\n return index.slice(0, index.length - 1);\n },\n };\n}\n\nexport function traverseItems(\n items: ButtonDropdownProps.Items,\n act: (item: ButtonDropdownProps.ItemOrGroup, index: TreeIndex) => void,\n parentIndex: TreeIndex = []\n) {\n items.forEach((item, index) => {\n const itemIndex = [...parentIndex, index];\n act(item, itemIndex);\n\n if (isItemGroup(item)) {\n traverseItems(item.items, act, itemIndex);\n }\n });\n}\n\nfunction stringifyIndex(index: TreeIndex): string {\n return index.join('-');\n}\n\nfunction parseIndex(index: string): TreeIndex {\n return index.split('-').map(it => parseInt(it));\n}\n"]}
|
|
@@ -5,4 +5,5 @@ export declare const isCheckboxItem: (item: ButtonDropdownProps.ItemOrGroup) =>
|
|
|
5
5
|
export declare const getItemTarget: (item: ButtonDropdownProps.Item) => "_blank" | undefined;
|
|
6
6
|
export declare function indexIncludes(source: number[], target: number[]): boolean;
|
|
7
7
|
export declare function indexEquals(left: number[], right: number[]): boolean;
|
|
8
|
+
export declare function hasCheckboxItems(items: ButtonDropdownProps.Items): boolean;
|
|
8
9
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9D,eAAO,MAAM,WAAW,SAAU,oBAAoB,WAAW,0CACI,CAAC;AAEtE,eAAO,MAAM,UAAU,SAAU,QAAQ,GAAG,oBAAoB,WAAW,qBAC5B,CAAC;AAEhD,eAAO,MAAM,cAAc,SAAU,oBAAoB,WAAW,6CACQ,CAAC;AAE7E,eAAO,MAAM,aAAa,SAAU,oBAAoB,IAAI,yBAA2C,CAAC;AAExG,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAQ/D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,WAY1D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,mBAAmB,CAAC,KAAK,WAQhE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { traverseItems } from './create-items-tree';
|
|
1
2
|
export const isItemGroup = (item) => item && item.items !== undefined;
|
|
2
3
|
export const isLinkItem = (item) => item && item.href !== undefined;
|
|
3
4
|
export const isCheckboxItem = (item) => item && item.itemType === 'checkbox';
|
|
@@ -21,4 +22,13 @@ export function indexEquals(left, right) {
|
|
|
21
22
|
}
|
|
22
23
|
return true;
|
|
23
24
|
}
|
|
25
|
+
export function hasCheckboxItems(items) {
|
|
26
|
+
let hasCheckboxItems = false;
|
|
27
|
+
traverseItems(items, item => {
|
|
28
|
+
if (item.itemType === 'checkbox') {
|
|
29
|
+
hasCheckboxItems = true;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return hasCheckboxItems;
|
|
33
|
+
}
|
|
24
34
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAqC,EAAyC,EAAE,CAC1G,IAAI,IAAK,IAAsC,CAAC,KAAK,KAAK,SAAS,CAAC;AAEtE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAgD,EA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C,CAAC;IACH,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ButtonDropdownProps, LinkItem } from '../interfaces';\nimport { traverseItems } from './create-items-tree';\n\nexport const isItemGroup = (item: ButtonDropdownProps.ItemOrGroup): item is ButtonDropdownProps.ItemGroup =>\n item && (item as ButtonDropdownProps.ItemGroup).items !== undefined;\n\nexport const isLinkItem = (item: LinkItem | ButtonDropdownProps.ItemOrGroup): item is LinkItem =>\n item && (item as LinkItem).href !== undefined;\n\nexport const isCheckboxItem = (item: ButtonDropdownProps.ItemOrGroup): item is ButtonDropdownProps.CheckboxItem =>\n item && (item as ButtonDropdownProps.CheckboxItem).itemType === 'checkbox';\n\nexport const getItemTarget = (item: ButtonDropdownProps.Item) => (item.external ? '_blank' : undefined);\n\nexport function indexIncludes(source: number[], target: number[]) {\n for (let index = 0; index < source.length; index++) {\n if (source[index] !== target[index]) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function indexEquals(left: number[], right: number[]) {\n if (left.length !== right.length) {\n return false;\n }\n\n for (let index = 0; index < left.length; index++) {\n if (left[index] !== right[index]) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function hasCheckboxItems(items: ButtonDropdownProps.Items) {\n let hasCheckboxItems = false;\n traverseItems(items, item => {\n if (item.itemType === 'checkbox') {\n hasCheckboxItems = true;\n }\n });\n return hasCheckboxItems;\n}\n"]}
|