@pure-ds/storybook 0.5.44 → 0.5.46
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/.storybook/addons/description/register.cjs +61 -0
- package/.storybook/addons/description/register.js +27 -26
- package/.storybook/addons/html-preview/constants.cjs +12 -0
- package/.storybook/addons/html-preview/register.cjs +41 -0
- package/.storybook/addons/html-preview/register.js +29 -5
- package/.storybook/addons/package.json +1 -1
- package/.storybook/addons/pds-configurator/SearchTool.cjs +47 -0
- package/.storybook/addons/pds-configurator/Tool.cjs +36 -0
- package/.storybook/addons/pds-configurator/constants.cjs +16 -0
- package/.storybook/addons/pds-configurator/register.cjs +12 -0
- package/.storybook/addons/pds-configurator/register.js +3 -4
- package/.storybook/main.js +3 -3
- package/dist/pds-reference.json +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const React = require('react');
|
|
2
|
+
const { addons, types } = require('@storybook/manager-api');
|
|
3
|
+
const { AddonPanel } = require('@storybook/components');
|
|
4
|
+
const { Markdown } = require('@storybook/blocks');
|
|
5
|
+
|
|
6
|
+
const ADDON_ID = 'pds-description';
|
|
7
|
+
const PANEL_ID = `${ADDON_ID}/panel`;
|
|
8
|
+
|
|
9
|
+
const DescriptionPanel = () => {
|
|
10
|
+
const [description, setDescription] = React.useState('');
|
|
11
|
+
const [title, setTitle] = React.useState('');
|
|
12
|
+
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
const channel = addons.getChannel();
|
|
15
|
+
|
|
16
|
+
const updateDescription = (data) => {
|
|
17
|
+
setTitle(data.title || '');
|
|
18
|
+
setDescription(data.description || 'No description available.');
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
channel.on('pds-description/update', updateDescription);
|
|
22
|
+
|
|
23
|
+
return () => {
|
|
24
|
+
channel.removeListener('pds-description/update', updateDescription);
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
28
|
+
return React.createElement(
|
|
29
|
+
'div',
|
|
30
|
+
{
|
|
31
|
+
style: {
|
|
32
|
+
padding: '1rem',
|
|
33
|
+
height: '100%',
|
|
34
|
+
overflow: 'auto'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
React.createElement(
|
|
38
|
+
'div',
|
|
39
|
+
{ style: { marginBottom: '0.5rem' } },
|
|
40
|
+
React.createElement(
|
|
41
|
+
'strong',
|
|
42
|
+
{ style: { fontSize: '1rem' } },
|
|
43
|
+
title
|
|
44
|
+
)
|
|
45
|
+
),
|
|
46
|
+
React.createElement(Markdown, null, description)
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
addons.register(ADDON_ID, () => {
|
|
51
|
+
addons.add(PANEL_ID, {
|
|
52
|
+
type: types.PANEL,
|
|
53
|
+
title: 'Description',
|
|
54
|
+
render: ({ active }) =>
|
|
55
|
+
React.createElement(
|
|
56
|
+
AddonPanel,
|
|
57
|
+
{ active },
|
|
58
|
+
React.createElement(DescriptionPanel)
|
|
59
|
+
)
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const React = require('react');
|
|
2
|
+
const { addons, types } = require('@storybook/manager-api');
|
|
3
|
+
const { AddonPanel } = require('@storybook/components');
|
|
4
|
+
const { Markdown } = require('@storybook/blocks');
|
|
5
5
|
|
|
6
6
|
const ADDON_ID = 'pds-description';
|
|
7
7
|
const PANEL_ID = `${ADDON_ID}/panel`;
|
|
8
8
|
|
|
9
9
|
const DescriptionPanel = () => {
|
|
10
|
-
const [description, setDescription] = useState('');
|
|
11
|
-
const [title, setTitle] = useState('');
|
|
10
|
+
const [description, setDescription] = React.useState('');
|
|
11
|
+
const [title, setTitle] = React.useState('');
|
|
12
12
|
|
|
13
|
-
useEffect(() => {
|
|
13
|
+
React.useEffect(() => {
|
|
14
14
|
const channel = addons.getChannel();
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
const updateDescription = (data) => {
|
|
17
17
|
setTitle(data.title || '');
|
|
18
18
|
setDescription(data.description || 'No description available.');
|
|
@@ -25,23 +25,23 @@ const DescriptionPanel = () => {
|
|
|
25
25
|
};
|
|
26
26
|
}, []);
|
|
27
27
|
|
|
28
|
-
return React.createElement(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
height: '100%',
|
|
32
|
-
overflow: 'auto'
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
React.createElement('div', {
|
|
28
|
+
return React.createElement(
|
|
29
|
+
'div',
|
|
30
|
+
{
|
|
36
31
|
style: {
|
|
37
|
-
|
|
32
|
+
padding: '1rem',
|
|
33
|
+
height: '100%',
|
|
34
|
+
overflow: 'auto'
|
|
38
35
|
}
|
|
39
36
|
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
React.createElement(
|
|
38
|
+
'div',
|
|
39
|
+
{ style: { marginBottom: '0.5rem' } },
|
|
40
|
+
React.createElement(
|
|
41
|
+
'strong',
|
|
42
|
+
{ style: { fontSize: '1rem' } },
|
|
43
|
+
title
|
|
44
|
+
)
|
|
45
45
|
),
|
|
46
46
|
React.createElement(Markdown, null, description)
|
|
47
47
|
);
|
|
@@ -51,10 +51,11 @@ addons.register(ADDON_ID, () => {
|
|
|
51
51
|
addons.add(PANEL_ID, {
|
|
52
52
|
type: types.PANEL,
|
|
53
53
|
title: 'Description',
|
|
54
|
-
render: ({ active }) =>
|
|
55
|
-
|
|
54
|
+
render: ({ active }) =>
|
|
55
|
+
React.createElement(
|
|
56
|
+
AddonPanel,
|
|
57
|
+
{ active },
|
|
56
58
|
React.createElement(DescriptionPanel)
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
+
)
|
|
59
60
|
});
|
|
60
61
|
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const React = require('react');
|
|
2
|
+
const { addons, types } = require('@storybook/manager-api');
|
|
3
|
+
const { ADDON_ID, PANEL_ID } = require('./constants.cjs');
|
|
4
|
+
|
|
5
|
+
const PanelLoader = ({ active }) => {
|
|
6
|
+
const [PanelComponent, setPanelComponent] = React.useState(null);
|
|
7
|
+
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
let mounted = true;
|
|
10
|
+
|
|
11
|
+
import('./Panel.jsx')
|
|
12
|
+
.then((mod) => {
|
|
13
|
+
if (!mounted) return;
|
|
14
|
+
const Resolved = mod.Panel || mod.default || null;
|
|
15
|
+
if (Resolved) setPanelComponent(() => Resolved);
|
|
16
|
+
})
|
|
17
|
+
.catch((error) => {
|
|
18
|
+
console.error('Failed to load html-preview Panel:', error);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return () => {
|
|
22
|
+
mounted = false;
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
|
|
26
|
+
if (!PanelComponent) return null;
|
|
27
|
+
return React.createElement(PanelComponent, { active });
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
addons.register(ADDON_ID, () => {
|
|
31
|
+
addons.add(PANEL_ID, {
|
|
32
|
+
type: types.PANEL,
|
|
33
|
+
title: 'Code',
|
|
34
|
+
render: ({ active, key }) =>
|
|
35
|
+
React.createElement(
|
|
36
|
+
'div',
|
|
37
|
+
{ style: { display: active ? 'block' : 'none', height: '100%' } },
|
|
38
|
+
React.createElement(PanelLoader, { key, active })
|
|
39
|
+
)
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -1,7 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const React = require('react');
|
|
2
|
+
const { addons, types } = require('@storybook/manager-api');
|
|
3
|
+
const { ADDON_ID, PANEL_ID } = require('./constants.cjs');
|
|
4
|
+
|
|
5
|
+
const PanelLoader = ({ active }) => {
|
|
6
|
+
const [PanelComponent, setPanelComponent] = React.useState(null);
|
|
7
|
+
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
let mounted = true;
|
|
10
|
+
|
|
11
|
+
import('./Panel.jsx')
|
|
12
|
+
.then((mod) => {
|
|
13
|
+
if (!mounted) return;
|
|
14
|
+
const Resolved = mod.Panel || mod.default || null;
|
|
15
|
+
if (Resolved) setPanelComponent(() => Resolved);
|
|
16
|
+
})
|
|
17
|
+
.catch((error) => {
|
|
18
|
+
console.error('Failed to load html-preview Panel:', error);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return () => {
|
|
22
|
+
mounted = false;
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
|
|
26
|
+
if (!PanelComponent) return null;
|
|
27
|
+
return React.createElement(PanelComponent, { active });
|
|
28
|
+
};
|
|
5
29
|
|
|
6
30
|
addons.register(ADDON_ID, () => {
|
|
7
31
|
addons.add(PANEL_ID, {
|
|
@@ -11,7 +35,7 @@ addons.register(ADDON_ID, () => {
|
|
|
11
35
|
React.createElement(
|
|
12
36
|
'div',
|
|
13
37
|
{ style: { display: active ? 'block' : 'none', height: '100%' } },
|
|
14
|
-
React.createElement(
|
|
38
|
+
React.createElement(PanelLoader, { key, active })
|
|
15
39
|
)
|
|
16
40
|
});
|
|
17
41
|
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const React = require('react');
|
|
2
|
+
const { useChannel } = require('@storybook/manager-api');
|
|
3
|
+
const { IconButton } = require('@storybook/components');
|
|
4
|
+
const { EVENTS } = require('./constants.cjs');
|
|
5
|
+
|
|
6
|
+
const SearchTool = () => {
|
|
7
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
8
|
+
|
|
9
|
+
const channel = useChannel({
|
|
10
|
+
[EVENTS.QUERY_EXECUTED + '_RESPONSE']: (data) => {
|
|
11
|
+
console.log('Query response received:', data);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const toggleSearch = React.useCallback(() => {
|
|
16
|
+
const newState = !isOpen;
|
|
17
|
+
console.log('Toggle search - current isOpen:', isOpen, 'newState:', newState);
|
|
18
|
+
|
|
19
|
+
if (newState) {
|
|
20
|
+
const searchQuery = prompt('Enter search query (e.g., "primary color", "spacing", "button"):');
|
|
21
|
+
if (searchQuery) {
|
|
22
|
+
console.log('Executing search query:', searchQuery);
|
|
23
|
+
channel.emit(EVENTS.QUERY_EXECUTED, { query: searchQuery });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
setIsOpen(newState);
|
|
28
|
+
}, [isOpen, channel]);
|
|
29
|
+
|
|
30
|
+
return React.createElement(
|
|
31
|
+
IconButton,
|
|
32
|
+
{
|
|
33
|
+
key: 'search-tool',
|
|
34
|
+
active: isOpen,
|
|
35
|
+
title: 'Quick Search PDS',
|
|
36
|
+
onClick: toggleSearch
|
|
37
|
+
},
|
|
38
|
+
React.createElement(
|
|
39
|
+
'svg',
|
|
40
|
+
{ width: '14', height: '14', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2' },
|
|
41
|
+
React.createElement('circle', { cx: '11', cy: '11', r: '8' }),
|
|
42
|
+
React.createElement('path', { d: 'm21 21-4.35-4.35' })
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
module.exports = { SearchTool };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const React = require('react');
|
|
2
|
+
const { useChannel } = require('@storybook/manager-api');
|
|
3
|
+
const { IconButton } = require('@storybook/components');
|
|
4
|
+
const { EVENTS } = require('./constants.cjs');
|
|
5
|
+
|
|
6
|
+
const Tool = () => {
|
|
7
|
+
const emit = useChannel({
|
|
8
|
+
[EVENTS.DESIGN_UPDATED]: (data) => {
|
|
9
|
+
console.log('Design updated in addon:', data);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const openConfigurator = React.useCallback(() => {
|
|
14
|
+
console.log('Opening PDS Configurator');
|
|
15
|
+
emit(EVENTS.OPEN_CONFIGURATOR);
|
|
16
|
+
}, [emit]);
|
|
17
|
+
|
|
18
|
+
return React.createElement(
|
|
19
|
+
IconButton,
|
|
20
|
+
{
|
|
21
|
+
key: 'configurator-toggle',
|
|
22
|
+
title: 'Open PDS Configurator',
|
|
23
|
+
onClick: openConfigurator
|
|
24
|
+
},
|
|
25
|
+
React.createElement(
|
|
26
|
+
'svg',
|
|
27
|
+
{ width: '14', height: '14', viewBox: '0 0 24 24', fill: 'currentColor' },
|
|
28
|
+
React.createElement('path', {
|
|
29
|
+
d: 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z'
|
|
30
|
+
}),
|
|
31
|
+
React.createElement('circle', { cx: '12', cy: '12', r: '3' })
|
|
32
|
+
)
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
module.exports = { Tool };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const ADDON_ID = 'pds-configurator';
|
|
2
|
+
const TOOL_ID = `${ADDON_ID}/tool`;
|
|
3
|
+
const PANEL_ID = `${ADDON_ID}/panel`;
|
|
4
|
+
|
|
5
|
+
const EVENTS = {
|
|
6
|
+
OPEN_CONFIGURATOR: `${ADDON_ID}/openConfigurator`,
|
|
7
|
+
DESIGN_UPDATED: `${ADDON_ID}/designUpdated`,
|
|
8
|
+
QUERY_EXECUTED: `${ADDON_ID}/queryExecuted`,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
ADDON_ID,
|
|
13
|
+
TOOL_ID,
|
|
14
|
+
PANEL_ID,
|
|
15
|
+
EVENTS,
|
|
16
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const { addons, types } = require('@storybook/manager-api');
|
|
2
|
+
const { ADDON_ID, TOOL_ID } = require('./constants.cjs');
|
|
3
|
+
const { Tool } = require('./Tool.cjs');
|
|
4
|
+
|
|
5
|
+
addons.register(ADDON_ID, () => {
|
|
6
|
+
addons.add(TOOL_ID, {
|
|
7
|
+
type: types.TOOL,
|
|
8
|
+
title: 'PDS Configurator',
|
|
9
|
+
match: ({ viewMode, tabId }) => !tabId && (viewMode === 'story' || viewMode === 'docs'),
|
|
10
|
+
render: Tool
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const { addons, types } = require('@storybook/manager-api');
|
|
2
|
+
const { ADDON_ID, TOOL_ID } = require('./constants.cjs');
|
|
3
|
+
const { Tool } = require('./Tool.cjs');
|
|
4
4
|
|
|
5
5
|
addons.register(ADDON_ID, () => {
|
|
6
|
-
// Register PDS Configurator button
|
|
7
6
|
addons.add(TOOL_ID, {
|
|
8
7
|
type: types.TOOL,
|
|
9
8
|
title: 'PDS Configurator',
|
package/.storybook/main.js
CHANGED
|
@@ -29,9 +29,9 @@ const config = {
|
|
|
29
29
|
addons: [
|
|
30
30
|
'@storybook/addon-links',
|
|
31
31
|
'@storybook/addon-essentials',
|
|
32
|
-
'./addons/pds-configurator/register.
|
|
33
|
-
'./addons/html-preview/register.
|
|
34
|
-
'./addons/description/register.
|
|
32
|
+
'./addons/pds-configurator/register.cjs',
|
|
33
|
+
'./addons/html-preview/register.cjs',
|
|
34
|
+
'./addons/description/register.cjs'
|
|
35
35
|
],
|
|
36
36
|
framework: {
|
|
37
37
|
name: '@storybook/web-components-vite',
|
package/dist/pds-reference.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pure-ds/storybook",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.46",
|
|
4
4
|
"description": "Storybook showcase for Pure Design System with live configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"pds:build-icons": "pds-build-icons"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@pure-ds/core": "^0.5.
|
|
41
|
+
"@pure-ds/core": "^0.5.46"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@custom-elements-manifest/analyzer": "^0.11.0",
|