@itcase/storybook-config 1.2.75 → 1.2.78
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 +213 -0
- package/dist/cjs/components/EmailTemplatePreview.js +11 -10
- package/dist/cjs/components/FormSubmitWrapper.js +1 -2
- package/dist/cjs/decorators/withClearStoresDecorator.js +8 -8
- package/dist/cjs/decorators/withExtraProviders.js +14 -9
- package/dist/cjs/decorators/withFigmaSourceLink.js +18 -13
- package/dist/cjs/decorators/withFormSubmitDecorator.js +31 -22
- package/dist/cjs/decorators/withLayoutDecorator.js +25 -19
- package/dist/cjs/decorators/withNextDecorator.js +43 -30
- package/dist/cjs/decorators/withUiDecorator.js +12 -7
- package/dist/cjs/decorators.js +2 -2
- package/dist/components/EmailTemplatePreview.js +12 -11
- package/dist/components/FormSubmitWrapper-B2tMQZu2.js +211 -0
- package/dist/components/FormSubmitWrapper.js +1 -2
- package/dist/decorators/withClearStoresDecorator.js +8 -8
- package/dist/decorators/withExtraProviders.js +14 -9
- package/dist/decorators/withFigmaSourceLink.js +18 -13
- package/dist/decorators/withFormSubmitDecorator.js +31 -22
- package/dist/decorators/withLayoutDecorator.js +25 -19
- package/dist/decorators/withNextDecorator.js +43 -30
- package/dist/decorators/withUiDecorator.js +12 -7
- package/dist/decorators.js +2 -2
- package/package.json +44 -44
- package/dist/FormSubmitWrapper-BaqE4w9q.js +0 -248
- package/dist/_rollupPluginBabelHelpers-B1r4NF8e.js +0 -264
- package/dist/components/FormSubmitWrapper-DoGZRTm5.js +0 -246
- package/dist/components/_rollupPluginBabelHelpers-CEVa9ZMs.js +0 -258
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
let BACKEND_URL = process.env.EMAIL_URL;
|
|
4
5
|
if (process.env.NODE_ENV === 'production' && process.env.REST_BASE_URL) {
|
|
5
|
-
BACKEND_URL =
|
|
6
|
+
BACKEND_URL = `${process.env.REST_BASE_URL}/storybook`;
|
|
6
7
|
}
|
|
7
8
|
function EmailTemplatePreview(props) {
|
|
8
|
-
|
|
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(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
30
|
+
emailPreviewIframe?.addEventListener('load', loaded, true);
|
|
30
31
|
});
|
|
31
32
|
if (!BACKEND_URL) {
|
|
32
33
|
return null;
|
|
33
34
|
}
|
|
34
|
-
return /*#__PURE__*/
|
|
35
|
+
return /*#__PURE__*/jsx("iframe", {
|
|
35
36
|
id: "emailPreview",
|
|
36
37
|
width: "100%",
|
|
37
38
|
height: "100%",
|
|
38
|
-
src:
|
|
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,12 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'react';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
3
|
|
|
3
|
-
function withClearStoresDecorator(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return /*#__PURE__*/React.createElement(Story, null);
|
|
4
|
+
function withClearStoresDecorator({
|
|
5
|
+
clearStoreData
|
|
6
|
+
}) {
|
|
7
|
+
const Decorator = Story => {
|
|
8
|
+
clearStoreData();
|
|
9
|
+
return /*#__PURE__*/jsx(Story, {});
|
|
10
10
|
};
|
|
11
11
|
return Decorator;
|
|
12
12
|
}
|
|
@@ -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
|
|
7
|
-
|
|
8
|
-
for (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
currentStory = /*#__PURE__*/
|
|
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
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
const decorator = (Story, {
|
|
63
|
+
parameters,
|
|
64
|
+
context
|
|
65
|
+
}) => {
|
|
66
|
+
const sourceLink = parameters.sourceLink || {};
|
|
66
67
|
if (parameters.design) {
|
|
67
|
-
|
|
68
|
+
const designList = castArray(parameters.design);
|
|
68
69
|
if (!sourceLink.links) {
|
|
69
70
|
sourceLink.links = {};
|
|
70
71
|
}
|
|
71
|
-
designList.forEach(
|
|
72
|
-
|
|
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
|
-
|
|
81
|
-
|
|
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
|
|
2
|
-
import
|
|
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
|
|
|
@@ -1118,32 +1118,41 @@ function hasFormParameters(parameters) {
|
|
|
1118
1118
|
}
|
|
1119
1119
|
|
|
1120
1120
|
function getStoryArgs(storyContext) {
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1121
|
+
const baseContext = storyContext.context ?? storyContext;
|
|
1122
|
+
return {
|
|
1123
|
+
...(storyContext.initialArgs ?? {}),
|
|
1124
|
+
...(baseContext.args ?? {}),
|
|
1125
|
+
...(storyContext.args ?? {})
|
|
1126
|
+
};
|
|
1124
1127
|
}
|
|
1125
1128
|
function enhanceStoryContext(storyContext) {
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
args
|
|
1131
|
-
}
|
|
1129
|
+
const baseContext = storyContext.context ?? storyContext;
|
|
1130
|
+
const args = getStoryArgs(storyContext);
|
|
1131
|
+
return {
|
|
1132
|
+
...baseContext,
|
|
1133
|
+
args
|
|
1134
|
+
};
|
|
1132
1135
|
}
|
|
1133
1136
|
function withFormSubmitDecorator() {
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
+
const decorator = (Story, storyContext) => {
|
|
1138
|
+
const {
|
|
1139
|
+
parameters
|
|
1140
|
+
} = storyContext;
|
|
1141
|
+
const context = enhanceStoryContext(storyContext);
|
|
1137
1142
|
if (!hasFormParameters(parameters)) {
|
|
1138
|
-
return /*#__PURE__*/
|
|
1143
|
+
return /*#__PURE__*/jsx(Story, {
|
|
1144
|
+
...context,
|
|
1139
1145
|
parameters: parameters
|
|
1140
|
-
})
|
|
1146
|
+
});
|
|
1141
1147
|
}
|
|
1142
|
-
return /*#__PURE__*/
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1148
|
+
return /*#__PURE__*/jsx(FormSubmitWrapper, {
|
|
1149
|
+
...context,
|
|
1150
|
+
parameters: parameters,
|
|
1151
|
+
children: /*#__PURE__*/jsx(Story, {
|
|
1152
|
+
...context,
|
|
1153
|
+
parameters: parameters
|
|
1154
|
+
})
|
|
1155
|
+
});
|
|
1147
1156
|
};
|
|
1148
1157
|
return decorator;
|
|
1149
1158
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'react';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
3
|
|
|
3
4
|
function withLayoutDecorator() {
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
+
const layoutClass = layouts[parameters?.layout || ''];
|
|
22
|
+
const maxWidthStyle = {
|
|
21
23
|
width: parameters.maxWidth && '100%',
|
|
22
|
-
maxWidth: parameters
|
|
24
|
+
maxWidth: parameters?.maxWidth
|
|
23
25
|
};
|
|
24
26
|
if (!layoutClass && parameters.maxWidth) {
|
|
25
|
-
return /*#__PURE__*/
|
|
26
|
-
style: maxWidthStyle
|
|
27
|
-
|
|
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__*/
|
|
31
|
-
className: layoutClass
|
|
32
|
-
|
|
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__*/
|
|
36
|
-
className: layoutClass
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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__*/
|
|
47
|
+
return /*#__PURE__*/jsx(Story, {});
|
|
42
48
|
};
|
|
43
49
|
}
|
|
44
50
|
|
|
@@ -1,42 +1,53 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
1
|
+
import 'react';
|
|
3
2
|
import { NotificationWrapper } from '@itcase/ui-web/components/Notification';
|
|
4
3
|
import { UIProvider, NotificationsProvider } from '@itcase/ui-core/context';
|
|
4
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
function withNextDecoratorFactory({
|
|
7
|
+
App,
|
|
8
|
+
RootStoreProvider
|
|
9
|
+
}) {
|
|
10
|
+
const decorator = (Story, {
|
|
11
|
+
args,
|
|
12
|
+
parameters,
|
|
13
|
+
context
|
|
14
|
+
}) => {
|
|
15
|
+
const {
|
|
16
|
+
appArgs,
|
|
17
|
+
appContext,
|
|
18
|
+
appParameters
|
|
19
|
+
} = prepareStoryArguments({
|
|
20
|
+
args,
|
|
21
|
+
parameters,
|
|
22
|
+
context
|
|
23
|
+
});
|
|
22
24
|
if (appParameters.page) {
|
|
23
|
-
return /*#__PURE__*/
|
|
25
|
+
return /*#__PURE__*/jsx(App, {
|
|
24
26
|
Component: Story,
|
|
25
27
|
pageProps: appArgs
|
|
26
28
|
});
|
|
27
29
|
}
|
|
28
|
-
return /*#__PURE__*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
return /*#__PURE__*/jsx(RootStoreProvider, {
|
|
31
|
+
...appArgs.rootStoreInitialData,
|
|
32
|
+
children: /*#__PURE__*/jsx(UIProvider, {
|
|
33
|
+
children: /*#__PURE__*/jsxs(NotificationsProvider, {
|
|
34
|
+
initialNotificationsList: parameters.initialNotificationsList || args.initialNotificationsList || [],
|
|
35
|
+
children: [/*#__PURE__*/jsx(NotificationWrapper, {
|
|
36
|
+
className: "notification_global notification_global_right_top"
|
|
37
|
+
}), /*#__PURE__*/jsx(Story, {
|
|
38
|
+
...appContext
|
|
39
|
+
})]
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
});
|
|
33
43
|
};
|
|
34
44
|
return decorator;
|
|
35
45
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
const prepareStoryArguments = ({
|
|
47
|
+
args,
|
|
48
|
+
parameters,
|
|
49
|
+
context
|
|
50
|
+
}) => {
|
|
40
51
|
if (parameters.storeData || parameters.storesData) {
|
|
41
52
|
throw new Error('"withNextDecoratorFactory" error: "parameters.storesData" is deprecated. Set "storesData" to args instead.');
|
|
42
53
|
}
|
|
@@ -46,8 +57,10 @@ var prepareStoryArguments = function prepareStoryArguments(_ref3) {
|
|
|
46
57
|
if (args.rootStoreInitialData) {
|
|
47
58
|
throw new Error('"withNextDecoratorFactory" error: do not user "args.rootStoreInitialData". Use "storesData" argument he passes parameters to rootStoreInitialData.');
|
|
48
59
|
}
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
const {
|
|
61
|
+
storesData,
|
|
62
|
+
...otherArgs
|
|
63
|
+
} = args;
|
|
51
64
|
otherArgs.rootStoreInitialData = storesData;
|
|
52
65
|
return {
|
|
53
66
|
appArgs: otherArgs,
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'react';
|
|
2
2
|
import { NotificationWrapper } from '@itcase/ui-web/components/Notification';
|
|
3
3
|
import { UIProvider, NotificationsProvider } from '@itcase/ui-core/context';
|
|
4
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
5
|
|
|
5
|
-
function withUiDecorator(Story,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
function withUiDecorator(Story, {
|
|
7
|
+
args,
|
|
8
|
+
parameters
|
|
9
|
+
}) {
|
|
10
|
+
return /*#__PURE__*/jsx(UIProvider, {
|
|
11
|
+
children: /*#__PURE__*/jsxs(NotificationsProvider, {
|
|
12
|
+
initialNotificationsList: parameters.initialNotificationsList || args.initialNotificationsList || [],
|
|
13
|
+
children: [/*#__PURE__*/jsx(NotificationWrapper, {}), /*#__PURE__*/jsx(Story, {})]
|
|
14
|
+
})
|
|
15
|
+
});
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
export { withUiDecorator };
|
package/dist/decorators.js
CHANGED
|
@@ -6,9 +6,9 @@ export { withLayoutDecorator } from './decorators/withLayoutDecorator.js';
|
|
|
6
6
|
export { withNextDecoratorFactory } from './decorators/withNextDecorator.js';
|
|
7
7
|
export { withUiDecorator } from './decorators/withUiDecorator.js';
|
|
8
8
|
import 'react';
|
|
9
|
-
import '
|
|
9
|
+
import 'react/jsx-runtime';
|
|
10
10
|
import './components/isArray-CPoGkdXv.js';
|
|
11
|
-
import './components/FormSubmitWrapper-
|
|
11
|
+
import './components/FormSubmitWrapper-B2tMQZu2.js';
|
|
12
12
|
import '@itcase/common';
|
|
13
13
|
import 'msw';
|
|
14
14
|
import 'final-form';
|