Skip to content

Commit f64bae6

Browse files
authored
Merge branch 'main' into 20859-wc-dropdown-autoalign
2 parents da04468 + 4ddc1a8 commit f64bae6

File tree

10 files changed

+436
-131
lines changed

10 files changed

+436
-131
lines changed

packages/react/src/components/MultiSelect/MultiSelect.featureflag.stories.js

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,66 @@ export default {
2121
</WithFeatureFlags>
2222
),
2323
],
24+
argTypes: {
25+
size: {
26+
options: ['sm', 'md', 'lg'],
27+
control: { type: 'select' },
28+
},
29+
direction: {
30+
options: ['top', 'bottom'],
31+
control: { type: 'radio' },
32+
},
33+
type: {
34+
options: ['inline', 'default'],
35+
control: { type: 'radio' },
36+
},
37+
disabled: {
38+
control: { type: 'boolean' },
39+
},
40+
invalid: {
41+
control: { type: 'boolean' },
42+
},
43+
light: {
44+
table: {
45+
disable: true,
46+
},
47+
},
48+
warn: {
49+
control: { type: 'boolean' },
50+
},
51+
helperText: {
52+
control: { type: 'text' },
53+
},
54+
invalidText: {
55+
control: { type: 'text' },
56+
},
57+
label: {
58+
control: { type: 'text' },
59+
},
60+
warnText: {
61+
control: { type: 'text' },
62+
},
63+
},
64+
parameters: {
65+
controls: {
66+
exclude: [
67+
'filterItems',
68+
'translateWithId',
69+
'titleText',
70+
'open',
71+
'selectedItems',
72+
'itemToString',
73+
'itemToElement',
74+
'locale',
75+
'items',
76+
'id',
77+
'initialSelectedItems',
78+
'sortItems',
79+
'compareItems',
80+
'downshiftProps',
81+
],
82+
},
83+
},
2484
};
2585

2686
const comboBoxItems = [
@@ -51,20 +111,35 @@ const comboBoxItems = [
51111
},
52112
];
53113

114+
const sharedArgs = {
115+
size: 'md',
116+
autoAlign: false,
117+
type: 'default',
118+
titleText: 'Multiselect title',
119+
disabled: false,
120+
hideLabel: false,
121+
invalid: false,
122+
warn: false,
123+
helperText: 'This is helper text',
124+
warnText: 'whoopsie!',
125+
invalidText: 'whoopsie!',
126+
label: 'Multiselect Label',
127+
clearSelectionDescription: 'Total items selected: ',
128+
useTitleInItem: false,
129+
clearSelectionText: 'To clear selection, press Delete or Backspace,',
130+
};
54131
export const FloatingStyles = (args) => (
55132
<MultiSelect
56-
label="Multiselect Label"
57133
id="carbon-multiselect-example"
58-
titleText="Multiselect title"
59-
helperText="This is helper text"
60134
items={comboBoxItems}
61-
direction={args.direction}
62135
itemToString={(item) => (item ? item.text : '')}
63136
selectionFeedback="top-after-reopen"
137+
{...args}
64138
/>
65139
);
66140

67141
FloatingStyles.args = {
142+
...sharedArgs,
68143
direction: 'bottom',
69144
};
70145

