UNPKG

react-kit-us-abc

Version:

A beautiful, customizable React Button component built with TailwindCSS and TypeScript

31 lines (28 loc) 14.8 kB
(function(_,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],P):(_=typeof globalThis<"u"?globalThis:_||self,P(_.ReactKitUSABC={},_.React))})(this,function(_,P){"use strict";var L={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 ee;function Pe(){if(ee)return F;ee=1;var I=P,T=Symbol.for("react.element"),$=Symbol.for("react.fragment"),y=Object.prototype.hasOwnProperty,m=I.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,x={key:!0,ref:!0,__self:!0,__source:!0};function w(g,f,R){var c,h={},O=null,U=null;R!==void 0&&(O=""+R),f.key!==void 0&&(O=""+f.key),f.ref!==void 0&&(U=f.ref);for(c in f)y.call(f,c)&&!x.hasOwnProperty(c)&&(h[c]=f[c]);if(g&&g.defaultProps)for(c in f=g.defaultProps,f)h[c]===void 0&&(h[c]=f[c]);return{$$typeof:T,type:g,key:O,ref:U,props:h,_owner:m.current}}return F.Fragment=$,F.jsx=w,F.jsxs=w,F}var A={};/** * @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 re;function je(){return re||(re=1,process.env.NODE_ENV!=="production"&&function(){var I=P,T=Symbol.for("react.element"),$=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),w=Symbol.for("react.provider"),g=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),U=Symbol.for("react.offscreen"),ne=Symbol.iterator,Ie="@@iterator";function $e(e){if(e===null||typeof e!="object")return null;var r=ne&&e[ne]||e[Ie];return typeof r=="function"?r:null}var j=I.__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];We("error",e,t)}}function We(e,r,t){{var n=j.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 Ye=!1,Le=!1,Me=!1,Ue=!1,Ve=!1,ae;ae=Symbol.for("react.module.reference");function Ne(e){return!!(typeof e=="string"||typeof e=="function"||e===y||e===x||Ve||e===m||e===R||e===c||Ue||e===U||Ye||Le||Me||typeof e=="object"&&e!==null&&(e.$$typeof===O||e.$$typeof===h||e.$$typeof===w||e.$$typeof===g||e.$$typeof===f||e.$$typeof===ae||e.getModuleId!==void 0))}function Be(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 E(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 y:return"Fragment";case $:return"Portal";case x:return"Profiler";case m:return"StrictMode";case R:return"Suspense";case c:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case g:var r=e;return oe(r)+".Consumer";case w:var t=e;return oe(t._context)+".Provider";case f:return Be(e,e.render,"ForwardRef");case h:var n=e.displayName||null;return n!==null?n:E(e.type)||"Memo";case O:{var i=e,u=i._payload,o=i._init;try{return E(o(u))}catch{return null}}}return null}var C=Object.assign,W=0,ie,ue,se,le,fe,ce,de;function ve(){}ve.__reactDisabledLog=!0;function Je(){{if(W===0){ie=console.log,ue=console.info,se=console.warn,le=console.error,fe=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})}W++}}function qe(){{if(W--,W===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:C({},e,{value:ie}),info:C({},e,{value:ue}),warn:C({},e,{value:se}),error:C({},e,{value:le}),group:C({},e,{value:fe}),groupCollapsed:C({},e,{value:ce}),groupEnd:C({},e,{value:de})})}W<0&&d("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var q=j.ReactCurrentDispatcher,K;function V(e,r,t){{if(K===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);K=n&&n[1]||""}return` `+K+e}}var z=!1,N;{var Ke=typeof WeakMap=="function"?WeakMap:Map;N=new Ke}function pe(e,r){if(!e||z)return"";{var t=N.get(e);if(t!==void 0)return t}var n;z=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=q.current,q.current=null,Je();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(p){n=p}Reflect.construct(e,[],o)}else{try{o.call()}catch(p){n=p}e.call(o.prototype)}}else{try{throw Error()}catch(p){n=p}e()}}catch(p){if(p&&n&&typeof p.stack=="string"){for(var a=p.stack.split(` `),v=n.stack.split(` `),s=a.length-1,l=v.length-1;s>=1&&l>=0&&a[s]!==v[l];)l--;for(;s>=1&&l>=0;s--,l--)if(a[s]!==v[l]){if(s!==1||l!==1)do if(s--,l--,l<0||a[s]!==v[l]){var b=` `+a[s].replace(" at new "," at ");return e.displayName&&b.includes("<anonymous>")&&(b=b.replace("<anonymous>",e.displayName)),typeof e=="function"&&N.set(e,b),b}while(s>=1&&l>=0);break}}}finally{z=!1,q.current=u,qe(),Error.prepareStackTrace=i}var D=e?e.displayName||e.name:"",S=D?V(D):"";return typeof e=="function"&&N.set(e,S),S}function ze(e,r,t){return pe(e,!1)}function Ge(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function B(e,r,t){if(e==null)return"";if(typeof e=="function")return pe(e,Ge(e));if(typeof e=="string")return V(e);switch(e){case R:return V("Suspense");case c:return V("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case f:return ze(e.render);case h:return B(e.type,r,t);case O:{var n=e,i=n._payload,u=n._init;try{return B(u(i),r,t)}catch{}}}return""}var Y=Object.prototype.hasOwnProperty,be={},ge=j.ReactDebugCurrentFrame;function J(e){if(e){var r=e._owner,t=B(e.type,e._source,r?r.type:null);ge.setExtraStackFrame(t)}else ge.setExtraStackFrame(null)}function Xe(e,r,t,n,i){{var u=Function.call.bind(Y);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)&&(J(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),J(null)),a instanceof Error&&!(a.message in be)&&(be[a.message]=!0,J(i),d("Failed %s type: %s",t,a.message),J(null))}}}var He=Array.isArray;function G(e){return He(e)}function Ze(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function Qe(e){try{return he(e),!1}catch{return!0}}function he(e){return""+e}function ye(e){if(Qe(e))return d("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ze(e)),he(e)}var me=j.ReactCurrentOwner,er={key:!0,ref:!0,__self:!0,__source:!0},Re,Ee;function rr(e){if(Y.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function tr(e){if(Y.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function nr(e,r){typeof e.ref=="string"&&me.current}function ar(e,r){{var t=function(){Re||(Re=!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 or(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 ir=function(e,r,t,n,i,u,o){var a={$$typeof:T,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 ur(e,r,t,n,i){{var u,o={},a=null,v=null;t!==void 0&&(ye(t),a=""+t),tr(r)&&(ye(r.key),a=""+r.key),rr(r)&&(v=r.ref,nr(r,i));for(u in r)Y.call(r,u)&&!er.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 l=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&ar(o,l),v&&or(o,l)}return ir(e,a,v,i,n,me.current,o)}}var X=j.ReactCurrentOwner,_e=j.ReactDebugCurrentFrame;function k(e){if(e){var r=e._owner,t=B(e.type,e._source,r?r.type:null);_e.setExtraStackFrame(t)}else _e.setExtraStackFrame(null)}var H;H=!1;function Z(e){return typeof e=="object"&&e!==null&&e.$$typeof===T}function Te(){{if(X.current){var e=E(X.current.type);if(e)return` Check the render method of \``+e+"`."}return""}}function sr(e){return""}var xe={};function lr(e){{var r=Te();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 we(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=lr(r);if(xe[t])return;xe[t]=!0;var n="";e&&e._owner&&e._owner!==X.current&&(n=" It was passed a child from "+E(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 Oe(e,r){{if(typeof e!="object")return;if(G(e))for(var t=0;t<e.length;t++){var n=e[t];Z(n)&&we(n,r)}else if(Z(e))e._store&&(e._store.validated=!0);else if(e){var i=$e(e);if(typeof i=="function"&&i!==e.entries)for(var u=i.call(e),o;!(o=u.next()).done;)Z(o.value)&&we(o.value,r)}}}function fr(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===f||r.$$typeof===h))t=r.propTypes;else return;if(t){var n=E(r);Xe(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!H){H=!0;var i=E(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 cr(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))}}var Ce={};function Se(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=sr();v?a+=v:a+=Te();var s;e===null?s="null":G(e)?s="array":e!==void 0&&e.$$typeof===T?(s="<"+(E(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 l=ur(e,r,t,i,u);if(l==null)return l;if(o){var b=r.children;if(b!==void 0)if(n)if(G(b)){for(var D=0;D<b.length;D++)Oe(b[D],e);Object.freeze&&Object.freeze(b)}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 Oe(b,e)}if(Y.call(r,"key")){var S=E(e),p=Object.keys(r).filter(function(hr){return hr!=="key"}),Q=p.length>0?"{key: someKey, "+p.join(": ..., ")+": ...}":"{key: someKey}";if(!Ce[S+Q]){var gr=p.length>0?"{"+p.join(": ..., ")+": ...}":"{}";d(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`,Q,S,gr,S),Ce[S+Q]=!0}}return e===y?cr(l):fr(l),l}}function dr(e,r,t){return Se(e,r,t,!0)}function vr(e,r,t){return Se(e,r,t,!1)}var pr=vr,br=dr;A.Fragment=y,A.jsx=pr,A.jsxs=br}()),A}var te;function ke(){return te||(te=1,process.env.NODE_ENV==="production"?L.exports=Pe():L.exports=je()),L.exports}var M=ke();const De={primary:"bg-blue-500 hover:bg-blue-600 text-white",secondary:"bg-gray-500 hover:bg-gray-600 text-white",success:"bg-green-500 hover:bg-green-600 text-white",danger:"bg-red-500 hover:bg-red-600 text-white",warning:"bg-yellow-500 hover:bg-yellow-600 text-white",outline:"bg-transparent border border-blue-500 text-blue-500 hover:bg-blue-500 hover:text-white"},Fe={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg"},Ae=({children:I,variant:T="primary",size:$="md",className:y="",loading:m=!1,disabled:x,...w})=>{const g="rounded font-medium transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",f=De[T],R=Fe[$],c=x||m?"opacity-50 cursor-not-allowed":"";return M.jsx("button",{className:`${g} ${f} ${R} ${c} ${y}`,disabled:x||m,...w,children:m?M.jsxs("div",{className:"flex items-center gap-2",children:[M.jsx("div",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),M.jsx("span",{children:"Loading..."})]}):I})};_.Button=Ae,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});