@itcase/storybook-config 1.2.80 → 1.2.81
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 → FormSubmitWrapper-Bv5qs18h.js} +10 -3
- 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/FormSubmitWrapper.d.ts +3 -1
- package/dist/components/FormSubmitWrapper/FormSubmitWrapper.js +7 -3
- package/dist/components/{FormSubmitWrapper-B2tMQZu2.js → FormSubmitWrapper-EwNkaMht.js} +10 -3
- 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
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
|
|
5
|
+
function isVitestEnvironment() {
|
|
6
|
+
return Boolean(undefined?.VITEST);
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
const SUBMIT_POLL_MS = 50;
|
|
6
10
|
function getStoryPreviewDocument() {
|
|
7
11
|
const previewIframe = document.getElementById('storybook-preview-iframe') ?? document.querySelector('iframe[data-is-storybook="true"]');
|
|
@@ -173,7 +177,9 @@ function withFormRef(children, formRef, bindings) {
|
|
|
173
177
|
/**
|
|
174
178
|
* Авто-submit для интерактивного Storybook (Require / Validation / ServerError).
|
|
175
179
|
* При primaryButtonHtmlType="button" — formRef.current.submit() (final-form API),
|
|
176
|
-
* при type="submit" — click по кнопке. В Vitest submit в play
|
|
180
|
+
* при type="submit" — click по кнопке. В Vitest submit в play — auto-submit не
|
|
181
|
+
* запускаем, иначе второй клик из play ставит modifiedSinceLastSubmit и прячет
|
|
182
|
+
* non-field notification.
|
|
177
183
|
*/
|
|
178
184
|
function FormSubmitWrapper(props) {
|
|
179
185
|
const formRef = React.useRef(null);
|
|
@@ -187,8 +193,9 @@ function FormSubmitWrapper(props) {
|
|
|
187
193
|
children
|
|
188
194
|
} = props;
|
|
189
195
|
const storyArgs = args ?? context?.args ?? children?.props?.args ?? {};
|
|
196
|
+
const shouldAutoSubmit = submit && !isVitestEnvironment();
|
|
190
197
|
React.useEffect(() => {
|
|
191
|
-
if (!
|
|
198
|
+
if (!shouldAutoSubmit) {
|
|
192
199
|
return undefined;
|
|
193
200
|
}
|
|
194
201
|
delete formRef.__itcaseDidAutoSubmit;
|
|
@@ -198,7 +205,7 @@ function FormSubmitWrapper(props) {
|
|
|
198
205
|
abortController.abort();
|
|
199
206
|
delete formRef.__itcaseDidAutoSubmit;
|
|
200
207
|
};
|
|
201
|
-
}, [
|
|
208
|
+
}, [shouldAutoSubmit, storyArgs.errors]);
|
|
202
209
|
|
|
203
210
|
// eslint-disable-next-line react-hooks/refs -- ref уходит в cloneElement внутри bound render
|
|
204
211
|
return withFormRef(children, formRef, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('react');
|
|
4
|
-
var FormSubmitWrapper = require('../../FormSubmitWrapper-
|
|
4
|
+
var FormSubmitWrapper = require('../../FormSubmitWrapper-Bv5qs18h.js');
|
|
5
5
|
var isArray = require('../../isArray-DJguRq_2.js');
|
|
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('react/jsx-runtime');
|
|
12
12
|
require('../isArray-DJguRq_2.js');
|
|
13
|
-
require('../FormSubmitWrapper-
|
|
13
|
+
require('../FormSubmitWrapper-Bv5qs18h.js');
|
|
14
14
|
require('@itcase/common');
|
|
15
15
|
require('msw');
|
|
16
16
|
require('@itcase/ui-core/context');
|
|
@@ -2,7 +2,9 @@ import React from 'react';
|
|
|
2
2
|
/**
|
|
3
3
|
* Авто-submit для интерактивного Storybook (Require / Validation / ServerError).
|
|
4
4
|
* При primaryButtonHtmlType="button" — formRef.current.submit() (final-form API),
|
|
5
|
-
* при type="submit" — click по кнопке. В Vitest submit в play
|
|
5
|
+
* при type="submit" — click по кнопке. В Vitest submit в play — auto-submit не
|
|
6
|
+
* запускаем, иначе второй клик из play ставит modifiedSinceLastSubmit и прячет
|
|
7
|
+
* non-field notification.
|
|
6
8
|
*/
|
|
7
9
|
declare function FormSubmitWrapper(props: any): React.FunctionComponentElement<{
|
|
8
10
|
component: any;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { isVitestEnvironment } from '../../utils/isVitestEnvironment';
|
|
2
3
|
import { autoSubmitForm } from './autoSubmitForm';
|
|
3
4
|
function wrapRender(component, render, formRef, defaultArgs = {}) {
|
|
4
5
|
if (typeof render !== 'function') {
|
|
@@ -54,14 +55,17 @@ function withFormRef(children, formRef, bindings) {
|
|
|
54
55
|
/**
|
|
55
56
|
* Авто-submit для интерактивного Storybook (Require / Validation / ServerError).
|
|
56
57
|
* При primaryButtonHtmlType="button" — formRef.current.submit() (final-form API),
|
|
57
|
-
* при type="submit" — click по кнопке. В Vitest submit в play
|
|
58
|
+
* при type="submit" — click по кнопке. В Vitest submit в play — auto-submit не
|
|
59
|
+
* запускаем, иначе второй клик из play ставит modifiedSinceLastSubmit и прячет
|
|
60
|
+
* non-field notification.
|
|
58
61
|
*/
|
|
59
62
|
function FormSubmitWrapper(props) {
|
|
60
63
|
const formRef = useRef(null);
|
|
61
64
|
const { component, args, render, allArgs, context, submit = true, children, } = props;
|
|
62
65
|
const storyArgs = args ?? context?.args ?? children?.props?.args ?? {};
|
|
66
|
+
const shouldAutoSubmit = submit && !isVitestEnvironment();
|
|
63
67
|
useEffect(() => {
|
|
64
|
-
if (!
|
|
68
|
+
if (!shouldAutoSubmit) {
|
|
65
69
|
return undefined;
|
|
66
70
|
}
|
|
67
71
|
delete formRef.__itcaseDidAutoSubmit;
|
|
@@ -71,7 +75,7 @@ function FormSubmitWrapper(props) {
|
|
|
71
75
|
abortController.abort();
|
|
72
76
|
delete formRef.__itcaseDidAutoSubmit;
|
|
73
77
|
};
|
|
74
|
-
}, [
|
|
78
|
+
}, [shouldAutoSubmit, storyArgs.errors]);
|
|
75
79
|
// eslint-disable-next-line react-hooks/refs -- ref уходит в cloneElement внутри bound render
|
|
76
80
|
return withFormRef(children, formRef, {
|
|
77
81
|
component,
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React, { useRef, useEffect } from 'react';
|
|
2
2
|
|
|
3
|
+
function isVitestEnvironment() {
|
|
4
|
+
return Boolean(import.meta.env?.VITEST);
|
|
5
|
+
}
|
|
6
|
+
|
|
3
7
|
const SUBMIT_POLL_MS = 50;
|
|
4
8
|
function getStoryPreviewDocument() {
|
|
5
9
|
const previewIframe = document.getElementById('storybook-preview-iframe') ?? document.querySelector('iframe[data-is-storybook="true"]');
|
|
@@ -171,7 +175,9 @@ function withFormRef(children, formRef, bindings) {
|
|
|
171
175
|
/**
|
|
172
176
|
* Авто-submit для интерактивного Storybook (Require / Validation / ServerError).
|
|
173
177
|
* При primaryButtonHtmlType="button" — formRef.current.submit() (final-form API),
|
|
174
|
-
* при type="submit" — click по кнопке. В Vitest submit в play
|
|
178
|
+
* при type="submit" — click по кнопке. В Vitest submit в play — auto-submit не
|
|
179
|
+
* запускаем, иначе второй клик из play ставит modifiedSinceLastSubmit и прячет
|
|
180
|
+
* non-field notification.
|
|
175
181
|
*/
|
|
176
182
|
function FormSubmitWrapper(props) {
|
|
177
183
|
const formRef = useRef(null);
|
|
@@ -185,8 +191,9 @@ function FormSubmitWrapper(props) {
|
|
|
185
191
|
children
|
|
186
192
|
} = props;
|
|
187
193
|
const storyArgs = args ?? context?.args ?? children?.props?.args ?? {};
|
|
194
|
+
const shouldAutoSubmit = submit && !isVitestEnvironment();
|
|
188
195
|
useEffect(() => {
|
|
189
|
-
if (!
|
|
196
|
+
if (!shouldAutoSubmit) {
|
|
190
197
|
return undefined;
|
|
191
198
|
}
|
|
192
199
|
delete formRef.__itcaseDidAutoSubmit;
|
|
@@ -196,7 +203,7 @@ function FormSubmitWrapper(props) {
|
|
|
196
203
|
abortController.abort();
|
|
197
204
|
delete formRef.__itcaseDidAutoSubmit;
|
|
198
205
|
};
|
|
199
|
-
}, [
|
|
206
|
+
}, [shouldAutoSubmit, storyArgs.errors]);
|
|
200
207
|
|
|
201
208
|
// eslint-disable-next-line react-hooks/refs -- ref уходит в cloneElement внутри bound render
|
|
202
209
|
return withFormRef(children, formRef, {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { F as FormSubmitWrapper } from './FormSubmitWrapper-
|
|
1
|
+
export { F as FormSubmitWrapper } from './FormSubmitWrapper-EwNkaMht.js';
|
|
2
2
|
import 'react';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
import { F as FormSubmitWrapper } from '../components/FormSubmitWrapper-
|
|
2
|
+
import { F as FormSubmitWrapper } from '../components/FormSubmitWrapper-EwNkaMht.js';
|
|
3
3
|
import { c as commonjsGlobal, r as requireIsArray } from '../components/isArray-CPoGkdXv.js';
|
|
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 'react/jsx-runtime';
|
|
10
10
|
import './components/isArray-CPoGkdXv.js';
|
|
11
|
-
import './components/FormSubmitWrapper-
|
|
11
|
+
import './components/FormSubmitWrapper-EwNkaMht.js';
|
|
12
12
|
import '@itcase/common';
|
|
13
13
|
import 'msw';
|
|
14
14
|
import '@itcase/ui-core/context';
|