@saas-ui/storybook-addon 3.0.2 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +11 -0
- package/dist/ChakraProviderDecorator.cjs +5 -5
- package/dist/ChakraProviderDecorator.cjs.map +1 -1
- package/dist/ChakraProviderDecorator.js +5 -5
- package/dist/ChakraProviderDecorator.js.map +1 -1
- package/dist/arg-types.cjs +1 -1
- package/dist/arg-types.cjs.map +1 -1
- package/dist/arg-types.d.cts +1 -1
- package/dist/arg-types.d.ts +1 -1
- package/dist/arg-types.js +1 -1
- package/dist/arg-types.js.map +1 -1
- package/dist/color-mode/ColorModeSync.cjs +1 -1
- package/dist/color-mode/ColorModeSync.cjs.map +1 -1
- package/dist/color-mode/ColorModeSync.js +1 -1
- package/dist/color-mode/ColorModeSync.js.map +1 -1
- package/dist/color-mode/ColorModeTool.cjs +1 -1
- package/dist/color-mode/ColorModeTool.cjs.map +1 -1
- package/dist/color-mode/ColorModeTool.js +1 -1
- package/dist/color-mode/ColorModeTool.js.map +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/direction/DirectionTool.cjs +1 -1
- package/dist/direction/DirectionTool.cjs.map +1 -1
- package/dist/direction/DirectionTool.js +1 -1
- package/dist/direction/DirectionTool.js.map +1 -1
- package/dist/direction/useDirection.cjs +1 -1
- package/dist/direction/useDirection.cjs.map +1 -1
- package/dist/direction/useDirection.d.cts +1 -1
- package/dist/direction/useDirection.d.ts +1 -1
- package/dist/direction/useDirection.js +1 -1
- package/dist/direction/useDirection.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/manager.cjs +2 -2
- package/dist/manager.cjs.map +1 -1
- package/dist/manager.js +2 -2
- package/dist/manager.js.map +1 -1
- package/dist/preview.cjs +5 -5
- package/dist/preview.cjs.map +1 -1
- package/dist/preview.js +5 -5
- package/dist/preview.js.map +1 -1
- package/dist/theme/ThemeTool.cjs +1 -1
- package/dist/theme/ThemeTool.cjs.map +1 -1
- package/dist/theme/ThemeTool.js +1 -1
- package/dist/theme/ThemeTool.js.map +1 -1
- package/package.json +11 -11
package/dist/arg-types.cjs
CHANGED
@@ -3,5 +3,5 @@
|
|
3
3
|
function y(t){let o=Object.keys(t||{});return ["50","100","200","300","400","500","600","700","800","900"].every(e=>o.includes(e))}function u(t,o){var c,i,m,p;let e=t.components[o];if(!e)return;let n={},s=Object.keys(e.variants||{});s.length&&(n.variant={type:{name:"enum",value:s},defaultValue:(c=e.defaultProps)==null?void 0:c.variant});let a=Object.keys(e.sizes||{});if(a.length&&(n.size={type:{name:"enum",value:a},defaultValue:(i=e.defaultProps)==null?void 0:i.size}),(m=e.defaultProps)!=null&&m.colorScheme){let l=Object.entries(t.colors).filter(([,r])=>y(r)).map(([r])=>r);l.length&&(n.colorScheme={type:{name:"enum",value:l},defaultValue:(p=e.defaultProps)==null?void 0:p.colorScheme});}return n}
|
4
4
|
|
5
5
|
exports.getThemingArgTypes = u;
|
6
|
-
//# sourceMappingURL=
|
6
|
+
//# sourceMappingURL=arg-types.cjs.map
|
7
7
|
//# sourceMappingURL=arg-types.cjs.map
|
package/dist/arg-types.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/arg-types.ts"],"names":["validateColorScheme","value","valueKeys","term","getThemingArgTypes","theme","componentName","_a","_b","_c","_d","component","argTypes","variantOptions","sizeOptions","colorSchemes","key"],"mappings":"AAiBA,SAASA,EAAoBC,
|
1
|
+
{"version":3,"sources":["../src/arg-types.ts"],"names":["validateColorScheme","value","valueKeys","term","getThemingArgTypes","theme","componentName","_a","_b","_c","_d","component","argTypes","variantOptions","sizeOptions","colorSchemes","key"],"mappings":";;AAiBA,SAASA,EAAoBC,CAAe,CAAA,CAC1C,IAAMC,CAAAA,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,OAAO,CAAC,EAAGJ,CAAK,IAAMD,CAAoBC,CAAAA,CAAK,CAAC,CAAA,CAChD,IAAI,CAAC,CAACe,CAAG,CAAMA,GAAAA,CAAG,EAEjBD,CAAa,CAAA,MAAA,GACfH,CAAS,CAAA,WAAA,CAAc,CACrB,IAAM,CAAA,CAAE,KAAM,MAAQ,CAAA,KAAA,CAAOG,CAAa,CAC1C,CAAA,YAAA,CAAA,CAAcL,CAAAC,CAAAA,CAAAA,CAAU,eAAV,IAAAD,CAAAA,KAAAA,CAAAA,CAAAA,CAAAA,CAAwB,WACxC,CAEJ,EAAA,CAEA,OAAOE,CACT","file":"arg-types.cjs","sourcesContent":["import type { ArgTypes } from '@storybook/react'\nimport type { ThemingProps } from '@chakra-ui/react'\n\n/**\n * `keyof` alternative which omits non-string keys\n */\ntype KeyOf<T> = [T] extends [never]\n ? never\n : T extends object\n ? Extract<keyof T, string>\n : never\n\nexport type ThemingArgTypeKey = 'variant' | 'size' | 'colorScheme'\n\n/**\n * Checks if the given color scale object has all required keys: 50, 100, 200...900.\n */\nfunction validateColorScheme(value: object) {\n const valueKeys = Object.keys(value || {})\n return [\n '50',\n '100',\n '200',\n '300',\n '400',\n '500',\n '600',\n '700',\n '800',\n '900',\n ].every((term) => valueKeys.includes(term))\n}\n\n/**\n * Create Storybook controls based on a Chakra UI theme component.\n *\n * @example\n * export default {\n * title: \"Components / Forms / Button\",\n * argTypes: getThemingArgTypes(theme, \"Button\"),\n * }\n *\n * @example full example\n * import { Meta, StoryFn } from \"@storybook/react\"\n * import { getThemingArgTypes } from \"@chakra-ui/storybook-addon\"\n * import { theme } from \"<your-theme>\"\n *\n * export default {\n * title: \"Components / Forms / Button\",\n * argTypes: {\n * ...getThemingArgTypes(theme, \"Button\"),\n * children: \"string\"\n * },\n * args: { children: \"Button\" },\n * } as Meta\n *\n * interface StoryProps extends ThemingProps<\"Button\"> {\n * children?: React.ReactNode\n * }\n *\n * export const Basic: StoryFn<StoryProps> = (props) => <Button {...props} />\n *\n * @param theme same Chakra UI theme used in .storybook/preview.tsx\n * @param componentName component name to create the ArgTypes for\n */\nexport function getThemingArgTypes<\n Theme extends {\n colors: Record<string, any>\n components: Record<string, any>\n },\n ComponentName extends KeyOf<Theme['components']>\n>(theme: Theme, componentName: ComponentName) {\n const component = theme.components[componentName]\n if (!component) {\n return undefined\n }\n\n const argTypes: ArgTypes<\n Partial<Pick<ThemingProps<ComponentName>, ThemingArgTypeKey>>\n > = {}\n\n const variantOptions = Object.keys(component.variants || {})\n if (variantOptions.length) {\n argTypes.variant = {\n type: { name: 'enum', value: variantOptions },\n defaultValue: component.defaultProps?.variant,\n }\n }\n\n const sizeOptions = Object.keys(component.sizes || {})\n if (sizeOptions.length) {\n argTypes.size = {\n type: { name: 'enum', value: sizeOptions },\n defaultValue: component.defaultProps?.size,\n }\n }\n\n if (component.defaultProps?.['colorScheme']) {\n const colorSchemes = Object.entries(theme.colors)\n .filter(([, value]) => validateColorScheme(value))\n .map(([key]) => key)\n\n if (colorSchemes.length) {\n argTypes.colorScheme = {\n type: { name: 'enum', value: colorSchemes },\n defaultValue: component.defaultProps?.colorScheme,\n }\n }\n }\n\n return argTypes\n}\n"]}
|
package/dist/arg-types.d.cts
CHANGED
package/dist/arg-types.d.ts
CHANGED
package/dist/arg-types.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
function y(t){let o=Object.keys(t||{});return ["50","100","200","300","400","500","600","700","800","900"].every(e=>o.includes(e))}function u(t,o){var c,i,m,p;let e=t.components[o];if(!e)return;let n={},s=Object.keys(e.variants||{});s.length&&(n.variant={type:{name:"enum",value:s},defaultValue:(c=e.defaultProps)==null?void 0:c.variant});let a=Object.keys(e.sizes||{});if(a.length&&(n.size={type:{name:"enum",value:a},defaultValue:(i=e.defaultProps)==null?void 0:i.size}),(m=e.defaultProps)!=null&&m.colorScheme){let l=Object.entries(t.colors).filter(([,r])=>y(r)).map(([r])=>r);l.length&&(n.colorScheme={type:{name:"enum",value:l},defaultValue:(p=e.defaultProps)==null?void 0:p.colorScheme});}return n}
|
2
2
|
|
3
3
|
export { u as getThemingArgTypes };
|
4
|
-
//# sourceMappingURL=
|
4
|
+
//# sourceMappingURL=arg-types.js.map
|
5
5
|
//# sourceMappingURL=arg-types.js.map
|
package/dist/arg-types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/arg-types.ts"],"names":["validateColorScheme","value","valueKeys","term","getThemingArgTypes","theme","componentName","_a","_b","_c","_d","component","argTypes","variantOptions","sizeOptions","colorSchemes","key"],"mappings":"AAiBA,SAASA,EAAoBC,
|
1
|
+
{"version":3,"sources":["../src/arg-types.ts"],"names":["validateColorScheme","value","valueKeys","term","getThemingArgTypes","theme","componentName","_a","_b","_c","_d","component","argTypes","variantOptions","sizeOptions","colorSchemes","key"],"mappings":"AAiBA,SAASA,EAAoBC,CAAe,CAAA,CAC1C,IAAMC,CAAAA,CAAY,OAAO,IAAKD,CAAAA,CAAAA,EAAS,EAAE,EACzC,OAAO,CACL,KACA,KACA,CAAA,KAAA,CACA,MACA,KACA,CAAA,KAAA,CACA,KACA,CAAA,KAAA,CACA,MACA,KACF,CAAA,CAAE,KAAOE,CAAAA,CAAAA,EAASD,EAAU,QAASC,CAAAA,CAAI,CAAC,CAC5C,CAkCO,SAASC,CAAAA,CAMdC,EAAcC,CAA8B,CAAA,CAvE9C,IAAAC,CAAAC,CAAAA,CAAAA,CAAAC,CAAAC,CAAAA,CAAAA,CAwEE,IAAMC,CAAYN,CAAAA,CAAAA,CAAM,UAAWC,CAAAA,CAAa,EAChD,GAAI,CAACK,CACH,CAAA,OAGF,IAAMC,CAEF,CAAA,GAEEC,CAAiB,CAAA,MAAA,CAAO,KAAKF,CAAU,CAAA,QAAA,EAAY,EAAE,EACvDE,CAAe,CAAA,MAAA,GACjBD,EAAS,OAAU,CAAA,CACjB,KAAM,CAAE,IAAA,CAAM,MAAQ,CAAA,KAAA,CAAOC,CAAe,CAC5C,CAAA,YAAA,CAAA,CAAcN,EAAAI,CAAU,CAAA,YAAA,GAAV,YAAAJ,CAAwB,CAAA,OACxC,CAGF,CAAA,CAAA,IAAMO,EAAc,MAAO,CAAA,IAAA,CAAKH,CAAU,CAAA,KAAA,EAAS,EAAE,CAAA,CAQrD,GAPIG,CAAAA,CAAY,SACdF,CAAS,CAAA,IAAA,CAAO,CACd,IAAM,CAAA,CAAE,KAAM,MAAQ,CAAA,KAAA,CAAOE,CAAY,CAAA,CACzC,cAAcN,CAAAG,CAAAA,CAAAA,CAAU,eAAV,IAAAH,CAAAA,KAAAA,CAAAA,CAAAA,CAAAA,CAAwB,IACxC,CAGEC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAE,CAAU,CAAA,YAAA,GAAV,MAAAF,CAAyB,CAAA,WAAA,CAAgB,CAC3C,IAAMM,CAAAA,CAAe,OAAO,OAAQV,CAAAA,CAAAA,CAAM,MAAM,CAAA,CAC7C,OAAO,CAAC,EAAGJ,CAAK,IAAMD,CAAoBC,CAAAA,CAAK,CAAC,CAAA,CAChD,IAAI,CAAC,CAACe,CAAG,CAAMA,GAAAA,CAAG,EAEjBD,CAAa,CAAA,MAAA,GACfH,CAAS,CAAA,WAAA,CAAc,CACrB,IAAM,CAAA,CAAE,KAAM,MAAQ,CAAA,KAAA,CAAOG,CAAa,CAC1C,CAAA,YAAA,CAAA,CAAcL,CAAAC,CAAAA,CAAAA,CAAU,eAAV,IAAAD,CAAAA,KAAAA,CAAAA,CAAAA,CAAAA,CAAwB,WACxC,CAEJ,EAAA,CAEA,OAAOE,CACT","file":"arg-types.js","sourcesContent":["import type { ArgTypes } from '@storybook/react'\nimport type { ThemingProps } from '@chakra-ui/react'\n\n/**\n * `keyof` alternative which omits non-string keys\n */\ntype KeyOf<T> = [T] extends [never]\n ? never\n : T extends object\n ? Extract<keyof T, string>\n : never\n\nexport type ThemingArgTypeKey = 'variant' | 'size' | 'colorScheme'\n\n/**\n * Checks if the given color scale object has all required keys: 50, 100, 200...900.\n */\nfunction validateColorScheme(value: object) {\n const valueKeys = Object.keys(value || {})\n return [\n '50',\n '100',\n '200',\n '300',\n '400',\n '500',\n '600',\n '700',\n '800',\n '900',\n ].every((term) => valueKeys.includes(term))\n}\n\n/**\n * Create Storybook controls based on a Chakra UI theme component.\n *\n * @example\n * export default {\n * title: \"Components / Forms / Button\",\n * argTypes: getThemingArgTypes(theme, \"Button\"),\n * }\n *\n * @example full example\n * import { Meta, StoryFn } from \"@storybook/react\"\n * import { getThemingArgTypes } from \"@chakra-ui/storybook-addon\"\n * import { theme } from \"<your-theme>\"\n *\n * export default {\n * title: \"Components / Forms / Button\",\n * argTypes: {\n * ...getThemingArgTypes(theme, \"Button\"),\n * children: \"string\"\n * },\n * args: { children: \"Button\" },\n * } as Meta\n *\n * interface StoryProps extends ThemingProps<\"Button\"> {\n * children?: React.ReactNode\n * }\n *\n * export const Basic: StoryFn<StoryProps> = (props) => <Button {...props} />\n *\n * @param theme same Chakra UI theme used in .storybook/preview.tsx\n * @param componentName component name to create the ArgTypes for\n */\nexport function getThemingArgTypes<\n Theme extends {\n colors: Record<string, any>\n components: Record<string, any>\n },\n ComponentName extends KeyOf<Theme['components']>\n>(theme: Theme, componentName: ComponentName) {\n const component = theme.components[componentName]\n if (!component) {\n return undefined\n }\n\n const argTypes: ArgTypes<\n Partial<Pick<ThemingProps<ComponentName>, ThemingArgTypeKey>>\n > = {}\n\n const variantOptions = Object.keys(component.variants || {})\n if (variantOptions.length) {\n argTypes.variant = {\n type: { name: 'enum', value: variantOptions },\n defaultValue: component.defaultProps?.variant,\n }\n }\n\n const sizeOptions = Object.keys(component.sizes || {})\n if (sizeOptions.length) {\n argTypes.size = {\n type: { name: 'enum', value: sizeOptions },\n defaultValue: component.defaultProps?.size,\n }\n }\n\n if (component.defaultProps?.['colorScheme']) {\n const colorSchemes = Object.entries(theme.colors)\n .filter(([, value]) => validateColorScheme(value))\n .map(([key]) => key)\n\n if (colorSchemes.length) {\n argTypes.colorScheme = {\n type: { name: 'enum', value: colorSchemes },\n defaultValue: component.defaultProps?.colorScheme,\n }\n }\n }\n\n return argTypes\n}\n"]}
|
@@ -7,5 +7,5 @@ var previewApi = require('@storybook/preview-api');
|
|
7
7
|
var o="@saas-ui/storybook-addon2",t={TOGGLE_COLOR_MODE:`${o}/toggleColorMode`,TOGGLE_DIRECTION:`${o}/toggleDirection`,SET_THEME:`${o}/setTheme`};function d(){let{setColorMode:e}=react.useColorMode();return react$1.useEffect(()=>{let r=previewApi.addons.getChannel(),n=O=>e(O);return r.on(t.TOGGLE_COLOR_MODE,n),()=>{r.removeListener(t.TOGGLE_COLOR_MODE,n);}},[e]),null}
|
8
8
|
|
9
9
|
exports.ColorModeSync = d;
|
10
|
-
//# sourceMappingURL=
|
10
|
+
//# sourceMappingURL=ColorModeSync.cjs.map
|
11
11
|
//# sourceMappingURL=ColorModeSync.cjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/
|
1
|
+
{"version":3,"sources":["../../src/constants.ts","../../src/color-mode/ColorModeSync.tsx"],"names":["ADDON_ID","EVENTS","ColorModeSync","setColorMode","useColorMode","useEffect","channel","addons","colorModeToolCallback","value"],"mappings":";;;;;;IAAaA,CAAW,CAAA,2BAAA,CAKXC,CAAS,CAAA,CACpB,kBAAmB,CAAGD,EAAAA,CAAQ,mBAC9B,gBAAkB,CAAA,CAAA,EAAGA,CAAQ,CAC7B,gBAAA,CAAA,CAAA,SAAA,CAAW,GAAGA,CAAQ,CAAA,SAAA,CACxB,ECDO,SAASE,CAAAA,EAAgB,CAC9B,GAAM,CAAE,YAAAC,CAAAA,CAAa,EAAIC,kBAAa,EAAA,CAEtC,OAAAC,iBAAU,CAAA,IAAM,CACd,IAAMC,EAAUC,iBAAO,CAAA,UAAA,GAEjBC,CAAyBC,CAAAA,CAAAA,EAAkBN,EAAaM,CAAK,CAAA,CACnE,OAAAH,CAAAA,CAAQ,GAAGL,CAAO,CAAA,iBAAA,CAAmBO,CAAqB,CAEnD,CAAA,IAAM,CACXF,CAAQ,CAAA,cAAA,CAAeL,EAAO,iBAAmBO,CAAAA,CAAqB,EACxE,CACF,CAAA,CAAG,CAACL,CAAY,CAAC,EAEV,IACT","file":"ColorModeSync.cjs","sourcesContent":["export const ADDON_ID = '@saas-ui/storybook-addon2'\nexport const COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`\nexport const DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`\nexport const THEME_TOOL_ID = `${ADDON_ID}/theme-tool`\n\nexport const EVENTS = {\n TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,\n TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,\n SET_THEME: `${ADDON_ID}/setTheme`,\n}\n","import { useEffect } from 'react'\nimport { useColorMode } from '@chakra-ui/react'\nimport { addons } from '@storybook/preview-api'\nimport { EVENTS } from '../constants'\n\n/**\n * Render <ColorModeSync /> to sync the storybook color mode with Chakra UI\n */\nexport function ColorModeSync() {\n const { setColorMode } = useColorMode()\n\n useEffect(() => {\n const channel = addons.getChannel()\n\n const colorModeToolCallback = (value: string) => setColorMode(value)\n channel.on(EVENTS.TOGGLE_COLOR_MODE, colorModeToolCallback)\n\n return () => {\n channel.removeListener(EVENTS.TOGGLE_COLOR_MODE, colorModeToolCallback)\n }\n }, [setColorMode])\n\n return null\n}\n"]}
|
@@ -5,5 +5,5 @@ import { addons } from '@storybook/preview-api';
|
|
5
5
|
var o="@saas-ui/storybook-addon2",t={TOGGLE_COLOR_MODE:`${o}/toggleColorMode`,TOGGLE_DIRECTION:`${o}/toggleDirection`,SET_THEME:`${o}/setTheme`};function d(){let{setColorMode:e}=useColorMode();return useEffect(()=>{let r=addons.getChannel(),n=O=>e(O);return r.on(t.TOGGLE_COLOR_MODE,n),()=>{r.removeListener(t.TOGGLE_COLOR_MODE,n);}},[e]),null}
|
6
6
|
|
7
7
|
export { d as ColorModeSync };
|
8
|
-
//# sourceMappingURL=
|
8
|
+
//# sourceMappingURL=ColorModeSync.js.map
|
9
9
|
//# sourceMappingURL=ColorModeSync.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/
|
1
|
+
{"version":3,"sources":["../../src/constants.ts","../../src/color-mode/ColorModeSync.tsx"],"names":["ADDON_ID","EVENTS","ColorModeSync","setColorMode","useColorMode","useEffect","channel","addons","colorModeToolCallback","value"],"mappings":";;;;IAAaA,CAAW,CAAA,2BAAA,CAKXC,CAAS,CAAA,CACpB,kBAAmB,CAAGD,EAAAA,CAAQ,mBAC9B,gBAAkB,CAAA,CAAA,EAAGA,CAAQ,CAC7B,gBAAA,CAAA,CAAA,SAAA,CAAW,GAAGA,CAAQ,CAAA,SAAA,CACxB,ECDO,SAASE,CAAAA,EAAgB,CAC9B,GAAM,CAAE,YAAAC,CAAAA,CAAa,EAAIC,YAAa,EAAA,CAEtC,OAAAC,SAAU,CAAA,IAAM,CACd,IAAMC,EAAUC,MAAO,CAAA,UAAA,GAEjBC,CAAyBC,CAAAA,CAAAA,EAAkBN,EAAaM,CAAK,CAAA,CACnE,OAAAH,CAAAA,CAAQ,GAAGL,CAAO,CAAA,iBAAA,CAAmBO,CAAqB,CAEnD,CAAA,IAAM,CACXF,CAAQ,CAAA,cAAA,CAAeL,EAAO,iBAAmBO,CAAAA,CAAqB,EACxE,CACF,CAAA,CAAG,CAACL,CAAY,CAAC,EAEV,IACT","file":"ColorModeSync.js","sourcesContent":["export const ADDON_ID = '@saas-ui/storybook-addon2'\nexport const COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`\nexport const DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`\nexport const THEME_TOOL_ID = `${ADDON_ID}/theme-tool`\n\nexport const EVENTS = {\n TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,\n TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,\n SET_THEME: `${ADDON_ID}/setTheme`,\n}\n","import { useEffect } from 'react'\nimport { useColorMode } from '@chakra-ui/react'\nimport { addons } from '@storybook/preview-api'\nimport { EVENTS } from '../constants'\n\n/**\n * Render <ColorModeSync /> to sync the storybook color mode with Chakra UI\n */\nexport function ColorModeSync() {\n const { setColorMode } = useColorMode()\n\n useEffect(() => {\n const channel = addons.getChannel()\n\n const colorModeToolCallback = (value: string) => setColorMode(value)\n channel.on(EVENTS.TOGGLE_COLOR_MODE, colorModeToolCallback)\n\n return () => {\n channel.removeListener(EVENTS.TOGGLE_COLOR_MODE, colorModeToolCallback)\n }\n }, [setColorMode])\n\n return null\n}\n"]}
|
@@ -28,5 +28,5 @@ var c__namespace = /*#__PURE__*/_interopNamespace(c);
|
|
28
28
|
var t="@saas-ui/storybook-addon2",a={TOGGLE_COLOR_MODE:`${t}/toggleColorMode`,TOGGLE_DIRECTION:`${t}/toggleDirection`,SET_THEME:`${t}/setTheme`};var p=()=>jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",focusable:"false",children:jsxRuntime.jsx("path",{fill:"currentColor",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"})}),i=()=>jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",focusable:"false",children:jsxRuntime.jsxs("g",{strokeLinejoin:"round",strokeLinecap:"round",strokeWidth:"2",fill:"none",stroke:"currentColor",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"5"}),jsxRuntime.jsx("path",{d:"M12 1v2"}),jsxRuntime.jsx("path",{d:"M12 21v2"}),jsxRuntime.jsx("path",{d:"M4.22 4.22l1.42 1.42"}),jsxRuntime.jsx("path",{d:"M18.36 18.36l1.42 1.42"}),jsxRuntime.jsx("path",{d:"M1 12h2"}),jsxRuntime.jsx("path",{d:"M21 12h2"}),jsxRuntime.jsx("path",{d:"M4.22 19.78l1.42-1.42"}),jsxRuntime.jsx("path",{d:"M18.36 5.64l1.42-1.42"})]})}),k=()=>{let r=localStorage.getItem("chakra-ui-color-mode")==="dark",[e,n]=c__namespace.useState(r),l=managerApi.addons.getChannel();return jsxRuntime.jsx(components.IconButton,{title:`Set color mode to ${e?"light":"dark"}`,active:e,onClick:()=>{l.emit(a.TOGGLE_COLOR_MODE,e?"light":"dark"),n(s=>!s);},children:e?jsxRuntime.jsx(i,{}):jsxRuntime.jsx(p,{})})};
|
29
29
|
|
30
30
|
exports.ColorModeTool = k;
|
31
|
-
//# sourceMappingURL=
|
31
|
+
//# sourceMappingURL=ColorModeTool.cjs.map
|
32
32
|
//# sourceMappingURL=ColorModeTool.cjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/
|
1
|
+
{"version":3,"sources":["../../src/constants.ts","../../src/color-mode/ColorModeTool.tsx"],"names":["ADDON_ID","EVENTS","MoonIcon","jsx","SunIcon","jsxs","ColorModeTool","isDarkMode","darkMode","setDarkMode","c","channel","addons","IconButton","prev"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;IAAaA,CAAW,CAAA,2BAAA,CAKXC,CAAAA,CAAS,CACpB,iBAAmB,CAAA,CAAA,EAAGD,CAAQ,CAC9B,gBAAA,CAAA,CAAA,gBAAA,CAAkB,GAAGA,CAAQ,CAAA,gBAAA,CAAA,CAC7B,UAAW,CAAGA,EAAAA,CAAQ,WACxB,ECHA,IAAME,CAAW,CAAA,IACfC,eAAC,KAAI,CAAA,CAAA,OAAA,CAAQ,YAAY,SAAU,CAAA,OAAA,CACjC,SAAAA,cAAC,CAAA,MAAA,CAAA,CACC,KAAK,cACL,CAAA,CAAA,CAAE,qOACH,CACH,CAAA,CAAA,CAGIC,EAAU,IACdD,cAAAA,CAAC,OAAI,OAAQ,CAAA,WAAA,CAAY,SAAU,CAAA,OAAA,CACjC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AA,EAAS,CAACA,CAAI,EAC7B,EAQK,QAAAN,CAAAA,CAAAA,CAAWL,eAACC,CAAA,CAAA,EAAQ,EAAKD,cAACD,CAAAA,CAAAA,CAAA,EAAS,CAAA,CACtC,CAEJ","file":"ColorModeTool.cjs","sourcesContent":["export const ADDON_ID = '@saas-ui/storybook-addon2'\nexport const COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`\nexport const DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`\nexport const THEME_TOOL_ID = `${ADDON_ID}/theme-tool`\n\nexport const EVENTS = {\n TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,\n TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,\n SET_THEME: `${ADDON_ID}/setTheme`,\n}\n","import * as React from 'react'\nimport { IconButton } from '@storybook/components'\nimport { addons } from '@storybook/manager-api'\n\nimport { EVENTS } from '../constants'\n\nconst MoonIcon = () => (\n <svg viewBox=\"0 0 24 24\" focusable=\"false\">\n <path\n fill=\"currentColor\"\n 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\"\n ></path>\n </svg>\n)\n\nconst SunIcon = () => (\n <svg viewBox=\"0 0 24 24\" focusable=\"false\">\n <g\n strokeLinejoin=\"round\"\n strokeLinecap=\"round\"\n strokeWidth=\"2\"\n fill=\"none\"\n stroke=\"currentColor\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"5\"></circle>\n <path d=\"M12 1v2\"></path>\n <path d=\"M12 21v2\"></path>\n <path d=\"M4.22 4.22l1.42 1.42\"></path>\n <path d=\"M18.36 18.36l1.42 1.42\"></path>\n <path d=\"M1 12h2\"></path>\n <path d=\"M21 12h2\"></path>\n <path d=\"M4.22 19.78l1.42-1.42\"></path>\n <path d=\"M18.36 5.64l1.42-1.42\"></path>\n </g>\n </svg>\n)\n\nexport const ColorModeTool = () => {\n const isDarkMode = localStorage.getItem('chakra-ui-color-mode') === 'dark'\n\n const [darkMode, setDarkMode] = React.useState(isDarkMode)\n\n const channel = addons.getChannel()\n\n const handleToggle = () => {\n channel.emit(EVENTS.TOGGLE_COLOR_MODE, !darkMode ? 'dark' : 'light')\n setDarkMode((prev) => !prev)\n }\n\n return (\n <IconButton\n title={`Set color mode to ${darkMode ? 'light' : 'dark'}`}\n active={darkMode}\n onClick={handleToggle}\n >\n {darkMode ? <SunIcon /> : <MoonIcon />}\n </IconButton>\n )\n}\n"]}
|
@@ -6,5 +6,5 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
6
|
var t="@saas-ui/storybook-addon2",a={TOGGLE_COLOR_MODE:`${t}/toggleColorMode`,TOGGLE_DIRECTION:`${t}/toggleDirection`,SET_THEME:`${t}/setTheme`};var p=()=>jsx("svg",{viewBox:"0 0 24 24",focusable:"false",children:jsx("path",{fill:"currentColor",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"})}),i=()=>jsx("svg",{viewBox:"0 0 24 24",focusable:"false",children:jsxs("g",{strokeLinejoin:"round",strokeLinecap:"round",strokeWidth:"2",fill:"none",stroke:"currentColor",children:[jsx("circle",{cx:"12",cy:"12",r:"5"}),jsx("path",{d:"M12 1v2"}),jsx("path",{d:"M12 21v2"}),jsx("path",{d:"M4.22 4.22l1.42 1.42"}),jsx("path",{d:"M18.36 18.36l1.42 1.42"}),jsx("path",{d:"M1 12h2"}),jsx("path",{d:"M21 12h2"}),jsx("path",{d:"M4.22 19.78l1.42-1.42"}),jsx("path",{d:"M18.36 5.64l1.42-1.42"})]})}),k=()=>{let r=localStorage.getItem("chakra-ui-color-mode")==="dark",[e,n]=c.useState(r),l=addons.getChannel();return jsx(IconButton,{title:`Set color mode to ${e?"light":"dark"}`,active:e,onClick:()=>{l.emit(a.TOGGLE_COLOR_MODE,e?"light":"dark"),n(s=>!s);},children:e?jsx(i,{}):jsx(p,{})})};
|
7
7
|
|
8
8
|
export { k as ColorModeTool };
|
9
|
-
//# sourceMappingURL=
|
9
|
+
//# sourceMappingURL=ColorModeTool.js.map
|
10
10
|
//# sourceMappingURL=ColorModeTool.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/
|
1
|
+
{"version":3,"sources":["../../src/constants.ts","../../src/color-mode/ColorModeTool.tsx"],"names":["ADDON_ID","EVENTS","MoonIcon","jsx","SunIcon","jsxs","ColorModeTool","isDarkMode","darkMode","setDarkMode","channel","addons","IconButton","prev"],"mappings":";;;;;IAAaA,CAAW,CAAA,2BAAA,CAKXC,CAAAA,CAAS,CACpB,iBAAmB,CAAA,CAAA,EAAGD,CAAQ,CAC9B,gBAAA,CAAA,CAAA,gBAAA,CAAkB,GAAGA,CAAQ,CAAA,gBAAA,CAAA,CAC7B,UAAW,CAAGA,EAAAA,CAAQ,WACxB,ECHA,IAAME,CAAW,CAAA,IACfC,IAAC,KAAI,CAAA,CAAA,OAAA,CAAQ,YAAY,SAAU,CAAA,OAAA,CACjC,SAAAA,GAAC,CAAA,MAAA,CAAA,CACC,KAAK,cACL,CAAA,CAAA,CAAE,qOACH,CACH,CAAA,CAAA,CAGIC,EAAU,IACdD,GAAAA,CAAC,OAAI,OAAQ,CAAA,WAAA,CAAY,SAAU,CAAA,OAAA,CACjC,QAAAE,CAAAA,IAAAA,CAAC,KACC,cAAe,CAAA,OAAA,CACf,cAAc,OACd,CAA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A,CAAA,EAAQ,EAAKD,GAACD,CAAAA,CAAAA,CAAA,EAAS,CAAA,CACtC,CAEJ","file":"ColorModeTool.js","sourcesContent":["export const ADDON_ID = '@saas-ui/storybook-addon2'\nexport const COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`\nexport const DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`\nexport const THEME_TOOL_ID = `${ADDON_ID}/theme-tool`\n\nexport const EVENTS = {\n TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,\n TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,\n SET_THEME: `${ADDON_ID}/setTheme`,\n}\n","import * as React from 'react'\nimport { IconButton } from '@storybook/components'\nimport { addons } from '@storybook/manager-api'\n\nimport { EVENTS } from '../constants'\n\nconst MoonIcon = () => (\n <svg viewBox=\"0 0 24 24\" focusable=\"false\">\n <path\n fill=\"currentColor\"\n 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\"\n ></path>\n </svg>\n)\n\nconst SunIcon = () => (\n <svg viewBox=\"0 0 24 24\" focusable=\"false\">\n <g\n strokeLinejoin=\"round\"\n strokeLinecap=\"round\"\n strokeWidth=\"2\"\n fill=\"none\"\n stroke=\"currentColor\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"5\"></circle>\n <path d=\"M12 1v2\"></path>\n <path d=\"M12 21v2\"></path>\n <path d=\"M4.22 4.22l1.42 1.42\"></path>\n <path d=\"M18.36 18.36l1.42 1.42\"></path>\n <path d=\"M1 12h2\"></path>\n <path d=\"M21 12h2\"></path>\n <path d=\"M4.22 19.78l1.42-1.42\"></path>\n <path d=\"M18.36 5.64l1.42-1.42\"></path>\n </g>\n </svg>\n)\n\nexport const ColorModeTool = () => {\n const isDarkMode = localStorage.getItem('chakra-ui-color-mode') === 'dark'\n\n const [darkMode, setDarkMode] = React.useState(isDarkMode)\n\n const channel = addons.getChannel()\n\n const handleToggle = () => {\n channel.emit(EVENTS.TOGGLE_COLOR_MODE, !darkMode ? 'dark' : 'light')\n setDarkMode((prev) => !prev)\n }\n\n return (\n <IconButton\n title={`Set color mode to ${darkMode ? 'light' : 'dark'}`}\n active={darkMode}\n onClick={handleToggle}\n >\n {darkMode ? <SunIcon /> : <MoonIcon />}\n </IconButton>\n )\n}\n"]}
|
package/dist/constants.cjs
CHANGED
package/dist/constants.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/constants.ts"],"names":["ADDON_ID","COLOR_MODE_TOOL_ID","DIRECTION_TOOL_ID","THEME_TOOL_ID","EVENTS"],"mappings":"
|
1
|
+
{"version":3,"sources":["../src/constants.ts"],"names":["ADDON_ID","COLOR_MODE_TOOL_ID","DIRECTION_TOOL_ID","THEME_TOOL_ID","EVENTS"],"mappings":";;AAAaA,IAAAA,CAAAA,CAAW,2BACXC,CAAAA,CAAAA,CAAqB,CAAGD,EAAAA,CAAQ,CAChCE,gBAAAA,CAAAA,CAAAA,CAAAA,CAAoB,CAAGF,EAAAA,CAAQ,CAC/BG,eAAAA,CAAAA,CAAAA,CAAAA,CAAgB,CAAGH,EAAAA,CAAQ,CAE3BI,WAAAA,CAAAA,CAAAA,CAAAA,CAAS,CACpB,iBAAA,CAAmB,CAAGJ,EAAAA,CAAQ,CAC9B,gBAAA,CAAA,CAAA,gBAAA,CAAkB,CAAGA,EAAAA,CAAQ,CAC7B,gBAAA,CAAA,CAAA,SAAA,CAAW,CAAGA,EAAAA,CAAQ,CACxB,SAAA,CAAA","file":"constants.cjs","sourcesContent":["export const ADDON_ID = '@saas-ui/storybook-addon2'\nexport const COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`\nexport const DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`\nexport const THEME_TOOL_ID = `${ADDON_ID}/theme-tool`\n\nexport const EVENTS = {\n TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,\n TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,\n SET_THEME: `${ADDON_ID}/setTheme`,\n}\n"]}
|
package/dist/constants.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
var o="@saas-ui/storybook-addon2",t=`${o}/color-mode-tool`,O=`${o}/direction-tool`,e=`${o}/theme-tool`,E={TOGGLE_COLOR_MODE:`${o}/toggleColorMode`,TOGGLE_DIRECTION:`${o}/toggleDirection`,SET_THEME:`${o}/setTheme`};
|
2
2
|
|
3
3
|
export { o as ADDON_ID, t as COLOR_MODE_TOOL_ID, O as DIRECTION_TOOL_ID, E as EVENTS, e as THEME_TOOL_ID };
|
4
|
-
//# sourceMappingURL=
|
4
|
+
//# sourceMappingURL=constants.js.map
|
5
5
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/constants.ts"],"names":["ADDON_ID","COLOR_MODE_TOOL_ID","DIRECTION_TOOL_ID","THEME_TOOL_ID","EVENTS"],"mappings":"
|
1
|
+
{"version":3,"sources":["../src/constants.ts"],"names":["ADDON_ID","COLOR_MODE_TOOL_ID","DIRECTION_TOOL_ID","THEME_TOOL_ID","EVENTS"],"mappings":"AAAaA,IAAAA,CAAAA,CAAW,2BACXC,CAAAA,CAAAA,CAAqB,CAAGD,EAAAA,CAAQ,CAChCE,gBAAAA,CAAAA,CAAAA,CAAAA,CAAoB,CAAGF,EAAAA,CAAQ,CAC/BG,eAAAA,CAAAA,CAAAA,CAAAA,CAAgB,CAAGH,EAAAA,CAAQ,CAE3BI,WAAAA,CAAAA,CAAAA,CAAAA,CAAS,CACpB,iBAAA,CAAmB,CAAGJ,EAAAA,CAAQ,CAC9B,gBAAA,CAAA,CAAA,gBAAA,CAAkB,CAAGA,EAAAA,CAAQ,CAC7B,gBAAA,CAAA,CAAA,SAAA,CAAW,CAAGA,EAAAA,CAAQ,CACxB,SAAA,CAAA","file":"constants.js","sourcesContent":["export const ADDON_ID = '@saas-ui/storybook-addon2'\nexport const COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`\nexport const DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`\nexport const THEME_TOOL_ID = `${ADDON_ID}/theme-tool`\n\nexport const EVENTS = {\n TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,\n TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,\n SET_THEME: `${ADDON_ID}/setTheme`,\n}\n"]}
|
@@ -8,5 +8,5 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var t="@saas-ui/storybook-addon2",n=`${t}/direction-tool`,i={TOGGLE_COLOR_MODE:`${t}/toggleColorMode`,TOGGLE_DIRECTION:`${t}/toggleDirection`,SET_THEME:`${t}/setTheme`};var D=e=>jsxRuntime.jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",height:"1em",width:"1em",style:{transform:"scale(1.2)"},...e,children:[jsxRuntime.jsx("path",{fill:"none",d:"M0 0h24v24H0V0z"}),jsxRuntime.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"})]}),I=e=>jsxRuntime.jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",height:"1em",width:"1em",style:{transform:"scale(1.2)"},...e,children:[jsxRuntime.jsx("path",{fill:"none",d:"M0 0h24v24H0V0z"}),jsxRuntime.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"})]}),L=()=>{let[e,s]=managerApi.useGlobals(),[l,c]=managerApi.useAddonState(n,e[n]||"ltr"),r=l!=="ltr"?"ltr":"rtl";react.useEffect(()=>{s({[n]:l});},[l,s]);let a=react.useCallback(()=>{managerApi.addons.getChannel().emit(i.TOGGLE_DIRECTION,r),c(r);},[c,r]);return jsxRuntime.jsx(components.IconButton,{active:l==="rtl",title:`Set layout direction to ${r}`,onClick:a,children:r==="ltr"?jsxRuntime.jsx(D,{}):jsxRuntime.jsx(I,{})})};
|
9
9
|
|
10
10
|
exports.DirectionTool = L;
|
11
|
-
//# sourceMappingURL=
|
11
|
+
//# sourceMappingURL=DirectionTool.cjs.map
|
12
12
|
//# sourceMappingURL=DirectionTool.cjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/
|
1
|
+
{"version":3,"sources":["../../src/constants.ts","../../src/direction/DirectionTool.tsx"],"names":["ADDON_ID","COLOR_MODE_TOOL_ID","DIRECTION_TOOL_ID","EVENTS","LTRIcon","props","jsxs","jsx","RTLIcon","DirectionTool","globals","setGlobals","useGlobals","direction","setDirection","useAddonState","targetDirection","useEffect","toggleDirection","useCallback","addons","IconButton"],"mappings":";;;;;;;AAAO,IAAMA,EAAW,2BACXC,CACAC,CAAAA,CAAoB,GAAGF,CAAQ,CAAA,eAAA,CAAA,CAG/BG,EAAS,CACpB,iBAAA,CAAmB,CAAGH,EAAAA,CAAQ,CAC9B,gBAAA,CAAA,CAAA,gBAAA,CAAkB,GAAGA,CAAQ,CAAA,gBAAA,CAAA,CAC7B,SAAW,CAAA,CAAA,EAAGA,CAAQ,CAAA,SAAA,CACxB,MCJMI,CAAWC,CAAAA,CAAAA,EACfC,gBAAC,KACC,CAAA,CAAA,MAAA,CAAO,eACP,IAAK,CAAA,cAAA,CACL,WAAY,CAAA,GAAA,CACZ,OAAQ,CAAA,WAAA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CAAA,CACrDF,EAAaE,CAAe,EAC9B,CAAG,CAAA,CAACF,CAAcE,CAAAA,CAAe,CAAC,CAElC,CAAA,OACET,cAACc,CAAAA,qBAAAA,CAAA,CACC,MAAA,CAAQR,IAAc,KACtB,CAAA,KAAA,CAAO,CAA2BG,wBAAAA,EAAAA,CAAe,CACjD,CAAA,CAAA,OAAA,CAASE,EAER,QAAAF,CAAAA,CAAAA,GAAoB,KAAQT,CAAAA,cAAAA,CAACH,CAAA,CAAA,EAAQ,EAAKG,cAACC,CAAAA,CAAAA,CAAA,EAAQ,CAAA,CACtD,CAEJ","file":"DirectionTool.cjs","sourcesContent":["export const ADDON_ID = '@saas-ui/storybook-addon2'\nexport const COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`\nexport const DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`\nexport const THEME_TOOL_ID = `${ADDON_ID}/theme-tool`\n\nexport const EVENTS = {\n TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,\n TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,\n SET_THEME: `${ADDON_ID}/setTheme`,\n}\n","import { useCallback, useEffect } from 'react'\nimport { addons, useAddonState, useGlobals } from '@storybook/manager-api'\nimport { IconButton } from '@storybook/components'\nimport { DIRECTION_TOOL_ID, EVENTS } from '../constants'\n\nconst LTRIcon = (props: React.SVGProps<SVGSVGElement>) => (\n <svg\n stroke=\"currentColor\"\n fill=\"currentColor\"\n strokeWidth=\"0\"\n viewBox=\"0 0 24 24\"\n height=\"1em\"\n width=\"1em\"\n style={{\n transform: 'scale(1.2)',\n }}\n {...props}\n >\n <path fill=\"none\" d=\"M0 0h24v24H0V0z\" />\n <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\" />\n </svg>\n)\n\nconst RTLIcon = (props: React.SVGProps<SVGSVGElement>) => (\n <svg\n stroke=\"currentColor\"\n fill=\"currentColor\"\n strokeWidth=\"0\"\n viewBox=\"0 0 24 24\"\n height=\"1em\"\n width=\"1em\"\n style={{\n transform: 'scale(1.2)',\n }}\n {...props}\n >\n <path fill=\"none\" d=\"M0 0h24v24H0V0z\" />\n <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\" />\n </svg>\n)\n\n/**\n * This component is rendered in the Storybook toolbar\n */\nexport const DirectionTool = () => {\n const [globals, setGlobals] = useGlobals()\n const [direction, setDirection] = useAddonState(\n DIRECTION_TOOL_ID,\n globals[DIRECTION_TOOL_ID] || 'ltr'\n )\n const targetDirection = direction !== 'ltr' ? 'ltr' : 'rtl'\n useEffect(() => {\n setGlobals({ [DIRECTION_TOOL_ID]: direction })\n }, [direction, setGlobals])\n\n const toggleDirection = useCallback(() => {\n const channel = addons.getChannel()\n channel.emit(EVENTS.TOGGLE_DIRECTION, targetDirection)\n setDirection(targetDirection)\n }, [setDirection, targetDirection])\n\n return (\n <IconButton\n active={direction === 'rtl'}\n title={`Set layout direction to ${targetDirection}`}\n onClick={toggleDirection}\n >\n {targetDirection === 'ltr' ? <LTRIcon /> : <RTLIcon />}\n </IconButton>\n )\n}\n"]}
|
@@ -6,5 +6,5 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
6
|
var t="@saas-ui/storybook-addon2",n=`${t}/direction-tool`,i={TOGGLE_COLOR_MODE:`${t}/toggleColorMode`,TOGGLE_DIRECTION:`${t}/toggleDirection`,SET_THEME:`${t}/setTheme`};var D=e=>jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",height:"1em",width:"1em",style:{transform:"scale(1.2)"},...e,children:[jsx("path",{fill:"none",d:"M0 0h24v24H0V0z"}),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"})]}),I=e=>jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",height:"1em",width:"1em",style:{transform:"scale(1.2)"},...e,children:[jsx("path",{fill:"none",d:"M0 0h24v24H0V0z"}),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"})]}),L=()=>{let[e,s]=useGlobals(),[l,c]=useAddonState(n,e[n]||"ltr"),r=l!=="ltr"?"ltr":"rtl";useEffect(()=>{s({[n]:l});},[l,s]);let a=useCallback(()=>{addons.getChannel().emit(i.TOGGLE_DIRECTION,r),c(r);},[c,r]);return jsx(IconButton,{active:l==="rtl",title:`Set layout direction to ${r}`,onClick:a,children:r==="ltr"?jsx(D,{}):jsx(I,{})})};
|
7
7
|
|
8
8
|
export { L as DirectionTool };
|
9
|
-
//# sourceMappingURL=
|
9
|
+
//# sourceMappingURL=DirectionTool.js.map
|
10
10
|
//# sourceMappingURL=DirectionTool.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/
|
1
|
+
{"version":3,"sources":["../../src/constants.ts","../../src/direction/DirectionTool.tsx"],"names":["ADDON_ID","COLOR_MODE_TOOL_ID","DIRECTION_TOOL_ID","EVENTS","LTRIcon","props","jsxs","jsx","RTLIcon","DirectionTool","globals","setGlobals","useGlobals","direction","setDirection","useAddonState","targetDirection","useEffect","toggleDirection","useCallback","addons","IconButton"],"mappings":";;;;;AAAO,IAAMA,EAAW,2BACXC,CACAC,CAAAA,CAAoB,GAAGF,CAAQ,CAAA,eAAA,CAAA,CAG/BG,EAAS,CACpB,iBAAA,CAAmB,CAAGH,EAAAA,C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CAAA,KAAA,CACtDI,SAAU,CAAA,IAAM,CACdN,CAAW,CAAA,CAAE,CAACT,CAAiB,EAAGW,CAAU,CAAC,EAC/C,CAAA,CAAG,CAACA,CAAAA,CAAWF,CAAU,CAAC,EAE1B,IAAMO,CAAAA,CAAkBC,WAAY,CAAA,IAAM,CACxBC,MAAAA,CAAO,YACf,CAAA,IAAA,CAAKjB,CAAO,CAAA,gBAAA,CAAkBa,CAAe,CAAA,CACrDF,EAAaE,CAAe,EAC9B,CAAG,CAAA,CAACF,CAAcE,CAAAA,CAAe,CAAC,CAElC,CAAA,OACET,GAACc,CAAAA,UAAAA,CAAA,CACC,MAAA,CAAQR,IAAc,KACtB,CAAA,KAAA,CAAO,CAA2BG,wBAAAA,EAAAA,CAAe,CACjD,CAAA,CAAA,OAAA,CAASE,EAER,QAAAF,CAAAA,CAAAA,GAAoB,KAAQT,CAAAA,GAAAA,CAACH,CAAA,CAAA,EAAQ,EAAKG,GAACC,CAAAA,CAAAA,CAAA,EAAQ,CAAA,CACtD,CAEJ","file":"DirectionTool.js","sourcesContent":["export const ADDON_ID = '@saas-ui/storybook-addon2'\nexport const COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`\nexport const DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`\nexport const THEME_TOOL_ID = `${ADDON_ID}/theme-tool`\n\nexport const EVENTS = {\n TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,\n TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,\n SET_THEME: `${ADDON_ID}/setTheme`,\n}\n","import { useCallback, useEffect } from 'react'\nimport { addons, useAddonState, useGlobals } from '@storybook/manager-api'\nimport { IconButton } from '@storybook/components'\nimport { DIRECTION_TOOL_ID, EVENTS } from '../constants'\n\nconst LTRIcon = (props: React.SVGProps<SVGSVGElement>) => (\n <svg\n stroke=\"currentColor\"\n fill=\"currentColor\"\n strokeWidth=\"0\"\n viewBox=\"0 0 24 24\"\n height=\"1em\"\n width=\"1em\"\n style={{\n transform: 'scale(1.2)',\n }}\n {...props}\n >\n <path fill=\"none\" d=\"M0 0h24v24H0V0z\" />\n <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\" />\n </svg>\n)\n\nconst RTLIcon = (props: React.SVGProps<SVGSVGElement>) => (\n <svg\n stroke=\"currentColor\"\n fill=\"currentColor\"\n strokeWidth=\"0\"\n viewBox=\"0 0 24 24\"\n height=\"1em\"\n width=\"1em\"\n style={{\n transform: 'scale(1.2)',\n }}\n {...props}\n >\n <path fill=\"none\" d=\"M0 0h24v24H0V0z\" />\n <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\" />\n </svg>\n)\n\n/**\n * This component is rendered in the Storybook toolbar\n */\nexport const DirectionTool = () => {\n const [globals, setGlobals] = useGlobals()\n const [direction, setDirection] = useAddonState(\n DIRECTION_TOOL_ID,\n globals[DIRECTION_TOOL_ID] || 'ltr'\n )\n const targetDirection = direction !== 'ltr' ? 'ltr' : 'rtl'\n useEffect(() => {\n setGlobals({ [DIRECTION_TOOL_ID]: direction })\n }, [direction, setGlobals])\n\n const toggleDirection = useCallback(() => {\n const channel = addons.getChannel()\n channel.emit(EVENTS.TOGGLE_DIRECTION, targetDirection)\n setDirection(targetDirection)\n }, [setDirection, targetDirection])\n\n return (\n <IconButton\n active={direction === 'rtl'}\n title={`Set layout direction to ${targetDirection}`}\n onClick={toggleDirection}\n >\n {targetDirection === 'ltr' ? <LTRIcon /> : <RTLIcon />}\n </IconButton>\n )\n}\n"]}
|
@@ -6,5 +6,5 @@ var previewApi = require('@storybook/preview-api');
|
|
6
6
|
var o="@saas-ui/storybook-addon2",e={TOGGLE_COLOR_MODE:`${o}/toggleColorMode`,TOGGLE_DIRECTION:`${o}/toggleDirection`,SET_THEME:`${o}/setTheme`};var a=(E="ltr")=>{let[t,r]=react.useState(E.toLowerCase());return react.useEffect(()=>{document.documentElement.dir=t;},[t]),react.useEffect(()=>{let n=previewApi.addons.getChannel(),c=O=>r(O);return n.on(e.TOGGLE_DIRECTION,c),()=>{n.removeListener(e.TOGGLE_DIRECTION,c);}},[r]),t};
|
7
7
|
|
8
8
|
exports.useDirection = a;
|
9
|
-
//# sourceMappingURL=
|
9
|
+
//# sourceMappingURL=useDirection.cjs.map
|
10
10
|
//# sourceMappingURL=useDirection.cjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/
|
1
|
+
{"version":3,"sources":["../../src/constants.ts","../../src/direction/useDirection.tsx"],"names":["ADDON_ID","EVENTS","useDirection","initialDirection","direction","setDirection","useState","useEffect","channel","addons","callback","value"],"mappings":";;;;;AAAaA,IAAAA,CAAAA,CAAW,4BAKXC,EAAS,CACpB,iBAAA,CAAmB,GAAGD,CAAQ,CAAA,gBAAA,CAAA,CAC9B,iBAAkB,CAAGA,EAAAA,CAAQ,CAC7B,gBAAA,CAAA,CAAA,SAAA,CAAW,CAAGA,EAAAA,CAAQ,WACxB,ECFO,IAAME,CAAe,CAAA,CAACC,CAAkC,CAAA,KAAA,GAAU,CACvE,GAAM,CAACC,CAAWC,CAAAA,CAAY,CAAIC,CAAAA,cAAAA,CAASH,EAAiB,WAAY,EAAC,EAEzE,OAAAI,eAAAA,CAAU,IAAM,CACd,QAAA,CAAS,eAAgB,CAAA,GAAA,CAAMH,EACjC,CAAA,CAAG,CAACA,CAAS,CAAC,EAEdG,eAAU,CAAA,IAAM,CACd,IAAMC,CAAAA,CAAUC,iBAAO,CAAA,UAAA,EACjBC,CAAAA,CAAAA,CAAYC,GAAkBN,CAAaM,CAAAA,CAAK,EACtD,OAAAH,CAAAA,CAAQ,GAAGP,CAAO,CAAA,gBAAA,CAAkBS,CAAQ,CAAA,CACrC,IAAM,CACXF,EAAQ,cAAeP,CAAAA,CAAAA,CAAO,gBAAkBS,CAAAA,CAAQ,EAC1D,CACF,EAAG,CAACL,CAAY,CAAC,CAAA,CAEVD,CACT","file":"useDirection.cjs","sourcesContent":["export const ADDON_ID = '@saas-ui/storybook-addon2'\nexport const COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`\nexport const DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`\nexport const THEME_TOOL_ID = `${ADDON_ID}/theme-tool`\n\nexport const EVENTS = {\n TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,\n TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,\n SET_THEME: `${ADDON_ID}/setTheme`,\n}\n","import { useEffect, useState } from 'react'\nimport { addons } from '@storybook/preview-api'\nimport { EVENTS } from '../constants'\n\n/**\n * Sync the layout direction to the html element\n */\nexport const useDirection = (initialDirection: 'ltr' | 'rtl' = 'ltr') => {\n const [direction, setDirection] = useState(initialDirection.toLowerCase())\n\n useEffect(() => {\n document.documentElement.dir = direction\n }, [direction])\n\n useEffect(() => {\n const channel = addons.getChannel()\n const callback = (value: string) => setDirection(value)\n channel.on(EVENTS.TOGGLE_DIRECTION, callback)\n return () => {\n channel.removeListener(EVENTS.TOGGLE_DIRECTION, callback)\n }\n }, [setDirection])\n\n return direction\n}\n"]}
|
@@ -4,5 +4,5 @@ import { addons } from '@storybook/preview-api';
|
|
4
4
|
var o="@saas-ui/storybook-addon2",e={TOGGLE_COLOR_MODE:`${o}/toggleColorMode`,TOGGLE_DIRECTION:`${o}/toggleDirection`,SET_THEME:`${o}/setTheme`};var a=(E="ltr")=>{let[t,r]=useState(E.toLowerCase());return useEffect(()=>{document.documentElement.dir=t;},[t]),useEffect(()=>{let n=addons.getChannel(),c=O=>r(O);return n.on(e.TOGGLE_DIRECTION,c),()=>{n.removeListener(e.TOGGLE_DIRECTION,c);}},[r]),t};
|
5
5
|
|
6
6
|
export { a as useDirection };
|
7
|
-
//# sourceMappingURL=
|
7
|
+
//# sourceMappingURL=useDirection.js.map
|
8
8
|
//# sourceMappingURL=useDirection.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/
|
1
|
+
{"version":3,"sources":["../../src/constants.ts","../../src/direction/useDirection.tsx"],"names":["ADDON_ID","EVENTS","useDirection","initialDirection","direction","setDirection","useState","useEffect","channel","addons","callback","value"],"mappings":";;;AAAaA,IAAAA,CAAAA,CAAW,4BAKXC,EAAS,CACpB,iBAAA,CAAmB,GAAGD,CAAQ,CAAA,gBAAA,CAAA,CAC9B,iBAAkB,CAAGA,EAAAA,CAAQ,CAC7B,gBAAA,CAAA,CAAA,SAAA,CAAW,CAAGA,EAAAA,CAAQ,WACxB,ECFO,IAAME,CAAe,CAAA,CAACC,CAAkC,CAAA,KAAA,GAAU,CACvE,GAAM,CAACC,CAAWC,CAAAA,CAAY,CAAIC,CAAAA,QAAAA,CAASH,EAAiB,WAAY,EAAC,EAEzE,OAAAI,SAAAA,CAAU,IAAM,CACd,QAAA,CAAS,eAAgB,CAAA,GAAA,CAAMH,EACjC,CAAA,CAAG,CAACA,CAAS,CAAC,EAEdG,SAAU,CAAA,IAAM,CACd,IAAMC,CAAAA,CAAUC,MAAO,CAAA,UAAA,EACjBC,CAAAA,CAAAA,CAAYC,GAAkBN,CAAaM,CAAAA,CAAK,EACtD,OAAAH,CAAAA,CAAQ,GAAGP,CAAO,CAAA,gBAAA,CAAkBS,CAAQ,CAAA,CACrC,IAAM,CACXF,EAAQ,cAAeP,CAAAA,CAAAA,CAAO,gBAAkBS,CAAAA,CAAQ,EAC1D,CACF,EAAG,CAACL,CAAY,CAAC,CAAA,CAEVD,CACT","file":"useDirection.js","sourcesContent":["export const ADDON_ID = '@saas-ui/storybook-addon2'\nexport const COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`\nexport const DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`\nexport const THEME_TOOL_ID = `${ADDON_ID}/theme-tool`\n\nexport const EVENTS = {\n TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,\n TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,\n SET_THEME: `${ADDON_ID}/setTheme`,\n}\n","import { useEffect, useState } from 'react'\nimport { addons } from '@storybook/preview-api'\nimport { EVENTS } from '../constants'\n\n/**\n * Sync the layout direction to the html element\n */\nexport const useDirection = (initialDirection: 'ltr' | 'rtl' = 'ltr') => {\n const [direction, setDirection] = useState(initialDirection.toLowerCase())\n\n useEffect(() => {\n document.documentElement.dir = direction\n }, [direction])\n\n useEffect(() => {\n const channel = addons.getChannel()\n const callback = (value: string) => setDirection(value)\n channel.on(EVENTS.TOGGLE_DIRECTION, callback)\n return () => {\n channel.removeListener(EVENTS.TOGGLE_DIRECTION, callback)\n }\n }, [setDirection])\n\n return direction\n}\n"]}
|
package/dist/index.cjs
CHANGED
package/dist/index.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/constants.ts","../src/arg-types.ts"],"names":["ADDON_ID","COLOR_MODE_TOOL_ID","DIRECTION_TOOL_ID","THEME_TOOL_ID","EVENTS","validateColorScheme","value","valueKeys","term","getThemingArgTypes","theme","componentName","_a","_b","_c","_d","component","argTypes","variantOptions","sizeOptions","colorSchemes","key"],"mappings":"
|
1
|
+
{"version":3,"sources":["../src/constants.ts","../src/arg-types.ts"],"names":["ADDON_ID","COLOR_MODE_TOOL_ID","DIRECTION_TOOL_ID","THEME_TOOL_ID","EVENTS","validateColorScheme","value","valueKeys","term","getThemingArgTypes","theme","componentName","_a","_b","_c","_d","component","argTypes","variantOptions","sizeOptions","colorSchemes","key"],"mappings":";;AAAaA,IAAAA,CAAAA,CAAW,4BACXC,CAAqB,CAAA,CAAA,EAAGD,CAAQ,CAChCE,gBAAAA,CAAAA,CAAAA,CAAAA,CAAoB,GAAGF,CAAQ,CAAA,eAAA,CAAA,CAC/BG,EAAgB,CAA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AA,CAAAG,EAAU,YAAV,GAAA,IAAA,CAAA,KAAA,CAAA,CAAAH,EAAwB,IACxC,CAAA,CAAA,CAAA,CAGEC,CAAAE,CAAAA,CAAAA,CAAU,YAAV,GAAA,IAAA,EAAAF,EAAyB,WAAgB,CAAA,CAC3C,IAAMM,CAAe,CAAA,MAAA,CAAO,QAAQV,CAAM,CAAA,MAAM,EAC7C,MAAO,CAAA,CAAC,EAAGJ,CAAK,IAAMD,CAAoBC,CAAAA,CAAK,CAAC,CAChD,CAAA,GAAA,CAAI,CAAC,CAACe,CAAG,CAAA,GAAMA,CAAG,CAEjBD,CAAAA,CAAAA,CAAa,SACfH,CAAS,CAAA,WAAA,CAAc,CACrB,IAAM,CAAA,CAAE,IAAM,CAAA,MAAA,CAAQ,KAAOG,CAAAA,CAAa,EAC1C,YAAcL,CAAAA,CAAAA,CAAAA,CAAAC,EAAU,YAAV,GAAA,IAAA,CAAA,KAAA,CAAA,CAAAD,EAAwB,WACxC,CAAA,EAEJ,CAEA,OAAOE,CACT","file":"index.cjs","sourcesContent":["export const ADDON_ID = '@saas-ui/storybook-addon2'\nexport const COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`\nexport const DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`\nexport const THEME_TOOL_ID = `${ADDON_ID}/theme-tool`\n\nexport const EVENTS = {\n TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,\n TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,\n SET_THEME: `${ADDON_ID}/setTheme`,\n}\n","import type { ArgTypes } from '@storybook/react'\nimport type { ThemingProps } from '@chakra-ui/react'\n\n/**\n * `keyof` alternative which omits non-string keys\n */\ntype KeyOf<T> = [T] extends [never]\n ? never\n : T extends object\n ? Extract<keyof T, string>\n : never\n\nexport type ThemingArgTypeKey = 'variant' | 'size' | 'colorScheme'\n\n/**\n * Checks if the given color scale object has all required keys: 50, 100, 200...900.\n */\nfunction validateColorScheme(value: object) {\n const valueKeys = Object.keys(value || {})\n return [\n '50',\n '100',\n '200',\n '300',\n '400',\n '500',\n '600',\n '700',\n '800',\n '900',\n ].every((term) => valueKeys.includes(term))\n}\n\n/**\n * Create Storybook controls based on a Chakra UI theme component.\n *\n * @example\n * export default {\n * title: \"Components / Forms / Button\",\n * argTypes: getThemingArgTypes(theme, \"Button\"),\n * }\n *\n * @example full example\n * import { Meta, StoryFn } from \"@storybook/react\"\n * import { getThemingArgTypes } from \"@chakra-ui/storybook-addon\"\n * import { theme } from \"<your-theme>\"\n *\n * export default {\n * title: \"Components / Forms / Button\",\n * argTypes: {\n * ...getThemingArgTypes(theme, \"Button\"),\n * children: \"string\"\n * },\n * args: { children: \"Button\" },\n * } as Meta\n *\n * interface StoryProps extends ThemingProps<\"Button\"> {\n * children?: React.ReactNode\n * }\n *\n * export const Basic: StoryFn<StoryProps> = (props) => <Button {...props} />\n *\n * @param theme same Chakra UI theme used in .storybook/preview.tsx\n * @param componentName component name to create the ArgTypes for\n */\nexport function getThemingArgTypes<\n Theme extends {\n colors: Record<string, any>\n components: Record<string, any>\n },\n ComponentName extends KeyOf<Theme['components']>\n>(theme: Theme, componentName: ComponentName) {\n const component = theme.components[componentName]\n if (!component) {\n return undefined\n }\n\n const argTypes: ArgTypes<\n Partial<Pick<ThemingProps<ComponentName>, ThemingArgTypeKey>>\n > = {}\n\n const variantOptions = Object.keys(component.variants || {})\n if (variantOptions.length) {\n argTypes.variant = {\n type: { name: 'enum', value: variantOptions },\n defaultValue: component.defaultProps?.variant,\n }\n }\n\n const sizeOptions = Object.keys(component.sizes || {})\n if (sizeOptions.length) {\n argTypes.size = {\n type: { name: 'enum', value: sizeOptions },\n defaultValue: component.defaultProps?.size,\n }\n }\n\n if (component.defaultProps?.['colorScheme']) {\n const colorSchemes = Object.entries(theme.colors)\n .filter(([, value]) => validateColorScheme(value))\n .map(([key]) => key)\n\n if (colorSchemes.length) {\n argTypes.colorScheme = {\n type: { name: 'enum', value: colorSchemes },\n defaultValue: component.defaultProps?.colorScheme,\n }\n }\n }\n\n return argTypes\n}\n"]}
|
package/dist/index.d.cts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
export { ADDON_ID, COLOR_MODE_TOOL_ID, DIRECTION_TOOL_ID, EVENTS, THEME_TOOL_ID } from './constants.cjs';
|
2
2
|
export { ThemingArgTypeKey, getThemingArgTypes } from './arg-types.cjs';
|
3
|
-
import '
|
3
|
+
import 'storybook/internal/types';
|
4
4
|
import '@chakra-ui/react';
|
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
export { ADDON_ID, COLOR_MODE_TOOL_ID, DIRECTION_TOOL_ID, EVENTS, THEME_TOOL_ID } from './constants.js';
|
2
2
|
export { ThemingArgTypeKey, getThemingArgTypes } from './arg-types.js';
|
3
|
-
import '
|
3
|
+
import 'storybook/internal/types';
|
4
4
|
import '@chakra-ui/react';
|
package/dist/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
var o="@saas-ui/storybook-addon2",u=`${o}/color-mode-tool`,O=`${o}/direction-tool`,f=`${o}/theme-tool`,d={TOGGLE_COLOR_MODE:`${o}/toggleColorMode`,TOGGLE_DIRECTION:`${o}/toggleDirection`,SET_THEME:`${o}/setTheme`};function y(t){let r=Object.keys(t||{});return ["50","100","200","300","400","500","600","700","800","900"].every(e=>r.includes(e))}function h(t,r){var i,p,m,l;let e=t.components[r];if(!e)return;let n={},c=Object.keys(e.variants||{});c.length&&(n.variant={type:{name:"enum",value:c},defaultValue:(i=e.defaultProps)==null?void 0:i.variant});let a=Object.keys(e.sizes||{});if(a.length&&(n.size={type:{name:"enum",value:a},defaultValue:(p=e.defaultProps)==null?void 0:p.size}),(m=e.defaultProps)!=null&&m.colorScheme){let T=Object.entries(t.colors).filter(([,s])=>y(s)).map(([s])=>s);T.length&&(n.colorScheme={type:{name:"enum",value:T},defaultValue:(l=e.defaultProps)==null?void 0:l.colorScheme});}return n}
|
2
2
|
|
3
3
|
export { o as ADDON_ID, u as COLOR_MODE_TOOL_ID, O as DIRECTION_TOOL_ID, d as EVENTS, f as THEME_TOOL_ID, h as getThemingArgTypes };
|
4
|
-
//# sourceMappingURL=
|
4
|
+
//# sourceMappingURL=index.js.map
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/constants.ts","../src/arg-types.ts"],"names":["ADDON_ID","COLOR_MODE_TOOL_ID","DIRECTION_TOOL_ID","THEME_TOOL_ID","EVENTS","validateColorScheme","value","valueKeys","term","getThemingArgTypes","theme","componentName","_a","_b","_c","_d","component","argTypes","variantOptions","sizeOptions","colorSchemes","key"],"mappings":"
|
1
|
+
{"version":3,"sources":["../src/constants.ts","../src/arg-types.ts"],"names":["ADDON_ID","COLOR_MODE_TOOL_ID","DIRECTION_TOOL_ID","THEME_TOOL_ID","EVENTS","validateColorScheme","value","valueKeys","term","getThemingArgTypes","theme","componentName","_a","_b","_c","_d","component","argTypes","variantOptions","sizeOptions","colorSchemes","key"],"mappings":"AAAaA,IAAAA,CAAAA,CAAW,4BACXC,CAAqB,CAAA,CAAA,EAAGD,CAAQ,CAChCE,gBAAAA,CAAAA,CAAAA,CAAAA,CAAoB,GAAGF,CAAQ,CAAA,eAAA,CAAA,CAC/BG,EAAgB,CAAGH,EAAAA,CAAQ,cAE3BI,CAAS,CAAA,CACpB,kBAAmB,CAAGJ,EAAAA,CAAQ,CAC9B,gBAAA,CAAA,CAAA,gBAAA,CAAkB,CAAGA,EAAAA,CAAQ,mBAC7B,SAAW,CAAA,CAAA,EAAGA,CAAQ,CACxB,SAAA,CAAA,ECQA,SAASK,CAAoBC,CAAAA,CAAAA,CAAe,CAC1C,IAAMC,CAAAA,CAAY,OAAO,IAAKD,CAAAA,CAAAA,EAAS,EAAE,CAAA,CACzC,OAAO,CACL,IAAA,CACA,KACA,CAAA,KAAA,CACA,KACA,CAAA,KAAA,CACA,MACA,KACA,CAAA,KA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SACfH,CAAS,CAAA,WAAA,CAAc,CACrB,IAAM,CAAA,CAAE,IAAM,CAAA,MAAA,CAAQ,KAAOG,CAAAA,CAAa,EAC1C,YAAcL,CAAAA,CAAAA,CAAAA,CAAAC,EAAU,YAAV,GAAA,IAAA,CAAA,KAAA,CAAA,CAAAD,EAAwB,WACxC,CAAA,EAEJ,CAEA,OAAOE,CACT","file":"index.js","sourcesContent":["export const ADDON_ID = '@saas-ui/storybook-addon2'\nexport const COLOR_MODE_TOOL_ID = `${ADDON_ID}/color-mode-tool`\nexport const DIRECTION_TOOL_ID = `${ADDON_ID}/direction-tool`\nexport const THEME_TOOL_ID = `${ADDON_ID}/theme-tool`\n\nexport const EVENTS = {\n TOGGLE_COLOR_MODE: `${ADDON_ID}/toggleColorMode`,\n TOGGLE_DIRECTION: `${ADDON_ID}/toggleDirection`,\n SET_THEME: `${ADDON_ID}/setTheme`,\n}\n","import type { ArgTypes } from '@storybook/react'\nimport type { ThemingProps } from '@chakra-ui/react'\n\n/**\n * `keyof` alternative which omits non-string keys\n */\ntype KeyOf<T> = [T] extends [never]\n ? never\n : T extends object\n ? Extract<keyof T, string>\n : never\n\nexport type ThemingArgTypeKey = 'variant' | 'size' | 'colorScheme'\n\n/**\n * Checks if the given color scale object has all required keys: 50, 100, 200...900.\n */\nfunction validateColorScheme(value: object) {\n const valueKeys = Object.keys(value || {})\n return [\n '50',\n '100',\n '200',\n '300',\n '400',\n '500',\n '600',\n '700',\n '800',\n '900',\n ].every((term) => valueKeys.includes(term))\n}\n\n/**\n * Create Storybook controls based on a Chakra UI theme component.\n *\n * @example\n * export default {\n * title: \"Components / Forms / Button\",\n * argTypes: getThemingArgTypes(theme, \"Button\"),\n * }\n *\n * @example full example\n * import { Meta, StoryFn } from \"@storybook/react\"\n * import { getThemingArgTypes } from \"@chakra-ui/storybook-addon\"\n * import { theme } from \"<your-theme>\"\n *\n * export default {\n * title: \"Components / Forms / Button\",\n * argTypes: {\n * ...getThemingArgTypes(theme, \"Button\"),\n * children: \"string\"\n * },\n * args: { children: \"Button\" },\n * } as Meta\n *\n * interface StoryProps extends ThemingProps<\"Button\"> {\n * children?: React.ReactNode\n * }\n *\n * export const Basic: StoryFn<StoryProps> = (props) => <Button {...props} />\n *\n * @param theme same Chakra UI theme used in .storybook/preview.tsx\n * @param componentName component name to create the ArgTypes for\n */\nexport function getThemingArgTypes<\n Theme extends {\n colors: Record<string, any>\n components: Record<string, any>\n },\n ComponentName extends KeyOf<Theme['components']>\n>(theme: Theme, componentName: ComponentName) {\n const component = theme.components[componentName]\n if (!component) {\n return undefined\n }\n\n const argTypes: ArgTypes<\n Partial<Pick<ThemingProps<ComponentName>, ThemingArgTypeKey>>\n > = {}\n\n const variantOptions = Object.keys(component.variants || {})\n if (variantOptions.length) {\n argTypes.variant = {\n type: { name: 'enum', value: variantOptions },\n defaultValue: component.defaultProps?.variant,\n }\n }\n\n const sizeOptions = Object.keys(component.sizes || {})\n if (sizeOptions.length) {\n argTypes.size = {\n type: { name: 'enum', value: sizeOptions },\n defaultValue: component.defaultProps?.size,\n }\n }\n\n if (component.defaultProps?.['colorScheme']) {\n const colorSchemes = Object.entries(theme.colors)\n .filter(([, value]) => validateColorScheme(value))\n .map(([key]) => key)\n\n if (colorSchemes.length) {\n argTypes.colorScheme = {\n type: { name: 'enum', value: colorSchemes },\n defaultValue: component.defaultProps?.colorScheme,\n }\n }\n }\n\n return argTypes\n}\n"]}
|