UNPKG

dgz-ui

Version:

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

286 lines (285 loc) 10 kB
import { jsx as l } from "react/jsx-runtime"; import * as s from "react"; import { P as O, c as g, a as y, b as $ } from "./index-BVqmUhu5.es.js"; import { c as L, u as _ } from "./index-DLcqcWxM.es.js"; import { D as W } from "./index-ClNIHY-1.es.js"; import { P as H, h as j, R as z, u as G, F as B } from "./index-BKZjW6I1.es.js"; import { u as K, a as Z } from "./index-BdfbDt7y.es.js"; import { R as U, A as E, c as b, C as q, a as J } from "./index-Bli6ZByj.es.js"; import { c as Q } from "./utils-CnvKSirc.es.js"; // @__NO_SIDE_EFFECTS__ function X(e) { const t = /* @__PURE__ */ Y(e), r = s.forwardRef((n, o) => { const { children: a, ...i } = n, c = s.Children.toArray(a), p = c.find(oe); if (p) { const u = p.props.children, P = c.map((f) => f === p ? s.Children.count(u) > 1 ? s.Children.only(null) : s.isValidElement(u) ? u.props.children : null : f); return /* @__PURE__ */ l(t, { ...i, ref: o, children: s.isValidElement(u) ? s.cloneElement(u, void 0, P) : null }); } return /* @__PURE__ */ l(t, { ...i, ref: o, children: a }); }); return r.displayName = `${e}.Slot`, r; } // @__NO_SIDE_EFFECTS__ function Y(e) { const t = s.forwardRef((r, n) => { const { children: o, ...a } = r; if (s.isValidElement(o)) { const i = re(o), c = te(a, o.props); return o.type !== s.Fragment && (c.ref = n ? L(n, i) : i), s.cloneElement(o, c); } return s.Children.count(o) > 1 ? s.Children.only(null) : null; }); return t.displayName = `${e}.SlotClone`, t; } var ee = Symbol("radix.slottable"); function oe(e) { return s.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === ee; } function te(e, t) { const r = { ...t }; for (const n in t) { const o = e[n], a = t[n]; /^on[A-Z]/.test(n) ? o && a ? r[n] = (...c) => { const p = a(...c); return o(...c), p; } : o && (r[n] = o) : n === "style" ? r[n] = { ...o, ...a } : n === "className" && (r[n] = [o, a].filter(Boolean).join(" ")); } return { ...e, ...r }; } function re(e) { var n, o; let t = (n = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : n.get, r = t && "isReactWarning" in t && t.isReactWarning; return r ? e.ref : (t = (o = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : o.get, r = t && "isReactWarning" in t && t.isReactWarning, r ? e.props.ref : e.props.ref || e.ref); } var C = "Popover", [x] = $(C, [ b ]), h = b(), [ne, d] = x(C), w = (e) => { const { __scopePopover: t, children: r, open: n, defaultOpen: o, onOpenChange: a, modal: i = !1 } = e, c = h(t), p = s.useRef(null), [u, P] = s.useState(!1), [f, v] = K({ prop: n, defaultProp: o ?? !1, onChange: a, caller: C }); return /* @__PURE__ */ l(U, { ...c, children: /* @__PURE__ */ l( ne, { scope: t, contentId: Z(), triggerRef: p, open: f, onOpenChange: v, onOpenToggle: s.useCallback(() => v((R) => !R), [v]), hasCustomAnchor: u, onCustomAnchorAdd: s.useCallback(() => P(!0), []), onCustomAnchorRemove: s.useCallback(() => P(!1), []), modal: i, children: r } ) }); }; w.displayName = C; var S = "PopoverAnchor", ae = s.forwardRef( (e, t) => { const { __scopePopover: r, ...n } = e, o = d(S, r), a = h(r), { onCustomAnchorAdd: i, onCustomAnchorRemove: c } = o; return s.useEffect(() => (i(), () => c()), [i, c]), /* @__PURE__ */ l(E, { ...a, ...n, ref: t }); } ); ae.displayName = S; var N = "PopoverTrigger", F = s.forwardRef( (e, t) => { const { __scopePopover: r, ...n } = e, o = d(N, r), a = h(r), i = _(t, o.triggerRef), c = /* @__PURE__ */ l( O.button, { type: "button", "aria-haspopup": "dialog", "aria-expanded": o.open, "aria-controls": o.contentId, "data-state": k(o.open), ...n, ref: i, onClick: g(e.onClick, o.onOpenToggle) } ); return o.hasCustomAnchor ? c : /* @__PURE__ */ l(E, { asChild: !0, ...a, children: c }); } ); F.displayName = N; var A = "PopoverPortal", [se, ie] = x(A, { forceMount: void 0 }), D = (e) => { const { __scopePopover: t, forceMount: r, children: n, container: o } = e, a = d(A, t); return /* @__PURE__ */ l(se, { scope: t, forceMount: r, children: /* @__PURE__ */ l(y, { present: r || a.open, children: /* @__PURE__ */ l(H, { asChild: !0, container: o, children: n }) }) }); }; D.displayName = A; var m = "PopoverContent", I = s.forwardRef( (e, t) => { const r = ie(m, e.__scopePopover), { forceMount: n = r.forceMount, ...o } = e, a = d(m, e.__scopePopover); return /* @__PURE__ */ l(y, { present: n || a.open, children: a.modal ? /* @__PURE__ */ l(le, { ...o, ref: t }) : /* @__PURE__ */ l(pe, { ...o, ref: t }) }); } ); I.displayName = m; var ce = /* @__PURE__ */ X("PopoverContent.RemoveScroll"), le = s.forwardRef( (e, t) => { const r = d(m, e.__scopePopover), n = s.useRef(null), o = _(t, n), a = s.useRef(!1); return s.useEffect(() => { const i = n.current; if (i) return j(i); }, []), /* @__PURE__ */ l(z, { as: ce, allowPinchZoom: !0, children: /* @__PURE__ */ l( T, { ...e, ref: o, trapFocus: r.open, disableOutsidePointerEvents: !0, onCloseAutoFocus: g(e.onCloseAutoFocus, (i) => { var c; i.preventDefault(), a.current || (c = r.triggerRef.current) == null || c.focus(); }), onPointerDownOutside: g( e.onPointerDownOutside, (i) => { const c = i.detail.originalEvent, p = c.button === 0 && c.ctrlKey === !0, u = c.button === 2 || p; a.current = u; }, { checkForDefaultPrevented: !1 } ), onFocusOutside: g( e.onFocusOutside, (i) => i.preventDefault(), { checkForDefaultPrevented: !1 } ) } ) }); } ), pe = s.forwardRef( (e, t) => { const r = d(m, e.__scopePopover), n = s.useRef(!1), o = s.useRef(!1); return /* @__PURE__ */ l( T, { ...e, ref: t, trapFocus: !1, disableOutsidePointerEvents: !1, onCloseAutoFocus: (a) => { var i, c; (i = e.onCloseAutoFocus) == null || i.call(e, a), a.defaultPrevented || (n.current || (c = r.triggerRef.current) == null || c.focus(), a.preventDefault()), n.current = !1, o.current = !1; }, onInteractOutside: (a) => { var p, u; (p = e.onInteractOutside) == null || p.call(e, a), a.defaultPrevented || (n.current = !0, a.detail.originalEvent.type === "pointerdown" && (o.current = !0)); const i = a.target; ((u = r.triggerRef.current) == null ? void 0 : u.contains(i)) && a.preventDefault(), a.detail.originalEvent.type === "focusin" && o.current && a.preventDefault(); } } ); } ), T = s.forwardRef( (e, t) => { const { __scopePopover: r, trapFocus: n, onOpenAutoFocus: o, onCloseAutoFocus: a, disableOutsidePointerEvents: i, onEscapeKeyDown: c, onPointerDownOutside: p, onFocusOutside: u, onInteractOutside: P, ...f } = e, v = d(m, r), R = h(r); return G(), /* @__PURE__ */ l( B, { asChild: !0, loop: !0, trapped: n, onMountAutoFocus: o, onUnmountAutoFocus: a, children: /* @__PURE__ */ l( W, { asChild: !0, disableOutsidePointerEvents: i, onInteractOutside: P, onEscapeKeyDown: c, onPointerDownOutside: p, onFocusOutside: u, onDismiss: () => v.onOpenChange(!1), children: /* @__PURE__ */ l( q, { "data-state": k(v.open), role: "dialog", id: v.contentId, ...R, ...f, ref: t, style: { ...f.style, "--radix-popover-content-transform-origin": "var(--radix-popper-transform-origin)", "--radix-popover-content-available-width": "var(--radix-popper-available-width)", "--radix-popover-content-available-height": "var(--radix-popper-available-height)", "--radix-popover-trigger-width": "var(--radix-popper-anchor-width)", "--radix-popover-trigger-height": "var(--radix-popper-anchor-height)" } } ) } ) } ); } ), M = "PopoverClose", ue = s.forwardRef( (e, t) => { const { __scopePopover: r, ...n } = e, o = d(M, r); return /* @__PURE__ */ l( O.button, { type: "button", ...n, ref: t, onClick: g(e.onClick, () => o.onOpenChange(!1)) } ); } ); ue.displayName = M; var de = "PopoverArrow", fe = s.forwardRef( (e, t) => { const { __scopePopover: r, ...n } = e, o = h(r); return /* @__PURE__ */ l(J, { ...o, ...n, ref: t }); } ); fe.displayName = de; function k(e) { return e ? "open" : "closed"; } var ve = w, Pe = F, me = D, V = I; const be = ve, xe = Pe, ge = s.forwardRef(({ className: e, align: t = "center", sideOffset: r = 4, ...n }, o) => /* @__PURE__ */ l(me, { children: /* @__PURE__ */ l( V, { ref: o, align: t, sideOffset: r, className: Q( "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 rounded-md border p-4 shadow-md outline-none", e ), ...n } ) })); ge.displayName = V.displayName; export { be as P, ge as a, xe as b }; //# sourceMappingURL=popover-BredK0sg.es.js.map