@storybook/csf 0.0.2--canary.835a408.0 → 0.0.2--canary.789b78e.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Args, InputType } from './story';
1
2
  export declare const sanitize: (string: string) => string;
2
3
  export declare const toId: (kind: string, name?: string | undefined) => string;
3
4
  export declare const storyNameFromExport: (key: string) => string;
@@ -15,4 +16,5 @@ export declare const parseKind: (kind: string, { rootSeparator, groupSeparator }
15
16
  root: string | null;
16
17
  groups: string[];
17
18
  };
19
+ export declare const includeConditionalArg: (argType: InputType, args: Args) => boolean;
18
20
  export * from './story';
package/dist/index.js CHANGED
@@ -8,10 +8,11 @@ var _exportNames = {
8
8
  toId: true,
9
9
  storyNameFromExport: true,
10
10
  isExportStory: true,
11
- parseKind: true
11
+ parseKind: true,
12
+ includeConditionalArg: true
12
13
  };
13
14
  exports.isExportStory = isExportStory;
14
- exports.parseKind = exports.storyNameFromExport = exports.toId = exports.sanitize = void 0;
15
+ exports.includeConditionalArg = exports.parseKind = exports.storyNameFromExport = exports.toId = exports.sanitize = void 0;
15
16
 
16
17
  var _startCase = _interopRequireDefault(require("lodash/startCase"));
17
18
 
@@ -126,4 +127,23 @@ var parseKind = function parseKind(kind, _ref2) {
126
127
  };
127
128
  };
128
129
 
129
- exports.parseKind = parseKind;
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
+ /**
136
+ * Helper function to include/exclude an arg based on the value of other other args
137
+ * aka "conditional args"
138
+ */
139
+
140
+
141
+ 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);
146
+ return true;
147
+ };
148
+
149
+ exports.includeConditionalArg = includeConditionalArg;
package/dist/story.d.ts CHANGED
@@ -21,6 +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
26
  [key: string]: any;
25
27
  }
26
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.835a408.0",
3
+ "version": "0.0.2--canary.789b78e.0",
4
4
  "description": "Component Story Format (CSF) utilities",
5
5
  "keywords": [
6
6
  "storybook",