@saas-ui/storybook-addon 1.0.0

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +497 -0
  2. package/README.md +97 -0
  3. package/dist/chunk-E3MMX4DM.js +4973 -0
  4. package/dist/chunk-GII4NPN2.js +81 -0
  5. package/dist/chunk-HSBRF2QZ.js +18 -0
  6. package/dist/chunk-N4JZ67DU.js +26 -0
  7. package/dist/chunk-NOGSFSIA.js +52 -0
  8. package/dist/chunk-QNOLFHPG.js +63 -0
  9. package/dist/chunk-SGM3YTWS.js +82 -0
  10. package/dist/chunk-SVHNULTN.js +24 -0
  11. package/dist/chunk-UK7U2PBM.js +70 -0
  12. package/dist/constants.cjs +46 -0
  13. package/dist/constants.d.ts +11 -0
  14. package/dist/constants.js +15 -0
  15. package/dist/feature/arg-types.cjs +76 -0
  16. package/dist/feature/arg-types.d.ts +46 -0
  17. package/dist/feature/arg-types.js +7 -0
  18. package/dist/feature/color-mode/ColorModeSync.cjs +57 -0
  19. package/dist/feature/color-mode/ColorModeSync.d.ts +6 -0
  20. package/dist/feature/color-mode/ColorModeSync.js +8 -0
  21. package/dist/feature/color-mode/ColorModeTool.cjs +95 -0
  22. package/dist/feature/color-mode/ColorModeTool.d.ts +6 -0
  23. package/dist/feature/color-mode/ColorModeTool.js +8 -0
  24. package/dist/feature/color-mode/ThemeTool.cjs +5038 -0
  25. package/dist/feature/color-mode/ThemeTool.d.ts +6 -0
  26. package/dist/feature/color-mode/ThemeTool.js +8 -0
  27. package/dist/feature/decorator/ChakraProviderDecorator.cjs +168 -0
  28. package/dist/feature/decorator/ChakraProviderDecorator.d.ts +5 -0
  29. package/dist/feature/decorator/ChakraProviderDecorator.js +10 -0
  30. package/dist/feature/direction/DirectionTool.cjs +127 -0
  31. package/dist/feature/direction/DirectionTool.d.ts +6 -0
  32. package/dist/feature/direction/DirectionTool.js +8 -0
  33. package/dist/feature/direction/useDirection.cjs +59 -0
  34. package/dist/feature/direction/useDirection.d.ts +6 -0
  35. package/dist/feature/direction/useDirection.js +8 -0
  36. package/dist/index.cjs +99 -0
  37. package/dist/index.d.ts +4 -0
  38. package/dist/index.js +19 -0
  39. package/dist/preset/decorators.cjs +173 -0
  40. package/dist/preset/decorators.d.ts +3 -0
  41. package/dist/preset/decorators.js +13 -0
  42. package/dist/preset/index.cjs +60 -0
  43. package/dist/preset/index.d.ts +5 -0
  44. package/dist/preset/index.js +27 -0
  45. package/dist/preset/register.cjs +5175 -0
  46. package/dist/preset/register.d.ts +2 -0
  47. package/dist/preset/register.js +40 -0
  48. package/package.json +120 -0
  49. package/theming-arg-types.png +0 -0
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This component is rendered in the Storybook toolbar
3
+ */
4
+ declare const ThemeTool: () => JSX.Element;
5
+
6
+ export { ThemeTool };
@@ -0,0 +1,8 @@
1
+ import {
2
+ ThemeTool
3
+ } from "../../chunk-E3MMX4DM.js";
4
+ import "../../chunk-HSBRF2QZ.js";
5
+ import "../../chunk-UK7U2PBM.js";
6
+ export {
7
+ ThemeTool
8
+ };
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
+ mod
44
+ ));
45
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+
47
+ // src/feature/decorator/ChakraProviderDecorator.tsx
48
+ var ChakraProviderDecorator_exports = {};
49
+ __export(ChakraProviderDecorator_exports, {
50
+ ChakraProviderDecorator: () => ChakraProviderDecorator
51
+ });
52
+ module.exports = __toCommonJS(ChakraProviderDecorator_exports);
53
+ var import_react4 = __toESM(require("react"), 1);
54
+ var import_addons3 = require("@storybook/addons");
55
+ var import_react5 = require("@chakra-ui/react");
56
+ var import_react6 = require("@saas-ui/react");
57
+
58
+ // src/feature/color-mode/ColorModeSync.tsx
59
+ var import_react = require("react");
60
+ var import_react2 = require("@chakra-ui/react");
61
+ var import_addons = require("@storybook/addons");
62
+
63
+ // src/constants.ts
64
+ var ADDON_ID = "@saas-ui/storybook-addon";
65
+ var COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`;
66
+ var DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`;
67
+ var THEME_TOOL_ID = `${ADDON_ID}/theme-tool`;
68
+ var EVENTS = {
69
+ TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,
70
+ TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,
71
+ SET_THEME: `${ADDON_ID}/setTheme`
72
+ };
73
+
74
+ // src/feature/color-mode/ColorModeSync.tsx
75
+ function ColorModeSync() {
76
+ const { setColorMode } = (0, import_react2.useColorMode)();
77
+ (0, import_react.useEffect)(() => {
78
+ const channel = import_addons.addons.getChannel();
79
+ const colorModeToolCallback = (value) => setColorMode(value);
80
+ channel.on(EVENTS.TOGGLE_COLOR_MODE, colorModeToolCallback);
81
+ return () => {
82
+ channel.removeListener(EVENTS.TOGGLE_COLOR_MODE, colorModeToolCallback);
83
+ };
84
+ }, [setColorMode]);
85
+ return null;
86
+ }
87
+
88
+ // src/feature/direction/useDirection.tsx
89
+ var import_react3 = require("react");
90
+ var import_addons2 = require("@storybook/addons");
91
+ var useDirection = (initialDirection = "ltr") => {
92
+ const [direction, setDirection] = (0, import_react3.useState)(initialDirection.toLowerCase());
93
+ (0, import_react3.useEffect)(() => {
94
+ document.documentElement.dir = direction;
95
+ }, [direction]);
96
+ (0, import_react3.useEffect)(() => {
97
+ const channel = import_addons2.addons.getChannel();
98
+ const callback = (value) => setDirection(value);
99
+ channel.on(EVENTS.TOGGLE_DIRECTION, callback);
100
+ return () => {
101
+ channel.removeListener(EVENTS.TOGGLE_DIRECTION, callback);
102
+ };
103
+ }, [setDirection]);
104
+ return direction;
105
+ };
106
+
107
+ // src/feature/decorator/ChakraProviderDecorator.tsx
108
+ var import_theme = require("@saas-ui/theme");
109
+ var import_theme_glass = require("@saas-ui/theme-glass");
110
+ var import_jsx_runtime = require("react/jsx-runtime");
111
+ var glassTheme = (0, import_react5.extendTheme)(import_theme_glass.theme, import_theme.theme);
112
+ var useThemeSync = () => {
113
+ const [themeId, setTheme] = (0, import_react6.useLocalStorage)("storybook.theme", "0");
114
+ import_react4.default.useEffect(() => {
115
+ const channel = import_addons3.addons.getChannel();
116
+ const themeCallback = (value) => setTheme(value);
117
+ channel.on(EVENTS.SET_THEME, themeCallback);
118
+ return () => {
119
+ channel.removeListener(EVENTS.SET_THEME, themeCallback);
120
+ };
121
+ }, [setTheme]);
122
+ return themeId;
123
+ };
124
+ function ChakraProviderDecorator(Story, context) {
125
+ const {
126
+ parameters: { saasui: saasuiParams },
127
+ globals: { [DIRECTION_TOOL_ID]: globalDirection }
128
+ } = context;
129
+ const themeId = useThemeSync();
130
+ const getTheme = import_react4.default.useCallback(() => {
131
+ switch (themeId) {
132
+ case "1":
133
+ return import_theme.theme;
134
+ case "2":
135
+ return glassTheme;
136
+ default:
137
+ return import_theme.baseTheme;
138
+ }
139
+ }, [themeId]);
140
+ const theme = (saasuiParams == null ? void 0 : saasuiParams.theme) || getTheme();
141
+ const themeOverride = !!(saasuiParams == null ? void 0 : saasuiParams.theme);
142
+ const chakraTheme = (saasuiParams == null ? void 0 : saasuiParams.theme) ? typeof saasuiParams.theme === "function" ? saasuiParams.theme(context) : saasuiParams.theme : theme;
143
+ const direction = useDirection(globalDirection || (chakraTheme == null ? void 0 : chakraTheme.direction));
144
+ const themeWithDirectionOverride = (0, import_react4.useMemo)(
145
+ () => (0, import_react5.extendTheme)(
146
+ {
147
+ direction,
148
+ styles: {
149
+ global: {
150
+ body: {
151
+ minHeight: "var(--chakra-vh)"
152
+ }
153
+ }
154
+ }
155
+ },
156
+ chakraTheme
157
+ ),
158
+ [chakraTheme, direction]
159
+ );
160
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react6.SaasProvider, __spreadProps(__spreadValues({}, saasuiParams), { theme: themeWithDirectionOverride, children: [
161
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ColorModeSync, {}),
162
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Story, __spreadValues({}, context))
163
+ ] }));
164
+ }
165
+ // Annotate the CommonJS export names for ESM import in node:
166
+ 0 && (module.exports = {
167
+ ChakraProviderDecorator
168
+ });
@@ -0,0 +1,5 @@
1
+ import { StoryFn, StoryContext } from '@storybook/types';
2
+
3
+ declare function ChakraProviderDecorator(Story: StoryFn<any>, context: StoryContext): JSX.Element;
4
+
5
+ export { ChakraProviderDecorator };
@@ -0,0 +1,10 @@
1
+ import {
2
+ ChakraProviderDecorator
3
+ } from "../../chunk-GII4NPN2.js";
4
+ import "../../chunk-N4JZ67DU.js";
5
+ import "../../chunk-SVHNULTN.js";
6
+ import "../../chunk-HSBRF2QZ.js";
7
+ import "../../chunk-UK7U2PBM.js";
8
+ export {
9
+ ChakraProviderDecorator
10
+ };
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
+
37
+ // src/feature/direction/DirectionTool.tsx
38
+ var DirectionTool_exports = {};
39
+ __export(DirectionTool_exports, {
40
+ DirectionTool: () => DirectionTool
41
+ });
42
+ module.exports = __toCommonJS(DirectionTool_exports);
43
+ var import_react = require("react");
44
+ var import_api = require("@storybook/api");
45
+ var import_addons = require("@storybook/addons");
46
+ var import_components = require("@storybook/components");
47
+
48
+ // src/constants.ts
49
+ var ADDON_ID = "@saas-ui/storybook-addon";
50
+ var COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`;
51
+ var DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`;
52
+ var THEME_TOOL_ID = `${ADDON_ID}/theme-tool`;
53
+ var EVENTS = {
54
+ TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,
55
+ TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,
56
+ SET_THEME: `${ADDON_ID}/setTheme`
57
+ };
58
+
59
+ // src/feature/direction/DirectionTool.tsx
60
+ var import_jsx_runtime = require("react/jsx-runtime");
61
+ var LTRIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
62
+ "svg",
63
+ __spreadProps(__spreadValues({
64
+ stroke: "currentColor",
65
+ fill: "currentColor",
66
+ strokeWidth: "0",
67
+ viewBox: "0 0 24 24",
68
+ height: "1em",
69
+ width: "1em",
70
+ style: {
71
+ transform: "scale(1.2)"
72
+ }
73
+ }, props), {
74
+ children: [
75
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "none", d: "M0 0h24v24H0V0z" }),
76
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M9 4v4c-1.1 0-2-.9-2-2s.9-2 2-2m8-2H9C6.79 2 5 3.79 5 6s1.79 4 4 4v5h2V4h2v11h2V4h2V2zm0 12v3H5v2h12v3l4-4-4-4z" })
77
+ ]
78
+ })
79
+ );
80
+ var RTLIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
81
+ "svg",
82
+ __spreadProps(__spreadValues({
83
+ stroke: "currentColor",
84
+ fill: "currentColor",
85
+ strokeWidth: "0",
86
+ viewBox: "0 0 24 24",
87
+ height: "1em",
88
+ width: "1em",
89
+ style: {
90
+ transform: "scale(1.2)"
91
+ }
92
+ }, props), {
93
+ children: [
94
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "none", d: "M0 0h24v24H0V0z" }),
95
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 4v4c-1.1 0-2-.9-2-2s.9-2 2-2m8-2h-8C7.79 2 6 3.79 6 6s1.79 4 4 4v5h2V4h2v11h2V4h2V2zM8 14l-4 4 4 4v-3h12v-2H8v-3z" })
96
+ ]
97
+ })
98
+ );
99
+ var DirectionTool = () => {
100
+ const [globals, setGlobals] = (0, import_api.useGlobals)();
101
+ const [direction, setDirection] = (0, import_api.useAddonState)(
102
+ DIRECTION_TOOL_ID,
103
+ globals[DIRECTION_TOOL_ID] || "ltr"
104
+ );
105
+ const targetDirection = direction !== "ltr" ? "ltr" : "rtl";
106
+ (0, import_react.useEffect)(() => {
107
+ setGlobals({ [DIRECTION_TOOL_ID]: direction });
108
+ }, [direction, setGlobals]);
109
+ const toggleDirection = (0, import_react.useCallback)(() => {
110
+ const channel = import_addons.addons.getChannel();
111
+ channel.emit(EVENTS.TOGGLE_DIRECTION, targetDirection);
112
+ setDirection(targetDirection);
113
+ }, [setDirection, targetDirection]);
114
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
115
+ import_components.IconButton,
116
+ {
117
+ active: direction === "rtl",
118
+ title: `Set layout direction to ${targetDirection}`,
119
+ onClick: toggleDirection,
120
+ children: targetDirection === "ltr" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LTRIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RTLIcon, {})
121
+ }
122
+ );
123
+ };
124
+ // Annotate the CommonJS export names for ESM import in node:
125
+ 0 && (module.exports = {
126
+ DirectionTool
127
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This component is rendered in the Storybook toolbar
3
+ */
4
+ declare const DirectionTool: () => JSX.Element;
5
+
6
+ export { DirectionTool };
@@ -0,0 +1,8 @@
1
+ import {
2
+ DirectionTool
3
+ } from "../../chunk-SGM3YTWS.js";
4
+ import "../../chunk-HSBRF2QZ.js";
5
+ import "../../chunk-UK7U2PBM.js";
6
+ export {
7
+ DirectionTool
8
+ };
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/feature/direction/useDirection.tsx
21
+ var useDirection_exports = {};
22
+ __export(useDirection_exports, {
23
+ useDirection: () => useDirection
24
+ });
25
+ module.exports = __toCommonJS(useDirection_exports);
26
+ var import_react = require("react");
27
+ var import_addons = require("@storybook/addons");
28
+
29
+ // src/constants.ts
30
+ var ADDON_ID = "@saas-ui/storybook-addon";
31
+ var COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`;
32
+ var DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`;
33
+ var THEME_TOOL_ID = `${ADDON_ID}/theme-tool`;
34
+ var EVENTS = {
35
+ TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,
36
+ TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,
37
+ SET_THEME: `${ADDON_ID}/setTheme`
38
+ };
39
+
40
+ // src/feature/direction/useDirection.tsx
41
+ var useDirection = (initialDirection = "ltr") => {
42
+ const [direction, setDirection] = (0, import_react.useState)(initialDirection.toLowerCase());
43
+ (0, import_react.useEffect)(() => {
44
+ document.documentElement.dir = direction;
45
+ }, [direction]);
46
+ (0, import_react.useEffect)(() => {
47
+ const channel = import_addons.addons.getChannel();
48
+ const callback = (value) => setDirection(value);
49
+ channel.on(EVENTS.TOGGLE_DIRECTION, callback);
50
+ return () => {
51
+ channel.removeListener(EVENTS.TOGGLE_DIRECTION, callback);
52
+ };
53
+ }, [setDirection]);
54
+ return direction;
55
+ };
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ useDirection
59
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Sync the layout direction to the html element
3
+ */
4
+ declare const useDirection: (initialDirection?: 'ltr' | 'rtl') => string;
5
+
6
+ export { useDirection };
@@ -0,0 +1,8 @@
1
+ import {
2
+ useDirection
3
+ } from "../../chunk-N4JZ67DU.js";
4
+ import "../../chunk-HSBRF2QZ.js";
5
+ import "../../chunk-UK7U2PBM.js";
6
+ export {
7
+ useDirection
8
+ };
package/dist/index.cjs ADDED
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ ADDON_ID: () => ADDON_ID,
24
+ COLOR_MODE_TOOL_ID: () => COLOR_MODE_TOOL_ID,
25
+ DIRECTION_TOOL_ID: () => DIRECTION_TOOL_ID,
26
+ EVENTS: () => EVENTS,
27
+ THEME_TOOL_ID: () => THEME_TOOL_ID,
28
+ getThemingArgTypes: () => getThemingArgTypes
29
+ });
30
+ module.exports = __toCommonJS(src_exports);
31
+
32
+ // src/constants.ts
33
+ var ADDON_ID = "@saas-ui/storybook-addon";
34
+ var COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`;
35
+ var DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`;
36
+ var THEME_TOOL_ID = `${ADDON_ID}/theme-tool`;
37
+ var EVENTS = {
38
+ TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,
39
+ TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,
40
+ SET_THEME: `${ADDON_ID}/setTheme`
41
+ };
42
+
43
+ // src/feature/arg-types.ts
44
+ function validateColorScheme(value) {
45
+ const valueKeys = Object.keys(value || {});
46
+ return [
47
+ "50",
48
+ "100",
49
+ "200",
50
+ "300",
51
+ "400",
52
+ "500",
53
+ "600",
54
+ "700",
55
+ "800",
56
+ "900"
57
+ ].every((term) => valueKeys.includes(term));
58
+ }
59
+ function getThemingArgTypes(theme, componentName) {
60
+ var _a, _b, _c, _d;
61
+ const component = theme.components[componentName];
62
+ if (!component) {
63
+ return void 0;
64
+ }
65
+ const argTypes = {};
66
+ const variantOptions = Object.keys(component.variants || {});
67
+ if (variantOptions.length) {
68
+ argTypes.variant = {
69
+ type: { name: "enum", value: variantOptions },
70
+ defaultValue: (_a = component.defaultProps) == null ? void 0 : _a.variant
71
+ };
72
+ }
73
+ const sizeOptions = Object.keys(component.sizes || {});
74
+ if (sizeOptions.length) {
75
+ argTypes.size = {
76
+ type: { name: "enum", value: sizeOptions },
77
+ defaultValue: (_b = component.defaultProps) == null ? void 0 : _b.size
78
+ };
79
+ }
80
+ if ((_c = component.defaultProps) == null ? void 0 : _c["colorScheme"]) {
81
+ const colorSchemes = Object.entries(theme.colors).filter(([, value]) => validateColorScheme(value)).map(([key]) => key);
82
+ if (colorSchemes.length) {
83
+ argTypes.colorScheme = {
84
+ type: { name: "enum", value: colorSchemes },
85
+ defaultValue: (_d = component.defaultProps) == null ? void 0 : _d.colorScheme
86
+ };
87
+ }
88
+ }
89
+ return argTypes;
90
+ }
91
+ // Annotate the CommonJS export names for ESM import in node:
92
+ 0 && (module.exports = {
93
+ ADDON_ID,
94
+ COLOR_MODE_TOOL_ID,
95
+ DIRECTION_TOOL_ID,
96
+ EVENTS,
97
+ THEME_TOOL_ID,
98
+ getThemingArgTypes
99
+ });
@@ -0,0 +1,4 @@
1
+ export { ADDON_ID, COLOR_MODE_TOOL_ID, DIRECTION_TOOL_ID, EVENTS, THEME_TOOL_ID } from './constants.js';
2
+ export { ThemingArgTypeKey, getThemingArgTypes } from './feature/arg-types.js';
3
+ import '@storybook/react';
4
+ import '@chakra-ui/react';
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ import {
2
+ getThemingArgTypes
3
+ } from "./chunk-NOGSFSIA.js";
4
+ import {
5
+ ADDON_ID,
6
+ COLOR_MODE_TOOL_ID,
7
+ DIRECTION_TOOL_ID,
8
+ EVENTS,
9
+ THEME_TOOL_ID
10
+ } from "./chunk-HSBRF2QZ.js";
11
+ import "./chunk-UK7U2PBM.js";
12
+ export {
13
+ ADDON_ID,
14
+ COLOR_MODE_TOOL_ID,
15
+ DIRECTION_TOOL_ID,
16
+ EVENTS,
17
+ THEME_TOOL_ID,
18
+ getThemingArgTypes
19
+ };