@storybook/addon-controls 7.0.0-alpha.1 → 7.0.0-alpha.4

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.
@@ -1,40 +1,10 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.symbol.js");
4
-
5
- require("core-js/modules/es.symbol.description.js");
6
-
7
- require("core-js/modules/es.symbol.iterator.js");
8
-
9
- require("core-js/modules/es.array.iterator.js");
10
-
11
- require("core-js/modules/es.string.iterator.js");
12
-
13
- require("core-js/modules/web.dom-collections.iterator.js");
14
-
15
- require("core-js/modules/es.array.slice.js");
16
-
17
- require("core-js/modules/es.function.name.js");
18
-
19
- require("core-js/modules/es.array.from.js");
20
-
21
- require("core-js/modules/es.regexp.exec.js");
22
-
23
3
  Object.defineProperty(exports, "__esModule", {
24
4
  value: true
25
5
  });
26
6
  exports.ControlsPanel = void 0;
27
7
 
28
- require("core-js/modules/es.array.sort.js");
29
-
30
- require("core-js/modules/es.object.to-string.js");
31
-
32
- require("core-js/modules/es.object.values.js");
33
-
34
- require("core-js/modules/es.object.entries.js");
35
-
36
- require("core-js/modules/es.object.assign.js");
37
-
38
8
  var _react = _interopRequireDefault(require("react"));
39
9
 
40
10
  var _api = require("@storybook/api");
@@ -45,56 +15,28 @@ var _constants = require("./constants");
45
15
 
46
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
47
17
 
48
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
49
-
50
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
51
-
52
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
53
-
54
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
55
-
56
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
57
-
58
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
59
-
60
- var ControlsPanel = function ControlsPanel() {
61
- var _useArgs = (0, _api.useArgs)(),
62
- _useArgs2 = _slicedToArray(_useArgs, 3),
63
- args = _useArgs2[0],
64
- updateArgs = _useArgs2[1],
65
- resetArgs = _useArgs2[2];
66
-
67
- var _useGlobals = (0, _api.useGlobals)(),
68
- _useGlobals2 = _slicedToArray(_useGlobals, 1),
69
- globals = _useGlobals2[0];
70
-
71
- var rows = (0, _api.useArgTypes)();
72
- var isArgsStory = (0, _api.useParameter)('__isArgsStory', false);
73
-
74
- var _useParameter = (0, _api.useParameter)(_constants.PARAM_KEY, {}),
75
- expanded = _useParameter.expanded,
76
- sort = _useParameter.sort,
77
- presetColors = _useParameter.presetColors,
78
- _useParameter$hideNoC = _useParameter.hideNoControlsWarning,
79
- hideNoControlsWarning = _useParameter$hideNoC === void 0 ? false : _useParameter$hideNoC;
80
-
81
- var _useStorybookState = (0, _api.useStorybookState)(),
82
- path = _useStorybookState.path;
83
-
84
- var hasControls = Object.values(rows).some(function (arg) {
85
- return arg === null || arg === void 0 ? void 0 : arg.control;
86
- });
87
- var showWarning = !(hasControls && isArgsStory) && !hideNoControlsWarning;
88
- var withPresetColors = Object.entries(rows).reduce(function (acc, _ref) {
18
+ const ControlsPanel = () => {
19
+ const [args, updateArgs, resetArgs] = (0, _api.useArgs)();
20
+ const [globals] = (0, _api.useGlobals)();
21
+ const rows = (0, _api.useArgTypes)();
22
+ const isArgsStory = (0, _api.useParameter)('__isArgsStory', false);
23
+ const {
24
+ expanded,
25
+ sort,
26
+ presetColors,
27
+ hideNoControlsWarning = false
28
+ } = (0, _api.useParameter)(_constants.PARAM_KEY, {});
29
+ const {
30
+ path
31
+ } = (0, _api.useStorybookState)();
32
+ const hasControls = Object.values(rows).some(arg => arg === null || arg === void 0 ? void 0 : arg.control);
33
+ const showWarning = !(hasControls && isArgsStory) && !hideNoControlsWarning;
34
+ const withPresetColors = Object.entries(rows).reduce((acc, [key, arg]) => {
89
35
  var _arg$control, _arg$control2;
90
36
 
91
- var _ref2 = _slicedToArray(_ref, 2),
92
- key = _ref2[0],
93
- arg = _ref2[1];
94
-
95
37
  if ((arg === null || arg === void 0 ? void 0 : (_arg$control = arg.control) === null || _arg$control === void 0 ? void 0 : _arg$control.type) !== 'color' || arg !== null && arg !== void 0 && (_arg$control2 = arg.control) !== null && _arg$control2 !== void 0 && _arg$control2.presetColors) acc[key] = arg;else acc[key] = Object.assign({}, arg, {
96
38
  control: Object.assign({}, arg.control, {
97
- presetColors: presetColors
39
+ presetColors
98
40
  })
99
41
  });
100
42
  return acc;
@@ -104,12 +46,12 @@ var ControlsPanel = function ControlsPanel() {
104
46
  // resets state when switching stories
105
47
  compact: !expanded && hasControls,
106
48
  rows: withPresetColors,
107
- args: args,
108
- globals: globals,
109
- updateArgs: updateArgs,
110
- resetArgs: resetArgs,
49
+ args,
50
+ globals,
51
+ updateArgs,
52
+ resetArgs,
111
53
  inAddonPanel: true,
112
- sort: sort
54
+ sort
113
55
  }));
114
56
  };
115
57
 
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.PARAM_KEY = exports.ADDON_ID = void 0;
7
- var ADDON_ID = 'addon-controls';
7
+ const ADDON_ID = 'addon-controls';
8
8
  exports.ADDON_ID = ADDON_ID;
9
- var PARAM_KEY = 'controls';
9
+ const PARAM_KEY = 'controls';
10
10
  exports.PARAM_KEY = PARAM_KEY;
package/dist/cjs/index.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "PARAM_KEY", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _constants.PARAM_KEY;
10
10
  }
11
11
  });
