@storybook/csf 0.0.2--canary.4566f4d.1 → 0.0.2--canary.50.45981a0.0
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/dist/index.d.ts +0 -1
- package/dist/index.js +1 -10
- package/dist/story.d.ts +1 -17
- package/dist/story.test.js +2 -2
- package/package.json +9 -5
- package/dist/includeConditionalArg.d.ts +0 -3
- package/dist/includeConditionalArg.js +0 -74
- package/dist/includeConditionalArg.test.d.ts +0 -1
- package/dist/includeConditionalArg.test.js +0 -318
- package/dist/properties.d.ts +0 -75
- package/dist/properties.js +0 -27
- package/dist/properties.test.d.ts +0 -1
- package/dist/properties.test.js +0 -14
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -8,22 +8,13 @@ var _exportNames = {
|
|
8
8
|
toId: true,
|
9
9
|
storyNameFromExport: true,
|
10
10
|
isExportStory: true,
|
11
|
-
parseKind: true
|
12
|
-
includeConditionalArg: true
|
11
|
+
parseKind: true
|
13
12
|
};
|
14
13
|
exports.isExportStory = isExportStory;
|
15
|
-
Object.defineProperty(exports, "includeConditionalArg", {
|
16
|
-
enumerable: true,
|
17
|
-
get: function get() {
|
18
|
-
return _includeConditionalArg.includeConditionalArg;
|
19
|
-
}
|
20
|
-
});
|
21
14
|
exports.parseKind = exports.storyNameFromExport = exports.toId = exports.sanitize = void 0;
|
22
15
|
|
23
16
|
var _startCase = _interopRequireDefault(require("lodash/startCase"));
|
24
17
|
|
25
|
-
var _includeConditionalArg = require("./includeConditionalArg");
|
26
|
-
|
27
18
|
var _story = require("./story");
|
28
19
|
|
29
20
|
Object.keys(_story).forEach(function (key) {
|
package/dist/story.d.ts
CHANGED
@@ -16,27 +16,11 @@ export interface StoryIdentifier {
|
|
16
16
|
export declare type Parameters = {
|
17
17
|
[name: string]: any;
|
18
18
|
};
|
19
|
-
declare type ConditionalTest = {
|
20
|
-
truthy?: boolean;
|
21
|
-
} | {
|
22
|
-
exists: boolean;
|
23
|
-
} | {
|
24
|
-
eq: any;
|
25
|
-
} | {
|
26
|
-
neq: any;
|
27
|
-
};
|
28
|
-
declare type ConditionalValue = {
|
29
|
-
arg: string;
|
30
|
-
} | {
|
31
|
-
global: string;
|
32
|
-
};
|
33
|
-
export declare type Conditional = ConditionalValue & ConditionalTest;
|
34
19
|
export interface InputType {
|
35
20
|
name?: string;
|
36
21
|
description?: string;
|
37
22
|
defaultValue?: any;
|
38
23
|
type?: SBType | SBScalarType['name'];
|
39
|
-
if?: Conditional;
|
40
24
|
[key: string]: any;
|
41
25
|
}
|
42
26
|
export interface StrictInputType extends InputType {
|
@@ -106,7 +90,7 @@ export declare type BaseAnnotations<TFramework extends AnyFramework = AnyFramewo
|
|
106
90
|
args?: Partial<TArgs>;
|
107
91
|
argTypes?: Partial<ArgTypes<TArgs>>;
|
108
92
|
loaders?: LoaderFunction<TFramework, Args>[];
|
109
|
-
render?: ArgsStoryFn<TFramework,
|
93
|
+
render?: ArgsStoryFn<TFramework, Args>;
|
110
94
|
};
|
111
95
|
export declare type ProjectAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = BaseAnnotations<TFramework, TArgs> & {
|
112
96
|
argsEnhancers?: ArgsEnhancer<TFramework, Args>[];
|
package/dist/story.test.js
CHANGED
@@ -116,7 +116,7 @@ CSF2Story.args = {
|
|
116
116
|
a: 1
|
117
117
|
};
|
118
118
|
var CSF3Story = {
|
119
|
-
render: function render(
|
119
|
+
render: function render() {
|
120
120
|
return 'Named Story';
|
121
121
|
},
|
122
122
|
name: 'Another name for story',
|
@@ -138,7 +138,7 @@ var CSF3Story = {
|
|
138
138
|
}
|
139
139
|
};
|
140
140
|
var CSF3StoryStrict = {
|
141
|
-
render: function render(
|
141
|
+
render: function render() {
|
142
142
|
return 'Named Story';
|
143
143
|
},
|
144
144
|
name: 'Another name for story',
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storybook/csf",
|
3
|
-
"version": "0.0.2--canary.
|
3
|
+
"version": "0.0.2--canary.50.45981a0.0",
|
4
4
|
"description": "Component Story Format (CSF) utilities",
|
5
5
|
"keywords": [
|
6
6
|
"storybook",
|
@@ -38,15 +38,13 @@
|
|
38
38
|
},
|
39
39
|
"prettier": "@storybook/linter-config/prettier.config",
|
40
40
|
"jest": {
|
41
|
-
"testEnvironment": "node"
|
42
|
-
"roots": [
|
43
|
-
"<rootDir>/src"
|
44
|
-
]
|
41
|
+
"testEnvironment": "node"
|
45
42
|
},
|
46
43
|
"dependencies": {
|
47
44
|
"lodash": "^4.17.15"
|
48
45
|
},
|
49
46
|
"devDependencies": {
|
47
|
+
"@auto-it/released": "^10.37.1",
|
50
48
|
"@babel/cli": "^7.8.4",
|
51
49
|
"@babel/core": "^7.9.0",
|
52
50
|
"@babel/preset-env": "^7.9.5",
|
@@ -63,6 +61,12 @@
|
|
63
61
|
"prettier": "^1.19.1",
|
64
62
|
"typescript": "^3.7.2"
|
65
63
|
},
|
64
|
+
"auto": {
|
65
|
+
"plugins": [
|
66
|
+
"npm",
|
67
|
+
"released"
|
68
|
+
]
|
69
|
+
},
|
66
70
|
"publishConfig": {
|
67
71
|
"access": "public"
|
68
72
|
}
|
@@ -1,74 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.includeConditionalArg = exports.testValue = void 0;
|
7
|
-
|
8
|
-
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
9
|
-
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
11
|
-
|
12
|
-
var count = function count(vals) {
|
13
|
-
return vals.map(function (v) {
|
14
|
-
return typeof v !== 'undefined';
|
15
|
-
}).filter(Boolean).length;
|
16
|
-
};
|
17
|
-
|
18
|
-
var testValue = function testValue(cond, value) {
|
19
|
-
var _ref = cond,
|
20
|
-
exists = _ref.exists,
|
21
|
-
eq = _ref.eq,
|
22
|
-
neq = _ref.neq,
|
23
|
-
truthy = _ref.truthy;
|
24
|
-
|
25
|
-
if (count([exists, eq, neq, truthy]) > 1) {
|
26
|
-
throw new Error("Invalid conditional test ".concat(JSON.stringify({
|
27
|
-
exists: exists,
|
28
|
-
eq: eq,
|
29
|
-
neq: neq
|
30
|
-
})));
|
31
|
-
}
|
32
|
-
|
33
|
-
if (typeof eq !== 'undefined') {
|
34
|
-
return (0, _isEqual["default"])(value, eq);
|
35
|
-
}
|
36
|
-
|
37
|
-
if (typeof neq !== 'undefined') {
|
38
|
-
return !(0, _isEqual["default"])(value, neq);
|
39
|
-
}
|
40
|
-
|
41
|
-
if (typeof exists !== 'undefined') {
|
42
|
-
var valueExists = typeof value !== 'undefined';
|
43
|
-
return exists ? valueExists : !valueExists;
|
44
|
-
}
|
45
|
-
|
46
|
-
var shouldBeTruthy = typeof truthy === 'undefined' ? true : truthy;
|
47
|
-
return shouldBeTruthy ? !!value : !value;
|
48
|
-
};
|
49
|
-
/**
|
50
|
-
* Helper function to include/exclude an arg based on the value of other other args
|
51
|
-
* aka "conditional args"
|
52
|
-
*/
|
53
|
-
|
54
|
-
|
55
|
-
exports.testValue = testValue;
|
56
|
-
|
57
|
-
var includeConditionalArg = function includeConditionalArg(argType, args, globals) {
|
58
|
-
if (!argType["if"]) return true;
|
59
|
-
var _ref2 = argType["if"],
|
60
|
-
arg = _ref2.arg,
|
61
|
-
global = _ref2.global;
|
62
|
-
|
63
|
-
if (count([arg, global]) !== 1) {
|
64
|
-
throw new Error("Invalid conditional value ".concat(JSON.stringify({
|
65
|
-
arg: arg,
|
66
|
-
global: global
|
67
|
-
})));
|
68
|
-
}
|
69
|
-
|
70
|
-
var value = arg ? args[arg] : globals[global];
|
71
|
-
return testValue(argType["if"], value);
|
72
|
-
};
|
73
|
-
|
74
|
-
exports.includeConditionalArg = includeConditionalArg;
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,318 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _includeConditionalArg = require("./includeConditionalArg");
|
4
|
-
|
5
|
-
/* eslint-disable @typescript-eslint/ban-ts-ignore */
|
6
|
-
describe('testValue', function () {
|
7
|
-
describe('truthy', function () {
|
8
|
-
it.each([['implicit true', {}, true, true], ['implicit truthy', {}, 1, true], ['implicit falsey', {}, 0, false], ['truthy true', {
|
9
|
-
truthy: true
|
10
|
-
}, true, true], ['truthy truthy', {
|
11
|
-
truthy: true
|
12
|
-
}, 1, true], ['truthy falsey', {
|
13
|
-
truthy: true
|
14
|
-
}, 0, false], ['falsey true', {
|
15
|
-
truthy: false
|
16
|
-
}, true, false], ['falsey truthy', {
|
17
|
-
truthy: false
|
18
|
-
}, 1, false], ['falsey falsey', {
|
19
|
-
truthy: false
|
20
|
-
}, 0, true]])('%s', function (_name, cond, value, expected) {
|
21
|
-
// @ts-ignore
|
22
|
-
expect((0, _includeConditionalArg.testValue)(cond, value)).toBe(expected);
|
23
|
-
});
|
24
|
-
});
|
25
|
-
describe('exists', function () {
|
26
|
-
it.each([['exist', {
|
27
|
-
exists: true
|
28
|
-
}, 1, true], ['exist false', {
|
29
|
-
exists: true
|
30
|
-
}, undefined, false], ['nexist', {
|
31
|
-
exists: false
|
32
|
-
}, undefined, true], ['nexist false', {
|
33
|
-
exists: false
|
34
|
-
}, 1, false]])('%s', function (_name, cond, value, expected) {
|
35
|
-
// @ts-ignore
|
36
|
-
expect((0, _includeConditionalArg.testValue)(cond, value)).toBe(expected);
|
37
|
-
});
|
38
|
-
});
|
39
|
-
describe('eq', function () {
|
40
|
-
it.each([['true', {
|
41
|
-
eq: 1
|
42
|
-
}, 1, true], ['false', {
|
43
|
-
eq: 1
|
44
|
-
}, 2, false], ['undefined', {
|
45
|
-
eq: undefined
|
46
|
-
}, undefined, false], ['undefined false', {
|
47
|
-
eq: 1
|
48
|
-
}, undefined, false], ['object true', {
|
49
|
-
eq: {
|
50
|
-
x: 1
|
51
|
-
}
|
52
|
-
}, {
|
53
|
-
x: 1
|
54
|
-
}, true], ['object true', {
|
55
|
-
eq: {
|
56
|
-
x: 1
|
57
|
-
}
|
58
|
-
}, {
|
59
|
-
x: 2
|
60
|
-
}, false]])('%s', function (_name, cond, value, expected) {
|
61
|
-
// @ts-ignore
|
62
|
-
expect((0, _includeConditionalArg.testValue)(cond, value)).toBe(expected);
|
63
|
-
});
|
64
|
-
});
|
65
|
-
describe('neq', function () {
|
66
|
-
it.each([['true', {
|
67
|
-
neq: 1
|
68
|
-
}, 2, true], ['false', {
|
69
|
-
neq: 1
|
70
|
-
}, 1, false], ['undefined true', {
|
71
|
-
neq: 1
|
72
|
-
}, undefined, true], ['undefined false', {
|
73
|
-
neq: undefined
|
74
|
-
}, undefined, false], ['object true', {
|
75
|
-
neq: {
|
76
|
-
x: 1
|
77
|
-
}
|
78
|
-
}, {
|
79
|
-
x: 2
|
80
|
-
}, true], ['object false', {
|
81
|
-
neq: {
|
82
|
-
x: 1
|
83
|
-
}
|
84
|
-
}, {
|
85
|
-
x: 1
|
86
|
-
}, false]])('%s', function (_name, cond, value, expected) {
|
87
|
-
// @ts-ignore
|
88
|
-
expect((0, _includeConditionalArg.testValue)(cond, value)).toBe(expected);
|
89
|
-
});
|
90
|
-
});
|
91
|
-
});
|
92
|
-
describe('includeConditionalArg', function () {
|
93
|
-
describe('errors', function () {
|
94
|
-
it('should throw if arg and global are both specified', function () {
|
95
|
-
expect(function () {
|
96
|
-
return (0, _includeConditionalArg.includeConditionalArg)({
|
97
|
-
"if": {
|
98
|
-
arg: 'a',
|
99
|
-
global: 'b'
|
100
|
-
}
|
101
|
-
}, {}, {});
|
102
|
-
}).toThrowErrorMatchingInlineSnapshot("\"Invalid conditional value {\\\"arg\\\":\\\"a\\\",\\\"global\\\":\\\"b\\\"}\"");
|
103
|
-
});
|
104
|
-
it('should throw if mulitiple exists / eq / neq are specified', function () {
|
105
|
-
expect(function () {
|
106
|
-
return (0, _includeConditionalArg.includeConditionalArg)({
|
107
|
-
"if": {
|
108
|
-
arg: 'a',
|
109
|
-
exists: true,
|
110
|
-
eq: 1
|
111
|
-
}
|
112
|
-
}, {}, {});
|
113
|
-
}).toThrowErrorMatchingInlineSnapshot("\"Invalid conditional test {\\\"exists\\\":true,\\\"eq\\\":1}\"");
|
114
|
-
expect(function () {
|
115
|
-
return (0, _includeConditionalArg.includeConditionalArg)({
|
116
|
-
"if": {
|
117
|
-
arg: 'a',
|
118
|
-
exists: false,
|
119
|
-
neq: 0
|
120
|
-
}
|
121
|
-
}, {}, {});
|
122
|
-
}).toThrowErrorMatchingInlineSnapshot("\"Invalid conditional test {\\\"exists\\\":false,\\\"neq\\\":0}\"");
|
123
|
-
expect(function () {
|
124
|
-
return (0, _includeConditionalArg.includeConditionalArg)({
|
125
|
-
"if": {
|
126
|
-
arg: 'a',
|
127
|
-
eq: 1,
|
128
|
-
neq: 0
|
129
|
-
}
|
130
|
-
}, {}, {});
|
131
|
-
}).toThrowErrorMatchingInlineSnapshot("\"Invalid conditional test {\\\"eq\\\":1,\\\"neq\\\":0}\"");
|
132
|
-
});
|
133
|
-
});
|
134
|
-
describe('args', function () {
|
135
|
-
describe('implicit', function () {
|
136
|
-
it.each([['implicit true', {
|
137
|
-
"if": {
|
138
|
-
arg: 'a'
|
139
|
-
}
|
140
|
-
}, {
|
141
|
-
a: 1
|
142
|
-
}, {}, true], ['truthy true', {
|
143
|
-
"if": {
|
144
|
-
arg: 'a',
|
145
|
-
truthy: true
|
146
|
-
}
|
147
|
-
}, {
|
148
|
-
a: 0
|
149
|
-
}, {}, false], ['truthy false', {
|
150
|
-
"if": {
|
151
|
-
arg: 'a',
|
152
|
-
truthy: false
|
153
|
-
}
|
154
|
-
}, {}, {}, true]])('%s', function (_name, argType, args, globals, expected) {
|
155
|
-
// @ts-ignore
|
156
|
-
expect((0, _includeConditionalArg.includeConditionalArg)(argType, args, globals)).toBe(expected);
|
157
|
-
});
|
158
|
-
});
|
159
|
-
describe('exists', function () {
|
160
|
-
it.each([['exist', {
|
161
|
-
"if": {
|
162
|
-
arg: 'a',
|
163
|
-
exists: true
|
164
|
-
}
|
165
|
-
}, {
|
166
|
-
a: 1
|
167
|
-
}, {}, true], ['exist false', {
|
168
|
-
"if": {
|
169
|
-
arg: 'a',
|
170
|
-
exists: true
|
171
|
-
}
|
172
|
-
}, {}, {}, false]])('%s', function (_name, argType, args, globals, expected) {
|
173
|
-
// @ts-ignore
|
174
|
-
expect((0, _includeConditionalArg.includeConditionalArg)(argType, args, globals)).toBe(expected);
|
175
|
-
});
|
176
|
-
});
|
177
|
-
describe('eq', function () {
|
178
|
-
it.each([['scalar true', {
|
179
|
-
"if": {
|
180
|
-
arg: 'a',
|
181
|
-
eq: 1
|
182
|
-
}
|
183
|
-
}, {
|
184
|
-
a: 1
|
185
|
-
}, {}, true], ['scalar false', {
|
186
|
-
"if": {
|
187
|
-
arg: 'a',
|
188
|
-
eq: 1
|
189
|
-
}
|
190
|
-
}, {
|
191
|
-
a: 2
|
192
|
-
}, {
|
193
|
-
a: 1
|
194
|
-
}, false]])('%s', function (_name, argType, args, globals, expected) {
|
195
|
-
// @ts-ignore
|
196
|
-
expect((0, _includeConditionalArg.includeConditionalArg)(argType, args, globals)).toBe(expected);
|
197
|
-
});
|
198
|
-
});
|
199
|
-
describe('neq', function () {
|
200
|
-
it.each([['scalar true', {
|
201
|
-
"if": {
|
202
|
-
arg: 'a',
|
203
|
-
neq: 1
|
204
|
-
}
|
205
|
-
}, {
|
206
|
-
a: 2
|
207
|
-
}, {}, true], ['scalar false', {
|
208
|
-
"if": {
|
209
|
-
arg: 'a',
|
210
|
-
neq: 1
|
211
|
-
}
|
212
|
-
}, {
|
213
|
-
a: 1
|
214
|
-
}, {
|
215
|
-
a: 2
|
216
|
-
}, false]])('%s', function (_name, argType, args, globals, expected) {
|
217
|
-
// @ts-ignore
|
218
|
-
expect((0, _includeConditionalArg.includeConditionalArg)(argType, args, globals)).toBe(expected);
|
219
|
-
});
|
220
|
-
});
|
221
|
-
});
|
222
|
-
describe('globals', function () {
|
223
|
-
describe('truthy', function () {
|
224
|
-
it.each([['implicit true', {
|
225
|
-
"if": {
|
226
|
-
global: 'a'
|
227
|
-
}
|
228
|
-
}, {}, {
|
229
|
-
a: 1
|
230
|
-
}, true], ['implicit undefined', {
|
231
|
-
"if": {
|
232
|
-
global: 'a'
|
233
|
-
}
|
234
|
-
}, {}, {}, false], ['truthy true', {
|
235
|
-
"if": {
|
236
|
-
global: 'a',
|
237
|
-
truthy: true
|
238
|
-
}
|
239
|
-
}, {}, {
|
240
|
-
a: 0
|
241
|
-
}, false], ['truthy false', {
|
242
|
-
"if": {
|
243
|
-
global: 'a',
|
244
|
-
truthy: false
|
245
|
-
}
|
246
|
-
}, {}, {
|
247
|
-
a: 0
|
248
|
-
}, true]])('%s', function (_name, argType, args, globals, expected) {
|
249
|
-
// @ts-ignore
|
250
|
-
expect((0, _includeConditionalArg.includeConditionalArg)(argType, args, globals)).toBe(expected);
|
251
|
-
});
|
252
|
-
});
|
253
|
-
describe('exists', function () {
|
254
|
-
it.each([['implicit exist true', {
|
255
|
-
"if": {
|
256
|
-
global: 'a',
|
257
|
-
exists: true
|
258
|
-
}
|
259
|
-
}, {}, {
|
260
|
-
a: 1
|
261
|
-
}, true], ['implicit exist false', {
|
262
|
-
"if": {
|
263
|
-
global: 'a',
|
264
|
-
exists: true
|
265
|
-
}
|
266
|
-
}, {
|
267
|
-
a: 1
|
268
|
-
}, {}, false]])('%s', function (_name, argType, args, globals, expected) {
|
269
|
-
// @ts-ignore
|
270
|
-
expect((0, _includeConditionalArg.includeConditionalArg)(argType, args, globals)).toBe(expected);
|
271
|
-
});
|
272
|
-
});
|
273
|
-
describe('eq', function () {
|
274
|
-
it.each([['scalar true', {
|
275
|
-
"if": {
|
276
|
-
global: 'a',
|
277
|
-
eq: 1
|
278
|
-
}
|
279
|
-
}, {}, {
|
280
|
-
a: 1
|
281
|
-
}, true], ['scalar false', {
|
282
|
-
"if": {
|
283
|
-
arg: 'a',
|
284
|
-
eq: 1
|
285
|
-
}
|
286
|
-
}, {
|
287
|
-
a: 2
|
288
|
-
}, {
|
289
|
-
a: 1
|
290
|
-
}, false]])('%s', function (_name, argType, args, globals, expected) {
|
291
|
-
// @ts-ignore
|
292
|
-
expect((0, _includeConditionalArg.includeConditionalArg)(argType, args, globals)).toBe(expected);
|
293
|
-
});
|
294
|
-
});
|
295
|
-
describe('neq', function () {
|
296
|
-
it.each([['scalar true', {
|
297
|
-
"if": {
|
298
|
-
global: 'a',
|
299
|
-
neq: 1
|
300
|
-
}
|
301
|
-
}, {}, {
|
302
|
-
a: 2
|
303
|
-
}, true], ['scalar false', {
|
304
|
-
"if": {
|
305
|
-
global: 'a',
|
306
|
-
neq: 1
|
307
|
-
}
|
308
|
-
}, {
|
309
|
-
a: 2
|
310
|
-
}, {
|
311
|
-
a: 1
|
312
|
-
}, false]])('%s', function (_name, argType, args, globals, expected) {
|
313
|
-
// @ts-ignore
|
314
|
-
expect((0, _includeConditionalArg.includeConditionalArg)(argType, args, globals)).toBe(expected);
|
315
|
-
});
|
316
|
-
});
|
317
|
-
});
|
318
|
-
});
|
package/dist/properties.d.ts
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
export declare enum PropertyTypes {
|
2
|
-
TEXT = "text",
|
3
|
-
NUMBER = "number",
|
4
|
-
BOOLEAN = "boolean",
|
5
|
-
OPTIONS = "options",
|
6
|
-
DATE = "date",
|
7
|
-
COLOR = "color",
|
8
|
-
BUTTON = "button",
|
9
|
-
OBJECT = "object",
|
10
|
-
ARRAY = "array",
|
11
|
-
FILES = "files"
|
12
|
-
}
|
13
|
-
export interface StoryPropertyBase<T> {
|
14
|
-
type: PropertyTypes;
|
15
|
-
label?: string;
|
16
|
-
value?: T;
|
17
|
-
hideLabel?: boolean;
|
18
|
-
hidden?: boolean;
|
19
|
-
groupId?: string;
|
20
|
-
order?: number;
|
21
|
-
}
|
22
|
-
export interface StoryPropertyText extends StoryPropertyBase<string> {
|
23
|
-
type: PropertyTypes.TEXT;
|
24
|
-
placeholder?: string;
|
25
|
-
maxRows?: number;
|
26
|
-
}
|
27
|
-
export interface StoryPropertyBoolean extends StoryPropertyBase<boolean> {
|
28
|
-
type: PropertyTypes.BOOLEAN;
|
29
|
-
}
|
30
|
-
export interface StoryPropertyColor extends StoryPropertyBase<string> {
|
31
|
-
type: PropertyTypes.COLOR;
|
32
|
-
}
|
33
|
-
export interface StoryPropertyDate extends StoryPropertyBase<Date> {
|
34
|
-
type: PropertyTypes.DATE;
|
35
|
-
datePicker?: boolean;
|
36
|
-
timePicker?: boolean;
|
37
|
-
}
|
38
|
-
export interface StoryPropertyFiles extends StoryPropertyBase<string[]> {
|
39
|
-
type: PropertyTypes.FILES;
|
40
|
-
accept?: string;
|
41
|
-
}
|
42
|
-
export interface StoryPropertyArray extends StoryPropertyBase<string[]> {
|
43
|
-
type: PropertyTypes.ARRAY;
|
44
|
-
separator?: string;
|
45
|
-
}
|
46
|
-
export interface StoryPropertyObject extends StoryPropertyBase<object> {
|
47
|
-
type: PropertyTypes.OBJECT;
|
48
|
-
}
|
49
|
-
export interface StoryPropertyButton extends StoryPropertyBase<void> {
|
50
|
-
type: PropertyTypes.BUTTON;
|
51
|
-
onClick?: (prop: StoryPropertyButton) => void;
|
52
|
-
}
|
53
|
-
export declare type OptionsValueType<T = unknown> = T | string | number | string[] | number[] | {
|
54
|
-
label: string;
|
55
|
-
value: any;
|
56
|
-
};
|
57
|
-
export declare type OptionsListType<T = unknown> = {
|
58
|
-
[key: string]: T;
|
59
|
-
} | OptionsValueType<T>[];
|
60
|
-
export interface StoryPropertyOptions<T = unknown> extends StoryPropertyBase<OptionsValueType<T>> {
|
61
|
-
type: PropertyTypes.OPTIONS;
|
62
|
-
options: OptionsListType<T>;
|
63
|
-
display?: 'select' | 'multi-select' | 'radio' | 'inline-radio' | 'check' | 'inline-check';
|
64
|
-
}
|
65
|
-
export interface StoryPropertyNumber extends StoryPropertyBase<number> {
|
66
|
-
type: PropertyTypes.NUMBER;
|
67
|
-
range?: boolean;
|
68
|
-
min?: number;
|
69
|
-
max?: number;
|
70
|
-
step?: number;
|
71
|
-
}
|
72
|
-
export declare type StoryProperty = StoryPropertyText | StoryPropertyBoolean | StoryPropertyColor | StoryPropertyDate | StoryPropertyObject | StoryPropertyButton | StoryPropertyOptions | StoryPropertyNumber | StoryPropertyArray | StoryPropertyFiles;
|
73
|
-
export interface StoryProperties {
|
74
|
-
[name: string]: StoryProperty;
|
75
|
-
}
|
package/dist/properties.js
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.PropertyTypes = void 0;
|
7
|
-
|
8
|
-
/**
|
9
|
-
* Property field types
|
10
|
-
* examples are provided for the different types:
|
11
|
-
*
|
12
|
-
*/
|
13
|
-
var PropertyTypes;
|
14
|
-
exports.PropertyTypes = PropertyTypes;
|
15
|
-
|
16
|
-
(function (PropertyTypes) {
|
17
|
-
PropertyTypes["TEXT"] = "text";
|
18
|
-
PropertyTypes["NUMBER"] = "number";
|
19
|
-
PropertyTypes["BOOLEAN"] = "boolean";
|
20
|
-
PropertyTypes["OPTIONS"] = "options";
|
21
|
-
PropertyTypes["DATE"] = "date";
|
22
|
-
PropertyTypes["COLOR"] = "color";
|
23
|
-
PropertyTypes["BUTTON"] = "button";
|
24
|
-
PropertyTypes["OBJECT"] = "object";
|
25
|
-
PropertyTypes["ARRAY"] = "array";
|
26
|
-
PropertyTypes["FILES"] = "files";
|
27
|
-
})(PropertyTypes || (exports.PropertyTypes = PropertyTypes = {}));
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/dist/properties.test.js
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _ = require(".");
|
4
|
-
|
5
|
-
describe('properties', function () {
|
6
|
-
it('type PropertyTypes.TEXT', function () {
|
7
|
-
expect(function () {
|
8
|
-
var prop = {
|
9
|
-
type: _.PropertyTypes.TEXT
|
10
|
-
};
|
11
|
-
return prop.type === 'text';
|
12
|
-
}).toBeTruthy();
|
13
|
-
});
|
14
|
-
});
|