@storybook/addon-docs 6.0.17 → 6.0.21
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/frameworks/common/enhanceArgTypes.js +2 -12
- package/dist/frameworks/common/enhanceArgTypes.test.js +8 -8
- package/dist/frameworks/react/react-argtypes.stories.js +7 -4
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.js +4 -4
- package/package.json +15 -15
- package/ts3.5/dist/lib/utils.d.ts +1 -1
- package/dist/frameworks/common/inferControls.d.ts +0 -2
- package/dist/frameworks/common/inferControls.js +0 -91
- package/ts3.5/dist/frameworks/common/inferControls.d.ts +0 -2
|
@@ -11,15 +11,12 @@ var _mapValues = _interopRequireDefault(require("lodash/mapValues"));
|
|
|
11
11
|
|
|
12
12
|
var _clientApi = require("@storybook/client-api");
|
|
13
13
|
|
|
14
|
-
var _inferControls = require("./inferControls");
|
|
15
|
-
|
|
16
14
|
var _normalizeArgTypes = require("./normalizeArgTypes");
|
|
17
15
|
|
|
18
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
17
|
|
|
20
18
|
var enhanceArgTypes = function enhanceArgTypes(context) {
|
|
21
19
|
var _context$parameters = context.parameters,
|
|
22
|
-
__isArgsStory = _context$parameters.__isArgsStory,
|
|
23
20
|
component = _context$parameters.component,
|
|
24
21
|
_context$parameters$a = _context$parameters.argTypes,
|
|
25
22
|
userArgTypes = _context$parameters$a === void 0 ? {} : _context$parameters$a,
|
|
@@ -33,15 +30,8 @@ var enhanceArgTypes = function enhanceArgTypes(context) {
|
|
|
33
30
|
}, val);
|
|
34
31
|
});
|
|
35
32
|
var extractedArgTypes = extractArgTypes && component ? extractArgTypes(component) : {};
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
if (!__isArgsStory) {
|
|
39
|
-
return withArgTypes;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var withControls = (0, _inferControls.inferControls)(withArgTypes);
|
|
43
|
-
var result = (0, _clientApi.combineParameters)(withControls, withArgTypes);
|
|
44
|
-
return result;
|
|
33
|
+
var withExtractedTypes = extractedArgTypes ? (0, _clientApi.combineParameters)(extractedArgTypes, namedArgTypes) : namedArgTypes;
|
|
34
|
+
return withExtractedTypes;
|
|
45
35
|
};
|
|
46
36
|
|
|
47
37
|
exports.enhanceArgTypes = enhanceArgTypes;
|
|
@@ -67,7 +67,7 @@ describe('enhanceArgTypes', function () {
|
|
|
67
67
|
name: 'number'
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
}).input).toMatchInlineSnapshot("\n {\n \"
|
|
70
|
+
}).input).toMatchInlineSnapshot("\n {\n \"name\": \"input\",\n \"type\": {\n \"name\": \"number\"\n }\n }\n ");
|
|
71
71
|
});
|
|
72
72
|
});
|
|
73
73
|
describe('extraction from component', function () {
|
|
@@ -81,7 +81,7 @@ describe('enhanceArgTypes', function () {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
}).input).toMatchInlineSnapshot("\n {\n \"
|
|
84
|
+
}).input).toMatchInlineSnapshot("\n {\n \"name\": \"input\",\n \"type\": {\n \"name\": \"number\"\n }\n }\n ");
|
|
85
85
|
});
|
|
86
86
|
});
|
|
87
87
|
describe('controls input', function () {
|
|
@@ -123,7 +123,7 @@ describe('enhanceArgTypes', function () {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
}).input).toMatchInlineSnapshot("\n {\n \"
|
|
126
|
+
}).input).toMatchInlineSnapshot("\n {\n \"type\": {\n \"name\": \"number\"\n },\n \"name\": \"input\"\n }\n ");
|
|
127
127
|
});
|
|
128
128
|
it('user-specified argTypes take precedence over inferred argTypes', function () {
|
|
129
129
|
expect(enhance({
|
|
@@ -133,7 +133,7 @@ describe('enhanceArgTypes', function () {
|
|
|
133
133
|
}
|
|
134
134
|
},
|
|
135
135
|
arg: 'hello'
|
|
136
|
-
}).input).toMatchInlineSnapshot("\n {\n \"
|
|
136
|
+
}).input).toMatchInlineSnapshot("\n {\n \"name\": \"input\",\n \"type\": {\n \"name\": \"number\"\n }\n }\n ");
|
|
137
137
|
});
|
|
138
138
|
it('extracted argTypes take precedence over inferred argTypes', function () {
|
|
139
139
|
expect(enhance({
|
|
@@ -145,7 +145,7 @@ describe('enhanceArgTypes', function () {
|
|
|
145
145
|
}
|
|
146
146
|
},
|
|
147
147
|
arg: 6
|
|
148
|
-
}).input).toMatchInlineSnapshot("\n {\n \"
|
|
148
|
+
}).input).toMatchInlineSnapshot("\n {\n \"type\": {\n \"name\": \"string\"\n }\n }\n ");
|
|
149
149
|
});
|
|
150
150
|
it('user-specified controls take precedence over inferred controls', function () {
|
|
151
151
|
expect(enhance({
|
|
@@ -177,7 +177,7 @@ describe('enhanceArgTypes', function () {
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
})).toMatchInlineSnapshot("\n {\n \"input\": {\n \"name\": \"input\"\n },\n \"foo\": {\n \"
|
|
180
|
+
})).toMatchInlineSnapshot("\n {\n \"input\": {\n \"name\": \"input\"\n },\n \"foo\": {\n \"type\": {\n \"name\": \"number\"\n }\n }\n }\n ");
|
|
181
181
|
});
|
|
182
182
|
it('includes extracted argTypes when user-specified argTypes match', function () {
|
|
183
183
|
expect(enhance({
|
|
@@ -196,7 +196,7 @@ describe('enhanceArgTypes', function () {
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
})).toMatchInlineSnapshot("\n {\n \"input\": {\n \"
|
|
199
|
+
})).toMatchInlineSnapshot("\n {\n \"input\": {\n \"name\": \"input\",\n \"type\": {\n \"name\": \"number\"\n }\n },\n \"foo\": {\n \"type\": {\n \"name\": \"number\"\n }\n }\n }\n ");
|
|
200
200
|
});
|
|
201
201
|
it('excludes extracted argTypes when user-specified argTypes do not match', function () {
|
|
202
202
|
expect(enhance({
|
|
@@ -212,7 +212,7 @@ describe('enhanceArgTypes', function () {
|
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
})).toMatchInlineSnapshot("\n {\n \"foo\": {\n \"
|
|
215
|
+
})).toMatchInlineSnapshot("\n {\n \"foo\": {\n \"type\": {\n \"name\": \"number\"\n }\n },\n \"input\": {\n \"name\": \"input\",\n \"type\": {\n \"name\": \"number\"\n }\n }\n }\n ");
|
|
216
216
|
});
|
|
217
217
|
});
|
|
218
218
|
});
|
|
@@ -48,8 +48,6 @@ var _clientApi = require("@storybook/client-api");
|
|
|
48
48
|
|
|
49
49
|
var _extractArgTypes = require("./extractArgTypes");
|
|
50
50
|
|
|
51
|
-
var _inferControls = require("../common/inferControls");
|
|
52
|
-
|
|
53
51
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
54
52
|
|
|
55
53
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
@@ -70,8 +68,13 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
70
68
|
|
|
71
69
|
var argsTableProps = function argsTableProps(component) {
|
|
72
70
|
var argTypes = (0, _extractArgTypes.extractArgTypes)(component);
|
|
73
|
-
var
|
|
74
|
-
|
|
71
|
+
var parameters = {
|
|
72
|
+
__isArgsStory: true,
|
|
73
|
+
argTypes: argTypes
|
|
74
|
+
};
|
|
75
|
+
var rows = (0, _clientApi.inferControls)({
|
|
76
|
+
parameters: parameters
|
|
77
|
+
});
|
|
75
78
|
return {
|
|
76
79
|
rows: rows
|
|
77
80
|
};
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PropSummaryValue } from '@storybook/components';
|
|
2
2
|
export declare const MAX_TYPE_SUMMARY_LENGTH = 90;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const MAX_DEFAULT_VALUE_SUMMARY_LENGTH = 50;
|
|
4
4
|
export declare function isTooLongForTypeSummary(value: string): boolean;
|
|
5
5
|
export declare function isTooLongForDefaultValueSummary(value: string): boolean;
|
|
6
6
|
export declare function createSummaryValue(summary: string, detail?: string): PropSummaryValue;
|
package/dist/lib/utils.js
CHANGED
|
@@ -10,18 +10,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
10
10
|
exports.isTooLongForTypeSummary = isTooLongForTypeSummary;
|
|
11
11
|
exports.isTooLongForDefaultValueSummary = isTooLongForDefaultValueSummary;
|
|
12
12
|
exports.createSummaryValue = createSummaryValue;
|
|
13
|
-
exports.normalizeNewlines = exports.
|
|
13
|
+
exports.normalizeNewlines = exports.MAX_DEFAULT_VALUE_SUMMARY_LENGTH = exports.MAX_TYPE_SUMMARY_LENGTH = void 0;
|
|
14
14
|
var MAX_TYPE_SUMMARY_LENGTH = 90;
|
|
15
15
|
exports.MAX_TYPE_SUMMARY_LENGTH = MAX_TYPE_SUMMARY_LENGTH;
|
|
16
|
-
var
|
|
17
|
-
exports.
|
|
16
|
+
var MAX_DEFAULT_VALUE_SUMMARY_LENGTH = 50;
|
|
17
|
+
exports.MAX_DEFAULT_VALUE_SUMMARY_LENGTH = MAX_DEFAULT_VALUE_SUMMARY_LENGTH;
|
|
18
18
|
|
|
19
19
|
function isTooLongForTypeSummary(value) {
|
|
20
20
|
return value.length > MAX_TYPE_SUMMARY_LENGTH;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function isTooLongForDefaultValueSummary(value) {
|
|
24
|
-
return value.length >
|
|
24
|
+
return value.length > MAX_DEFAULT_VALUE_SUMMARY_LENGTH;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function createSummaryValue(summary, detail) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-docs",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.21",
|
|
4
4
|
"description": "Superior documentation for your components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"addon",
|
|
@@ -47,18 +47,18 @@
|
|
|
47
47
|
"@mdx-js/loader": "^1.5.1",
|
|
48
48
|
"@mdx-js/mdx": "^1.5.1",
|
|
49
49
|
"@mdx-js/react": "^1.5.1",
|
|
50
|
-
"@storybook/addons": "6.0.
|
|
51
|
-
"@storybook/api": "6.0.
|
|
52
|
-
"@storybook/client-api": "6.0.
|
|
53
|
-
"@storybook/client-logger": "6.0.
|
|
54
|
-
"@storybook/components": "6.0.
|
|
55
|
-
"@storybook/core": "6.0.
|
|
56
|
-
"@storybook/core-events": "6.0.
|
|
50
|
+
"@storybook/addons": "6.0.21",
|
|
51
|
+
"@storybook/api": "6.0.21",
|
|
52
|
+
"@storybook/client-api": "6.0.21",
|
|
53
|
+
"@storybook/client-logger": "6.0.21",
|
|
54
|
+
"@storybook/components": "6.0.21",
|
|
55
|
+
"@storybook/core": "6.0.21",
|
|
56
|
+
"@storybook/core-events": "6.0.21",
|
|
57
57
|
"@storybook/csf": "0.0.1",
|
|
58
|
-
"@storybook/node-logger": "6.0.
|
|
59
|
-
"@storybook/postinstall": "6.0.
|
|
60
|
-
"@storybook/source-loader": "6.0.
|
|
61
|
-
"@storybook/theming": "6.0.
|
|
58
|
+
"@storybook/node-logger": "6.0.21",
|
|
59
|
+
"@storybook/postinstall": "6.0.21",
|
|
60
|
+
"@storybook/source-loader": "6.0.21",
|
|
61
|
+
"@storybook/theming": "6.0.21",
|
|
62
62
|
"acorn": "^7.1.0",
|
|
63
63
|
"acorn-jsx": "^5.1.0",
|
|
64
64
|
"acorn-walk": "^7.0.0",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"@babel/core": "^7.9.6",
|
|
84
84
|
"@emotion/core": "^10.0.20",
|
|
85
85
|
"@emotion/styled": "^10.0.17",
|
|
86
|
-
"@storybook/react": "6.0.
|
|
87
|
-
"@storybook/web-components": "6.0.
|
|
86
|
+
"@storybook/react": "6.0.21",
|
|
87
|
+
"@storybook/web-components": "6.0.21",
|
|
88
88
|
"@types/cross-spawn": "^6.0.1",
|
|
89
89
|
"@types/doctrine": "^0.0.3",
|
|
90
90
|
"@types/enzyme": "^3.10.3",
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
"publishConfig": {
|
|
145
145
|
"access": "public"
|
|
146
146
|
},
|
|
147
|
-
"gitHead": "
|
|
147
|
+
"gitHead": "fb14a86c1cbf5eb21023bf2021eecdea9c6df83d",
|
|
148
148
|
"typesVersions": {
|
|
149
149
|
"<=3.5": {
|
|
150
150
|
"*": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PropSummaryValue } from '@storybook/components';
|
|
2
2
|
export declare const MAX_TYPE_SUMMARY_LENGTH = 90;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const MAX_DEFAULT_VALUE_SUMMARY_LENGTH = 50;
|
|
4
4
|
export declare function isTooLongForTypeSummary(value: string): boolean;
|
|
5
5
|
export declare function isTooLongForDefaultValueSummary(value: string): boolean;
|
|
6
6
|
export declare function createSummaryValue(summary: string, detail?: string): PropSummaryValue;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/es.array.includes");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.array.is-array");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.function.name");
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "__esModule", {
|
|
10
|
-
value: true
|
|
11
|
-
});
|
|
12
|
-
exports.inferControls = void 0;
|
|
13
|
-
|
|
14
|
-
var _mapValues = _interopRequireDefault(require("lodash/mapValues"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
-
|
|
18
|
-
var inferControl = function inferControl(argType) {
|
|
19
|
-
var type = argType.type;
|
|
20
|
-
|
|
21
|
-
if (!type) {
|
|
22
|
-
// console.log('no sbtype', { argType });
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
switch (type.name) {
|
|
27
|
-
case 'array':
|
|
28
|
-
{
|
|
29
|
-
var value = type.value;
|
|
30
|
-
|
|
31
|
-
if ((value === null || value === void 0 ? void 0 : value.name) && ['object', 'other'].includes(value.name)) {
|
|
32
|
-
return {
|
|
33
|
-
type: 'object',
|
|
34
|
-
validator: function validator(obj) {
|
|
35
|
-
return Array.isArray(obj);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
type: 'array'
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
case 'boolean':
|
|
46
|
-
return {
|
|
47
|
-
type: 'boolean'
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
case 'string':
|
|
51
|
-
return {
|
|
52
|
-
type: 'text'
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
case 'number':
|
|
56
|
-
return {
|
|
57
|
-
type: 'number'
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
case 'enum':
|
|
61
|
-
{
|
|
62
|
-
var _ref = type,
|
|
63
|
-
_value = _ref.value;
|
|
64
|
-
return {
|
|
65
|
-
type: 'select',
|
|
66
|
-
options: _value
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
case 'function':
|
|
71
|
-
case 'symbol':
|
|
72
|
-
case 'void':
|
|
73
|
-
return null;
|
|
74
|
-
|
|
75
|
-
default:
|
|
76
|
-
return {
|
|
77
|
-
type: 'object'
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
var inferControls = function inferControls(argTypes) {
|
|
83
|
-
return (0, _mapValues["default"])(argTypes, function (argType) {
|
|
84
|
-
var control = argType && argType.type && inferControl(argType);
|
|
85
|
-
return control ? {
|
|
86
|
-
control: control
|
|
87
|
-
} : undefined;
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
exports.inferControls = inferControls;
|