UNPKG

vite-react-component-library-template

Version:

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

665 lines (661 loc) 21.5 kB
import Oe from "react"; function ur() { for (var E = [], b = 0; b < arguments.length; b++) E[b] = arguments[b]; for (var v = /* @__PURE__ */ new Set(), h = 0, R = E; h < R.length; h++) { var p = R[h]; if (typeof p == "string" && p.length > 0) v.add(p); else if (typeof p == "object") if (Array.isArray(p)) for (var m = 0, _ = p; m < _.length; m++) { var l = _[m]; l && v.add(l); } else for (var T in p) p[T] && v.add(T); } return Array.from(v).join(" "); } const sr = "_button_13oeq_1", fr = "_rounded_13oeq_18", lr = "_square_13oeq_23", Re = { button: sr, rounded: fr, square: lr }; var Ce = { 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 me; function cr() { if (me) return F; me = 1; var E = Oe, b = Symbol.for("react.element"), v = Symbol.for("react.fragment"), h = Object.prototype.hasOwnProperty, R = E.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 }; function m(_, l, T) { var g, O = {}, w = null, $ = null; T !== void 0 && (w = "" + T), l.key !== void 0 && (w = "" + l.key), l.ref !== void 0 && ($ = l.ref); for (g in l) h.call(l, g) && !p.hasOwnProperty(g) && (O[g] = l[g]); if (_ && _.defaultProps) for (g in l = _.defaultProps, l) O[g] === void 0 && (O[g] = l[g]); return { $$typeof: b, type: _, key: w, ref: $, props: O, _owner: R.current }; } return F.Fragment = v, 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 dr() { return Te || (Te = 1, process.env.NODE_ENV !== "production" && function() { var E = Oe, b = Symbol.for("react.element"), v = Symbol.for("react.portal"), h = Symbol.for("react.fragment"), R = Symbol.for("react.strict_mode"), p = Symbol.for("react.profiler"), m = Symbol.for("react.provider"), _ = Symbol.for("react.context"), l = Symbol.for("react.forward_ref"), T = Symbol.for("react.suspense"), g = Symbol.for("react.suspense_list"), O = Symbol.for("react.memo"), w = Symbol.for("react.lazy"), $ = Symbol.for("react.offscreen"), H = Symbol.iterator, Se = "@@iterator"; function we(e) { if (e === null || typeof e != "object") return null; var r = H && e[H] || e[Se]; return typeof r == "function" ? r : null; } var j = E.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; function c(e) { { for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++) t[n - 1] = arguments[n]; Pe("error", e, t); } } function Pe(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 je = !1, xe = !1, ke = !1, Ae = !1, De = !1, X; X = Symbol.for("react.module.reference"); function Fe(e) { return !!(typeof e == "string" || typeof e == "function" || e === h || e === p || De || e === R || e === T || e === g || Ae || e === $ || je || xe || ke || typeof e == "object" && e !== null && (e.$$typeof === w || e.$$typeof === O || e.$$typeof === m || e.$$typeof === _ || e.$$typeof === l || e.$$typeof === X || e.getModuleId !== void 0)); } function Ie(e, r, t) { var n = e.displayName; if (n) return n; var i = r.displayName || r.name || ""; return i !== "" ? t + "(" + i + ")" : t; } function Z(e) { return e.displayName || "Context"; } function C(e) { if (e == null) return null; if (typeof e.tag == "number" && c("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 v: return "Portal"; case p: return "Profiler"; case R: return "StrictMode"; case T: return "Suspense"; case g: return "SuspenseList"; } if (typeof e == "object") switch (e.$$typeof) { case _: var r = e; return Z(r) + ".Consumer"; case m: var t = e; return Z(t._context) + ".Provider"; case l: return Ie(e, e.render, "ForwardRef"); case O: var n = e.displayName || null; return n !== null ? n : C(e.type) || "Memo"; case w: { var i = e, u = i._payload, o = i._init; try { return C(o(u)); } catch { return null; } } } return null; } var P = Object.assign, A = 0, Q, ee, re, te, ne, ae, oe; function ie() { } ie.__reactDisabledLog = !0; function $e() { { if (A === 0) { Q = console.log, ee = console.info, re = console.warn, te = console.error, ne = console.group, ae = console.groupCollapsed, oe = console.groupEnd; var e = { configurable: !0, enumerable: !0, value: ie, writable: !0 }; Object.defineProperties(console, { info: e, log: e, warn: e, error: e, group: e, groupCollapsed: e, groupEnd: e }); } A++; } } function We() { { if (A--, A === 0) { var e = { configurable: !0, enumerable: !0, writable: !0 }; Object.defineProperties(console, { log: P({}, e, { value: Q }), info: P({}, e, { value: ee }), warn: P({}, e, { value: re }), error: P({}, e, { value: te }), group: P({}, e, { value: ne }), groupCollapsed: P({}, e, { value: ae }), groupEnd: P({}, e, { value: oe }) }); } A < 0 && c("disabledDepth fell below zero. This is a bug in React. Please file an issue."); } } var M = j.ReactCurrentDispatcher, U; function W(e, r, t) { { if (U === void 0) try { throw Error(); } catch (i) { var n = i.stack.trim().match(/\n( *(at )?)/); U = n && n[1] || ""; } return ` ` + U + e; } } var q = !1, Y; { var Ye = typeof WeakMap == "function" ? WeakMap : Map; Y = new Ye(); } function ue(e, r) { if (!e || q) return ""; { var t = Y.get(e); if (t !== void 0) return t; } var n; q = !0; var i = Error.prepareStackTrace; Error.prepareStackTrace = void 0; var u; u = M.current, M.current = null, $e(); 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 (S) { n = S; } Reflect.construct(e, [], o); } else { try { o.call(); } catch (S) { n = S; } e.call(o.prototype); } } else { try { throw Error(); } catch (S) { n = S; } e(); } } catch (S) { if (S && n && typeof S.stack == "string") { for (var a = S.stack.split(` `), d = n.stack.split(` `), s = a.length - 1, f = d.length - 1; s >= 1 && f >= 0 && a[s] !== d[f]; ) f--; for (; s >= 1 && f >= 0; s--, f--) if (a[s] !== d[f]) { if (s !== 1 || f !== 1) do if (s--, f--, f < 0 || a[s] !== d[f]) { var y = ` ` + a[s].replace(" at new ", " at "); return e.displayName && y.includes("<anonymous>") && (y = y.replace("<anonymous>", e.displayName)), typeof e == "function" && Y.set(e, y), y; } while (s >= 1 && f >= 0); break; } } } finally { q = !1, M.current = u, We(), Error.prepareStackTrace = i; } var k = e ? e.displayName || e.name : "", _e = k ? W(k) : ""; return typeof e == "function" && Y.set(e, _e), _e; } function Ne(e, r, t) { return ue(e, !1); } function Le(e) { var r = e.prototype; return !!(r && r.isReactComponent); } function N(e, r, t) { if (e == null) return ""; if (typeof e == "function") return ue(e, Le(e)); if (typeof e == "string") return W(e); switch (e) { case T: return W("Suspense"); case g: return W("SuspenseList"); } if (typeof e == "object") switch (e.$$typeof) { case l: return Ne(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 L = Object.prototype.hasOwnProperty, se = {}, fe = j.ReactDebugCurrentFrame; function V(e) { if (e) { var r = e._owner, t = N(e.type, e._source, r ? r.type : null); fe.setExtraStackFrame(t); } else fe.setExtraStackFrame(null); } function Ve(e, r, t, n, i) { { var u = Function.call.bind(L); for (var o in e) if (u(e, o)) { var a = void 0; try { if (typeof e[o] != "function") { var d = 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 d.name = "Invariant Violation", d; } 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) && (V(i), c("%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), V(null)), a instanceof Error && !(a.message in se) && (se[a.message] = !0, V(i), c("Failed %s type: %s", t, a.message), V(null)); } } } var Me = Array.isArray; function B(e) { return Me(e); } function Ue(e) { { var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object"; return t; } } function qe(e) { try { return le(e), !1; } catch { return !0; } } function le(e) { return "" + e; } function ce(e) { if (qe(e)) return c("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ue(e)), le(e); } var D = j.ReactCurrentOwner, Be = { key: !0, ref: !0, __self: !0, __source: !0 }, de, ve, J; J = {}; function Je(e) { if (L.call(e, "ref")) { var r = Object.getOwnPropertyDescriptor(e, "ref").get; if (r && r.isReactWarning) return !1; } return e.ref !== void 0; } function Ge(e) { if (L.call(e, "key")) { var r = Object.getOwnPropertyDescriptor(e, "key").get; if (r && r.isReactWarning) return !1; } return e.key !== void 0; } function ze(e, r) { if (typeof e.ref == "string" && D.current && r && D.current.stateNode !== r) { var t = C(D.current.type); J[t] || (c('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', C(D.current.type), e.ref), J[t] = !0); } } function Ke(e, r) { { var t = function() { de || (de = !0, c("%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 He(e, r) { { var t = function() { ve || (ve = !0, c("%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 Xe = 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 Ze(e, r, t, n, i) { { var u, o = {}, a = null, d = null; t !== void 0 && (ce(t), a = "" + t), Ge(r) && (ce(r.key), a = "" + r.key), Je(r) && (d = r.ref, ze(r, i)); for (u in r) L.call(r, u) && !Be.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 || d) { var f = typeof e == "function" ? e.displayName || e.name || "Unknown" : e; a && Ke(o, f), d && He(o, f); } return Xe(e, a, d, i, n, D.current, o); } } var G = j.ReactCurrentOwner, pe = j.ReactDebugCurrentFrame; function x(e) { if (e) { var r = e._owner, t = N(e.type, e._source, r ? r.type : null); pe.setExtraStackFrame(t); } else pe.setExtraStackFrame(null); } var z; z = !1; function K(e) { return typeof e == "object" && e !== null && e.$$typeof === b; } function ge() { { if (G.current) { var e = C(G.current.type); if (e) return ` Check the render method of \`` + e + "`."; } return ""; } } function Qe(e) { { if (e !== void 0) { var r = e.fileName.replace(/^.*[\\\/]/, ""), t = e.lineNumber; return ` Check your code at ` + r + ":" + t + "."; } return ""; } } var be = {}; function er(e) { { var r = ge(); 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 he(e, r) { { if (!e._store || e._store.validated || e.key != null) return; e._store.validated = !0; var t = er(r); if (be[t]) return; be[t] = !0; var n = ""; e && e._owner && e._owner !== G.current && (n = " It was passed a child from " + C(e._owner.type) + "."), x(e), c('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), x(null); } } function ye(e, r) { { if (typeof e != "object") return; if (B(e)) for (var t = 0; t < e.length; t++) { var n = e[t]; K(n) && he(n, r); } else if (K(e)) e._store && (e._store.validated = !0); else if (e) { var i = we(e); if (typeof i == "function" && i !== e.entries) for (var u = i.call(e), o; !(o = u.next()).done; ) K(o.value) && he(o.value, r); } } } function rr(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 = C(r); Ve(t, e.props, "prop", n, e); } else if (r.PropTypes !== void 0 && !z) { z = !0; var i = C(r); c("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", i || "Unknown"); } typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && c("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); } } function tr(e) { { for (var r = Object.keys(e.props), t = 0; t < r.length; t++) { var n = r[t]; if (n !== "children" && n !== "key") { x(e), c("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), x(null); break; } } e.ref !== null && (x(e), c("Invalid attribute `ref` supplied to `React.Fragment`."), x(null)); } } function Ee(e, r, t, n, i, u) { { var o = Fe(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 d = Qe(i); d ? a += d : a += ge(); var s; e === null ? s = "null" : B(e) ? s = "array" : e !== void 0 && e.$$typeof === b ? (s = "<" + (C(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : s = typeof e, c("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 = Ze(e, r, t, i, u); if (f == null) return f; if (o) { var y = r.children; if (y !== void 0) if (n) if (B(y)) { for (var k = 0; k < y.length; k++) ye(y[k], e); Object.freeze && Object.freeze(y); } else c("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 ye(y, e); } return e === h ? tr(f) : rr(f), f; } } function nr(e, r, t) { return Ee(e, r, t, !0); } function ar(e, r, t) { return Ee(e, r, t, !1); } var or = ar, ir = nr; I.Fragment = h, I.jsx = or, I.jsxs = ir; }()), I; } (function(E) { process.env.NODE_ENV === "production" ? E.exports = cr() : E.exports = dr(); })(Ce); const vr = Ce.exports.jsx; function gr({ text: E, onClick: b, mode: v = "rounded", ...h }) { const R = ur(Re.button, { [Re[v != null ? v : ""]]: v }); return /* @__PURE__ */ vr("button", { className: R, onClick: b, ...h, children: E }); } export { gr as Button };