UNPKG

dgz-ui-shared

Version:

Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript, dgz-ui library

731 lines (730 loc) 24.3 kB
import * as i from "react"; import ve from "react"; import * as be from "react-dom"; var V = { exports: {} }, C = {}; /** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and 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 ge() { if (te) return C; te = 1; var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment"); function s(r, o, a) { var u = null; if (a !== void 0 && (u = "" + a), o.key !== void 0 && (u = "" + o.key), "key" in o) { a = {}; for (var l in o) l !== "key" && (a[l] = o[l]); } else a = o; return o = a.ref, { $$typeof: e, type: r, key: u, ref: o !== void 0 ? o : null, props: a }; } return C.Fragment = t, C.jsx = s, C.jsxs = s, C; } var T = {}; /** * @license React * react-jsx-runtime.development.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var ne; function he() { return ne || (ne = 1, process.env.NODE_ENV !== "production" && function() { function e(n) { if (n == null) return null; if (typeof n == "function") return n.$$typeof === pe ? null : n.displayName || n.name || null; if (typeof n == "string") return n; switch (n) { case _: return "Fragment"; case $: return "Profiler"; case P: return "StrictMode"; case R: return "Suspense"; case v: return "SuspenseList"; case I: return "Activity"; } if (typeof n == "object") switch (typeof n.tag == "number" && console.error( "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue." ), n.$$typeof) { case w: return "Portal"; case x: return n.displayName || "Context"; case M: return (n._context.displayName || "Context") + ".Consumer"; case A: var f = n.render; return n = n.displayName, n || (n = f.displayName || f.name || "", n = n !== "" ? "ForwardRef(" + n + ")" : "ForwardRef"), n; case j: return f = n.displayName || null, f !== null ? f : e(n.type) || "Memo"; case S: f = n._payload, n = n._init; try { return e(n(f)); } catch { } } return null; } function t(n) { return "" + n; } function s(n) { try { t(n); var f = !1; } catch { f = !0; } if (f) { f = console; var b = f.error, g = typeof Symbol == "function" && Symbol.toStringTag && n[Symbol.toStringTag] || n.constructor.name || "Object"; return b.call( f, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", g ), t(n); } } function r(n) { if (n === _) return "<>"; if (typeof n == "object" && n !== null && n.$$typeof === S) return "<...>"; try { var f = e(n); return f ? "<" + f + ">" : "<...>"; } catch { return "<...>"; } } function o() { var n = F.A; return n === null ? null : n.getOwner(); } function a() { return Error("react-stack-top-frame"); } function u(n) { if (H.call(n, "key")) { var f = Object.getOwnPropertyDescriptor(n, "key").get; if (f && f.isReactWarning) return !1; } return n.key !== void 0; } function l(n, f) { function b() { q || (q = !0, console.error( "%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://react.dev/link/special-props)", f )); } b.isReactWarning = !0, Object.defineProperty(n, "key", { get: b, configurable: !0 }); } function p() { var n = e(this.type); return G[n] || (G[n] = !0, console.error( "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release." )), n = this.props.ref, n !== void 0 ? n : null; } function c(n, f, b, g, U, z) { var h = b.ref; return n = { $$typeof: O, type: n, key: f, props: b, _owner: g }, (h !== void 0 ? h : null) !== null ? Object.defineProperty(n, "ref", { enumerable: !1, get: p }) : Object.defineProperty(n, "ref", { enumerable: !1, value: null }), n._store = {}, Object.defineProperty(n._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: 0 }), Object.defineProperty(n, "_debugInfo", { configurable: !1, enumerable: !1, writable: !0, value: null }), Object.defineProperty(n, "_debugStack", { configurable: !1, enumerable: !1, writable: !0, value: U }), Object.defineProperty(n, "_debugTask", { configurable: !1, enumerable: !1, writable: !0, value: z }), Object.freeze && (Object.freeze(n.props), Object.freeze(n)), n; } function d(n, f, b, g, U, z) { var h = f.children; if (h !== void 0) if (g) if (me(h)) { for (g = 0; g < h.length; g++) y(h[g]); Object.freeze && Object.freeze(h); } else console.error( "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 y(h); if (H.call(f, "key")) { h = e(n); var k = Object.keys(f).filter(function(ye) { return ye !== "key"; }); g = 0 < k.length ? "{key: someKey, " + k.join(": ..., ") + ": ...}" : "{key: someKey}", ee[h + g] || (k = 0 < k.length ? "{" + k.join(": ..., ") + ": ...}" : "{}", console.error( `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} />`, g, h, k, h ), ee[h + g] = !0); } if (h = null, b !== void 0 && (s(b), h = "" + b), u(f) && (s(f.key), h = "" + f.key), "key" in f) { b = {}; for (var B in f) B !== "key" && (b[B] = f[B]); } else b = f; return h && l( b, typeof n == "function" ? n.displayName || n.name || "Unknown" : n ), c( n, h, b, o(), U, z ); } function y(n) { m(n) ? n._store && (n._store.validated = 1) : typeof n == "object" && n !== null && n.$$typeof === S && (n._payload.status === "fulfilled" ? m(n._payload.value) && n._payload.value._store && (n._payload.value._store.validated = 1) : n._store && (n._store.validated = 1)); } function m(n) { return typeof n == "object" && n !== null && n.$$typeof === O; } var E = ve, O = Symbol.for("react.transitional.element"), w = Symbol.for("react.portal"), _ = Symbol.for("react.fragment"), P = Symbol.for("react.strict_mode"), $ = Symbol.for("react.profiler"), M = Symbol.for("react.consumer"), x = Symbol.for("react.context"), A = Symbol.for("react.forward_ref"), R = Symbol.for("react.suspense"), v = Symbol.for("react.suspense_list"), j = Symbol.for("react.memo"), S = Symbol.for("react.lazy"), I = Symbol.for("react.activity"), pe = Symbol.for("react.client.reference"), F = E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, H = Object.prototype.hasOwnProperty, me = Array.isArray, W = console.createTask ? console.createTask : function() { return null; }; E = { react_stack_bottom_frame: function(n) { return n(); } }; var q, G = {}, Z = E.react_stack_bottom_frame.bind( E, a )(), Q = W(r(a)), ee = {}; T.Fragment = _, T.jsx = function(n, f, b) { var g = 1e4 > F.recentlyCreatedOwnerStacks++; return d( n, f, b, !1, g ? Error("react-stack-top-frame") : Z, g ? W(r(n)) : Q ); }, T.jsxs = function(n, f, b) { var g = 1e4 > F.recentlyCreatedOwnerStacks++; return d( n, f, b, !0, g ? Error("react-stack-top-frame") : Z, g ? W(r(n)) : Q ); }; }()), T; } var re; function Ee() { return re || (re = 1, process.env.NODE_ENV === "production" ? V.exports = ge() : V.exports = he()), V.exports; } var N = Ee(); function Je(e, t) { const s = i.createContext(t), r = (a) => { const { children: u, ...l } = a, p = i.useMemo(() => l, Object.values(l)); return /* @__PURE__ */ N.jsx(s.Provider, { value: p, children: u }); }; r.displayName = e + "Provider"; function o(a) { const u = i.useContext(s); if (u) return u; if (t !== void 0) return t; throw new Error(`\`${a}\` must be used within \`${e}\``); } return [r, o]; } function Ye(e, t = []) { let s = []; function r(a, u) { const l = i.createContext(u), p = s.length; s = [...s, u]; const c = (y) => { var m; const { scope: E, children: O, ...w } = y, _ = ((m = E == null ? void 0 : E[e]) == null ? void 0 : m[p]) || l, P = i.useMemo(() => w, Object.values(w)); return /* @__PURE__ */ N.jsx(_.Provider, { value: P, children: O }); }; c.displayName = a + "Provider"; function d(y, m) { var E; const O = ((E = m == null ? void 0 : m[e]) == null ? void 0 : E[p]) || l, w = i.useContext(O); if (w) return w; if (u !== void 0) return u; throw new Error(`\`${y}\` must be used within \`${a}\``); } return [c, d]; } const o = () => { const a = s.map((u) => i.createContext(u)); return function(u) { const l = (u == null ? void 0 : u[e]) || a; return i.useMemo( () => ({ [`__scope${e}`]: { ...u, [e]: l } }), [u, l] ); }; }; return o.scopeName = e, [r, we(o, ...t)]; } function we(...e) { const t = e[0]; if (e.length === 1) return t; const s = () => { const r = e.map((o) => ({ useScope: o(), scopeName: o.scopeName })); return function(o) { const a = r.reduce((u, { useScope: l, scopeName: p }) => { const c = l(o)[`__scope${p}`]; return { ...u, ...c }; }, {}); return i.useMemo(() => ({ [`__scope${t.scopeName}`]: a }), [a]); }; }; return s.scopeName = t.scopeName, s; } var L = globalThis != null && globalThis.document ? i.useLayoutEffect : () => { }; function oe(e, t) { if (typeof e == "function") return e(t); e != null && (e.current = t); } function ie(...e) { return (t) => { let s = !1; const r = e.map((o) => { const a = oe(o, t); return !s && typeof a == "function" && (s = !0), a; }); if (s) return () => { for (let o = 0; o < r.length; o++) { const a = r[o]; typeof a == "function" ? a() : oe(e[o], null); } }; }; } function J(...e) { return i.useCallback(ie(...e), e); } function K(e, t, { checkForDefaultPrevented: s = !0 } = {}) { return function(r) { if (e == null || e(r), s === !1 || !r.defaultPrevented) return t == null ? void 0 : t(r); }; } function Oe(e, t) { return i.useReducer((s, r) => t[s][r] ?? s, e); } var Ne = (e) => { const { present: t, children: s } = e, r = _e(t), o = typeof s == "function" ? s({ present: r.isPresent }) : i.Children.only(s), a = J(r.ref, Se(o)); return typeof s == "function" || r.isPresent ? i.cloneElement(o, { ref: a }) : null; }; Ne.displayName = "Presence"; function _e(e) { const [t, s] = i.useState(), r = i.useRef(null), o = i.useRef(e), a = i.useRef("none"), u = e ? "mounted" : "unmounted", [l, p] = Oe(u, { mounted: { UNMOUNT: "unmounted", ANIMATION_OUT: "unmountSuspended" }, unmountSuspended: { MOUNT: "mounted", ANIMATION_END: "unmounted" }, unmounted: { MOUNT: "mounted" } }); return i.useEffect(() => { const c = D(r.current); a.current = l === "mounted" ? c : "none"; }, [l]), L(() => { const c = r.current, d = o.current; if (d !== e) { const y = a.current, m = D(c); e ? p("MOUNT") : m === "none" || (c == null ? void 0 : c.display) === "none" ? p("UNMOUNT") : p(d && y !== m ? "ANIMATION_OUT" : "UNMOUNT"), o.current = e; } }, [e, p]), L(() => { if (t) { let c; const d = t.ownerDocument.defaultView ?? window, y = (E) => { const O = D(r.current).includes(E.animationName); if (E.target === t && O && (p("ANIMATION_END"), !o.current)) { const w = t.style.animationFillMode; t.style.animationFillMode = "forwards", c = d.setTimeout(() => { t.style.animationFillMode === "forwards" && (t.style.animationFillMode = w); }); } }, m = (E) => { E.target === t && (a.current = D(r.current)); }; return t.addEventListener("animationstart", m), t.addEventListener("animationcancel", y), t.addEventListener("animationend", y), () => { d.clearTimeout(c), t.removeEventListener("animationstart", m), t.removeEventListener("animationcancel", y), t.removeEventListener("animationend", y); }; } else p("ANIMATION_END"); }, [t, p]), { isPresent: ["mounted", "unmountSuspended"].includes(l), ref: i.useCallback((c) => { r.current = c ? getComputedStyle(c) : null, s(c); }, []) }; } function D(e) { return (e == null ? void 0 : e.animationName) || "none"; } function Se(e) { var t, s; let r = (t = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : t.get, o = r && "isReactWarning" in r && r.isReactWarning; return o ? e.ref : (r = (s = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : s.get, o = r && "isReactWarning" in r && r.isReactWarning, o ? e.props.ref : e.props.ref || e.ref); } var ke = i[" useId ".trim().toString()] || (() => { }), Pe = 0; function He(e) { const [t, s] = i.useState(ke()); return L(() => { s((r) => r ?? String(Pe++)); }, [e]), t ? `radix-${t}` : ""; } var je = i[" useInsertionEffect ".trim().toString()] || L; function qe({ prop: e, defaultProp: t, onChange: s = () => { }, caller: r }) { const [o, a, u] = Ce({ defaultProp: t, onChange: s }), l = e !== void 0, p = l ? e : o; { const d = i.useRef(e !== void 0); i.useEffect(() => { const y = d.current; y !== l && console.warn( `${r} is changing from ${y ? "controlled" : "uncontrolled"} to ${l ? "controlled" : "uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.` ), d.current = l; }, [l, r]); } const c = i.useCallback( (d) => { var y; if (l) { const m = $e(d) ? d(e) : d; m !== e && ((y = u.current) == null || y.call(u, m)); } else a(d); }, [l, e, a, u] ); return [p, c]; } function Ce({ defaultProp: e, onChange: t }) { const [s, r] = i.useState(e), o = i.useRef(s), a = i.useRef(t); return je(() => { a.current = t; }, [t]), i.useEffect(() => { var u; o.current !== s && ((u = a.current) == null || u.call(a, s), o.current = s); }, [s, o]), [s, r, a]; } function $e(e) { return typeof e == "function"; } // @__NO_SIDE_EFFECTS__ function ue(e) { const t = /* @__PURE__ */ xe(e), s = i.forwardRef((r, o) => { const { children: a, ...u } = r, l = i.Children.toArray(a), p = l.find(Re); if (p) { const c = p.props.children, d = l.map((y) => y === p ? i.Children.count(c) > 1 ? i.Children.only(null) : i.isValidElement(c) ? c.props.children : null : y); return /* @__PURE__ */ N.jsx(t, { ...u, ref: o, children: i.isValidElement(c) ? i.cloneElement(c, void 0, d) : null }); } return /* @__PURE__ */ N.jsx(t, { ...u, ref: o, children: a }); }); return s.displayName = `${e}.Slot`, s; } var Ge = /* @__PURE__ */ ue("Slot"); // @__NO_SIDE_EFFECTS__ function xe(e) { const t = i.forwardRef((s, r) => { const { children: o, ...a } = s; if (i.isValidElement(o)) { const u = De(o), l = Te(a, o.props); return o.type !== i.Fragment && (l.ref = r ? ie(r, u) : u), i.cloneElement(o, l); } return i.Children.count(o) > 1 ? i.Children.only(null) : null; }); return t.displayName = `${e}.SlotClone`, t; } var le = Symbol("radix.slottable"); // @__NO_SIDE_EFFECTS__ function Ze(e) { const t = ({ children: s }) => /* @__PURE__ */ N.jsx(N.Fragment, { children: s }); return t.displayName = `${e}.Slottable`, t.__radixId = le, t; } function Re(e) { return i.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === le; } function Te(e, t) { const s = { ...t }; for (const r in t) { const o = e[r], a = t[r]; /^on[A-Z]/.test(r) ? o && a ? s[r] = (...u) => { const l = a(...u); return o(...u), l; } : o && (s[r] = o) : r === "style" ? s[r] = { ...o, ...a } : r === "className" && (s[r] = [o, a].filter(Boolean).join(" ")); } return { ...e, ...s }; } function De(e) { var t, s; let r = (t = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : t.get, o = r && "isReactWarning" in r && r.isReactWarning; return o ? e.ref : (r = (s = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : s.get, o = r && "isReactWarning" in r && r.isReactWarning, o ? e.props.ref : e.props.ref || e.ref); } var Le = [ "a", "button", "div", "form", "h2", "h3", "img", "input", "label", "li", "nav", "ol", "p", "select", "span", "svg", "ul" ], ce = Le.reduce((e, t) => { const s = /* @__PURE__ */ ue(`Primitive.${t}`), r = i.forwardRef((o, a) => { const { asChild: u, ...l } = o, p = u ? s : t; return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ N.jsx(p, { ...l, ref: a }); }); return r.displayName = `Primitive.${t}`, { ...e, [t]: r }; }, {}); function Me(e, t) { e && be.flushSync(() => e.dispatchEvent(t)); } function Y(e) { const t = i.useRef(e); return i.useEffect(() => { t.current = e; }), i.useMemo(() => (...s) => { var r; return (r = t.current) == null ? void 0 : r.call(t, ...s); }, []); } function Ae(e, t = globalThis == null ? void 0 : globalThis.document) { const s = Y(e); i.useEffect(() => { const r = (o) => { o.key === "Escape" && s(o); }; return t.addEventListener("keydown", r, { capture: !0 }), () => t.removeEventListener("keydown", r, { capture: !0 }); }, [s, t]); } var Ie = "DismissableLayer", X = "dismissableLayer.update", Fe = "dismissableLayer.pointerDownOutside", We = "dismissableLayer.focusOutside", se, fe = i.createContext({ layers: /* @__PURE__ */ new Set(), layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(), branches: /* @__PURE__ */ new Set() }), Ue = i.forwardRef( (e, t) => { const { disableOutsidePointerEvents: s = !1, onEscapeKeyDown: r, onPointerDownOutside: o, onFocusOutside: a, onInteractOutside: u, onDismiss: l, ...p } = e, c = i.useContext(fe), [d, y] = i.useState(null), m = (d == null ? void 0 : d.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, E] = i.useState({}), O = J(t, (v) => y(v)), w = Array.from(c.layers), [_] = [...c.layersWithOutsidePointerEventsDisabled].slice(-1), P = w.indexOf(_), $ = d ? w.indexOf(d) : -1, M = c.layersWithOutsidePointerEventsDisabled.size > 0, x = $ >= P, A = Ve((v) => { const j = v.target, S = [...c.branches].some((I) => I.contains(j)); !x || S || (o == null || o(v), u == null || u(v), v.defaultPrevented || l == null || l()); }, m), R = Ke((v) => { const j = v.target; [...c.branches].some((S) => S.contains(j)) || (a == null || a(v), u == null || u(v), v.defaultPrevented || l == null || l()); }, m); return Ae((v) => { $ === c.layers.size - 1 && (r == null || r(v), !v.defaultPrevented && l && (v.preventDefault(), l())); }, m), i.useEffect(() => { if (d) return s && (c.layersWithOutsidePointerEventsDisabled.size === 0 && (se = m.body.style.pointerEvents, m.body.style.pointerEvents = "none"), c.layersWithOutsidePointerEventsDisabled.add(d)), c.layers.add(d), ae(), () => { s && c.layersWithOutsidePointerEventsDisabled.size === 1 && (m.body.style.pointerEvents = se); }; }, [d, m, s, c]), i.useEffect(() => () => { d && (c.layers.delete(d), c.layersWithOutsidePointerEventsDisabled.delete(d), ae()); }, [d, c]), i.useEffect(() => { const v = () => E({}); return document.addEventListener(X, v), () => document.removeEventListener(X, v); }, []), /* @__PURE__ */ N.jsx( ce.div, { ...p, ref: O, style: { pointerEvents: M ? x ? "auto" : "none" : void 0, ...e.style }, onFocusCapture: K(e.onFocusCapture, R.onFocusCapture), onBlurCapture: K(e.onBlurCapture, R.onBlurCapture), onPointerDownCapture: K( e.onPointerDownCapture, A.onPointerDownCapture ) } ); } ); Ue.displayName = Ie; var ze = "DismissableLayerBranch", Be = i.forwardRef((e, t) => { const s = i.useContext(fe), r = i.useRef(null), o = J(t, r); return i.useEffect(() => { const a = r.current; if (a) return s.branches.add(a), () => { s.branches.delete(a); }; }, [s.branches]), /* @__PURE__ */ N.jsx(ce.div, { ...e, ref: o }); }); Be.displayName = ze; function Ve(e, t = globalThis == null ? void 0 : globalThis.document) { const s = Y(e), r = i.useRef(!1), o = i.useRef(() => { }); return i.useEffect(() => { const a = (l) => { if (l.target && !r.current) { let p = function() { de( Fe, s, c, { discrete: !0 } ); }; const c = { originalEvent: l }; l.pointerType === "touch" ? (t.removeEventListener("click", o.current), o.current = p, t.addEventListener("click", o.current, { once: !0 })) : p(); } else t.removeEventListener("click", o.current); r.current = !1; }, u = window.setTimeout(() => { t.addEventListener("pointerdown", a); }, 0); return () => { window.clearTimeout(u), t.removeEventListener("pointerdown", a), t.removeEventListener("click", o.current); }; }, [t, s]), { // ensures we check React component tree (not just DOM tree) onPointerDownCapture: () => r.current = !0 }; } function Ke(e, t = globalThis == null ? void 0 : globalThis.document) { const s = Y(e), r = i.useRef(!1); return i.useEffect(() => { const o = (a) => { a.target && !r.current && de(We, s, { originalEvent: a }, { discrete: !1 }); }; return t.addEventListener("focusin", o), () => t.removeEventListener("focusin", o); }, [t, s]), { onFocusCapture: () => r.current = !0, onBlurCapture: () => r.current = !1 }; } function ae() { const e = new CustomEvent(X); document.dispatchEvent(e); } function de(e, t, s, { discrete: r }) { const o = s.originalEvent.target, a = new CustomEvent(e, { bubbles: !1, cancelable: !0, detail: s }); t && o.addEventListener(e, t, { once: !0 }), r ? Me(o, a) : o.dispatchEvent(a); } export { Ue as M, Ne as R, ue as S, N as a, K as b, Je as c, L as d, Ze as e, ie as f, He as g, ce as h, J as i, Ye as j, Ge as k, Y as n, Me as w, qe as y };