@itcase/storybook-config 1.2.74 → 1.2.77
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-_VeLgVir.js +213 -0
- package/dist/cjs/components/EmailTemplatePreview.js +11 -10
- package/dist/cjs/components/FormSubmitWrapper.js +1 -2
- package/dist/cjs/decorators/withClearStoresDecorator.js +18 -7
- package/dist/cjs/decorators/withExtraProviders.js +14 -9
- package/dist/cjs/decorators/withFigmaSourceLink.js +18 -13
- package/dist/cjs/decorators/withFormSubmitDecorator.js +32 -28
- package/dist/cjs/decorators/withLayoutDecorator.js +25 -19
- package/dist/cjs/decorators/withNextDecorator.js +43 -30
- package/dist/cjs/decorators/withUiDecorator.js +12 -7
- package/dist/cjs/decorators.js +2 -2
- package/dist/components/EmailTemplatePreview.js +12 -11
- package/dist/components/FormSubmitWrapper-B2tMQZu2.js +211 -0
- package/dist/components/FormSubmitWrapper.js +1 -2
- package/dist/config/viewport/viewport.js +7 -0
- package/dist/decorators/withClearStoresDecorator.js +19 -8
- package/dist/decorators/withExtraProviders.js +14 -9
- package/dist/decorators/withFigmaSourceLink.js +18 -13
- package/dist/decorators/withFormSubmitDecorator.js +32 -28
- package/dist/decorators/withLayoutDecorator.js +25 -19
- package/dist/decorators/withNextDecorator.js +43 -30
- package/dist/decorators/withUiDecorator.js +12 -7
- package/dist/decorators.js +2 -2
- package/package.json +46 -46
- package/dist/FormSubmitWrapper-BaqE4w9q.js +0 -248
- package/dist/_rollupPluginBabelHelpers-B1r4NF8e.js +0 -264
- package/dist/components/FormSubmitWrapper-DoGZRTm5.js +0 -246
- package/dist/components/_rollupPluginBabelHelpers-CEVa9ZMs.js +0 -258
|
@@ -1,42 +1,53 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
1
|
+
import 'react';
|
|
3
2
|
import { NotificationWrapper } from '@itcase/ui-web/components/Notification';
|
|
4
3
|
import { UIProvider, NotificationsProvider } from '@itcase/ui-core/context';
|
|
4
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
function withNextDecoratorFactory({
|
|
7
|
+
App,
|
|
8
|
+
RootStoreProvider
|
|
9
|
+
}) {
|
|
10
|
+
const decorator = (Story, {
|
|
11
|
+
args,
|
|
12
|
+
parameters,
|
|
13
|
+
context
|
|
14
|
+
}) => {
|
|
15
|
+
const {
|
|
16
|
+
appArgs,
|
|
17
|
+
appContext,
|
|
18
|
+
appParameters
|
|
19
|
+
} = prepareStoryArguments({
|
|
20
|
+
args,
|
|
21
|
+
parameters,
|
|
22
|
+
context
|
|
23
|
+
});
|
|
22
24
|
if (appParameters.page) {
|
|
23
|
-
return /*#__PURE__*/
|
|
25
|
+
return /*#__PURE__*/jsx(App, {
|
|
24
26
|
Component: Story,
|
|
25
27
|
pageProps: appArgs
|
|
26
28
|
});
|
|
27
29
|
}
|
|
28
|
-
return /*#__PURE__*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
return /*#__PURE__*/jsx(RootStoreProvider, {
|
|
31
|
+
...appArgs.rootStoreInitialData,
|
|
32
|
+
children: /*#__PURE__*/jsx(UIProvider, {
|
|
33
|
+
children: /*#__PURE__*/jsxs(NotificationsProvider, {
|
|
34
|
+
initialNotificationsList: parameters.initialNotificationsList || args.initialNotificationsList || [],
|
|
35
|
+
children: [/*#__PURE__*/jsx(NotificationWrapper, {
|
|
36
|
+
className: "notification_global notification_global_right_top"
|
|
37
|
+
}), /*#__PURE__*/jsx(Story, {
|
|
38
|
+
...appContext
|
|
39
|
+
})]
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
});
|
|
33
43
|
};
|
|
34
44
|
return decorator;
|
|
35
45
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
const prepareStoryArguments = ({
|
|
47
|
+
args,
|
|
48
|
+
parameters,
|
|
49
|
+
context
|
|
50
|
+
}) => {
|
|
40
51
|
if (parameters.storeData || parameters.storesData) {
|
|
41
52
|
throw new Error('"withNextDecoratorFactory" error: "parameters.storesData" is deprecated. Set "storesData" to args instead.');
|
|
42
53
|
}
|
|
@@ -46,8 +57,10 @@ var prepareStoryArguments = function prepareStoryArguments(_ref3) {
|
|
|
46
57
|
if (args.rootStoreInitialData) {
|
|
47
58
|
throw new Error('"withNextDecoratorFactory" error: do not user "args.rootStoreInitialData". Use "storesData" argument he passes parameters to rootStoreInitialData.');
|
|
48
59
|
}
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
const {
|
|
61
|
+
storesData,
|
|
62
|
+
...otherArgs
|
|
63
|
+
} = args;
|
|
51
64
|
otherArgs.rootStoreInitialData = storesData;
|
|
52
65
|
return {
|
|
53
66
|
appArgs: otherArgs,
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'react';
|
|
2
2
|
import { NotificationWrapper } from '@itcase/ui-web/components/Notification';
|
|
3
3
|
import { UIProvider, NotificationsProvider } from '@itcase/ui-core/context';
|
|
4
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
5
|
|
|
5
|
-
function withUiDecorator(Story,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
function withUiDecorator(Story, {
|
|
7
|
+
args,
|
|
8
|
+
parameters
|
|
9
|
+
}) {
|
|
10
|
+
return /*#__PURE__*/jsx(UIProvider, {
|
|
11
|
+
children: /*#__PURE__*/jsxs(NotificationsProvider, {
|
|
12
|
+
initialNotificationsList: parameters.initialNotificationsList || args.initialNotificationsList || [],
|
|
13
|
+
children: [/*#__PURE__*/jsx(NotificationWrapper, {}), /*#__PURE__*/jsx(Story, {})]
|
|
14
|
+
})
|
|
15
|
+
});
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
export { withUiDecorator };
|
package/dist/decorators.js
CHANGED
|
@@ -6,9 +6,9 @@ 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 '
|
|
9
|
+
import 'react/jsx-runtime';
|
|
10
10
|
import './components/isArray-CPoGkdXv.js';
|
|
11
|
-
import './components/FormSubmitWrapper-
|
|
11
|
+
import './components/FormSubmitWrapper-B2tMQZu2.js';
|
|
12
12
|
import '@itcase/common';
|
|
13
13
|
import 'msw';
|
|
14
14
|
import 'final-form';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itcase/storybook-config",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.77",
|
|
4
4
|
"author": "ITCase",
|
|
5
5
|
"description": "Storybook configuration package",
|
|
6
6
|
"engines": {
|
|
@@ -89,78 +89,78 @@
|
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
91
|
"@gorhom/bottom-sheet": "^5.2.14",
|
|
92
|
-
"@itcase/config": "^1.6.
|
|
92
|
+
"@itcase/config": "^1.6.61",
|
|
93
93
|
"@itcase/storybook-addon-auth": "^1.0.5",
|
|
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.
|
|
98
|
-
"@storybook/addon-links": "^10.4.
|
|
99
|
-
"@storybook/addon-ondevice-actions": "10.4.
|
|
100
|
-
"@storybook/addon-ondevice-backgrounds": "10.4.
|
|
101
|
-
"@storybook/addon-ondevice-controls": "10.4.
|
|
102
|
-
"@storybook/addon-ondevice-notes": "^10.4.
|
|
97
|
+
"@storybook/addon-docs": "^10.4.6",
|
|
98
|
+
"@storybook/addon-links": "^10.4.6",
|
|
99
|
+
"@storybook/addon-ondevice-actions": "10.4.7",
|
|
100
|
+
"@storybook/addon-ondevice-backgrounds": "10.4.7",
|
|
101
|
+
"@storybook/addon-ondevice-controls": "10.4.7",
|
|
102
|
+
"@storybook/addon-ondevice-notes": "^10.4.7",
|
|
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.
|
|
106
|
-
"@storybook/addon-vitest": "^10.4.
|
|
105
|
+
"@storybook/addon-themes": "^10.4.6",
|
|
106
|
+
"@storybook/addon-vitest": "^10.4.6",
|
|
107
107
|
"@storybook/addon-webpack5-compiler-swc": "^4.0.3",
|
|
108
|
-
"@storybook/builder-vite": "^10.4.
|
|
109
|
-
"@storybook/nextjs": "^10.4.
|
|
110
|
-
"@storybook/nextjs-vite": "^10.4.
|
|
111
|
-
"@storybook/react": "^10.4.
|
|
112
|
-
"@storybook/react-native": "10.4.
|
|
113
|
-
"@storybook/react-native-ui-lite": "10.4.
|
|
114
|
-
"@storybook/react-native-web-vite": "^10.4.
|
|
115
|
-
"@storybook/react-vite": "^10.4.
|
|
116
|
-
"@storybook/react-webpack5": "^10.4.
|
|
108
|
+
"@storybook/builder-vite": "^10.4.6",
|
|
109
|
+
"@storybook/nextjs": "^10.4.6",
|
|
110
|
+
"@storybook/nextjs-vite": "^10.4.6",
|
|
111
|
+
"@storybook/react": "^10.4.6",
|
|
112
|
+
"@storybook/react-native": "10.4.7",
|
|
113
|
+
"@storybook/react-native-ui-lite": "10.4.7",
|
|
114
|
+
"@storybook/react-native-web-vite": "^10.4.6",
|
|
115
|
+
"@storybook/react-vite": "^10.4.6",
|
|
116
|
+
"@storybook/react-webpack5": "^10.4.6",
|
|
117
117
|
"@vitejs/plugin-react": "^6.0.2",
|
|
118
|
-
"@vitest/browser-playwright": "^4.1.
|
|
118
|
+
"@vitest/browser-playwright": "^4.1.9",
|
|
119
119
|
"babel-loader": "^10.1.1",
|
|
120
120
|
"babel-plugin-react-docgen": "^4.2.1",
|
|
121
121
|
"babel-plugin-react-native-web": "^0.21.2",
|
|
122
122
|
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
|
|
123
123
|
"chalk": "^5.6.2",
|
|
124
|
-
"http-proxy-middleware": "^4.
|
|
124
|
+
"http-proxy-middleware": "^4.1.1",
|
|
125
125
|
"msw": "^2.14.6",
|
|
126
126
|
"msw-storybook-addon": "^2.0.7",
|
|
127
|
-
"react-native-gesture-handler": "^3.0.
|
|
128
|
-
"react-native-reanimated": "^4.4.
|
|
127
|
+
"react-native-gesture-handler": "^3.0.2",
|
|
128
|
+
"react-native-reanimated": "^4.4.1",
|
|
129
129
|
"react-native-safe-area-context": "^5.8.0",
|
|
130
130
|
"react-native-svg": "^15.15.5",
|
|
131
131
|
"react-native-web": "^0.21.2",
|
|
132
|
-
"react-native-worklets": "^0.9.
|
|
133
|
-
"storybook": "^10.4.
|
|
132
|
+
"react-native-worklets": "^0.9.2",
|
|
133
|
+
"storybook": "^10.4.6",
|
|
134
134
|
"storybook-addon-source-link": "^2.0.1",
|
|
135
135
|
"vite": "^8.0.16",
|
|
136
136
|
"vite-plugin-babel": "^1.7.3",
|
|
137
137
|
"vite-plugin-svgr": "^5.2.0",
|
|
138
138
|
"vite-tsconfig-paths": "^6.1.1",
|
|
139
|
-
"vitest": "^4.1.
|
|
139
|
+
"vitest": "^4.1.9"
|
|
140
140
|
},
|
|
141
141
|
"devDependencies": {
|
|
142
|
-
"@babel/core": "^
|
|
143
|
-
"@babel/preset-env": "^
|
|
144
|
-
"@babel/preset-react": "^
|
|
145
|
-
"@babel/runtime": "^
|
|
142
|
+
"@babel/core": "^8.0.1",
|
|
143
|
+
"@babel/preset-env": "^8.0.2",
|
|
144
|
+
"@babel/preset-react": "^8.0.1",
|
|
145
|
+
"@babel/runtime": "^8.0.0",
|
|
146
146
|
"@commitlint/cli": "^21.0.2",
|
|
147
147
|
"@commitlint/config-conventional": "^21.0.2",
|
|
148
|
-
"@itcase/common": "^1.2.
|
|
149
|
-
"@itcase/lint": "^1.1.
|
|
150
|
-
"@itcase/ui-core": "^1.10.
|
|
151
|
-
"@itcase/ui-web": "^1.10.
|
|
148
|
+
"@itcase/common": "^1.2.46",
|
|
149
|
+
"@itcase/lint": "^1.1.117",
|
|
150
|
+
"@itcase/ui-core": "^1.10.37",
|
|
151
|
+
"@itcase/ui-web": "^1.10.40",
|
|
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",
|
|
155
|
-
"@react-native/babel-preset": "0.
|
|
156
|
-
"@react-native/eslint-config": "0.
|
|
157
|
-
"@react-native/metro-config": "0.
|
|
158
|
-
"@react-native/typescript-config": "0.
|
|
155
|
+
"@react-native/babel-preset": "0.86.0",
|
|
156
|
+
"@react-native/eslint-config": "0.86.0",
|
|
157
|
+
"@react-native/metro-config": "0.86.0",
|
|
158
|
+
"@react-native/typescript-config": "0.86.0",
|
|
159
159
|
"@rollup/plugin-babel": "^7.1.0",
|
|
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.
|
|
163
|
+
"@storybook/addon-docs": "^10.4.6",
|
|
164
164
|
"@types/react": "^18",
|
|
165
165
|
"@types/react-dom": "^18",
|
|
166
166
|
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
|
|
@@ -168,20 +168,20 @@
|
|
|
168
168
|
"eslint": "9.39.2",
|
|
169
169
|
"glob": "^13.0.6",
|
|
170
170
|
"husky": "^9.1.7",
|
|
171
|
-
"lint-staged": "^17.0.
|
|
172
|
-
"next": "^16.2.
|
|
173
|
-
"prettier": "^3.8.
|
|
171
|
+
"lint-staged": "^17.0.8",
|
|
172
|
+
"next": "^16.2.9",
|
|
173
|
+
"prettier": "^3.8.4",
|
|
174
174
|
"react": "^18",
|
|
175
175
|
"react-docgen": "^8.0.3",
|
|
176
176
|
"react-docgen-typescript": "^2.4.0",
|
|
177
177
|
"react-dom": "^18",
|
|
178
|
-
"react-native": "0.
|
|
178
|
+
"react-native": "0.86.0",
|
|
179
179
|
"react-native-web": "^0.21.2",
|
|
180
|
-
"rollup": "^4.
|
|
180
|
+
"rollup": "^4.62.2",
|
|
181
181
|
"rollup-plugin-copy": "^3.5.0",
|
|
182
182
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
183
|
-
"semantic-release": "^25.0.
|
|
184
|
-
"stylelint": "^17.
|
|
183
|
+
"semantic-release": "^25.0.5",
|
|
184
|
+
"stylelint": "^17.13.0",
|
|
185
185
|
"typescript": "^6.0.3",
|
|
186
186
|
"vite": "^8.0.16"
|
|
187
187
|
}
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-B1r4NF8e.js');
|
|
4
|
-
var React = require('react');
|
|
5
|
-
|
|
6
|
-
var SUBMIT_POLL_MS = 50;
|
|
7
|
-
function getStoryPreviewDocument() {
|
|
8
|
-
var _document$getElementB, _previewIframe$conten;
|
|
9
|
-
var previewIframe = (_document$getElementB = document.getElementById('storybook-preview-iframe')) !== null && _document$getElementB !== void 0 ? _document$getElementB : document.querySelector('iframe[data-is-storybook="true"]');
|
|
10
|
-
return (_previewIframe$conten = previewIframe === null || previewIframe === void 0 ? void 0 : previewIframe.contentDocument) !== null && _previewIframe$conten !== void 0 ? _previewIframe$conten : null;
|
|
11
|
-
}
|
|
12
|
-
function getMountRoot() {
|
|
13
|
-
var _ref2, _document$getElementB2;
|
|
14
|
-
var previewDocument = getStoryPreviewDocument();
|
|
15
|
-
if (previewDocument) {
|
|
16
|
-
var _ref, _previewDocument$getE;
|
|
17
|
-
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;
|
|
18
|
-
}
|
|
19
|
-
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;
|
|
20
|
-
}
|
|
21
|
-
function canSubmitFormApi(form) {
|
|
22
|
-
return typeof (form === null || form === void 0 ? void 0 : form.submit) === 'function' && typeof form.getRegisteredFields === 'function' && form.getRegisteredFields().length > 0;
|
|
23
|
-
}
|
|
24
|
-
function findSaveDraftButton(root) {
|
|
25
|
-
if (!root) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
var saveDraft = root.querySelector('[data-testid$="SaveDraftButton"]');
|
|
29
|
-
if (!saveDraft) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
return saveDraft.tagName === 'BUTTON' ? saveDraft : saveDraft.querySelector('button');
|
|
33
|
-
}
|
|
34
|
-
function findSubmitButton(root) {
|
|
35
|
-
var _form$querySelector;
|
|
36
|
-
if (!root) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
var byType = root.querySelector('button[type="submit"]');
|
|
40
|
-
if (byType) {
|
|
41
|
-
return byType;
|
|
42
|
-
}
|
|
43
|
-
var form = root.querySelector('form[data-testid], form');
|
|
44
|
-
if (!form) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
return (_form$querySelector = form.querySelector('.form__button .form__button-item, .form__button-item')) !== null && _form$querySelector !== void 0 ? _form$querySelector : null;
|
|
48
|
-
}
|
|
49
|
-
function touchFieldsBeforeSubmit(form) {
|
|
50
|
-
if (!canSubmitFormApi(form)) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
var _iterator = _rollupPluginBabelHelpers._createForOfIteratorHelper(form.getRegisteredFields()),
|
|
54
|
-
_step;
|
|
55
|
-
try {
|
|
56
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
57
|
-
var _form$getFieldState;
|
|
58
|
-
var fieldName = _step.value;
|
|
59
|
-
if (!((_form$getFieldState = form.getFieldState(fieldName)) !== null && _form$getFieldState !== void 0 && _form$getFieldState.touched)) {
|
|
60
|
-
form.blur(fieldName);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
} catch (err) {
|
|
64
|
-
_iterator.e(err);
|
|
65
|
-
} finally {
|
|
66
|
-
_iterator.f();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
function triggerFormSubmit(_ref3) {
|
|
70
|
-
var form = _ref3.form,
|
|
71
|
-
root = _ref3.root,
|
|
72
|
-
submitButton = _ref3.submitButton;
|
|
73
|
-
var saveDraftButton = findSaveDraftButton(root !== null && root !== void 0 ? root : getMountRoot());
|
|
74
|
-
if (saveDraftButton) {
|
|
75
|
-
saveDraftButton.click();
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (canSubmitFormApi(form)) {
|
|
79
|
-
touchFieldsBeforeSubmit(form);
|
|
80
|
-
form.submit();
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
if ((submitButton === null || submitButton === void 0 ? void 0 : submitButton.type) === 'submit') {
|
|
84
|
-
submitButton.click();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function autoSubmitForm(_x, _x2) {
|
|
88
|
-
return _autoSubmitForm.apply(this, arguments);
|
|
89
|
-
}
|
|
90
|
-
function _autoSubmitForm() {
|
|
91
|
-
_autoSubmitForm = _rollupPluginBabelHelpers._asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers._regenerator().m(function _callee(formRef, signal) {
|
|
92
|
-
var root, form, submitButton, saveDraftButton, canSubmitViaFormApi, canClickNativeSubmit, canClickSaveDraft;
|
|
93
|
-
return _rollupPluginBabelHelpers._regenerator().w(function (_context) {
|
|
94
|
-
while (1) switch (_context.n) {
|
|
95
|
-
case 0:
|
|
96
|
-
if (!formRef.__itcaseDidAutoSubmit) {
|
|
97
|
-
_context.n = 1;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
return _context.a(2);
|
|
101
|
-
case 1:
|
|
102
|
-
if (signal.aborted) {
|
|
103
|
-
_context.n = 6;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
root = getMountRoot();
|
|
107
|
-
form = formRef.current;
|
|
108
|
-
submitButton = findSubmitButton(root);
|
|
109
|
-
saveDraftButton = findSaveDraftButton(root);
|
|
110
|
-
canSubmitViaFormApi = canSubmitFormApi(form);
|
|
111
|
-
canClickNativeSubmit = (submitButton === null || submitButton === void 0 ? void 0 : submitButton.type) === 'submit';
|
|
112
|
-
canClickSaveDraft = Boolean(saveDraftButton); // primaryButtonHtmlType="button": ждём final-form API или кнопку черновика в DOM
|
|
113
|
-
if (!(!canSubmitViaFormApi && !canClickNativeSubmit && !canClickSaveDraft)) {
|
|
114
|
-
_context.n = 3;
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
_context.n = 2;
|
|
118
|
-
return new Promise(function (resolve) {
|
|
119
|
-
setTimeout(resolve, SUBMIT_POLL_MS);
|
|
120
|
-
});
|
|
121
|
-
case 2:
|
|
122
|
-
return _context.a(3, 1);
|
|
123
|
-
case 3:
|
|
124
|
-
formRef.__itcaseDidAutoSubmit = true;
|
|
125
|
-
_context.n = 4;
|
|
126
|
-
return new Promise(function (resolve) {
|
|
127
|
-
requestAnimationFrame(function () {
|
|
128
|
-
requestAnimationFrame(resolve);
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
case 4:
|
|
132
|
-
if (!signal.aborted) {
|
|
133
|
-
_context.n = 5;
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
return _context.a(2);
|
|
137
|
-
case 5:
|
|
138
|
-
triggerFormSubmit({
|
|
139
|
-
form: formRef.current,
|
|
140
|
-
root: root,
|
|
141
|
-
submitButton: submitButton
|
|
142
|
-
});
|
|
143
|
-
return _context.a(2);
|
|
144
|
-
case 6:
|
|
145
|
-
return _context.a(2);
|
|
146
|
-
}
|
|
147
|
-
}, _callee);
|
|
148
|
-
}));
|
|
149
|
-
return _autoSubmitForm.apply(this, arguments);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function wrapRender(component, render, formRef) {
|
|
153
|
-
var defaultArgs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
154
|
-
if (typeof render !== 'function') {
|
|
155
|
-
return render;
|
|
156
|
-
}
|
|
157
|
-
return function renderWithRef(storyArgs) {
|
|
158
|
-
var args = _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, defaultArgs), storyArgs !== null && storyArgs !== void 0 ? storyArgs : {});
|
|
159
|
-
delete args.ref;
|
|
160
|
-
delete args.errors;
|
|
161
|
-
if (!args.onSubmit && defaultArgs.onSubmit) {
|
|
162
|
-
args.onSubmit = defaultArgs.onSubmit;
|
|
163
|
-
}
|
|
164
|
-
var rendered = render(args);
|
|
165
|
-
if (/*#__PURE__*/React.isValidElement(rendered)) {
|
|
166
|
-
return /*#__PURE__*/React.cloneElement(rendered, _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, rendered.props), args), {}, {
|
|
167
|
-
ref: formRef
|
|
168
|
-
}));
|
|
169
|
-
}
|
|
170
|
-
if (component) {
|
|
171
|
-
return /*#__PURE__*/React.createElement(component, _rollupPluginBabelHelpers._objectSpread2({
|
|
172
|
-
ref: formRef
|
|
173
|
-
}, args));
|
|
174
|
-
}
|
|
175
|
-
return rendered;
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
function withFormRef(children, formRef, bindings) {
|
|
179
|
-
var _ref, _ref2, _children$props, _ref3, _children$props2, _ref4, _children$props3;
|
|
180
|
-
var component = bindings.component,
|
|
181
|
-
args = bindings.args,
|
|
182
|
-
storyRender = bindings.render,
|
|
183
|
-
allArgs = bindings.allArgs,
|
|
184
|
-
context = bindings.context;
|
|
185
|
-
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 : {};
|
|
186
|
-
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;
|
|
187
|
-
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;
|
|
188
|
-
var boundRender = wrapRender(storyComponent, storyRenderFn, formRef, storyArgs);
|
|
189
|
-
var addRef = function addRef(value) {
|
|
190
|
-
return value ? _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, value), {}, {
|
|
191
|
-
ref: formRef
|
|
192
|
-
}) : value;
|
|
193
|
-
};
|
|
194
|
-
return /*#__PURE__*/React.cloneElement(children, {
|
|
195
|
-
component: storyComponent,
|
|
196
|
-
args: addRef(storyArgs),
|
|
197
|
-
render: boundRender,
|
|
198
|
-
allArgs: addRef(allArgs),
|
|
199
|
-
context: context ? _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, context), {}, {
|
|
200
|
-
component: storyComponent,
|
|
201
|
-
args: addRef(context.args),
|
|
202
|
-
render: boundRender,
|
|
203
|
-
allArgs: addRef(context.allArgs)
|
|
204
|
-
}) : context
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Авто-submit для интерактивного Storybook (Require / Validation / ServerError).
|
|
210
|
-
* При primaryButtonHtmlType="button" — formRef.current.submit() (final-form API),
|
|
211
|
-
* при type="submit" — click по кнопке. В Vitest submit в play.
|
|
212
|
-
*/
|
|
213
|
-
function FormSubmitWrapper(props) {
|
|
214
|
-
var _ref5, _ref6, _children$props4;
|
|
215
|
-
var formRef = React.useRef(null);
|
|
216
|
-
var component = props.component,
|
|
217
|
-
args = props.args,
|
|
218
|
-
render = props.render,
|
|
219
|
-
allArgs = props.allArgs,
|
|
220
|
-
context = props.context,
|
|
221
|
-
_props$submit = props.submit,
|
|
222
|
-
submit = _props$submit === void 0 ? true : _props$submit,
|
|
223
|
-
children = props.children;
|
|
224
|
-
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 : {};
|
|
225
|
-
React.useEffect(function () {
|
|
226
|
-
if (!submit) {
|
|
227
|
-
return undefined;
|
|
228
|
-
}
|
|
229
|
-
delete formRef.__itcaseDidAutoSubmit;
|
|
230
|
-
var abortController = new AbortController();
|
|
231
|
-
autoSubmitForm(formRef, abortController.signal);
|
|
232
|
-
return function () {
|
|
233
|
-
abortController.abort();
|
|
234
|
-
delete formRef.__itcaseDidAutoSubmit;
|
|
235
|
-
};
|
|
236
|
-
}, [submit, storyArgs.errors]);
|
|
237
|
-
|
|
238
|
-
// eslint-disable-next-line react-hooks/refs -- ref уходит в cloneElement внутри bound render
|
|
239
|
-
return withFormRef(children, formRef, {
|
|
240
|
-
component: component,
|
|
241
|
-
args: storyArgs,
|
|
242
|
-
render: render,
|
|
243
|
-
allArgs: allArgs,
|
|
244
|
-
context: context
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
exports.FormSubmitWrapper = FormSubmitWrapper;
|