@itcase/storybook-config 1.2.73 → 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.
- package/dist/{FormSubmitWrapper-kEv1DMjn.js → FormSubmitWrapper-BaqE4w9q.js} +16 -64
- 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-obAauTlP.js → FormSubmitWrapper-DoGZRTm5.js} +16 -64
- package/dist/components/FormSubmitWrapper.js +1 -1
- package/dist/decorators/withFormSubmitDecorator.js +1 -1
- package/dist/decorators.js +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-B1r4NF8e.js');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
|
|
6
|
-
var SUBMIT_TIMEOUT_MS = 15000;
|
|
7
6
|
var SUBMIT_POLL_MS = 50;
|
|
8
7
|
function getStoryPreviewDocument() {
|
|
9
8
|
var _document$getElementB, _previewIframe$conten;
|
|
@@ -67,41 +66,6 @@ function touchFieldsBeforeSubmit(form) {
|
|
|
67
66
|
_iterator.f();
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
|
-
function hasModifiedFields(form) {
|
|
71
|
-
return Object.values(form.getState().modified).some(Boolean);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** Filled edit-формы (#1167): без modified submit не уходит — для story auto-submit. */
|
|
75
|
-
function ensureFormModifiedForStorybookSubmit(form) {
|
|
76
|
-
if (!canSubmitFormApi(form) || hasModifiedFields(form)) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
var _form$getState = form.getState(),
|
|
80
|
-
values = _form$getState.values;
|
|
81
|
-
var _iterator2 = _rollupPluginBabelHelpers._createForOfIteratorHelper(form.getRegisteredFields()),
|
|
82
|
-
_step2;
|
|
83
|
-
try {
|
|
84
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
85
|
-
var fieldName = _step2.value;
|
|
86
|
-
var value = values[fieldName];
|
|
87
|
-
if (typeof value === 'string' && value.length > 0) {
|
|
88
|
-
form.change(fieldName, "".concat(value, "x"));
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
} catch (err) {
|
|
93
|
-
_iterator2.e(err);
|
|
94
|
-
} finally {
|
|
95
|
-
_iterator2.f();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function clickSubmitButton(submitButton) {
|
|
99
|
-
if (!submitButton) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
var nativeButton = submitButton.tagName === 'BUTTON' ? submitButton : submitButton.querySelector('button');
|
|
103
|
-
(nativeButton !== null && nativeButton !== void 0 ? nativeButton : submitButton).click();
|
|
104
|
-
}
|
|
105
69
|
function triggerFormSubmit(_ref3) {
|
|
106
70
|
var form = _ref3.form,
|
|
107
71
|
root = _ref3.root,
|
|
@@ -112,19 +76,20 @@ function triggerFormSubmit(_ref3) {
|
|
|
112
76
|
return;
|
|
113
77
|
}
|
|
114
78
|
if (canSubmitFormApi(form)) {
|
|
115
|
-
ensureFormModifiedForStorybookSubmit(form);
|
|
116
79
|
touchFieldsBeforeSubmit(form);
|
|
117
80
|
form.submit();
|
|
118
81
|
return;
|
|
119
82
|
}
|
|
120
|
-
|
|
83
|
+
if ((submitButton === null || submitButton === void 0 ? void 0 : submitButton.type) === 'submit') {
|
|
84
|
+
submitButton.click();
|
|
85
|
+
}
|
|
121
86
|
}
|
|
122
87
|
function autoSubmitForm(_x, _x2) {
|
|
123
88
|
return _autoSubmitForm.apply(this, arguments);
|
|
124
89
|
}
|
|
125
90
|
function _autoSubmitForm() {
|
|
126
91
|
_autoSubmitForm = _rollupPluginBabelHelpers._asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers._regenerator().m(function _callee(formRef, signal) {
|
|
127
|
-
var
|
|
92
|
+
var root, form, submitButton, saveDraftButton, canSubmitViaFormApi, canClickNativeSubmit, canClickSaveDraft;
|
|
128
93
|
return _rollupPluginBabelHelpers._regenerator().w(function (_context) {
|
|
129
94
|
while (1) switch (_context.n) {
|
|
130
95
|
case 0:
|
|
@@ -134,10 +99,8 @@ function _autoSubmitForm() {
|
|
|
134
99
|
}
|
|
135
100
|
return _context.a(2);
|
|
136
101
|
case 1:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (!(Date.now() < deadline && !signal.aborted)) {
|
|
140
|
-
_context.n = 9;
|
|
102
|
+
if (signal.aborted) {
|
|
103
|
+
_context.n = 6;
|
|
141
104
|
break;
|
|
142
105
|
}
|
|
143
106
|
root = getMountRoot();
|
|
@@ -145,51 +108,40 @@ function _autoSubmitForm() {
|
|
|
145
108
|
submitButton = findSubmitButton(root);
|
|
146
109
|
saveDraftButton = findSaveDraftButton(root);
|
|
147
110
|
canSubmitViaFormApi = canSubmitFormApi(form);
|
|
148
|
-
canClickNativeSubmit =
|
|
111
|
+
canClickNativeSubmit = (submitButton === null || submitButton === void 0 ? void 0 : submitButton.type) === 'submit';
|
|
149
112
|
canClickSaveDraft = Boolean(saveDraftButton); // primaryButtonHtmlType="button": ждём final-form API или кнопку черновика в DOM
|
|
150
113
|
if (!(!canSubmitViaFormApi && !canClickNativeSubmit && !canClickSaveDraft)) {
|
|
151
|
-
_context.n =
|
|
114
|
+
_context.n = 3;
|
|
152
115
|
break;
|
|
153
116
|
}
|
|
154
|
-
_context.n =
|
|
117
|
+
_context.n = 2;
|
|
155
118
|
return new Promise(function (resolve) {
|
|
156
119
|
setTimeout(resolve, SUBMIT_POLL_MS);
|
|
157
120
|
});
|
|
121
|
+
case 2:
|
|
122
|
+
return _context.a(3, 1);
|
|
158
123
|
case 3:
|
|
159
|
-
return _context.a(3, 2);
|
|
160
|
-
case 4:
|
|
161
|
-
if (!(!canSubmitViaFormApi && canClickNativeSubmit && !canClickSaveDraft)) {
|
|
162
|
-
_context.n = 6;
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
_context.n = 5;
|
|
166
|
-
return new Promise(function (resolve) {
|
|
167
|
-
setTimeout(resolve, SUBMIT_POLL_MS);
|
|
168
|
-
});
|
|
169
|
-
case 5:
|
|
170
|
-
return _context.a(3, 2);
|
|
171
|
-
case 6:
|
|
172
124
|
formRef.__itcaseDidAutoSubmit = true;
|
|
173
|
-
_context.n =
|
|
125
|
+
_context.n = 4;
|
|
174
126
|
return new Promise(function (resolve) {
|
|
175
127
|
requestAnimationFrame(function () {
|
|
176
128
|
requestAnimationFrame(resolve);
|
|
177
129
|
});
|
|
178
130
|
});
|
|
179
|
-
case
|
|
131
|
+
case 4:
|
|
180
132
|
if (!signal.aborted) {
|
|
181
|
-
_context.n =
|
|
133
|
+
_context.n = 5;
|
|
182
134
|
break;
|
|
183
135
|
}
|
|
184
136
|
return _context.a(2);
|
|
185
|
-
case
|
|
137
|
+
case 5:
|
|
186
138
|
triggerFormSubmit({
|
|
187
139
|
form: formRef.current,
|
|
188
140
|
root: root,
|
|
189
141
|
submitButton: submitButton
|
|
190
142
|
});
|
|
191
143
|
return _context.a(2);
|
|
192
|
-
case
|
|
144
|
+
case 6:
|
|
193
145
|
return _context.a(2);
|
|
194
146
|
}
|
|
195
147
|
}, _callee);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _rollupPluginBabelHelpers = require('../../_rollupPluginBabelHelpers-B1r4NF8e.js');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
var FormSubmitWrapper = require('../../FormSubmitWrapper-
|
|
5
|
+
var FormSubmitWrapper = require('../../FormSubmitWrapper-BaqE4w9q.js');
|
|
6
6
|
var isArray = require('../../isArray-DJguRq_2.js');
|
|
7
7
|
require('@itcase/common');
|
|
8
8
|
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-B1r4NF8e.js');
|
|
12
12
|
require('../isArray-DJguRq_2.js');
|
|
13
|
-
require('../FormSubmitWrapper-
|
|
13
|
+
require('../FormSubmitWrapper-BaqE4w9q.js');
|
|
14
14
|
require('@itcase/common');
|
|
15
15
|
require('msw');
|
|
16
16
|
require('final-form');
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { a as _asyncToGenerator, b as _regenerator, c as _createForOfIteratorHelper, d as _objectSpread2 } from './_rollupPluginBabelHelpers-CEVa9ZMs.js';
|
|
2
2
|
import React, { useRef, useEffect } from 'react';
|
|
3
3
|
|
|
4
|
-
var SUBMIT_TIMEOUT_MS = 15000;
|
|
5
4
|
var SUBMIT_POLL_MS = 50;
|
|
6
5
|
function getStoryPreviewDocument() {
|
|
7
6
|
var _document$getElementB, _previewIframe$conten;
|
|
@@ -65,41 +64,6 @@ function touchFieldsBeforeSubmit(form) {
|
|
|
65
64
|
_iterator.f();
|
|
66
65
|
}
|
|
67
66
|
}
|
|
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
67
|
function triggerFormSubmit(_ref3) {
|
|
104
68
|
var form = _ref3.form,
|
|
105
69
|
root = _ref3.root,
|
|
@@ -110,19 +74,20 @@ function triggerFormSubmit(_ref3) {
|
|
|
110
74
|
return;
|
|
111
75
|
}
|
|
112
76
|
if (canSubmitFormApi(form)) {
|
|
113
|
-
ensureFormModifiedForStorybookSubmit(form);
|
|
114
77
|
touchFieldsBeforeSubmit(form);
|
|
115
78
|
form.submit();
|
|
116
79
|
return;
|
|
117
80
|
}
|
|
118
|
-
|
|
81
|
+
if ((submitButton === null || submitButton === void 0 ? void 0 : submitButton.type) === 'submit') {
|
|
82
|
+
submitButton.click();
|
|
83
|
+
}
|
|
119
84
|
}
|
|
120
85
|
function autoSubmitForm(_x, _x2) {
|
|
121
86
|
return _autoSubmitForm.apply(this, arguments);
|
|
122
87
|
}
|
|
123
88
|
function _autoSubmitForm() {
|
|
124
89
|
_autoSubmitForm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(formRef, signal) {
|
|
125
|
-
var
|
|
90
|
+
var root, form, submitButton, saveDraftButton, canSubmitViaFormApi, canClickNativeSubmit, canClickSaveDraft;
|
|
126
91
|
return _regenerator().w(function (_context) {
|
|
127
92
|
while (1) switch (_context.n) {
|
|
128
93
|
case 0:
|
|
@@ -132,10 +97,8 @@ function _autoSubmitForm() {
|
|
|
132
97
|
}
|
|
133
98
|
return _context.a(2);
|
|
134
99
|
case 1:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (!(Date.now() < deadline && !signal.aborted)) {
|
|
138
|
-
_context.n = 9;
|
|
100
|
+
if (signal.aborted) {
|
|
101
|
+
_context.n = 6;
|
|
139
102
|
break;
|
|
140
103
|
}
|
|
141
104
|
root = getMountRoot();
|
|
@@ -143,51 +106,40 @@ function _autoSubmitForm() {
|
|
|
143
106
|
submitButton = findSubmitButton(root);
|
|
144
107
|
saveDraftButton = findSaveDraftButton(root);
|
|
145
108
|
canSubmitViaFormApi = canSubmitFormApi(form);
|
|
146
|
-
canClickNativeSubmit =
|
|
109
|
+
canClickNativeSubmit = (submitButton === null || submitButton === void 0 ? void 0 : submitButton.type) === 'submit';
|
|
147
110
|
canClickSaveDraft = Boolean(saveDraftButton); // primaryButtonHtmlType="button": ждём final-form API или кнопку черновика в DOM
|
|
148
111
|
if (!(!canSubmitViaFormApi && !canClickNativeSubmit && !canClickSaveDraft)) {
|
|
149
|
-
_context.n =
|
|
112
|
+
_context.n = 3;
|
|
150
113
|
break;
|
|
151
114
|
}
|
|
152
|
-
_context.n =
|
|
115
|
+
_context.n = 2;
|
|
153
116
|
return new Promise(function (resolve) {
|
|
154
117
|
setTimeout(resolve, SUBMIT_POLL_MS);
|
|
155
118
|
});
|
|
119
|
+
case 2:
|
|
120
|
+
return _context.a(3, 1);
|
|
156
121
|
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
122
|
formRef.__itcaseDidAutoSubmit = true;
|
|
171
|
-
_context.n =
|
|
123
|
+
_context.n = 4;
|
|
172
124
|
return new Promise(function (resolve) {
|
|
173
125
|
requestAnimationFrame(function () {
|
|
174
126
|
requestAnimationFrame(resolve);
|
|
175
127
|
});
|
|
176
128
|
});
|
|
177
|
-
case
|
|
129
|
+
case 4:
|
|
178
130
|
if (!signal.aborted) {
|
|
179
|
-
_context.n =
|
|
131
|
+
_context.n = 5;
|
|
180
132
|
break;
|
|
181
133
|
}
|
|
182
134
|
return _context.a(2);
|
|
183
|
-
case
|
|
135
|
+
case 5:
|
|
184
136
|
triggerFormSubmit({
|
|
185
137
|
form: formRef.current,
|
|
186
138
|
root: root,
|
|
187
139
|
submitButton: submitButton
|
|
188
140
|
});
|
|
189
141
|
return _context.a(2);
|
|
190
|
-
case
|
|
142
|
+
case 6:
|
|
191
143
|
return _context.a(2);
|
|
192
144
|
}
|
|
193
145
|
}, _callee);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { d as _objectSpread2 } from '../components/_rollupPluginBabelHelpers-CEVa9ZMs.js';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { F as FormSubmitWrapper } from '../components/FormSubmitWrapper-
|
|
3
|
+
import { F as FormSubmitWrapper } from '../components/FormSubmitWrapper-DoGZRTm5.js';
|
|
4
4
|
import { c as commonjsGlobal, r as requireIsArray } from '../components/isArray-CPoGkdXv.js';
|
|
5
5
|
import '@itcase/common';
|
|
6
6
|
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-CEVa9ZMs.js';
|
|
10
10
|
import './components/isArray-CPoGkdXv.js';
|
|
11
|
-
import './components/FormSubmitWrapper-
|
|
11
|
+
import './components/FormSubmitWrapper-DoGZRTm5.js';
|
|
12
12
|
import '@itcase/common';
|
|
13
13
|
import 'msw';
|
|
14
14
|
import 'final-form';
|