@itcase/storybook-config 1.2.75 → 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.
Files changed (27) hide show
  1. package/dist/FormSubmitWrapper-_VeLgVir.js +213 -0
  2. package/dist/cjs/components/EmailTemplatePreview.js +11 -10
  3. package/dist/cjs/components/FormSubmitWrapper.js +1 -2
  4. package/dist/cjs/decorators/withClearStoresDecorator.js +18 -7
  5. package/dist/cjs/decorators/withExtraProviders.js +14 -9
  6. package/dist/cjs/decorators/withFigmaSourceLink.js +18 -13
  7. package/dist/cjs/decorators/withFormSubmitDecorator.js +31 -22
  8. package/dist/cjs/decorators/withLayoutDecorator.js +25 -19
  9. package/dist/cjs/decorators/withNextDecorator.js +43 -30
  10. package/dist/cjs/decorators/withUiDecorator.js +12 -7
  11. package/dist/cjs/decorators.js +2 -2
  12. package/dist/components/EmailTemplatePreview.js +12 -11
  13. package/dist/components/FormSubmitWrapper-B2tMQZu2.js +211 -0
  14. package/dist/components/FormSubmitWrapper.js +1 -2
  15. package/dist/decorators/withClearStoresDecorator.js +19 -8
  16. package/dist/decorators/withExtraProviders.js +14 -9
  17. package/dist/decorators/withFigmaSourceLink.js +18 -13
  18. package/dist/decorators/withFormSubmitDecorator.js +31 -22
  19. package/dist/decorators/withLayoutDecorator.js +25 -19
  20. package/dist/decorators/withNextDecorator.js +43 -30
  21. package/dist/decorators/withUiDecorator.js +12 -7
  22. package/dist/decorators.js +2 -2
  23. package/package.json +44 -44
  24. package/dist/FormSubmitWrapper-BaqE4w9q.js +0 -248
  25. package/dist/_rollupPluginBabelHelpers-B1r4NF8e.js +0 -264
  26. package/dist/components/FormSubmitWrapper-DoGZRTm5.js +0 -246
  27. package/dist/components/_rollupPluginBabelHelpers-CEVa9ZMs.js +0 -258
