UNPKG

@undp/design-system-react

Version:

React based design system for UNDP

188 lines (187 loc) 6.81 kB
import { i as e, n as t } from "./dist-DxuGUd9a.js"; import { t as n } from "./dist-jqIPNHDe.js"; import { n as r, t as i } from "./dist-BKfyhBSH.js"; import { n as a, t as o } from "./dist-CwCVtfik.js"; import { t as s } from "./dist-CnnnGPaT.js"; import { t as c } from "./dist-DfB3OR9K.js"; import { i as l, n as u } from "./dist-CMH_aW5P.js"; import { i as d, n as f, r as p, t as m } from "./es2015-PKoodAxS.js"; import { t as h } from "./dist-vWm-kLzq.js"; import * as g from "react"; import { Fragment as _, jsx as v } from "react/jsx-runtime"; //#region node_modules/@radix-ui/react-dialog/dist/index.mjs var y = Object.defineProperty, b = (e, t) => y(e, "name", { value: t, configurable: !0 }), x = "Dialog", [S, C] = r(x), [w, T] = S(x), E = /* @__PURE__ */ b((e) => { let { __scopeDialog: t, children: n, open: r, defaultOpen: i, onOpenChange: a, modal: s = !0 } = e, l = g.useRef(null), u = g.useRef(null), [d, f] = o({ prop: r, defaultProp: i ?? !1, onChange: a, caller: x }), [p, m] = g.useState(0), [h, _] = g.useState(0); return /* @__PURE__ */ v(w, { scope: t, triggerRef: l, contentRef: u, contentId: c(), titleId: c(), descriptionId: c(), titlePresent: p > 0, descriptionPresent: h > 0, setTitleCount: m, setDescriptionCount: _, open: d, onOpenChange: f, onOpenToggle: g.useCallback(() => f((e) => !e), [f]), modal: s, children: n }); }, "Dialog"), D = "DialogTrigger", O = /* @__PURE__ */ g.forwardRef(/* @__PURE__ */ b(function(t, r) { let { __scopeDialog: i, ...o } = t, s = T(D, i), c = e(r, s.triggerRef); return /* @__PURE__ */ v(n.button, { type: "button", "aria-haspopup": "dialog", "aria-expanded": s.open, "aria-controls": s.open ? s.contentId : void 0, "data-state": J(s.open), ...o, ref: c, onClick: a(t.onClick, s.onOpenToggle) }); }, "DialogTrigger")), k = "DialogPortal", [A, j] = S(k, { forceMount: void 0 }), M = /* @__PURE__ */ b((e) => { let { __scopeDialog: t, forceMount: n, children: r, container: i } = e, a = T(k, t); return /* @__PURE__ */ v(A, { scope: t, forceMount: n, children: g.Children.map(r, (e) => /* @__PURE__ */ v(s, { present: n || a.open, children: /* @__PURE__ */ v(h, { asChild: !0, container: i, children: e }) })) }); }, "DialogPortal"), N = "DialogOverlay", P = /* @__PURE__ */ g.forwardRef(/* @__PURE__ */ b(function(e, t) { let n = j(N, e.__scopeDialog), { forceMount: r = n.forceMount, ...i } = e, a = T(N, e.__scopeDialog); return a.modal ? /* @__PURE__ */ v(s, { present: r || a.open, children: /* @__PURE__ */ v(I, { ...i, ref: t }) }) : null; }, "DialogOverlay")), F = t("DialogOverlay.RemoveScroll"), I = /* @__PURE__ */ g.forwardRef(/* @__PURE__ */ b(function(t, r) { let { __scopeDialog: i, ...a } = t, o = T(N, i), s = e(r, l()); return /* @__PURE__ */ v(f, { as: F, allowPinchZoom: !0, shards: [o.contentRef], children: /* @__PURE__ */ v(n.div, { "data-state": J(o.open), ...a, ref: s, style: { pointerEvents: "auto", ...a.style } }) }); }, "DialogOverlayImpl")), L = "DialogContent", R = /* @__PURE__ */ g.forwardRef(/* @__PURE__ */ b(function(e, t) { let n = j(L, e.__scopeDialog), { forceMount: r = n.forceMount, ...i } = e, a = T(L, e.__scopeDialog); return /* @__PURE__ */ v(s, { present: r || a.open, children: a.modal ? /* @__PURE__ */ v(z, { ...i, ref: t }) : /* @__PURE__ */ v(B, { ...i, ref: t }) }); }, "DialogContent")), z = /* @__PURE__ */ g.forwardRef(/* @__PURE__ */ b(function(t, n) { let r = T(L, t.__scopeDialog), i = g.useRef(null), o = e(n, r.contentRef, i); return g.useEffect(() => { let e = i.current; if (e) return m(e); }, []), /* @__PURE__ */ v(V, { ...t, ref: o, trapFocus: r.open, disableOutsidePointerEvents: r.open, onCloseAutoFocus: a(t.onCloseAutoFocus, (e) => { e.preventDefault(), r.triggerRef.current?.focus(); }), onPointerDownOutside: a(t.onPointerDownOutside, (e) => { let t = e.detail.originalEvent, n = t.button === 0 && t.ctrlKey === !0; (t.button === 2 || n) && e.preventDefault(); }), onFocusOutside: a(t.onFocusOutside, (e) => e.preventDefault()) }); }, "DialogContentModal")), B = /* @__PURE__ */ g.forwardRef(/* @__PURE__ */ b(function(e, t) { let n = T(L, e.__scopeDialog), r = g.useRef(!1), i = g.useRef(!1); return /* @__PURE__ */ v(V, { ...e, ref: t, trapFocus: !1, disableOutsidePointerEvents: !1, onCloseAutoFocus: (t) => { e.onCloseAutoFocus?.(t), t.defaultPrevented || (r.current || n.triggerRef.current?.focus(), t.preventDefault()), r.current = !1, i.current = !1; }, onInteractOutside: (t) => { e.onInteractOutside?.(t), t.defaultPrevented || (r.current = !0, t.detail.originalEvent.type === "pointerdown" && (i.current = !0)); let a = t.target; n.triggerRef.current?.contains(a) && t.preventDefault(), t.detail.originalEvent.type === "focusin" && i.current && t.preventDefault(); } }); }, "DialogContentNonModal")), V = /* @__PURE__ */ g.forwardRef(/* @__PURE__ */ b(function(e, t) { let { __scopeDialog: n, trapFocus: r, onOpenAutoFocus: i, onCloseAutoFocus: a, ...o } = e, s = T(L, n); return p(), /* @__PURE__ */ v(_, { children: /* @__PURE__ */ v(d, { asChild: !0, loop: !0, trapped: r, onMountAutoFocus: i, onUnmountAutoFocus: a, children: /* @__PURE__ */ v(u, { role: "dialog", id: s.contentId, "aria-describedby": s.descriptionPresent ? s.descriptionId : void 0, "aria-labelledby": s.titlePresent ? s.titleId : void 0, "data-state": J(s.open), ...o, ref: t, deferPointerDownOutside: !0, onDismiss: () => s.onOpenChange(!1) }) }) }); }, "DialogContentImpl")), H = "DialogTitle", U = /* @__PURE__ */ g.forwardRef(/* @__PURE__ */ b(function(e, t) { let { __scopeDialog: r, ...a } = e, o = T(H, r), { setTitleCount: s } = o; return i(() => (s((e) => e + 1), () => s((e) => e - 1)), [s]), /* @__PURE__ */ v(n.h2, { id: o.titleId, ...a, ref: t }); }, "DialogTitle")), W = "DialogDescription", G = /* @__PURE__ */ g.forwardRef(/* @__PURE__ */ b(function(e, t) { let { __scopeDialog: r, ...a } = e, o = T(W, r), { setDescriptionCount: s } = o; return i(() => (s((e) => e + 1), () => s((e) => e - 1)), [s]), /* @__PURE__ */ v(n.p, { id: o.descriptionId, ...a, ref: t }); }, "DialogDescription")), K = "DialogClose", q = /* @__PURE__ */ g.forwardRef(/* @__PURE__ */ b(function(e, t) { let { __scopeDialog: r, ...i } = e, o = T(K, r); return /* @__PURE__ */ v(n.button, { type: "button", ...i, ref: t, onClick: a(e.onClick, () => o.onOpenChange(!1)) }); }, "DialogClose")); function J(e) { return e ? "open" : "closed"; } b(J, "getState"); //#endregion export { P as a, O as c, G as i, q as n, M as o, R as r, U as s, E as t }; //# sourceMappingURL=dist-CnD55hFX.js.map