@dxos/storybook-utils 0.8.3 → 0.8.4-main.1068cf700f
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/lib/browser/index.mjs +48 -127
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +48 -127
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/DocsContainer.d.ts +4 -0
- package/dist/types/src/components/DocsContainer.d.ts.map +1 -0
- package/dist/types/src/components/ThemeEditor.d.ts +5 -0
- package/dist/types/src/components/ThemeEditor.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/decorators/index.d.ts +2 -2
- package/dist/types/src/decorators/index.d.ts.map +1 -1
- package/dist/types/src/decorators/withLayout.d.ts +1 -18
- package/dist/types/src/decorators/withLayout.d.ts.map +1 -1
- package/dist/types/src/decorators/withRegistry.d.ts +6 -0
- package/dist/types/src/decorators/withRegistry.d.ts.map +1 -0
- package/dist/types/src/decorators/withThemeEditor.d.ts +6 -0
- package/dist/types/src/decorators/withThemeEditor.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/stories/test/Test.d.ts +6 -0
- package/dist/types/src/stories/test/Test.d.ts.map +1 -0
- package/dist/types/src/stories/test/Test.stories.d.ts +11 -0
- package/dist/types/src/stories/test/Test.stories.d.ts.map +1 -0
- package/dist/types/src/stories/test/Test.test.d.ts +2 -0
- package/dist/types/src/stories/test/Test.test.d.ts.map +1 -0
- package/dist/types/src/util.d.ts +1 -1
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/src/vitest-setup.d.ts +2 -0
- package/dist/types/src/vitest-setup.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -20
- package/src/components/DocsContainer.tsx +18 -0
- package/src/components/ThemeEditor.tsx +18 -0
- package/src/components/index.ts +5 -0
- package/src/decorators/index.ts +2 -2
- package/src/decorators/withLayout.tsx +15 -74
- package/src/decorators/withRegistry.tsx +23 -0
- package/src/decorators/withThemeEditor.tsx +28 -0
- package/src/index.ts +1 -6
- package/src/stories/test/Test.stories.tsx +61 -0
- package/src/stories/test/Test.test.tsx +30 -0
- package/src/stories/test/Test.tsx +15 -0
- package/src/stories/test/__snapshots__/Test.test.tsx.snap +3 -0
- package/src/stories/test/index.mdx__ +17 -0
- package/src/util.tsx +5 -2
- package/src/vitest-setup.ts +11 -0
- package/README.yml +0 -1
- package/dist/lib/node/index.cjs +0 -170
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/types/src/decorators/withSignals.d.ts +0 -6
- package/dist/types/src/decorators/withSignals.d.ts.map +0 -1
- package/dist/types/src/decorators/withTheme.d.ts +0 -7
- package/dist/types/src/decorators/withTheme.d.ts.map +0 -1
- package/src/decorators/withSignals.tsx +0 -16
- package/src/decorators/withTheme.tsx +0 -84
|
@@ -1,141 +1,62 @@
|
|
|
1
|
-
//
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
// packages/common/storybook-utils/src/decorators/withLayout.tsx
|
|
5
|
-
import defaultsDeep from "lodash.defaultsdeep";
|
|
6
|
-
import React from "react";
|
|
7
|
-
import { DensityProvider } from "@dxos/react-ui";
|
|
8
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
9
|
-
var defaultOptions = {
|
|
10
|
-
density: "fine"
|
|
11
|
-
};
|
|
12
|
-
var providers = [
|
|
13
|
-
(children, options) => {
|
|
14
|
-
return options?.density ? /* @__PURE__ */ React.createElement(DensityProvider, {
|
|
15
|
-
density: options.density
|
|
16
|
-
}, children) : children;
|
|
17
|
-
}
|
|
18
|
-
];
|
|
19
|
-
var withLayout = ({ classNames, fullscreen, Container = fullscreen ? FixedContainer : DefaultContainer, ...providedOptions } = {}) => {
|
|
20
|
-
return (Story, _context) => {
|
|
21
|
-
const children = /* @__PURE__ */ React.createElement(Container, {
|
|
22
|
-
classNames,
|
|
23
|
-
fullscreen
|
|
24
|
-
}, /* @__PURE__ */ React.createElement(Story, null));
|
|
25
|
-
const options = defaultsDeep({}, providedOptions, defaultOptions);
|
|
26
|
-
return providers.reduceRight((acc, provider) => provider(acc, options), children);
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
var DefaultContainer = ({ children, classNames }) => {
|
|
30
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
31
|
-
role: "none",
|
|
32
|
-
className: mx(classNames)
|
|
33
|
-
}, children);
|
|
34
|
-
};
|
|
35
|
-
var FixedContainer = ({ children, classNames }) => {
|
|
36
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
37
|
-
role: "none",
|
|
38
|
-
className: mx("fixed inset-0 flex overflow-hidden", classNames)
|
|
39
|
-
}, children);
|
|
40
|
-
};
|
|
41
|
-
var ColumnContainer = ({ children, classNames = "w-[30rem]", ...props }) => {
|
|
42
|
-
return /* @__PURE__ */ React.createElement(FixedContainer, {
|
|
43
|
-
classNames: "justify-center bg-modalSurface",
|
|
44
|
-
...props
|
|
45
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
46
|
-
role: "none",
|
|
47
|
-
className: mx("flex flex-col h-full overflow-y-auto bg-baseSurface", classNames)
|
|
48
|
-
}, children));
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// packages/common/storybook-utils/src/decorators/withSignals.tsx
|
|
52
|
-
import React2 from "react";
|
|
53
|
-
import { registerSignalsRuntime } from "@dxos/echo-signals/react";
|
|
54
|
-
var withSignals = (Story) => {
|
|
55
|
-
registerSignalsRuntime();
|
|
56
|
-
return /* @__PURE__ */ React2.createElement(Story, null);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// packages/common/storybook-utils/src/decorators/withTheme.tsx
|
|
60
|
-
import { addons } from "@storybook/preview-api";
|
|
61
|
-
import React3, { memo, useCallback, useEffect, useState } from "react";
|
|
62
|
-
import { DARK_MODE_EVENT_NAME } from "storybook-dark-mode";
|
|
1
|
+
// src/components/ThemeEditor.tsx
|
|
2
|
+
import React, { memo } from "react";
|
|
63
3
|
import { DxThemeEditor as NaturalDxThemeEditor } from "@dxos/lit-theme-editor";
|
|
64
|
-
import "@dxos/lit-theme-editor/dx-theme-editor.pcss";
|
|
65
4
|
import { createComponent } from "@dxos/lit-ui/react";
|
|
66
|
-
import
|
|
67
|
-
import { defaultTx } from "@dxos/react-ui-theme";
|
|
68
|
-
import { PARAM_KEY } from "@dxos/theme-editor-addon";
|
|
5
|
+
import "@dxos/lit-theme-editor/dx-theme-editor.pcss";
|
|
69
6
|
var DxThemeEditor = createComponent({
|
|
70
7
|
tagName: "dx-theme-editor",
|
|
71
8
|
elementClass: NaturalDxThemeEditor,
|
|
72
|
-
react:
|
|
9
|
+
react: React
|
|
73
10
|
});
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
handleOpenChange(true);
|
|
89
|
-
};
|
|
90
|
-
addons.getChannel().on(PARAM_KEY, openEditor);
|
|
91
|
-
return () => addons.getChannel().off(PARAM_KEY, openEditor);
|
|
92
|
-
}, []);
|
|
93
|
-
return /* @__PURE__ */ React3.createElement(ThemeProvider, {
|
|
94
|
-
tx: defaultTx,
|
|
95
|
-
themeMode,
|
|
96
|
-
resourceExtensions: context?.parameters?.translations,
|
|
97
|
-
noCache: true
|
|
98
|
-
}, /* @__PURE__ */ React3.createElement(Tooltip.Provider, null, /* @__PURE__ */ React3.createElement(MemoizedStory, null), /* @__PURE__ */ React3.createElement(Dialog.Root, {
|
|
99
|
-
open: editorOpen,
|
|
100
|
-
onOpenChange: handleOpenChange,
|
|
101
|
-
modal: false
|
|
102
|
-
}, /* @__PURE__ */ React3.createElement("div", {
|
|
103
|
-
role: "none",
|
|
104
|
-
className: "dx-dialog__overlay bg-transparent pointer-events-none",
|
|
105
|
-
style: {
|
|
106
|
-
placeContent: "end"
|
|
107
|
-
}
|
|
108
|
-
}, /* @__PURE__ */ React3.createElement(Dialog.Content, {
|
|
109
|
-
classNames: "relative box-content py-0 px-2 md:is-[35rem] md:max-is-none overflow-y-auto layout-contain pointer-events-auto",
|
|
110
|
-
style: {
|
|
111
|
-
maxBlockSize: "50dvh"
|
|
112
|
-
},
|
|
113
|
-
onInteractOutside: (event) => event.preventDefault()
|
|
114
|
-
}, /* @__PURE__ */ React3.createElement(Dialog.Title, {
|
|
115
|
-
srOnly: true
|
|
116
|
-
}, "Theme Editor"), editorOpen && /* @__PURE__ */ React3.createElement(DxThemeEditor, null), /* @__PURE__ */ React3.createElement(Dialog.Close, {
|
|
117
|
-
asChild: true
|
|
118
|
-
}, /* @__PURE__ */ React3.createElement(IconButton, {
|
|
119
|
-
iconOnly: true,
|
|
120
|
-
icon: "ph--x--regular",
|
|
121
|
-
label: "Close",
|
|
122
|
-
classNames: "absolute block-start-2 inline-end-2"
|
|
123
|
-
})))))));
|
|
11
|
+
var ThemeEditor = /* @__PURE__ */ memo(DxThemeEditor);
|
|
12
|
+
|
|
13
|
+
// src/decorators/withLayout.tsx
|
|
14
|
+
import React2 from "react";
|
|
15
|
+
var withLayout = (Story, context) => {
|
|
16
|
+
switch (context.parameters.layout) {
|
|
17
|
+
case "fullscreen":
|
|
18
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
19
|
+
role: "none",
|
|
20
|
+
className: "fixed inset-0 flex flex-col overflow-hidden bg-baseSurface"
|
|
21
|
+
}, /* @__PURE__ */ React2.createElement(Story, null));
|
|
22
|
+
default:
|
|
23
|
+
return /* @__PURE__ */ React2.createElement(Story, null);
|
|
24
|
+
}
|
|
124
25
|
};
|
|
125
26
|
|
|
126
|
-
//
|
|
127
|
-
import
|
|
128
|
-
|
|
27
|
+
// src/decorators/withRegistry.tsx
|
|
28
|
+
import { Registry, RegistryContext } from "@effect-atom/atom-react";
|
|
29
|
+
import React3, { memo as memo2, useMemo } from "react";
|
|
30
|
+
var withRegistry = (Story) => {
|
|
31
|
+
const registry = useMemo(() => Registry.make(), []);
|
|
32
|
+
const MemoizedStory = /* @__PURE__ */ memo2(Story);
|
|
33
|
+
return /* @__PURE__ */ React3.createElement(RegistryContext.Provider, {
|
|
34
|
+
value: registry
|
|
35
|
+
}, /* @__PURE__ */ React3.createElement(MemoizedStory, null));
|
|
36
|
+
};
|
|
129
37
|
|
|
130
|
-
//
|
|
131
|
-
|
|
38
|
+
// src/decorators/withThemeEditor.tsx
|
|
39
|
+
import React4, { memo as memo3 } from "react";
|
|
40
|
+
var withThemeEditor = (Story, context) => {
|
|
41
|
+
const MemoizedStory = /* @__PURE__ */ memo3(Story);
|
|
42
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(MemoizedStory, null), /* @__PURE__ */ React4.createElement("div", {
|
|
43
|
+
className: "absolute top-4 bottom-4 right-4 z-10"
|
|
44
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
45
|
+
className: "bs-full is-[35rem] overflow-auto bg-baseSurface border border-separator rounded"
|
|
46
|
+
}, /* @__PURE__ */ React4.createElement(ThemeEditor, null))));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// src/util.tsx
|
|
50
|
+
import React5 from "react";
|
|
51
|
+
var render = (Story) => (args) => {
|
|
52
|
+
const result = /* @__PURE__ */ React5.createElement(Story, args);
|
|
53
|
+
return result ?? /* @__PURE__ */ React5.createElement("div", null);
|
|
54
|
+
};
|
|
132
55
|
export {
|
|
133
|
-
|
|
134
|
-
DefaultContainer,
|
|
135
|
-
FixedContainer,
|
|
56
|
+
ThemeEditor,
|
|
136
57
|
render,
|
|
137
58
|
withLayout,
|
|
138
|
-
|
|
139
|
-
|
|
59
|
+
withRegistry,
|
|
60
|
+
withThemeEditor
|
|
140
61
|
};
|
|
141
62
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright
|
|
5
|
-
"mappings": ";AAIA,
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/components/ThemeEditor.tsx", "../../../src/decorators/withLayout.tsx", "../../../src/decorators/withRegistry.tsx", "../../../src/decorators/withThemeEditor.tsx", "../../../src/util.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { memo } from 'react';\n\nimport { DxThemeEditor as NaturalDxThemeEditor } from '@dxos/lit-theme-editor';\nimport { createComponent } from '@dxos/lit-ui/react';\n\nimport '@dxos/lit-theme-editor/dx-theme-editor.pcss';\n\nconst DxThemeEditor = createComponent({\n tagName: 'dx-theme-editor',\n elementClass: NaturalDxThemeEditor,\n react: React,\n});\n\nexport const ThemeEditor = memo(DxThemeEditor);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react';\nimport React from 'react';\n\nexport const withLayout: Decorator = (Story, context) => {\n switch (context.parameters.layout) {\n case 'fullscreen':\n return (\n <div role='none' className='fixed inset-0 flex flex-col overflow-hidden bg-baseSurface'>\n <Story />\n </div>\n );\n\n default:\n return <Story />;\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Registry, RegistryContext } from '@effect-atom/atom-react';\nimport { type Decorator } from '@storybook/react';\nimport React, { memo, useMemo } from 'react';\n\n/**\n * Adds Effect Atom registry context for storybook.\n */\nexport const withRegistry: Decorator = (Story) => {\n const registry = useMemo(() => Registry.make(), []);\n\n // Prevent re-rendering of the story.\n const MemoizedStory = memo(Story);\n\n return (\n <RegistryContext.Provider value={registry}>\n <MemoizedStory />\n </RegistryContext.Provider>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react';\nimport React, { memo } from 'react';\n\nimport { ThemeEditor } from '../components/ThemeEditor';\n\n/**\n * Show theme editor.\n */\n// TODO(burdon): Ideally move to storybook-addon-theme, but this has a build issue since the addon would depend on the vite theme plugin.\nexport const withThemeEditor: Decorator = (Story, context) => {\n // Prevent re-rendering of the story.\n const MemoizedStory = memo(Story);\n\n return (\n <>\n <MemoizedStory />\n <div className='absolute top-4 bottom-4 right-4 z-10'>\n <div className='bs-full is-[35rem] overflow-auto bg-baseSurface border border-separator rounded'>\n <ThemeEditor />\n </div>\n </div>\n </>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { type FC } from 'react';\n\n/**\n * Story renderer wrapper.\n */\nexport const render =\n <T extends Record<string, any>>(Story: FC<T>) =>\n (args: unknown) => {\n const result = <Story {...(args as T)} />;\n return result ?? <div />;\n };\n"],
|
|
5
|
+
"mappings": ";AAIA,OAAOA,SAASC,YAAY;AAE5B,SAASC,iBAAiBC,4BAA4B;AACtD,SAASC,uBAAuB;AAEhC,OAAO;AAEP,IAAMC,gBAAgBC,gBAAgB;EACpCC,SAAS;EACTC,cAAcC;EACdC,OAAOC;AACT,CAAA;AAEO,IAAMC,cAAcC,qBAAKR,aAAAA;;;ACZhC,OAAOS,YAAW;AAEX,IAAMC,aAAwB,CAACC,OAAOC,YAAAA;AAC3C,UAAQA,QAAQC,WAAWC,QAAM;IAC/B,KAAK;AACH,aACE,gBAAAC,OAAA,cAACC,OAAAA;QAAIC,MAAK;QAAOC,WAAU;SACzB,gBAAAH,OAAA,cAACJ,OAAAA,IAAAA,CAAAA;IAIP;AACE,aAAO,gBAAAI,OAAA,cAACJ,OAAAA,IAAAA;EACZ;AACF;;;ACfA,SAASQ,UAAUC,uBAAuB;AAE1C,OAAOC,UAASC,QAAAA,OAAMC,eAAe;AAK9B,IAAMC,eAA0B,CAACC,UAAAA;AACtC,QAAMC,WAAWC,QAAQ,MAAMC,SAASC,KAAI,GAAI,CAAA,CAAE;AAGlD,QAAMC,gBAAgBC,gBAAAA,MAAKN,KAAAA;AAE3B,SACE,gBAAAO,OAAA,cAACC,gBAAgBC,UAAQ;IAACC,OAAOT;KAC/B,gBAAAM,OAAA,cAACF,eAAAA,IAAAA,CAAAA;AAGP;;;ACjBA,OAAOM,UAASC,QAAAA,aAAY;AAQrB,IAAMC,kBAA6B,CAACC,OAAOC,YAAAA;AAEhD,QAAMC,gBAAgBC,gBAAAA,MAAKH,KAAAA;AAE3B,SACE,gBAAAI,OAAA,cAAAA,OAAA,UAAA,MACE,gBAAAA,OAAA,cAACF,eAAAA,IAAAA,GACD,gBAAAE,OAAA,cAACC,OAAAA;IAAIC,WAAU;KACb,gBAAAF,OAAA,cAACC,OAAAA;IAAIC,WAAU;KACb,gBAAAF,OAAA,cAACG,aAAAA,IAAAA,CAAAA,CAAAA,CAAAA;AAKX;;;ACvBA,OAAOC,YAAwB;AAKxB,IAAMC,SACX,CAAgCC,UAChC,CAACC,SAAAA;AACC,QAAMC,SAAS,gBAAAC,OAAA,cAACH,OAAWC,IAAAA;AAC3B,SAAOC,UAAU,gBAAAC,OAAA,cAACC,OAAAA,IAAAA;AACpB;",
|
|
6
|
+
"names": ["React", "memo", "DxThemeEditor", "NaturalDxThemeEditor", "createComponent", "DxThemeEditor", "createComponent", "tagName", "elementClass", "NaturalDxThemeEditor", "react", "React", "ThemeEditor", "memo", "React", "withLayout", "Story", "context", "parameters", "layout", "React", "div", "role", "className", "Registry", "RegistryContext", "React", "memo", "useMemo", "withRegistry", "Story", "registry", "useMemo", "Registry", "make", "MemoizedStory", "memo", "React", "RegistryContext", "Provider", "value", "React", "memo", "withThemeEditor", "Story", "context", "MemoizedStory", "memo", "React", "div", "className", "ThemeEditor", "React", "render", "Story", "args", "result", "React", "div"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"
|
|
1
|
+
{"inputs":{"src/components/ThemeEditor.tsx":{"bytes":1828,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/lit-theme-editor","kind":"import-statement","external":true},{"path":"@dxos/lit-ui/react","kind":"import-statement","external":true},{"path":"@dxos/lit-theme-editor/dx-theme-editor.pcss","kind":"import-statement","external":true}],"format":"esm"},"src/components/index.ts":{"bytes":480,"imports":[{"path":"src/components/ThemeEditor.tsx","kind":"import-statement","original":"./ThemeEditor"}],"format":"esm"},"src/decorators/withLayout.tsx":{"bytes":1803,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/decorators/withRegistry.tsx":{"bytes":2217,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/decorators/withThemeEditor.tsx":{"bytes":2746,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/components/ThemeEditor.tsx","kind":"import-statement","original":"../components/ThemeEditor"}],"format":"esm"},"src/decorators/index.ts":{"bytes":682,"imports":[{"path":"src/decorators/withLayout.tsx","kind":"import-statement","original":"./withLayout"},{"path":"src/decorators/withRegistry.tsx","kind":"import-statement","original":"./withRegistry"},{"path":"src/decorators/withThemeEditor.tsx","kind":"import-statement","original":"./withThemeEditor"}],"format":"esm"},"src/util.tsx":{"bytes":1228,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":634,"imports":[{"path":"src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"src/decorators/index.ts","kind":"import-statement","original":"./decorators"},{"path":"src/util.tsx","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4806},"dist/lib/browser/index.mjs":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/lit-theme-editor","kind":"import-statement","external":true},{"path":"@dxos/lit-ui/react","kind":"import-statement","external":true},{"path":"@dxos/lit-theme-editor/dx-theme-editor.pcss","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["ThemeEditor","render","withLayout","withRegistry","withThemeEditor"],"entryPoint":"src/index.ts","inputs":{"src/components/ThemeEditor.tsx":{"bytesInOutput":405},"src/components/index.ts":{"bytesInOutput":0},"src/index.ts":{"bytesInOutput":0},"src/decorators/withLayout.tsx":{"bytesInOutput":435},"src/decorators/index.ts":{"bytesInOutput":0},"src/decorators/withRegistry.tsx":{"bytesInOutput":428},"src/decorators/withThemeEditor.tsx":{"bytesInOutput":589},"src/util.tsx":{"bytesInOutput":205}},"bytes":2342}}}
|
|
@@ -1,143 +1,64 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
// packages/common/storybook-utils/src/decorators/withLayout.tsx
|
|
7
|
-
import defaultsDeep from "lodash.defaultsdeep";
|
|
8
|
-
import React from "react";
|
|
9
|
-
import { DensityProvider } from "@dxos/react-ui";
|
|
10
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
11
|
-
var defaultOptions = {
|
|
12
|
-
density: "fine"
|
|
13
|
-
};
|
|
14
|
-
var providers = [
|
|
15
|
-
(children, options) => {
|
|
16
|
-
return options?.density ? /* @__PURE__ */ React.createElement(DensityProvider, {
|
|
17
|
-
density: options.density
|
|
18
|
-
}, children) : children;
|
|
19
|
-
}
|
|
20
|
-
];
|
|
21
|
-
var withLayout = ({ classNames, fullscreen, Container = fullscreen ? FixedContainer : DefaultContainer, ...providedOptions } = {}) => {
|
|
22
|
-
return (Story, _context) => {
|
|
23
|
-
const children = /* @__PURE__ */ React.createElement(Container, {
|
|
24
|
-
classNames,
|
|
25
|
-
fullscreen
|
|
26
|
-
}, /* @__PURE__ */ React.createElement(Story, null));
|
|
27
|
-
const options = defaultsDeep({}, providedOptions, defaultOptions);
|
|
28
|
-
return providers.reduceRight((acc, provider) => provider(acc, options), children);
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
var DefaultContainer = ({ children, classNames }) => {
|
|
32
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
33
|
-
role: "none",
|
|
34
|
-
className: mx(classNames)
|
|
35
|
-
}, children);
|
|
36
|
-
};
|
|
37
|
-
var FixedContainer = ({ children, classNames }) => {
|
|
38
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
39
|
-
role: "none",
|
|
40
|
-
className: mx("fixed inset-0 flex overflow-hidden", classNames)
|
|
41
|
-
}, children);
|
|
42
|
-
};
|
|
43
|
-
var ColumnContainer = ({ children, classNames = "w-[30rem]", ...props }) => {
|
|
44
|
-
return /* @__PURE__ */ React.createElement(FixedContainer, {
|
|
45
|
-
classNames: "justify-center bg-modalSurface",
|
|
46
|
-
...props
|
|
47
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
48
|
-
role: "none",
|
|
49
|
-
className: mx("flex flex-col h-full overflow-y-auto bg-baseSurface", classNames)
|
|
50
|
-
}, children));
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// packages/common/storybook-utils/src/decorators/withSignals.tsx
|
|
54
|
-
import React2 from "react";
|
|
55
|
-
import { registerSignalsRuntime } from "@dxos/echo-signals/react";
|
|
56
|
-
var withSignals = (Story) => {
|
|
57
|
-
registerSignalsRuntime();
|
|
58
|
-
return /* @__PURE__ */ React2.createElement(Story, null);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// packages/common/storybook-utils/src/decorators/withTheme.tsx
|
|
62
|
-
import { addons } from "@storybook/preview-api";
|
|
63
|
-
import React3, { memo, useCallback, useEffect, useState } from "react";
|
|
64
|
-
import { DARK_MODE_EVENT_NAME } from "storybook-dark-mode";
|
|
3
|
+
// src/components/ThemeEditor.tsx
|
|
4
|
+
import React, { memo } from "react";
|
|
65
5
|
import { DxThemeEditor as NaturalDxThemeEditor } from "@dxos/lit-theme-editor";
|
|
66
|
-
import "@dxos/lit-theme-editor/dx-theme-editor.pcss";
|
|
67
6
|
import { createComponent } from "@dxos/lit-ui/react";
|
|
68
|
-
import
|
|
69
|
-
import { defaultTx } from "@dxos/react-ui-theme";
|
|
70
|
-
import { PARAM_KEY } from "@dxos/theme-editor-addon";
|
|
7
|
+
import "@dxos/lit-theme-editor/dx-theme-editor.pcss";
|
|
71
8
|
var DxThemeEditor = createComponent({
|
|
72
9
|
tagName: "dx-theme-editor",
|
|
73
10
|
elementClass: NaturalDxThemeEditor,
|
|
74
|
-
react:
|
|
11
|
+
react: React
|
|
75
12
|
});
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
handleOpenChange(true);
|
|
91
|
-
};
|
|
92
|
-
addons.getChannel().on(PARAM_KEY, openEditor);
|
|
93
|
-
return () => addons.getChannel().off(PARAM_KEY, openEditor);
|
|
94
|
-
}, []);
|
|
95
|
-
return /* @__PURE__ */ React3.createElement(ThemeProvider, {
|
|
96
|
-
tx: defaultTx,
|
|
97
|
-
themeMode,
|
|
98
|
-
resourceExtensions: context?.parameters?.translations,
|
|
99
|
-
noCache: true
|
|
100
|
-
}, /* @__PURE__ */ React3.createElement(Tooltip.Provider, null, /* @__PURE__ */ React3.createElement(MemoizedStory, null), /* @__PURE__ */ React3.createElement(Dialog.Root, {
|
|
101
|
-
open: editorOpen,
|
|
102
|
-
onOpenChange: handleOpenChange,
|
|
103
|
-
modal: false
|
|
104
|
-
}, /* @__PURE__ */ React3.createElement("div", {
|
|
105
|
-
role: "none",
|
|
106
|
-
className: "dx-dialog__overlay bg-transparent pointer-events-none",
|
|
107
|
-
style: {
|
|
108
|
-
placeContent: "end"
|
|
109
|
-
}
|
|
110
|
-
}, /* @__PURE__ */ React3.createElement(Dialog.Content, {
|
|
111
|
-
classNames: "relative box-content py-0 px-2 md:is-[35rem] md:max-is-none overflow-y-auto layout-contain pointer-events-auto",
|
|
112
|
-
style: {
|
|
113
|
-
maxBlockSize: "50dvh"
|
|
114
|
-
},
|
|
115
|
-
onInteractOutside: (event) => event.preventDefault()
|
|
116
|
-
}, /* @__PURE__ */ React3.createElement(Dialog.Title, {
|
|
117
|
-
srOnly: true
|
|
118
|
-
}, "Theme Editor"), editorOpen && /* @__PURE__ */ React3.createElement(DxThemeEditor, null), /* @__PURE__ */ React3.createElement(Dialog.Close, {
|
|
119
|
-
asChild: true
|
|
120
|
-
}, /* @__PURE__ */ React3.createElement(IconButton, {
|
|
121
|
-
iconOnly: true,
|
|
122
|
-
icon: "ph--x--regular",
|
|
123
|
-
label: "Close",
|
|
124
|
-
classNames: "absolute block-start-2 inline-end-2"
|
|
125
|
-
})))))));
|
|
13
|
+
var ThemeEditor = /* @__PURE__ */ memo(DxThemeEditor);
|
|
14
|
+
|
|
15
|
+
// src/decorators/withLayout.tsx
|
|
16
|
+
import React2 from "react";
|
|
17
|
+
var withLayout = (Story, context) => {
|
|
18
|
+
switch (context.parameters.layout) {
|
|
19
|
+
case "fullscreen":
|
|
20
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
21
|
+
role: "none",
|
|
22
|
+
className: "fixed inset-0 flex flex-col overflow-hidden bg-baseSurface"
|
|
23
|
+
}, /* @__PURE__ */ React2.createElement(Story, null));
|
|
24
|
+
default:
|
|
25
|
+
return /* @__PURE__ */ React2.createElement(Story, null);
|
|
26
|
+
}
|
|
126
27
|
};
|
|
127
28
|
|
|
128
|
-
//
|
|
129
|
-
import
|
|
130
|
-
|
|
29
|
+
// src/decorators/withRegistry.tsx
|
|
30
|
+
import { Registry, RegistryContext } from "@effect-atom/atom-react";
|
|
31
|
+
import React3, { memo as memo2, useMemo } from "react";
|
|
32
|
+
var withRegistry = (Story) => {
|
|
33
|
+
const registry = useMemo(() => Registry.make(), []);
|
|
34
|
+
const MemoizedStory = /* @__PURE__ */ memo2(Story);
|
|
35
|
+
return /* @__PURE__ */ React3.createElement(RegistryContext.Provider, {
|
|
36
|
+
value: registry
|
|
37
|
+
}, /* @__PURE__ */ React3.createElement(MemoizedStory, null));
|
|
38
|
+
};
|
|
131
39
|
|
|
132
|
-
//
|
|
133
|
-
|
|
40
|
+
// src/decorators/withThemeEditor.tsx
|
|
41
|
+
import React4, { memo as memo3 } from "react";
|
|
42
|
+
var withThemeEditor = (Story, context) => {
|
|
43
|
+
const MemoizedStory = /* @__PURE__ */ memo3(Story);
|
|
44
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(MemoizedStory, null), /* @__PURE__ */ React4.createElement("div", {
|
|
45
|
+
className: "absolute top-4 bottom-4 right-4 z-10"
|
|
46
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
47
|
+
className: "bs-full is-[35rem] overflow-auto bg-baseSurface border border-separator rounded"
|
|
48
|
+
}, /* @__PURE__ */ React4.createElement(ThemeEditor, null))));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// src/util.tsx
|
|
52
|
+
import React5 from "react";
|
|
53
|
+
var render = (Story) => (args) => {
|
|
54
|
+
const result = /* @__PURE__ */ React5.createElement(Story, args);
|
|
55
|
+
return result ?? /* @__PURE__ */ React5.createElement("div", null);
|
|
56
|
+
};
|
|
134
57
|
export {
|
|
135
|
-
|
|
136
|
-
DefaultContainer,
|
|
137
|
-
FixedContainer,
|
|
58
|
+
ThemeEditor,
|
|
138
59
|
render,
|
|
139
60
|
withLayout,
|
|
140
|
-
|
|
141
|
-
|
|
61
|
+
withRegistry,
|
|
62
|
+
withThemeEditor
|
|
142
63
|
};
|
|
143
64
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright
|
|
5
|
-
"mappings": ";;;AAIA,
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/components/ThemeEditor.tsx", "../../../src/decorators/withLayout.tsx", "../../../src/decorators/withRegistry.tsx", "../../../src/decorators/withThemeEditor.tsx", "../../../src/util.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { memo } from 'react';\n\nimport { DxThemeEditor as NaturalDxThemeEditor } from '@dxos/lit-theme-editor';\nimport { createComponent } from '@dxos/lit-ui/react';\n\nimport '@dxos/lit-theme-editor/dx-theme-editor.pcss';\n\nconst DxThemeEditor = createComponent({\n tagName: 'dx-theme-editor',\n elementClass: NaturalDxThemeEditor,\n react: React,\n});\n\nexport const ThemeEditor = memo(DxThemeEditor);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react';\nimport React from 'react';\n\nexport const withLayout: Decorator = (Story, context) => {\n switch (context.parameters.layout) {\n case 'fullscreen':\n return (\n <div role='none' className='fixed inset-0 flex flex-col overflow-hidden bg-baseSurface'>\n <Story />\n </div>\n );\n\n default:\n return <Story />;\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Registry, RegistryContext } from '@effect-atom/atom-react';\nimport { type Decorator } from '@storybook/react';\nimport React, { memo, useMemo } from 'react';\n\n/**\n * Adds Effect Atom registry context for storybook.\n */\nexport const withRegistry: Decorator = (Story) => {\n const registry = useMemo(() => Registry.make(), []);\n\n // Prevent re-rendering of the story.\n const MemoizedStory = memo(Story);\n\n return (\n <RegistryContext.Provider value={registry}>\n <MemoizedStory />\n </RegistryContext.Provider>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react';\nimport React, { memo } from 'react';\n\nimport { ThemeEditor } from '../components/ThemeEditor';\n\n/**\n * Show theme editor.\n */\n// TODO(burdon): Ideally move to storybook-addon-theme, but this has a build issue since the addon would depend on the vite theme plugin.\nexport const withThemeEditor: Decorator = (Story, context) => {\n // Prevent re-rendering of the story.\n const MemoizedStory = memo(Story);\n\n return (\n <>\n <MemoizedStory />\n <div className='absolute top-4 bottom-4 right-4 z-10'>\n <div className='bs-full is-[35rem] overflow-auto bg-baseSurface border border-separator rounded'>\n <ThemeEditor />\n </div>\n </div>\n </>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { type FC } from 'react';\n\n/**\n * Story renderer wrapper.\n */\nexport const render =\n <T extends Record<string, any>>(Story: FC<T>) =>\n (args: unknown) => {\n const result = <Story {...(args as T)} />;\n return result ?? <div />;\n };\n"],
|
|
5
|
+
"mappings": ";;;AAIA,OAAOA,SAASC,YAAY;AAE5B,SAASC,iBAAiBC,4BAA4B;AACtD,SAASC,uBAAuB;AAEhC,OAAO;AAEP,IAAMC,gBAAgBC,gBAAgB;EACpCC,SAAS;EACTC,cAAcC;EACdC,OAAOC;AACT,CAAA;AAEO,IAAMC,cAAcC,qBAAKR,aAAAA;;;ACZhC,OAAOS,YAAW;AAEX,IAAMC,aAAwB,CAACC,OAAOC,YAAAA;AAC3C,UAAQA,QAAQC,WAAWC,QAAM;IAC/B,KAAK;AACH,aACE,gBAAAC,OAAA,cAACC,OAAAA;QAAIC,MAAK;QAAOC,WAAU;SACzB,gBAAAH,OAAA,cAACJ,OAAAA,IAAAA,CAAAA;IAIP;AACE,aAAO,gBAAAI,OAAA,cAACJ,OAAAA,IAAAA;EACZ;AACF;;;ACfA,SAASQ,UAAUC,uBAAuB;AAE1C,OAAOC,UAASC,QAAAA,OAAMC,eAAe;AAK9B,IAAMC,eAA0B,CAACC,UAAAA;AACtC,QAAMC,WAAWC,QAAQ,MAAMC,SAASC,KAAI,GAAI,CAAA,CAAE;AAGlD,QAAMC,gBAAgBC,gBAAAA,MAAKN,KAAAA;AAE3B,SACE,gBAAAO,OAAA,cAACC,gBAAgBC,UAAQ;IAACC,OAAOT;KAC/B,gBAAAM,OAAA,cAACF,eAAAA,IAAAA,CAAAA;AAGP;;;ACjBA,OAAOM,UAASC,QAAAA,aAAY;AAQrB,IAAMC,kBAA6B,CAACC,OAAOC,YAAAA;AAEhD,QAAMC,gBAAgBC,gBAAAA,MAAKH,KAAAA;AAE3B,SACE,gBAAAI,OAAA,cAAAA,OAAA,UAAA,MACE,gBAAAA,OAAA,cAACF,eAAAA,IAAAA,GACD,gBAAAE,OAAA,cAACC,OAAAA;IAAIC,WAAU;KACb,gBAAAF,OAAA,cAACC,OAAAA;IAAIC,WAAU;KACb,gBAAAF,OAAA,cAACG,aAAAA,IAAAA,CAAAA,CAAAA,CAAAA;AAKX;;;ACvBA,OAAOC,YAAwB;AAKxB,IAAMC,SACX,CAAgCC,UAChC,CAACC,SAAAA;AACC,QAAMC,SAAS,gBAAAC,OAAA,cAACH,OAAWC,IAAAA;AAC3B,SAAOC,UAAU,gBAAAC,OAAA,cAACC,OAAAA,IAAAA;AACpB;",
|
|
6
|
+
"names": ["React", "memo", "DxThemeEditor", "NaturalDxThemeEditor", "createComponent", "DxThemeEditor", "createComponent", "tagName", "elementClass", "NaturalDxThemeEditor", "react", "React", "ThemeEditor", "memo", "React", "withLayout", "Story", "context", "parameters", "layout", "React", "div", "role", "className", "Registry", "RegistryContext", "React", "memo", "useMemo", "withRegistry", "Story", "registry", "useMemo", "Registry", "make", "MemoizedStory", "memo", "React", "RegistryContext", "Provider", "value", "React", "memo", "withThemeEditor", "Story", "context", "MemoizedStory", "memo", "React", "div", "className", "ThemeEditor", "React", "render", "Story", "args", "result", "React", "div"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"
|
|
1
|
+
{"inputs":{"src/components/ThemeEditor.tsx":{"bytes":1828,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/lit-theme-editor","kind":"import-statement","external":true},{"path":"@dxos/lit-ui/react","kind":"import-statement","external":true},{"path":"@dxos/lit-theme-editor/dx-theme-editor.pcss","kind":"import-statement","external":true}],"format":"esm"},"src/components/index.ts":{"bytes":480,"imports":[{"path":"src/components/ThemeEditor.tsx","kind":"import-statement","original":"./ThemeEditor"}],"format":"esm"},"src/decorators/withLayout.tsx":{"bytes":1803,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/decorators/withRegistry.tsx":{"bytes":2217,"imports":[{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/decorators/withThemeEditor.tsx":{"bytes":2746,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/components/ThemeEditor.tsx","kind":"import-statement","original":"../components/ThemeEditor"}],"format":"esm"},"src/decorators/index.ts":{"bytes":682,"imports":[{"path":"src/decorators/withLayout.tsx","kind":"import-statement","original":"./withLayout"},{"path":"src/decorators/withRegistry.tsx","kind":"import-statement","original":"./withRegistry"},{"path":"src/decorators/withThemeEditor.tsx","kind":"import-statement","original":"./withThemeEditor"}],"format":"esm"},"src/util.tsx":{"bytes":1228,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":634,"imports":[{"path":"src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"src/decorators/index.ts","kind":"import-statement","original":"./decorators"},{"path":"src/util.tsx","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4808},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/lit-theme-editor","kind":"import-statement","external":true},{"path":"@dxos/lit-ui/react","kind":"import-statement","external":true},{"path":"@dxos/lit-theme-editor/dx-theme-editor.pcss","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["ThemeEditor","render","withLayout","withRegistry","withThemeEditor"],"entryPoint":"src/index.ts","inputs":{"src/components/ThemeEditor.tsx":{"bytesInOutput":405},"src/components/index.ts":{"bytesInOutput":0},"src/index.ts":{"bytesInOutput":0},"src/decorators/withLayout.tsx":{"bytesInOutput":435},"src/decorators/index.ts":{"bytesInOutput":0},"src/decorators/withRegistry.tsx":{"bytesInOutput":428},"src/decorators/withThemeEditor.tsx":{"bytesInOutput":589},"src/util.tsx":{"bytesInOutput":205}},"bytes":2435}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocsContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/DocsContainer.tsx"],"names":[],"mappings":"AAQA;;GAEG"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DxThemeEditor as NaturalDxThemeEditor } from '@dxos/lit-theme-editor';
|
|
3
|
+
import '@dxos/lit-theme-editor/dx-theme-editor.pcss';
|
|
4
|
+
export declare const ThemeEditor: React.NamedExoticComponent<Omit<React.HTMLAttributes<NaturalDxThemeEditor>, "connectedCallback" | "disconnectedCallback" | "render" | "createRenderRoot" | "renderOptions" | "renderRoot" | "isUpdatePending" | "hasUpdated" | "addController" | "removeController" | "attributeChangedCallback" | "requestUpdate" | "updateComplete"> & {} & Partial<Omit<NaturalDxThemeEditor, keyof HTMLElement>> & React.RefAttributes<NaturalDxThemeEditor>>;
|
|
5
|
+
//# sourceMappingURL=ThemeEditor.d.ts.map
|