@@ -0,0 +1,213 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ const SUBMIT_POLL_MS = 50;
6
+ function getStoryPreviewDocument() {
7
+ const previewIframe = document.getElementById('storybook-preview-iframe') ?? document.querySelector('iframe[data-is-storybook="true"]');
8
+ return previewIframe?.contentDocument ?? null;
9
+ }
10
+ function getMountRoot() {
11
+ const previewDocument = getStoryPreviewDocument();
12
+ if (previewDocument) {
13
+ return previewDocument.getElementById('storybook-root') ?? previewDocument.getElementById('root') ?? previewDocument.body;
14
+ }
15
+ return document.getElementById('storybook-root') ?? document.getElementById('root') ?? document.body;
16
+ }
17
+ function canSubmitFormApi(form) {
18
+ return typeof form?.submit === 'function' && typeof form.getRegisteredFields === 'function' && form.getRegisteredFields().length > 0;
19
+ }
20
+ function findSaveDraftButton(root) {
21
+ if (!root) {
22
+ return null;
23
+ }
24
+ const saveDraft = root.querySelector('[data-testid$="SaveDraftButton"]');
25
+ if (!saveDraft) {
26
+ return null;
27
+ }
28
+ return saveDraft.tagName === 'BUTTON' ? saveDraft : saveDraft.querySelector('button');
29
+ }
30
+ function findSubmitButton(root) {
31
+ if (!root) {
32
+ return null;
33
+ }
34
+ const byType = root.querySelector('button[type="submit"]');
35
+ if (byType) {
36
+ return byType;
37
+ }
38
+ const form = root.querySelector('form[data-testid], form');
39
+ if (!form) {
40
+ return null;
41
+ }
42
+ return form.querySelector('.form__button .form__button-item, .form__button-item') ?? null;
43
+ }
44
+ function touchFieldsBeforeSubmit(form) {
45
+ if (!canSubmitFormApi(form)) {
46
+ return;
47
+ }
48
+ for (const fieldName of form.getRegisteredFields()) {
49
+ if (!form.getFieldState(fieldName)?.touched) {
50
+ form.blur(fieldName);
51
+ }
52
+ }
53
+ }
54
+ function triggerFormSubmit({
55
+ form,
56
+ root,
57
+ submitButton
58
+ }) {
59
+ const saveDraftButton = findSaveDraftButton(root ?? getMountRoot());
60
+ if (saveDraftButton) {
61
+ saveDraftButton.click();
62
+ return;
63
+ }
64
+ if (canSubmitFormApi(form)) {
65
+ touchFieldsBeforeSubmit(form);
66
+ form.submit();
67
+ return;
68
+ }
69
+ if (submitButton?.type === 'submit') {
70
+ submitButton.click();
71
+ }
72
+ }
73
+ async function autoSubmitForm(formRef, signal) {
74
+ if (formRef.__itcaseDidAutoSubmit) {
75
+ return;
76
+ }
77
+ while (!signal.aborted) {
78
+ const root = getMountRoot();
79
+ const form = formRef.current;
80
+ const submitButton = findSubmitButton(root);
81
+ const saveDraftButton = findSaveDraftButton(root);
82
+ const canSubmitViaFormApi = canSubmitFormApi(form);
83
+ const canClickNativeSubmit = submitButton?.type === 'submit';
84
+ const canClickSaveDraft = Boolean(saveDraftButton);
85
+
86
+ // primaryButtonHtmlType="button": ждём final-form API или кнопку черновика в DOM
87
+ if (!canSubmitViaFormApi && !canClickNativeSubmit && !canClickSaveDraft) {
88
+ await new Promise(resolve => {
89
+ setTimeout(resolve, SUBMIT_POLL_MS);
90
+ });
91
+ continue;
92
+ }
93
+ formRef.__itcaseDidAutoSubmit = true;
94
+ await new Promise(resolve => {
95
+ requestAnimationFrame(() => {
96
+ requestAnimationFrame(resolve);
97
+ });
98
+ });
99
+ if (signal.aborted) {
100
+ return;
101
+ }
102
+ triggerFormSubmit({
103
+ form: formRef.current,
104
+ root,
105
+ submitButton
106
+ });
107
+ return;
108
+ }
109
+ }
110
+
111
+ function wrapRender(component, render, formRef, defaultArgs = {}) {
112
+ if (typeof render !== 'function') {
113
+ return render;
114
+ }
115
+ return function renderWithRef(storyArgs) {
116
+ const args = {
117
+ ...defaultArgs,
118
+ ...(storyArgs ?? {})
119
+ };
120
+ delete args.ref;
121
+ delete args.errors;
122
+ if (!args.onSubmit && defaultArgs.onSubmit) {
123
+ args.onSubmit = defaultArgs.onSubmit;
124
+ }
125
+ const rendered = render(args);
126
+ if (/*#__PURE__*/React.isValidElement(rendered)) {
127
+ return /*#__PURE__*/React.cloneElement(rendered, {
128
+ ...rendered.props,
129
+ ...args,
130
+ ref: formRef
131
+ });
132
+ }
133
+ if (component) {
134
+ return /*#__PURE__*/React.createElement(component, {
135
+ ref: formRef,
136
+ ...args
137
+ });
138
+ }
139
+ return rendered;
140
+ };
141
+ }
142
+ function withFormRef(children, formRef, bindings) {
143
+ const {
144
+ component,
145
+ args,
146
+ render: storyRender,
147
+ allArgs,
148
+ context
149
+ } = bindings;
150
+ const storyArgs = args ?? context?.args ?? children?.props?.args ?? {};
151
+ const storyComponent = component ?? context?.component ?? children?.props?.component;
152
+ const storyRenderFn = storyRender ?? context?.render ?? children?.props?.render;
153
+ const boundRender = wrapRender(storyComponent, storyRenderFn, formRef, storyArgs);
154
+ const addRef = value => value ? {
155
+ ...value,
156
+ ref: formRef
157
+ } : value;
158
+ return /*#__PURE__*/React.cloneElement(children, {
159
+ component: storyComponent,
160
+ args: addRef(storyArgs),
161
+ render: boundRender,
162
+ allArgs: addRef(allArgs),
163
+ context: context ? {
164
+ ...context,
165
+ component: storyComponent,
166
+ args: addRef(context.args),
167
+ render: boundRender,
168
+ allArgs: addRef(context.allArgs)
169
+ } : context
170
+ });
171
+ }
172
+
173
+ /**
174
+ * Авто-submit для интерактивного Storybook (Require / Validation / ServerError).
175
+ * При primaryButtonHtmlType="button" — formRef.current.submit() (final-form API),
176
+ * при type="submit" — click по кнопке. В Vitest submit в play.
177
+ */
178
+ function FormSubmitWrapper(props) {
179
+ const formRef = React.useRef(null);
180
+ const {
181
+ component,
182
+ args,
183
+ render,
184
+ allArgs,
185
+ context,
186
+ submit = true,
187
+ children
188
+ } = props;
189
+ const storyArgs = args ?? context?.args ?? children?.props?.args ?? {};
190
+ React.useEffect(() => {
191
+ if (!submit) {
192
+ return undefined;
193
+ }
194
+ delete formRef.__itcaseDidAutoSubmit;
195
+ const abortController = new AbortController();
196
+ autoSubmitForm(formRef, abortController.signal);
197
+ return () => {
198
+ abortController.abort();
199
+ delete formRef.__itcaseDidAutoSubmit;
200
+ };
201
+ }, [submit, storyArgs.errors]);
202
+
203
+ // eslint-disable-next-line react-hooks/refs -- ref уходит в cloneElement внутри bound render
204
+ return withFormRef(children, formRef, {
205
+ component,
206
+ args: storyArgs,
207
+ render,
208
+ allArgs,
209
+ context
210
+ });
211
+ }
212
+
213
+ exports.FormSubmitWrapper = FormSubmitWrapper;
@@ -1,13 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
+ var jsxRuntime = require('react/jsx-runtime');
4
5
 
