UNPKG

vite-react-component-library-template

Version:

Vite template for building a React library component. TypeScript, SASS and Storybook.

28 lines (24 loc) 14.6 kB
(function(P,A){typeof exports=="object"&&typeof module<"u"?A(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],A):(P=typeof globalThis<"u"?globalThis:P||self,A(P.MyComponent={},P.React))})(this,function(P,A){"use strict";const Z=(c=>c&&typeof c=="object"&&"default"in c?c:{default:c})(A);function we(){for(var c=[],b=0;b<arguments.length;b++)c[b]=arguments[b];for(var p=new Set,h=0,R=c;h<R.length;h++){var g=R[h];if(typeof g=="string"&&g.length>0)p.add(g);else if(typeof g=="object")if(Array.isArray(g))for(var m=0,E=g;m<E.length;m++){var l=E[m];l&&p.add(l)}else for(var T in g)g[T]&&p.add(T)}return Array.from(p).join(" ")}const Q={button:"_button_13oeq_1",rounded:"_rounded_13oeq_18",square:"_square_13oeq_23"};var ee={exports:{}},F={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var re;function je(){if(re)return F;re=1;var c=Z.default,b=Symbol.for("react.element"),p=Symbol.for("react.fragment"),h=Object.prototype.hasOwnProperty,R=c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,g={key:!0,ref:!0,__self:!0,__source:!0};function m(E,l,T){var y,O={},w=null,Y=null;T!==void 0&&(w=""+T),l.key!==void 0&&(w=""+l.key),l.ref!==void 0&&(Y=l.ref);for(y in l)h.call(l,y)&&!g.hasOwnProperty(y)&&(O[y]=l[y]);if(E&&E.defaultProps)for(y in l=E.defaultProps,l)O[y]===void 0&&(O[y]=l[y]);return{$$typeof:b,type:E,key:w,ref:Y,props:O,_owner:R.current}}return F.Fragment=p,F.jsx=m,F.jsxs=m,F}var I={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var te;function xe(){return te||(te=1,process.env.NODE_ENV!=="production"&&function(){var c=Z.default,b=Symbol.for("react.element"),p=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),g=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),E=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),y=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),Y=Symbol.for("react.offscreen"),ne=Symbol.iterator,Ae="@@iterator";function Fe(e){if(e===null||typeof e!="object")return null;var r=ne&&e[ne]||e[Ae];return typeof r=="function"?r:null}var x=c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function d(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];Ie("error",e,t)}}function Ie(e,r,t){{var n=x.ReactDebugCurrentFrame,i=n.getStackAddendum();i!==""&&(r+="%s",t=t.concat([i]));var u=t.map(function(o){return String(o)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var $e=!1,We=!1,Ye=!1,Le=!1,Me=!1,ae;ae=Symbol.for("react.module.reference");function Ne(e){return!!(typeof e=="string"||typeof e=="function"||e===h||e===g||Me||e===R||e===T||e===y||Le||e===Y||$e||We||Ye||typeof e=="object"&&e!==null&&(e.$$typeof===w||e.$$typeof===O||e.$$typeof===m||e.$$typeof===E||e.$$typeof===l||e.$$typeof===ae||e.getModuleId!==void 0))}function Ve(e,r,t){var n=e.displayName;if(n)return n;var i=r.displayName||r.name||"";return i!==""?t+"("+i+")":t}function oe(e){return e.displayName||"Context"}function S(e){if(e==null)return null;if(typeof e.tag=="number"&&d("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case h:return"Fragment";case p:return"Portal";case g:return"Profiler";case R:return"StrictMode";case T:return"Suspense";case y:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case E:var r=e;return oe(r)+".Consumer";case m:var t=e;return oe(t._context)+".Provider";case l:return Ve(e,e.render,"ForwardRef");case O:var n=e.displayName||null;return n!==null?n:S(e.type)||"Memo";case w:{var i=e,u=i._payload,o=i._init;try{return S(o(u))}catch{return null}}}return null}var j=Object.assign,$=0,ie,ue,se,fe,le,ce,de;function ve(){}ve.__reactDisabledLog=!0;function qe(){{if($===0){ie=console.log,ue=console.info,se=console.warn,fe=console.error,le=console.group,ce=console.groupCollapsed,de=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ve,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}$++}}function Ue(){{if($--,$===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:j({},e,{value:ie}),info:j({},e,{value:ue}),warn:j({},e,{value:se}),error:j({},e,{value:fe}),group:j({},e,{value:le}),groupCollapsed:j({},e,{value:ce}),groupEnd:j({},e,{value:de})})}$<0&&d("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var U=x.ReactCurrentDispatcher,B;function L(e,r,t){{if(B===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);B=n&&n[1]||""}return` `+B+e}}var J=!1,M;{var Be=typeof WeakMap=="function"?WeakMap:Map;M=new Be}function pe(e,r){if(!e||J)return"";{var t=M.get(e);if(t!==void 0)return t}var n;J=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=U.current,U.current=null,qe();try{if(r){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(C){n=C}Reflect.construct(e,[],o)}else{try{o.call()}catch(C){n=C}e.call(o.prototype)}}else{try{throw Error()}catch(C){n=C}e()}}catch(C){if(C&&n&&typeof C.stack=="string"){for(var a=C.stack.split(` `),v=n.stack.split(` `),s=a.length-1,f=v.length-1;s>=1&&f>=0&&a[s]!==v[f];)f--;for(;s>=1&&f>=0;s--,f--)if(a[s]!==v[f]){if(s!==1||f!==1)do if(s--,f--,f<0||a[s]!==v[f]){var _=` `+a[s].replace(" at new "," at ");return e.displayName&&_.includes("<anonymous>")&&(_=_.replace("<anonymous>",e.displayName)),typeof e=="function"&&M.set(e,_),_}while(s>=1&&f>=0);break}}}finally{J=!1,U.current=u,Ue(),Error.prepareStackTrace=i}var D=e?e.displayName||e.name:"",Pe=D?L(D):"";return typeof e=="function"&&M.set(e,Pe),Pe}function Je(e,r,t){return pe(e,!1)}function Ge(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function N(e,r,t){if(e==null)return"";if(typeof e=="function")return pe(e,Ge(e));if(typeof e=="string")return L(e);switch(e){case T:return L("Suspense");case y:return L("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case l:return Je(e.render);case O:return N(e.type,r,t);case w:{var n=e,i=n._payload,u=n._init;try{return N(u(i),r,t)}catch{}}}return""}var V=Object.prototype.hasOwnProperty,ge={},ye=x.ReactDebugCurrentFrame;function q(e){if(e){var r=e._owner,t=N(e.type,e._source,r?r.type:null);ye.setExtraStackFrame(t)}else ye.setExtraStackFrame(null)}function ze(e,r,t,n,i){{var u=Function.call.bind(V);for(var o in e)if(u(e,o)){var a=void 0;try{if(typeof e[o]!="function"){var v=Error((n||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}a=e[o](r,o,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(s){a=s}a&&!(a instanceof Error)&&(q(i),d("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,o,typeof a),q(null)),a instanceof Error&&!(a.message in ge)&&(ge[a.message]=!0,q(i),d("Failed %s type: %s",t,a.message),q(null))}}}var Ke=Array.isArray;function G(e){return Ke(e)}function He(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function Xe(e){try{return be(e),!1}catch{return!0}}function be(e){return""+e}function he(e){if(Xe(e))return d("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",He(e)),be(e)}var W=x.ReactCurrentOwner,Ze={key:!0,ref:!0,__self:!0,__source:!0},_e,Ee,z;z={};function Qe(e){if(V.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function er(e){if(V.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function rr(e,r){if(typeof e.ref=="string"&&W.current&&r&&W.current.stateNode!==r){var t=S(W.current.type);z[t]||(d('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',S(W.current.type),e.ref),z[t]=!0)}}function tr(e,r){{var t=function(){_e||(_e=!0,d("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function nr(e,r){{var t=function(){Ee||(Ee=!0,d("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var ar=function(e,r,t,n,i,u,o){var a={$$typeof:b,type:e,key:r,ref:t,props:o,_owner:u};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function or(e,r,t,n,i){{var u,o={},a=null,v=null;t!==void 0&&(he(t),a=""+t),er(r)&&(he(r.key),a=""+r.key),Qe(r)&&(v=r.ref,rr(r,i));for(u in r)V.call(r,u)&&!Ze.hasOwnProperty(u)&&(o[u]=r[u]);if(e&&e.defaultProps){var s=e.defaultProps;for(u in s)o[u]===void 0&&(o[u]=s[u])}if(a||v){var f=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&tr(o,f),v&&nr(o,f)}return ar(e,a,v,i,n,W.current,o)}}var K=x.ReactCurrentOwner,Re=x.ReactDebugCurrentFrame;function k(e){if(e){var r=e._owner,t=N(e.type,e._source,r?r.type:null);Re.setExtraStackFrame(t)}else Re.setExtraStackFrame(null)}var H;H=!1;function X(e){return typeof e=="object"&&e!==null&&e.$$typeof===b}function me(){{if(K.current){var e=S(K.current.type);if(e)return` Check the render method of \``+e+"`."}return""}}function ir(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return` Check your code at `+r+":"+t+"."}return""}}var Te={};function ur(e){{var r=me();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=` Check the top-level render call using <`+t+">.")}return r}}function Oe(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=ur(r);if(Te[t])return;Te[t]=!0;var n="";e&&e._owner&&e._owner!==K.current&&(n=" It was passed a child from "+S(e._owner.type)+"."),k(e),d('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),k(null)}}function Se(e,r){{if(typeof e!="object")return;if(G(e))for(var t=0;t<e.length;t++){var n=e[t];X(n)&&Oe(n,r)}else if(X(e))e._store&&(e._store.validated=!0);else if(e){var i=Fe(e);if(typeof i=="function"&&i!==e.entries)for(var u=i.call(e),o;!(o=u.next()).done;)X(o.value)&&Oe(o.value,r)}}}function sr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===l||r.$$typeof===O))t=r.propTypes;else return;if(t){var n=S(r);ze(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!H){H=!0;var i=S(r);d("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",i||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&d("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function fr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){k(e),d("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),k(null);break}}e.ref!==null&&(k(e),d("Invalid attribute `ref` supplied to `React.Fragment`."),k(null))}}function Ce(e,r,t,n,i,u){{var o=Ne(e);if(!o){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var v=ir(i);v?a+=v:a+=me();var s;e===null?s="null":G(e)?s="array":e!==void 0&&e.$$typeof===b?(s="<"+(S(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):s=typeof e,d("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",s,a)}var f=or(e,r,t,i,u);if(f==null)return f;if(o){var _=r.children;if(_!==void 0)if(n)if(G(_)){for(var D=0;D<_.length;D++)Se(_[D],e);Object.freeze&&Object.freeze(_)}else d("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Se(_,e)}return e===h?fr(f):sr(f),f}}function lr(e,r,t){return Ce(e,r,t,!0)}function cr(e,r,t){return Ce(e,r,t,!1)}var dr=cr,vr=lr;I.Fragment=h,I.jsx=dr,I.jsxs=vr}()),I}(function(c){process.env.NODE_ENV==="production"?c.exports=je():c.exports=xe()})(ee);const ke=ee.exports.jsx;function De({text:c,onClick:b,mode:p="rounded",...h}){const R=we(Q.button,{[Q[p!=null?p:""]]:p});return ke("button",{className:R,onClick:b,...h,children:c})}P.Button=De,Object.defineProperties(P,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});