@itcase/storybook-config 1.2.71 → 1.2.73

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.
Files changed (32) hide show
  1. package/README.md +9 -0
  2. package/dist/FormSubmitWrapper-kEv1DMjn.js +296 -0
  3. package/dist/{_rollupPluginBabelHelpers-D8XyM9rZ.js → _rollupPluginBabelHelpers-B1r4NF8e.js} +61 -0
  4. package/dist/cjs/components/FormSubmitWrapper.js +2 -2
  5. package/dist/cjs/decorators/withFigmaSourceLink.js +59 -3
  6. package/dist/cjs/decorators/withFormSubmitDecorator.js +1128 -6
  7. package/dist/cjs/decorators/withNextDecorator.js +7 -12
  8. package/dist/cjs/decorators/withUiDecorator.js +4 -9
  9. package/dist/cjs/decorators.js +6 -8
  10. package/dist/components/EmailTemplatePreview.js +2 -2
  11. package/dist/components/FormSubmitWrapper-obAauTlP.js +294 -0
  12. package/dist/components/FormSubmitWrapper.js +2 -2
  13. package/dist/components/{_rollupPluginBabelHelpers-DQ-fuxJg.js → _rollupPluginBabelHelpers-CEVa9ZMs.js} +61 -1
  14. package/dist/components/isArray-CPoGkdXv.js +43 -0
  15. package/dist/config/sourceLink/sourceLink.js +8 -16
  16. package/dist/decorators/withClearStoresDecorator.js +2 -2
  17. package/dist/decorators/withExtraProviders.js +2 -2
  18. package/dist/decorators/withFigmaSourceLink.js +61 -5
  19. package/dist/decorators/withFormSubmitDecorator.js +1131 -9
  20. package/dist/decorators/withLayoutDecorator.js +9 -9
  21. package/dist/decorators/withNextDecorator.js +8 -13
  22. package/dist/decorators/withUiDecorator.js +5 -10
  23. package/dist/decorators.js +6 -8
  24. package/dist/isArray-DJguRq_2.js +47 -0
  25. package/dist/utils/handleMSWParameters.js +20 -8
  26. package/dist/utils/index.js +2 -0
  27. package/dist/utils/storybookServerErrorOnSubmit.js +21 -0
  28. package/package.json +35 -29
  29. package/dist/FormSubmitWrapper-DXUEGLuS.js +0 -247
  30. package/dist/Notification-Cqx2_tCE.js +0 -7945
  31. package/dist/components/FormSubmitWrapper-YokGjDrh.js +0 -245
  32. package/dist/components/Notification-qLYjGbKN.js +0 -7923
@@ -1,14 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var _rollupPluginBabelHelpers = require('../../_rollupPluginBabelHelpers-D8XyM9rZ.js');
3
+ var _rollupPluginBabelHelpers = require('../../_rollupPluginBabelHelpers-B1r4NF8e.js');
4
4
  var React = require('react');
5
- var Notification = require('../../Notification-Cqx2_tCE.js');
6
- require('@itcase/common');
7
- require('lodash/camelCase');
8
- require('lodash/castArray');
9
- require('lodash/upperFirst');
10
- require('lodash/maxBy');
11
- require('react-dom');
5
+ var Notification = require('@itcase/ui-web/components/Notification');
6
+ var context = require('@itcase/ui-core/context');
12
7
 
13
8
  var _excluded = ["storesData"];
