UNPKG

storybook-addon-aem-style-system

Version:
1 lines 4.2 kB
{"version":3,"sources":["../src/constants.ts","../src/withGlobals.ts","../src/withRoundTrip.ts","../src/preview.ts"],"names":["ADDON_ID","TOOL_ID","KEY","EVENTS","withGlobals","StoryFn","context","globals","useGlobals","myAddon","isInDocs","theme","useEffect","withRoundTrip","storyFn","emit","useChannel","preview","preview_default"],"mappings":"sEAAO,IAAMA,EAAW,4BACXC,CAGAC,CAAAA,CAAM,YAENC,CAAS,CAAA,CACpB,MAAQ,CAAA,CAAA,EAAGH,CAAQ,CACnB,OAAA,CAAA,CAAA,OAAA,CAAS,CAAGA,EAAAA,CAAQ,WACpB,KAAO,CAAA,CAAA,EAAGA,CAAQ,CAAA,MAAA,CAAA,CAClB,OAAQ,CAAGA,EAAAA,CAAQ,SACrB,ECFO,IAAMI,CAAc,CAAA,CACzBC,CACAC,CAAAA,CAAAA,GACG,CACH,GAAM,CAACC,CAAO,CAAA,CAAIC,uBACZC,CAAAA,CAAAA,CAAUF,EAAQL,CAAG,CAAA,CAIrBQ,EAAWJ,CAAQ,CAAA,QAAA,GAAa,MAChC,CAAA,CAAE,MAAAK,CAAM,CAAA,CAAIL,CAAQ,CAAA,OAAA,CAE1B,OAAAM,oBAAU,CAAA,IAAM,CACGF,CACb,CAAA,CAAA,SAAA,EAAYJ,EAAQ,EAAE,CAAA,UAAA,CAAA,CACtB,kBACN,CAAG,CAAA,CAACG,CAASE,CAAAA,CAAK,CAAC,CAEZN,CAAAA,CAAAA,EACT,CAAA,CCrBO,IAAMQ,EAAmC,CAACC,CAAAA,CAASR,IAAY,CACpE,IAAMS,EAAOC,qBAAW,CAAA,CACtB,CAACb,CAAAA,CAAO,OAAO,EAAG,IAAM,CACtBY,CAAAA,CAAKZ,EAAO,MAAQ,CAAA,CAClB,QAAS,CAAA,EACX,CAAC,EACH,EACA,CAACA,CAAAA,CAAO,MAAM,EAAG,IAAM,EAIvB,CACA,CAACA,CAAO,CAAA,KAAK,EAAG,IAAM,CACpBY,CAAKZ,CAAAA,CAAAA,CAAO,MAAQ,CAAA,CAClB,SAAS,EACX,CAAC,EACH,CACF,CAAC,CAED,CAAA,OAAOW,CAAQ,EACjB,ECNMG,IAAAA,CAAAA,CAAwC,CAC5C,UAAA,CAAY,CAACb,CAAaS,CAAAA,CAAa,CACvC,CAAA,cAAA,CAAgB,CACd,CAACX,CAAG,EAAG,CACT,CAAA,CACF,EAEOgB,CAAQD,CAAAA","file":"preview.cjs","sourcesContent":["export const ADDON_ID = \"storybook/aem-style-system\";\nexport const TOOL_ID = `${ADDON_ID}/tool`;\nexport const PANEL_ID = `${ADDON_ID}/panel`;\nexport const TAB_ID = `${ADDON_ID}/tab`;\nexport const KEY = `aemStyles`;\n\nexport const EVENTS = {\n RESULT: `${ADDON_ID}/result`,\n REQUEST: `${ADDON_ID}/request`,\n CLEAR: `${ADDON_ID}/clear`,\n CHANGE: `${ADDON_ID}/change`\n};\n","import { useEffect, useGlobals } from \"storybook/internal/preview-api\";\nimport type {\n Renderer,\n StoryContext,\n PartialStoryFn as StoryFunction,\n} from \"storybook/internal/types\";\n\nimport { KEY } from \"./constants\";\n\nexport const withGlobals = (\n StoryFn: StoryFunction<Renderer>,\n context: StoryContext<Renderer>,\n) => {\n const [globals] = useGlobals();\n const myAddon = globals[KEY];\n\n\n // Is the addon being used in the docs panel\n const isInDocs = context.viewMode === \"docs\";\n const { theme } = context.globals;\n\n useEffect(() => {\n const selector = isInDocs\n ? `#anchor--${context.id} .sb-story`\n : \"#storybook-root\";\n }, [myAddon, theme]);\n\n return StoryFn();\n};","\nimport { useChannel } from \"storybook/internal/preview-api\";\nimport type { DecoratorFunction } from \"storybook/internal/types\";\n\nimport { EVENTS } from \"./constants\";\n\n\nexport const withRoundTrip: DecoratorFunction = (storyFn, context) => {\n const emit = useChannel({\n [EVENTS.REQUEST]: () => {\n emit(EVENTS.RESULT, {\n cssClass:[]\n });\n },\n [EVENTS.CHANGE]: () => {\n // emit(EVENTS.RESULT, {\n // cssClass:[]\n // });\n },\n [EVENTS.CLEAR]: () => {\n emit(EVENTS.RESULT, {\n cssClass:[]\n });\n },\n });\n\n return storyFn();\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 { ProjectAnnotations, Renderer } from \"storybook/internal/types\";\n\nimport { KEY } from \"./constants\";\nimport { withGlobals } from \"./withGlobals\";\nimport { withRoundTrip } from \"./withRoundTrip\";\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<Renderer> = {\n decorators: [withGlobals, withRoundTrip],\n initialGlobals: {\n [KEY]: false,\n },\n};\n\nexport default preview;\n"]}