@itcase/storybook-config 1.3.21 → 1.3.23
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/README.md +0 -8
- package/dist/addons/print/constants.d.ts +3 -0
- package/dist/addons/print/constants.js +3 -0
- package/dist/addons/print/manager.d.ts +1 -0
- package/dist/addons/print/manager.js +43 -0
- package/dist/addons/print/preview.d.ts +1 -0
- package/dist/addons/print/preview.js +1 -0
- package/dist/addons/print/print.css +13 -0
- package/dist/addons/variants/VariantsCanvas.d.ts +4 -0
- package/dist/addons/variants/VariantsCanvas.js +137 -0
- package/dist/addons/variants/VariantsControl.d.ts +3 -0
- package/dist/addons/variants/VariantsControl.js +51 -0
- package/dist/addons/variants/constants.d.ts +6 -0
- package/dist/addons/variants/constants.js +6 -0
- package/dist/addons/variants/manager.d.ts +1 -0
- package/dist/addons/variants/manager.js +117 -0
- package/dist/addons/variants/preview.d.ts +11 -0
- package/dist/addons/variants/preview.js +41 -0
- package/dist/addons/variants/variants.helpers.d.ts +13 -0
- package/dist/addons/variants/variants.helpers.js +145 -0
- package/dist/addons/variants/variants.interface.d.ts +42 -0
- package/dist/addons/variants/variants.interface.js +1 -0
- package/dist/cjs/decorators/withA4PaperDecorator.js +52 -0
- package/dist/cjs/decorators.js +2 -0
- package/dist/config/addons/addonPrint.d.ts +2 -0
- package/dist/config/addons/addonPrint.js +2 -0
- package/dist/config/addons/addonVariants.d.ts +2 -0
- package/dist/config/addons/addonVariants.js +2 -0
- package/dist/config/addons/addonsNextJs.js +4 -0
- package/dist/config/addons/addonsVite.js +4 -0
- package/dist/config/addons/withLocalAddons.js +4 -0
- package/dist/config/main/index.d.ts +3 -4
- package/dist/config/main/index.js +3 -4
- package/dist/decorators/index.d.ts +2 -1
- package/dist/decorators/index.js +2 -1
- package/dist/decorators/withA4PaperDecorator.d.ts +3 -0
- package/dist/decorators/withA4PaperDecorator.js +50 -0
- package/dist/decorators.js +1 -0
- package/package.json +53 -37
- package/dist/config/addons/addonsWebpack.d.ts +0 -18
- package/dist/config/addons/addonsWebpack.js +0 -33
- package/dist/config/framework/frameworkWebpack.d.ts +0 -11
- package/dist/config/framework/frameworkWebpack.js +0 -11
- package/dist/config/static/staticDirsWebpack.d.ts +0 -5
- package/dist/config/static/staticDirsWebpack.js +0 -2
package/README.md
CHANGED
|
@@ -8,14 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
Перед запуском установите зависимости: `npm install`.
|
|
10
10
|
|
|
11
|
-
### React (Webpack)
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm run storybook-react-webpack
|
|
15
|
-
# или через Makefile (с очисткой кэша):
|
|
16
|
-
make storybook-react-webpack
|
|
17
|
-
```
|
|
18
|
-
|
|
19
11
|
### React (Vite)
|
|
20
12
|
|
|
21
13
|
```bash
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { PrintIcon } from '@storybook/icons';
|
|
3
|
+
import { Button } from 'storybook/internal/components';
|
|
4
|
+
import { addons, types, useGlobals } from 'storybook/manager-api';
|
|
5
|
+
import { PRINT_ADDON_ID, PRINT_TOOL_ID } from './constants.js';
|
|
6
|
+
function printViewport() {
|
|
7
|
+
const previewFrame = document.getElementById('storybook-preview-iframe');
|
|
8
|
+
if (!(previewFrame instanceof HTMLIFrameElement)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const previewWindow = previewFrame.contentWindow;
|
|
12
|
+
if (!previewWindow) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
previewWindow.focus();
|
|
16
|
+
previewWindow.print();
|
|
17
|
+
}
|
|
18
|
+
function isA4Viewport(viewport) {
|
|
19
|
+
if (viewport === 'a4') {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (typeof viewport !== 'object' ||
|
|
23
|
+
viewport === null ||
|
|
24
|
+
!('value' in viewport)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return viewport.value === 'a4';
|
|
28
|
+
}
|
|
29
|
+
function PrintTool() {
|
|
30
|
+
const [globals] = useGlobals();
|
|
31
|
+
if (!isA4Viewport(globals.viewport)) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return (_jsxs(Button, { size: "small", padding: "small", "aria-label": "Print viewport", variant: "ghost", onClick: printViewport, children: [_jsx(PrintIcon, {}), "Print"] }));
|
|
35
|
+
}
|
|
36
|
+
addons.register(PRINT_ADDON_ID, () => {
|
|
37
|
+
addons.add(PRINT_TOOL_ID, {
|
|
38
|
+
type: types.TOOL,
|
|
39
|
+
title: 'Print',
|
|
40
|
+
match: ({ viewMode }) => viewMode === 'story',
|
|
41
|
+
render: PrintTool,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './print.css';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './print.css';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* Viewport and #storybook-root clip the iframe. Print needs the full story. */
|
|
2
|
+
@media print {
|
|
3
|
+
html,
|
|
4
|
+
body.sb-show-main,
|
|
5
|
+
#storybook-root {
|
|
6
|
+
height: auto !important;
|
|
7
|
+
min-height: 0 !important;
|
|
8
|
+
max-height: none !important;
|
|
9
|
+
background: white !important;
|
|
10
|
+
overflow: visible !important;
|
|
11
|
+
transform: none !important;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { VariantsPropertyListProps } from './variants.interface.js';
|
|
2
|
+
declare function VariantsSwitchList(props: VariantsPropertyListProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare function VariantsCanvas(props: VariantsPropertyListProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export { VariantsCanvas, VariantsSwitchList };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { ChevronSmallDownIcon } from '@storybook/icons';
|
|
4
|
+
import { Badge } from 'storybook/internal/components';
|
|
5
|
+
import { ensure, styled, ThemeProvider, themes } from 'storybook/theming';
|
|
6
|
+
import { findVariant, getPropertyControl, getPropertyNames, getPropertyOptions, getPropertyValue, } from './variants.helpers.js';
|
|
7
|
+
const theme = ensure(themes.light);
|
|
8
|
+
const Panel = styled.div(({ theme: storybookTheme }) => ({
|
|
9
|
+
width: 280,
|
|
10
|
+
flexDirection: 'column',
|
|
11
|
+
border: `1px solid ${storybookTheme.appBorderColor}`,
|
|
12
|
+
borderRadius: storybookTheme.appBorderRadius,
|
|
13
|
+
overflow: 'hidden',
|
|
14
|
+
display: 'flex',
|
|
15
|
+
background: storybookTheme.background.content,
|
|
16
|
+
}));
|
|
17
|
+
const Header = styled.button(({ theme: storybookTheme }) => ({
|
|
18
|
+
width: '100%',
|
|
19
|
+
minHeight: 32,
|
|
20
|
+
justifyContent: 'space-between',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
border: 0,
|
|
23
|
+
padding: '0 12px',
|
|
24
|
+
gap: 8,
|
|
25
|
+
color: storybookTheme.color.defaultText,
|
|
26
|
+
fontSize: storybookTheme.typography.size.s2,
|
|
27
|
+
fontWeight: storybookTheme.typography.weight.bold,
|
|
28
|
+
display: 'flex',
|
|
29
|
+
cursor: 'pointer',
|
|
30
|
+
background: storybookTheme.background.app,
|
|
31
|
+
}));
|
|
32
|
+
const HeaderTitle = styled.span({
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
gap: 8,
|
|
35
|
+
display: 'flex',
|
|
36
|
+
});
|
|
37
|
+
const Chevron = styled(ChevronSmallDownIcon)(({ theme: storybookTheme }) => ({
|
|
38
|
+
color: storybookTheme.color.mediumdark,
|
|
39
|
+
}));
|
|
40
|
+
const bodyStyle = {
|
|
41
|
+
flexDirection: 'column',
|
|
42
|
+
padding: '8px 16px',
|
|
43
|
+
display: 'flex',
|
|
44
|
+
};
|
|
45
|
+
const rowStyle = {
|
|
46
|
+
minHeight: 40,
|
|
47
|
+
justifyContent: 'space-between',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
padding: '0 4px',
|
|
50
|
+
gap: 16,
|
|
51
|
+
display: 'flex',
|
|
52
|
+
};
|
|
53
|
+
const labelStyle = {
|
|
54
|
+
color: '#2c2c2c',
|
|
55
|
+
font: '400 13px/20px "Inter", "Nunito Sans", sans-serif',
|
|
56
|
+
};
|
|
57
|
+
const selectStyle = {
|
|
58
|
+
width: 148,
|
|
59
|
+
height: 32,
|
|
60
|
+
border: '1px solid #e6e6e6',
|
|
61
|
+
borderRadius: 6,
|
|
62
|
+
padding: '0 8px',
|
|
63
|
+
color: '#2c2c2c',
|
|
64
|
+
font: '400 13px/20px "Inter", "Nunito Sans", sans-serif',
|
|
65
|
+
background: '#ffffff',
|
|
66
|
+
};
|
|
67
|
+
function getChevronStyle(isOpen) {
|
|
68
|
+
return {
|
|
69
|
+
transform: isOpen ? 'rotate(0deg)' : 'rotate(-90deg)',
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function getSwitchTrackStyle(isChecked) {
|
|
73
|
+
return {
|
|
74
|
+
width: 40,
|
|
75
|
+
height: 22,
|
|
76
|
+
flexShrink: 0,
|
|
77
|
+
position: 'relative',
|
|
78
|
+
border: 0,
|
|
79
|
+
borderRadius: 11,
|
|
80
|
+
padding: 0,
|
|
81
|
+
cursor: 'pointer',
|
|
82
|
+
background: isChecked ? '#0d99ff' : '#e6e6e6',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function getSwitchKnobStyle(isChecked) {
|
|
86
|
+
return {
|
|
87
|
+
width: 18,
|
|
88
|
+
height: 18,
|
|
89
|
+
position: 'absolute',
|
|
90
|
+
top: 2,
|
|
91
|
+
left: isChecked ? 20 : 2,
|
|
92
|
+
borderRadius: 9,
|
|
93
|
+
background: '#ffffff',
|
|
94
|
+
boxShadow: '0 1px 2px rgba(0, 0, 0, 0.2)',
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function formatLabel(value) {
|
|
98
|
+
if (!value) {
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
102
|
+
}
|
|
103
|
+
function VariantSwitch(props) {
|
|
104
|
+
const { checked, onToggle } = props;
|
|
105
|
+
return (_jsx("button", { type: "button", "aria-checked": checked, role: "switch", style: getSwitchTrackStyle(checked), onClick: onToggle, children: _jsx("span", { style: getSwitchKnobStyle(checked) }) }));
|
|
106
|
+
}
|
|
107
|
+
function VariantsSwitchList(props) {
|
|
108
|
+
const { selectedProperties, variants, onChange } = props;
|
|
109
|
+
const selectedVariant = findVariant(variants, selectedProperties);
|
|
110
|
+
const propertyNames = getPropertyNames(variants);
|
|
111
|
+
return (_jsx("div", { style: bodyStyle, children: propertyNames.map((propertyName) => {
|
|
112
|
+
const options = getPropertyOptions(variants, propertyName);
|
|
113
|
+
const control = getPropertyControl(variants, propertyName, options);
|
|
114
|
+
const value = getPropertyValue(selectedVariant, propertyName) ?? options[0];
|
|
115
|
+
if (control === 'switch') {
|
|
116
|
+
return options.map((option) => {
|
|
117
|
+
const isChecked = value === option;
|
|
118
|
+
return (_jsxs("div", { style: rowStyle, children: [_jsx("span", { style: labelStyle, children: formatLabel(option) }), _jsx(VariantSwitch, { checked: isChecked, onToggle: () => {
|
|
119
|
+
if (!isChecked) {
|
|
120
|
+
onChange(propertyName, option);
|
|
121
|
+
}
|
|
122
|
+
} })] }, `${propertyName}-${option}`));
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return (_jsxs("div", { style: rowStyle, children: [_jsx("span", { style: labelStyle, children: formatLabel(propertyName) }), _jsx("select", { style: selectStyle, value: value, onChange: (event) => {
|
|
126
|
+
onChange(propertyName, event.currentTarget.value);
|
|
127
|
+
}, children: options.map((option) => (_jsx("option", { value: option, children: option }, option))) })] }, propertyName));
|
|
128
|
+
}) }));
|
|
129
|
+
}
|
|
130
|
+
function VariantsCanvas(props) {
|
|
131
|
+
const { variants } = props;
|
|
132
|
+
const [isOpen, setIsOpen] = useState(true);
|
|
133
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsxs(Panel, { children: [_jsxs(Header, { type: "button", "aria-expanded": isOpen, onClick: () => {
|
|
134
|
+
setIsOpen((open) => !open);
|
|
135
|
+
}, children: [_jsxs(HeaderTitle, { children: ["Variants", _jsx(Badge, { status: "active", compact: true, children: variants.length })] }), _jsx(Chevron, { style: getChevronStyle(isOpen) })] }), isOpen && _jsx(VariantsSwitchList, { ...props })] }) }));
|
|
136
|
+
}
|
|
137
|
+
export { VariantsCanvas, VariantsSwitchList };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { BooleanControl, OptionsControl } from '@storybook/addon-docs/blocks';
|
|
3
|
+
import { ensure, ThemeProvider, themes } from 'storybook/theming';
|
|
4
|
+
import { findVariant, getPropertyControl, getPropertyNames, getPropertyOptions, getPropertyValue, } from './variants.helpers.js';
|
|
5
|
+
const listStyle = {
|
|
6
|
+
width: '100%',
|
|
7
|
+
flexDirection: 'column',
|
|
8
|
+
gap: 8,
|
|
9
|
+
display: 'flex',
|
|
10
|
+
};
|
|
11
|
+
const rowStyle = {
|
|
12
|
+
minHeight: 32,
|
|
13
|
+
justifyContent: 'start',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
gap: 16,
|
|
16
|
+
display: 'grid',
|
|
17
|
+
gridTemplateColumns: '25% auto',
|
|
18
|
+
};
|
|
19
|
+
function formatLabel(value) {
|
|
20
|
+
if (!value) {
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
24
|
+
}
|
|
25
|
+
function VariantsPropertyList(props) {
|
|
26
|
+
const { selectedProperties, variants, onChange } = props;
|
|
27
|
+
const selectedVariant = findVariant(variants, selectedProperties);
|
|
28
|
+
const propertyNames = getPropertyNames(variants);
|
|
29
|
+
return (_jsx(ThemeProvider, { theme: ensure(themes.light), children: _jsx("div", { style: listStyle, children: propertyNames.map((propertyName) => {
|
|
30
|
+
const options = getPropertyOptions(variants, propertyName);
|
|
31
|
+
const control = getPropertyControl(variants, propertyName, options);
|
|
32
|
+
const value = getPropertyValue(selectedVariant, propertyName) ?? options[0];
|
|
33
|
+
if (control === 'switch') {
|
|
34
|
+
return options.map((option) => {
|
|
35
|
+
const isChecked = value === option;
|
|
36
|
+
return (_jsxs("div", { style: rowStyle, children: [_jsx("span", { children: formatLabel(option) }), _jsx(BooleanControl, { name: `${propertyName}-${option}`, value: isChecked, onChange: (nextValue) => {
|
|
37
|
+
if (nextValue) {
|
|
38
|
+
onChange(propertyName, option);
|
|
39
|
+
}
|
|
40
|
+
} })] }, `${propertyName}-${option}`));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return (_jsxs("div", { style: rowStyle, children: [_jsx("span", { children: formatLabel(propertyName) }), _jsx(OptionsControl, { type: control === 'radio' ? 'radio' : 'select', name: propertyName, argType: { options: options }, value: value, onChange: (nextValue) => {
|
|
44
|
+
if (nextValue == null) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
onChange(propertyName, String(nextValue));
|
|
48
|
+
} })] }, propertyName));
|
|
49
|
+
}) }) }));
|
|
50
|
+
}
|
|
51
|
+
export { VariantsPropertyList };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const VARIANTS_ADDON_ID = "variants";
|
|
2
|
+
declare const VARIANTS_GLOBAL_KEY = "variants";
|
|
3
|
+
declare const VARIANTS_PANEL_ID = "variants/panel";
|
|
4
|
+
declare const VARIANTS_PARAMETER_KEY = "variants";
|
|
5
|
+
declare const VARIANTS_TOOL_ID = "variants/tool";
|
|
6
|
+
export { VARIANTS_ADDON_ID, VARIANTS_GLOBAL_KEY, VARIANTS_PANEL_ID, VARIANTS_PARAMETER_KEY, VARIANTS_TOOL_ID, };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const VARIANTS_ADDON_ID = 'variants';
|
|
2
|
+
const VARIANTS_GLOBAL_KEY = 'variants';
|
|
3
|
+
const VARIANTS_PANEL_ID = 'variants/panel';
|
|
4
|
+
const VARIANTS_PARAMETER_KEY = 'variants';
|
|
5
|
+
const VARIANTS_TOOL_ID = 'variants/tool';
|
|
6
|
+
export { VARIANTS_ADDON_ID, VARIANTS_GLOBAL_KEY, VARIANTS_PANEL_ID, VARIANTS_PARAMETER_KEY, VARIANTS_TOOL_ID, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ControlsIcon } from '@storybook/icons';
|
|
3
|
+
import { AddonPanel, Badge, Button, Placeholder, WithTooltip, } from 'storybook/internal/components';
|
|
4
|
+
import { addons, types, useArgs, useGlobals, useParameter, useStorybookApi, useStorybookState, } from 'storybook/manager-api';
|
|
5
|
+
import { VARIANTS_ADDON_ID, VARIANTS_GLOBAL_KEY, VARIANTS_PANEL_ID, VARIANTS_PARAMETER_KEY, VARIANTS_TOOL_ID, } from './constants.js';
|
|
6
|
+
import { findVariant, getSelectedProperties, isStoryVariantList, replacePropertyValue, } from './variants.helpers.js';
|
|
7
|
+
import { VariantsSwitchList } from './VariantsCanvas.js';
|
|
8
|
+
import { VariantsPropertyList } from './VariantsControl.js';
|
|
9
|
+
function useVariantsState() {
|
|
10
|
+
const variants = useParameter(VARIANTS_PARAMETER_KEY, []);
|
|
11
|
+
const [args] = useArgs();
|
|
12
|
+
const [globals, updateGlobals] = useGlobals();
|
|
13
|
+
const state = useStorybookState();
|
|
14
|
+
const storyId = state.storyId;
|
|
15
|
+
const hasVariants = isStoryVariantList(variants) && variants.length > 0 && Boolean(storyId);
|
|
16
|
+
const selectedProperties = hasVariants
|
|
17
|
+
? getSelectedProperties({
|
|
18
|
+
args: args,
|
|
19
|
+
globalValue: globals[VARIANTS_GLOBAL_KEY],
|
|
20
|
+
storyId: storyId,
|
|
21
|
+
variants: variants,
|
|
22
|
+
})
|
|
23
|
+
: [];
|
|
24
|
+
const selectedVariant = hasVariants
|
|
25
|
+
? findVariant(variants, selectedProperties)
|
|
26
|
+
: undefined;
|
|
27
|
+
function selectProperties(properties) {
|
|
28
|
+
if (!storyId) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
updateGlobals({
|
|
32
|
+
[VARIANTS_GLOBAL_KEY]: {
|
|
33
|
+
properties: properties,
|
|
34
|
+
storyId: storyId,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
hasVariants: hasVariants,
|
|
40
|
+
selectedProperties: selectedProperties,
|
|
41
|
+
selectedVariant: selectedVariant,
|
|
42
|
+
selectProperties: selectProperties,
|
|
43
|
+
variants: hasVariants ? variants : [],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function VariantsControls() {
|
|
47
|
+
const { selectedProperties, selectedVariant, selectProperties, variants } = useVariantsState();
|
|
48
|
+
if (!selectedVariant) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return (_jsx(VariantsPropertyList, { selectedProperties: selectedProperties, variants: variants, onChange: (propertyName, nextValue) => {
|
|
52
|
+
const nextProperties = replacePropertyValue(selectedVariant.properties, propertyName, nextValue);
|
|
53
|
+
const nextVariant = findVariant(variants, nextProperties);
|
|
54
|
+
selectProperties(nextVariant.properties);
|
|
55
|
+
} }));
|
|
56
|
+
}
|
|
57
|
+
const panelStyle = {
|
|
58
|
+
justifyContent: 'center',
|
|
59
|
+
padding: 16,
|
|
60
|
+
display: 'flex',
|
|
61
|
+
};
|
|
62
|
+
const panelInnerStyle = {
|
|
63
|
+
width: '100%',
|
|
64
|
+
maxWidth: 360,
|
|
65
|
+
};
|
|
66
|
+
const titleStyle = {
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
gap: 6,
|
|
69
|
+
display: 'flex',
|
|
70
|
+
};
|
|
71
|
+
const tooltipStyle = {
|
|
72
|
+
width: 280,
|
|
73
|
+
padding: '4px 8px',
|
|
74
|
+
};
|
|
75
|
+
function VariantsPanel() {
|
|
76
|
+
const { hasVariants } = useVariantsState();
|
|
77
|
+
if (!hasVariants) {
|
|
78
|
+
return _jsx(Placeholder, { children: "No variants for this story" });
|
|
79
|
+
}
|
|
80
|
+
return (_jsx("div", { style: panelStyle, children: _jsx("div", { style: panelInnerStyle, children: _jsx(VariantsControls, {}) }) }));
|
|
81
|
+
}
|
|
82
|
+
function VariantsPanelTitle() {
|
|
83
|
+
const api = useStorybookApi();
|
|
84
|
+
const variants = useParameter(VARIANTS_PARAMETER_KEY, []);
|
|
85
|
+
const variantsCount = isStoryVariantList(variants) ? variants.length : 0;
|
|
86
|
+
const isSelected = api.getSelectedPanel() === VARIANTS_PANEL_ID;
|
|
87
|
+
return (_jsxs("div", { style: titleStyle, children: [_jsx("span", { children: "Variants" }), variantsCount > 0 && (_jsx(Badge, { status: isSelected ? 'active' : 'neutral', compact: true, children: variantsCount }))] }));
|
|
88
|
+
}
|
|
89
|
+
function VariantsTool() {
|
|
90
|
+
const { hasVariants, selectedProperties, selectedVariant, selectProperties, variants, } = useVariantsState();
|
|
91
|
+
if (!hasVariants || !selectedVariant) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
return (_jsx(WithTooltip, { placement: "bottom-end", tooltip: _jsx("div", { style: tooltipStyle, children: _jsx(VariantsSwitchList, { selectedProperties: selectedProperties, variants: variants, onChange: (propertyName, nextValue) => {
|
|
95
|
+
const nextProperties = replacePropertyValue(selectedVariant.properties, propertyName, nextValue);
|
|
96
|
+
const nextVariant = findVariant(variants, nextProperties);
|
|
97
|
+
selectProperties(nextVariant.properties);
|
|
98
|
+
} }) }), trigger: "click", closeOnOutsideClick: true, children: _jsxs(Button, { size: "small", padding: "small", "aria-label": "Variants", variant: "ghost", children: [_jsx(ControlsIcon, {}), "Variants", _jsx(Badge, { status: "neutral", compact: true, children: variants.length })] }) }));
|
|
99
|
+
}
|
|
100
|
+
function VariantsPanelContainer(props) {
|
|
101
|
+
const { active = false } = props;
|
|
102
|
+
return (_jsx(AddonPanel, { active: active, children: _jsx(VariantsPanel, {}) }));
|
|
103
|
+
}
|
|
104
|
+
addons.register(VARIANTS_ADDON_ID, () => {
|
|
105
|
+
addons.add(VARIANTS_TOOL_ID, {
|
|
106
|
+
type: types.TOOL,
|
|
107
|
+
title: 'Variants',
|
|
108
|
+
match: ({ viewMode }) => viewMode === 'story',
|
|
109
|
+
render: VariantsTool,
|
|
110
|
+
});
|
|
111
|
+
addons.add(VARIANTS_PANEL_ID, {
|
|
112
|
+
type: types.PANEL,
|
|
113
|
+
title: VariantsPanelTitle,
|
|
114
|
+
match: ({ viewMode }) => viewMode === 'story',
|
|
115
|
+
render: VariantsPanelContainer,
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { withA4PaperDecorator } from '../../decorators/withA4PaperDecorator.js';
|
|
3
|
+
import { VARIANTS_GLOBAL_KEY, VARIANTS_PARAMETER_KEY } from './constants.js';
|
|
4
|
+
import { findVariant, getSelectedProperties, isStoryVariantList, } from './variants.helpers.js';
|
|
5
|
+
const storyStyle = {
|
|
6
|
+
width: '100%',
|
|
7
|
+
};
|
|
8
|
+
function withVariants(Story, context) {
|
|
9
|
+
const variants = context.parameters[VARIANTS_PARAMETER_KEY];
|
|
10
|
+
if (!isStoryVariantList(variants) || variants.length === 0) {
|
|
11
|
+
return _jsx(Story, {});
|
|
12
|
+
}
|
|
13
|
+
if (context.viewMode === 'docs') {
|
|
14
|
+
return _jsx(Story, {});
|
|
15
|
+
}
|
|
16
|
+
const selectedProperties = getSelectedProperties({
|
|
17
|
+
args: context.args,
|
|
18
|
+
globalValue: context.globals[VARIANTS_GLOBAL_KEY],
|
|
19
|
+
storyId: context.id,
|
|
20
|
+
variants: variants,
|
|
21
|
+
});
|
|
22
|
+
const selectedVariant = findVariant(variants, selectedProperties);
|
|
23
|
+
const selectionKey = selectedProperties
|
|
24
|
+
.map((property) => `${property.name}:${property.value}`)
|
|
25
|
+
.join('|');
|
|
26
|
+
const story = context.originalStoryFn(selectedVariant.args, {
|
|
27
|
+
...context,
|
|
28
|
+
args: selectedVariant.args,
|
|
29
|
+
});
|
|
30
|
+
return withA4PaperDecorator(() => (_jsx("div", { style: storyStyle, children: story }, selectionKey)), context);
|
|
31
|
+
}
|
|
32
|
+
const decorators = [withVariants];
|
|
33
|
+
const globalTypes = {
|
|
34
|
+
[VARIANTS_GLOBAL_KEY]: {
|
|
35
|
+
defaultValue: {
|
|
36
|
+
properties: [],
|
|
37
|
+
storyId: '',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
export { decorators, globalTypes };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GetInitialPropertiesParams, GetSelectedPropertiesParams, StoryVariant, StoryVariantControl, StoryVariantProperty, VariantsGlobal } from './variants.interface.js';
|
|
2
|
+
declare function isStoryVariantList(value: unknown): value is StoryVariant[];
|
|
3
|
+
declare function isVariantsGlobal(value: unknown): value is VariantsGlobal;
|
|
4
|
+
declare function getShowCanvas(globalValue: unknown): boolean;
|
|
5
|
+
declare function getPropertyValue(variant: StoryVariant, propertyName: string): string;
|
|
6
|
+
declare function getPropertyNames(variants: StoryVariant[]): string[];
|
|
7
|
+
declare function getPropertyControl(variants: StoryVariant[], propertyName: string, options: string[]): StoryVariantControl;
|
|
8
|
+
declare function getPropertyOptions(variants: StoryVariant[], propertyName: string): string[];
|
|
9
|
+
declare function findVariant(variants: StoryVariant[], properties: StoryVariantProperty[]): StoryVariant;
|
|
10
|
+
declare function getInitialProperties(params: GetInitialPropertiesParams): StoryVariantProperty[];
|
|
11
|
+
declare function replacePropertyValue(properties: StoryVariantProperty[], propertyName: string, propertyValue: string): StoryVariantProperty[];
|
|
12
|
+
declare function getSelectedProperties(params: GetSelectedPropertiesParams): StoryVariantProperty[];
|
|
13
|
+
export { findVariant, getInitialProperties, getPropertyControl, getPropertyNames, getPropertyOptions, getPropertyValue, getSelectedProperties, getShowCanvas, isStoryVariantList, isVariantsGlobal, replacePropertyValue, };
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
function isStoryVariantArgs(value) {
|
|
2
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
function isStoryVariantProperty(value) {
|
|
5
|
+
if (!value || typeof value !== 'object') {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
if (!('name' in value) || !('value' in value)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (typeof value.name !== 'string' || typeof value.value !== 'string') {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (!('control' in value) || value.control === undefined) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return (value.control === 'radio' ||
|
|
18
|
+
value.control === 'select' ||
|
|
19
|
+
value.control === 'switch');
|
|
20
|
+
}
|
|
21
|
+
function isStoryVariant(value) {
|
|
22
|
+
if (!value || typeof value !== 'object') {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (!('properties' in value) || !('args' in value)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return (Array.isArray(value.properties) &&
|
|
29
|
+
value.properties.every((property) => isStoryVariantProperty(property)) &&
|
|
30
|
+
isStoryVariantArgs(value.args));
|
|
31
|
+
}
|
|
32
|
+
function isStoryVariantList(value) {
|
|
33
|
+
return (Array.isArray(value) && value.every((variant) => isStoryVariant(variant)));
|
|
34
|
+
}
|
|
35
|
+
function isVariantsGlobal(value) {
|
|
36
|
+
if (!value || typeof value !== 'object') {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (!('properties' in value) || !('storyId' in value)) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return (typeof value.storyId === 'string' &&
|
|
43
|
+
Array.isArray(value.properties) &&
|
|
44
|
+
value.properties.every((property) => isStoryVariantProperty(property)));
|
|
45
|
+
}
|
|
46
|
+
function getShowCanvas(globalValue) {
|
|
47
|
+
if (!isVariantsGlobal(globalValue) || globalValue.showCanvas === undefined) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return globalValue.showCanvas;
|
|
51
|
+
}
|
|
52
|
+
function getPropertyValue(variant, propertyName) {
|
|
53
|
+
return variant.properties.find((property) => property.name === propertyName)
|
|
54
|
+
?.value;
|
|
55
|
+
}
|
|
56
|
+
function getPropertyNames(variants) {
|
|
57
|
+
return variants.reduce((names, variant) => {
|
|
58
|
+
return variant.properties.reduce((result, property) => {
|
|
59
|
+
if (result.includes(property.name)) {
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
return [...result, property.name];
|
|
63
|
+
}, names);
|
|
64
|
+
}, []);
|
|
65
|
+
}
|
|
66
|
+
function getPropertyControl(variants, propertyName, options) {
|
|
67
|
+
const explicitControl = variants
|
|
68
|
+
.flatMap((variant) => variant.properties)
|
|
69
|
+
.find((property) => property.name === propertyName)?.control;
|
|
70
|
+
if (explicitControl === 'radio' ||
|
|
71
|
+
explicitControl === 'select' ||
|
|
72
|
+
explicitControl === 'switch') {
|
|
73
|
+
return explicitControl;
|
|
74
|
+
}
|
|
75
|
+
if (options.length <= 2) {
|
|
76
|
+
return 'switch';
|
|
77
|
+
}
|
|
78
|
+
return 'radio';
|
|
79
|
+
}
|
|
80
|
+
function getPropertyOptions(variants, propertyName) {
|
|
81
|
+
return variants.reduce((options, variant) => {
|
|
82
|
+
const propertyValue = getPropertyValue(variant, propertyName);
|
|
83
|
+
if (!propertyValue || options.includes(propertyValue)) {
|
|
84
|
+
return options;
|
|
85
|
+
}
|
|
86
|
+
return [...options, propertyValue];
|
|
87
|
+
}, []);
|
|
88
|
+
}
|
|
89
|
+
function findVariant(variants, properties) {
|
|
90
|
+
return (variants.find((variant) => {
|
|
91
|
+
return properties.every((property) => {
|
|
92
|
+
return getPropertyValue(variant, property.name) === property.value;
|
|
93
|
+
});
|
|
94
|
+
}) ?? variants[0]);
|
|
95
|
+
}
|
|
96
|
+
function argsMatchVariant(args, variant) {
|
|
97
|
+
if (!args || !variant.args) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
const variantKeys = Object.keys(variant.args);
|
|
101
|
+
if (variantKeys.length === 0) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
return variantKeys.every((key) => variant.args[key] === args[key]);
|
|
105
|
+
}
|
|
106
|
+
function getInitialProperties(params) {
|
|
107
|
+
const { args, variants } = params;
|
|
108
|
+
const argsMatch = variants.find((variant) => {
|
|
109
|
+
return variant.args === args || argsMatchVariant(args, variant);
|
|
110
|
+
});
|
|
111
|
+
const matchedVariant = argsMatch ?? variants[0];
|
|
112
|
+
if (!matchedVariant) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
return [...matchedVariant.properties];
|
|
116
|
+
}
|
|
117
|
+
function replacePropertyValue(properties, propertyName, propertyValue) {
|
|
118
|
+
return properties.map((property) => {
|
|
119
|
+
if (property.name !== propertyName) {
|
|
120
|
+
return property;
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
name: property.name,
|
|
124
|
+
value: propertyValue,
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function propertiesBelongToVariants(variants, properties) {
|
|
129
|
+
const propertyNames = getPropertyNames(variants);
|
|
130
|
+
return properties.every((property) => propertyNames.includes(property.name));
|
|
131
|
+
}
|
|
132
|
+
function getSelectedProperties(params) {
|
|
133
|
+
const { args, globalValue, storyId, variants } = params;
|
|
134
|
+
if (isVariantsGlobal(globalValue) &&
|
|
135
|
+
globalValue.storyId === storyId &&
|
|
136
|
+
globalValue.properties.length > 0 &&
|
|
137
|
+
propertiesBelongToVariants(variants, globalValue.properties)) {
|
|
138
|
+
return findVariant(variants, globalValue.properties).properties;
|
|
139
|
+
}
|
|
140
|
+
return getInitialProperties({
|
|
141
|
+
args: args,
|
|
142
|
+
variants: variants,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
export { findVariant, getInitialProperties, getPropertyControl, getPropertyNames, getPropertyOptions, getPropertyValue, getSelectedProperties, getShowCanvas, isStoryVariantList, isVariantsGlobal, replacePropertyValue, };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
type StoryVariantControl = 'radio' | 'select' | 'switch';
|
|
2
|
+
interface StoryVariantProperty {
|
|
3
|
+
control?: StoryVariantControl;
|
|
4
|
+
name: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
type StoryVariantArgs = Record<string, unknown>;
|
|
8
|
+
interface StoryVariant {
|
|
9
|
+
args: StoryVariantArgs;
|
|
10
|
+
properties: StoryVariantProperty[];
|
|
11
|
+
}
|
|
12
|
+
interface VariantsGlobal {
|
|
13
|
+
properties: StoryVariantProperty[];
|
|
14
|
+
showCanvas?: boolean;
|
|
15
|
+
storyId: string;
|
|
16
|
+
}
|
|
17
|
+
interface GetInitialPropertiesParams {
|
|
18
|
+
args: StoryVariantArgs;
|
|
19
|
+
variants: StoryVariant[];
|
|
20
|
+
}
|
|
21
|
+
interface GetSelectedPropertiesParams {
|
|
22
|
+
args: StoryVariantArgs;
|
|
23
|
+
globalValue: unknown;
|
|
24
|
+
storyId: string;
|
|
25
|
+
variants: StoryVariant[];
|
|
26
|
+
}
|
|
27
|
+
interface VariantsPanelContainerProps {
|
|
28
|
+
active?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface VariantsControlProps {
|
|
31
|
+
onChange: (value: string) => void;
|
|
32
|
+
control: StoryVariantControl;
|
|
33
|
+
name: string;
|
|
34
|
+
options: string[];
|
|
35
|
+
value: string;
|
|
36
|
+
}
|
|
37
|
+
interface VariantsPropertyListProps {
|
|
38
|
+
onChange: (propertyName: string, value: string) => void;
|
|
39
|
+
selectedProperties: StoryVariantProperty[];
|
|
40
|
+
variants: StoryVariant[];
|
|
41
|
+
}
|
|
42
|
+
export type { GetInitialPropertiesParams, GetSelectedPropertiesParams, StoryVariant, StoryVariantArgs, StoryVariantControl, StoryVariantProperty, VariantsControlProps, VariantsGlobal, VariantsPanelContainerProps, VariantsPropertyListProps, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
function isA4Viewport(viewport) {
|
|
7
|
+
if (viewport === 'a4') {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
if (typeof viewport !== 'object' || viewport === null || !('value' in viewport)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return viewport.value === 'a4';
|
|
14
|
+
}
|
|
15
|
+
const paperStyle = {
|
|
16
|
+
width: '100%',
|
|
17
|
+
background: '#ffffff'
|
|
18
|
+
};
|
|
19
|
+
function A4Paper(props) {
|
|
20
|
+
const {
|
|
21
|
+
storyId,
|
|
22
|
+
viewMode,
|
|
23
|
+
children
|
|
24
|
+
} = props;
|
|
25
|
+
React.useLayoutEffect(() => {
|
|
26
|
+
const selector = viewMode === 'docs' ? `#anchor--${storyId} .docs-story` : '.sb-show-main';
|
|
27
|
+
const canvas = document.querySelector(selector);
|
|
28
|
+
if (!(canvas instanceof HTMLElement)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
canvas.style.setProperty('background', '#ffffff', 'important');
|
|
32
|
+
return () => {
|
|
33
|
+
canvas.style.removeProperty('background');
|
|
34
|
+
};
|
|
35
|
+
}, [storyId, viewMode]);
|
|
36
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
37
|
+
style: paperStyle,
|
|
38
|
+
children: children
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function withA4PaperDecorator(Story, context) {
|
|
42
|
+
if (!isA4Viewport(context.globals.viewport)) {
|
|
43
|
+
return /*#__PURE__*/jsxRuntime.jsx(Story, {});
|
|
44
|
+
}
|
|
45
|
+
return /*#__PURE__*/jsxRuntime.jsx(A4Paper, {
|
|
46
|
+
storyId: context.id,
|
|
47
|
+
viewMode: context.viewMode,
|
|
48
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Story, {})
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exports.withA4PaperDecorator = withA4PaperDecorator;
|
package/dist/cjs/decorators.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var withA4PaperDecorator = require('./decorators/withA4PaperDecorator.js');
|
|
3
4
|
var withClearStoresDecorator = require('./decorators/withClearStoresDecorator.js');
|
|
4
5
|
var withExtraProviders = require('./decorators/withExtraProviders.js');
|
|
5
6
|
var withFigmaSourceLink = require('./decorators/withFigmaSourceLink.js');
|
|
@@ -20,6 +21,7 @@ require('@itcase/ui-web/components/Notification');
|
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
|
|
24
|
+
exports.withA4PaperDecorator = withA4PaperDecorator.withA4PaperDecorator;
|
|
23
25
|
exports.withClearStoresDecorator = withClearStoresDecorator.withClearStoresDecorator;
|
|
24
26
|
exports.withExtraProviders = withExtraProviders.withExtraProviders;
|
|
25
27
|
exports.withFigmaSourceLink = withFigmaSourceLink.withFigmaSourceLink;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { ADDON_PRINT } from './addonPrint.js';
|
|
1
2
|
import { ADDON_TAG_BADGES, ADDON_TAG_BADGES_CONFIG } from './addonTagBadges.js';
|
|
2
3
|
import { ADDON_TOUR } from './addonTour.js';
|
|
4
|
+
import { ADDON_VARIANTS } from './addonVariants.js';
|
|
3
5
|
const ADDONS_NEXTJS = [
|
|
4
6
|
'@storybook/addon-links',
|
|
5
7
|
'@storybook/addon-themes',
|
|
@@ -7,8 +9,10 @@ const ADDONS_NEXTJS = [
|
|
|
7
9
|
'@storybook/addon-docs',
|
|
8
10
|
'@storybook/addon-vitest',
|
|
9
11
|
'storybook-addon-source-link',
|
|
12
|
+
ADDON_PRINT,
|
|
10
13
|
ADDON_TAG_BADGES,
|
|
11
14
|
ADDON_TAG_BADGES_CONFIG,
|
|
12
15
|
ADDON_TOUR,
|
|
16
|
+
ADDON_VARIANTS,
|
|
13
17
|
];
|
|
14
18
|
export { ADDONS_NEXTJS };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ADDON_MCP } from './addonMcp.js';
|
|
2
|
+
import { ADDON_PRINT } from './addonPrint.js';
|
|
2
3
|
import { ADDON_TAG_BADGES, ADDON_TAG_BADGES_CONFIG } from './addonTagBadges.js';
|
|
3
4
|
import { ADDON_TOUR } from './addonTour.js';
|
|
5
|
+
import { ADDON_VARIANTS } from './addonVariants.js';
|
|
4
6
|
const ADDONS_VITE = [
|
|
5
7
|
'@storybook/addon-links',
|
|
6
8
|
'@storybook/addon-themes',
|
|
@@ -10,8 +12,10 @@ const ADDONS_VITE = [
|
|
|
10
12
|
'msw-storybook-addon',
|
|
11
13
|
'storybook-addon-source-link',
|
|
12
14
|
ADDON_MCP,
|
|
15
|
+
ADDON_PRINT,
|
|
13
16
|
ADDON_TAG_BADGES,
|
|
14
17
|
ADDON_TAG_BADGES_CONFIG,
|
|
15
18
|
ADDON_TOUR,
|
|
19
|
+
ADDON_VARIANTS,
|
|
16
20
|
];
|
|
17
21
|
export { ADDONS_VITE };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { ADDON_PRINT } from './addonPrint.js';
|
|
2
3
|
import { ADDON_TAG_BADGES_CONFIG } from './addonTagBadges.js';
|
|
3
4
|
import { ADDON_TOUR } from './addonTour.js';
|
|
5
|
+
import { ADDON_VARIANTS } from './addonVariants.js';
|
|
4
6
|
const LOCAL_ADDON_DIRS = {
|
|
7
|
+
[ADDON_PRINT]: fileURLToPath(new URL('../../addons/print/', import.meta.url)),
|
|
5
8
|
[ADDON_TAG_BADGES_CONFIG]: fileURLToPath(new URL('../../addons/tag-badges/', import.meta.url)),
|
|
6
9
|
[ADDON_TOUR]: fileURLToPath(new URL('../../addons/tour/', import.meta.url)),
|
|
10
|
+
[ADDON_VARIANTS]: fileURLToPath(new URL('../../addons/variants/', import.meta.url)),
|
|
7
11
|
};
|
|
8
12
|
function withLocalAddons(addons) {
|
|
9
13
|
return addons.map((addon) => LOCAL_ADDON_DIRS[addon] ?? addon);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ADDON_MCP } from '../addons/addonMcp.js';
|
|
2
|
+
import { ADDON_PRINT } from '../addons/addonPrint.js';
|
|
2
3
|
import { ADDONS_NEXTJS } from '../addons/addonsNextJs.js';
|
|
3
4
|
import { ADDONS_REACT_NATIVE } from '../addons/addonsReactNative.js';
|
|
4
5
|
import { ADDONS_REACT_NATIVE_WEB } from '../addons/addonsReactNativeWeb.js';
|
|
5
6
|
import { ADDONS_VITE } from '../addons/addonsVite.js';
|
|
6
|
-
import {
|
|
7
|
+
import { ADDON_VARIANTS } from '../addons/addonVariants.js';
|
|
7
8
|
import { CODE } from '../code/code.js';
|
|
8
9
|
import { MAIN_CONFIG_NEXTJS_VITE } from '../config/mainConfigNextJsVite.js';
|
|
9
10
|
import { MAIN_CONFIG_REACT_NATIVE } from '../config/mainConfigReactNative.js';
|
|
@@ -15,13 +16,11 @@ import { FRAMEWORK_NEXTJS_VITE } from '../framework/frameworkNextJsVite.js';
|
|
|
15
16
|
import { FRAMEWORK_REACT_NATIVE } from '../framework/frameworkReactNative.js';
|
|
16
17
|
import { FRAMEWORK_REACT_NATIVE_WEB } from '../framework/frameworkReactNativeWeb.js';
|
|
17
18
|
import { FRAMEWORK_VITE } from '../framework/frameworkVite.js';
|
|
18
|
-
import { FRAMEWORK_WEBPACK } from '../framework/frameworkWebpack.js';
|
|
19
19
|
import { REFS } from '../refs/refs.js';
|
|
20
20
|
import { STATIC_DIRS_NEXTJS } from '../static/staticDirsNextJs.js';
|
|
21
21
|
import { STATIC_DIRS_REACT_NATIVE } from '../static/staticDirsReactNative.js';
|
|
22
22
|
import { STATIC_DIRS_REACT_NATIVE_WEB } from '../static/staticDirsReactNativeWeb.js';
|
|
23
23
|
import { STATIC_DIRS_VITE } from '../static/staticDirsVite.js';
|
|
24
|
-
import { STATIC_DIRS_WEBPACK } from '../static/staticDirsWebpack.js';
|
|
25
24
|
import { STATUS } from '../status/status.js';
|
|
26
25
|
import { AUTHORIZATION } from '../users/authorization.js';
|
|
27
|
-
export { ADDON_MCP, ADDONS_NEXTJS, ADDONS_REACT_NATIVE, ADDONS_REACT_NATIVE_WEB, ADDONS_VITE,
|
|
26
|
+
export { ADDON_MCP, ADDON_PRINT, ADDON_VARIANTS, ADDONS_NEXTJS, ADDONS_REACT_NATIVE, ADDONS_REACT_NATIVE_WEB, ADDONS_VITE, AUTHORIZATION, CODE, FRAMEWORK_NEXTJS, FRAMEWORK_NEXTJS_VITE, FRAMEWORK_REACT_NATIVE, FRAMEWORK_REACT_NATIVE_WEB, FRAMEWORK_VITE, MAIN_CONFIG_NEXTJS_VITE, MAIN_CONFIG_REACT_NATIVE, MAIN_CONFIG_REACT_NATIVE_WEB, MAIN_CONFIG_VITE, MAIN_CONFIG_WEBPACK, REFS, STATIC_DIRS_NEXTJS, STATIC_DIRS_REACT_NATIVE, STATIC_DIRS_REACT_NATIVE_WEB, STATIC_DIRS_VITE, STATUS, };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ADDON_MCP } from '../addons/addonMcp.js';
|
|
2
|
+
import { ADDON_PRINT } from '../addons/addonPrint.js';
|
|
2
3
|
import { ADDONS_NEXTJS } from '../addons/addonsNextJs.js';
|
|
3
4
|
import { ADDONS_REACT_NATIVE } from '../addons/addonsReactNative.js';
|
|
4
5
|
import { ADDONS_REACT_NATIVE_WEB } from '../addons/addonsReactNativeWeb.js';
|
|
5
6
|
import { ADDONS_VITE } from '../addons/addonsVite.js';
|
|
6
|
-
import {
|
|
7
|
+
import { ADDON_VARIANTS } from '../addons/addonVariants.js';
|
|
7
8
|
import { CODE } from '../code/code.js';
|
|
8
9
|
import { MAIN_CONFIG_NEXTJS_VITE } from '../config/mainConfigNextJsVite.js';
|
|
9
10
|
import { MAIN_CONFIG_REACT_NATIVE } from '../config/mainConfigReactNative.js';
|
|
@@ -15,13 +16,11 @@ import { FRAMEWORK_NEXTJS_VITE } from '../framework/frameworkNextJsVite.js';
|
|
|
15
16
|
import { FRAMEWORK_REACT_NATIVE } from '../framework/frameworkReactNative.js';
|
|
16
17
|
import { FRAMEWORK_REACT_NATIVE_WEB } from '../framework/frameworkReactNativeWeb.js';
|
|
17
18
|
import { FRAMEWORK_VITE } from '../framework/frameworkVite.js';
|
|
18
|
-
import { FRAMEWORK_WEBPACK } from '../framework/frameworkWebpack.js';
|
|
19
19
|
import { REFS } from '../refs/refs.js';
|
|
20
20
|
import { STATIC_DIRS_NEXTJS } from '../static/staticDirsNextJs.js';
|
|
21
21
|
import { STATIC_DIRS_REACT_NATIVE } from '../static/staticDirsReactNative.js';
|
|
22
22
|
import { STATIC_DIRS_REACT_NATIVE_WEB } from '../static/staticDirsReactNativeWeb.js';
|
|
23
23
|
import { STATIC_DIRS_VITE } from '../static/staticDirsVite.js';
|
|
24
|
-
import { STATIC_DIRS_WEBPACK } from '../static/staticDirsWebpack.js';
|
|
25
24
|
import { STATUS } from '../status/status.js';
|
|
26
25
|
import { AUTHORIZATION } from '../users/authorization.js';
|
|
27
|
-
export { ADDON_MCP, ADDONS_NEXTJS, ADDONS_REACT_NATIVE, ADDONS_REACT_NATIVE_WEB, ADDONS_VITE,
|
|
26
|
+
export { ADDON_MCP, ADDON_PRINT, ADDON_VARIANTS, ADDONS_NEXTJS, ADDONS_REACT_NATIVE, ADDONS_REACT_NATIVE_WEB, ADDONS_VITE, AUTHORIZATION, CODE, FRAMEWORK_NEXTJS, FRAMEWORK_NEXTJS_VITE, FRAMEWORK_REACT_NATIVE, FRAMEWORK_REACT_NATIVE_WEB, FRAMEWORK_VITE, MAIN_CONFIG_NEXTJS_VITE, MAIN_CONFIG_REACT_NATIVE, MAIN_CONFIG_REACT_NATIVE_WEB, MAIN_CONFIG_VITE, MAIN_CONFIG_WEBPACK, REFS, STATIC_DIRS_NEXTJS, STATIC_DIRS_REACT_NATIVE, STATIC_DIRS_REACT_NATIVE_WEB, STATIC_DIRS_VITE, STATUS, };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withA4PaperDecorator } from './withA4PaperDecorator';
|
|
1
2
|
import { withClearStoresDecorator } from './withClearStoresDecorator';
|
|
2
3
|
import { withExtraProviders } from './withExtraProviders';
|
|
3
4
|
import { withFigmaSourceLink } from './withFigmaSourceLink';
|
|
@@ -5,4 +6,4 @@ import { withFormSubmitDecorator } from './withFormSubmitDecorator';
|
|
|
5
6
|
import { withLayoutDecorator } from './withLayoutDecorator';
|
|
6
7
|
import { withNextDecoratorFactory } from './withNextDecorator';
|
|
7
8
|
import { withUiDecorator } from './withUiDecorator';
|
|
8
|
-
export { withClearStoresDecorator, withExtraProviders, withFigmaSourceLink, withFormSubmitDecorator, withLayoutDecorator, withNextDecoratorFactory, withUiDecorator, };
|
|
9
|
+
export { withA4PaperDecorator, withClearStoresDecorator, withExtraProviders, withFigmaSourceLink, withFormSubmitDecorator, withLayoutDecorator, withNextDecoratorFactory, withUiDecorator, };
|
package/dist/decorators/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withA4PaperDecorator } from './withA4PaperDecorator';
|
|
1
2
|
import { withClearStoresDecorator } from './withClearStoresDecorator';
|
|
2
3
|
import { withExtraProviders } from './withExtraProviders';
|
|
3
4
|
import { withFigmaSourceLink } from './withFigmaSourceLink';
|
|
@@ -5,4 +6,4 @@ import { withFormSubmitDecorator } from './withFormSubmitDecorator';
|
|
|
5
6
|
import { withLayoutDecorator } from './withLayoutDecorator';
|
|
6
7
|
import { withNextDecoratorFactory } from './withNextDecorator';
|
|
7
8
|
import { withUiDecorator } from './withUiDecorator';
|
|
8
|
-
export { withClearStoresDecorator, withExtraProviders, withFigmaSourceLink, withFormSubmitDecorator, withLayoutDecorator, withNextDecoratorFactory, withUiDecorator, };
|
|
9
|
+
export { withA4PaperDecorator, withClearStoresDecorator, withExtraProviders, withFigmaSourceLink, withFormSubmitDecorator, withLayoutDecorator, withNextDecoratorFactory, withUiDecorator, };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useLayoutEffect } from 'react';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
function isA4Viewport(viewport) {
|
|
5
|
+
if (viewport === 'a4') {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
if (typeof viewport !== 'object' || viewport === null || !('value' in viewport)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return viewport.value === 'a4';
|
|
12
|
+
}
|
|
13
|
+
const paperStyle = {
|
|
14
|
+
width: '100%',
|
|
15
|
+
background: '#ffffff'
|
|
16
|
+
};
|
|
17
|
+
function A4Paper(props) {
|
|
18
|
+
const {
|
|
19
|
+
storyId,
|
|
20
|
+
viewMode,
|
|
21
|
+
children
|
|
22
|
+
} = props;
|
|
23
|
+
useLayoutEffect(() => {
|
|
24
|
+
const selector = viewMode === 'docs' ? `#anchor--${storyId} .docs-story` : '.sb-show-main';
|
|
25
|
+
const canvas = document.querySelector(selector);
|
|
26
|
+
if (!(canvas instanceof HTMLElement)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
canvas.style.setProperty('background', '#ffffff', 'important');
|
|
30
|
+
return () => {
|
|
31
|
+
canvas.style.removeProperty('background');
|
|
32
|
+
};
|
|
33
|
+
}, [storyId, viewMode]);
|
|
34
|
+
return /*#__PURE__*/jsx("div", {
|
|
35
|
+
style: paperStyle,
|
|
36
|
+
children: children
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function withA4PaperDecorator(Story, context) {
|
|
40
|
+
if (!isA4Viewport(context.globals.viewport)) {
|
|
41
|
+
return /*#__PURE__*/jsx(Story, {});
|
|
42
|
+
}
|
|
43
|
+
return /*#__PURE__*/jsx(A4Paper, {
|
|
44
|
+
storyId: context.id,
|
|
45
|
+
viewMode: context.viewMode,
|
|
46
|
+
children: /*#__PURE__*/jsx(Story, {})
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { withA4PaperDecorator };
|
package/dist/decorators.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { withA4PaperDecorator } from './decorators/withA4PaperDecorator.js';
|
|
1
2
|
export { withClearStoresDecorator } from './decorators/withClearStoresDecorator.js';
|
|
2
3
|
export { withExtraProviders } from './decorators/withExtraProviders.js';
|
|
3
4
|
export { withFigmaSourceLink } from './decorators/withFigmaSourceLink.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itcase/storybook-config",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.23",
|
|
4
4
|
"author": "ITCase",
|
|
5
5
|
"description": "Storybook configuration package",
|
|
6
6
|
"engines": {
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"android": "expo run:android",
|
|
19
19
|
"storybook-react-native-ios": "sb-rn-get-stories --config-path ./.storybook-react-native && REACT_NATIVE_PACKAGER_HOSTNAME=$(ipconfig getifaddr $(route -n get default | awk '/interface:/{print $2}')) expo run:ios",
|
|
20
20
|
"storybook-react-native-android": "sb-rn-get-stories --config-path ./.storybook-react-native && expo run:android",
|
|
21
|
-
"storybook-react-webpack": "storybook dev -p 6006 --config-dir .storybook-react-webpack",
|
|
22
21
|
"storybook-next-js": "storybook dev -p 6006 --config-dir .storybook-next-js",
|
|
23
22
|
"storybook-vite": "storybook dev -p 6006 --config-dir .storybook-vite",
|
|
24
23
|
"storybook-next-js-vite": "storybook dev -p 6006 --config-dir .storybook-next-js-vite",
|
|
@@ -46,6 +45,26 @@
|
|
|
46
45
|
"import": "./dist/config/preview/index.js",
|
|
47
46
|
"require": "./dist/config/preview/index.js"
|
|
48
47
|
},
|
|
48
|
+
"./addons/print/manager": {
|
|
49
|
+
"types": "./dist/addons/print/manager.d.ts",
|
|
50
|
+
"import": "./dist/addons/print/manager.js",
|
|
51
|
+
"require": "./dist/addons/print/manager.js"
|
|
52
|
+
},
|
|
53
|
+
"./addons/print/preview": {
|
|
54
|
+
"types": "./dist/addons/print/preview.d.ts",
|
|
55
|
+
"import": "./dist/addons/print/preview.js",
|
|
56
|
+
"require": "./dist/addons/print/preview.js"
|
|
57
|
+
},
|
|
58
|
+
"./addons/variants/manager": {
|
|
59
|
+
"types": "./dist/addons/variants/manager.d.ts",
|
|
60
|
+
"import": "./dist/addons/variants/manager.js",
|
|
61
|
+
"require": "./dist/addons/variants/manager.js"
|
|
62
|
+
},
|
|
63
|
+
"./addons/variants/preview": {
|
|
64
|
+
"types": "./dist/addons/variants/preview.d.ts",
|
|
65
|
+
"import": "./dist/addons/variants/preview.js",
|
|
66
|
+
"require": "./dist/addons/variants/preview.js"
|
|
67
|
+
},
|
|
49
68
|
"./addons/tour/manager": {
|
|
50
69
|
"types": "./dist/addons/tour/manager.d.ts",
|
|
51
70
|
"import": "./dist/addons/tour/manager.js",
|
|
@@ -118,57 +137,55 @@
|
|
|
118
137
|
"@itcase/config": "^1.7.33",
|
|
119
138
|
"@itcase/storybook-addon-auth": "^1.0.5",
|
|
120
139
|
"@storybook/addon-designs": "^12.0.0",
|
|
121
|
-
"@storybook/addon-docs": "^10.6.
|
|
122
|
-
"@storybook/addon-links": "^10.6.
|
|
123
|
-
"@storybook/addon-mcp": "^10.6.
|
|
140
|
+
"@storybook/addon-docs": "^10.6.7",
|
|
141
|
+
"@storybook/addon-links": "^10.6.7",
|
|
142
|
+
"@storybook/addon-mcp": "^10.6.7",
|
|
124
143
|
"@storybook/addon-ondevice-actions": "10.7.1",
|
|
125
144
|
"@storybook/addon-ondevice-backgrounds": "10.7.1",
|
|
126
145
|
"@storybook/addon-ondevice-controls": "10.7.1",
|
|
127
146
|
"@storybook/addon-ondevice-notes": "^10.7.1",
|
|
128
|
-
"@storybook/addon-
|
|
129
|
-
"@storybook/addon-
|
|
130
|
-
"@storybook/
|
|
131
|
-
"@storybook/
|
|
132
|
-
"@storybook/
|
|
133
|
-
"@storybook/
|
|
134
|
-
"@storybook/nextjs-vite": "^10.6.6",
|
|
135
|
-
"@storybook/react": "^10.6.6",
|
|
147
|
+
"@storybook/addon-themes": "^10.6.7",
|
|
148
|
+
"@storybook/addon-vitest": "^10.6.7",
|
|
149
|
+
"@storybook/mcp": "10.6.7",
|
|
150
|
+
"@storybook/nextjs": "^10.6.7",
|
|
151
|
+
"@storybook/nextjs-vite": "^10.6.7",
|
|
152
|
+
"@storybook/react": "^10.6.7",
|
|
136
153
|
"@storybook/react-native": "10.7.1",
|
|
137
|
-
"@storybook/react-native-web-vite": "^10.6.
|
|
138
|
-
"@storybook/react-vite": "^10.6.
|
|
139
|
-
"@storybook/react-webpack5": "^10.6.
|
|
154
|
+
"@storybook/react-native-web-vite": "^10.6.7",
|
|
155
|
+
"@storybook/react-vite": "^10.6.7",
|
|
156
|
+
"@storybook/react-webpack5": "^10.6.7",
|
|
140
157
|
"chalk": "^6.0.1",
|
|
141
|
-
"driver.js": "^1.
|
|
142
|
-
"expo": "~58.0.
|
|
158
|
+
"driver.js": "^1.14.0",
|
|
159
|
+
"expo": "~58.0.25",
|
|
143
160
|
"lodash-es": "^4.18.1",
|
|
144
|
-
"msw": "^3.0.
|
|
161
|
+
"msw": "^3.0.6",
|
|
145
162
|
"msw-storybook-addon": "^3.0.3",
|
|
146
163
|
"react-native": "0.88.1",
|
|
147
164
|
"react-native-svg": "^15.16.1",
|
|
148
165
|
"react-native-web": "^0.21.4",
|
|
149
166
|
"srvx": "^1.0.8",
|
|
150
|
-
"storybook": "^10.6.
|
|
167
|
+
"storybook": "^10.6.7",
|
|
151
168
|
"storybook-addon-source-link": "^2.0.1",
|
|
152
169
|
"storybook-addon-tag-badges": "^3.1.0",
|
|
153
|
-
"vite": "^8.3.
|
|
170
|
+
"vite": "^8.3.8",
|
|
154
171
|
"vite-plugin-svgr": "^5.2.0"
|
|
155
172
|
},
|
|
156
173
|
"devDependencies": {
|
|
157
|
-
"@babel/core": "^8.1.
|
|
174
|
+
"@babel/core": "^8.1.2",
|
|
158
175
|
"@babel/preset-env": "^8.0.7",
|
|
159
176
|
"@babel/preset-react": "^8.0.1",
|
|
160
177
|
"@babel/preset-typescript": "^8.0.7",
|
|
161
|
-
"@babel/runtime": "^8.1.
|
|
178
|
+
"@babel/runtime": "^8.1.2",
|
|
162
179
|
"@commitlint/cli": "^21.2.4",
|
|
163
180
|
"@commitlint/config-conventional": "^21.2.4",
|
|
164
181
|
"@itcase/common": "^1.2.56",
|
|
165
|
-
"@itcase/lint": "^1.1.
|
|
166
|
-
"@itcase/ui-core": "^1.11.
|
|
167
|
-
"@itcase/ui-web": "^1.11.
|
|
182
|
+
"@itcase/lint": "^1.1.138",
|
|
183
|
+
"@itcase/ui-core": "^1.11.12",
|
|
184
|
+
"@itcase/ui-web": "^1.11.13",
|
|
168
185
|
"@react-native-async-storage/async-storage": "^3.1.1",
|
|
169
|
-
"@react-native-community/cli": "
|
|
170
|
-
"@react-native-community/cli-platform-android": "
|
|
171
|
-
"@react-native-community/cli-platform-ios": "
|
|
186
|
+
"@react-native-community/cli": "21.0.0",
|
|
187
|
+
"@react-native-community/cli-platform-android": "21.0.0",
|
|
188
|
+
"@react-native-community/cli-platform-ios": "21.0.0",
|
|
172
189
|
"@react-native/babel-preset": "0.88.1",
|
|
173
190
|
"@react-native/metro-config": "0.88.1",
|
|
174
191
|
"@react-native/typescript-config": "0.88.1",
|
|
@@ -181,24 +198,23 @@
|
|
|
181
198
|
"@types/react-dom": "^18",
|
|
182
199
|
"@vitest/browser-playwright": "^5.1.0",
|
|
183
200
|
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
|
|
184
|
-
"conventional-changelog-conventionalcommits": "9.3.1",
|
|
185
201
|
"eslint": "9.39.2",
|
|
186
|
-
"glob": "^14.0.
|
|
202
|
+
"glob": "^14.0.6",
|
|
187
203
|
"husky": "^9.1.7",
|
|
188
|
-
"lint-staged": "^17.6.
|
|
189
|
-
"next": "^16.4.
|
|
190
|
-
"playwright": "^1.65.
|
|
191
|
-
"prettier": "^3.
|
|
204
|
+
"lint-staged": "^17.6.1",
|
|
205
|
+
"next": "^16.4.6",
|
|
206
|
+
"playwright": "^1.65.1",
|
|
207
|
+
"prettier": "^3.10.1",
|
|
192
208
|
"react": "19.3.0",
|
|
193
209
|
"react-docgen-typescript": "^2.4.0",
|
|
194
210
|
"react-dom": "19.3.0",
|
|
195
211
|
"react-native-reanimated": "^4.7.1",
|
|
196
212
|
"react-native-safe-area-context": "^5.11.1",
|
|
197
213
|
"react-native-worklets": "^0.13.1",
|
|
198
|
-
"rollup": "^4.68.
|
|
214
|
+
"rollup": "^4.68.5",
|
|
199
215
|
"rollup-plugin-copy": "^3.5.0",
|
|
200
216
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
201
|
-
"semantic-release": "^
|
|
217
|
+
"semantic-release": "^26.0.1",
|
|
202
218
|
"stylelint": "^18.0.0",
|
|
203
219
|
"typescript": "^6.0.3",
|
|
204
220
|
"vitest": "^5.1.0"
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
declare const ADDONS_WEBPACK: (string | {
|
|
2
|
-
name: string;
|
|
3
|
-
options: {
|
|
4
|
-
rules: {
|
|
5
|
-
test: RegExp;
|
|
6
|
-
use: (string | {
|
|
7
|
-
loader: string;
|
|
8
|
-
options: {
|
|
9
|
-
importLoaders: number;
|
|
10
|
-
};
|
|
11
|
-
} | {
|
|
12
|
-
loader: string;
|
|
13
|
-
options?: undefined;
|
|
14
|
-
})[];
|
|
15
|
-
}[];
|
|
16
|
-
};
|
|
17
|
-
})[];
|
|
18
|
-
export { ADDONS_WEBPACK };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ADDON_TAG_BADGES, ADDON_TAG_BADGES_CONFIG } from './addonTagBadges.js';
|
|
2
|
-
import { ADDON_TOUR } from './addonTour.js';
|
|
3
|
-
const ADDONS_WEBPACK = [
|
|
4
|
-
'@storybook/addon-webpack5-compiler-swc',
|
|
5
|
-
'@storybook/addon-themes',
|
|
6
|
-
'@storybook/addon-designs',
|
|
7
|
-
'@storybook/addon-docs',
|
|
8
|
-
{
|
|
9
|
-
name: '@storybook/addon-styling-webpack',
|
|
10
|
-
options: {
|
|
11
|
-
rules: [
|
|
12
|
-
{
|
|
13
|
-
test: /\.css$/,
|
|
14
|
-
use: [
|
|
15
|
-
'style-loader',
|
|
16
|
-
{
|
|
17
|
-
loader: 'css-loader',
|
|
18
|
-
options: { importLoaders: 1 },
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
loader: 'postcss-loader',
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
'storybook-addon-source-link',
|
|
29
|
-
ADDON_TAG_BADGES,
|
|
30
|
-
ADDON_TAG_BADGES_CONFIG,
|
|
31
|
-
ADDON_TOUR,
|
|
32
|
-
];
|
|
33
|
-
export { ADDONS_WEBPACK };
|