@itcase/storybook-config 1.2.73 → 1.2.75

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-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
- clickSubmitButton(submitButton);
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 deadline, _submitButton$querySe, root, form, submitButton, saveDraftButton, canSubmitViaFormApi, canClickNativeSubmit, canClickSaveDraft;
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
- deadline = Date.now() + SUBMIT_TIMEOUT_MS;
138
- case 2:
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 = Boolean(submitButton && (submitButton.type === 'submit' || ((_submitButton$querySe = submitButton.querySelector) === null || _submitButton$querySe === void 0 ? void 0 : _submitButton$querySe.call(submitButton, 'button[type="submit"]'))));
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 = 4;
114
+ _context.n = 3;
152
115
  break;
153
116
  }
154
- _context.n = 3;
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 = 7;
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 7:
131
+ case 4:
180
132
  if (!signal.aborted) {
181
- _context.n = 8;
133
+ _context.n = 5;
182
134
  break;
183
135
  }
184
136
  return _context.a(2);
185
- case 8:
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 9:
144
+ case 6:
193
145
  return _context.a(2);
194
146
  }
195
147
  }, _callee);
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var FormSubmitWrapper = require('../../FormSubmitWrapper-kEv1DMjn.js');
3
+ var FormSubmitWrapper = require('../../FormSubmitWrapper-BaqE4w9q.js');
4
4
  require('../../_rollupPluginBabelHelpers-B1r4NF8e.js');
5
5
  require('react');
6
6
 
@@ -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-kEv1DMjn.js');
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');
@@ -1119,11 +1119,6 @@ function hasFormParameters(parameters) {
1119
1119
  return Boolean(parameters.require || parameters.validation || parameters.error || parameters.serverError || parameters.serverErrorData);
1120
1120
  }
1121
1121
 
1122
- function isVitestEnvironment() {
1123
- var _import$meta$env;
1124
- return Boolean((_import$meta$env = undefined) === null || _import$meta$env === void 0 ? void 0 : _import$meta$env.VITEST);
1125
- }
1126
-
1127
1122
  function getStoryArgs(storyContext) {
1128
1123
  var _storyContext$context, _storyContext$initial, _baseContext$args, _storyContext$args;
1129
1124
  var baseContext = (_storyContext$context = storyContext.context) !== null && _storyContext$context !== void 0 ? _storyContext$context : storyContext;
@@ -1141,7 +1136,7 @@ function withFormSubmitDecorator() {
1141
1136
  var decorator = function decorator(Story, storyContext) {
1142
1137
  var parameters = storyContext.parameters;
1143
1138
  var context = enhanceStoryContext(storyContext);
1144
- if (isVitestEnvironment() || !hasFormParameters(parameters)) {
1139
+ if (!hasFormParameters(parameters)) {
1145
1140
  return /*#__PURE__*/React.createElement(Story, Object.assign({}, context, {
1146
1141
  parameters: parameters
1147
1142
  }));
@@ -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-kEv1DMjn.js');
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
- clickSubmitButton(submitButton);
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 deadline, _submitButton$querySe, root, form, submitButton, saveDraftButton, canSubmitViaFormApi, canClickNativeSubmit, canClickSaveDraft;
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
- deadline = Date.now() + SUBMIT_TIMEOUT_MS;
136
- case 2:
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 = Boolean(submitButton && (submitButton.type === 'submit' || ((_submitButton$querySe = submitButton.querySelector) === null || _submitButton$querySe === void 0 ? void 0 : _submitButton$querySe.call(submitButton, 'button[type="submit"]'))));
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 = 4;
112
+ _context.n = 3;
150
113
  break;
151
114
  }
152
- _context.n = 3;
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 = 7;
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 7:
129
+ case 4:
178
130
  if (!signal.aborted) {
179
- _context.n = 8;
131
+ _context.n = 5;
180
132
  break;
181
133
  }
182
134
  return _context.a(2);
183
- case 8:
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 9:
142
+ case 6:
191
143
  return _context.a(2);
192
144
  }
193
145
  }, _callee);
@@ -1,3 +1,3 @@
1
- export { F as FormSubmitWrapper } from './FormSubmitWrapper-obAauTlP.js';
1
+ export { F as FormSubmitWrapper } from './FormSubmitWrapper-DoGZRTm5.js';
2
2
  import './_rollupPluginBabelHelpers-CEVa9ZMs.js';
3
3
  import 'react';
@@ -17,6 +17,13 @@ const VIEWPORTS = {
17
17
  height: '667px',
18
18
  },
19
19
  },
