@storybook/addon-docs 6.5.0-alpha.40 → 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;
@@ -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({});
@@ -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,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.40",
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.40",
68
- "@storybook/api": "6.5.0-alpha.40",
69
- "@storybook/builder-webpack4": "6.5.0-alpha.40",
70
- "@storybook/client-logger": "6.5.0-alpha.40",
71
- "@storybook/components": "6.5.0-alpha.40",
72
- "@storybook/core": "6.5.0-alpha.40",
73
- "@storybook/core-events": "6.5.0-alpha.40",
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.40",
76
- "@storybook/node-logger": "6.5.0-alpha.40",
77
- "@storybook/postinstall": "6.5.0-alpha.40",
78
- "@storybook/preview-web": "6.5.0-alpha.40",
79
- "@storybook/source-loader": "6.5.0-alpha.40",
80
- "@storybook/store": "6.5.0-alpha.40",
81
- "@storybook/theming": "6.5.0-alpha.40",
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.40",
111
- "@storybook/html": "6.5.0-alpha.40",
112
- "@storybook/react": "6.5.0-alpha.40",
113
- "@storybook/vue": "6.5.0-alpha.40",
114
- "@storybook/web-components": "6.5.0-alpha.40",
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",
@@ -199,7 +199,7 @@
199
199
  "publishConfig": {
200
200
  "access": "public"
201
201
  },
202
- "gitHead": "ffb3402ee40562579d45dbcf7870a1a8372ac0dd",
202
+ "gitHead": "10663a4c9ea6c04a04047b5bb22254d6b64201c2",
203
203
  "sbmodern": "dist/modern/index.js",
204
204
  "storybook": {
205
205
  "displayName": "Docs",