@itcase/storybook-config 1.2.72 → 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.
@@ -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-CytvWwKi.js';
2
- import './_rollupPluginBabelHelpers-OwKVS06F.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 { _objectWithoutProperties as _, _asyncToGenerator as a, _regenerator as b, _objectSpread2 as c };
258
+ export { _objectWithoutProperties as _, _asyncToGenerator as a, _regenerator as b, _createForOfIteratorHelper as c, _objectSpread2 as d };
@@ -1,4 +1,4 @@
1
- import { c as _objectSpread2 } from '../components/_rollupPluginBabelHelpers-OwKVS06F.js';
1
+ import { d as _objectSpread2 } from '../components/_rollupPluginBabelHelpers-CEVa9ZMs.js';
2
2
  import React from 'react';
3
3
  import { r as requireIsArray, g as getDefaultExportFromCjs } from '../components/isArray-CPoGkdXv.js';
4
4
 
@@ -1,9 +1,10 @@
1
+ import { d as _objectSpread2 } from '../components/_rollupPluginBabelHelpers-CEVa9ZMs.js';
1
2
  import React from 'react';
2
- import { F as FormSubmitWrapper } from '../components/FormSubmitWrapper-CytvWwKi.js';
3
+ import { F as FormSubmitWrapper } from '../components/FormSubmitWrapper-obAauTlP.js';
3
4
  import { c as commonjsGlobal, r as requireIsArray } from '../components/isArray-CPoGkdXv.js';
4
5
  import '@itcase/common';
5
6
  import 'msw';
6
- import '../components/_rollupPluginBabelHelpers-OwKVS06F.js';
7
+ import 'final-form';
7
8
 
8
9
  /** Detect free variable `global` from Node.js. */
9
10
 
@@ -1121,13 +1122,27 @@ function isVitestEnvironment() {
1121
1122
  return Boolean((_import$meta$env = import.meta.env) === null || _import$meta$env === void 0 ? void 0 : _import$meta$env.VITEST);
1122
1123
  }
1123
1124
 
