@saas-ui/storybook-addon 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,57 @@
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/color-mode/ColorModeSync.tsx
21
+ var ColorModeSync_exports = {};
22
+ __export(ColorModeSync_exports, {
23
+ ColorModeSync: () => ColorModeSync
24
+ });
25
+ module.exports = __toCommonJS(ColorModeSync_exports);
26
+ var import_react = require("react");
27
+ var import_react2 = require("@chakra-ui/react");
28
+ var import_addons = require("@storybook/addons");
29
+
30
+ // src/constants.ts
31
+ var ADDON_ID = "@saas-ui/storybook-addon";
32
+ var COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`;
33
+ var DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`;
34
+ var THEME_TOOL_ID = `${ADDON_ID}/theme-tool`;
35
+ var EVENTS = {
36
+ TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,
37
+ TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,
38
+ SET_THEME: `${ADDON_ID}/setTheme`
39
+ };
40
+
41
+ // src/feature/color-mode/ColorModeSync.tsx
42
+ function ColorModeSync() {
43
+ const { setColorMode } = (0, import_react2.useColorMode)();
44
+ (0, import_react.useEffect)(() => {
45
+ const channel = import_addons.addons.getChannel();
46
+ const colorModeToolCallback = (value) => setColorMode(value);
47
+ channel.on(EVENTS.TOGGLE_COLOR_MODE, colorModeToolCallback);
48
+ return () => {
49
+ channel.removeListener(EVENTS.TOGGLE_COLOR_MODE, colorModeToolCallback);
50
+ };
51
+ }, [setColorMode]);
52
+ return null;
53
+ }
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ ColorModeSync
57
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Render <ColorModeSync /> to sync the storybook color mode with Chakra UI
3
+ */
4
+ declare function ColorModeSync(): null;
5
+
6
+ export { ColorModeSync };
@@ -0,0 +1,8 @@
1
+ import {
2
+ ColorModeSync
3
+ } from "../../chunk-SVHNULTN.js";
4
+ import "../../chunk-HSBRF2QZ.js";
5
+ import "../../chunk-UK7U2PBM.js";
6
+ export {
7
+ ColorModeSync
8
+ };
@@ -0,0 +1,95 @@
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/color-mode/ColorModeTool.tsx
21
+ var ColorModeTool_exports = {};
22
+ __export(ColorModeTool_exports, {
23
+ ColorModeTool: () => ColorModeTool
24
+ });
25
+ module.exports = __toCommonJS(ColorModeTool_exports);
26
+ var import_api = require("@storybook/api");
27
+ var import_components = require("@storybook/components");
28
+ var import_addons = require("@storybook/addons");
29
+
30
+ // src/constants.ts
31
+ var ADDON_ID = "@saas-ui/storybook-addon";
32
+ var COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`;
33
+ var DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`;
34
+ var THEME_TOOL_ID = `${ADDON_ID}/theme-tool`;
35
+ var EVENTS = {
36
+ TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,
37
+ TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,
38
+ SET_THEME: `${ADDON_ID}/setTheme`
39
+ };
40
+
41
+ // src/feature/color-mode/ColorModeTool.tsx
42
+ var import_jsx_runtime = require("react/jsx-runtime");
43
+ var MoonIcon = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", focusable: "false", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
44
+ "path",
45
+ {
46
+ fill: "currentColor",
47
+ d: "M21.4,13.7C20.6,13.9,19.8,14,19,14c-5,0-9-4-9-9c0-0.8,0.1-1.6,0.3-2.4c0.1-0.3,0-0.7-0.3-1 c-0.3-0.3-0.6-0.4-1-0.3C4.3,2.7,1,7.1,1,12c0,6.1,4.9,11,11,11c4.9,0,9.3-3.3,10.6-8.1c0.1-0.3,0-0.7-0.3-1 C22.1,13.7,21.7,13.6,21.4,13.7z"
48
+ }
49
+ ) });
50
+ var SunIcon = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", focusable: "false", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
51
+ "g",
52
+ {
53
+ strokeLinejoin: "round",
54
+ strokeLinecap: "round",
55
+ strokeWidth: "2",
56
+ fill: "none",
57
+ stroke: "currentColor",
58
+ children: [
59
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "5" }),
60
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 1v2" }),
61
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 21v2" }),
62
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4.22 4.22l1.42 1.42" }),
63
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M18.36 18.36l1.42 1.42" }),
64
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M1 12h2" }),
65
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 12h2" }),
66
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4.22 19.78l1.42-1.42" }),
67
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M18.36 5.64l1.42-1.42" })
68
+ ]
69
+ }
70
+ ) });
71
+ var ColorModeTool = () => {
72
+ const isDarkMode = localStorage.getItem("chakra-ui-color-mode") === "dark";
73
+ const [darkMode, setDarkMode] = (0, import_api.useAddonState)(
74
+ `${ADDON_ID}/dark-mode`,
75
+ isDarkMode
76
+ );
77
+ const channel = import_addons.addons.getChannel();
78
+ const toggleDarkMode = () => {
79
+ channel.emit(EVENTS.TOGGLE_COLOR_MODE, !darkMode ? "dark" : "light");
80
+ setDarkMode(!darkMode);
81
+ };
82
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
83
+ import_components.IconButton,
84
+ {
85
+ active: darkMode,
86
+ title: `Set color mode to ${darkMode ? "light" : "dark"}`,
87
+ onClick: toggleDarkMode,
88
+ children: darkMode ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SunIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MoonIcon, {})
89
+ }
90
+ );
91
+ };
92
+ // Annotate the CommonJS export names for ESM import in node:
93
+ 0 && (module.exports = {
94
+ ColorModeTool
95
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This component is rendered in the Storybook toolbar
3
+ */
4
+ declare const ColorModeTool: () => JSX.Element;
5
+
6
+ export { ColorModeTool };
@@ -0,0 +1,8 @@
1
+ import {
2
+ ColorModeTool
3
+ } from "../../chunk-QNOLFHPG.js";
4
+ import "../../chunk-HSBRF2QZ.js";
5
+ import "../../chunk-UK7U2PBM.js";
6
+ export {
7
+ ColorModeTool
8
+ };