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