14
9
  function withNextDecoratorFactory(_ref) {
@@ -17,11 +12,11 @@ function withNextDecoratorFactory(_ref) {
17
12
  var decorator = function decorator(Story, _ref2) {
18
13
  var args = _ref2.args,
19
14
  parameters = _ref2.parameters,
20
- context = _ref2.context;
15
+ context$1 = _ref2.context;
21
16
  var _prepareStoryArgument = prepareStoryArguments({
22
17
  args: args,
23
18
  parameters: parameters,
24
- context: context
19
+ context: context$1
25
20
  }),
26
21
  appArgs = _prepareStoryArgument.appArgs,
27
22
  appContext = _prepareStoryArgument.appContext,
@@ -32,9 +27,9 @@ function withNextDecoratorFactory(_ref) {
32
27
  pageProps: appArgs
33
28
  });
34
29
  }
35
- return /*#__PURE__*/React.createElement(RootStoreProvider, appArgs.rootStoreInitialData, /*#__PURE__*/React.createElement(Notification.d, null, /*#__PURE__*/React.createElement(Notification.m, {
30
+ return /*#__PURE__*/React.createElement(RootStoreProvider, appArgs.rootStoreInitialData, /*#__PURE__*/React.createElement(context.UIProvider, null, /*#__PURE__*/React.createElement(context.NotificationsProvider, {
36
31
  initialNotificationsList: parameters.initialNotificationsList || args.initialNotificationsList || []
37
- }, /*#__PURE__*/React.createElement(Notification.P, {
32
+ }, /*#__PURE__*/React.createElement(Notification.NotificationWrapper, {
38
33
  className: "notification_global notification_global_right_top"
39
34
  }), /*#__PURE__*/React.createElement(Story, appContext))));
40
35
  };
@@ -1,20 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
- var Notification = require('../../Notification-Cqx2_tCE.js');
5
- require('@itcase/common');
6
- require('lodash/camelCase');
7
- require('lodash/castArray');
8
- require('lodash/upperFirst');
9
- require('lodash/maxBy');
10
- require('react-dom');
4
+ var Notification = require('@itcase/ui-web/components/Notification');
5
+ var context = require('@itcase/ui-core/context');
11
6
 
12
7
  function withUiDecorator(Story, _ref) {
13
8
  var args = _ref.args,
14
9
  parameters = _ref.parameters;
15
- return /*#__PURE__*/React.createElement(Notification.d, null, /*#__PURE__*/React.createElement(Notification.m, {
10
+ return /*#__PURE__*/React.createElement(context.UIProvider, null, /*#__PURE__*/React.createElement(context.NotificationsProvider, {
16
11
  initialNotificationsList: parameters.initialNotificationsList || args.initialNotificationsList || []
17
- }, /*#__PURE__*/React.createElement(Notification.P, null), /*#__PURE__*/React.createElement(Story, null)));
12
+ }, /*#__PURE__*/React.createElement(Notification.NotificationWrapper, null), /*#__PURE__*/React.createElement(Story, null)));
18
13
  }
19
14
 
20
15
  exports.withUiDecorator = withUiDecorator;
@@ -8,16 +8,14 @@ var withLayoutDecorator = require('./decorators/withLayoutDecorator.js');
8
8
  var withNextDecorator = require('./decorators/withNextDecorator.js');
9
9
  var withUiDecorator = require('./decorators/withUiDecorator.js');
10
10
  require('react');
11
- require('../_rollupPluginBabelHelpers-D8XyM9rZ.js');
12
- require('lodash/castArray');
13
- require('../FormSubmitWrapper-DXUEGLuS.js');
14
- require('lodash/camelCase');
11
+ require('../_rollupPluginBabelHelpers-B1r4NF8e.js');
12
+ require('../isArray-DJguRq_2.js');
13
+ require('../FormSubmitWrapper-kEv1DMjn.js');
15
14
  require('@itcase/common');
16
15
  require('msw');
17
- require('../Notification-Cqx2_tCE.js');
18
- require('lodash/upperFirst');
19
- require('lodash/maxBy');
20
- require('react-dom');
16
+ require('final-form');
17
+ require('@itcase/ui-web/components/Notification');
18
+ require('@itcase/ui-core/context');
21
19
 
22
20
 
23
21
 
@@ -1,4 +1,4 @@
1
- import React__default, { useEffect } from 'react';
1
+ import React, { useEffect } from 'react';
2
2
 
3
3
  var BACKEND_URL = process.env.EMAIL_URL;
4
4
  if (process.env.NODE_ENV === 'production' && process.env.REST_BASE_URL) {
@@ -31,7 +31,7 @@ function EmailTemplatePreview(props) {
31
31
  if (!BACKEND_URL) {
32
32
  return null;
33
33
  }
34
- return /*#__PURE__*/React__default.createElement("iframe", {
34
+ return /*#__PURE__*/React.createElement("iframe", {
35
35
  id: "emailPreview",
36
36
  width: "100%",
37
37
  height: "100%",
@@ -0,0 +1,294 @@
1
+ import { a as _asyncToGenerator, b as _regenerator, c as _createForOfIteratorHelper, d as _objectSpread2 } from './_rollupPluginBabelHelpers-CEVa9ZMs.js';
2
+ import React, { useRef, useEffect } from 'react';
3
+
4
+ var SUBMIT_TIMEOUT_MS = 15000;
5
+ var SUBMIT_POLL_MS = 50;
6
+ function getStoryPreviewDocument() {
7
+ var _document$getElementB, _previewIframe$conten;
8
+ var previewIframe = (_document$getElementB = document.getElementById('storybook-preview-iframe')) !== null && _document$getElementB !== void 0 ? _document$getElementB : document.querySelector('iframe[data-is-storybook="true"]');
9
+ return (_previewIframe$conten = previewIframe === null || previewIframe === void 0 ? void 0 : previewIframe.contentDocument) !== null && _previewIframe$conten !== void 0 ? _previewIframe$conten : null;
10
+ }
11
+ function getMountRoot() {
12
+ var _ref2, _document$getElementB2;
13
+ var previewDocument = getStoryPreviewDocument();
14
+ if (previewDocument) {
15
+ var _ref, _previewDocument$getE;
16
+ return (_ref = (_previewDocument$getE = previewDocument.getElementById('storybook-root')) !== null && _previewDocument$getE !== void 0 ? _previewDocument$getE : previewDocument.getElementById('root')) !== null && _ref !== void 0 ? _ref : previewDocument.body;
17
+ }
18
+ return (_ref2 = (_document$getElementB2 = document.getElementById('storybook-root')) !== null && _document$getElementB2 !== void 0 ? _document$getElementB2 : document.getElementById('root')) !== null && _ref2 !== void 0 ? _ref2 : document.body;
19
+ }
20
+ function canSubmitFormApi(form) {
21
+ return typeof (form === null || form === void 0 ? void 0 : form.submit) === 'function' && typeof form.getRegisteredFields === 'function' && form.getRegisteredFields().length > 0;
22
+ }
23
+ function findSaveDraftButton(root) {
24
+ if (!root) {
25
+ return null;
26
+ }
27
+ var saveDraft = root.querySelector('[data-testid$="SaveDraftButton"]');
28
+ if (!saveDraft) {
29
+ return null;
30
+ }
31
+ return saveDraft.tagName === 'BUTTON' ? saveDraft : saveDraft.querySelector('button');
32
+ }
33
+ function findSubmitButton(root) {
34
+ var _form$querySelector;
35
+ if (!root) {
36
+ return null;
37
+ }
38
+ var byType = root.querySelector('button[type="submit"]');
39
+ if (byType) {
40
+ return byType;
41
+ }
42
+ var form = root.querySelector('form[data-testid], form');
43
+ if (!form) {
44
+ return null;
45
+ }
46
+ return (_form$querySelector = form.querySelector('.form__button .form__button-item, .form__button-item')) !== null && _form$querySelector !== void 0 ? _form$querySelector : null;
47
+ }
48
+ function touchFieldsBeforeSubmit(form) {
49
+ if (!canSubmitFormApi(form)) {
50
+ return;
51
+ }
52
+ var _iterator = _createForOfIteratorHelper(form.getRegisteredFields()),
53
+ _step;
54
+ try {
55
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
56
+ var _form$getFieldState;
57
+ var fieldName = _step.value;
58
+ if (!((_form$getFieldState = form.getFieldState(fieldName)) !== null && _form$getFieldState !== void 0 && _form$getFieldState.touched)) {
59
+ form.blur(fieldName);
60
+ }
61
+ }
62
+ } catch (err) {
63
+ _iterator.e(err);
64
+ } finally {
65
+ _iterator.f();
66
+ }
67
+ }
68
+ function hasModifiedFields(form) {
69
+ return Object.values(form.getState().modified).some(Boolean);
70
+ }
71
+
72
+ /** Filled edit-формы (#1167): без modified submit не уходит — для story auto-submit. */
73
+ function ensureFormModifiedForStorybookSubmit(form) {
74
+ if (!canSubmitFormApi(form) || hasModifiedFields(form)) {
75
+ return;
76
+ }
77
+ var _form$getState = form.getState(),
78
+ values = _form$getState.values;
79
+ var _iterator2 = _createForOfIteratorHelper(form.getRegisteredFields()),
80
+ _step2;
81
+ try {
82
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
83
+ var fieldName = _step2.value;
84
+ var value = values[fieldName];
85
+ if (typeof value === 'string' && value.length > 0) {
86
+ form.change(fieldName, "".concat(value, "x"));
87
+ return;
88
+ }
89
+ }
90
+ } catch (err) {
91
+ _iterator2.e(err);
92
+ } finally {
93
+ _iterator2.f();
94
+ }
95
+ }
96
+ function clickSubmitButton(submitButton) {
97
+ if (!submitButton) {
98
+ return;
99
+ }
100
+ var nativeButton = submitButton.tagName === 'BUTTON' ? submitButton : submitButton.querySelector('button');
101
+ (nativeButton !== null && nativeButton !== void 0 ? nativeButton : submitButton).click();
102
+ }
103
+ function triggerFormSubmit(_ref3) {
104
+ var form = _ref3.form,
105
+ root = _ref3.root,
106
+ submitButton = _ref3.submitButton;
107
+ var saveDraftButton = findSaveDraftButton(root !== null && root !== void 0 ? root : getMountRoot());
108
+ if (saveDraftButton) {
109
+ saveDraftButton.click();
110
+ return;
111
+ }
112
+ if (canSubmitFormApi(form)) {
113
+ ensureFormModifiedForStorybookSubmit(form);
114
+ touchFieldsBeforeSubmit(form);
115
+ form.submit();
116
+ return;
117
+ }
118
+ clickSubmitButton(submitButton);
119
+ }
120
+ function autoSubmitForm(_x, _x2) {
121
+ return _autoSubmitForm.apply(this, arguments);
122
+ }
123
+ function _autoSubmitForm() {
124
+ _autoSubmitForm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(formRef, signal) {
125
+ var deadline, _submitButton$querySe, root, form, submitButton, saveDraftButton, canSubmitViaFormApi, canClickNativeSubmit, canClickSaveDraft;
126
+ return _regenerator().w(function (_context) {
127
+ while (1) switch (_context.n) {
128
+ case 0:
129
+ if (!formRef.__itcaseDidAutoSubmit) {
130
+ _context.n = 1;
131
+ break;
132
+ }
133
+ return _context.a(2);
134
+ case 1:
135
+ deadline = Date.now() + SUBMIT_TIMEOUT_MS;
136
+ case 2:
137
+ if (!(Date.now() < deadline && !signal.aborted)) {
138
+ _context.n = 9;
139
+ break;
140
+ }
141
+ root = getMountRoot();
142
+ form = formRef.current;
143
+ submitButton = findSubmitButton(root);
144
+ saveDraftButton = findSaveDraftButton(root);
145
+ canSubmitViaFormApi = canSubmitFormApi(form);
146
+ canClickNativeSubmit = Boolean(submitButton && (submitButton.type === 'submit' || ((_submitButton$querySe = submitButton.querySelector) === null || _submitButton$querySe === void 0 ? void 0 : _submitButton$querySe.call(submitButton, 'button[type="submit"]'))));
147
+ canClickSaveDraft = Boolean(saveDraftButton); // primaryButtonHtmlType="button": ждём final-form API или кнопку черновика в DOM
148
+ if (!(!canSubmitViaFormApi && !canClickNativeSubmit && !canClickSaveDraft)) {
149
+ _context.n = 4;
150
+ break;
151
+ }
152
+ _context.n = 3;
153
+ return new Promise(function (resolve) {
154
+ setTimeout(resolve, SUBMIT_POLL_MS);
155
+ });
156
+ case 3:
157
+ return _context.a(3, 2);
158
+ case 4:
159
+ if (!(!canSubmitViaFormApi && canClickNativeSubmit && !canClickSaveDraft)) {
160
+ _context.n = 6;
161
+ break;
162
+ }
163
+ _context.n = 5;
164
+ return new Promise(function (resolve) {
165
+ setTimeout(resolve, SUBMIT_POLL_MS);
166
+ });
167
+ case 5:
168
+ return _context.a(3, 2);
169
+ case 6:
170
+ formRef.__itcaseDidAutoSubmit = true;
171
+ _context.n = 7;
172
+ return new Promise(function (resolve) {
173
+ requestAnimationFrame(function () {
174
+ requestAnimationFrame(resolve);
175
+ });
176
+ });
177
+ case 7:
178
+ if (!signal.aborted) {
179
+ _context.n = 8;
180
+ break;
181
+ }
182
+ return _context.a(2);
183
+ case 8:
184
+ triggerFormSubmit({
185
+ form: formRef.current,
186
+ root: root,
187
+ submitButton: submitButton
188
+ });
189
+ return _context.a(2);
190
+ case 9:
191
+ return _context.a(2);
192
+ }
193
+ }, _callee);
194
+ }));
195
+ return _autoSubmitForm.apply(this, arguments);
196
+ }
197
+
198
+ function wrapRender(component, render, formRef) {
199
+ var defaultArgs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
200
+ if (typeof render !== 'function') {
201
+ return render;
202
+ }
203
+ return function renderWithRef(storyArgs) {
204
+ var args = _objectSpread2(_objectSpread2({}, defaultArgs), storyArgs !== null && storyArgs !== void 0 ? storyArgs : {});
205
+ delete args.ref;
206
+ delete args.errors;
207
+ if (!args.onSubmit && defaultArgs.onSubmit) {
208
+ args.onSubmit = defaultArgs.onSubmit;
209
+ }
210
+ var rendered = render(args);
211
+ if (/*#__PURE__*/React.isValidElement(rendered)) {
212
+ return /*#__PURE__*/React.cloneElement(rendered, _objectSpread2(_objectSpread2(_objectSpread2({}, rendered.props), args), {}, {
213
+ ref: formRef
214
+ }));
215
+ }
216
+ if (component) {
217
+ return /*#__PURE__*/React.createElement(component, _objectSpread2({
218
+ ref: formRef
219
+ }, args));
220
+ }
221
+ return rendered;
222
+ };
223
+ }
224
+ function withFormRef(children, formRef, bindings) {
225
+ var _ref, _ref2, _children$props, _ref3, _children$props2, _ref4, _children$props3;
226
+ var component = bindings.component,
227
+ args = bindings.args,
228
+ storyRender = bindings.render,
229
+ allArgs = bindings.allArgs,
230
+ context = bindings.context;
231
+ var storyArgs = (_ref = (_ref2 = args !== null && args !== void 0 ? args : context === null || context === void 0 ? void 0 : context.args) !== null && _ref2 !== void 0 ? _ref2 : children === null || children === void 0 || (_children$props = children.props) === null || _children$props === void 0 ? void 0 : _children$props.args) !== null && _ref !== void 0 ? _ref : {};
232
+ var storyComponent = (_ref3 = component !== null && component !== void 0 ? component : context === null || context === void 0 ? void 0 : context.component) !== null && _ref3 !== void 0 ? _ref3 : children === null || children === void 0 || (_children$props2 = children.props) === null || _children$props2 === void 0 ? void 0 : _children$props2.component;
233
+ var storyRenderFn = (_ref4 = storyRender !== null && storyRender !== void 0 ? storyRender : context === null || context === void 0 ? void 0 : context.render) !== null && _ref4 !== void 0 ? _ref4 : children === null || children === void 0 || (_children$props3 = children.props) === null || _children$props3 === void 0 ? void 0 : _children$props3.render;
234
+ var boundRender = wrapRender(storyComponent, storyRenderFn, formRef, storyArgs);
235
+ var addRef = function addRef(value) {
236
+ return value ? _objectSpread2(_objectSpread2({}, value), {}, {
237
+ ref: formRef
238
+ }) : value;
239
+ };
240
+ return /*#__PURE__*/React.cloneElement(children, {
241
+ component: storyComponent,
242
+ args: addRef(storyArgs),
243
+ render: boundRender,
244
+ allArgs: addRef(allArgs),
245
+ context: context ? _objectSpread2(_objectSpread2({}, context), {}, {
246
+ component: storyComponent,
247
+ args: addRef(context.args),
248
+ render: boundRender,
249
+ allArgs: addRef(context.allArgs)
250
+ }) : context
251
+ });
252
+ }
253
+
254
+ /**
255
+ * Авто-submit для интерактивного Storybook (Require / Validation / ServerError).
256
+ * При primaryButtonHtmlType="button" — formRef.current.submit() (final-form API),
257
+ * при type="submit" — click по кнопке. В Vitest submit в play.
258
+ */
259
+ function FormSubmitWrapper(props) {
260
+ var _ref5, _ref6, _children$props4;
261
+ var formRef = useRef(null);
262
+ var component = props.component,
263
+ args = props.args,
264
+ render = props.render,
265
+ allArgs = props.allArgs,
266
+ context = props.context,
267
+ _props$submit = props.submit,
268
+ submit = _props$submit === void 0 ? true : _props$submit,
269
+ children = props.children;
270
+ var storyArgs = (_ref5 = (_ref6 = args !== null && args !== void 0 ? args : context === null || context === void 0 ? void 0 : context.args) !== null && _ref6 !== void 0 ? _ref6 : children === null || children === void 0 || (_children$props4 = children.props) === null || _children$props4 === void 0 ? void 0 : _children$props4.args) !== null && _ref5 !== void 0 ? _ref5 : {};
271
+ useEffect(function () {
272
+ if (!submit) {
273
+ return undefined;
274
+ }
275
+ delete formRef.__itcaseDidAutoSubmit;
276
+ var abortController = new AbortController();
277
+ autoSubmitForm(formRef, abortController.signal);
278
+ return function () {
279
+ abortController.abort();
280
+ delete formRef.__itcaseDidAutoSubmit;
281
+ };
282
+ }, [submit, storyArgs.errors]);
283
+
284
+ // eslint-disable-next-line react-hooks/refs -- ref уходит в cloneElement внутри bound render
285
+ return withFormRef(children, formRef, {
286
+ component: component,
287
+ args: storyArgs,
288
+ render: render,
289
+ allArgs: allArgs,
290
+ context: context
291
+ });
292
+ }
293
+
294
+ export { FormSubmitWrapper as F };
@@ -1,3 +1,3 @@
1
- export { F as FormSubmitWrapper } from './FormSubmitWrapper-YokGjDrh.js';
2
- import './_rollupPluginBabelHelpers-DQ-fuxJg.js';
1
+ export { F as FormSubmitWrapper } from './FormSubmitWrapper-obAauTlP.js';
2
+ import './_rollupPluginBabelHelpers-CEVa9ZMs.js';
3
3
  import 'react';
@@ -1,3 +1,8 @@
1
+ function _arrayLikeToArray(r, a) {
2
+ (null == a || a > r.length) && (a = r.length);
3
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
4
+ return n;
5
+ }
1
6
  function asyncGeneratorStep(n, t, e, r, o, a, c) {
2
7
  try {
3
8
  var i = n[a](c),
@@ -23,6 +28,54 @@ function _asyncToGenerator(n) {
23
28
  });
24
29
  };
25
30
  }
31
+ function _createForOfIteratorHelper(r, e) {
32
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
33
+ if (!t) {
34
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
35
+ t && (r = t);
36
+ var n = 0,
37
+ F = function () {};
38
+ return {
39
+ s: F,
40
+ n: function () {
41
+ return n >= r.length ? {
42
+ done: true
43
+ } : {
44
+ done: false,
45
+ value: r[n++]
46
+ };
47
+ },
48
+ e: function (r) {
49
+ throw r;
50
+ },
51
+ f: F
52
+ };
53
+ }
54
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
55
+ }
56
+ var o,
57
+ a = true,
58
+ u = false;
59
+ return {
60
+ s: function () {
61
+ t = t.call(r);
62
+ },
63
+ n: function () {
64
+ var r = t.next();
65
+ return a = r.done, r;
66
+ },
67
+ e: function (r) {
68
+ u = true, o = r;
69
+ },
70
+ f: function () {
71
+ try {
72
+ a || null == t.return || t.return();
73
+ } finally {
74
+ if (u) throw o;
75
+ }
76
+ }
77
+ };
78
+ }
26
79
  function _defineProperty(e, r, t) {
27
80
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
28
81
  value: t,
@@ -194,5 +247,12 @@ function _toPropertyKey(t) {
194
247
  var i = _toPrimitive(t, "string");
195
248
  return "symbol" == typeof i ? i : i + "";
196
249
  }
250
+ function _unsupportedIterableToArray(r, a) {
251
+ if (r) {
252
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
253
+ var t = {}.toString.call(r).slice(8, -1);
254
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
255
+ }
256
+ }
197
257
 
198
- export { _asyncToGenerator as _, _objectSpread2 as a, _objectWithoutProperties as b, _regenerator as c };
258
+ export { _objectWithoutProperties as _, _asyncToGenerator as a, _regenerator as b, _createForOfIteratorHelper as c, _objectSpread2 as d };
@@ -0,0 +1,43 @@
1
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
+
3
+ function getDefaultExportFromCjs (x) {
4
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
+ }
6
+
7
+ /**
8
+ * Checks if `value` is classified as an `Array` object.
9
+ *
10
+ * @static
11
+ * @memberOf _
12
+ * @since 0.1.0
13
+ * @category Lang
14
+ * @param {*} value The value to check.
15
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
16
+ * @example
17
+ *
18
+ * _.isArray([1, 2, 3]);
19
+ * // => true
20
+ *
21
+ * _.isArray(document.body.children);
22
+ * // => false
23
+ *
24
+ * _.isArray('abc');
25
+ * // => false
26
+ *
27
+ * _.isArray(_.noop);
28
+ * // => false
29
+ */
30
+
31
+ var isArray_1;
32
+ var hasRequiredIsArray;
33
+
34
+ function requireIsArray () {
35
+ if (hasRequiredIsArray) return isArray_1;
36
+ hasRequiredIsArray = 1;
37
+ var isArray = Array.isArray;
38
+
39
+ isArray_1 = isArray;
40
+ return isArray_1;
41
+ }
42
+
43
+ export { commonjsGlobal as c, getDefaultExportFromCjs as g, requireIsArray as r };
@@ -7,26 +7,18 @@ const SOURCE_LINK = {
7
7
  'component-editor': ({ importPath, rootPath }) => {
8
8
  if (!rootPath) return undefined
9
9
 
10
- let labelPath =
11
- 'Source ' + importPath.replace(/\.stories\.(js|jsx|ts|tsx)?$/, '')
12
- let componentPath = importPath.replace('.stories', '')
13
- let componentFileUrl = getFileUrl(rootPath, componentPath)
10
+ const storiesFolderIndex = importPath.indexOf('/stories/')
11
+ const componentPath =
12
+ storiesFolderIndex !== -1
13
+ ? `${importPath.slice(0, storiesFolderIndex)}/index.ts`
14
+ : importPath.replace(/\.stories\.(js|jsx|mjs|ts|tsx)$/, '.$1')
15
+
16
+ const fileUrl = getFileUrl(rootPath, componentPath)
14
17
 
15
- if (componentFileUrl.pathname.includes('/stories')) {
16
- const resultPath =
17
- componentFileUrl.pathname.slice(
18
- 0,
19
- componentFileUrl.pathname.indexOf('/stories'),
20
- ) + '/index.ts'
21
- const resultLabelBase =
22
- labelPath.slice(0, labelPath.indexOf('/stories')) + '/index.ts'
23
- labelPath = resultLabelBase
24
- componentFileUrl = resultPath
25
- }
26
18
  return {
27
19
  type: 'editor',
28
20
  label: 'VSCode — ' + componentPath,
29
- href: componentFileUrl.href,
21
+ href: fileUrl.href,
30
22
  icon: 'VSCodeIcon',
31
23
  }
32
24
  },
@@ -1,4 +1,4 @@
1
- import React__default, { useMemo } from 'react';
1
+ import React, { useMemo } from 'react';
2
2
 
3
3
  function withClearStoresDecorator(_ref) {
4
4
  var clearStoreData = _ref.clearStoreData;
@@ -6,7 +6,7 @@ function withClearStoresDecorator(_ref) {
6
6
  useMemo(function () {
7
7
  clearStoreData();
8
8
  }, [Story]);
9
- return /*#__PURE__*/React__default.createElement(Story, null);
9
+ return /*#__PURE__*/React.createElement(Story, null);
10
10
  };
11
11
  return Decorator;
12
12
  }
@@ -1,4 +1,4 @@
1
- import React__default from 'react';
1
+ import React from 'react';
2
2
 
3
3
  function withExtraProviders() {
4
4
  var providers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
@@ -9,7 +9,7 @@ function withExtraProviders() {
9
9
  var item = providers[i];
10
10
  var Component = item.provider;
11
11
  var props = item.props || {};
12
- currentStory = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Component, props, currentStory));
12
+ currentStory = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Component, props, currentStory));
13
13
  }
14
14
  return currentStory;
15
15
  };
@@ -1,6 +1,62 @@
1
- import { a as _objectSpread2 } from '../components/_rollupPluginBabelHelpers-DQ-fuxJg.js';
2
- import React__default from 'react';
3
- import s from 'lodash/castArray';
1
+ import { d as _objectSpread2 } from '../components/_rollupPluginBabelHelpers-CEVa9ZMs.js';
2
+ import React from 'react';
3
+ import { r as requireIsArray, g as getDefaultExportFromCjs } from '../components/isArray-CPoGkdXv.js';
4
+
5
+ var castArray_1;
6
+ var hasRequiredCastArray;
7
+
8
+ function requireCastArray () {
9
+ if (hasRequiredCastArray) return castArray_1;
10
+ hasRequiredCastArray = 1;
11
+ var isArray = requireIsArray();
12
+
13
+ /**
14
+ * Casts `value` as an array if it's not one.
15
+ *
16
+ * @static
17
+ * @memberOf _
18
+ * @since 4.4.0
19
+ * @category Lang
20
+ * @param {*} value The value to inspect.
21
+ * @returns {Array} Returns the cast array.
22
+ * @example
23
+ *
24
+ * _.castArray(1);
25
+ * // => [1]
26
+ *
27
+ * _.castArray({ 'a': 1 });
28
+ * // => [{ 'a': 1 }]
29
+ *
30
+ * _.castArray('abc');
31
+ * // => ['abc']
32
+ *
33
+ * _.castArray(null);
34
+ * // => [null]
35
+ *
36
+ * _.castArray(undefined);
37
+ * // => [undefined]
38
+ *
39
+ * _.castArray();
40
+ * // => []
41
+ *
42
+ * var array = [1, 2, 3];
43
+ * console.log(_.castArray(array) === array);
44
+ * // => true
45
+ */
46
+ function castArray() {
47
+ if (!arguments.length) {
48
+ return [];
49
+ }
50
+ var value = arguments[0];
51
+ return isArray(value) ? value : [value];
52
+ }
53
+
54
+ castArray_1 = castArray;
55
+ return castArray_1;
56
+ }
57
+
58
+ var castArrayExports = requireCastArray();
59
+ var castArray = /*@__PURE__*/getDefaultExportFromCjs(castArrayExports);
4
60
 
5
61
  function withFigmaSourceLink() {
6
62
  var decorator = function decorator(Story, _ref) {
@@ -8,7 +64,7 @@ function withFigmaSourceLink() {
8
64
  context = _ref.context;
9
65
  var sourceLink = parameters.sourceLink || {};
10
66
  if (parameters.design) {
11
- var designList = s(parameters.design);
67
+ var designList = castArray(parameters.design);
12
68
  if (!sourceLink.links) {
13
69
  sourceLink.links = {};
14
70
  }
@@ -26,7 +82,7 @@ function withFigmaSourceLink() {
26
82
  sourceLink: sourceLink
27
83
  })
28
84
  });
29
- return /*#__PURE__*/React__default.createElement(Story, updatedContext);
85
+ return /*#__PURE__*/React.createElement(Story, updatedContext);
30
86
  };
31
87
  return decorator;
32
88
  }