storybook-prebuilt
Version:
A prebuilt storybook version for web components
3 lines (2 loc) • 12.7 kB
JavaScript
import{c as e,u as t}from"./storybook-prebuilt-3ba63d3f.js";import{a as n,_ as r}from"./storybook-prebuilt-0b3b0ce5.js";import{r as o,a,_ as s}from"./storybook-prebuilt-e17bc3b1.js";import"./storybook-prebuilt-d40d7550.js";var i=e((function(e,t){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.isSupportedType=function(e){return!!Object.values(n).find((function(t){return t===e}))},t.types=void 0,t.types=n,function(e){e.TAB="tab",e.PANEL="panel",e.TOOL="tool",e.PREVIEW="preview",e.NOTES_ELEMENT="notes-element"}(n||(t.types=n={}))}));t(i);i.isSupportedType,i.types;var u=e((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.addons=t.AddonStore=void 0;var o,a=(o=n)&&o.__esModule?o:{default:o};var s=function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.loaders={},this.elements={},this.config={},this.channel=void 0,this.promise=void 0,this.resolve=void 0,this.getChannel=function(){if(!t.channel)throw new Error("Accessing non-existent addons channel, see https://storybook.js.org/basics/faq/#why-is-there-no-addons-channel");return t.channel},this.ready=function(){return t.promise},this.hasChannel=function(){return!!t.channel},this.setChannel=function(e){t.channel=e,t.resolve()},this.getElements=function(e){return t.elements[e]||(t.elements[e]={}),t.elements[e]},this.addPanel=function(e,n){t.add(e,Object.assign({type:i.types.PANEL},n))},this.add=function(e,n){var r=n.type;t.getElements(r)[e]=Object.assign({id:e},n)},this.setConfig=function(e){Object.assign(t.config,e)},this.getConfig=function(){return t.config},this.register=function(e,n){t.loaders[e]&&r.logger.warn("".concat(e," was loaded twice, this could have bad side-effects")),t.loaders[e]=n},this.loadAddons=function(e){Object.values(t.loaders).forEach((function(t){return t(e)}))},this.promise=new Promise((function(e){t.resolve=function(){return e(t.getChannel())}}))};t.AddonStore=s;var u="__STORYBOOK_ADDONS";var c=(a.default[u]||(a.default[u]=new s),a.default[u]);t.addons=c}));t(u);u.addons,u.AddonStore;var c=e((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.makeDecorator=void 0;var n,r=(n=o)&&n.__esModule?n:{default:n};t.makeDecorator=function(e){var t=e.name,n=e.parameterName,o=e.wrapper,a=e.skipIfNoParametersOrOptions,s=void 0!==a&&a,i=e.allowDeprecatedUsage,u=void 0!==i&&i,c=function(e){return function(t,r){var a=r.parameters&&r.parameters[n];return a&&a.disable?t(r):!s||e||a?o(t,r,{options:e,parameters:a}):t(r)}};return function(){for(var e=arguments.length,o=new Array(e),a=0;a<e;a++)o[a]=arguments[a];return"function"==typeof o[0]?c().apply(void 0,o):function(){for(var e=arguments.length,a=new Array(e),s=0;s<e;s++)a[s]=arguments[s];if(a.length>1)return c.apply(void 0,o).apply(void 0,a);if(u)return(0,r.default)((function(e){return c.apply(void 0,o)(a[0],e)}),"Passing stories directly into ".concat(t,"() is deprecated,\n instead use addDecorator(").concat(t,") and pass options with the '").concat(n,"' parameter"));throw new Error("Passing stories directly into ".concat(t,"() is not allowed,\n instead use addDecorator(").concat(t,") and pass options with the '").concat(n,"' parameter"))}}}}));t(c);c.makeDecorator;var f=e((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.mockChannel=function(){return new r.default({transport:{setHandler:function(){},send:function(){}}})};var n,r=(n=a)&&n.__esModule?n:{default:n}}));t(f);f.mockChannel;var d=e((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.useMemo=function(e,t){return b("useMemo",e,t)},t.useCallback=function(e,t){return b("useCallback",(function(){return e}),t)},t.useRef=function(e){return g("useRef",e)},t.useState=function(e){return O("useState",e)},t.useReducer=function(e,t,n){var r=i(O("useReducer",null!=n?function(){return n(t)}:t),2),o=r[0],a=r[1];return[o,function(t){return a((function(n){return e(n,t)}))}]},t.useEffect=k,t.useChannel=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=u.addons.getChannel();return k((function(){return Object.entries(e).forEach((function(e){var t=i(e,2),r=t[0],o=t[1];return n.on(r,o)})),function(){Object.entries(e).forEach((function(e){var t=i(e,2),r=t[0],o=t[1];return n.removeListener(r,o)}))}}),[].concat(c(Object.keys(e)),c(t))),n.emit.bind(n)},t.useStoryContext=E,t.useParameter=function(e,t){var n=E().parameters;if(e)return n[e]||t;return},t.applyHooks=t.HooksContext=void 0;var o,a=(o=n)&&o.__esModule?o:{default:o};function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var n=[],r=!0,o=!1,a=void 0;try{for(var s,i=e[Symbol.iterator]();!(r=(s=i.next()).done)&&(n.push(s.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{r||null==i.return||i.return()}finally{if(o)throw a}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function c(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var d=[s.STORY_RENDERED,s.DOCS_RENDERED],l=function(){function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.hookListsMap=void 0,this.mountedDecorators=void 0,this.prevMountedDecorators=void 0,this.currentHooks=void 0,this.nextHookIndex=void 0,this.currentPhase=void 0,this.currentEffects=void 0,this.prevEffects=void 0,this.currentDecoratorName=void 0,this.hasUpdates=void 0,this.currentContext=void 0,this.renderListener=function(){t.triggerEffects(),t.currentContext=null,t.removeRenderListeners()},this.init()}var t,n,r;return t=e,(n=[{key:"init",value:function(){this.hookListsMap=new WeakMap,this.mountedDecorators=new Set,this.prevMountedDecorators=this.mountedDecorators,this.currentHooks=[],this.nextHookIndex=0,this.currentPhase="NONE",this.currentEffects=[],this.prevEffects=[],this.currentDecoratorName=null,this.hasUpdates=!1,this.currentContext=null}},{key:"clean",value:function(){this.prevEffects.forEach((function(e){e.destroy&&e.destroy()})),this.init(),this.removeRenderListeners()}},{key:"getNextHook",value:function(){var e=this.currentHooks[this.nextHookIndex];return this.nextHookIndex+=1,e}},{key:"triggerEffects",value:function(){var e=this;this.prevEffects.forEach((function(t){!e.currentEffects.includes(t)&&t.destroy&&t.destroy()})),this.currentEffects.forEach((function(t){e.prevEffects.includes(t)||(t.destroy=t.create())})),this.prevEffects=this.currentEffects,this.currentEffects=[]}},{key:"addRenderListeners",value:function(){var e=this;this.removeRenderListeners();var t=u.addons.getChannel();d.forEach((function(n){return t.on(n,e.renderListener)}))}},{key:"removeRenderListeners",value:function(){var e=this,t=u.addons.getChannel();d.forEach((function(n){return t.removeListener(n,e.renderListener)}))}}])&&f(t.prototype,n),r&&f(t,r),e}();t.HooksContext=l;var h=function(e){return function(){var t="function"==typeof(arguments.length<=0?void 0:arguments[0])?arguments.length<=1?void 0:arguments[1]:arguments.length<=0?void 0:arguments[0],n=t.hooks,r=n.currentPhase,o=n.currentHooks,s=n.nextHookIndex,i=n.currentDecoratorName;n.currentDecoratorName=e.name,n.prevMountedDecorators.has(e)?(n.currentPhase="UPDATE",n.currentHooks=n.hookListsMap.get(e)||[]):(n.currentPhase="MOUNT",n.currentHooks=[],n.hookListsMap.set(e,n.currentHooks),n.prevMountedDecorators.add(e)),n.nextHookIndex=0;var u=a.default.STORYBOOK_HOOKS_CONTEXT;a.default.STORYBOOK_HOOKS_CONTEXT=n;var c=e.apply(void 0,arguments);if(a.default.STORYBOOK_HOOKS_CONTEXT=u,"UPDATE"===n.currentPhase&&null!=n.getNextHook())throw new Error("Rendered fewer hooks than expected. This may be caused by an accidental early return statement.");return n.currentPhase=r,n.currentHooks=o,n.nextHookIndex=s,n.currentDecoratorName=i,c}},p=0;t.applyHooks=function(e){return function(t,n){var r=e(h(t),n.map(h));return function(e){var o=e.hooks;o.prevMountedDecorators=o.mountedDecorators,o.mountedDecorators=new Set([t].concat(c(n))),o.currentContext=e,o.hasUpdates=!1;var a=r(e);for(p=1;o.hasUpdates;)if(o.hasUpdates=!1,o.currentEffects=[],a=r(e),(p+=1)>25)throw new Error("Too many re-renders. Storybook limits the number of renders to prevent an infinite loop.");return o.addRenderListeners(),a}}};var v=function(){return new Error("Storybook preview hooks can only be called inside decorators and story functions.")};function y(){return a.default.STORYBOOK_HOOKS_CONTEXT||null}function m(){var e=y();if(null==e)throw v();return e}function b(e,t,n){return function(e,t,n){var o=m();if("MOUNT"===o.currentPhase){null==n||Array.isArray(n)||r.logger.warn("".concat(e," received a final argument that is not an array (instead, received ").concat(n,"). When specified, the final argument must be an array."));var a={name:e,deps:n};return o.currentHooks.push(a),t(a),a}if("UPDATE"===o.currentPhase){var s=o.getNextHook();if(null==s)throw new Error("Rendered more hooks than during the previous render.");return s.name!==e&&r.logger.warn("Storybook has detected a change in the order of Hooks".concat(o.currentDecoratorName?" called by ".concat(o.currentDecoratorName):"",". This will lead to bugs and errors if not fixed.")),null!=n&&null==s.deps&&r.logger.warn("".concat(e," received a final argument during this render, but not during the previous render. Even though the final argument is optional, its type cannot change between renders.")),null!=n&&null!=s.deps&&n.length!==s.deps.length&&r.logger.warn("The final argument passed to ".concat(e," changed size between renders. The order and size of this array must remain constant.\nPrevious: ").concat(s.deps,"\nIncoming: ").concat(n)),null!=n&&null!=s.deps&&function(e,t){return e.length===t.length&&e.every((function(e,n){return e===t[n]}))}(n,s.deps)||(t(s),s.deps=n),s}throw v()}(e,(function(e){e.memoizedState=t()}),n).memoizedState}function g(e,t){return b(e,(function(){return{current:t}}),[])}function O(e,t){var n=g(e,"function"==typeof t?t():t);return[n.current,function(e){n.current="function"==typeof e?e(n.current):e,function(){var e=y();if(null!=e&&"NONE"!==e.currentPhase)e.hasUpdates=!0;else try{u.addons.getChannel().emit(s.FORCE_RE_RENDER)}catch(e){r.logger.warn("State updates of Storybook preview hooks work only in browser")}}()}]}function k(e,t){var n=m(),r=b("useEffect",(function(){return{create:e}}),t);n.currentEffects.includes(r)||n.currentEffects.push(r)}function E(){var e=m().currentContext;if(null==e)throw v();return e}}));t(d);d.useMemo,d.useCallback,d.useRef,d.useState,d.useReducer,d.useEffect,d.useChannel,d.useStoryContext,d.useParameter,d.applyHooks,d.HooksContext;var l=e((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n={};t.default=void 0,Object.keys(u).forEach((function(e){"default"!==e&&"__esModule"!==e&&(Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return u[e]}}))})),Object.keys(c).forEach((function(e){"default"!==e&&"__esModule"!==e&&(Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return c[e]}}))})),Object.keys(i).forEach((function(e){"default"!==e&&"__esModule"!==e&&(Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}}))})),Object.keys(f).forEach((function(e){"default"!==e&&"__esModule"!==e&&(Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return f[e]}}))})),Object.keys(d).forEach((function(e){"default"!==e&&"__esModule"!==e&&(Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return d[e]}}))}));var r=u.addons;t.default=r}));t(l);var h=l.makeDecorator,p=l.addons,v=l.AddonStore,y=l.mockChannel,m=l.HooksContext,b=l.useParameter,g=l.useStoryContext,O=l.useChannel,k=l.useEffect,E=l.useReducer,w=l.useState,_=l.useStateLike,j=l.triggerUpdate,P=l.useRef,S=l.useRefLike,C=l.useCallback,D=l.useMemo;export{h as a,p as b,v as c,y as d,m as e,b as f,g,O as h,k as i,E as j,w as k,_ as l,j as m,P as n,S as o,l as p,C as q,D as r};
//# sourceMappingURL=storybook-prebuilt-e856152c.js.map