Skip to content

Commit 4b9f3a8

Browse files
Revert "add onClick() actions for PicklistItems"
This reverts commit 174e7f4.
1 parent f487cc6 commit 4b9f3a8

File tree

1 file changed

+34
-113
lines changed

1 file changed

+34
-113
lines changed

stories/Picklist.stories.tsx

Lines changed: 34 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
import React, { ComponentProps } from 'react';
1+
import React from 'react';
22
import { Picklist, PicklistItem } from '../src/scripts';
3-
import { Meta, StoryObj } from '@storybook/react';
4-
5-
type StoryProps = ComponentProps<typeof Picklist> & {
6-
picklistItem1_onClick: ComponentProps<typeof PicklistItem>['onClick'];
7-
picklistItem2_onClick: ComponentProps<typeof PicklistItem>['onClick'];
8-
picklistItem3_onClick: ComponentProps<typeof PicklistItem>['onClick'];
9-
};
3+
import { ComponentMeta, ComponentStoryObj } from '@storybook/react';
104

115
/**
126
*
137
*/
14-
const meta: Meta<StoryProps> = {
8+
const meta: ComponentMeta<typeof Picklist> = {
159
title: 'Picklist',
1610
component: Picklist,
1711
subcomponents: { PicklistItem },
@@ -20,9 +14,6 @@ const meta: Meta<StoryProps> = {
2014
onValueChange: { action: 'valueChange' },
2115
onBlur: { action: 'blur' },
2216
onComplete: { action: 'complete' },
23-
picklistItem1_onClick: { action: 'picklistItem1_click' },
24-
picklistItem2_onClick: { action: 'picklistItem2_click' },
25-
picklistItem3_onClick: { action: 'picklistItem3_click' },
2617
},
2718
parameters: {
2819
docs: {
@@ -36,37 +27,15 @@ export default meta;
3627
/**
3728
*
3829
*/
39-
export const ControlledWithKnobs: StoryObj<StoryProps> = {
30+
export const ControlledWithKnobs: ComponentStoryObj<typeof Picklist> = {
4031
name: 'Controlled with knobs',
41-
render: ({
42-
picklistItem1_onClick,
43-
picklistItem2_onClick,
44-
picklistItem3_onClick,
45-
...args
46-
}) => (
47-
<Picklist {...args}>
48-
<PicklistItem
49-
key='1'
50-
label='Picklist Item One'
51-
value='1'
52-
onClick={picklistItem1_onClick}
53-
/>
54-
<PicklistItem
55-
key='2'
56-
label='Picklist Item Two'
57-
value='2'
58-
onClick={picklistItem2_onClick}
59-
/>
60-
<PicklistItem
61-
key='3'
62-
label='Picklist Item Three'
63-
value='3'
64-
onClick={picklistItem3_onClick}
65-
/>
66-
</Picklist>
67-
),
6832
args: {
6933
label: 'Picklist Label',
34+
children: [
35+
<PicklistItem key='1' label='Picklist Item One' value='1' />,
36+
<PicklistItem key='2' label='Picklist Item Two' value='2' />,
37+
<PicklistItem key='3' label='Picklist Item Three' value='3' />,
38+
],
7039
},
7140
parameters: {
7241
docs: {
@@ -80,8 +49,7 @@ export const ControlledWithKnobs: StoryObj<StoryProps> = {
8049
/**
8150
*
8251
*/
83-
export const Default: StoryObj<StoryProps> = {
84-
render: ControlledWithKnobs.render,
52+
export const Default: ComponentStoryObj<typeof Picklist> = {
8553
args: {
8654
...ControlledWithKnobs.args,
8755
selectedText: 'Select item from here',
@@ -99,8 +67,7 @@ export const Default: StoryObj<StoryProps> = {
9967
/**
10068
*
10169
*/
102-
export const Required: StoryObj<StoryProps> = {
103-
render: ControlledWithKnobs.render,
70+
export const Required: ComponentStoryObj<typeof Picklist> = {
10471
args: {
10572
...ControlledWithKnobs.args,
10673
required: true,
@@ -118,8 +85,7 @@ export const Required: StoryObj<StoryProps> = {
11885
/**
11986
*
12087
*/
121-
export const Error: StoryObj<StoryProps> = {
122-
render: ControlledWithKnobs.render,
88+
export const Error: ComponentStoryObj<typeof Picklist> = {
12389
args: {
12490
...ControlledWithKnobs.args,
12591
required: true,
@@ -138,40 +104,15 @@ export const Error: StoryObj<StoryProps> = {
138104
/**
139105
*
140106
*/
141-
export const DisabledItems: StoryObj<StoryProps> = {
142-
render: ({
143-
picklistItem1_onClick,
144-
picklistItem2_onClick,
145-
picklistItem3_onClick,
146-
...args
147-
}) => (
148-
<Picklist {...args}>
149-
<PicklistItem
150-
key='1'
151-
label='Picklist Item One'
152-
value='1'
153-
onClick={picklistItem1_onClick}
154-
disabled
155-
/>
156-
<PicklistItem
157-
key='2'
158-
label='Picklist Item Two'
159-
value='2'
160-
onClick={picklistItem2_onClick}
161-
disabled
162-
/>
163-
<PicklistItem
164-
key='3'
165-
label='Picklist Item Three'
166-
value='3'
167-
onClick={picklistItem3_onClick}
168-
disabled
169-
/>
170-
</Picklist>
171-
),
107+
export const DisabledItems: ComponentStoryObj<typeof Picklist> = {
172108
args: {
173109
label: 'Picklist Label',
174110
defaultOpened: true,
111+
children: [
112+
<PicklistItem label='Picklist Item One' value='1' key='1' disabled />,
113+
<PicklistItem label='Picklist Item Two' value='2' key='2' disabled />,
114+
<PicklistItem label='Picklist Item Three' value='3' key='3' disabled />,
115+
],
175116
},
176117
parameters: {
177118
docs: {
@@ -185,8 +126,7 @@ export const DisabledItems: StoryObj<StoryProps> = {
185126
/**
186127
*
187128
*/
188-
export const Disabled: StoryObj<StoryProps> = {
189-
render: ControlledWithKnobs.render,
129+
export const Disabled: ComponentStoryObj<typeof Picklist> = {
190130
args: {
191131
...ControlledWithKnobs.args,
192132
disabled: true,
@@ -203,8 +143,7 @@ export const Disabled: StoryObj<StoryProps> = {
203143
/**
204144
*
205145
*/
206-
export const MenuSizeMedium: StoryObj<StoryProps> = {
207-
render: ControlledWithKnobs.render,
146+
export const MenuSizeMedium: ComponentStoryObj<typeof Picklist> = {
208147
name: 'Menu Size - Medium',
209148
args: {
210149
...ControlledWithKnobs.args,
@@ -224,8 +163,7 @@ export const MenuSizeMedium: StoryObj<StoryProps> = {
224163
/**
225164
*
226165
*/
227-
export const MenuSizeLarge: StoryObj<StoryProps> = {
228-
render: ControlledWithKnobs.render,
166+
export const MenuSizeLarge: ComponentStoryObj<typeof Picklist> = {
229167
name: 'Menu Size - Large',
230168
args: {
231169
...ControlledWithKnobs.args,
@@ -245,8 +183,7 @@ export const MenuSizeLarge: StoryObj<StoryProps> = {
245183
/**
246184
*
247185
*/
248-
export const SingleItemSelected: StoryObj<StoryProps> = {
249-
render: ControlledWithKnobs.render,
186+
export const SingleItemSelected: ComponentStoryObj<typeof Picklist> = {
250187
name: 'Single item selected',
251188
args: {
252189
...ControlledWithKnobs.args,
@@ -265,8 +202,7 @@ export const SingleItemSelected: StoryObj<StoryProps> = {
265202
/**
266203
*
267204
*/
268-
export const MultipleItemsSelected: StoryObj<StoryProps> = {
269-
render: ControlledWithKnobs.render,
205+
export const MultipleItemsSelected: ComponentStoryObj<typeof Picklist> = {
270206
name: 'Multiple items selected',
271207
args: {
272208
...ControlledWithKnobs.args,
@@ -287,7 +223,7 @@ export const MultipleItemsSelected: StoryObj<StoryProps> = {
287223
/**
288224
*
289225
*/
290-
export const DropdownScroll: StoryObj<StoryProps> = {
226+
export const DropdownScroll: ComponentStoryObj<typeof Picklist> = {
291227
args: {
292228
...ControlledWithKnobs.args,
293229
selectedText: 'Select item from here',
@@ -318,8 +254,7 @@ export const DropdownScroll: StoryObj<StoryProps> = {
318254
/**
319255
*
320256
*/
321-
export const WithTooltip: StoryObj<StoryProps> = {
322-
render: ControlledWithKnobs.render,
257+
export const WithTooltip: ComponentStoryObj<typeof Picklist> = {
323258
name: 'With tooltip',
324259
args: {
325260
...ControlledWithKnobs.args,
@@ -337,40 +272,26 @@ export const WithTooltip: StoryObj<StoryProps> = {
337272
/**
338273
*
339274
*/
340-
export const WithDividers: StoryObj<StoryProps> = {
275+
export const WithDividers: ComponentStoryObj<typeof Picklist> = {
341276
name: 'With Dividers',
342-
render: ({
343-
picklistItem1_onClick,
344-
picklistItem2_onClick,
345-
picklistItem3_onClick,
346-
...args
347-
}) => (
348-
<Picklist {...args}>
277+
args: {
278+
label: 'Picklist Label',
279+
defaultOpened: true,
280+
children: [
349281
<PicklistItem
350282
key='1'
351283
label='Picklist Item One'
352284
value='1'
353-
onClick={picklistItem1_onClick}
354285
divider='bottom'
355-
/>
356-
<PicklistItem
357-
key='2'
358-
label='Picklist Item Two'
359-
value='2'
360-
onClick={picklistItem2_onClick}
361-
/>
286+
/>,
287+
<PicklistItem key='2' label='Picklist Item Two' value='2' />,
362288
<PicklistItem
363289
key='3'
364290
label='Picklist Item Three'
365291
value='3'
366-
onClick={picklistItem3_onClick}
367292
divider='top'
368-
/>
369-
</Picklist>
370-
),
371-
args: {
372-
label: 'Picklist Label',
373-
defaultOpened: true,
293+
/>,
294+
],
374295
},
375296
parameters: {
376297
docs: {

0 commit comments

Comments
 (0)