@itcase/storybook-config 1.2.72 → 1.2.74

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,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-DoGZRTm5.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-DoGZRTm5.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.74",
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",
@@ -1,247 +0,0 @@
1
- 'use strict';
2
-
3
- var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-D8XyM9rZ.js');
4
- var React = require('react');
5
-
6
- var SUBMIT_TIMEOUT_MS = 5000;
7
- var SUBMIT_POLL_MS = 50;
8
- function getMountRoot() {
9
- var _document$getElementB;
10
- return (_document$getElementB = document.getElementById('storybook-root')) !== null && _document$getElementB !== void 0 ? _document$getElementB : document.body;
11
- }
12
- function sleep() {
13
- var ms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SUBMIT_POLL_MS;
14
- return new Promise(function (resolve) {
15
- setTimeout(resolve, ms);
16
- });
17
- }
18
- function findSubmitButton(root) {
19
- var _root$querySelector;
20
- if (!root) {
21
- return null;
22
- }
23
- return (_root$querySelector = root.querySelector('button[type="submit"]')) !== null && _root$querySelector !== void 0 ? _root$querySelector : root.querySelector('button.form__button-item');
24
- }
25
- function isSubmitButton(button) {
26
- return (button === null || button === void 0 ? void 0 : button.type) === 'submit';
27
- }
28
- function canUseFormApi(form) {
29
- return typeof (form === null || form === void 0 ? void 0 : form.submit) === 'function';
30
- }
31
- function prepareFormForAutoSubmit(form) {
32
- var _config$field, _form$getFieldState$v, _form$getFieldState, _config$suffix;
33
- var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
34
- if (!canUseFormApi(form) || typeof form.getRegisteredFields !== 'function') {
35
- return;
36
- }
37
- var fieldName = (_config$field = config.field) !== null && _config$field !== void 0 ? _config$field : form.getRegisteredFields()[0];
38
- if (!fieldName) {
39
- return;
40
- }
41
- var value = (_form$getFieldState$v = (_form$getFieldState = form.getFieldState(fieldName)) === null || _form$getFieldState === void 0 ? void 0 : _form$getFieldState.value) !== null && _form$getFieldState$v !== void 0 ? _form$getFieldState$v : '';
42
- var nextValue = "".concat(value).concat((_config$suffix = config.suffix) !== null && _config$suffix !== void 0 ? _config$suffix : "\u200B");
43
- if (nextValue !== value) {
44
- form.change(fieldName, nextValue);
45
- }
46
- }
47
- function triggerFormSubmit(_ref) {
48
- var _submitButton$closest, _submitButton$closest2;
49
- var form = _ref.form,
50
- submitButton = _ref.submitButton;
51
- if (isSubmitButton(submitButton)) {
52
- submitButton.click();
53
- return;
54
- }
55
- if (canUseFormApi(form)) {
56
- form.submit();
57
- return;
58
- }
59
- submitButton === null || submitButton === void 0 || (_submitButton$closest = submitButton.closest('form')) === null || _submitButton$closest === void 0 || (_submitButton$closest2 = _submitButton$closest.requestSubmit) === null || _submitButton$closest2 === void 0 || _submitButton$closest2.call(_submitButton$closest);
60
- }
61
- function getSubmitTarget(formRef) {
62
- var submitButton = findSubmitButton(getMountRoot());
63
- return {
64
- canSubmit: Boolean(submitButton) || canUseFormApi(formRef.current),
65
- form: formRef.current,
66
- submitButton: submitButton
67
- };
68
- }
69
- function bindSubmitButtonClick(formRef, signal) {
70
- var root = getMountRoot();
71
- if (!root) {
72
- return undefined;
73
- }
74
- var handler = function handler(event) {
75
- if (signal.aborted) {
76
- return;
77
- }
78
- var submitButton = findSubmitButton(root);
79
- if (!submitButton || isSubmitButton(submitButton)) {
80
- return;
81
- }
82
- if (event.target !== submitButton && !submitButton.contains(event.target)) {
83
- return;
84
- }
85
- event.preventDefault();
86
- triggerFormSubmit({
87
- form: formRef.current,
88
- submitButton: submitButton
89
- });
90
- };
91
- root.addEventListener('click', handler, true);
92
- return function () {
93
- root.removeEventListener('click', handler, true);
94
- };
95
- }
96
- function autoSubmitForm(_x) {
97
- return _autoSubmitForm.apply(this, arguments);
98
- }
99
- function _autoSubmitForm() {
100
- _autoSubmitForm = _rollupPluginBabelHelpers._asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers._regenerator().m(function _callee(formRef) {
101
- var formSubmitConfig,
102
- signal,
103
- didPrepareUnchangedSubmit,
104
- deadline,
105
- _getSubmitTarget,
106
- canSubmit,
107
- form,
108
- submitButton,
109
- _args = arguments;
110
- return _rollupPluginBabelHelpers._regenerator().w(function (_context) {
111
- while (1) switch (_context.n) {
112
- case 0:
113
- formSubmitConfig = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
114
- signal = _args.length > 2 ? _args[2] : undefined;
115
- didPrepareUnchangedSubmit = false;
116
- deadline = Date.now() + SUBMIT_TIMEOUT_MS;
117
- case 1:
118
- if (!(Date.now() < deadline && !signal.aborted)) {
119
- _context.n = 6;
120
- break;
121
- }
122
- _getSubmitTarget = getSubmitTarget(formRef), canSubmit = _getSubmitTarget.canSubmit, form = _getSubmitTarget.form, submitButton = _getSubmitTarget.submitButton;
123
- if (canSubmit) {
124
- _context.n = 3;
125
- break;
126
- }
127
- _context.n = 2;
128
- return sleep();
129
- case 2:
130
- return _context.a(3, 1);
131
- case 3:
132
- if (!(formSubmitConfig !== null && formSubmitConfig !== void 0 && formSubmitConfig.allowUnchangedSubmit && !didPrepareUnchangedSubmit)) {
133
- _context.n = 5;
134
- break;
135
- }
136
- prepareFormForAutoSubmit(form, formSubmitConfig);
137
- didPrepareUnchangedSubmit = true;
138
- _context.n = 4;
139
- return sleep();
140
- case 4:
141
- return _context.a(3, 1);
142
- case 5:
143
- triggerFormSubmit({
144
- form: form,
145
- submitButton: submitButton
146
- });
147
- return _context.a(2);
148
- case 6:
149
- return _context.a(2);
150
- }
151
- }, _callee);
152
- }));
153
- return _autoSubmitForm.apply(this, arguments);
154
- }
155
-
156
- function wrapRender(component, render, formRef) {
157
- if (!component || typeof render !== 'function') {
158
- return render;
159
- }
160
- return function renderWithRef(storyArgs) {
161
- var args = _rollupPluginBabelHelpers._objectSpread2({}, storyArgs !== null && storyArgs !== void 0 ? storyArgs : {});
162
- delete args.ref;
163
- return /*#__PURE__*/React.createElement(component, _rollupPluginBabelHelpers._objectSpread2({
164
- ref: formRef
165
- }, args));
166
- };
167
- }
168
- function withFormRef(children, formRef, bindings) {
169
- var _ref, _children$props, _ref2, _children$props2, _ref3, _children$props3;
170
- var component = bindings.component,
171
- args = bindings.args,
172
- storyRender = bindings.render,
173
- allArgs = bindings.allArgs,
174
- context = bindings.context;
175
- var storyComponent = (_ref = component !== null && component !== void 0 ? component : context === null || context === void 0 ? void 0 : context.component) !== null && _ref !== void 0 ? _ref : children === null || children === void 0 || (_children$props = children.props) === null || _children$props === void 0 ? void 0 : _children$props.component;
176
- var storyRenderFn = (_ref2 = storyRender !== null && storyRender !== void 0 ? storyRender : context === null || context === void 0 ? void 0 : context.render) !== null && _ref2 !== void 0 ? _ref2 : children === null || children === void 0 || (_children$props2 = children.props) === null || _children$props2 === void 0 ? void 0 : _children$props2.render;
177
- var boundRender = wrapRender(storyComponent, storyRenderFn, formRef);
178
- var addRef = function addRef(value) {
179
- return value ? _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, value), {}, {
180
- ref: formRef
181
- }) : value;
182
- };
183
- return /*#__PURE__*/React.cloneElement(children, {
184
- component: storyComponent,
185
- args: addRef((_ref3 = args !== null && args !== void 0 ? args : context === null || context === void 0 ? void 0 : context.args) !== null && _ref3 !== void 0 ? _ref3 : children === null || children === void 0 || (_children$props3 = children.props) === null || _children$props3 === void 0 ? void 0 : _children$props3.args),
186
- render: boundRender,
187
- allArgs: addRef(allArgs),
188
- context: context ? _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, context), {}, {
189
- component: storyComponent,
190
- args: addRef(context.args),
191
- render: boundRender,
192
- allArgs: addRef(context.allArgs)
193
- }) : context
194
- });
195
- }
196
-
197
- /**
198
- * Авто-submit для интерактивного Storybook (Require / Validation / ServerError).
199
- * При primaryButtonHtmlType="button" вызывает formRef.current.submit() (final-form API)
200
- * и вешает click на кнопку, чтобы ручной submit тоже работал.
201
- * В Vitest не используется — submit делается в play.
202
- */
203
- function FormSubmitWrapper(props) {
204
- var formRef = React.useRef(null);
205
- var component = props.component,
206
- args = props.args,
207
- parameters = props.parameters,
208
- render = props.render,
209
- allArgs = props.allArgs,
210
- context = props.context,
211
- _props$submit = props.submit,
212
- submit = _props$submit === void 0 ? true : _props$submit,
213
- children = props.children;
214
- var formSubmitConfig = parameters === null || parameters === void 0 ? void 0 : parameters.formSubmit;
215
- React.useEffect(function () {
216
- if (!submit) {
217
- return undefined;
218
- }
219
- var abortController = new AbortController();
220
- var unbindClick = bindSubmitButtonClick(formRef, abortController.signal);
221
- return function () {
222
- abortController.abort();
223
- unbindClick === null || unbindClick === void 0 || unbindClick();
224
- };
225
- }, [formSubmitConfig, submit]);
226
- React.useEffect(function () {
227
- if (!submit) {
228
- return undefined;
229
- }
230
- var abortController = new AbortController();
231
- autoSubmitForm(formRef, formSubmitConfig, abortController.signal);
232
- return function () {
233
- abortController.abort();
234
- };
235
- }, [formSubmitConfig, submit]);
236
-
237
- // eslint-disable-next-line react-hooks/refs -- ref уходит в createElement внутри bound render
238
- return withFormRef(children, formRef, {
239
- component: component,
240
- args: args,
241
- render: render,
242
- allArgs: allArgs,
243
- context: context
244
- });
245
- }
246
-
247
- exports.FormSubmitWrapper = FormSubmitWrapper;