2024-08-12 15:09:11 +02:00
|
|
|
{"version":3,"file":"preview-CXooXs_x.js","sources":["../../node_modules/@storybook/sveltekit/dist/preview.mjs"],"sourcesContent":["import { action } from '@storybook/addon-actions';\nimport { onMount, setContext, getContext } from 'svelte';\n\nfunction setAfterNavigateArgument(afterNavigateArgs){setContext(\"after-navigate-args\",afterNavigateArgs);}function createMockedStore(contextName){return [{subscribe(runner){let page2=getContext(contextName);return runner(page2),()=>{}}},value=>{setContext(contextName,value);}]}var[page,setPage]=createMockedStore(\"page-ctx\"),[navigating,setNavigating]=createMockedStore(\"navigating-ctx\"),[updated,setUpdated]=createMockedStore(\"updated-ctx\");updated.check=()=>{};var normalizeHrefConfig=hrefConfig=>typeof hrefConfig==\"function\"?{callback:hrefConfig,asRegex:!1}:hrefConfig,decorators=[(Story,ctx)=>{let svelteKitParameters=ctx.parameters?.sveltekit_experimental??{};return setPage(svelteKitParameters?.stores?.page),setNavigating(svelteKitParameters?.stores?.navigating),setUpdated(svelteKitParameters?.stores?.updated),setAfterNavigateArgument(svelteKitParameters?.navigation?.afterNavigate),onMount(()=>{let globalClickListener=e=>{let element=e.composedPath().findLast(el=>el instanceof HTMLElement&&el.tagName===\"A\");if(element&&element instanceof HTMLAnchorElement){let to=element.getAttribute(\"href\");if(!to)return;e.preventDefault();let defaultActionCallback=()=>action(\"navigate\")(to,e);if(!svelteKitParameters.hrefs){defaultActionCallback();return}let callDefaultCallback=!0;Object.entries(svelteKitParameters.hrefs).forEach(([href,hrefConfig])=>{let{callback,asRegex}=normalizeHrefConfig(hrefConfig);(asRegex?new RegExp(href).test(to):to===href)&&(callDefaultCallback=!1,callback?.(to,e));}),callDefaultCallback&&defaultActionCallback();}};function createListeners(baseModule,functions,defaultToAction){let toRemove=[];return functions.forEach(func=>{let hasFunction=svelteKitParameters[baseModule]?.[func]&&svelteKitParameters[baseModule][func]instanceof Function;if(hasFunction||defaultToAction){let listener=({detail=[]})=>{let args=Array.isArray(detail)?detail:[];(hasFunction?svelteKitParameters[baseModule][func]:action(func))(...args);},eventType=`storybook:${func}`;toRemove.push({eventType,listener}),window.addEventListener(eventType,listener);}}),()=>{toRemove.forEach(({eventType,listener})=>{window.removeEventListener(eventType,listener);});}}let removeNavigationListeners=createListeners(\"navigation\",[\"goto\",\"invalidate\",\"invalidateAll\",\"pushState\",\"replaceState\"],!0),removeFormsListeners=createListeners(\"forms\",[\"enhance\"]);return window.addEventListener(\"click\",globalClickListener),()=>{window.removeEventListener(\"click\",globalClickListener),removeNavigationListeners(),removeFormsListeners();}}),Story()}];\n\nexport { decorators };\n"],"names":["setAfterNavigateArgument","afterNavigateArgs","setContext","createMockedStore","contextName","runner","page2","getContext","value","page","setPage","navigating","setNavigating","updated","setUpdated","normalizeHrefConfig","hrefConfig","decorators","Story","ctx","svelteKitParameters","_a","_b","_c","_d","_e","onMount","globalClickListener","e","element","el","to","defaultActionCallback","action","callDefaultCallback","href","callback","asRegex","createListeners","baseModule","functions","defaultToAction","toRemove","func","hasFunction","listener","detail","args","eventType","removeNavigationListeners","removeFormsListeners"],"mappings":"oIAGA,SAASA,EAAyBC,EAAkB,CAACC,EAAW,sBAAsBD,CAAiB,CAAE,CAAC,SAASE,EAAkBC,EAAY,CAAC,MAAO,CAAC,CAAC,UAAUC,EAAO,CAAC,IAAIC,EAAMC,EAAWH,CAAW,EAAE,OAAOC,EAAOC,CAAK,EAAE,IAAI,CAAE,CAAA,CAAC,EAAEE,GAAO,CAACN,EAAWE,EAAYI,CAAK,CAAE,CAAC,CAAC,CAAC,GAAG,CAACC,EAAKC,CAAO,EAAEP,EAAkB,UAAU,EAAE,CAACQ,EAAWC,CAAa,EAAET,EAAkB,gBAAgB,EAAE,CAACU,EAAQC,CAAU,EAAEX,EAAkB,aAAa,EAAEU,EAAQ,MAAM,IAAI,CAAE,EAAI,IAACE,EAAoBC,GAAY,OAAOA,GAAY,WAAW,CAAC,SAASA,EAAW,QAAQ,EAAE,EAAEA,EAAWC,EAAW,CAAC,CAACC,EAAMC,IAAM,eAAC,IAAIC,IAAoBC,EAAAF,EAAI,aAAJ,YAAAE,EAAgB,yBAAwB,CAAE,EAAC,OAAOX,GAAQY,EAAAF,GAAA,YAAAA,EAAqB,SAAr
|