@saas-ui/storybook-addon 3.0.2 → 4.0.0-alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +22 -0
- package/dist/ChakraProviderDecorator.d.ts +3 -1
- package/dist/ChakraProviderDecorator.js +47 -8
- package/dist/ChakraProviderDecorator.js.map +1 -1
- package/dist/ChakraProviderDecorator.mjs +30 -0
- package/dist/ChakraProviderDecorator.mjs.map +1 -0
- package/dist/arg-types.d.ts +1 -1
- package/dist/arg-types.js +3 -1
- package/dist/arg-types.js.map +1 -1
- package/dist/{arg-types.cjs → arg-types.mjs} +2 -4
- package/dist/arg-types.mjs.map +1 -0
- package/dist/color-mode/ColorModeSync.js +7 -5
- package/dist/color-mode/ColorModeSync.js.map +1 -1
- package/dist/color-mode/ColorModeSync.mjs +9 -0
- package/dist/color-mode/ColorModeSync.mjs.map +1 -0
- package/dist/color-mode/ColorModeTool.js +28 -6
- package/dist/color-mode/ColorModeTool.js.map +1 -1
- package/dist/color-mode/ColorModeTool.mjs +10 -0
- package/dist/color-mode/ColorModeTool.mjs.map +1 -0
- package/dist/constants.js +7 -1
- package/dist/constants.js.map +1 -1
- package/dist/{constants.cjs → constants.mjs} +2 -8
- package/dist/constants.mjs.map +1 -0
- package/dist/direction/DirectionTool.js +8 -6
- package/dist/direction/DirectionTool.js.map +1 -1
- package/dist/direction/DirectionTool.mjs +10 -0
- package/dist/direction/DirectionTool.mjs.map +1 -0
- package/dist/direction/useDirection.js +6 -4
- package/dist/direction/useDirection.js.map +1 -1
- package/dist/direction/useDirection.mjs +8 -0
- package/dist/direction/useDirection.mjs.map +1 -0
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/{index.cjs → index.mjs} +2 -9
- package/dist/index.mjs.map +1 -0
- package/dist/manager.d.ts +1 -1
- package/dist/manager.js +31 -8
- package/dist/manager.js.map +1 -1
- package/dist/manager.mjs +12 -0
- package/dist/manager.mjs.map +1 -0
- package/dist/preview.js +47 -8
- package/dist/preview.js.map +1 -1
- package/dist/preview.mjs +30 -0
- package/dist/preview.mjs.map +1 -0
- package/dist/theme/ThemeTool.js +29 -6
- package/dist/theme/ThemeTool.js.map +1 -1
- package/dist/theme/ThemeTool.mjs +12 -0
- package/dist/theme/ThemeTool.mjs.map +1 -0
- package/package.json +12 -13
- package/dist/ChakraProviderDecorator.cjs +0 -33
- package/dist/ChakraProviderDecorator.cjs.map +0 -1
- package/dist/ChakraProviderDecorator.d.cts +0 -3
- package/dist/arg-types.cjs.map +0 -1
- package/dist/arg-types.d.cts +0 -52
- package/dist/color-mode/ColorModeSync.cjs +0 -11
- package/dist/color-mode/ColorModeSync.cjs.map +0 -1
- package/dist/color-mode/ColorModeSync.d.cts +0 -6
- package/dist/color-mode/ColorModeTool.cjs +0 -32
- package/dist/color-mode/ColorModeTool.cjs.map +0 -1
- package/dist/color-mode/ColorModeTool.d.cts +0 -5
- package/dist/constants.cjs.map +0 -1
- package/dist/constants.d.cts +0 -11
- package/dist/direction/DirectionTool.cjs +0 -12
- package/dist/direction/DirectionTool.cjs.map +0 -1
- package/dist/direction/DirectionTool.d.cts +0 -8
- package/dist/direction/useDirection.cjs +0 -10
- package/dist/direction/useDirection.cjs.map +0 -1
- package/dist/direction/useDirection.d.cts +0 -6
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -4
- package/dist/manager.cjs +0 -31
- package/dist/manager.cjs.map +0 -1
- package/dist/manager.d.cts +0 -2
- package/dist/preview.cjs +0 -33
- package/dist/preview.cjs.map +0 -1
- package/dist/preview.d.cts +0 -5
- package/dist/theme/ThemeTool.cjs +0 -12
- package/dist/theme/ThemeTool.cjs.map +0 -1
- package/dist/theme/ThemeTool.d.cts +0 -8
package/dist/manager.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/manager.ts","../src/constants.ts","../src/color-mode/ColorModeTool.tsx","../src/direction/DirectionTool.tsx","../src/theme/ThemeTool.tsx"],"names":["addons","types","ADDON_ID","COLOR_MODE_TOOL_ID","DIRECTION_TOOL_ID","THEME_TOOL_ID","EVENTS","React","IconButton","jsx","jsxs","MoonIcon","SunIcon","ColorModeTool","isDarkMode","darkMode","setDarkMode","channel","prev","useCallback","useEffect","useAddonState","useGlobals","LTRIcon","props","RTLIcon","DirectionTool","globals","setGlobals","direction","setDirection","targetDirection","toggleDirection","WithTooltip","TooltipLinkList","Icons","themes","ThemeTool","themeId","theme","setTheme","setActiveTheme","onHide","api","match","viewMode"],"mappings":"AAAA,OAAS,UAAAA,EAAQ,SAAAC,MAAa,yBCAvB,IAAMC,EAAW,4BACXC,EAAqB,GAAGD,CAAQ,mBAChCE,EAAoB,GAAGF,CAAQ,kBAC/BG,EAAgB,GAAGH,CAAQ,cAE3BI,EAAS,CACpB,kBAAmB,GAAGJ,CAAQ,mBAC9B,iBAAkB,GAAGA,CAAQ,mBAC7B,UAAW,GAAGA,CAAQ,WACxB,ECTA,UAAYK,MAAW,QACvB,OAAS,cAAAC,MAAkB,wBAC3B,OAAS,UAAAR,MAAc,yBAMnB,cAAAS,EASA,QAAAC,MATA,oBAFJ,IAAMC,EAAW,IACfF,EAAC,OAAI,QAAQ,YAAY,UAAU,QACjC,SAAAA,EAAC,QACC,KAAK,eACL,EAAE,qOACH,EACH,EAGIG,EAAU,IACdH,EAAC,OAAI,QAAQ,YAAY,UAAU,QACjC,SAAAC,EAAC,KACC,eAAe,QACf,cAAc,QACd,YAAY,IACZ,KAAK,OACL,OAAO,eAEP,UAAAD,EAAC,UAAO,GAAG,KAAK,GAAG,KAAK,EAAE,IAAI,EAC9BA,EAAC,QAAK,EAAE,UAAU,EAClBA,EAAC,QAAK,EAAE,WAAW,EACnBA,EAAC,QAAK,EAAE,uBAAuB,EAC/BA,EAAC,QAAK,EAAE,yBAAyB,EACjCA,EAAC,QAAK,EAAE,UAAU,EAClBA,EAAC,QAAK,EAAE,WAAW,EACnBA,EAAC,QAAK,EAAE,wBAAwB,EAChCA,EAAC,QAAK,EAAE,wBAAwB,GAClC,EACF,EAGW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AS,IAAM,CACbD,EAAe,GAAG,EAClBC,EAAO,CACT,CACF,CACF,EACF,EAGF,SAAAhC,EAACF,EAAA,CAAW,MAAM,eAChB,UAAAC,EAAC0B,EAAA,CAAM,KAAK,MAAM,EAAE,IAAEC,EAAOG,GAAS,GAAG,GAC3C,EACF,CAEJ,EJ5DA,QAAQ,IAAI,UAAU,EAEtBvC,EAAO,SAASE,EAAWyC,GAAQ,CACjC,QAAQ,IAAI,UAAU,EAEtB,IAAMC,EAAQ,CAAC,CAAE,SAAAC,CAAS,IACxB,GAAQA,GAAYA,EAAS,MAAM,gBAAgB,GAErD7C,EAAO,IAAII,EAAmB,CAC5B,KAAMH,EAAM,KACZ,MAAO,YACP,OAAQyB,EACR,MAAAkB,CACF,CAAC,EAED5C,EAAO,IAAIG,EAAoB,CAC7B,KAAMF,EAAM,KACZ,MAAO,aACP,OAAQY,EACR,MAAA+B,CACF,CAAC,EAED5C,EAAO,IAAIK,EAAe,CACxB,KAAMJ,EAAM,KACZ,MAAO,QACP,OAAQoC,EACR,MAAAO,CACF,CAAC,CACH,CAAC","sourcesContent":["import { addons, types } from '@storybook/manager-api'\nimport {\n ADDON_ID,\n COLOR_MODE_TOOL_ID,\n DIRECTION_TOOL_ID,\n THEME_TOOL_ID,\n} from './constants'\nimport { ColorModeTool } from './color-mode/ColorModeTool'\nimport { DirectionTool } from './direction/DirectionTool'\nimport { ThemeTool } from './theme/ThemeTool'\n\nconsole.log('REGISTER')\n\naddons.register(ADDON_ID, (api) => {\n console.log('REGISTER')\n\n const match = ({ viewMode }: { viewMode?: string }) =>\n Boolean(viewMode && viewMode.match(/^(story|docs)$/))\n\n addons.add(DIRECTION_TOOL_ID, {\n type: types.TOOL,\n title: 'Direction',\n render: DirectionTool,\n match,\n })\n\n addons.add(COLOR_MODE_TOOL_ID, {\n type: types.TOOL,\n title: 'Color Mode',\n render: ColorModeTool,\n match,\n })\n\n addons.add(THEME_TOOL_ID, {\n type: types.TOOL,\n title: 'Theme',\n render: ThemeTool,\n match,\n })\n})\n","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","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","import {\n IconButton,\n WithTooltip,\n TooltipLinkList,\n Icons,\n} from '@storybook/components'\nimport { ADDON_ID, EVENTS } from '../constants'\nimport { addons } from '@storybook/preview-api'\nimport { useAddonState } from '@storybook/manager-api'\n\nconst themes: Record<string, string> = {\n 0: 'Chakra UI',\n 1: 'Saas UI',\n 2: 'Glass',\n}\n\n/**\n * This component is rendered in the Storybook toolbar\n */\nexport const ThemeTool = () => {\n const themeId = localStorage.getItem('saas-ui-theme')\n const [theme, setTheme] = useAddonState(`${ADDON_ID}/theme`, themeId)\n\n const channel = addons.getChannel()\n\n const setActiveTheme = (themeId: string) => {\n channel.emit(EVENTS.SET_THEME, !themeId ? '1' : themeId)\n setTheme(themeId)\n }\n\n return (\n <WithTooltip\n placement=\"top\"\n closeOnOutsideClick\n trigger=\"click\"\n tooltip={({ onHide }) => (\n <TooltipLinkList\n links={[\n {\n id: '0',\n title: 'Chakra UI',\n onClick: () => {\n setActiveTheme('0')\n onHide()\n },\n },\n {\n id: '1',\n title: 'Saas UI',\n onClick: () => {\n setActiveTheme('1')\n onHide()\n },\n },\n {\n id: '2',\n title: 'Glass',\n onClick: () => {\n setActiveTheme('2')\n onHide()\n },\n },\n ]}\n />\n )}\n >\n <IconButton title=\"Select theme\">\n <Icons icon=\"eye\" /> {themes[theme || '1']}\n </IconButton>\n </WithTooltip>\n )\n}\n"]}
|
1
|
+
{"version":3,"sources":["../src/manager.ts","../src/constants.ts","../src/color-mode/ColorModeTool.tsx","../src/direction/DirectionTool.tsx","../../../node_modules/@storybook/api/dist/entry.mjs","../src/theme/ThemeTool.tsx","../../../node_modules/@storybook/addons/dist/index.mjs"],"names":["addons","types","ADDON_ID","COLOR_MODE_TOOL_ID","DIRECTION_TOOL_ID","THEME_TOOL_ID","EVENTS","React","IconButton","jsx","jsxs","MoonIcon","SunIcon","ColorModeTool","isDarkMode","darkMode","setDarkMode","channel","prev","useCallback","useEffect","useAddonState","useGlobals","LTRIcon","props","__spreadProps","__spreadValues","RTLIcon","DirectionTool","globals","setGlobals","direction","setDirection","targetDirection","toggleDirection","entry_exports","__reExport","manager_api_star","WithTooltip","TooltipLinkList","Icons","Addon_TypesEnum","mockChannel","HooksContext","applyHooks","makeDecorator","useArgs","useChannel","useMemo","useParameter","useReducer","useRef","useState","useStoryContext","themes","ThemeTool","themeId","theme","setTheme","setActiveTheme","onHide","match","viewMode"],"mappings":"msBAAA,OAAS,UAAAA,EAAQ,SAAAC,MAAa,yBCAvB,IAAMC,EAAW,4BACXC,EAAqB,GAAGD,oBACxBE,EAAoB,GAAGF,mBACvBG,EAAgB,GAAGH,eAEnBI,EAAS,CACpB,kBAAmB,GAAGJ,oBACtB,iBAAkB,GAAGA,oBACrB,UAAW,GAAGA,YAChB,ECTA,UAAYK,MAAW,QACvB,OAAS,cAAAC,MAAkB,wBAC3B,OAAS,UAAAR,MAAc,yBAMnB,cAAAS,EASA,QAAAC,MATA,oBAFJ,IAAMC,EAAW,IACfF,EAAC,OAAI,QAAQ,YAAY,UAAU,QACjC,SAAAA,EAAC,QACC,KAAK,eACL,EAAE,qOACH,EACH,EAGIG,EAAU,IACdH,EAAC,OAAI,QAAQ,YAAY,UAAU,QACjC,SAAAC,EAAC,KACC,eAAe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AAe,CACxB,KAAMJ,EAAM,KACZ,MAAO,QACP,OAAQsD,EACR,MAAAM,CACF,CAAC,CACH,CAAC","sourcesContent":["import { addons, types } from '@storybook/manager-api'\nimport {\n ADDON_ID,\n COLOR_MODE_TOOL_ID,\n DIRECTION_TOOL_ID,\n THEME_TOOL_ID,\n} from './constants'\nimport { ColorModeTool } from './color-mode/ColorModeTool'\nimport { DirectionTool } from './direction/DirectionTool'\nimport { ThemeTool } from './theme/ThemeTool'\n\naddons.register(ADDON_ID, () => {\n const match = ({ viewMode }: { viewMode?: string }) =>\n Boolean(viewMode && viewMode.match(/^(story|docs)$/))\n\n addons.add(DIRECTION_TOOL_ID, {\n type: types.TOOL,\n title: 'Direction',\n render: DirectionTool,\n match,\n })\n\n addons.add(COLOR_MODE_TOOL_ID, {\n type: types.TOOL,\n title: 'Color Mode',\n render: ColorModeTool,\n match,\n })\n\n addons.add(THEME_TOOL_ID, {\n type: types.TOOL,\n title: 'Theme',\n render: ThemeTool,\n match,\n })\n})\n","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","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","// shim-mmode\nexport * from '@storybook/manager-api';","import { useAddonState } from '@storybook/api'\nimport {\n IconButton,\n WithTooltip,\n TooltipLinkList,\n Icons,\n} from '@storybook/components'\nimport { addons } from '@storybook/addons'\nimport { ADDON_ID, EVENTS } from '../constants'\n\nconst themes: Record<string, string> = {\n 0: 'Chakra UI',\n 1: 'Saas UI',\n 2: 'Glass',\n}\n\n/**\n * This component is rendered in the Storybook toolbar\n */\nexport const ThemeTool = () => {\n const themeId = localStorage.getItem('saas-ui-theme')\n const [theme, setTheme] = useAddonState(`${ADDON_ID}/theme`, themeId)\n\n const channel = addons.getChannel()\n\n const setActiveTheme = (themeId: string) => {\n channel.emit(EVENTS.SET_THEME, !themeId ? '1' : themeId)\n setTheme(themeId)\n }\n\n return (\n <WithTooltip\n placement=\"top\"\n closeOnClick\n trigger=\"click\"\n tooltip={({ onHide }) => (\n <TooltipLinkList\n links={[\n {\n id: '0',\n title: 'Chakra UI',\n onClick: () => {\n setActiveTheme('0')\n onHide()\n },\n },\n {\n id: '1',\n title: 'Saas UI',\n onClick: () => {\n setActiveTheme('1')\n onHide()\n },\n },\n {\n id: '2',\n title: 'Glass',\n onClick: () => {\n setActiveTheme('2')\n onHide()\n },\n },\n ]}\n />\n )}\n >\n <IconButton title=\"Select theme\">\n <Icons icon=\"eye\" /> {themes[theme || '1']}\n </IconButton>\n </WithTooltip>\n )\n}\n","export { Addon_TypesEnum as types } from '@storybook/types';\nexport { addons, mockChannel } from '@storybook/manager-api';\nexport { HooksContext, applyHooks, makeDecorator, useArgs, useCallback, useChannel, useEffect, useGlobals, useMemo, useParameter, useReducer, useRef, useState, useStoryContext } from '@storybook/preview-api/dist/addons';\n"]}
|
package/dist/manager.mjs
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
import * as Co from '@storybook/manager-api';
|
2
|
+
import { addons, types, useGlobals, useAddonState } from '@storybook/manager-api';
|
3
|
+
import * as M from 'react';
|
4
|
+
import { useEffect, useCallback } from 'react';
|
5
|
+
import { IconButton, WithTooltip, TooltipLinkList, Icons } from '@storybook/components';
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
7
|
+
import '@storybook/types';
|
8
|
+
import '@storybook/preview-api/dist/addons';
|
9
|
+
|
10
|
+
var E=Object.defineProperty,V=Object.defineProperties,x=Object.getOwnPropertyDescriptor,y=Object.getOwnPropertyDescriptors,N=Object.getOwnPropertyNames,C=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var u=(t,o,e)=>o in t?E(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,p=(t,o)=>{for(var e in o||(o={}))I.call(o,e)&&u(t,e,o[e]);if(C)for(var e of C(o))B.call(o,e)&&u(t,e,o[e]);return t},T=(t,o)=>V(t,y(o));var f=(t,o,e,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of N(o))!I.call(t,r)&&r!==e&&E(t,r,{get:()=>o[r],enumerable:!(c=x(o,r))||c.enumerable});return t},D=(t,o,e)=>(f(t,o,"default"),e&&f(e,o,"default"));var s="@saas-ui/storybook-addon2",k=`${s}/color-mode-tool`,i=`${s}/direction-tool`,v=`${s}/theme-tool`,h={TOGGLE_COLOR_MODE:`${s}/toggleColorMode`,TOGGLE_DIRECTION:`${s}/toggleDirection`,SET_THEME:`${s}/setTheme`};var H=()=>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"})}),A=()=>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"})]})}),_=()=>{let t=localStorage.getItem("chakra-ui-color-mode")==="dark",[o,e]=M.useState(t),c=addons.getChannel();return jsx(IconButton,{title:`Set color mode to ${o?"light":"dark"}`,active:o,onClick:()=>{c.emit(h.TOGGLE_COLOR_MODE,o?"light":"dark"),e(l=>!l);},children:o?jsx(A,{}):jsx(H,{})})};var J=t=>jsxs("svg",T(p({stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",height:"1em",width:"1em",style:{transform:"scale(1.2)"}},t),{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"})]})),K=t=>jsxs("svg",T(p({stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",height:"1em",width:"1em",style:{transform:"scale(1.2)"}},t),{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"})]})),S=()=>{let[t,o]=useGlobals(),[e,c]=useAddonState(i,t[i]||"ltr"),r=e!=="ltr"?"ltr":"rtl";useEffect(()=>{o({[i]:e});},[e,o]);let l=useCallback(()=>{addons.getChannel().emit(h.TOGGLE_DIRECTION,r),c(r);},[c,r]);return jsx(IconButton,{active:e==="rtl",title:`Set layout direction to ${r}`,onClick:l,children:r==="ltr"?jsx(J,{}):jsx(K,{})})};var m={};D(m,Co);var j={0:"Chakra UI",1:"Saas UI",2:"Glass"},R=()=>{let t=localStorage.getItem("saas-ui-theme"),[o,e]=(0, m.useAddonState)(`${s}/theme`,t),c=addons.getChannel(),r=l=>{c.emit(h.SET_THEME,l||"1"),e(l);};return jsx(WithTooltip,{placement:"top",closeOnClick:!0,trigger:"click",tooltip:({onHide:l})=>jsx(TooltipLinkList,{links:[{id:"0",title:"Chakra UI",onClick:()=>{r("0"),l();}},{id:"1",title:"Saas UI",onClick:()=>{r("1"),l();}},{id:"2",title:"Glass",onClick:()=>{r("2"),l();}}]}),children:jsxs(IconButton,{title:"Select theme",children:[jsx(Icons,{icon:"eye"})," ",j[o||"1"]]})})};addons.register(s,()=>{let t=({viewMode:o})=>!!(o&&o.match(/^(story|docs)$/));addons.add(i,{type:types.TOOL,title:"Direction",render:S,match:t}),addons.add(k,{type:types.TOOL,title:"Color Mode",render:_,match:t}),addons.add(v,{type:types.TOOL,title:"Theme",render:R,match:t});});
|
11
|
+
//# sourceMappingURL=out.js.map
|
12
|
+
//# sourceMappingURL=manager.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/manager.ts","../src/constants.ts","../src/color-mode/ColorModeTool.tsx","../src/direction/DirectionTool.tsx","../../../node_modules/@storybook/api/dist/entry.mjs","../src/theme/ThemeTool.tsx","../../../node_modules/@storybook/addons/dist/index.mjs"],"names":["addons","types","ADDON_ID","COLOR_MODE_TOOL_ID","DIRECTION_TOOL_ID","THEME_TOOL_ID","EVENTS","React","IconButton","jsx","jsxs","MoonIcon","SunIcon","ColorModeTool","isDarkMode","darkMode","setDarkMode","channel","prev","useCallback","useEffect","useAddonState","useGlobals","LTRIcon","props","__spreadProps","__spreadValues","RTLIcon","DirectionTool","globals","setGlobals","direction","setDirection","targetDirection","toggleDirection","entry_exports","__reExport","manager_api_star","WithTooltip","TooltipLinkList","Icons","Addon_TypesEnum","mockChannel","HooksContext","applyHooks","makeDecorator","useArgs","useChannel","useMemo","useParameter","useReducer","useRef","useState","useStoryContext","themes","ThemeTool","themeId","theme","setTheme","setActiveTheme","onHide","match","viewMode"],"mappings":"msBAAA,OAAS,UAAAA,EAAQ,SAAAC,MAAa,yBCAvB,IAAMC,EAAW,4BACXC,EAAqB,GAAGD,oBACxBE,EAAoB,GAAGF,mBACvBG,EAAgB,GAAGH,eAEnBI,EAAS,CACpB,kBAAmB,GAAGJ,oBACtB,iBAAkB,GAAGA,oBACrB,UAAW,GAAGA,YAChB,ECTA,UAAYK,MAAW,QACvB,OAAS,cAAAC,MAAkB,wBAC3B,OAAS,UAAAR,MAAc,yBAMnB,cAAAS,EASA,QAAAC,MATA,oBAFJ,IAAMC,EAAW,IACfF,EAAC,OAAI,QAAQ,YAAY,UAAU,QACjC,SAAAA,EAAC,QACC,KAAK,eACL,EAAE,qOACH,EACH,EAGIG,EAAU,IACdH,EAAC,OAAI,QAAQ,YAAY,UAAU,QACjC,SAAAC,EAAC,KACC,eAAe,QACf,cAAc,QACd,YAAY,IACZ,KAAK,OACL,OAAO,eAEP,UAAAD,EAAC,UAAO,GAAG,KAAK,GAAG,KAAK,EAAE,IAAI,EAC9BA,EAAC,QAAK,EAAE,UAAU,EAClBA,EAAC,QAAK,EAAE,WAAW,EACnBA,EAAC,QAAK,EAAE,uBAAuB,EAC/BA,EAAC,QAAK,EAAE,yBAAyB,EACjCA,EAAC,QAAK,EAAE,UAAU,EAClBA,EAAC,QAAK,EAAE,WAAW,EACnBA,EAAC,QAAK,EAAE,wBAAwB,EAChCA,EAAC,QAAK,EAAE,wBAAwB,GAClC,EACF,EAGWI,EAAgB,IAAM,CACjC,IAAMC,EAAa,aAAa,QAAQ,sBAAsB,IAAM,OAE9D,CAACC,EAAUC,CAAW,EAAU,WAASF,CAAU,EAEnDG,EAAUjB,EAAO,WAAW,EAOlC,OACES,EAACD,EAAA,CACC,MAAO,qBAAqBO,EAAW,QAAU,SACjD,OAAQA,EACR,QATiB,IAAM,CACzBE,EAAQ,KAAKX,EAAO,kBA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EAClBC,EAAO,CACT,CACF,EACA,CACE,GAAI,IACJ,MAAO,QACP,QAAS,IAAM,CACbD,EAAe,GAAG,EAClBC,EAAO,CACT,CACF,CACF,EACF,EAGF,SAAAlD,GAACF,EAAA,CAAW,MAAM,eAChB,UAAAC,EAAC+B,EAAA,CAAM,KAAK,MAAM,EAAE,IAAEc,EAAOG,GAAS,GAAG,GAC3C,EACF,CAEJ,EL5DAzD,EAAO,SAASE,EAAU,IAAM,CAC9B,IAAM2D,EAAQ,CAAC,CAAE,SAAAC,CAAS,IACxB,GAAQA,GAAYA,EAAS,MAAM,gBAAgB,GAErD9D,EAAO,IAAII,EAAmB,CAC5B,KAAMH,EAAM,KACZ,MAAO,YACP,OAAQ2B,EACR,MAAAiC,CACF,CAAC,EAED7D,EAAO,IAAIG,EAAoB,CAC7B,KAAMF,EAAM,KACZ,MAAO,aACP,OAAQY,EACR,MAAAgD,CACF,CAAC,EAED7D,EAAO,IAAIK,EAAe,CACxB,KAAMJ,EAAM,KACZ,MAAO,QACP,OAAQsD,EACR,MAAAM,CACF,CAAC,CACH,CAAC","sourcesContent":["import { addons, types } from '@storybook/manager-api'\nimport {\n ADDON_ID,\n COLOR_MODE_TOOL_ID,\n DIRECTION_TOOL_ID,\n THEME_TOOL_ID,\n} from './constants'\nimport { ColorModeTool } from './color-mode/ColorModeTool'\nimport { DirectionTool } from './direction/DirectionTool'\nimport { ThemeTool } from './theme/ThemeTool'\n\naddons.register(ADDON_ID, () => {\n const match = ({ viewMode }: { viewMode?: string }) =>\n Boolean(viewMode && viewMode.match(/^(story|docs)$/))\n\n addons.add(DIRECTION_TOOL_ID, {\n type: types.TOOL,\n title: 'Direction',\n render: DirectionTool,\n match,\n })\n\n addons.add(COLOR_MODE_TOOL_ID, {\n type: types.TOOL,\n title: 'Color Mode',\n render: ColorModeTool,\n match,\n })\n\n addons.add(THEME_TOOL_ID, {\n type: types.TOOL,\n title: 'Theme',\n render: ThemeTool,\n match,\n })\n})\n","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","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","// shim-mmode\nexport * from '@storybook/manager-api';","import { useAddonState } from '@storybook/api'\nimport {\n IconButton,\n WithTooltip,\n TooltipLinkList,\n Icons,\n} from '@storybook/components'\nimport { addons } from '@storybook/addons'\nimport { ADDON_ID, EVENTS } from '../constants'\n\nconst themes: Record<string, string> = {\n 0: 'Chakra UI',\n 1: 'Saas UI',\n 2: 'Glass',\n}\n\n/**\n * This component is rendered in the Storybook toolbar\n */\nexport const ThemeTool = () => {\n const themeId = localStorage.getItem('saas-ui-theme')\n const [theme, setTheme] = useAddonState(`${ADDON_ID}/theme`, themeId)\n\n const channel = addons.getChannel()\n\n const setActiveTheme = (themeId: string) => {\n channel.emit(EVENTS.SET_THEME, !themeId ? '1' : themeId)\n setTheme(themeId)\n }\n\n return (\n <WithTooltip\n placement=\"top\"\n closeOnClick\n trigger=\"click\"\n tooltip={({ onHide }) => (\n <TooltipLinkList\n links={[\n {\n id: '0',\n title: 'Chakra UI',\n onClick: () => {\n setActiveTheme('0')\n onHide()\n },\n },\n {\n id: '1',\n title: 'Saas UI',\n onClick: () => {\n setActiveTheme('1')\n onHide()\n },\n },\n {\n id: '2',\n title: 'Glass',\n onClick: () => {\n setActiveTheme('2')\n onHide()\n },\n },\n ]}\n />\n )}\n >\n <IconButton title=\"Select theme\">\n <Icons icon=\"eye\" /> {themes[theme || '1']}\n </IconButton>\n </WithTooltip>\n )\n}\n","export { Addon_TypesEnum as types } from '@storybook/types';\nexport { addons, mockChannel } from '@storybook/manager-api';\nexport { HooksContext, applyHooks, makeDecorator, useArgs, useCallback, useChannel, useEffect, useGlobals, useMemo, useParameter, useReducer, useRef, useState, useStoryContext } from '@storybook/preview-api/dist/addons';\n"]}
|