Skip to content

Commit 16942d6

Browse files
authored
Merge pull request #83 from ComponentDriven/kasper/fix-control-type
Loosen control type and some fixes
2 parents 8e94d1a + ab72fee commit 16942d6

File tree

1 file changed

+59
-48
lines changed

1 file changed

+59
-48
lines changed

src/story.ts

Lines changed: 59 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -53,55 +53,65 @@ type ControlType =
5353
type ConditionalTest = { truthy?: boolean } | { exists: boolean } | { eq: any } | { neq: any };
5454
type ConditionalValue = { arg: string } | { global: string };
5555
export type Conditional = ConditionalValue & ConditionalTest;
56+
57+
interface ControlBase {
58+
[key: string]: any;
59+
/**
60+
* @see https://storybook.js.org/docs/api/arg-types#controltype
61+
*/
62+
type?: ControlType;
63+
disable?: boolean;
64+
}
65+
66+
type Control =
67+
| ControlType
68+
| false
69+
| (ControlBase &
70+
(
71+
| ControlBase
72+
| {
73+
type: 'color';
74+
/**
75+
* @see https://storybook.js.org/docs/api/arg-types#controlpresetcolors
76+
*/
77+
presetColors?: string[];
78+
}
79+
| {
80+
type: 'file';
81+
/**
82+
* @see https://storybook.js.org/docs/api/arg-types#controlaccept
83+
*/
84+
accept?: string;
85+
}
86+
| {
87+
type: 'inline-check' | 'radio' | 'inline-radio' | 'select' | 'multi-select';
88+
/**
89+
* @see https://storybook.js.org/docs/api/arg-types#controllabels
90+
*/
91+
labels?: { [options: string]: string };
92+
}
93+
| {
94+
type: 'number' | 'range';
95+
/**
96+
* @see https://storybook.js.org/docs/api/arg-types#controlmax
97+
*/
98+
max?: number;
99+
/**
100+
* @see https://storybook.js.org/docs/api/arg-types#controlmin
101+
*/
102+
min?: number;
103+
/**
104+
* @see https://storybook.js.org/docs/api/arg-types#controlstep
105+
*/
106+
step?: number;
107+
}
108+
));
109+
56110
export interface InputType {
57111
/**
58112
* @see https://storybook.js.org/docs/api/arg-types#control
59113
*/
60-
control?:
61-
| ControlType
62-
| {
63-
/**
64-
* @see https://storybook.js.org/docs/api/arg-types#controltype
65-
*/
66-
type: ControlType;
67-
}
68-
| {
69-
type: 'color';
70-
/**
71-
* @see https://storybook.js.org/docs/api/arg-types#controlpresetcolors
72-
*/
73-
presetColors?: string[];
74-
}
75-
| {
76-
type: 'file';
77-
/**
78-
* @see https://storybook.js.org/docs/api/arg-types#controlaccept
79-
*/
80-
accept?: string;
81-
}
82-
| {
83-
type: 'inline-check' | 'radio' | 'inline-radio' | 'select' | 'multi-select';
84-
/**
85-
* @see https://storybook.js.org/docs/api/arg-types#controllabels
86-
*/
87-
labels?: { [options: string]: string };
88-
}
89-
| {
90-
type: 'number' | 'range';
91-
/**
92-
* @see https://storybook.js.org/docs/api/arg-types#controlmax
93-
*/
94-
max?: number;
95-
/**
96-
* @see https://storybook.js.org/docs/api/arg-types#controlmin
97-
*/
98-
min?: number;
99-
/**
100-
* @see https://storybook.js.org/docs/api/arg-types#controlstep
101-
*/
102-
step?: number;
103-
}
104-
| false;
114+
control?: Control;
105115
/**
106116
* @see https://storybook.js.org/docs/api/arg-types#description
107117
*/
@@ -113,27 +123,28 @@ export interface InputType {
113123
/**
114124
* @see https://storybook.js.org/docs/api/arg-types#mapping
115125
*/
116-
mapping?: { [key: string]: { [option: string]: any } };
126+
mapping?: { [key: string]: any };
117127
/**
118128
* @see https://storybook.js.org/docs/api/arg-types#name
119129
*/
120130
name?: string;
121131
/**
122132
* @see https://storybook.js.org/docs/api/arg-types#options
123133
*/
124-
options?: string[];
134+
options?: any[];
125135
/**
126136
* @see https://storybook.js.org/docs/api/arg-types#table
127137
*/
128138
table?: {
139+
[key: string]: unknown;
129140
/**
130141
* @see https://storybook.js.org/docs/api/arg-types#tablecategory
131142
*/
132143
category?: string;
133144
/**
134145
* @see https://storybook.js.org/docs/api/arg-types#tabledefaultvalue
135146
*/
136-
defaultValue?: { summary: string; detail?: string };
147+
defaultValue?: { summary?: string; detail?: string };
137148
/**
138149
* @see https://storybook.js.org/docs/api/arg-types#tabledisable
139150
*/

0 commit comments

Comments
 (0)