From 304e84174d1970c9d17d91e5722d996fa11b3d89 Mon Sep 17 00:00:00 2001 From: Toastie Date: Fri, 18 Oct 2024 23:01:44 +1300 Subject: [PATCH] Added dist files. --- dist/index.d.ts | 3 +++ dist/index.js | 7 +++++++ dist/index.js.map | 1 + dist/index.mjs | 5 +++++ dist/index.mjs.map | 1 + dist/manager.d.ts | 2 ++ dist/manager.js | 13 +++++++++++++ dist/manager.js.map | 1 + dist/manager.mjs | 7 +++++++ dist/manager.mjs.map | 1 + dist/preview.d.ts | 20 ++++++++++++++++++++ dist/preview.js | 9 +++++++++ dist/preview.js.map | 1 + dist/preview.mjs | 7 +++++++ dist/preview.mjs.map | 1 + 15 files changed, 79 insertions(+) create mode 100644 dist/index.d.ts create mode 100644 dist/index.js create mode 100644 dist/index.js.map create mode 100644 dist/index.mjs create mode 100644 dist/index.mjs.map create mode 100644 dist/manager.d.ts create mode 100644 dist/manager.js create mode 100644 dist/manager.js.map create mode 100644 dist/manager.mjs create mode 100644 dist/manager.mjs.map create mode 100644 dist/preview.d.ts create mode 100644 dist/preview.js create mode 100644 dist/preview.js.map create mode 100644 dist/preview.mjs create mode 100644 dist/preview.mjs.map diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..a2e803e --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,3 @@ +declare const _default: {}; + +export { _default as default }; diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..7918a7c --- /dev/null +++ b/dist/index.js @@ -0,0 +1,7 @@ +'use strict'; + +var e={}; + +module.exports = e; +//# sourceMappingURL=out.js.map +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 0000000..d147ee6 --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/index.ts"],"names":["src_default"],"mappings":"AACA,IAAOA,EAAQ,CAAC","sourcesContent":["// make it work with --isolatedModules\nexport default {};"]} \ No newline at end of file diff --git a/dist/index.mjs b/dist/index.mjs new file mode 100644 index 0000000..ce92622 --- /dev/null +++ b/dist/index.mjs @@ -0,0 +1,5 @@ +var e={}; + +export { e as default }; +//# sourceMappingURL=out.js.map +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/dist/index.mjs.map b/dist/index.mjs.map new file mode 100644 index 0000000..d147ee6 --- /dev/null +++ b/dist/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/index.ts"],"names":["src_default"],"mappings":"AACA,IAAOA,EAAQ,CAAC","sourcesContent":["// make it work with --isolatedModules\nexport default {};"]} \ No newline at end of file diff --git a/dist/manager.d.ts b/dist/manager.d.ts new file mode 100644 index 0000000..c9247d4 --- /dev/null +++ b/dist/manager.d.ts @@ -0,0 +1,2 @@ + +export { } diff --git a/dist/manager.js b/dist/manager.js new file mode 100644 index 0000000..42cbf03 --- /dev/null +++ b/dist/manager.js @@ -0,0 +1,13 @@ +'use strict'; + +var managerApi = require('@storybook/manager-api'); +var r = require('react'); +var components = require('@storybook/components'); + +function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } + +var r__default = /*#__PURE__*/_interopDefault(r); + +var o="valkyriecoms/storybook-addon-valkyrie-theme",e=`${o}/tool`,i="valkyrieTheme";var n=r.memo(function(){let [a,p]=r.useState(!1),[s,m]=managerApi.useGlobals();managerApi.useStorybookApi();let d=!!s[i];return r__default.default.createElement(components.WithTooltip,{placement:"top",closeOnOutsideClick:!0,tooltip:({onHide:u})=>r__default.default.createElement(components.TooltipLinkList,{links:["(clear)","l-light","l-coffee","l-apricot","l-rainy","l-botanical","l-vivid","l-cherry","l-sushi","l-u0","d-dark","d-persimmon","d-astro","d-future","d-botanical","d-green-lime","d-green-orange","d-cherry","d-ice","d-u0"].map((t,T)=>({id:t,title:t,onClick(){m({[i]:T?t:!1}),u();},value:t,active:t===s[i]}))}),onVisibleChange:p},r__default.default.createElement(components.IconButton,{key:e,active:d||a,title:"Switch theme"},r__default.default.createElement(components.Icons,{icon:"mirror"})))});managerApi.addons.register(o,()=>{managerApi.addons.add(e,{type:managerApi.types.TOOL,title:"Valkyrie theme",match:({viewMode:l})=>!!(l&&l.match(/^(story|docs)$/)),render:n});}); +//# sourceMappingURL=out.js.map +//# sourceMappingURL=manager.js.map \ No newline at end of file diff --git a/dist/manager.js.map b/dist/manager.js.map new file mode 100644 index 0000000..f52765a --- /dev/null +++ b/dist/manager.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/manager.ts","../src/constants.ts","../src/Tool.tsx"],"names":["addons","types","ADDON_ID","TOOL_ID","PARAM_KEY","EVENTS","React","memo","useState","useGlobals","useStorybookApi","Icons","IconButton","TooltipLinkList","WithTooltip","Tool","isTooltipVisible","setIsTooltipVisible","globals","updateGlobals","api","isActive","onHide","theme","i","viewMode"],"mappings":"AAAA,OAAS,UAAAA,EAAQ,SAAAC,MAAa,yBCAvB,IAAMC,EAAW,8CACXC,EAAU,GAAGD,SACbE,EAAY,gBAEZC,EAAS,CACpB,OAAQ,GAAGH,WACX,QAAS,GAAGA,YACZ,MAAO,GAAGA,SACZ,ECRA,OAAOI,GAAS,QAAAC,EAAM,YAAAC,MAAgB,QACtC,OAAS,cAAAC,EAAY,mBAAAC,MAAuB,yBAC5C,OAAS,SAAAC,EAAO,cAAAC,EAAY,mBAAAC,EAAiB,eAAAC,MAAmB,wBAGzD,IAAMC,EAAOR,EAAK,UAA2B,CAClD,GAAM,CAACS,EAAkBC,CAAmB,EAAIT,EAAS,EAAK,EACxD,CAACU,EAASC,CAAa,EAAIV,EAAW,EACtCW,EAAMV,EAAgB,EAEtBW,EAAW,CAAC,CAACH,EAAQd,CAAS,EAEpC,OACEE,EAAA,cAACQ,EAAA,CACC,UAAU,MACV,oBAAmB,GACnB,QAAS,CAAC,CAAE,OAAAQ,CAAO,IAEfhB,EAAA,cAACO,EAAA,CACC,MAAO,CACL,UACA,UACA,WACA,YACA,UACA,cACA,UACA,WACA,UACA,OACA,SACA,cACA,UACA,WACA,cACA,eACA,iBACA,WACA,QACA,MACF,EAAE,IAAI,CAACU,EAAOC,KAAO,CACnB,GAAID,EACJ,MAAOA,EACP,SAAU,CACRJ,EAAc,CACZ,CAACf,CAAS,EAAGoB,EAAID,EAAQ,EAC3B,CAAC,EACDD,EAAO,CACT,EACA,MAAOC,EACP,OAAQA,IAAUL,EAAQd,CAAS,CACrC,EAAE,EACJ,EAGJ,gBAAiBa,GAEjBX,EAAA,cAACM,EAAA,CACC,IAAKT,EACL,OAAQkB,GAAYL,EACpB,MAAM,gBAENV,EAAA,cAACK,EAAA,CAAM,KAAK,SAAS,CACvB,CACF,CAEJ,CAAC,EFxDDX,EAAO,SAASE,EAAU,IAAM,CAE9BF,EAAO,IAAIG,EAAS,CAClB,KAAMF,EAAM,KACZ,MAAO,iBACP,MAAO,CAAC,CAAE,SAAAwB,CAAS,IAAM,CAAC,EAAEA,GAAYA,EAAS,MAAM,gBAAgB,GACvE,OAAQV,CACV,CAAC,CACH,CAAC","sourcesContent":["import { addons, types } from \"@storybook/manager-api\";\nimport { ADDON_ID, TOOL_ID } from \"./constants\";\nimport { Tool } from \"./Tool\";\n\n/**\n * Note: if you want to use JSX in this file, rename it to `manager.tsx`\n * and update the entry prop in tsup.config.ts to use \"src/manager.tsx\",\n */\n\n// Register the addon\naddons.register(ADDON_ID, () => {\n // Register the tool\n addons.add(TOOL_ID, {\n type: types.TOOL,\n title: \"Valkyrie theme\",\n match: ({ viewMode }) => !!(viewMode && viewMode.match(/^(story|docs)$/)),\n render: Tool,\n });\n});","export const ADDON_ID = \"valkyriecoms/storybook-addon-valkyrie-theme\";\nexport const TOOL_ID = `${ADDON_ID}/tool`;\nexport const PARAM_KEY = `valkyrieTheme`;\n\nexport const EVENTS = {\n RESULT: `${ADDON_ID}/result`,\n REQUEST: `${ADDON_ID}/request`,\n CLEAR: `${ADDON_ID}/clear`,\n};","import React, { memo, useState } from \"react\";\nimport { useGlobals, useStorybookApi } from \"@storybook/manager-api\";\nimport { Icons, IconButton, TooltipLinkList, WithTooltip } from \"@storybook/components\";\nimport { ADDON_ID, PARAM_KEY, TOOL_ID } from \"./constants\";\n\nexport const Tool = memo(function MyAddonSelector() {\n const [isTooltipVisible, setIsTooltipVisible] = useState(false);\n const [globals, updateGlobals] = useGlobals();\n const api = useStorybookApi();\n\n const isActive = !!globals[PARAM_KEY];\n\n return (\n {\n return (\n ({\n id: theme,\n title: theme,\n onClick() {\n updateGlobals({\n [PARAM_KEY]: i ? theme : false,\n });\n onHide();\n },\n value: theme,\n active: theme === globals[PARAM_KEY],\n }))}\n />\n );\n }}\n onVisibleChange={setIsTooltipVisible}\n >\n \n \n \n \n );\n});"]} \ No newline at end of file diff --git a/dist/manager.mjs b/dist/manager.mjs new file mode 100644 index 0000000..e13c71e --- /dev/null +++ b/dist/manager.mjs @@ -0,0 +1,7 @@ +import { useGlobals, useStorybookApi, addons, types } from '@storybook/manager-api'; +import r, { memo, useState } from 'react'; +import { WithTooltip, TooltipLinkList, IconButton, Icons } from '@storybook/components'; + +var o="valkyriecoms/storybook-addon-valkyrie-theme",e=`${o}/tool`,i="valkyrieTheme";var n=memo(function(){let [a,p]=useState(!1),[s,m]=useGlobals();useStorybookApi();let d=!!s[i];return r.createElement(WithTooltip,{placement:"top",closeOnOutsideClick:!0,tooltip:({onHide:u})=>r.createElement(TooltipLinkList,{links:["(clear)","l-light","l-coffee","l-apricot","l-rainy","l-botanical","l-vivid","l-cherry","l-sushi","l-u0","d-dark","d-persimmon","d-astro","d-future","d-botanical","d-green-lime","d-green-orange","d-cherry","d-ice","d-u0"].map((t,T)=>({id:t,title:t,onClick(){m({[i]:T?t:!1}),u();},value:t,active:t===s[i]}))}),onVisibleChange:p},r.createElement(IconButton,{key:e,active:d||a,title:"Switch theme"},r.createElement(Icons,{icon:"mirror"})))});addons.register(o,()=>{addons.add(e,{type:types.TOOL,title:"Valkyrie theme",match:({viewMode:l})=>!!(l&&l.match(/^(story|docs)$/)),render:n});}); +//# sourceMappingURL=out.js.map +//# sourceMappingURL=manager.mjs.map \ No newline at end of file diff --git a/dist/manager.mjs.map b/dist/manager.mjs.map new file mode 100644 index 0000000..f52765a --- /dev/null +++ b/dist/manager.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/manager.ts","../src/constants.ts","../src/Tool.tsx"],"names":["addons","types","ADDON_ID","TOOL_ID","PARAM_KEY","EVENTS","React","memo","useState","useGlobals","useStorybookApi","Icons","IconButton","TooltipLinkList","WithTooltip","Tool","isTooltipVisible","setIsTooltipVisible","globals","updateGlobals","api","isActive","onHide","theme","i","viewMode"],"mappings":"AAAA,OAAS,UAAAA,EAAQ,SAAAC,MAAa,yBCAvB,IAAMC,EAAW,8CACXC,EAAU,GAAGD,SACbE,EAAY,gBAEZC,EAAS,CACpB,OAAQ,GAAGH,WACX,QAAS,GAAGA,YACZ,MAAO,GAAGA,SACZ,ECRA,OAAOI,GAAS,QAAAC,EAAM,YAAAC,MAAgB,QACtC,OAAS,cAAAC,EAAY,mBAAAC,MAAuB,yBAC5C,OAAS,SAAAC,EAAO,cAAAC,EAAY,mBAAAC,EAAiB,eAAAC,MAAmB,wBAGzD,IAAMC,EAAOR,EAAK,UAA2B,CAClD,GAAM,CAACS,EAAkBC,CAAmB,EAAIT,EAAS,EAAK,EACxD,CAACU,EAASC,CAAa,EAAIV,EAAW,EACtCW,EAAMV,EAAgB,EAEtBW,EAAW,CAAC,CAACH,EAAQd,CAAS,EAEpC,OACEE,EAAA,cAACQ,EAAA,CACC,UAAU,MACV,oBAAmB,GACnB,QAAS,CAAC,CAAE,OAAAQ,CAAO,IAEfhB,EAAA,cAACO,EAAA,CACC,MAAO,CACL,UACA,UACA,WACA,YACA,UACA,cACA,UACA,WACA,UACA,OACA,SACA,cACA,UACA,WACA,cACA,eACA,iBACA,WACA,QACA,MACF,EAAE,IAAI,CAACU,EAAOC,KAAO,CACnB,GAAID,EACJ,MAAOA,EACP,SAAU,CACRJ,EAAc,CACZ,CAACf,CAAS,EAAGoB,EAAID,EAAQ,EAC3B,CAAC,EACDD,EAAO,CACT,EACA,MAAOC,EACP,OAAQA,IAAUL,EAAQd,CAAS,CACrC,EAAE,EACJ,EAGJ,gBAAiBa,GAEjBX,EAAA,cAACM,EAAA,CACC,IAAKT,EACL,OAAQkB,GAAYL,EACpB,MAAM,gBAENV,EAAA,cAACK,EAAA,CAAM,KAAK,SAAS,CACvB,CACF,CAEJ,CAAC,EFxDDX,EAAO,SAASE,EAAU,IAAM,CAE9BF,EAAO,IAAIG,EAAS,CAClB,KAAMF,EAAM,KACZ,MAAO,iBACP,MAAO,CAAC,CAAE,SAAAwB,CAAS,IAAM,CAAC,EAAEA,GAAYA,EAAS,MAAM,gBAAgB,GACvE,OAAQV,CACV,CAAC,CACH,CAAC","sourcesContent":["import { addons, types } from \"@storybook/manager-api\";\nimport { ADDON_ID, TOOL_ID } from \"./constants\";\nimport { Tool } from \"./Tool\";\n\n/**\n * Note: if you want to use JSX in this file, rename it to `manager.tsx`\n * and update the entry prop in tsup.config.ts to use \"src/manager.tsx\",\n */\n\n// Register the addon\naddons.register(ADDON_ID, () => {\n // Register the tool\n addons.add(TOOL_ID, {\n type: types.TOOL,\n title: \"Valkyrie theme\",\n match: ({ viewMode }) => !!(viewMode && viewMode.match(/^(story|docs)$/)),\n render: Tool,\n });\n});","export const ADDON_ID = \"valkyriecoms/storybook-addon-valkyrie-theme\";\nexport const TOOL_ID = `${ADDON_ID}/tool`;\nexport const PARAM_KEY = `valkyrieTheme`;\n\nexport const EVENTS = {\n RESULT: `${ADDON_ID}/result`,\n REQUEST: `${ADDON_ID}/request`,\n CLEAR: `${ADDON_ID}/clear`,\n};","import React, { memo, useState } from \"react\";\nimport { useGlobals, useStorybookApi } from \"@storybook/manager-api\";\nimport { Icons, IconButton, TooltipLinkList, WithTooltip } from \"@storybook/components\";\nimport { ADDON_ID, PARAM_KEY, TOOL_ID } from \"./constants\";\n\nexport const Tool = memo(function MyAddonSelector() {\n const [isTooltipVisible, setIsTooltipVisible] = useState(false);\n const [globals, updateGlobals] = useGlobals();\n const api = useStorybookApi();\n\n const isActive = !!globals[PARAM_KEY];\n\n return (\n {\n return (\n ({\n id: theme,\n title: theme,\n onClick() {\n updateGlobals({\n [PARAM_KEY]: i ? theme : false,\n });\n onHide();\n },\n value: theme,\n active: theme === globals[PARAM_KEY],\n }))}\n />\n );\n }}\n onVisibleChange={setIsTooltipVisible}\n >\n \n \n \n \n );\n});"]} \ No newline at end of file diff --git a/dist/preview.d.ts b/dist/preview.d.ts new file mode 100644 index 0000000..a094034 --- /dev/null +++ b/dist/preview.d.ts @@ -0,0 +1,20 @@ +import { ProjectAnnotations, Renderer } from '@storybook/types'; + +/** + * A decorator is a way to wrap a story in extra “rendering” functionality. Many addons define decorators + * in order to augment stories: + * - with extra rendering + * - gather details about how a story is rendered + * + * When writing stories, decorators are typically used to wrap stories with extra markup or context mocking. + * + * https://storybook.js.org/docs/react/writing-stories/decorators + */ + +/** + * Note: if you want to use JSX in this file, rename it to `preview.tsx` + * and update the entry prop in tsup.config.ts to use "src/preview.tsx", + */ +declare const preview: ProjectAnnotations; + +export { preview as default }; diff --git a/dist/preview.js b/dist/preview.js new file mode 100644 index 0000000..c473c44 --- /dev/null +++ b/dist/preview.js @@ -0,0 +1,9 @@ +'use strict'; + +var previewApi = require('@storybook/preview-api'); + +var o="valkyrieTheme";var s=(e,n)=>{let[l]=previewApi.useGlobals(),r=l[o],{theme:a}=n.globals;return previewApi.useEffect(()=>{i(r);},[r,a]),e()};function i(e){e?document.documentElement.dataset.misskeyTheme=e:delete document.documentElement.dataset.misskeyTheme;}var p={decorators:[s],globals:{[o]:!1}},S=p; + +module.exports = S; +//# sourceMappingURL=out.js.map +//# sourceMappingURL=preview.js.map \ No newline at end of file diff --git a/dist/preview.js.map b/dist/preview.js.map new file mode 100644 index 0000000..c4a44bc --- /dev/null +++ b/dist/preview.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/constants.ts","../src/withGlobals.ts","../src/preview.ts"],"names":["ADDON_ID","TOOL_ID","PARAM_KEY","EVENTS","useEffect","useGlobals","withGlobals","StoryFn","context","globals","state","theme","applyToolState","preview","preview_default"],"mappings":"AAAO,IAAMA,EAAW,8CACXC,EAAU,GAAGD,SACbE,EAAY,gBAEZC,EAAS,CACpB,OAAQ,GAAGH,WACX,QAAS,GAAGA,YACZ,MAAO,GAAGA,SACZ,ECHA,OAAS,aAAAI,EAAW,cAAAC,MAAkB,yBAG/B,IAAMC,EAAc,CACzBC,EACAC,IACG,CACH,GAAM,CAACC,CAAO,EAAIJ,EAAW,EACvBK,EAAQD,EAAQP,CAAS,EACzB,CAAE,MAAAS,CAAM,EAAIH,EAAQ,QAE1B,OAAAJ,EAAU,IAAM,CACdQ,EAAeF,CAAK,CACtB,EAAG,CAACA,EAAOC,CAAK,CAAC,EAEVJ,EAAQ,CACjB,EAEA,SAASK,EAAeF,EAAuB,CACzCA,EACF,SAAS,gBAAgB,QAAQ,aAAeA,EAEhD,OAAO,SAAS,gBAAgB,QAAQ,YAE5C,CCVA,IAAMG,EAAwC,CAC5C,WAAY,CAACP,CAAW,EACxB,QAAS,CACP,CAACJ,CAAS,EAAG,EACf,CACF,EAEOY,EAAQD","sourcesContent":["export const ADDON_ID = \"valkyriecoms/storybook-addon-valkyrie-theme\";\nexport const TOOL_ID = `${ADDON_ID}/tool`;\nexport const PARAM_KEY = `valkyrieTheme`;\n\nexport const EVENTS = {\n RESULT: `${ADDON_ID}/result`,\n REQUEST: `${ADDON_ID}/request`,\n CLEAR: `${ADDON_ID}/clear`,\n};","import type {\n Renderer,\n PartialStoryFn as StoryFunction,\n StoryContext,\n} from \"@storybook/types\";\nimport { useEffect, useGlobals } from \"@storybook/preview-api\";\nimport { PARAM_KEY } from \"./constants\";\n\nexport const withGlobals = (\n StoryFn: StoryFunction,\n context: StoryContext\n) => {\n const [globals] = useGlobals();\n const state = globals[PARAM_KEY];\n const { theme } = context.globals;\n\n useEffect(() => {\n applyToolState(state);\n }, [state, theme]);\n\n return StoryFn();\n};\n\nfunction applyToolState(state: string | false) {\n if (state) {\n document.documentElement.dataset.misskeyTheme = state;\n } else {\n delete document.documentElement.dataset.misskeyTheme;\n }\n}","/**\n * A decorator is a way to wrap a story in extra “rendering” functionality. Many addons define decorators\n * in order to augment stories:\n * - with extra rendering\n * - gather details about how a story is rendered\n *\n * When writing stories, decorators are typically used to wrap stories with extra markup or context mocking.\n *\n * https://storybook.js.org/docs/react/writing-stories/decorators\n */\nimport type { Renderer, ProjectAnnotations } from \"@storybook/types\";\nimport { PARAM_KEY } from \"./constants\";\nimport { withGlobals } from \"./withGlobals\";\n\n/**\n * Note: if you want to use JSX in this file, rename it to `preview.tsx`\n * and update the entry prop in tsup.config.ts to use \"src/preview.tsx\",\n */\n\nconst preview: ProjectAnnotations = {\n decorators: [withGlobals],\n globals: {\n [PARAM_KEY]: false,\n },\n};\n\nexport default preview;"]} \ No newline at end of file diff --git a/dist/preview.mjs b/dist/preview.mjs new file mode 100644 index 0000000..2660543 --- /dev/null +++ b/dist/preview.mjs @@ -0,0 +1,7 @@ +import { useGlobals, useEffect } from '@storybook/preview-api'; + +var o="valkyrieTheme";var s=(e,n)=>{let[l]=useGlobals(),r=l[o],{theme:a}=n.globals;return useEffect(()=>{i(r);},[r,a]),e()};function i(e){e?document.documentElement.dataset.misskeyTheme=e:delete document.documentElement.dataset.misskeyTheme;}var p={decorators:[s],globals:{[o]:!1}},S=p; + +export { S as default }; +//# sourceMappingURL=out.js.map +//# sourceMappingURL=preview.mjs.map \ No newline at end of file diff --git a/dist/preview.mjs.map b/dist/preview.mjs.map new file mode 100644 index 0000000..c4a44bc --- /dev/null +++ b/dist/preview.mjs.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/constants.ts","../src/withGlobals.ts","../src/preview.ts"],"names":["ADDON_ID","TOOL_ID","PARAM_KEY","EVENTS","useEffect","useGlobals","withGlobals","StoryFn","context","globals","state","theme","applyToolState","preview","preview_default"],"mappings":"AAAO,IAAMA,EAAW,8CACXC,EAAU,GAAGD,SACbE,EAAY,gBAEZC,EAAS,CACpB,OAAQ,GAAGH,WACX,QAAS,GAAGA,YACZ,MAAO,GAAGA,SACZ,ECHA,OAAS,aAAAI,EAAW,cAAAC,MAAkB,yBAG/B,IAAMC,EAAc,CACzBC,EACAC,IACG,CACH,GAAM,CAACC,CAAO,EAAIJ,EAAW,EACvBK,EAAQD,EAAQP,CAAS,EACzB,CAAE,MAAAS,CAAM,EAAIH,EAAQ,QAE1B,OAAAJ,EAAU,IAAM,CACdQ,EAAeF,CAAK,CACtB,EAAG,CAACA,EAAOC,CAAK,CAAC,EAEVJ,EAAQ,CACjB,EAEA,SAASK,EAAeF,EAAuB,CACzCA,EACF,SAAS,gBAAgB,QAAQ,aAAeA,EAEhD,OAAO,SAAS,gBAAgB,QAAQ,YAE5C,CCVA,IAAMG,EAAwC,CAC5C,WAAY,CAACP,CAAW,EACxB,QAAS,CACP,CAACJ,CAAS,EAAG,EACf,CACF,EAEOY,EAAQD","sourcesContent":["export const ADDON_ID = \"valkyriecoms/storybook-addon-valkyrie-theme\";\nexport const TOOL_ID = `${ADDON_ID}/tool`;\nexport const PARAM_KEY = `valkyrieTheme`;\n\nexport const EVENTS = {\n RESULT: `${ADDON_ID}/result`,\n REQUEST: `${ADDON_ID}/request`,\n CLEAR: `${ADDON_ID}/clear`,\n};","import type {\n Renderer,\n PartialStoryFn as StoryFunction,\n StoryContext,\n} from \"@storybook/types\";\nimport { useEffect, useGlobals } from \"@storybook/preview-api\";\nimport { PARAM_KEY } from \"./constants\";\n\nexport const withGlobals = (\n StoryFn: StoryFunction,\n context: StoryContext\n) => {\n const [globals] = useGlobals();\n const state = globals[PARAM_KEY];\n const { theme } = context.globals;\n\n useEffect(() => {\n applyToolState(state);\n }, [state, theme]);\n\n return StoryFn();\n};\n\nfunction applyToolState(state: string | false) {\n if (state) {\n document.documentElement.dataset.misskeyTheme = state;\n } else {\n delete document.documentElement.dataset.misskeyTheme;\n }\n}","/**\n * A decorator is a way to wrap a story in extra “rendering” functionality. Many addons define decorators\n * in order to augment stories:\n * - with extra rendering\n * - gather details about how a story is rendered\n *\n * When writing stories, decorators are typically used to wrap stories with extra markup or context mocking.\n *\n * https://storybook.js.org/docs/react/writing-stories/decorators\n */\nimport type { Renderer, ProjectAnnotations } from \"@storybook/types\";\nimport { PARAM_KEY } from \"./constants\";\nimport { withGlobals } from \"./withGlobals\";\n\n/**\n * Note: if you want to use JSX in this file, rename it to `preview.tsx`\n * and update the entry prop in tsup.config.ts to use \"src/preview.tsx\",\n */\n\nconst preview: ProjectAnnotations = {\n decorators: [withGlobals],\n globals: {\n [PARAM_KEY]: false,\n },\n};\n\nexport default preview;"]} \ No newline at end of file