packages/react/src/components/MultiSelect/MultiSelect.stories.js

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default {
106106
},
107107
useTitleInItem: {
108108
control: {
109-
type: 'text',
109+
type: 'boolean',
110110
},
111111
},
112112
clearSelectionText: {
@@ -188,10 +188,26 @@ const sharedArgs = {
188188
clearSelectionDescription: 'Total items selected: ',
189189
useTitleInItem: false,
190190
clearSelectionText: 'To clear selection, press Delete or Backspace,',
191-
selectAll: false,
192-
selectAllItemText: 'All options',
193191
};
194192

193+
const filterableArgTypes = {
194+
label: {
195+
control: false,
196+
table: {
197+
disable: true,
198+
},
199+
},
200+
placeholder: {
201+
control: {
202+
type: 'text',
203+
},
204+
description:
205+
'Generic `placeholder` that will be used as the textual representation of what this field is for',
206+
table: {
207+
type: { summary: 'string' },
208+
},
209+
},
210+
};
195211
export const Default = (args) => {
196212
const items = [
197213
{
@@ -289,6 +305,7 @@ export const WithInitialSelectedItems = (args) => {
289305
);
290306
};
291307

308+
WithInitialSelectedItems.args = { ...sharedArgs };
292309
export const Filterable = (args) => {
293310
const items = [
294311
{
@@ -354,7 +371,11 @@ export const FilterableWithSelectAll = (args) => {
354371
);
355372
};
356373

374+
FilterableWithSelectAll.argTypes = {
375+
...filterableArgTypes,
376+
};
357377
Filterable.argTypes = {
378+
...filterableArgTypes,
358379
onChange: {
359380
action: 'onChange',
360381
},
@@ -381,6 +402,7 @@ export const WithLayerMultiSelect = (args) => (
381402
)}
382403
</WithLayer>
383404
);
405+
WithLayerMultiSelect.args = { ...sharedArgs };
384406
export const _FilterableWithLayer = (args) => (
385407
<WithLayer>
386408
{(layer) => (
@@ -399,6 +421,9 @@ export const _FilterableWithLayer = (args) => (
399421
</WithLayer>
400422
);
401423

424+
_FilterableWithLayer.argTypes = {
425+
...filterableArgTypes,
426+
};
402427
export const _Controlled = (args) => {
403428
const [selectedItems, setSelectedItems] = useState(
404429
items.filter((item) => item.id === 'downshift-1-item-0')
@@ -442,6 +467,7 @@ export const _Controlled = (args) => {
442467
);
443468
};
444469

470+
_Controlled.args = { ...sharedArgs };
445471
const itemsWithSelectAll = [
446472
{
447473
id: 'downshift-1-item-0',
@@ -544,6 +570,7 @@ export const withAILabel = (args) => (
544570
</div>
545571
);
546572

573+
withAILabel.args = { ...sharedArgs };
547574
export const FilterableWithAILabel = (args) => (
548575
<div style={{ width: 400 }}>
549576
<FilterableMultiSelect
@@ -560,6 +587,9 @@ export const FilterableWithAILabel = (args) => (
560587
</div>
561588
);
562589

590+
FilterableWithAILabel.argTypes = {
591+
...filterableArgTypes,
592+
};
563593
export const ExperimentalAutoAlign = (args) => {
564594
const ref = useRef();
565595
useEffect(() => {
@@ -597,6 +627,7 @@ ExperimentalAutoAlign.argTypes = {
597627
},
598628
};
599629

630+
ExperimentalAutoAlign.args = { ...sharedArgs, autoAlign: true };
600631
export const withToggletipLabel = (args) => {
601632
return (
602633
<div>
@@ -634,7 +665,7 @@ export const withToggletipLabel = (args) => {
634665
);
635666
};
636667

637-
export const SelectAllWithDynamicItems = () => {
668+
export const SelectAllWithDynamicItems = (args) => {
638669
const [label, setLabel] = useState('Choose options');
639670
const [items, setItems] = useState(itemsWithSelectAll);
640671

@@ -676,6 +707,7 @@ export const SelectAllWithDynamicItems = () => {
676707
itemToString={(item) => (item ? item.text : '')}
677708
selectionFeedback="top-after-reopen"
678709
onChange={onChange}
710+
{...args}
679711
/>
680712
<Button onClick={addItems}>Add 2 items to the list</Button>
681713
</div>

packages/web-components/src/components/menu-button/__tests__/__snapshots__/menu-button-test.snap.js

Lines changed: 6 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ snapshots['cds-menu-button should render and match snapshot'] =
66
kind="primary"
77
label="Actions"
88
menu-alignment="bottom"
9+
menu-background-token="layer"
910
size="lg"
1011
tab-index="0"
1112
>
1213
<cds-menu
1314
size="lg"
14-
style="inset-inline-start: 8px; inset-inline-end: initial; inset-block-start: 8px;"
15+
style=""
1516
>
1617
<cds-menu-item
1718
label="First action"
@@ -44,12 +45,13 @@ snapshots[
4445
kind="primary"
4546
label="Test"
4647
menu-alignment="bottom"
48+
menu-background-token="layer"
4749
size="lg"
4850
tab-index="0"
4951
>
5052
<cds-menu
5153
size="lg"
52-
style="inset-inline-start: 8px; inset-inline-end: initial; inset-block-start: 8px;"
54+
style=""
5355
>
5456
<cds-menu-item
5557
label="First action"
@@ -78,12 +80,13 @@ snapshots[
7880
kind="primary"
7981
label="Nested"
8082
menu-alignment="bottom"
83+
menu-background-token="layer"
8184
size="lg"
8285
tab-index="0"
8386
>
8487
<cds-menu
8588
size="lg"
86-
style="inset-inline-start: 8px; inset-inline-end: initial; inset-block-start: 8px;"
89+
style=""
8790
>
8891
<cds-menu-item
8992
aria-expanded="true"
@@ -121,110 +124,3 @@ snapshots['cds-menu-button should support xs size'] = `<cds-button
121124
</slot>
122125
`;
123126
/* end snapshot cds-menu-button should support xs size */
124-
snapshots['cds-menu-button should render and match snapshot'] =
125-
`<cds-menu-button
126-
kind="primary"
127-
label="Actions"
128-
menu-alignment="bottom"
129-
menu-background-token="layer"
130-
size="lg"
131-
tab-index="0"
132-
>
133-
<cds-menu
134-
size="lg"
135-
style="inset-inline-start: 8px; inset-inline-end: initial; inset-block-start: 8px;"
136-
>
137-
<cds-menu-item
138-
label="First action"
139-
role="menuitem"
140-
tabindex="0"
141-
>
142-
</cds-menu-item>
143-
<cds-menu-item
144-
label="Second action"
145-
role="menuitem"
146-
tabindex="0"
147-
>
148-
</cds-menu-item>
149-
<cds-menu-item
150-
aria-disabled="true"
151-
disabled=""
152-
label="Third action"
153-
role="menuitem"
154-
tabindex="-1"
155-
>
156-
</cds-menu-item>
157-
</cds-menu>
158-
</cds-menu-button>
159-
`;
160-
/* end snapshot cds-menu-button should render and match snapshot */
161-
162-
snapshots[
163-
'cds-menu-button Children/slots and special menu content Snapshot variants should render with divider and danger and match snapshot'
164-
] = `<cds-menu-button
165-
kind="primary"
166-
label="Test"
167-
menu-alignment="bottom"
168-
menu-background-token="layer"
169-
size="lg"
170-
tab-index="0"
171-
>
172-
<cds-menu
173-
size="lg"
174-
style="inset-inline-start: 8px; inset-inline-end: initial; inset-block-start: 8px;"
175-
>
176-
<cds-menu-item
177-
label="First action"
178-
role="menuitem"
179-
tabindex="0"
180-
>
181-
</cds-menu-item>
182-
<cds-menu-item-divider role="separator">
183-
</cds-menu-item-divider>
184-
<cds-menu-item
185-
class="cds--menu-item--danger"
186-
kind="danger"
187-
label="Danger"
188-
role="menuitem"
189-
tabindex="0"
190-
>
191-
</cds-menu-item>
192-
</cds-menu>
193-
</cds-menu-button>
194-
`;
195-
/* end snapshot cds-menu-button Children/slots and special menu content Snapshot variants should render with divider and danger and match snapshot */
196-
197-
snapshots[
198-
'cds-menu-button Children/slots and special menu content Snapshot variants should render with nested menu and match snapshot'
199-
] = `<cds-menu-button
200-
kind="primary"
201-
label="Nested"
202-
menu-alignment="bottom"
203-
menu-background-token="layer"
204-
size="lg"
205-
tab-index="0"
206-
>
207-
<cds-menu
208-
size="lg"
209-
style="inset-inline-start: 8px; inset-inline-end: initial; inset-block-start: 8px;"
210-
>
211-
<cds-menu-item
212-
aria-expanded="true"
213-
aria-haspopup="true"
214-
label="Export as"
215-
role="menuitem"
216-
tabindex="0"
217-
>
218-
<cds-menu-item-group slot="submenu">
219-
<cds-menu-item
220-
label="PDF"
221-
role="menuitem"
222-
tabindex="0"
223-
>
224-
</cds-menu-item>
225-
</cds-menu-item-group>
226-
</cds-menu-item>
227-
</cds-menu>
228-
</cds-menu-button>
229-
`;
230-
/* end snapshot cds-menu-button Children/slots and special menu content Snapshot variants should render with nested menu and match snapshot */

0 commit comments

Comments
 (0)