5
- var BACKEND_URL = process.env.EMAIL_URL;
6
+ let BACKEND_URL = process.env.EMAIL_URL;
6
7
  if (process.env.NODE_ENV === 'production' && process.env.REST_BASE_URL) {
7
- BACKEND_URL = "".concat(process.env.REST_BASE_URL, "/storybook");
8
+ BACKEND_URL = `${process.env.REST_BASE_URL}/storybook`;
8
9
  }
9
10
  function EmailTemplatePreview(props) {
10
- var style = {
11
+ const style = {
11
12
  width: '100%',
12
13
  height: '100%',
13
14
  border: '0',
@@ -20,24 +21,24 @@ function EmailTemplatePreview(props) {
20
21
  overflowX: 'hidden',
21
22
  overflowY: 'hidden'
22
23
  };
23
- React.useEffect(function () {
24
- var emailPreviewIframe = document.getElementById('emailPreview');
25
- var loaded = function loaded() {
26
- var email = emailPreviewIframe.getElementsByClassName('email-body').length;
24
+ React.useEffect(() => {
25
+ const emailPreviewIframe = document.getElementById('emailPreview');
26
+ const loaded = () => {
27
+ const email = emailPreviewIframe.getElementsByClassName('email-body').length;
27
28
  if (!email && process.env.EMAIL_URL && process.env.EMAIL_URL.includes('http://')) {
28
29
  alert('Need to run the backend server to display email templates, use: python manage.py runserver');
29
30
  }
30
31
  };
31
- emailPreviewIframe === null || emailPreviewIframe === void 0 || emailPreviewIframe.addEventListener('load', loaded, true);
32
+ emailPreviewIframe?.addEventListener('load', loaded, true);
32
33
  });
33
34
  if (!BACKEND_URL) {
34
35
  return null;
35
36
  }
36
- return /*#__PURE__*/React.createElement("iframe", {
37
+ return /*#__PURE__*/jsxRuntime.jsx("iframe", {
37
38
  id: "emailPreview",
38
39
  width: "100%",
39
40
  height: "100%",
40
- src: "".concat(BACKEND_URL).concat(props.url),
41
+ src: `${BACKEND_URL}${props.url}`,
41
42
  style: style
42
43
  });
43
44
  }
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var FormSubmitWrapper = require('../../FormSubmitWrapper-BaqE4w9q.js');
4
- require('../../_rollupPluginBabelHelpers-B1r4NF8e.js');
3
+ var FormSubmitWrapper = require('../../FormSubmitWrapper-_VeLgVir.js');
5
4
  require('react');
6
5
 
7
6
 
@@ -1,14 +1,25 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
+ var jsxRuntime = require('react/jsx-runtime');
4
5
 
5
- function withClearStoresDecorator(_ref) {
6
- var clearStoreData = _ref.clearStoreData;
7
- var Decorator = function Decorator(Story) {
8
- React.useMemo(function () {
9
- clearStoreData();
10
- }, [Story]);
11
- return /*#__PURE__*/React.createElement(Story, null);
6
+ function ClearStoresWrapper({
7
+ clearStoreData,
8
+ Story
9
+ }) {
10
+ React.useEffect(() => {
11
+ clearStoreData();
12
+ }, [Story, clearStoreData]);
13
+ return /*#__PURE__*/jsxRuntime.jsx(Story, {});
14
+ }
15
+ function withClearStoresDecorator({
16
+ clearStoreData
17
+ }) {
18
+ const Decorator = Story => {
19
+ return /*#__PURE__*/jsxRuntime.jsx(ClearStoresWrapper, {
20
+ clearStoreData: clearStoreData,
21
+ Story: Story
22
+ });
12
23
  };
13
24
  return Decorator;
14
25
  }
@@ -1,17 +1,22 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
+ var jsxRuntime = require('react/jsx-runtime');
4
5
 
5
- function withExtraProviders() {
6
- var providers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
6
+ function withExtraProviders(providers = []) {
7
7
  if (!Array.isArray(providers)) throw new Error('withExtraProviders requires an array of components');
8
- return function (StoryFn, context) {
9
- var currentStory = StoryFn(context);
10
- for (var i = providers.length - 1; i >= 0; i--) {
11
- var item = providers[i];
12
- var Component = item.provider;
13
- var props = item.props || {};
14
- currentStory = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Component, props, currentStory));
8
+ return (StoryFn, context) => {
9
+ let currentStory = StoryFn(context);
10
+ for (let i = providers.length - 1; i >= 0; i--) {
11
+ const item = providers[i];
12
+ const Component = item.provider;
13
+ const props = item.props || {};
14
+ currentStory = /*#__PURE__*/jsxRuntime.jsx(React.Fragment, {
15
+ children: /*#__PURE__*/jsxRuntime.jsx(Component, {
16
+ ...props,
17
+ children: currentStory
18
+ })
19
+ });
15
20
  }
16
21
  return currentStory;
17
22
  };
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var _rollupPluginBabelHelpers = require('../../_rollupPluginBabelHelpers-B1r4NF8e.js');
4
- var React = require('react');
3
+ require('react');
5
4
  var isArray = require('../../isArray-DJguRq_2.js');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
6
 
7
7
  var castArray_1;
8
8
  var hasRequiredCastArray;
@@ -61,17 +61,18 @@ var castArrayExports = requireCastArray();
61
61
  var castArray = /*@__PURE__*/isArray.getDefaultExportFromCjs(castArrayExports);
62
62
 
63
63
  function withFigmaSourceLink() {
64
- var decorator = function decorator(Story, _ref) {
65
- var parameters = _ref.parameters,
66
- context = _ref.context;
67
- var sourceLink = parameters.sourceLink || {};
64
+ const decorator = (Story, {
65
+ parameters,
66
+ context
67
+ }) => {
68
+ const sourceLink = parameters.sourceLink || {};
68
69
  if (parameters.design) {
69
- var designList = castArray(parameters.design);
70
+ const designList = castArray(parameters.design);
70
71
  if (!sourceLink.links) {
71
72
  sourceLink.links = {};
72
73
  }
73
- designList.forEach(function (design) {
74
- var groupKey = "".concat(design.type).concat(design.name || '');
74
+ designList.forEach(design => {
75
+ const groupKey = `${design.type}${design.name || ''}`;
75
76
  sourceLink.links[groupKey] = {
76
77
  label: 'Figma — ' + context.title + (design.name ? ' / ' + design.name : ''),
77
78
  href: design.url,
@@ -79,12 +80,16 @@ function withFigmaSourceLink() {
79
80
  };
80
81
  });
81
82
  }
82
- var updatedContext = _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, context), {}, {
83
- parameters: _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, context.parameters), {}, {
83
+ const updatedContext = {
84
+ ...context,
85
+ parameters: {
86
+ ...context.parameters,
84
87
  sourceLink: sourceLink
85
- })
88
+ }
89
+ };
90
+ return /*#__PURE__*/jsxRuntime.jsx(Story, {
91
+ ...updatedContext
86
92
  });
87
- return /*#__PURE__*/React.createElement(Story, updatedContext);
88
93
  };
89
94
  return decorator;
90
95
  }
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var _rollupPluginBabelHelpers = require('../../_rollupPluginBabelHelpers-B1r4NF8e.js');
4
- var React = require('react');
5
- var FormSubmitWrapper = require('../../FormSubmitWrapper-BaqE4w9q.js');
3
+ require('react');
4
+ var FormSubmitWrapper = require('../../FormSubmitWrapper-_VeLgVir.js');
6
5
  var isArray = require('../../isArray-DJguRq_2.js');
7
6
  require('@itcase/common');
8
7
  require('msw');
9
8
  require('final-form');
9
+ var jsxRuntime = require('react/jsx-runtime');
10
10
 
11
11
  /** Detect free variable `global` from Node.js. */
12
12
 
@@ -1120,32 +1120,41 @@ function hasFormParameters(parameters) {
1120
1120
  }
1121
1121
 
1122
1122
  function getStoryArgs(storyContext) {
1123
- var _storyContext$context, _storyContext$initial, _baseContext$args, _storyContext$args;
1124
- var baseContext = (_storyContext$context = storyContext.context) !== null && _storyContext$context !== void 0 ? _storyContext$context : storyContext;
1125
- return _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, (_storyContext$initial = storyContext.initialArgs) !== null && _storyContext$initial !== void 0 ? _storyContext$initial : {}), (_baseContext$args = baseContext.args) !== null && _baseContext$args !== void 0 ? _baseContext$args : {}), (_storyContext$args = storyContext.args) !== null && _storyContext$args !== void 0 ? _storyContext$args : {});
1123
+ const baseContext = storyContext.context ?? storyContext;
1124
+ return {
1125
+ ...(storyContext.initialArgs ?? {}),
1126
+ ...(baseContext.args ?? {}),
1127
+ ...(storyContext.args ?? {})
1128
+ };
1126
1129
  }
1127
1130
  function enhanceStoryContext(storyContext) {
1128
- var _storyContext$context2;
1129
- var baseContext = (_storyContext$context2 = storyContext.context) !== null && _storyContext$context2 !== void 0 ? _storyContext$context2 : storyContext;
1130
- var args = getStoryArgs(storyContext);
1131
- return _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, baseContext), {}, {
1132
- args: args
1133
- });
1131
+ const baseContext = storyContext.context ?? storyContext;
1132
+ const args = getStoryArgs(storyContext);
1133
+ return {
1134
+ ...baseContext,
1135
+ args
1136
+ };
1134
1137
  }
1135
1138
  function withFormSubmitDecorator() {
1136
- var decorator = function decorator(Story, storyContext) {
1137
- var parameters = storyContext.parameters;
1138
- var context = enhanceStoryContext(storyContext);
1139
+ const decorator = (Story, storyContext) => {
1140
+ const {
1141
+ parameters
1142
+ } = storyContext;
1143
+ const context = enhanceStoryContext(storyContext);
1139
1144
  if (!hasFormParameters(parameters)) {
1140
- return /*#__PURE__*/React.createElement(Story, Object.assign({}, context, {
1145
+ return /*#__PURE__*/jsxRuntime.jsx(Story, {
1146
+ ...context,
1141
1147
  parameters: parameters
1142
- }));
1148
+ });
1143
1149
  }
1144
- return /*#__PURE__*/React.createElement(FormSubmitWrapper.FormSubmitWrapper, Object.assign({}, context, {
1145
- parameters: parameters
1146
- }), /*#__PURE__*/React.createElement(Story, Object.assign({}, context, {
1147
- parameters: parameters
1148
- })));
1150
+ return /*#__PURE__*/jsxRuntime.jsx(FormSubmitWrapper.FormSubmitWrapper, {
1151
+ ...context,
1152
+ parameters: parameters,
1153
+ children: /*#__PURE__*/jsxRuntime.jsx(Story, {
1154
+ ...context,
1155
+ parameters: parameters
1156
+ })
1157
+ });
1149
1158
  };
1150
1159
  return decorator;
1151
1160
  }
@@ -1,11 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var React = require('react');
3
+ require('react');
4
+ var jsxRuntime = require('react/jsx-runtime');
4
5
 
5
6
  function withLayoutDecorator() {
6
- return function (Story, _ref) {
7
- var parameters = _ref.parameters;
8
- var layouts = {
7
+ return (Story, {
8
+ parameters
9
+ }) => {
10
+ const layouts = {
9
11
  top: 'sb-layout-top',
10
12
  right: 'sb-layout-right',
11
13
  bottom: 'sb-layout-bottom',
@@ -18,29 +20,33 @@ function withLayoutDecorator() {
18
20
  rightFull: 'sb-layout-right-full',
19
21
  topFull: 'sb-layout-top-full'
20
22
  };
21
- var layoutClass = layouts[(parameters === null || parameters === void 0 ? void 0 : parameters.layout) || ''];
22
- var maxWidthStyle = {
23
+ const layoutClass = layouts[parameters?.layout || ''];
24
+ const maxWidthStyle = {
23
25
  width: parameters.maxWidth && '100%',
24
- maxWidth: parameters === null || parameters === void 0 ? void 0 : parameters.maxWidth
26
+ maxWidth: parameters?.maxWidth
25
27
  };
26
28
  if (!layoutClass && parameters.maxWidth) {
27
- return /*#__PURE__*/React.createElement("div", {
28
- style: maxWidthStyle
29
- }, /*#__PURE__*/React.createElement(Story, null));
29
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
30
+ style: maxWidthStyle,
31
+ children: /*#__PURE__*/jsxRuntime.jsx(Story, {})
32
+ });
30
33
  }
31
34
  if (layoutClass && !parameters.maxWidth) {
32
- return /*#__PURE__*/React.createElement("div", {
33
- className: layoutClass
34
- }, /*#__PURE__*/React.createElement(Story, null));
35
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
36
+ className: layoutClass,
37
+ children: /*#__PURE__*/jsxRuntime.jsx(Story, {})
38
+ });
35
39
  }
36
40
  if (layoutClass && parameters.maxWidth) {
37
- return /*#__PURE__*/React.createElement("div", {
38
- className: layoutClass
39
- }, /*#__PURE__*/React.createElement("div", {
40
- style: maxWidthStyle
41
- }, /*#__PURE__*/React.createElement(Story, null)));
41
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
42
+ className: layoutClass,
43
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
44
+ style: maxWidthStyle,
45
+ children: /*#__PURE__*/jsxRuntime.jsx(Story, {})
46
+ })
47
+ });
42
48
  }
43
- return /*#__PURE__*/React.createElement(Story, null);
49
+ return /*#__PURE__*/jsxRuntime.jsx(Story, {});
44
50
  };
45
51
  }
46
52
 
@@ -1,44 +1,55 @@
1
1
  'use strict';
2
2
 
3
- var _rollupPluginBabelHelpers = require('../../_rollupPluginBabelHelpers-B1r4NF8e.js');
4
- var React = require('react');
3
+ require('react');
5
4
  var Notification = require('@itcase/ui-web/components/Notification');
6
5
  var context = require('@itcase/ui-core/context');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
7
 
8
- var _excluded = ["storesData"];
9
- function withNextDecoratorFactory(_ref) {
10
- var App = _ref.App,
11
- RootStoreProvider = _ref.RootStoreProvider;
12
- var decorator = function decorator(Story, _ref2) {
13
- var args = _ref2.args,
14
- parameters = _ref2.parameters,
15
- context$1 = _ref2.context;
16
- var _prepareStoryArgument = prepareStoryArguments({
17
- args: args,
18
- parameters: parameters,
19
- context: context$1
20
- }),
21
- appArgs = _prepareStoryArgument.appArgs,
22
- appContext = _prepareStoryArgument.appContext,
23
- appParameters = _prepareStoryArgument.appParameters;
8
+ function withNextDecoratorFactory({
9
+ App,
10
+ RootStoreProvider
11
+ }) {
12
+ const decorator = (Story, {
13
+ args,
14
+ parameters,
15
+ context: context$1
16
+ }) => {
17
+ const {
18
+ appArgs,
19
+ appContext,
20
+ appParameters
21
+ } = prepareStoryArguments({
22
+ args,
23
+ parameters,
24
+ context: context$1
25
+ });
24
26
  if (appParameters.page) {
25
- return /*#__PURE__*/React.createElement(App, {
27
+ return /*#__PURE__*/jsxRuntime.jsx(App, {
26
28
  Component: Story,
27
29
  pageProps: appArgs
28
30
  });
29
31
  }
30
- return /*#__PURE__*/React.createElement(RootStoreProvider, appArgs.rootStoreInitialData, /*#__PURE__*/React.createElement(context.UIProvider, null, /*#__PURE__*/React.createElement(context.NotificationsProvider, {
31
- initialNotificationsList: parameters.initialNotificationsList || args.initialNotificationsList || []
32
- }, /*#__PURE__*/React.createElement(Notification.NotificationWrapper, {
33
- className: "notification_global notification_global_right_top"
34
- }), /*#__PURE__*/React.createElement(Story, appContext))));
32
+ return /*#__PURE__*/jsxRuntime.jsx(RootStoreProvider, {
33
+ ...appArgs.rootStoreInitialData,
34
+ children: /*#__PURE__*/jsxRuntime.jsx(context.UIProvider, {
35
+ children: /*#__PURE__*/jsxRuntime.jsxs(context.NotificationsProvider, {
36
+ initialNotificationsList: parameters.initialNotificationsList || args.initialNotificationsList || [],
37
+ children: [/*#__PURE__*/jsxRuntime.jsx(Notification.NotificationWrapper, {
38
+ className: "notification_global notification_global_right_top"
39
+ }), /*#__PURE__*/jsxRuntime.jsx(Story, {
40
+ ...appContext
41
+ })]
42
+ })
43
+ })
44
+ });
35
45
  };
36
46
  return decorator;
37
47
  }
38
- var prepareStoryArguments = function prepareStoryArguments(_ref3) {
39
- var args = _ref3.args,
40
- parameters = _ref3.parameters,
41
- context = _ref3.context;
48
+ const prepareStoryArguments = ({
49
+ args,
50
+ parameters,
51
+ context
52
+ }) => {
42
53
  if (parameters.storeData || parameters.storesData) {
43
54
  throw new Error('"withNextDecoratorFactory" error: "parameters.storesData" is deprecated. Set "storesData" to args instead.');
44
55
  }
@@ -48,8 +59,10 @@ var prepareStoryArguments = function prepareStoryArguments(_ref3) {
48
59
  if (args.rootStoreInitialData) {
49
60
  throw new Error('"withNextDecoratorFactory" error: do not user "args.rootStoreInitialData". Use "storesData" argument he passes parameters to rootStoreInitialData.');
50
61
  }
51
- var storesData = args.storesData,
52
- otherArgs = _rollupPluginBabelHelpers._objectWithoutProperties(args, _excluded);
62
+ const {
63
+ storesData,
64
+ ...otherArgs
65
+ } = args;
53
66
  otherArgs.rootStoreInitialData = storesData;
54
67
  return {
55
68
  appArgs: otherArgs,
@@ -1,15 +1,20 @@
1
1
  'use strict';
2
2
 
3
- var React = require('react');
3
+ require('react');
4
4
  var Notification = require('@itcase/ui-web/components/Notification');
5
5
  var context = require('@itcase/ui-core/context');
6
+ var jsxRuntime = require('react/jsx-runtime');
6
7
 
7
- function withUiDecorator(Story, _ref) {
8
- var args = _ref.args,
9
- parameters = _ref.parameters;
10
- return /*#__PURE__*/React.createElement(context.UIProvider, null, /*#__PURE__*/React.createElement(context.NotificationsProvider, {
11
- initialNotificationsList: parameters.initialNotificationsList || args.initialNotificationsList || []
12
- }, /*#__PURE__*/React.createElement(Notification.NotificationWrapper, null), /*#__PURE__*/React.createElement(Story, null)));
8
+ function withUiDecorator(Story, {
9
+ args,
10
+ parameters
11
+ }) {
12
+ return /*#__PURE__*/jsxRuntime.jsx(context.UIProvider, {
13
+ children: /*#__PURE__*/jsxRuntime.jsxs(context.NotificationsProvider, {
14
+ initialNotificationsList: parameters.initialNotificationsList || args.initialNotificationsList || [],
15
+ children: [/*#__PURE__*/jsxRuntime.jsx(Notification.NotificationWrapper, {}), /*#__PURE__*/jsxRuntime.jsx(Story, {})]
16
+ })
17
+ });
13
18
  }
14
19
 
15
20
  exports.withUiDecorator = withUiDecorator;