@itcase/storybook-config 1.2.69 → 1.2.71
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.
- package/dist/{FormSubmitWrapper-i32wPLJH.js → FormSubmitWrapper-DXUEGLuS.js} +111 -71
- package/dist/cjs/components/FormSubmitWrapper.js +1 -1
- package/dist/cjs/decorators/withFormSubmitDecorator.js +1 -1
- package/dist/cjs/decorators.js +1 -1
- package/dist/components/{FormSubmitWrapper-DvowO4lz.js → FormSubmitWrapper-YokGjDrh.js} +111 -71
- package/dist/components/FormSubmitWrapper.js +1 -1
- package/dist/decorators/withFormSubmitDecorator.js +1 -1
- package/dist/decorators.js +1 -1
- package/package.json +9 -9
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-D8XyM9rZ.js');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
|
|
6
|
-
var SUBMIT_TIMEOUT_MS =
|
|
6
|
+
var SUBMIT_TIMEOUT_MS = 5000;
|
|
7
7
|
var SUBMIT_POLL_MS = 50;
|
|
8
8
|
function getMountRoot() {
|
|
9
|
-
var
|
|
10
|
-
return (
|
|
9
|
+
var _document$getElementB;
|
|
10
|
+
return (_document$getElementB = document.getElementById('storybook-root')) !== null && _document$getElementB !== void 0 ? _document$getElementB : document.body;
|
|
11
11
|
}
|
|
12
12
|
function sleep() {
|
|
13
13
|
var ms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SUBMIT_POLL_MS;
|
|
@@ -15,110 +15,137 @@ function sleep() {
|
|
|
15
15
|
setTimeout(resolve, ms);
|
|
16
16
|
});
|
|
17
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
|
+
}
|
|
18
31
|
function prepareFormForAutoSubmit(form) {
|
|
19
|
-
var _config$field,
|
|
32
|
+
var _config$field, _form$getFieldState$v, _form$getFieldState, _config$suffix;
|
|
20
33
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
21
|
-
|
|
22
|
-
|
|
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];
|
|
23
38
|
if (!fieldName) {
|
|
24
|
-
return
|
|
39
|
+
return;
|
|
25
40
|
}
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (nextValue === value) {
|
|
31
|
-
return false;
|
|
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);
|
|
32
45
|
}
|
|
33
|
-
form.change(fieldName, nextValue);
|
|
34
|
-
return true;
|
|
35
46
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
var form = root.querySelector('form[data-testid], form');
|
|
45
|
-
if (!form) {
|
|
46
|
-
return null;
|
|
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;
|
|
47
54
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return
|
|
55
|
+
if (canUseFormApi(form)) {
|
|
56
|
+
form.submit();
|
|
57
|
+
return;
|
|
51
58
|
}
|
|
52
|
-
|
|
53
|
-
return byTestId;
|
|
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);
|
|
54
60
|
}
|
|
55
|
-
function
|
|
56
|
-
var
|
|
57
|
-
var submitButton = findSubmitButton(root);
|
|
58
|
-
var form = formRef.current;
|
|
59
|
-
var hasFields = typeof (form === null || form === void 0 ? void 0 : form.getRegisteredFields) === 'function' && form.getRegisteredFields().length > 0;
|
|
61
|
+
function getSubmitTarget(formRef) {
|
|
62
|
+
var submitButton = findSubmitButton(getMountRoot());
|
|
60
63
|
return {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
form: form,
|
|
64
|
+
canSubmit: Boolean(submitButton) || canUseFormApi(formRef.current),
|
|
65
|
+
form: formRef.current,
|
|
64
66
|
submitButton: submitButton
|
|
65
67
|
};
|
|
66
68
|
}
|
|
67
|
-
function
|
|
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) {
|
|
68
97
|
return _autoSubmitForm.apply(this, arguments);
|
|
69
98
|
}
|
|
70
99
|
function _autoSubmitForm() {
|
|
71
|
-
_autoSubmitForm = _rollupPluginBabelHelpers._asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers._regenerator().m(function _callee(formRef
|
|
72
|
-
var
|
|
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;
|
|
73
110
|
return _rollupPluginBabelHelpers._regenerator().w(function (_context) {
|
|
74
111
|
while (1) switch (_context.n) {
|
|
75
112
|
case 0:
|
|
76
|
-
|
|
113
|
+
formSubmitConfig = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
114
|
+
signal = _args.length > 2 ? _args[2] : undefined;
|
|
77
115
|
didPrepareUnchangedSubmit = false;
|
|
116
|
+
deadline = Date.now() + SUBMIT_TIMEOUT_MS;
|
|
78
117
|
case 1:
|
|
79
|
-
if (!(Date.now() < deadline)) {
|
|
80
|
-
_context.n =
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
if (!signal.aborted) {
|
|
84
|
-
_context.n = 2;
|
|
118
|
+
if (!(Date.now() < deadline && !signal.aborted)) {
|
|
119
|
+
_context.n = 6;
|
|
85
120
|
break;
|
|
86
121
|
}
|
|
87
|
-
|
|
88
|
-
case 2:
|
|
89
|
-
_getFormSubmitTarget = getFormSubmitTarget(formRef), canMarkForm = _getFormSubmitTarget.canMarkForm, canSubmit = _getFormSubmitTarget.canSubmit, form = _getFormSubmitTarget.form, submitButton = _getFormSubmitTarget.submitButton;
|
|
122
|
+
_getSubmitTarget = getSubmitTarget(formRef), canSubmit = _getSubmitTarget.canSubmit, form = _getSubmitTarget.form, submitButton = _getSubmitTarget.submitButton;
|
|
90
123
|
if (canSubmit) {
|
|
91
|
-
_context.n =
|
|
124
|
+
_context.n = 3;
|
|
92
125
|
break;
|
|
93
126
|
}
|
|
94
|
-
_context.n =
|
|
127
|
+
_context.n = 2;
|
|
95
128
|
return sleep();
|
|
96
|
-
case
|
|
129
|
+
case 2:
|
|
97
130
|
return _context.a(3, 1);
|
|
98
|
-
case
|
|
131
|
+
case 3:
|
|
99
132
|
if (!(formSubmitConfig !== null && formSubmitConfig !== void 0 && formSubmitConfig.allowUnchangedSubmit && !didPrepareUnchangedSubmit)) {
|
|
100
|
-
_context.n =
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
if (!canMarkForm) {
|
|
104
|
-
_context.n = 6;
|
|
133
|
+
_context.n = 5;
|
|
105
134
|
break;
|
|
106
135
|
}
|
|
107
136
|
prepareFormForAutoSubmit(form, formSubmitConfig);
|
|
108
137
|
didPrepareUnchangedSubmit = true;
|
|
109
|
-
_context.n =
|
|
138
|
+
_context.n = 4;
|
|
110
139
|
return sleep();
|
|
111
|
-
case
|
|
112
|
-
return _context.a(3, 1);
|
|
113
|
-
case 6:
|
|
114
|
-
_context.n = 7;
|
|
115
|
-
return sleep();
|
|
116
|
-
case 7:
|
|
140
|
+
case 4:
|
|
117
141
|
return _context.a(3, 1);
|
|
118
|
-
case
|
|
119
|
-
|
|
142
|
+
case 5:
|
|
143
|
+
triggerFormSubmit({
|
|
144
|
+
form: form,
|
|
145
|
+
submitButton: submitButton
|
|
146
|
+
});
|
|
120
147
|
return _context.a(2);
|
|
121
|
-
case
|
|
148
|
+
case 6:
|
|
122
149
|
return _context.a(2);
|
|
123
150
|
}
|
|
124
151
|
}, _callee);
|
|
@@ -169,6 +196,8 @@ function withFormRef(children, formRef, bindings) {
|
|
|
169
196
|
|
|
170
197
|
/**
|
|
171
198
|
* Авто-submit для интерактивного Storybook (Require / Validation / ServerError).
|
|
199
|
+
* При primaryButtonHtmlType="button" вызывает formRef.current.submit() (final-form API)
|
|
200
|
+
* и вешает click на кнопку, чтобы ручной submit тоже работал.
|
|
172
201
|
* В Vitest не используется — submit делается в play.
|
|
173
202
|
*/
|
|
174
203
|
function FormSubmitWrapper(props) {
|
|
@@ -183,6 +212,17 @@ function FormSubmitWrapper(props) {
|
|
|
183
212
|
submit = _props$submit === void 0 ? true : _props$submit,
|
|
184
213
|
children = props.children;
|
|
185
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]);
|
|
186
226
|
React.useEffect(function () {
|
|
187
227
|
if (!submit) {
|
|
188
228
|
return undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var FormSubmitWrapper = require('../../FormSubmitWrapper-
|
|
4
|
+
var FormSubmitWrapper = require('../../FormSubmitWrapper-DXUEGLuS.js');
|
|
5
5
|
require('lodash/camelCase');
|
|
6
6
|
require('@itcase/common');
|
|
7
7
|
require('msw');
|
package/dist/cjs/decorators.js
CHANGED
|
@@ -10,7 +10,7 @@ var withUiDecorator = require('./decorators/withUiDecorator.js');
|
|
|
10
10
|
require('react');
|
|
11
11
|
require('../_rollupPluginBabelHelpers-D8XyM9rZ.js');
|
|
12
12
|
require('lodash/castArray');
|
|
13
|
-
require('../FormSubmitWrapper-
|
|
13
|
+
require('../FormSubmitWrapper-DXUEGLuS.js');
|
|
14
14
|
require('lodash/camelCase');
|
|
15
15
|
require('@itcase/common');
|
|
16
16
|
require('msw');
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { _ as _asyncToGenerator, c as _regenerator, a as _objectSpread2 } from './_rollupPluginBabelHelpers-DQ-fuxJg.js';
|
|
2
2
|
import React__default, { useRef, useEffect } from 'react';
|
|
3
3
|
|
|
4
|
-
var SUBMIT_TIMEOUT_MS =
|
|
4
|
+
var SUBMIT_TIMEOUT_MS = 5000;
|
|
5
5
|
var SUBMIT_POLL_MS = 50;
|
|
6
6
|
function getMountRoot() {
|
|
7
|
-
var
|
|
8
|
-
return (
|
|
7
|
+
var _document$getElementB;
|
|
8
|
+
return (_document$getElementB = document.getElementById('storybook-root')) !== null && _document$getElementB !== void 0 ? _document$getElementB : document.body;
|
|
9
9
|
}
|
|
10
10
|
function sleep() {
|
|
11
11
|
var ms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SUBMIT_POLL_MS;
|
|
@@ -13,110 +13,137 @@ function sleep() {
|
|
|
13
13
|
setTimeout(resolve, ms);
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
+
function findSubmitButton(root) {
|
|
17
|
+
var _root$querySelector;
|
|
18
|
+
if (!root) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return (_root$querySelector = root.querySelector('button[type="submit"]')) !== null && _root$querySelector !== void 0 ? _root$querySelector : root.querySelector('button.form__button-item');
|
|
22
|
+
}
|
|
23
|
+
function isSubmitButton(button) {
|
|
24
|
+
return (button === null || button === void 0 ? void 0 : button.type) === 'submit';
|
|
25
|
+
}
|
|
26
|
+
function canUseFormApi(form) {
|
|
27
|
+
return typeof (form === null || form === void 0 ? void 0 : form.submit) === 'function';
|
|
28
|
+
}
|
|
16
29
|
function prepareFormForAutoSubmit(form) {
|
|
17
|
-
var _config$field,
|
|
30
|
+
var _config$field, _form$getFieldState$v, _form$getFieldState, _config$suffix;
|
|
18
31
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
19
|
-
|
|
20
|
-
|
|
32
|
+
if (!canUseFormApi(form) || typeof form.getRegisteredFields !== 'function') {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
var fieldName = (_config$field = config.field) !== null && _config$field !== void 0 ? _config$field : form.getRegisteredFields()[0];
|
|
21
36
|
if (!fieldName) {
|
|
22
|
-
return
|
|
37
|
+
return;
|
|
23
38
|
}
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (nextValue === value) {
|
|
29
|
-
return false;
|
|
39
|
+
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 : '';
|
|
40
|
+
var nextValue = "".concat(value).concat((_config$suffix = config.suffix) !== null && _config$suffix !== void 0 ? _config$suffix : "\u200B");
|
|
41
|
+
if (nextValue !== value) {
|
|
42
|
+
form.change(fieldName, nextValue);
|
|
30
43
|
}
|
|
31
|
-
form.change(fieldName, nextValue);
|
|
32
|
-
return true;
|
|
33
44
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
var form = root.querySelector('form[data-testid], form');
|
|
43
|
-
if (!form) {
|
|
44
|
-
return null;
|
|
45
|
+
function triggerFormSubmit(_ref) {
|
|
46
|
+
var _submitButton$closest, _submitButton$closest2;
|
|
47
|
+
var form = _ref.form,
|
|
48
|
+
submitButton = _ref.submitButton;
|
|
49
|
+
if (isSubmitButton(submitButton)) {
|
|
50
|
+
submitButton.click();
|
|
51
|
+
return;
|
|
45
52
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return
|
|
53
|
+
if (canUseFormApi(form)) {
|
|
54
|
+
form.submit();
|
|
55
|
+
return;
|
|
49
56
|
}
|
|
50
|
-
|
|
51
|
-
return byTestId;
|
|
57
|
+
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);
|
|
52
58
|
}
|
|
53
|
-
function
|
|
54
|
-
var
|
|
55
|
-
var submitButton = findSubmitButton(root);
|
|
56
|
-
var form = formRef.current;
|
|
57
|
-
var hasFields = typeof (form === null || form === void 0 ? void 0 : form.getRegisteredFields) === 'function' && form.getRegisteredFields().length > 0;
|
|
59
|
+
function getSubmitTarget(formRef) {
|
|
60
|
+
var submitButton = findSubmitButton(getMountRoot());
|
|
58
61
|
return {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
form: form,
|
|
62
|
+
canSubmit: Boolean(submitButton) || canUseFormApi(formRef.current),
|
|
63
|
+
form: formRef.current,
|
|
62
64
|
submitButton: submitButton
|
|
63
65
|
};
|
|
64
66
|
}
|
|
65
|
-
function
|
|
67
|
+
function bindSubmitButtonClick(formRef, signal) {
|
|
68
|
+
var root = getMountRoot();
|
|
69
|
+
if (!root) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
var handler = function handler(event) {
|
|
73
|
+
if (signal.aborted) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
var submitButton = findSubmitButton(root);
|
|
77
|
+
if (!submitButton || isSubmitButton(submitButton)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (event.target !== submitButton && !submitButton.contains(event.target)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
triggerFormSubmit({
|
|
85
|
+
form: formRef.current,
|
|
86
|
+
submitButton: submitButton
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
root.addEventListener('click', handler, true);
|
|
90
|
+
return function () {
|
|
91
|
+
root.removeEventListener('click', handler, true);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function autoSubmitForm(_x) {
|
|
66
95
|
return _autoSubmitForm.apply(this, arguments);
|
|
67
96
|
}
|
|
68
97
|
function _autoSubmitForm() {
|
|
69
|
-
_autoSubmitForm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(formRef
|
|
70
|
-
var
|
|
98
|
+
_autoSubmitForm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(formRef) {
|
|
99
|
+
var formSubmitConfig,
|
|
100
|
+
signal,
|
|
101
|
+
didPrepareUnchangedSubmit,
|
|
102
|
+
deadline,
|
|
103
|
+
_getSubmitTarget,
|
|
104
|
+
canSubmit,
|
|
105
|
+
form,
|
|
106
|
+
submitButton,
|
|
107
|
+
_args = arguments;
|
|
71
108
|
return _regenerator().w(function (_context) {
|
|
72
109
|
while (1) switch (_context.n) {
|
|
73
110
|
case 0:
|
|
74
|
-
|
|
111
|
+
formSubmitConfig = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
112
|
+
signal = _args.length > 2 ? _args[2] : undefined;
|
|
75
113
|
didPrepareUnchangedSubmit = false;
|
|
114
|
+
deadline = Date.now() + SUBMIT_TIMEOUT_MS;
|
|
76
115
|
case 1:
|
|
77
|
-
if (!(Date.now() < deadline)) {
|
|
78
|
-
_context.n =
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
if (!signal.aborted) {
|
|
82
|
-
_context.n = 2;
|
|
116
|
+
if (!(Date.now() < deadline && !signal.aborted)) {
|
|
117
|
+
_context.n = 6;
|
|
83
118
|
break;
|
|
84
119
|
}
|
|
85
|
-
|
|
86
|
-
case 2:
|
|
87
|
-
_getFormSubmitTarget = getFormSubmitTarget(formRef), canMarkForm = _getFormSubmitTarget.canMarkForm, canSubmit = _getFormSubmitTarget.canSubmit, form = _getFormSubmitTarget.form, submitButton = _getFormSubmitTarget.submitButton;
|
|
120
|
+
_getSubmitTarget = getSubmitTarget(formRef), canSubmit = _getSubmitTarget.canSubmit, form = _getSubmitTarget.form, submitButton = _getSubmitTarget.submitButton;
|
|
88
121
|
if (canSubmit) {
|
|
89
|
-
_context.n =
|
|
122
|
+
_context.n = 3;
|
|
90
123
|
break;
|
|
91
124
|
}
|
|
92
|
-
_context.n =
|
|
125
|
+
_context.n = 2;
|
|
93
126
|
return sleep();
|
|
94
|
-
case
|
|
127
|
+
case 2:
|
|
95
128
|
return _context.a(3, 1);
|
|
96
|
-
case
|
|
129
|
+
case 3:
|
|
97
130
|
if (!(formSubmitConfig !== null && formSubmitConfig !== void 0 && formSubmitConfig.allowUnchangedSubmit && !didPrepareUnchangedSubmit)) {
|
|
98
|
-
_context.n =
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
if (!canMarkForm) {
|
|
102
|
-
_context.n = 6;
|
|
131
|
+
_context.n = 5;
|
|
103
132
|
break;
|
|
104
133
|
}
|
|
105
134
|
prepareFormForAutoSubmit(form, formSubmitConfig);
|
|
106
135
|
didPrepareUnchangedSubmit = true;
|
|
107
|
-
_context.n =
|
|
136
|
+
_context.n = 4;
|
|
108
137
|
return sleep();
|
|
109
|
-
case
|
|
110
|
-
return _context.a(3, 1);
|
|
111
|
-
case 6:
|
|
112
|
-
_context.n = 7;
|
|
113
|
-
return sleep();
|
|
114
|
-
case 7:
|
|
138
|
+
case 4:
|
|
115
139
|
return _context.a(3, 1);
|
|
116
|
-
case
|
|
117
|
-
|
|
140
|
+
case 5:
|
|
141
|
+
triggerFormSubmit({
|
|
142
|
+
form: form,
|
|
143
|
+
submitButton: submitButton
|
|
144
|
+
});
|
|
118
145
|
return _context.a(2);
|
|
119
|
-
case
|
|
146
|
+
case 6:
|
|
120
147
|
return _context.a(2);
|
|
121
148
|
}
|
|
122
149
|
}, _callee);
|
|
@@ -167,6 +194,8 @@ function withFormRef(children, formRef, bindings) {
|
|
|
167
194
|
|
|
168
195
|
/**
|
|
169
196
|
* Авто-submit для интерактивного Storybook (Require / Validation / ServerError).
|
|
197
|
+
* При primaryButtonHtmlType="button" вызывает formRef.current.submit() (final-form API)
|
|
198
|
+
* и вешает click на кнопку, чтобы ручной submit тоже работал.
|
|
170
199
|
* В Vitest не используется — submit делается в play.
|
|
171
200
|
*/
|
|
172
201
|
function FormSubmitWrapper(props) {
|
|
@@ -181,6 +210,17 @@ function FormSubmitWrapper(props) {
|
|
|
181
210
|
submit = _props$submit === void 0 ? true : _props$submit,
|
|
182
211
|
children = props.children;
|
|
183
212
|
var formSubmitConfig = parameters === null || parameters === void 0 ? void 0 : parameters.formSubmit;
|
|
213
|
+
useEffect(function () {
|
|
214
|
+
if (!submit) {
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
var abortController = new AbortController();
|
|
218
|
+
var unbindClick = bindSubmitButtonClick(formRef, abortController.signal);
|
|
219
|
+
return function () {
|
|
220
|
+
abortController.abort();
|
|
221
|
+
unbindClick === null || unbindClick === void 0 || unbindClick();
|
|
222
|
+
};
|
|
223
|
+
}, [formSubmitConfig, submit]);
|
|
184
224
|
useEffect(function () {
|
|
185
225
|
if (!submit) {
|
|
186
226
|
return undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import { F as FormSubmitWrapper } from '../components/FormSubmitWrapper-
|
|
2
|
+
import { F as FormSubmitWrapper } from '../components/FormSubmitWrapper-YokGjDrh.js';
|
|
3
3
|
import 'lodash/camelCase';
|
|
4
4
|
import '@itcase/common';
|
|
5
5
|
import 'msw';
|
package/dist/decorators.js
CHANGED
|
@@ -8,7 +8,7 @@ export { withUiDecorator } from './decorators/withUiDecorator.js';
|
|
|
8
8
|
import 'react';
|
|
9
9
|
import './components/_rollupPluginBabelHelpers-DQ-fuxJg.js';
|
|
10
10
|
import 'lodash/castArray';
|
|
11
|
-
import './components/FormSubmitWrapper-
|
|
11
|
+
import './components/FormSubmitWrapper-YokGjDrh.js';
|
|
12
12
|
import 'lodash/camelCase';
|
|
13
13
|
import '@itcase/common';
|
|
14
14
|
import 'msw';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itcase/storybook-config",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.71",
|
|
4
4
|
"author": "ITCase",
|
|
5
5
|
"description": "Storybook configuration package",
|
|
6
6
|
"engines": {
|
|
@@ -118,12 +118,12 @@
|
|
|
118
118
|
"http-proxy-middleware": "^4.0.0",
|
|
119
119
|
"msw": "^2.14.6",
|
|
120
120
|
"msw-storybook-addon": "^2.0.7",
|
|
121
|
-
"react-native-gesture-handler": "^
|
|
122
|
-
"react-native-reanimated": "^4.
|
|
121
|
+
"react-native-gesture-handler": "^3.0.0",
|
|
122
|
+
"react-native-reanimated": "^4.4.0",
|
|
123
123
|
"react-native-safe-area-context": "^5.8.0",
|
|
124
124
|
"react-native-svg": "^15.15.5",
|
|
125
125
|
"react-native-web": "^0.21.2",
|
|
126
|
-
"react-native-worklets": "^0.
|
|
126
|
+
"react-native-worklets": "^0.9.1",
|
|
127
127
|
"storybook": "^10.4.1",
|
|
128
128
|
"storybook-addon-source-link": "^2.0.1",
|
|
129
129
|
"vite": "^8.0.14",
|
|
@@ -141,8 +141,8 @@
|
|
|
141
141
|
"@commitlint/config-conventional": "^21.0.1",
|
|
142
142
|
"@itcase/common": "^1.2.43",
|
|
143
143
|
"@itcase/lint": "^1.1.116",
|
|
144
|
-
"@itcase/ui-core": "^1.10.
|
|
145
|
-
"@itcase/ui-web": "^1.10.
|
|
144
|
+
"@itcase/ui-core": "^1.10.8",
|
|
145
|
+
"@itcase/ui-web": "^1.10.8",
|
|
146
146
|
"@react-native-community/cli": "20.1.3",
|
|
147
147
|
"@react-native-community/cli-platform-android": "20.1.3",
|
|
148
148
|
"@react-native-community/cli-platform-ios": "20.1.3",
|
|
@@ -157,8 +157,6 @@
|
|
|
157
157
|
"@storybook/addon-docs": "^10.4.1",
|
|
158
158
|
"@types/react": "^18",
|
|
159
159
|
"@types/react-dom": "^18",
|
|
160
|
-
"react-docgen": "^8.0.3",
|
|
161
|
-
"react-docgen-typescript": "^2.4.0",
|
|
162
160
|
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
|
|
163
161
|
"conventional-changelog-conventionalcommits": "^9.3.1",
|
|
164
162
|
"eslint": "9.39.2",
|
|
@@ -168,6 +166,8 @@
|
|
|
168
166
|
"next": "^16.2.6",
|
|
169
167
|
"prettier": "^3.8.3",
|
|
170
168
|
"react": "^18",
|
|
169
|
+
"react-docgen": "^8.0.3",
|
|
170
|
+
"react-docgen-typescript": "^2.4.0",
|
|
171
171
|
"react-dom": "^18",
|
|
172
172
|
"react-native": "0.85.3",
|
|
173
173
|
"react-native-web": "^0.21.2",
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
177
177
|
"semantic-release": "^25.0.3",
|
|
178
178
|
"stylelint": "^17.12.0",
|
|
179
|
-
"typescript": "^
|
|
179
|
+
"typescript": "^6.0.3",
|
|
180
180
|
"vite": "^8.0.14"
|
|
181
181
|
}
|
|
182
182
|
}
|