1125
+ function getStoryArgs(storyContext) {
1126
+ var _storyContext$context, _storyContext$initial, _baseContext$args, _storyContext$args;
1127
+ var baseContext = (_storyContext$context = storyContext.context) !== null && _storyContext$context !== void 0 ? _storyContext$context : storyContext;
1128
+ return _objectSpread2(_objectSpread2(_objectSpread2({}, (_storyContext$initial = storyContext.initialArgs) !== null && _storyContext$initial !== void 0 ? _storyContext$initial : {}), (_baseContext$args = baseContext.args) !== null && _baseContext$args !== void 0 ? _baseContext$args : {}), (_storyContext$args = storyContext.args) !== null && _storyContext$args !== void 0 ? _storyContext$args : {});
1129
+ }
1130
+ function enhanceStoryContext(storyContext) {
1131
+ var _storyContext$context2;
1132
+ var baseContext = (_storyContext$context2 = storyContext.context) !== null && _storyContext$context2 !== void 0 ? _storyContext$context2 : storyContext;
1133
+ var args = getStoryArgs(storyContext);
1134
+ return _objectSpread2(_objectSpread2({}, baseContext), {}, {
1135
+ args: args
1136
+ });
1137
+ }
1124
1138
  function withFormSubmitDecorator() {
1125
1139
  var decorator = function decorator(Story, storyContext) {
1126
- var _storyContext$context;
1127
1140
  var parameters = storyContext.parameters;
1128
- var context = (_storyContext$context = storyContext.context) !== null && _storyContext$context !== void 0 ? _storyContext$context : storyContext;
1141
+ var context = enhanceStoryContext(storyContext);
1129
1142
  if (isVitestEnvironment() || !hasFormParameters(parameters)) {
1130
- return /*#__PURE__*/React.createElement(Story, context);
1143
+ return /*#__PURE__*/React.createElement(Story, Object.assign({}, context, {
1144
+ parameters: parameters
1145
+ }));
1131
1146
  }
1132
1147
  return /*#__PURE__*/React.createElement(FormSubmitWrapper, Object.assign({}, context, {
1133
1148
  parameters: parameters
@@ -1,4 +1,4 @@
1
- import { _ as _objectWithoutProperties } from '../components/_rollupPluginBabelHelpers-OwKVS06F.js';
1
+ import { _ as _objectWithoutProperties } from '../components/_rollupPluginBabelHelpers-CEVa9ZMs.js';
2
2
  import React from 'react';
3
3
  import { NotificationWrapper } from '@itcase/ui-web/components/Notification';
4
4
  import { UIProvider, NotificationsProvider } from '@itcase/ui-core/context';
@@ -6,10 +6,11 @@ export { withLayoutDecorator } from './decorators/withLayoutDecorator.js';
6
6
  export { withNextDecoratorFactory } from './decorators/withNextDecorator.js';
7
7
  export { withUiDecorator } from './decorators/withUiDecorator.js';
8
8
  import 'react';
9
- import './components/_rollupPluginBabelHelpers-OwKVS06F.js';
9
+ import './components/_rollupPluginBabelHelpers-CEVa9ZMs.js';
10
10
  import './components/isArray-CPoGkdXv.js';
11
- import './components/FormSubmitWrapper-CytvWwKi.js';
11
+ import './components/FormSubmitWrapper-obAauTlP.js';
12
12
  import '@itcase/common';
13
13
  import 'msw';
14
+ import 'final-form';
14
15
  import '@itcase/ui-web/components/Notification';
15
16
  import '@itcase/ui-core/context';
@@ -1,17 +1,29 @@
1
- import { serverErrorHandler } from '../config/msw/mswHandlers'
1
+ import {
2
+ serverErrorDataHandler,
3
+ serverErrorHandler,
4
+ } from '../config/msw/mswHandlers'
2
5
 
3
6
  function handleMSWParameters(parameters, args) {
4
- let mswHandlersParams = {}
7
+ const errors = args?.errors
8
+ const handlers = []
5
9
 
6
10
  if (parameters.serverError) {
7
- mswHandlersParams = {
8
- msw: {
9
- handlers: [serverErrorHandler(args.errors)],
10
- },
11
- }
11
+ handlers.push(serverErrorHandler(errors))
12
12
  }
13
13
 
14
- return mswHandlersParams
14
+ if (parameters.serverErrorData) {
15
+ handlers.push(serverErrorDataHandler(errors?.non_field_errors || errors))
16
+ }
17
+
18
+ if (handlers.length === 0) {
19
+ return {}
20
+ }
21
+
22
+ return {
23
+ msw: {
24
+ handlers,
25
+ },
26
+ }
15
27
  }
16
28
 
17
29
  export { handleMSWParameters }
@@ -3,6 +3,7 @@ import { getStoryInfoBlocks } from './getStoryInfoBlocks.js'
3
3
  import { handleMSWParameters } from './handleMSWParameters.js'
4
4
  import { hasFormParameters } from './hasFormParameters.js'
5
5
  import { isVitestEnvironment } from './isVitestEnvironment.js'
6
+ import { mapErrorsToFinalForm } from './storybookServerErrorOnSubmit.js'
6
7
 
7
8
  // import { storybookFormMockFactory } from './storybookFormMockFactory.js'
8
9
 
@@ -12,5 +13,6 @@ export {
12
13
  handleMSWParameters,
13
14
  hasFormParameters,
14
15
  isVitestEnvironment,
16
+ mapErrorsToFinalForm,
15
17
  // storybookFormMockFactory,
16
18
  }
@@ -0,0 +1,21 @@
1
+ import { FORM_ERROR } from 'final-form'
2
+
3
+ function mapErrorsToFinalForm(errors) {
4
+ if (!errors || typeof errors !== 'object') {
5
+ return {}
6
+ }
7
+
8
+ const formErrors = {}
9
+
10
+ for (const key of Object.keys(errors)) {
11
+ const errorFieldKey =
12
+ key === 'non_field_errors' || key === 'detail' ? FORM_ERROR : key
13
+ const value = errors[key]
14
+
15
+ formErrors[errorFieldKey] = Array.isArray(value) ? value[0] : value
16
+ }
17
+
18
+ return formErrors
19
+ }
20
+
21
+ export { mapErrorsToFinalForm }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/storybook-config",
3
- "version": "1.2.72",
3
+ "version": "1.2.73",
4
4
  "author": "ITCase",
5
5
  "description": "Storybook configuration package",
6
6
  "engines": {
@@ -94,26 +94,26 @@
94
94
  "@react-native-async-storage/async-storage": "^3.1.1",
95
95
  "@react-native-community/datetimepicker": "^9.1.0",
96
96
  "@storybook/addon-designs": "^11.1.3",
97
- "@storybook/addon-docs": "^10.4.1",
98
- "@storybook/addon-links": "^10.4.1",
97
+ "@storybook/addon-docs": "^10.4.2",
98
+ "@storybook/addon-links": "^10.4.2",
99
99
  "@storybook/addon-ondevice-actions": "10.4.4",
100
100
  "@storybook/addon-ondevice-backgrounds": "10.4.4",
101
101
  "@storybook/addon-ondevice-controls": "10.4.4",
102
102
  "@storybook/addon-ondevice-notes": "^10.4.4",
103
103
  "@storybook/addon-react-native-web": "^0.0.29",
104
104
  "@storybook/addon-styling-webpack": "^3.0.2",
105
- "@storybook/addon-themes": "^10.4.1",
106
- "@storybook/addon-vitest": "^10.4.1",
105
+ "@storybook/addon-themes": "^10.4.2",
106
+ "@storybook/addon-vitest": "^10.4.2",
107
107
  "@storybook/addon-webpack5-compiler-swc": "^4.0.3",
108
- "@storybook/builder-vite": "^10.4.1",
109
- "@storybook/nextjs": "^10.4.1",
110
- "@storybook/nextjs-vite": "^10.4.1",
111
- "@storybook/react": "^10.4.1",
108
+ "@storybook/builder-vite": "^10.4.2",
109
+ "@storybook/nextjs": "^10.4.2",
110
+ "@storybook/nextjs-vite": "^10.4.2",
111
+ "@storybook/react": "^10.4.2",
112
112
  "@storybook/react-native": "10.4.4",
113
113
  "@storybook/react-native-ui-lite": "10.4.4",
114
- "@storybook/react-native-web-vite": "^10.4.1",
115
- "@storybook/react-vite": "^10.4.1",
116
- "@storybook/react-webpack5": "^10.4.1",
114
+ "@storybook/react-native-web-vite": "^10.4.2",
115
+ "@storybook/react-vite": "^10.4.2",
116
+ "@storybook/react-webpack5": "^10.4.2",
117
117
  "@vitejs/plugin-react": "^6.0.2",
118
118
  "@vitest/browser-playwright": "^4.1.8",
119
119
  "babel-loader": "^10.1.1",
@@ -130,7 +130,7 @@
130
130
  "react-native-svg": "^15.15.5",
131
131
  "react-native-web": "^0.21.2",
132
132
  "react-native-worklets": "^0.9.1",
133
- "storybook": "^10.4.1",
133
+ "storybook": "^10.4.2",
134
134
  "storybook-addon-source-link": "^2.0.1",
135
135
  "vite": "^8.0.16",
136
136
  "vite-plugin-babel": "^1.7.3",
@@ -145,10 +145,10 @@
145
145
  "@babel/runtime": "^7.29.7",
146
146
  "@commitlint/cli": "^21.0.2",
147
147
  "@commitlint/config-conventional": "^21.0.2",
148
- "@itcase/common": "^1.2.43",
148
+ "@itcase/common": "^1.2.44",
149
149
  "@itcase/lint": "^1.1.116",
150
150
  "@itcase/ui-core": "^1.10.15",
151
- "@itcase/ui-web": "^1.10.16",
151
+ "@itcase/ui-web": "^1.10.20",
152
152
  "@react-native-community/cli": "20.1.3",
153
153
  "@react-native-community/cli-platform-android": "20.1.3",
154
154
  "@react-native-community/cli-platform-ios": "20.1.3",
@@ -160,7 +160,7 @@
160
160
  "@rollup/plugin-commonjs": "^29.0.3",
161
161
  "@rollup/plugin-json": "^6.1.0",
162
162
  "@rollup/plugin-node-resolve": "^16.0.3",
163
- "@storybook/addon-docs": "^10.4.1",
163
+ "@storybook/addon-docs": "^10.4.2",
164
164
  "@types/react": "^18",
165
165
  "@types/react-dom": "^18",
166
166
  "babel-plugin-transform-inline-environment-variables": "^0.4.4",