@@ -1,11 +1,5 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.array.filter.js");
4
-
5
- require("core-js/modules/es.object.to-string.js");
6
-
7
- require("core-js/modules/es.object.values.js");
8
-
9
3
  var _react = _interopRequireDefault(require("react"));
10
4
 
11
5
  var _addons = require("@storybook/addons");
@@ -20,22 +14,21 @@ var _constants = require("./constants");
20
14
 
21
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
16
 
23
- _addons.addons.register(_constants.ADDON_ID, function (api) {
17
+ _addons.addons.register(_constants.ADDON_ID, api => {
24
18
  _addons.addons.addPanel(_constants.ADDON_ID, {
25
- title: function title() {
26
- var rows = (0, _api.useArgTypes)();
27
- var controlsCount = Object.values(rows).filter(function (argType) {
28
- return argType === null || argType === void 0 ? void 0 : argType.control;
29
- }).length;
30
- var suffix = controlsCount === 0 ? '' : " (".concat(controlsCount, ")");
31
- return "Controls".concat(suffix);
19
+ title() {
20
+ const rows = (0, _api.useArgTypes)();
21
+ const controlsCount = Object.values(rows).filter(argType => argType === null || argType === void 0 ? void 0 : argType.control).length;
22
+ const suffix = controlsCount === 0 ? '' : ` (${controlsCount})`;
23
+ return `Controls${suffix}`;
32
24
  },
25
+
33
26
  type: _addons.types.PANEL,
34
27
  paramKey: _constants.PARAM_KEY,
35
- render: function render(_ref) {
36
- var key = _ref.key,
37
- active = _ref.active;
38
-
28
+ render: ({
29
+ key,
30
+ active
31
+ }) => {
39
32
  if (!active || !api.getCurrentStoryData()) {
40
33
  return null;
41
34
  }
@@ -5,15 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.checkDocsLoaded = void 0;
7
7
 
8
- require("core-js/modules/es.array.join.js");
9
-
10
8
  var _coreCommon = require("@storybook/core-common");
11
9
 
12
10
  var _path = _interopRequireDefault(require("path"));
13
11
 
14
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
13
 
16
- var checkDocsLoaded = function checkDocsLoaded(configDir) {
14
+ const checkDocsLoaded = configDir => {
17
15
  (0, _coreCommon.checkAddonOrder)({
18
16
  before: {
19
17
  name: '@storybook/addon-docs',
@@ -24,9 +22,7 @@ var checkDocsLoaded = function checkDocsLoaded(configDir) {
24
22
  inEssentials: true
25
23
  },
26
24
  configFile: _path.default.isAbsolute(configDir) ? _path.default.join(configDir, 'main') : _path.default.join(process.cwd(), configDir, 'main'),
27
- getConfig: function getConfig(configFile) {
28
- return (0, _coreCommon.serverRequire)(configFile);
29
- }
25
+ getConfig: configFile => (0, _coreCommon.serverRequire)(configFile)
30
26
  });
31
27
  };
32
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/addon-controls",
3
- "version": "7.0.0-alpha.1",
3
+ "version": "7.0.0-alpha.4",
4
4
  "description": "Interact with component inputs dynamically in the Storybook UI",
5
5
  "keywords": [
6
6
  "addon",
@@ -38,15 +38,15 @@
38
38
  "prepare": "node ../../scripts/prepare.js"
39
39
  },
40
40
  "dependencies": {
41
- "@storybook/addons": "7.0.0-alpha.1",
42
- "@storybook/api": "7.0.0-alpha.1",
43
- "@storybook/client-logger": "7.0.0-alpha.1",
44
- "@storybook/components": "7.0.0-alpha.1",
45
- "@storybook/core-common": "7.0.0-alpha.1",
41
+ "@storybook/addons": "7.0.0-alpha.4",
42
+ "@storybook/api": "7.0.0-alpha.4",
43
+ "@storybook/client-logger": "7.0.0-alpha.4",
44
+ "@storybook/components": "7.0.0-alpha.4",
45
+ "@storybook/core-common": "7.0.0-alpha.4",
46
46
  "@storybook/csf": "0.0.2--canary.4566f4d.1",
47
- "@storybook/node-logger": "7.0.0-alpha.1",
48
- "@storybook/store": "7.0.0-alpha.1",
49
- "@storybook/theming": "7.0.0-alpha.1",
47
+ "@storybook/node-logger": "7.0.0-alpha.4",
48
+ "@storybook/store": "7.0.0-alpha.4",
49
+ "@storybook/theming": "7.0.0-alpha.4",
50
50
  "core-js": "^3.8.2",
51
51
  "lodash": "^4.17.21",
52
52
  "ts-dedent": "^2.0.0"
@@ -66,7 +66,7 @@
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "gitHead": "b90b85210f66da59656c2ef58b0910b156256bea",
69
+ "gitHead": "006ed54452dd7c37a8cbe91a84f5312182f7ca00",
70
70
  "storybook": {
71
71
  "displayName": "Controls",
72
72
  "icon": "https://user-images.githubusercontent.com/263385/101991669-479cc600-3c7c-11eb-93d9-38b67e8371f2.png",