Skip to content

Commit 4ddc1a8

Browse files
baadhiramaradwan26
andauthored
feat(multiselect): add controls args to every story (#21169)
* feat(multiselect): add controls args to every story Signed-off-by: baadhira <[email protected]> * fix(multiselect): enable controls for MultiSelect stories * fix(multiselect): enable controls for MultiSelect stories * Update packages/react/src/components/MultiSelect/MultiSelect.featureflag.stories.js Co-authored-by: Mahmoud <[email protected]> * Update packages/react/src/components/MultiSelect/MultiSelect.stories.js Co-authored-by: Mahmoud <[email protected]> * Update packages/react/src/components/MultiSelect/MultiSelect.featureflag.stories.js Co-authored-by: Mahmoud <[email protected]> * fix(multiselect): enable controls for MultiSelect stories * fix(multiselect): add controls args to every story --------- Signed-off-by: baadhira <[email protected]> Co-authored-by: Mahmoud <[email protected]>
1 parent 6d957f1 commit 4ddc1a8

File tree

2 files changed

+115
-8
lines changed

2 files changed

+115
-8
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>

0 commit comments

Comments
 (0)