@storybook/addon-docs 6.5.0-alpha.38 → 6.5.0-alpha.41

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.
@@ -16,10 +16,10 @@ var _global = require("global");
16
16
  // This was specifically a problem with the Vite builder.
17
17
 
18
18
  /* eslint-disable no-underscore-dangle */
19
- if (_global.window.__DOCS_CONTEXT__ === undefined) {
19
+ if (_global.window && _global.window.__DOCS_CONTEXT__ === undefined) {
20
20
  _global.window.__DOCS_CONTEXT__ = /*#__PURE__*/(0, _react.createContext)({});
21
21
  _global.window.__DOCS_CONTEXT__.displayName = 'DocsContext';
22
22
  }
23
23
 
24
- var DocsContext = _global.window.__DOCS_CONTEXT__;
24
+ var DocsContext = _global.window ? _global.window.__DOCS_CONTEXT__ : /*#__PURE__*/(0, _react.createContext)({});
25
25
  exports.DocsContext = DocsContext;
@@ -11,7 +11,6 @@ var _HOC = _interopRequireDefault(require("@storybook/addon-docs/svelte/HOC.svel
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
- // eslint-disable-next-line import/no-extraneous-dependencies
15
14
  var prepareForInline = function prepareForInline(storyFn) {
16
15
  var el = _react.default.useRef(null);
17
16
 
@@ -9,6 +9,10 @@ require("core-js/modules/es.function.name.js");
9
9
 
10
10
  require("core-js/modules/es.array.map.js");
11
11
 
12
+ require("core-js/modules/es.number.is-nan.js");
13
+
14
+ require("core-js/modules/es.number.constructor.js");
15
+
12
16
  require("core-js/modules/es.object.assign.js");
13
17
 
14
18
  require("core-js/modules/es.regexp.exec.js");
@@ -38,7 +42,8 @@ var convert = function convert(type) {
38
42
  case 'enum':
39
43
  {
40
44
  var _values = computed ? value : value.map(function (v) {
41
- return (0, _utils.trimQuotes)(v.value);
45
+ var trimmedValue = (0, _utils.trimQuotes)(v.value);
46
+ return (0, _utils.includesQuotes)(v.value) || Number.isNaN(Number(trimmedValue)) ? trimmedValue : Number(trimmedValue);
42
47
  });
43
48
 
44
49
  return Object.assign({}, base, {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.trimQuotes = void 0;
6
+ exports.trimQuotes = exports.includesQuotes = void 0;
7
7
 
8
8
  require("core-js/modules/es.regexp.exec.js");
9
9
 
@@ -15,4 +15,10 @@ var trimQuotes = function trimQuotes(str) {
15
15
  return str.replace(QUOTE_REGEX, '');
16
16
  };
17
17
 
18
- exports.trimQuotes = trimQuotes;
18
+ exports.trimQuotes = trimQuotes;
19
+
20
+ var includesQuotes = function includesQuotes(str) {
21
+ return QUOTE_REGEX.test(str);
22
+ };
23
+
24
+ exports.includesQuotes = includesQuotes;
@@ -8,9 +8,9 @@ import { window as globalWindow } from 'global';
8
8
  // This was specifically a problem with the Vite builder.
9
9
 
10
10
  /* eslint-disable no-underscore-dangle */
11
- if (globalWindow.__DOCS_CONTEXT__ === undefined) {
11
+ if (globalWindow && globalWindow.__DOCS_CONTEXT__ === undefined) {
12
12
  globalWindow.__DOCS_CONTEXT__ = /*#__PURE__*/createContext({});
13
13
  globalWindow.__DOCS_CONTEXT__.displayName = 'DocsContext';
14
14
  }
15
15
 
16
- export var DocsContext = globalWindow.__DOCS_CONTEXT__;
16
+ export var DocsContext = globalWindow ? globalWindow.__DOCS_CONTEXT__ : /*#__PURE__*/createContext({});
@@ -3,8 +3,7 @@ import "core-js/modules/es.function.name.js";
3
3
  import "core-js/modules/es.array.filter.js";
4
4
  import "core-js/modules/es.object.to-string.js";
5
5
  import { Parser } from 'acorn';
6
- import jsx from 'acorn-jsx'; // eslint-disable-next-line import/no-extraneous-dependencies
7
-
6
+ import jsx from 'acorn-jsx';
8
7
  import * as acornWalk from 'acorn-walk';
9
8
  import { InspectionType } from './types';
10
9
  var ACORN_WALK_VISITORS = Object.assign({}, acornWalk.base, {
@@ -1,5 +1,4 @@
1
- import React from 'react'; // eslint-disable-next-line import/no-extraneous-dependencies
2
-
1
+ import React from 'react';
3
2
  import HOC from '@storybook/addon-docs/svelte/HOC.svelte';
4
3
  export var prepareForInline = function prepareForInline(storyFn) {
5
4
  var el = React.useRef(null);
@@ -1,5 +1,7 @@
1
1
  import "core-js/modules/es.function.name.js";
2
2
  import "core-js/modules/es.array.map.js";
3
+ import "core-js/modules/es.number.is-nan.js";
4
+ import "core-js/modules/es.number.constructor.js";
3
5
  import "core-js/modules/es.object.assign.js";
4
6
  import "core-js/modules/es.regexp.exec.js";
5
7
  import "core-js/modules/es.string.split.js";
@@ -7,7 +9,7 @@ import "core-js/modules/es.array.concat.js";
7
9
 
8
10
  /* eslint-disable no-case-declarations */
9
11
  import mapValues from 'lodash/mapValues';
10
- import { trimQuotes } from '../utils';
12
+ import { includesQuotes, trimQuotes } from '../utils';
11
13
  var SIGNATURE_REGEXP = /^\(.*\) => /;
12
14
  export var convert = function convert(type) {
13
15
  var name = type.name,
@@ -21,7 +23,8 @@ export var convert = function convert(type) {
21
23
  case 'enum':
22
24
  {
23
25
  var _values = computed ? value : value.map(function (v) {
24
- return trimQuotes(v.value);
26
+ var trimmedValue = trimQuotes(v.value);
27
+ return includesQuotes(v.value) || Number.isNaN(Number(trimmedValue)) ? trimmedValue : Number(trimmedValue);
25
28
  });
26
29
 
27
30
  return Object.assign({}, base, {
@@ -3,4 +3,7 @@ import "core-js/modules/es.string.replace.js";
3
3
  var QUOTE_REGEX = /^['"]|['"]$/g;
4
4
  export var trimQuotes = function trimQuotes(str) {
5
5
  return str.replace(QUOTE_REGEX, '');
6
+ };
7
+ export var includesQuotes = function includesQuotes(str) {
8
+ return QUOTE_REGEX.test(str);
6
9
  };
@@ -8,9 +8,9 @@ import { window as globalWindow } from 'global';
8
8
  // This was specifically a problem with the Vite builder.
9
9
 
10
10
  /* eslint-disable no-underscore-dangle */
11
- if (globalWindow.__DOCS_CONTEXT__ === undefined) {
11
+ if (globalWindow && globalWindow.__DOCS_CONTEXT__ === undefined) {
12
12
  globalWindow.__DOCS_CONTEXT__ = /*#__PURE__*/createContext({});
13
13
  globalWindow.__DOCS_CONTEXT__.displayName = 'DocsContext';
14
14
  }
15
15
 
16
- export const DocsContext = globalWindow.__DOCS_CONTEXT__;
16
+ export const DocsContext = globalWindow ? globalWindow.__DOCS_CONTEXT__ : /*#__PURE__*/createContext({});
@@ -1,6 +1,5 @@
1
1
  import { Parser } from 'acorn';
2
- import jsx from 'acorn-jsx'; // eslint-disable-next-line import/no-extraneous-dependencies
3
-
2
+ import jsx from 'acorn-jsx';
4
3
  import * as acornWalk from 'acorn-walk';
5
4
  import { InspectionType } from './types';
6
5
  const ACORN_WALK_VISITORS = Object.assign({}, acornWalk.base, {
@@ -1,5 +1,4 @@
1
- import React from 'react'; // eslint-disable-next-line import/no-extraneous-dependencies
2
-
1
+ import React from 'react';
3
2
  import HOC from '@storybook/addon-docs/svelte/HOC.svelte';
4
3
  export const prepareForInline = storyFn => {
5
4
  const el = React.useRef(null);
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-case-declarations */
2
2
  import mapValues from 'lodash/mapValues';
3
- import { trimQuotes } from '../utils';
3
+ import { includesQuotes, trimQuotes } from '../utils';
4
4
  const SIGNATURE_REGEXP = /^\(.*\) => /;
5
5
  export const convert = type => {
6
6
  const {
@@ -15,7 +15,10 @@ export const convert = type => {
15
15
  switch (name) {
16
16
  case 'enum':
17
17
  {
18
- const values = computed ? value : value.map(v => trimQuotes(v.value));
18
+ const values = computed ? value : value.map(v => {
19
+ const trimmedValue = trimQuotes(v.value);
20
+ return includesQuotes(v.value) || Number.isNaN(Number(trimmedValue)) ? trimmedValue : Number(trimmedValue);
21
+ });
19
22
  return Object.assign({}, base, {
20
23
  name,
21
24
  value: values
@@ -1,2 +1,3 @@
1
1
  const QUOTE_REGEX = /^['"]|['"]$/g;
2
- export const trimQuotes = str => str.replace(QUOTE_REGEX, '');
2
+ export const trimQuotes = str => str.replace(QUOTE_REGEX, '');
3
+ export const includesQuotes = str => QUOTE_REGEX.test(str);
@@ -1 +1,2 @@
1
1
  export declare const trimQuotes: (str: string) => string;
2
+ export declare const includesQuotes: (str: string) => boolean;
@@ -1 +1,2 @@
1
1
  export declare const trimQuotes: (str: string) => string;
2
+ export declare const includesQuotes: (str: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/addon-docs",
3
- "version": "6.5.0-alpha.38",
3
+ "version": "6.5.0-alpha.41",
4
4
  "description": "Document component usage and properties in Markdown",
5
5
  "keywords": [
6
6
  "addon",
@@ -64,21 +64,21 @@
64
64
  "@mdx-js/loader": "^1.6.22",
65
65
  "@mdx-js/mdx": "^1.6.22",
66
66
  "@mdx-js/react": "^1.6.22",
67
- "@storybook/addons": "6.5.0-alpha.38",
68
- "@storybook/api": "6.5.0-alpha.38",
69
- "@storybook/builder-webpack4": "6.5.0-alpha.38",
70
- "@storybook/client-logger": "6.5.0-alpha.38",
71
- "@storybook/components": "6.5.0-alpha.38",
72
- "@storybook/core": "6.5.0-alpha.38",
73
- "@storybook/core-events": "6.5.0-alpha.38",
67
+ "@storybook/addons": "6.5.0-alpha.41",
68
+ "@storybook/api": "6.5.0-alpha.41",
69
+ "@storybook/builder-webpack4": "6.5.0-alpha.41",
70
+ "@storybook/client-logger": "6.5.0-alpha.41",
71
+ "@storybook/components": "6.5.0-alpha.41",
72
+ "@storybook/core": "6.5.0-alpha.41",
73
+ "@storybook/core-events": "6.5.0-alpha.41",
74
74
  "@storybook/csf": "0.0.2--canary.87bc651.0",
75
- "@storybook/csf-tools": "6.5.0-alpha.38",
76
- "@storybook/node-logger": "6.5.0-alpha.38",
77
- "@storybook/postinstall": "6.5.0-alpha.38",
78
- "@storybook/preview-web": "6.5.0-alpha.38",
79
- "@storybook/source-loader": "6.5.0-alpha.38",
80
- "@storybook/store": "6.5.0-alpha.38",
81
- "@storybook/theming": "6.5.0-alpha.38",
75
+ "@storybook/csf-tools": "6.5.0-alpha.41",
76
+ "@storybook/node-logger": "6.5.0-alpha.41",
77
+ "@storybook/postinstall": "6.5.0-alpha.41",
78
+ "@storybook/preview-web": "6.5.0-alpha.41",
79
+ "@storybook/source-loader": "6.5.0-alpha.41",
80
+ "@storybook/store": "6.5.0-alpha.41",
81
+ "@storybook/theming": "6.5.0-alpha.41",
82
82
  "acorn": "^7.4.1",
83
83
  "acorn-jsx": "^5.3.1",
84
84
  "acorn-walk": "^7.2.0",
@@ -107,11 +107,11 @@
107
107
  "@babel/core": "^7.12.10",
108
108
  "@emotion/core": "^10.3.1",
109
109
  "@emotion/styled": "^10.0.27",
110
- "@storybook/angular": "6.5.0-alpha.38",
111
- "@storybook/html": "6.5.0-alpha.38",
112
- "@storybook/react": "6.5.0-alpha.38",
113
- "@storybook/vue": "6.5.0-alpha.38",
114
- "@storybook/web-components": "6.5.0-alpha.38",
110
+ "@storybook/angular": "6.5.0-alpha.41",
111
+ "@storybook/html": "6.5.0-alpha.41",
112
+ "@storybook/react": "6.5.0-alpha.41",
113
+ "@storybook/vue": "6.5.0-alpha.41",
114
+ "@storybook/web-components": "6.5.0-alpha.41",
115
115
  "@types/cross-spawn": "^6.0.2",
116
116
  "@types/doctrine": "^0.0.3",
117
117
  "@types/enzyme": "^3.10.8",
@@ -140,29 +140,25 @@
140
140
  "webpack": "4",
141
141
  "zone.js": "^0.11.3"
142
142
  },
143
- "peerDependencies": {
144
- "@storybook/angular": "6.5.0-alpha.38",
145
- "@storybook/html": "6.5.0-alpha.38",
146
- "@storybook/react": "6.5.0-alpha.38",
147
- "@storybook/vue": "6.5.0-alpha.38",
148
- "@storybook/vue3": "6.5.0-alpha.38",
149
- "@storybook/web-components": "6.5.0-alpha.38",
150
- "lit": "^2.0.0",
151
- "lit-html": "^1.4.1 || ^2.0.0",
152
- "react": "^16.8.0 || ^17.0.0",
153
- "react-dom": "^16.8.0 || ^17.0.0",
154
- "svelte": "^3.31.2",
155
- "sveltedoc-parser": "^4.1.0",
156
- "vue": "^2.6.10 || ^3.0.0",
157
- "webpack": "*"
158
- },
159
143
  "peerDependenciesMeta": {
160
144
  "@storybook/angular": {
161
145
  "optional": true
162
146
  },
147
+ "@storybook/builder-webpack4": {
148
+ "optional": true
149
+ },
150
+ "@storybook/builder-webpack5": {
151
+ "optional": true
152
+ },
163
153
  "@storybook/html": {
164
154
  "optional": true
165
155
  },
156
+ "@storybook/manager-webpack4": {
157
+ "optional": true
158
+ },
159
+ "@storybook/manager-webpack5": {
160
+ "optional": true
161
+ },
166
162
  "@storybook/react": {
167
163
  "optional": true
168
164
  },
@@ -203,7 +199,7 @@
203
199
  "publishConfig": {
204
200
  "access": "public"
205
201
  },
206
- "gitHead": "b0dd637a70b6b24fbd3b8d9f9df7299511f6ba62",
202
+ "gitHead": "10663a4c9ea6c04a04047b5bb22254d6b64201c2",
207
203
  "sbmodern": "dist/modern/index.js",
208
204
  "storybook": {
209
205
  "displayName": "Docs",