@itcase/storybook-config 1.2.61 → 1.2.62
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.
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var _rollupPluginBabelHelpers = require('../../_rollupPluginBabelHelpers-Wvf9ehn_.js');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
|
|
6
|
-
var STABLE_TICKS = 2;
|
|
7
6
|
function FormSubmitWrapper(props) {
|
|
8
7
|
var formRef = React.useRef();
|
|
9
8
|
var initialArgs = props.initialArgs,
|
|
@@ -19,26 +18,25 @@ function FormSubmitWrapper(props) {
|
|
|
19
18
|
}
|
|
20
19
|
var cancelled = false;
|
|
21
20
|
var timeoutId;
|
|
22
|
-
var lastCount = 0;
|
|
23
|
-
var stableTicks = 0;
|
|
24
21
|
var _pollSubmit = function pollSubmit() {
|
|
25
|
-
var
|
|
22
|
+
var _document$getElementB, _formRef$current$getR, _formRef$current, _formRef$current$getR2;
|
|
26
23
|
if (cancelled) {
|
|
27
24
|
return;
|
|
28
25
|
}
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} else if (count !== lastCount) {
|
|
35
|
-
lastCount = count;
|
|
36
|
-
stableTicks = 1;
|
|
37
|
-
} else if (++stableTicks >= STABLE_TICKS) {
|
|
38
|
-
form.submit();
|
|
26
|
+
var submitButton = (_document$getElementB = document.getElementById('storybook-root')) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.querySelector('button[type="submit"]');
|
|
27
|
+
var fieldCount = (_formRef$current$getR = (_formRef$current = formRef.current) === null || _formRef$current === void 0 || (_formRef$current$getR2 = _formRef$current.getRegisteredFields) === null || _formRef$current$getR2 === void 0 || (_formRef$current$getR2 = _formRef$current$getR2.call(_formRef$current)) === null || _formRef$current$getR2 === void 0 ? void 0 : _formRef$current$getR2.length) !== null && _formRef$current$getR !== void 0 ? _formRef$current$getR : 0;
|
|
28
|
+
var isReady = submitButton && (!formRef.current || fieldCount > 0);
|
|
29
|
+
if (!isReady) {
|
|
30
|
+
timeoutId = setTimeout(_pollSubmit, 0);
|
|
39
31
|
return;
|
|
40
32
|
}
|
|
41
|
-
timeoutId = setTimeout(
|
|
33
|
+
timeoutId = setTimeout(function () {
|
|
34
|
+
var _formRef$current$subm, _formRef$current2, _formRef$current2$sub;
|
|
35
|
+
if (cancelled) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
(_formRef$current$subm = (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || (_formRef$current2$sub = _formRef$current2.submit) === null || _formRef$current2$sub === void 0 ? void 0 : _formRef$current2$sub.call(_formRef$current2)) !== null && _formRef$current$subm !== void 0 ? _formRef$current$subm : submitButton.click();
|
|
39
|
+
}, 100);
|
|
42
40
|
};
|
|
43
41
|
timeoutId = setTimeout(_pollSubmit, 0);
|
|
44
42
|
return function () {
|
|
@@ -12,9 +12,10 @@ function hasFormParameters(parameters) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
function withFormSubmitDecorator() {
|
|
15
|
-
var decorator = function decorator(Story,
|
|
16
|
-
var parameters =
|
|
17
|
-
context =
|
|
15
|
+
var decorator = function decorator(Story, storyContext) {
|
|
16
|
+
var parameters = storyContext.parameters,
|
|
17
|
+
_storyContext$context = storyContext.context,
|
|
18
|
+
context = _storyContext$context === void 0 ? storyContext : _storyContext$context;
|
|
18
19
|
return hasFormParameters(parameters) ? /*#__PURE__*/React.createElement(index.FormSubmitWrapper, context, /*#__PURE__*/React.createElement(Story, context)) : /*#__PURE__*/React.createElement(Story, context);
|
|
19
20
|
};
|
|
20
21
|
return decorator;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { _ as _objectSpread2 } from '../_rollupPluginBabelHelpers-BsYN8Oir.js';
|
|
2
2
|
import React__default, { useRef, useEffect } from 'react';
|
|
3
3
|
|
|
4
|
-
var STABLE_TICKS = 2;
|
|
5
4
|
function FormSubmitWrapper(props) {
|
|
6
5
|
var formRef = useRef();
|
|
7
6
|
var initialArgs = props.initialArgs,
|
|
@@ -17,26 +16,25 @@ function FormSubmitWrapper(props) {
|
|
|
17
16
|
}
|
|
18
17
|
var cancelled = false;
|
|
19
18
|
var timeoutId;
|
|
20
|
-
var lastCount = 0;
|
|
21
|
-
var stableTicks = 0;
|
|
22
19
|
var _pollSubmit = function pollSubmit() {
|
|
23
|
-
var
|
|
20
|
+
var _document$getElementB, _formRef$current$getR, _formRef$current, _formRef$current$getR2;
|
|
24
21
|
if (cancelled) {
|
|
25
22
|
return;
|
|
26
23
|
}
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} else if (count !== lastCount) {
|
|
33
|
-
lastCount = count;
|
|
34
|
-
stableTicks = 1;
|
|
35
|
-
} else if (++stableTicks >= STABLE_TICKS) {
|
|
36
|
-
form.submit();
|
|
24
|
+
var submitButton = (_document$getElementB = document.getElementById('storybook-root')) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.querySelector('button[type="submit"]');
|
|
25
|
+
var fieldCount = (_formRef$current$getR = (_formRef$current = formRef.current) === null || _formRef$current === void 0 || (_formRef$current$getR2 = _formRef$current.getRegisteredFields) === null || _formRef$current$getR2 === void 0 || (_formRef$current$getR2 = _formRef$current$getR2.call(_formRef$current)) === null || _formRef$current$getR2 === void 0 ? void 0 : _formRef$current$getR2.length) !== null && _formRef$current$getR !== void 0 ? _formRef$current$getR : 0;
|
|
26
|
+
var isReady = submitButton && (!formRef.current || fieldCount > 0);
|
|
27
|
+
if (!isReady) {
|
|
28
|
+
timeoutId = setTimeout(_pollSubmit, 0);
|
|
37
29
|
return;
|
|
38
30
|
}
|
|
39
|
-
timeoutId = setTimeout(
|
|
31
|
+
timeoutId = setTimeout(function () {
|
|
32
|
+
var _formRef$current$subm, _formRef$current2, _formRef$current2$sub;
|
|
33
|
+
if (cancelled) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
(_formRef$current$subm = (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || (_formRef$current2$sub = _formRef$current2.submit) === null || _formRef$current2$sub === void 0 ? void 0 : _formRef$current2$sub.call(_formRef$current2)) !== null && _formRef$current$subm !== void 0 ? _formRef$current$subm : submitButton.click();
|
|
37
|
+
}, 100);
|
|
40
38
|
};
|
|
41
39
|
timeoutId = setTimeout(_pollSubmit, 0);
|
|
42
40
|
return function () {
|
|
@@ -10,9 +10,10 @@ function hasFormParameters(parameters) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
function withFormSubmitDecorator() {
|
|
13
|
-
var decorator = function decorator(Story,
|
|
14
|
-
var parameters =
|
|
15
|
-
context =
|
|
13
|
+
var decorator = function decorator(Story, storyContext) {
|
|
14
|
+
var parameters = storyContext.parameters,
|
|
15
|
+
_storyContext$context = storyContext.context,
|
|
16
|
+
context = _storyContext$context === void 0 ? storyContext : _storyContext$context;
|
|
16
17
|
return hasFormParameters(parameters) ? /*#__PURE__*/React__default.createElement(FormSubmitWrapper, context, /*#__PURE__*/React__default.createElement(Story, context)) : /*#__PURE__*/React__default.createElement(Story, context);
|
|
17
18
|
};
|
|
18
19
|
return decorator;
|