@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.
@@ -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
- import { addons, types } from '@storybook/manager-api';
2
- import { AddonPanel } from '@storybook/components';
3
- import React, { useEffect, useState } from 'react';
4
- import { Markdown } from '@storybook/blocks';
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('div', {
29
- style: {
30
- padding: '1rem',
31
- height: '100%',
32
- overflow: 'auto'
33
- }
34
- },
35
- React.createElement('div', {
28
+ return React.createElement(
29
+ 'div',
30
+ {
36
31
  style: {
37
- marginBottom: '0.5rem'
32
+ padding: '1rem',
33
+ height: '100%',
34
+ overflow: 'auto'
38
35
  }
39
36
  },
40
- React.createElement('strong', {
41
- style: {
42
- fontSize: '1rem'
43
- }
44
- }, title)
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
- return React.createElement(AddonPanel, { active },
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,12 @@
1
+ const ADDON_ID = 'html-preview';
2
+ const PANEL_ID = `${ADDON_ID}/panel`;
3
+
4
+ const EVENTS = {
5
+ UPDATE_HTML: `${ADDON_ID}/updateHtml`
6
+ };
7
+
8
+ module.exports = {
9
+ ADDON_ID,
10
+ PANEL_ID,
11
+ EVENTS,
12
+ };
@@ -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
- import React from 'react';
2
- import { addons, types } from '@storybook/manager-api';
3
- import { ADDON_ID, PANEL_ID } from './constants.js';
4
- import { Panel } from './Panel.jsx';
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(Panel, { key, active })
38
+ React.createElement(PanelLoader, { key, active })
15
39
  )
16
40
  });
17
41
  });
@@ -1,3 +1,3 @@
1
1
  {
2
- "type": "commonjs"
2
+ "type": "module"
3
3
  }
@@ -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
- import { addons, types } from '@storybook/manager-api';
2
- import { ADDON_ID, TOOL_ID } from './constants.js';
3
- import { Tool } from './Tool.js';
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',
@@ -29,9 +29,9 @@ const config = {
29
29
  addons: [
30
30
  '@storybook/addon-links',
31
31
  '@storybook/addon-essentials',
32
- './addons/pds-configurator/register.js',
33
- './addons/html-preview/register.js',
34
- './addons/description/register.js'
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',
@@ -1,5 +1,5 @@
1
1
  {
2
- "generatedAt": "2026-02-04T07:31:00.131Z",
2
+ "generatedAt": "2026-02-04T08:03:20.323Z",
3
3
  "sources": {
4
4
  "customElements": "custom-elements.json",
5
5
  "ontology": "src\\js\\pds-core\\pds-ontology.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pure-ds/storybook",
3
- "version": "0.5.44",
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.44"
41
+ "@pure-ds/core": "^0.5.46"
42
42
  },
43
43
  "dependencies": {
44
44
  "@custom-elements-manifest/analyzer": "^0.11.0",