dgz-ui
Version:
Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript
291 lines (288 loc) • 9.94 kB
JavaScript
import * as i from "react";
import { P as D, c as m, a as h, b as H, d as Z } from "./index-BVqmUhu5.es.js";
import { c as q, u as E } from "./index-DLcqcWxM.es.js";
import { u as K, a as y } from "./index-BdfbDt7y.es.js";
import { D as U } from "./index-ClNIHY-1.es.js";
import { P as Y, h as z, R as J, u as Q, F as X } from "./index-BKZjW6I1.es.js";
import { jsx as c, jsxs as N, Fragment as I } from "react/jsx-runtime";
// @__NO_SIDE_EFFECTS__
function ee(e) {
const o = /* @__PURE__ */ te(e), a = i.forwardRef((n, t) => {
const { children: r, ...s } = n, l = i.Children.toArray(r), u = l.find(ne);
if (u) {
const d = u.props.children, p = l.map((v) => v === u ? i.Children.count(d) > 1 ? i.Children.only(null) : i.isValidElement(d) ? d.props.children : null : v);
return /* @__PURE__ */ c(o, { ...s, ref: t, children: i.isValidElement(d) ? i.cloneElement(d, void 0, p) : null });
}
return /* @__PURE__ */ c(o, { ...s, ref: t, children: r });
});
return a.displayName = `${e}.Slot`, a;
}
// @__NO_SIDE_EFFECTS__
function te(e) {
const o = i.forwardRef((a, n) => {
const { children: t, ...r } = a;
if (i.isValidElement(t)) {
const s = ae(t), l = re(r, t.props);
return t.type !== i.Fragment && (l.ref = n ? q(n, s) : s), i.cloneElement(t, l);
}
return i.Children.count(t) > 1 ? i.Children.only(null) : null;
});
return o.displayName = `${e}.SlotClone`, o;
}
var oe = Symbol("radix.slottable");
function ne(e) {
return i.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === oe;
}
function re(e, o) {
const a = { ...o };
for (const n in o) {
const t = e[n], r = o[n];
/^on[A-Z]/.test(n) ? t && r ? a[n] = (...l) => {
const u = r(...l);
return t(...l), u;
} : t && (a[n] = t) : n === "style" ? a[n] = { ...t, ...r } : n === "className" && (a[n] = [t, r].filter(Boolean).join(" "));
}
return { ...e, ...a };
}
function ae(e) {
var n, t;
let o = (n = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : n.get, a = o && "isReactWarning" in o && o.isReactWarning;
return a ? e.ref : (o = (t = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : t.get, a = o && "isReactWarning" in o && o.isReactWarning, a ? e.props.ref : e.props.ref || e.ref);
}
var R = "Dialog", [b, he] = H(R), [ie, f] = b(R), x = (e) => {
const {
__scopeDialog: o,
children: a,
open: n,
defaultOpen: t,
onOpenChange: r,
modal: s = !0
} = e, l = i.useRef(null), u = i.useRef(null), [d, p] = K({
prop: n,
defaultProp: t ?? !1,
onChange: r,
caller: R
});
return /* @__PURE__ */ c(
ie,
{
scope: o,
triggerRef: l,
contentRef: u,
contentId: y(),
titleId: y(),
descriptionId: y(),
open: d,
onOpenChange: p,
onOpenToggle: i.useCallback(() => p((v) => !v), [p]),
modal: s,
children: a
}
);
};
x.displayName = R;
var A = "DialogTrigger", T = i.forwardRef(
(e, o) => {
const { __scopeDialog: a, ...n } = e, t = f(A, a), r = E(o, t.triggerRef);
return /* @__PURE__ */ c(
D.button,
{
type: "button",
"aria-haspopup": "dialog",
"aria-expanded": t.open,
"aria-controls": t.contentId,
"data-state": O(t.open),
...n,
ref: r,
onClick: m(e.onClick, t.onOpenToggle)
}
);
}
);
T.displayName = A;
var _ = "DialogPortal", [se, S] = b(_, {
forceMount: void 0
}), M = (e) => {
const { __scopeDialog: o, forceMount: a, children: n, container: t } = e, r = f(_, o);
return /* @__PURE__ */ c(se, { scope: o, forceMount: a, children: i.Children.map(n, (s) => /* @__PURE__ */ c(h, { present: a || r.open, children: /* @__PURE__ */ c(Y, { asChild: !0, container: t, children: s }) })) });
};
M.displayName = _;
var C = "DialogOverlay", w = i.forwardRef(
(e, o) => {
const a = S(C, e.__scopeDialog), { forceMount: n = a.forceMount, ...t } = e, r = f(C, e.__scopeDialog);
return r.modal ? /* @__PURE__ */ c(h, { present: n || r.open, children: /* @__PURE__ */ c(ce, { ...t, ref: o }) }) : null;
}
);
w.displayName = C;
var le = /* @__PURE__ */ ee("DialogOverlay.RemoveScroll"), ce = i.forwardRef(
(e, o) => {
const { __scopeDialog: a, ...n } = e, t = f(C, a);
return (
// Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
// ie. when `Overlay` and `Content` are siblings
/* @__PURE__ */ c(J, { as: le, allowPinchZoom: !0, shards: [t.contentRef], children: /* @__PURE__ */ c(
D.div,
{
"data-state": O(t.open),
...n,
ref: o,
style: { pointerEvents: "auto", ...n.style }
}
) })
);
}
), g = "DialogContent", F = i.forwardRef(
(e, o) => {
const a = S(g, e.__scopeDialog), { forceMount: n = a.forceMount, ...t } = e, r = f(g, e.__scopeDialog);
return /* @__PURE__ */ c(h, { present: n || r.open, children: r.modal ? /* @__PURE__ */ c(ue, { ...t, ref: o }) : /* @__PURE__ */ c(de, { ...t, ref: o }) });
}
);
F.displayName = g;
var ue = i.forwardRef(
(e, o) => {
const a = f(g, e.__scopeDialog), n = i.useRef(null), t = E(o, a.contentRef, n);
return i.useEffect(() => {
const r = n.current;
if (r) return z(r);
}, []), /* @__PURE__ */ c(
W,
{
...e,
ref: t,
trapFocus: a.open,
disableOutsidePointerEvents: !0,
onCloseAutoFocus: m(e.onCloseAutoFocus, (r) => {
var s;
r.preventDefault(), (s = a.triggerRef.current) == null || s.focus();
}),
onPointerDownOutside: m(e.onPointerDownOutside, (r) => {
const s = r.detail.originalEvent, l = s.button === 0 && s.ctrlKey === !0;
(s.button === 2 || l) && r.preventDefault();
}),
onFocusOutside: m(
e.onFocusOutside,
(r) => r.preventDefault()
)
}
);
}
), de = i.forwardRef(
(e, o) => {
const a = f(g, e.__scopeDialog), n = i.useRef(!1), t = i.useRef(!1);
return /* @__PURE__ */ c(
W,
{
...e,
ref: o,
trapFocus: !1,
disableOutsidePointerEvents: !1,
onCloseAutoFocus: (r) => {
var s, l;
(s = e.onCloseAutoFocus) == null || s.call(e, r), r.defaultPrevented || (n.current || (l = a.triggerRef.current) == null || l.focus(), r.preventDefault()), n.current = !1, t.current = !1;
},
onInteractOutside: (r) => {
var u, d;
(u = e.onInteractOutside) == null || u.call(e, r), r.defaultPrevented || (n.current = !0, r.detail.originalEvent.type === "pointerdown" && (t.current = !0));
const s = r.target;
((d = a.triggerRef.current) == null ? void 0 : d.contains(s)) && r.preventDefault(), r.detail.originalEvent.type === "focusin" && t.current && r.preventDefault();
}
}
);
}
), W = i.forwardRef(
(e, o) => {
const { __scopeDialog: a, trapFocus: n, onOpenAutoFocus: t, onCloseAutoFocus: r, ...s } = e, l = f(g, a), u = i.useRef(null), d = E(o, u);
return Q(), /* @__PURE__ */ N(I, { children: [
/* @__PURE__ */ c(
X,
{
asChild: !0,
loop: !0,
trapped: n,
onMountAutoFocus: t,
onUnmountAutoFocus: r,
children: /* @__PURE__ */ c(
U,
{
role: "dialog",
id: l.contentId,
"aria-describedby": l.descriptionId,
"aria-labelledby": l.titleId,
"data-state": O(l.open),
...s,
ref: d,
onDismiss: () => l.onOpenChange(!1)
}
)
}
),
/* @__PURE__ */ N(I, { children: [
/* @__PURE__ */ c(fe, { titleId: l.titleId }),
/* @__PURE__ */ c(pe, { contentRef: u, descriptionId: l.descriptionId })
] })
] });
}
), P = "DialogTitle", L = i.forwardRef(
(e, o) => {
const { __scopeDialog: a, ...n } = e, t = f(P, a);
return /* @__PURE__ */ c(D.h2, { id: t.titleId, ...n, ref: o });
}
);
L.displayName = P;
var k = "DialogDescription", G = i.forwardRef(
(e, o) => {
const { __scopeDialog: a, ...n } = e, t = f(k, a);
return /* @__PURE__ */ c(D.p, { id: t.descriptionId, ...n, ref: o });
}
);
G.displayName = k;
var V = "DialogClose", $ = i.forwardRef(
(e, o) => {
const { __scopeDialog: a, ...n } = e, t = f(V, a);
return /* @__PURE__ */ c(
D.button,
{
type: "button",
...n,
ref: o,
onClick: m(e.onClick, () => t.onOpenChange(!1))
}
);
}
);
$.displayName = V;
function O(e) {
return e ? "open" : "closed";
}
var j = "DialogTitleWarning", [Ee, B] = Z(j, {
contentName: g,
titleName: P,
docsSlug: "dialog"
}), fe = ({ titleId: e }) => {
const o = B(j), a = `\`${o.contentName}\` requires a \`${o.titleName}\` for the component to be accessible for screen reader users.
If you want to hide the \`${o.titleName}\`, you can wrap it with our VisuallyHidden component.
For more information, see https://radix-ui.com/primitives/docs/components/${o.docsSlug}`;
return i.useEffect(() => {
e && (document.getElementById(e) || console.error(a));
}, [a, e]), null;
}, ge = "DialogDescriptionWarning", pe = ({ contentRef: e, descriptionId: o }) => {
const n = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${B(ge).contentName}}.`;
return i.useEffect(() => {
var r;
const t = (r = e.current) == null ? void 0 : r.getAttribute("aria-describedby");
o && t && (document.getElementById(o) || console.warn(n));
}, [n, e, o]), null;
}, _e = x, Pe = T, Oe = M, Ne = w, Ie = F, be = L, xe = G, Ae = $;
export {
Ae as C,
xe as D,
Ne as O,
Oe as P,
_e as R,
Pe as T,
Ee as W,
Ie as a,
be as b,
he as c
};
//# sourceMappingURL=index-xl-szYFX.es.js.map