@storybook/csf 0.0.2--canary.789b78e.0 → 0.0.2--canary.507502b.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.js +6 -10
- package/dist/index.test.js +20 -0
- package/dist/story.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -126,23 +126,19 @@ var parseKind = function parseKind(kind, _ref2) {
|
|
126
126
|
groups: groups
|
127
127
|
};
|
128
128
|
};
|
129
|
-
|
130
|
-
exports.parseKind = parseKind;
|
131
|
-
|
132
|
-
var includeHelper = function includeHelper(includeIf, args) {
|
133
|
-
return typeof includeIf === 'string' && includeIf.length > 0 ? !!args[includeIf] : !!includeIf;
|
134
|
-
};
|
135
129
|
/**
|
136
130
|
* Helper function to include/exclude an arg based on the value of other other args
|
137
131
|
* aka "conditional args"
|
138
132
|
*/
|
139
133
|
|
140
134
|
|
135
|
+
exports.parseKind = parseKind;
|
136
|
+
|
141
137
|
var includeConditionalArg = function includeConditionalArg(argType, args) {
|
142
|
-
var
|
143
|
-
|
144
|
-
if (
|
145
|
-
if (
|
138
|
+
var addIf = argType.addIf,
|
139
|
+
removeIf = argType.removeIf;
|
140
|
+
if (addIf) return !!args[addIf];
|
141
|
+
if (removeIf) return !args[removeIf];
|
146
142
|
return true;
|
147
143
|
};
|
148
144
|
|
package/dist/index.test.js
CHANGED
@@ -139,4 +139,24 @@ describe('isExportStory', function () {
|
|
139
139
|
excludeStories: /b/
|
140
140
|
})).toBeTruthy();
|
141
141
|
});
|
142
|
+
});
|
143
|
+
describe('includeConditionalArg', function () {
|
144
|
+
it('dynamic values', function () {
|
145
|
+
expect((0, _.includeConditionalArg)({
|
146
|
+
addIf: 'foo'
|
147
|
+
}, {
|
148
|
+
foo: true
|
149
|
+
})).toBe(true);
|
150
|
+
expect((0, _.includeConditionalArg)({
|
151
|
+
addIf: 'bar'
|
152
|
+
}, {})).toBe(false);
|
153
|
+
expect((0, _.includeConditionalArg)({
|
154
|
+
removeIf: 'foo'
|
155
|
+
}, {
|
156
|
+
foo: true
|
157
|
+
})).toBe(false);
|
158
|
+
expect((0, _.includeConditionalArg)({
|
159
|
+
removeIf: 'bar'
|
160
|
+
}, {})).toBe(true);
|
161
|
+
});
|
142
162
|
});
|
package/dist/story.d.ts
CHANGED
@@ -21,8 +21,8 @@ export interface InputType {
|
|
21
21
|
description?: string;
|
22
22
|
defaultValue?: any;
|
23
23
|
type?: SBType | SBScalarType['name'];
|
24
|
-
|
25
|
-
|
24
|
+
addIf?: string;
|
25
|
+
removeIf?: string;
|
26
26
|
[key: string]: any;
|
27
27
|
}
|
28
28
|
export interface StrictInputType extends InputType {
|