20
+ tablet: {
21
+ name: 'Tablet',
22
+ styles: {
23
+ width: '768px',
24
+ height: '1024px',
25
+ },
26
+ },
20
27
  }
21
28
 
22
29
  export { VIEWPORTS }
@@ -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-obAauTlP.js';
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';
@@ -1117,11 +1117,6 @@ function hasFormParameters(parameters) {
1117
1117
  return Boolean(parameters.require || parameters.validation || parameters.error || parameters.serverError || parameters.serverErrorData);
1118
1118
  }
1119
1119
 
1120
- function isVitestEnvironment() {
1121
- var _import$meta$env;
1122
- return Boolean((_import$meta$env = import.meta.env) === null || _import$meta$env === void 0 ? void 0 : _import$meta$env.VITEST);
1123
- }
1124
-
1125
1120
  function getStoryArgs(storyContext) {
1126
1121
  var _storyContext$context, _storyContext$initial, _baseContext$args, _storyContext$args;
1127
1122
  var baseContext = (_storyContext$context = storyContext.context) !== null && _storyContext$context !== void 0 ? _storyContext$context : storyContext;
@@ -1139,7 +1134,7 @@ function withFormSubmitDecorator() {
1139
1134
  var decorator = function decorator(Story, storyContext) {
1140
1135
  var parameters = storyContext.parameters;
1141
1136
  var context = enhanceStoryContext(storyContext);
1142
- if (isVitestEnvironment() || !hasFormParameters(parameters)) {
1137
+ if (!hasFormParameters(parameters)) {
1143
1138
  return /*#__PURE__*/React.createElement(Story, Object.assign({}, context, {
1144
1139
  parameters: parameters
1145
1140
  }));
@@ -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-obAauTlP.js';
11
+ import './components/FormSubmitWrapper-DoGZRTm5.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.73",
3
+ "version": "1.2.75",
4
4
  "author": "ITCase",
5
5
  "description": "Storybook configuration package",
6
6
  "engines": {
@@ -121,11 +121,11 @@
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.0.0",
124
+ "http-proxy-middleware": "^4.1.0",
125
125
  "msw": "^2.14.6",
126
126
  "msw-storybook-addon": "^2.0.7",
127
127
  "react-native-gesture-handler": "^3.0.0",
128
- "react-native-reanimated": "^4.4.0",
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",
@@ -147,8 +147,8 @@
147
147
  "@commitlint/config-conventional": "^21.0.2",
148
148
  "@itcase/common": "^1.2.44",
149
149
  "@itcase/lint": "^1.1.116",
150
- "@itcase/ui-core": "^1.10.15",
151
- "@itcase/ui-web": "^1.10.20",
150
+ "@itcase/ui-core": "^1.10.21",
151
+ "@itcase/ui-web": "^1.10.23",
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",
@@ -177,11 +177,11 @@
177
177
  "react-dom": "^18",
178
178
  "react-native": "0.85.3",
179
179
  "react-native-web": "^0.21.2",
180
- "rollup": "^4.61.0",
180
+ "rollup": "^4.61.1",
181
181
  "rollup-plugin-copy": "^3.5.0",
182
182
  "rollup-plugin-peer-deps-external": "^2.2.4",
183
183
  "semantic-release": "^25.0.3",
184
- "stylelint": "^17.12.0",
184
+ "stylelint": "^17.13.0",
185
185
  "typescript": "^6.0.3",
186
186
  "vite": "^8.0.16"
187
187
  }