@itcase/storybook-config 1.2.71 → 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.
- package/README.md +9 -0
- package/dist/FormSubmitWrapper-kEv1DMjn.js +296 -0
- package/dist/{_rollupPluginBabelHelpers-D8XyM9rZ.js → _rollupPluginBabelHelpers-B1r4NF8e.js} +61 -0
- package/dist/cjs/components/FormSubmitWrapper.js +2 -2
- package/dist/cjs/decorators/withFigmaSourceLink.js +59 -3
- package/dist/cjs/decorators/withFormSubmitDecorator.js +1128 -6
- package/dist/cjs/decorators/withNextDecorator.js +7 -12
- package/dist/cjs/decorators/withUiDecorator.js +4 -9
- package/dist/cjs/decorators.js +6 -8
- package/dist/components/EmailTemplatePreview.js +2 -2
- package/dist/components/FormSubmitWrapper-obAauTlP.js +294 -0
- package/dist/components/FormSubmitWrapper.js +2 -2
- package/dist/components/{_rollupPluginBabelHelpers-DQ-fuxJg.js → _rollupPluginBabelHelpers-CEVa9ZMs.js} +61 -1
- package/dist/components/isArray-CPoGkdXv.js +43 -0
- package/dist/config/sourceLink/sourceLink.js +8 -16
- package/dist/decorators/withClearStoresDecorator.js +2 -2
- package/dist/decorators/withExtraProviders.js +2 -2
- package/dist/decorators/withFigmaSourceLink.js +61 -5
- package/dist/decorators/withFormSubmitDecorator.js +1131 -9
- package/dist/decorators/withLayoutDecorator.js +9 -9
- package/dist/decorators/withNextDecorator.js +8 -13
- package/dist/decorators/withUiDecorator.js +5 -10
- package/dist/decorators.js +6 -8
- package/dist/isArray-DJguRq_2.js +47 -0
- package/dist/utils/handleMSWParameters.js +20 -8
- package/dist/utils/index.js +2 -0
- package/dist/utils/storybookServerErrorOnSubmit.js +21 -0
- package/package.json +35 -29
- package/dist/FormSubmitWrapper-DXUEGLuS.js +0 -247
- package/dist/Notification-Cqx2_tCE.js +0 -7945
- package/dist/components/FormSubmitWrapper-YokGjDrh.js +0 -245
- package/dist/components/Notification-qLYjGbKN.js +0 -7923
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
3
|
function withLayoutDecorator() {
|
|
4
4
|
return function (Story, _ref) {
|
|
@@ -22,23 +22,23 @@ function withLayoutDecorator() {
|
|
|
22
22
|
maxWidth: parameters === null || parameters === void 0 ? void 0 : parameters.maxWidth
|
|
23
23
|
};
|
|
24
24
|
if (!layoutClass && parameters.maxWidth) {
|
|
25
|
-
return /*#__PURE__*/
|
|
25
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
26
26
|
style: maxWidthStyle
|
|
27
|
-
}, /*#__PURE__*/
|
|
27
|
+
}, /*#__PURE__*/React.createElement(Story, null));
|
|
28
28
|
}
|
|
29
29
|
if (layoutClass && !parameters.maxWidth) {
|
|
30
|
-
return /*#__PURE__*/
|
|
30
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
31
31
|
className: layoutClass
|
|
32
|
-
}, /*#__PURE__*/
|
|
32
|
+
}, /*#__PURE__*/React.createElement(Story, null));
|
|
33
33
|
}
|
|
34
34
|
if (layoutClass && parameters.maxWidth) {
|
|
35
|
-
return /*#__PURE__*/
|
|
35
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
36
36
|
className: layoutClass
|
|
37
|
-
}, /*#__PURE__*/
|
|
37
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
38
38
|
style: maxWidthStyle
|
|
39
|
-
}, /*#__PURE__*/
|
|
39
|
+
}, /*#__PURE__*/React.createElement(Story, null)));
|
|
40
40
|
}
|
|
41
|
-
return /*#__PURE__*/
|
|
41
|
+
return /*#__PURE__*/React.createElement(Story, null);
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import '@itcase/
|
|
5
|
-
import 'lodash/camelCase';
|
|
6
|
-
import 'lodash/castArray';
|
|
7
|
-
import 'lodash/upperFirst';
|
|
8
|
-
import 'lodash/maxBy';
|
|
9
|
-
import 'react-dom';
|
|
1
|
+
import { _ as _objectWithoutProperties } from '../components/_rollupPluginBabelHelpers-CEVa9ZMs.js';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { NotificationWrapper } from '@itcase/ui-web/components/Notification';
|
|
4
|
+
import { UIProvider, NotificationsProvider } from '@itcase/ui-core/context';
|
|
10
5
|
|
|
11
6
|
var _excluded = ["storesData"];
|
|
12
7
|
function withNextDecoratorFactory(_ref) {
|
|
@@ -25,16 +20,16 @@ function withNextDecoratorFactory(_ref) {
|
|
|
25
20
|
appContext = _prepareStoryArgument.appContext,
|
|
26
21
|
appParameters = _prepareStoryArgument.appParameters;
|
|
27
22
|
if (appParameters.page) {
|
|
28
|
-
return /*#__PURE__*/
|
|
23
|
+
return /*#__PURE__*/React.createElement(App, {
|
|
29
24
|
Component: Story,
|
|
30
25
|
pageProps: appArgs
|
|
31
26
|
});
|
|
32
27
|
}
|
|
33
|
-
return /*#__PURE__*/
|
|
28
|
+
return /*#__PURE__*/React.createElement(RootStoreProvider, appArgs.rootStoreInitialData, /*#__PURE__*/React.createElement(UIProvider, null, /*#__PURE__*/React.createElement(NotificationsProvider, {
|
|
34
29
|
initialNotificationsList: parameters.initialNotificationsList || args.initialNotificationsList || []
|
|
35
|
-
}, /*#__PURE__*/
|
|
30
|
+
}, /*#__PURE__*/React.createElement(NotificationWrapper, {
|
|
36
31
|
className: "notification_global notification_global_right_top"
|
|
37
|
-
}), /*#__PURE__*/
|
|
32
|
+
}), /*#__PURE__*/React.createElement(Story, appContext))));
|
|
38
33
|
};
|
|
39
34
|
return decorator;
|
|
40
35
|
}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import '@itcase/
|
|
4
|
-
import 'lodash/camelCase';
|
|
5
|
-
import 'lodash/castArray';
|
|
6
|
-
import 'lodash/upperFirst';
|
|
7
|
-
import 'lodash/maxBy';
|
|
8
|
-
import 'react-dom';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NotificationWrapper } from '@itcase/ui-web/components/Notification';
|
|
3
|
+
import { UIProvider, NotificationsProvider } from '@itcase/ui-core/context';
|
|
9
4
|
|
|
10
5
|
function withUiDecorator(Story, _ref) {
|
|
11
6
|
var args = _ref.args,
|
|
12
7
|
parameters = _ref.parameters;
|
|
13
|
-
return /*#__PURE__*/
|
|
8
|
+
return /*#__PURE__*/React.createElement(UIProvider, null, /*#__PURE__*/React.createElement(NotificationsProvider, {
|
|
14
9
|
initialNotificationsList: parameters.initialNotificationsList || args.initialNotificationsList || []
|
|
15
|
-
}, /*#__PURE__*/
|
|
10
|
+
}, /*#__PURE__*/React.createElement(NotificationWrapper, null), /*#__PURE__*/React.createElement(Story, null)));
|
|
16
11
|
}
|
|
17
12
|
|
|
18
13
|
export { withUiDecorator };
|
package/dist/decorators.js
CHANGED
|
@@ -6,13 +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-
|
|
10
|
-
import '
|
|
11
|
-
import './components/FormSubmitWrapper-
|
|
12
|
-
import 'lodash/camelCase';
|
|
9
|
+
import './components/_rollupPluginBabelHelpers-CEVa9ZMs.js';
|
|
10
|
+
import './components/isArray-CPoGkdXv.js';
|
|
11
|
+
import './components/FormSubmitWrapper-obAauTlP.js';
|
|
13
12
|
import '@itcase/common';
|
|
14
13
|
import 'msw';
|
|
15
|
-
import '
|
|
16
|
-
import '
|
|
17
|
-
import '
|
|
18
|
-
import 'react-dom';
|
|
14
|
+
import 'final-form';
|
|
15
|
+
import '@itcase/ui-web/components/Notification';
|
|
16
|
+
import '@itcase/ui-core/context';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
4
|
+
|
|
5
|
+
function getDefaultExportFromCjs (x) {
|
|
6
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Checks if `value` is classified as an `Array` object.
|
|
11
|
+
*
|
|
12
|
+
* @static
|
|
13
|
+
* @memberOf _
|
|
14
|
+
* @since 0.1.0
|
|
15
|
+
* @category Lang
|
|
16
|
+
* @param {*} value The value to check.
|
|
17
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
18
|
+
* @example
|
|
19
|
+
*
|
|
20
|
+
* _.isArray([1, 2, 3]);
|
|
21
|
+
* // => true
|
|
22
|
+
*
|
|
23
|
+
* _.isArray(document.body.children);
|
|
24
|
+
* // => false
|
|
25
|
+
*
|
|
26
|
+
* _.isArray('abc');
|
|
27
|
+
* // => false
|
|
28
|
+
*
|
|
29
|
+
* _.isArray(_.noop);
|
|
30
|
+
* // => false
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
var isArray_1;
|
|
34
|
+
var hasRequiredIsArray;
|
|
35
|
+
|
|
36
|
+
function requireIsArray () {
|
|
37
|
+
if (hasRequiredIsArray) return isArray_1;
|
|
38
|
+
hasRequiredIsArray = 1;
|
|
39
|
+
var isArray = Array.isArray;
|
|
40
|
+
|
|
41
|
+
isArray_1 = isArray;
|
|
42
|
+
return isArray_1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.commonjsGlobal = commonjsGlobal;
|
|
46
|
+
exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
|
|
47
|
+
exports.requireIsArray = requireIsArray;
|
|
@@ -1,17 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
serverErrorDataHandler,
|
|
3
|
+
serverErrorHandler,
|
|
4
|
+
} from '../config/msw/mswHandlers'
|
|
2
5
|
|
|
3
6
|
function handleMSWParameters(parameters, args) {
|
|
4
|
-
|
|
7
|
+
const errors = args?.errors
|
|
8
|
+
const handlers = []
|
|
5
9
|
|
|
6
10
|
if (parameters.serverError) {
|
|
7
|
-
|
|
8
|
-
msw: {
|
|
9
|
-
handlers: [serverErrorHandler(args.errors)],
|
|
10
|
-
},
|
|
11
|
-
}
|
|
11
|
+
handlers.push(serverErrorHandler(errors))
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
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 }
|
package/dist/utils/index.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "1.2.73",
|
|
4
4
|
"author": "ITCase",
|
|
5
5
|
"description": "Storybook configuration package",
|
|
6
6
|
"engines": {
|
|
@@ -81,35 +81,41 @@
|
|
|
81
81
|
"react": "^18",
|
|
82
82
|
"react-dom": "^18"
|
|
83
83
|
},
|
|
84
|
+
"peerDependencies": {
|
|
85
|
+
"@itcase/ui-core": "^1.10.8",
|
|
86
|
+
"@itcase/ui-web": "^1.10.8",
|
|
87
|
+
"react": "^18",
|
|
88
|
+
"react-dom": "^18"
|
|
89
|
+
},
|
|
84
90
|
"dependencies": {
|
|
85
91
|
"@gorhom/bottom-sheet": "^5.2.14",
|
|
86
92
|
"@itcase/config": "^1.6.58",
|
|
87
93
|
"@itcase/storybook-addon-auth": "^1.0.5",
|
|
88
|
-
"@react-native-async-storage/async-storage": "^3.1.
|
|
94
|
+
"@react-native-async-storage/async-storage": "^3.1.1",
|
|
89
95
|
"@react-native-community/datetimepicker": "^9.1.0",
|
|
90
96
|
"@storybook/addon-designs": "^11.1.3",
|
|
91
|
-
"@storybook/addon-docs": "^10.4.
|
|
92
|
-
"@storybook/addon-links": "^10.4.
|
|
97
|
+
"@storybook/addon-docs": "^10.4.2",
|
|
98
|
+
"@storybook/addon-links": "^10.4.2",
|
|
93
99
|
"@storybook/addon-ondevice-actions": "10.4.4",
|
|
94
100
|
"@storybook/addon-ondevice-backgrounds": "10.4.4",
|
|
95
101
|
"@storybook/addon-ondevice-controls": "10.4.4",
|
|
96
102
|
"@storybook/addon-ondevice-notes": "^10.4.4",
|
|
97
103
|
"@storybook/addon-react-native-web": "^0.0.29",
|
|
98
104
|
"@storybook/addon-styling-webpack": "^3.0.2",
|
|
99
|
-
"@storybook/addon-themes": "^10.4.
|
|
100
|
-
"@storybook/addon-vitest": "^10.4.
|
|
105
|
+
"@storybook/addon-themes": "^10.4.2",
|
|
106
|
+
"@storybook/addon-vitest": "^10.4.2",
|
|
101
107
|
"@storybook/addon-webpack5-compiler-swc": "^4.0.3",
|
|
102
|
-
"@storybook/builder-vite": "^10.4.
|
|
103
|
-
"@storybook/nextjs": "^10.4.
|
|
104
|
-
"@storybook/nextjs-vite": "^10.4.
|
|
105
|
-
"@storybook/react": "^10.4.
|
|
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",
|
|
106
112
|
"@storybook/react-native": "10.4.4",
|
|
107
113
|
"@storybook/react-native-ui-lite": "10.4.4",
|
|
108
|
-
"@storybook/react-native-web-vite": "^10.4.
|
|
109
|
-
"@storybook/react-vite": "^10.4.
|
|
110
|
-
"@storybook/react-webpack5": "^10.4.
|
|
114
|
+
"@storybook/react-native-web-vite": "^10.4.2",
|
|
115
|
+
"@storybook/react-vite": "^10.4.2",
|
|
116
|
+
"@storybook/react-webpack5": "^10.4.2",
|
|
111
117
|
"@vitejs/plugin-react": "^6.0.2",
|
|
112
|
-
"@vitest/browser-playwright": "^4.1.
|
|
118
|
+
"@vitest/browser-playwright": "^4.1.8",
|
|
113
119
|
"babel-loader": "^10.1.1",
|
|
114
120
|
"babel-plugin-react-docgen": "^4.2.1",
|
|
115
121
|
"babel-plugin-react-native-web": "^0.21.2",
|
|
@@ -124,25 +130,25 @@
|
|
|
124
130
|
"react-native-svg": "^15.15.5",
|
|
125
131
|
"react-native-web": "^0.21.2",
|
|
126
132
|
"react-native-worklets": "^0.9.1",
|
|
127
|
-
"storybook": "^10.4.
|
|
133
|
+
"storybook": "^10.4.2",
|
|
128
134
|
"storybook-addon-source-link": "^2.0.1",
|
|
129
|
-
"vite": "^8.0.
|
|
135
|
+
"vite": "^8.0.16",
|
|
130
136
|
"vite-plugin-babel": "^1.7.3",
|
|
131
137
|
"vite-plugin-svgr": "^5.2.0",
|
|
132
138
|
"vite-tsconfig-paths": "^6.1.1",
|
|
133
|
-
"vitest": "^4.1.
|
|
139
|
+
"vitest": "^4.1.8"
|
|
134
140
|
},
|
|
135
141
|
"devDependencies": {
|
|
136
142
|
"@babel/core": "^7.29.7",
|
|
137
143
|
"@babel/preset-env": "^7.29.7",
|
|
138
144
|
"@babel/preset-react": "^7.29.7",
|
|
139
145
|
"@babel/runtime": "^7.29.7",
|
|
140
|
-
"@commitlint/cli": "^21.0.
|
|
141
|
-
"@commitlint/config-conventional": "^21.0.
|
|
142
|
-
"@itcase/common": "^1.2.
|
|
146
|
+
"@commitlint/cli": "^21.0.2",
|
|
147
|
+
"@commitlint/config-conventional": "^21.0.2",
|
|
148
|
+
"@itcase/common": "^1.2.44",
|
|
143
149
|
"@itcase/lint": "^1.1.116",
|
|
144
|
-
"@itcase/ui-core": "^1.10.
|
|
145
|
-
"@itcase/ui-web": "^1.10.
|
|
150
|
+
"@itcase/ui-core": "^1.10.15",
|
|
151
|
+
"@itcase/ui-web": "^1.10.20",
|
|
146
152
|
"@react-native-community/cli": "20.1.3",
|
|
147
153
|
"@react-native-community/cli-platform-android": "20.1.3",
|
|
148
154
|
"@react-native-community/cli-platform-ios": "20.1.3",
|
|
@@ -150,11 +156,11 @@
|
|
|
150
156
|
"@react-native/eslint-config": "0.85.3",
|
|
151
157
|
"@react-native/metro-config": "0.85.3",
|
|
152
158
|
"@react-native/typescript-config": "0.85.3",
|
|
153
|
-
"@rollup/plugin-babel": "^7.
|
|
154
|
-
"@rollup/plugin-commonjs": "^29.0.
|
|
159
|
+
"@rollup/plugin-babel": "^7.1.0",
|
|
160
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
155
161
|
"@rollup/plugin-json": "^6.1.0",
|
|
156
162
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
157
|
-
"@storybook/addon-docs": "^10.4.
|
|
163
|
+
"@storybook/addon-docs": "^10.4.2",
|
|
158
164
|
"@types/react": "^18",
|
|
159
165
|
"@types/react-dom": "^18",
|
|
160
166
|
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
|
|
@@ -162,8 +168,8 @@
|
|
|
162
168
|
"eslint": "9.39.2",
|
|
163
169
|
"glob": "^13.0.6",
|
|
164
170
|
"husky": "^9.1.7",
|
|
165
|
-
"lint-staged": "^17.0.
|
|
166
|
-
"next": "^16.2.
|
|
171
|
+
"lint-staged": "^17.0.7",
|
|
172
|
+
"next": "^16.2.7",
|
|
167
173
|
"prettier": "^3.8.3",
|
|
168
174
|
"react": "^18",
|
|
169
175
|
"react-docgen": "^8.0.3",
|
|
@@ -171,12 +177,12 @@
|
|
|
171
177
|
"react-dom": "^18",
|
|
172
178
|
"react-native": "0.85.3",
|
|
173
179
|
"react-native-web": "^0.21.2",
|
|
174
|
-
"rollup": "^4.
|
|
180
|
+
"rollup": "^4.61.0",
|
|
175
181
|
"rollup-plugin-copy": "^3.5.0",
|
|
176
182
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
177
183
|
"semantic-release": "^25.0.3",
|
|
178
184
|
"stylelint": "^17.12.0",
|
|
179
185
|
"typescript": "^6.0.3",
|
|
180
|
-
"vite": "^8.0.
|
|
186
|
+
"vite": "^8.0.16"
|
|
181
187
|
}
|
|
182
188
|
}
|
|
@@ -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;
|