@dxos/storybook-utils 0.8.2-main.fbd8ed0 → 0.8.2-staging.7ac8446
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 +15 -32
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/decorators/withLayout.d.ts +3 -9
- package/dist/types/src/decorators/withLayout.d.ts.map +1 -1
- package/dist/types/src/decorators/withTheme.d.ts.map +1 -1
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/decorators/withLayout.tsx +12 -39
- package/src/decorators/withTheme.tsx +2 -4
|
@@ -5,48 +5,34 @@ import { registerSignalsRuntime as registerSignalsRuntime2 } from "@dxos/echo-si
|
|
|
5
5
|
import defaultsDeep from "lodash.defaultsdeep";
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { DensityProvider } from "@dxos/react-ui";
|
|
8
|
+
import { Tooltip } from "@dxos/react-ui";
|
|
8
9
|
import { mx } from "@dxos/react-ui-theme";
|
|
9
10
|
var defaultOptions = {
|
|
10
11
|
density: "fine"
|
|
11
12
|
};
|
|
12
13
|
var providers = [
|
|
14
|
+
(children, options) => {
|
|
15
|
+
return options.tooltips ? /* @__PURE__ */ React.createElement(Tooltip.Provider, null, children) : children;
|
|
16
|
+
},
|
|
13
17
|
(children, options) => {
|
|
14
18
|
return options?.density ? /* @__PURE__ */ React.createElement(DensityProvider, {
|
|
15
19
|
density: options.density
|
|
16
20
|
}, children) : children;
|
|
17
21
|
}
|
|
18
22
|
];
|
|
19
|
-
var withLayout = ({ classNames, fullscreen,
|
|
23
|
+
var withLayout = ({ classNames, fullscreen, ..._options } = {}) => {
|
|
20
24
|
return (Story, _context) => {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const options = defaultsDeep({}, _options, defaultOptions);
|
|
26
|
+
const children = (
|
|
27
|
+
// NOTE: Do not change the flex direction to flex-col by default.
|
|
28
|
+
/* @__PURE__ */ React.createElement("div", {
|
|
29
|
+
role: "none",
|
|
30
|
+
className: mx(fullscreen && "fixed inset-0 flex overflow-hidden", classNames)
|
|
31
|
+
}, /* @__PURE__ */ React.createElement(Story, null))
|
|
32
|
+
);
|
|
26
33
|
return providers.reduceRight((acc, provider) => provider(acc, options), children);
|
|
27
34
|
};
|
|
28
35
|
};
|
|
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
36
|
|
|
51
37
|
// packages/common/storybook-utils/src/decorators/withSignals.tsx
|
|
52
38
|
import React2 from "react";
|
|
@@ -60,7 +46,7 @@ var withSignals = (Story) => {
|
|
|
60
46
|
import { addons } from "@storybook/preview-api";
|
|
61
47
|
import React3, { memo, useEffect, useState } from "react";
|
|
62
48
|
import { DARK_MODE_EVENT_NAME } from "storybook-dark-mode";
|
|
63
|
-
import { ThemeProvider
|
|
49
|
+
import { ThemeProvider } from "@dxos/react-ui";
|
|
64
50
|
import { defaultTx } from "@dxos/react-ui-theme";
|
|
65
51
|
var channel = addons.getChannel();
|
|
66
52
|
var withTheme = (Story, context) => {
|
|
@@ -78,7 +64,7 @@ var withTheme = (Story, context) => {
|
|
|
78
64
|
themeMode,
|
|
79
65
|
resourceExtensions: context?.parameters?.translations,
|
|
80
66
|
noCache: true
|
|
81
|
-
}, /* @__PURE__ */ React3.createElement(
|
|
67
|
+
}, /* @__PURE__ */ React3.createElement(MemoizedStory, null));
|
|
82
68
|
};
|
|
83
69
|
|
|
84
70
|
// packages/common/storybook-utils/src/util.tsx
|
|
@@ -88,9 +74,6 @@ var render = (r) => (args) => /* @__PURE__ */ React4.createElement(React4.Fragme
|
|
|
88
74
|
// packages/common/storybook-utils/src/index.ts
|
|
89
75
|
registerSignalsRuntime2();
|
|
90
76
|
export {
|
|
91
|
-
ColumnContainer,
|
|
92
|
-
DefaultContainer,
|
|
93
|
-
FixedContainer,
|
|
94
77
|
render,
|
|
95
78
|
withLayout,
|
|
96
79
|
withSignals,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/index.ts", "../../../src/decorators/withLayout.tsx", "../../../src/decorators/withSignals.tsx", "../../../src/decorators/withTheme.tsx", "../../../src/util.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { registerSignalsRuntime } from '@dxos/echo-signals/react';\n\nexport { type Meta } from '@storybook/react';\n\nexport * from './decorators';\nexport * from './util';\n\nregisterSignalsRuntime();\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react';\nimport defaultsDeep from 'lodash.defaultsdeep';\nimport React, { type
|
|
5
|
-
"mappings": ";AAIA,SAASA,0BAAAA,+BAA8B;;;ACCvC,OAAOC,kBAAkB;AACzB,OAAOC,
|
|
6
|
-
"names": ["registerSignalsRuntime", "defaultsDeep", "React", "DensityProvider", "mx", "defaultOptions", "density", "providers", "children", "options", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { registerSignalsRuntime } from '@dxos/echo-signals/react';\n\nexport { type Meta } from '@storybook/react';\n\nexport * from './decorators';\nexport * from './util';\n\nregisterSignalsRuntime();\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react';\nimport defaultsDeep from 'lodash.defaultsdeep';\nimport React, { type JSX } from 'react';\n\nimport { type Density, DensityProvider, type ThemedClassName } from '@dxos/react-ui';\nimport { Tooltip } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\ntype ProviderOptions = {\n fullscreen?: boolean;\n density?: Density;\n tooltips?: boolean;\n};\n\nconst defaultOptions: ProviderOptions = {\n density: 'fine',\n};\n\ntype Provider = (children: JSX.Element, options: ProviderOptions) => JSX.Element;\n\nconst providers: Provider[] = [\n (children, options) => {\n return options.tooltips ? <Tooltip.Provider>{children}</Tooltip.Provider> : children;\n },\n (children, options) => {\n return options?.density ? <DensityProvider density={options.density}>{children}</DensityProvider> : children;\n },\n];\n\nexport type WithFullscreenProps = ThemedClassName<ProviderOptions>;\n\n/**\n * Decorator to layout the story container, adding optional providers.\n */\nexport const withLayout = ({ classNames, fullscreen, ..._options }: WithFullscreenProps = {}): Decorator => {\n // TODO(burdon): Inspect \"fullscreen\" parameter in context.\n return (Story, _context) => {\n const options = defaultsDeep({}, _options, defaultOptions);\n const children = (\n // NOTE: Do not change the flex direction to flex-col by default.\n <div role='none' className={mx(fullscreen && 'fixed inset-0 flex overflow-hidden', classNames)}>\n <Story />\n </div>\n );\n\n return providers.reduceRight((acc, provider) => provider(acc, options), children);\n };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react';\nimport React from 'react';\n\nimport { registerSignalsRuntime } from '@dxos/echo-signals/react';\n\n/**\n * Make objects created using @dxos/echo-schema `create` reactive.\n */\nexport const withSignals: Decorator = (Story) => {\n registerSignalsRuntime();\n return <Story />;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { addons } from '@storybook/preview-api';\nimport { type Decorator } from '@storybook/react';\nimport React, { memo, useEffect, useState } from 'react';\nimport { DARK_MODE_EVENT_NAME } from 'storybook-dark-mode';\n\nimport { type ThemeMode, ThemeProvider } from '@dxos/react-ui';\nimport { defaultTx } from '@dxos/react-ui-theme';\n\nconst channel = addons.getChannel();\n\n/**\n * Changes theme based on storybook toolbar toggle.\n */\nexport const withTheme: Decorator = (Story, context) => {\n // Prevent re-rendering of the story.\n const MemoizedStory = memo(Story);\n const [themeMode, setThemeMode] = useState<ThemeMode>('dark');\n\n // https://www.npmjs.com/package/storybook-dark-mode\n // NOTE: The `useDarkMode` hook causes the story to continually re-render.\n // NOTE: Changing the theme will cause the story to remount.\n useEffect(() => {\n const handleUpdate = (darkMode: boolean) => setThemeMode(darkMode ? 'dark' : 'light');\n channel.on(DARK_MODE_EVENT_NAME, handleUpdate);\n return () => channel.off(DARK_MODE_EVENT_NAME, handleUpdate);\n }, [channel]);\n\n return (\n <ThemeProvider tx={defaultTx} themeMode={themeMode} resourceExtensions={context?.parameters?.translations} noCache>\n <MemoizedStory />\n </ThemeProvider>\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,>(r: FC<T>) =>\n (args: T) => <>{r(args) ?? <div />}</>;\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,0BAAAA,+BAA8B;;;ACCvC,OAAOC,kBAAkB;AACzB,OAAOC,WAAyB;AAEhC,SAAuBC,uBAA6C;AACpE,SAASC,eAAe;AACxB,SAASC,UAAU;AAQnB,IAAMC,iBAAkC;EACtCC,SAAS;AACX;AAIA,IAAMC,YAAwB;EAC5B,CAACC,UAAUC,YAAAA;AACT,WAAOA,QAAQC,WAAW,sBAAA,cAACC,QAAQC,UAAQ,MAAEJ,QAAAA,IAA+BA;EAC9E;EACA,CAACA,UAAUC,YAAAA;AACT,WAAOA,SAASH,UAAU,sBAAA,cAACO,iBAAAA;MAAgBP,SAASG,QAAQH;OAAUE,QAAAA,IAA8BA;EACtG;;AAQK,IAAMM,aAAa,CAAC,EAAEC,YAAYC,YAAY,GAAGC,SAAAA,IAAkC,CAAC,MAAC;AAE1F,SAAO,CAACC,OAAOC,aAAAA;AACb,UAAMV,UAAUW,aAAa,CAAC,GAAGH,UAAUZ,cAAAA;AAC3C,UAAMG;;MAEJ,sBAAA,cAACa,OAAAA;QAAIC,MAAK;QAAOC,WAAWC,GAAGR,cAAc,sCAAsCD,UAAAA;SACjF,sBAAA,cAACG,OAAAA,IAAAA,CAAAA;;AAIL,WAAOX,UAAUkB,YAAY,CAACC,KAAKC,aAAaA,SAASD,KAAKjB,OAAAA,GAAUD,QAAAA;EAC1E;AACF;;;AC9CA,OAAOoB,YAAW;AAElB,SAASC,8BAA8B;AAKhC,IAAMC,cAAyB,CAACC,UAAAA;AACrCC,yBAAAA;AACA,SAAO,gBAAAC,OAAA,cAACF,OAAAA,IAAAA;AACV;;;ACXA,SAASG,cAAc;AAEvB,OAAOC,UAASC,MAAMC,WAAWC,gBAAgB;AACjD,SAASC,4BAA4B;AAErC,SAAyBC,qBAAqB;AAC9C,SAASC,iBAAiB;AAE1B,IAAMC,UAAUC,OAAOC,WAAU;AAK1B,IAAMC,YAAuB,CAACC,OAAOC,YAAAA;AAE1C,QAAMC,gBAAgBC,qBAAKH,KAAAA;AAC3B,QAAM,CAACI,WAAWC,YAAAA,IAAgBC,SAAoB,MAAA;AAKtDC,YAAU,MAAA;AACR,UAAMC,eAAe,CAACC,aAAsBJ,aAAaI,WAAW,SAAS,OAAA;AAC7Eb,YAAQc,GAAGC,sBAAsBH,YAAAA;AACjC,WAAO,MAAMZ,QAAQgB,IAAID,sBAAsBH,YAAAA;EACjD,GAAG;IAACZ;GAAQ;AAEZ,SACE,gBAAAiB,OAAA,cAACC,eAAAA;IAAcC,IAAIC;IAAWZ;IAAsBa,oBAAoBhB,SAASiB,YAAYC;IAAcC,SAAAA;KACzG,gBAAAP,OAAA,cAACX,eAAAA,IAAAA,CAAAA;AAGP;;;AChCA,OAAOmB,YAAwB;AAKxB,IAAMC,SACX,CAAKC,MACL,CAACC,SAAY,gBAAAC,OAAA,cAAAA,OAAA,UAAA,MAAGF,EAAEC,IAAAA,KAAS,gBAAAC,OAAA,cAACC,OAAAA,IAAAA,CAAAA;;;AJA9BC,wBAAAA;",
|
|
6
|
+
"names": ["registerSignalsRuntime", "defaultsDeep", "React", "DensityProvider", "Tooltip", "mx", "defaultOptions", "density", "providers", "children", "options", "tooltips", "Tooltip", "Provider", "DensityProvider", "withLayout", "classNames", "fullscreen", "_options", "Story", "_context", "defaultsDeep", "div", "role", "className", "mx", "reduceRight", "acc", "provider", "React", "registerSignalsRuntime", "withSignals", "Story", "registerSignalsRuntime", "React", "addons", "React", "memo", "useEffect", "useState", "DARK_MODE_EVENT_NAME", "ThemeProvider", "defaultTx", "channel", "addons", "getChannel", "withTheme", "Story", "context", "MemoizedStory", "memo", "themeMode", "setThemeMode", "useState", "useEffect", "handleUpdate", "darkMode", "on", "DARK_MODE_EVENT_NAME", "off", "React", "ThemeProvider", "tx", "defaultTx", "resourceExtensions", "parameters", "translations", "noCache", "React", "render", "r", "args", "React", "div", "registerSignalsRuntime"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/common/storybook-utils/src/decorators/withLayout.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"packages/common/storybook-utils/src/decorators/withLayout.tsx":{"bytes":5343,"imports":[{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"format":"esm"},"packages/common/storybook-utils/src/decorators/withSignals.tsx":{"bytes":1440,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo-signals/react","kind":"import-statement","external":true}],"format":"esm"},"packages/common/storybook-utils/src/decorators/withTheme.tsx":{"bytes":4710,"imports":[{"path":"@storybook/preview-api","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"storybook-dark-mode","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"format":"esm"},"packages/common/storybook-utils/src/decorators/index.ts":{"bytes":708,"imports":[{"path":"packages/common/storybook-utils/src/decorators/withLayout.tsx","kind":"import-statement","original":"./withLayout"},{"path":"packages/common/storybook-utils/src/decorators/withSignals.tsx","kind":"import-statement","original":"./withSignals"},{"path":"packages/common/storybook-utils/src/decorators/withTheme.tsx","kind":"import-statement","original":"./withTheme"}],"format":"esm"},"packages/common/storybook-utils/src/util.tsx":{"bytes":1048,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"packages/common/storybook-utils/src/index.ts":{"bytes":962,"imports":[{"path":"@dxos/echo-signals/react","kind":"import-statement","external":true},{"path":"packages/common/storybook-utils/src/decorators/index.ts","kind":"import-statement","original":"./decorators"},{"path":"packages/common/storybook-utils/src/util.tsx","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/common/storybook-utils/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":6666},"packages/common/storybook-utils/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/echo-signals/react","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/echo-signals/react","kind":"import-statement","external":true},{"path":"@storybook/preview-api","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"storybook-dark-mode","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["render","withLayout","withSignals","withTheme"],"entryPoint":"packages/common/storybook-utils/src/index.ts","inputs":{"packages/common/storybook-utils/src/index.ts":{"bytesInOutput":121},"packages/common/storybook-utils/src/decorators/withLayout.tsx":{"bytesInOutput":1175},"packages/common/storybook-utils/src/decorators/index.ts":{"bytesInOutput":0},"packages/common/storybook-utils/src/decorators/withSignals.tsx":{"bytesInOutput":217},"packages/common/storybook-utils/src/decorators/withTheme.tsx":{"bytesInOutput":933},"packages/common/storybook-utils/src/util.tsx":{"bytesInOutput":181}},"bytes":3069}}}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { type Decorator } from '@storybook/react';
|
|
2
|
-
import { type PropsWithChildren, type FC } from 'react';
|
|
3
2
|
import { type Density, type ThemedClassName } from '@dxos/react-ui';
|
|
4
3
|
type ProviderOptions = {
|
|
5
4
|
fullscreen?: boolean;
|
|
6
5
|
density?: Density;
|
|
6
|
+
tooltips?: boolean;
|
|
7
7
|
};
|
|
8
|
-
export type
|
|
9
|
-
export type WithLayoutProps = ThemedClassName<ProviderOptions & {
|
|
10
|
-
Container?: FC<ContainerProps>;
|
|
11
|
-
}>;
|
|
8
|
+
export type WithFullscreenProps = ThemedClassName<ProviderOptions>;
|
|
12
9
|
/**
|
|
13
10
|
* Decorator to layout the story container, adding optional providers.
|
|
14
11
|
*/
|
|
15
|
-
export declare const withLayout: ({ classNames, fullscreen,
|
|
16
|
-
export declare const DefaultContainer: FC<ContainerProps>;
|
|
17
|
-
export declare const FixedContainer: FC<ContainerProps>;
|
|
18
|
-
export declare const ColumnContainer: FC<ContainerProps>;
|
|
12
|
+
export declare const withLayout: ({ classNames, fullscreen, ..._options }?: WithFullscreenProps) => Decorator;
|
|
19
13
|
export {};
|
|
20
14
|
//# sourceMappingURL=withLayout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withLayout.d.ts","sourceRoot":"","sources":["../../../../src/decorators/withLayout.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"withLayout.d.ts","sourceRoot":"","sources":["../../../../src/decorators/withLayout.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD,OAAO,EAAE,KAAK,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAIrF,KAAK,eAAe,GAAG;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAiBF,MAAM,MAAM,mBAAmB,GAAG,eAAe,CAAC,eAAe,CAAC,CAAC;AAEnE;;GAEG;AACH,eAAO,MAAM,UAAU,6CAA6C,mBAAmB,KAAQ,SAa9F,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTheme.d.ts","sourceRoot":"","sources":["../../../../src/decorators/withTheme.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AASlD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"withTheme.d.ts","sourceRoot":"","sources":["../../../../src/decorators/withTheme.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AASlD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,SAmBvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,MAAM,GAChB,CAAC,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,MAAM,GAChB,CAAC,KAAM,EAAE,CAAC,CAAC,CAAC,YACN,CAAC,sBAA8B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"5.
|
|
1
|
+
{"version":"5.7.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/storybook-utils",
|
|
3
|
-
"version": "0.8.2-
|
|
3
|
+
"version": "0.8.2-staging.7ac8446",
|
|
4
4
|
"description": "Utilities for DXOS UI Storybooks.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@storybook/preview-api": "^8.3.6",
|
|
27
27
|
"lodash.defaultsdeep": "^4.6.1",
|
|
28
28
|
"storybook-dark-mode": "^4.0.2",
|
|
29
|
-
"@dxos/echo-signals": "0.8.2-
|
|
30
|
-
"@dxos/log": "0.8.2-
|
|
29
|
+
"@dxos/echo-signals": "0.8.2-staging.7ac8446",
|
|
30
|
+
"@dxos/log": "0.8.2-staging.7ac8446"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/lodash.defaultsdeep": "^4.6.6",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"react": "~18.2.0",
|
|
37
37
|
"react-dom": "~18.2.0",
|
|
38
38
|
"storybook": "^8.3.6",
|
|
39
|
-
"@dxos/react-ui": "0.8.2-
|
|
40
|
-
"@dxos/react-ui-theme": "0.8.2-
|
|
39
|
+
"@dxos/react-ui": "0.8.2-staging.7ac8446",
|
|
40
|
+
"@dxos/react-ui-theme": "0.8.2-staging.7ac8446"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react": "~18.2.0",
|
|
44
44
|
"react-dom": "~18.2.0",
|
|
45
|
-
"@dxos/react-ui": "0.8.2-
|
|
46
|
-
"@dxos/react-ui-theme": "0.8.2-
|
|
45
|
+
"@dxos/react-ui": "0.8.2-staging.7ac8446",
|
|
46
|
+
"@dxos/react-ui-theme": "0.8.2-staging.7ac8446"
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Decorator } from '@storybook/react';
|
|
6
6
|
import defaultsDeep from 'lodash.defaultsdeep';
|
|
7
|
-
import React, { type
|
|
7
|
+
import React, { type JSX } from 'react';
|
|
8
8
|
|
|
9
9
|
import { type Density, DensityProvider, type ThemedClassName } from '@dxos/react-ui';
|
|
10
|
+
import { Tooltip } from '@dxos/react-ui';
|
|
10
11
|
import { mx } from '@dxos/react-ui-theme';
|
|
11
12
|
|
|
12
13
|
type ProviderOptions = {
|
|
13
14
|
fullscreen?: boolean;
|
|
14
15
|
density?: Density;
|
|
16
|
+
tooltips?: boolean;
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
const defaultOptions: ProviderOptions = {
|
|
@@ -21,59 +23,30 @@ const defaultOptions: ProviderOptions = {
|
|
|
21
23
|
type Provider = (children: JSX.Element, options: ProviderOptions) => JSX.Element;
|
|
22
24
|
|
|
23
25
|
const providers: Provider[] = [
|
|
26
|
+
(children, options) => {
|
|
27
|
+
return options.tooltips ? <Tooltip.Provider>{children}</Tooltip.Provider> : children;
|
|
28
|
+
},
|
|
24
29
|
(children, options) => {
|
|
25
30
|
return options?.density ? <DensityProvider density={options.density}>{children}</DensityProvider> : children;
|
|
26
31
|
},
|
|
27
32
|
];
|
|
28
33
|
|
|
29
|
-
export type
|
|
30
|
-
|
|
31
|
-
export type WithLayoutProps = ThemedClassName<ProviderOptions & { Container?: FC<ContainerProps> }>;
|
|
34
|
+
export type WithFullscreenProps = ThemedClassName<ProviderOptions>;
|
|
32
35
|
|
|
33
36
|
/**
|
|
34
37
|
* Decorator to layout the story container, adding optional providers.
|
|
35
38
|
*/
|
|
36
|
-
export const withLayout = ({
|
|
37
|
-
classNames,
|
|
38
|
-
fullscreen,
|
|
39
|
-
Container = fullscreen ? FixedContainer : DefaultContainer,
|
|
40
|
-
...providedOptions
|
|
41
|
-
}: WithLayoutProps = {}): Decorator => {
|
|
39
|
+
export const withLayout = ({ classNames, fullscreen, ..._options }: WithFullscreenProps = {}): Decorator => {
|
|
42
40
|
// TODO(burdon): Inspect "fullscreen" parameter in context.
|
|
43
41
|
return (Story, _context) => {
|
|
42
|
+
const options = defaultsDeep({}, _options, defaultOptions);
|
|
44
43
|
const children = (
|
|
45
|
-
|
|
44
|
+
// NOTE: Do not change the flex direction to flex-col by default.
|
|
45
|
+
<div role='none' className={mx(fullscreen && 'fixed inset-0 flex overflow-hidden', classNames)}>
|
|
46
46
|
<Story />
|
|
47
|
-
</
|
|
47
|
+
</div>
|
|
48
48
|
);
|
|
49
49
|
|
|
50
|
-
const options = defaultsDeep({}, providedOptions, defaultOptions);
|
|
51
50
|
return providers.reduceRight((acc, provider) => provider(acc, options), children);
|
|
52
51
|
};
|
|
53
52
|
};
|
|
54
|
-
|
|
55
|
-
export const DefaultContainer: FC<ContainerProps> = ({ children, classNames }) => {
|
|
56
|
-
return (
|
|
57
|
-
<div role='none' className={mx(classNames)}>
|
|
58
|
-
{children}
|
|
59
|
-
</div>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const FixedContainer: FC<ContainerProps> = ({ children, classNames }) => {
|
|
64
|
-
return (
|
|
65
|
-
<div role='none' className={mx('fixed inset-0 flex overflow-hidden', classNames)}>
|
|
66
|
-
{children}
|
|
67
|
-
</div>
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const ColumnContainer: FC<ContainerProps> = ({ children, classNames = 'w-[30rem]', ...props }) => {
|
|
72
|
-
return (
|
|
73
|
-
<FixedContainer classNames='justify-center bg-modalSurface' {...props}>
|
|
74
|
-
<div role='none' className={mx('flex flex-col h-full overflow-y-auto bg-baseSurface', classNames)}>
|
|
75
|
-
{children}
|
|
76
|
-
</div>
|
|
77
|
-
</FixedContainer>
|
|
78
|
-
);
|
|
79
|
-
};
|
|
@@ -7,7 +7,7 @@ import { type Decorator } from '@storybook/react';
|
|
|
7
7
|
import React, { memo, useEffect, useState } from 'react';
|
|
8
8
|
import { DARK_MODE_EVENT_NAME } from 'storybook-dark-mode';
|
|
9
9
|
|
|
10
|
-
import { type ThemeMode, ThemeProvider
|
|
10
|
+
import { type ThemeMode, ThemeProvider } from '@dxos/react-ui';
|
|
11
11
|
import { defaultTx } from '@dxos/react-ui-theme';
|
|
12
12
|
|
|
13
13
|
const channel = addons.getChannel();
|
|
@@ -31,9 +31,7 @@ export const withTheme: Decorator = (Story, context) => {
|
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
33
|
<ThemeProvider tx={defaultTx} themeMode={themeMode} resourceExtensions={context?.parameters?.translations} noCache>
|
|
34
|
-
<
|
|
35
|
-
<MemoizedStory />
|
|
36
|
-
</Tooltip.Provider>
|
|
34
|
+
<MemoizedStory />
|
|
37
35
|
</ThemeProvider>
|
|
38
36
|
);
|
|
39
37
|
};
|