@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 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 includeIf = argType.includeIf,
143
- excludeIf = argType.excludeIf;
144
- if (typeof includeIf !== 'undefined') return includeHelper(includeIf, args);
145
- if (typeof excludeIf !== 'undefined') return !includeHelper(excludeIf, args);
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
 
@@ -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
- includeIf?: boolean | string;
25
- excludeIf?: boolean | string;
24
+ addIf?: string;
25
+ removeIf?: string;
26
26
  [key: string]: any;
27
27
  }
28
28
  export interface StrictInputType extends InputType {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/csf",
3
- "version": "0.0.2--canary.789b78e.0",
3
+ "version": "0.0.2--canary.507502b.0",
4
4
  "description": "Component Story Format (CSF) utilities",
5
5
  "keywords": [
6
6
  "storybook",