@undp/design-system-react
Version:
React based design system for UNDP
181 lines (180 loc) • 7.19 kB
JavaScript
import { t as e } from "./utils-ca9as9Ye.js";
import { i as t, n } from "./dist-DxuGUd9a.js";
import { t as r } from "./dist-jqIPNHDe.js";
import { n 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 { n as l } from "./dist-CMH_aW5P.js";
import { i as u, n as d, r as f, t as p } from "./es2015-PKoodAxS.js";
import { t as m } from "./dist-vWm-kLzq.js";
import { i as h, n as g, r as _, t as v } from "./dist-D8TIRAGv.js";
import * as y from "react";
import b from "react";
import { jsx as x } from "react/jsx-runtime";
//#region node_modules/@radix-ui/react-popover/dist/index.mjs
var S = Object.defineProperty, C = (e, t) => S(e, "name", {
value: t,
configurable: !0
}), w = "Popover", [T, ee] = i(w, [h]), E = h(), [D, O] = T(w), k = /* @__PURE__ */ C((e) => {
let { __scopePopover: t, children: n, open: r, defaultOpen: i, onOpenChange: a, modal: s = !1 } = e, l = E(t), u = y.useRef(null), [d, f] = y.useState(!1), [p, m] = o({
prop: r,
defaultProp: i ?? !1,
onChange: a,
caller: w
});
return /* @__PURE__ */ x(_, {
...l,
children: /* @__PURE__ */ x(D, {
scope: t,
contentId: c(),
triggerRef: u,
open: p,
onOpenChange: m,
onOpenToggle: y.useCallback(() => m((e) => !e), [m]),
hasCustomAnchor: d,
onCustomAnchorAdd: y.useCallback(() => f(!0), []),
onCustomAnchorRemove: y.useCallback(() => f(!1), []),
modal: s,
children: n
})
});
}, "Popover"), A = "PopoverAnchor", j = /* @__PURE__ */ y.forwardRef(/* @__PURE__ */ C(function(e, t) {
let { __scopePopover: n, ...r } = e, i = O(A, n), a = E(n), { onCustomAnchorAdd: o, onCustomAnchorRemove: s } = i;
return y.useEffect(() => (o(), () => s()), [o, s]), /* @__PURE__ */ x(v, {
...a,
...r,
ref: t
});
}, "PopoverAnchor")), M = "PopoverTrigger", N = /* @__PURE__ */ y.forwardRef(/* @__PURE__ */ C(function(e, n) {
let { __scopePopover: i, ...o } = e, s = O(M, i), c = E(i), l = t(n, s.triggerRef), u = /* @__PURE__ */ x(r.button, {
type: "button",
"aria-haspopup": "dialog",
"aria-expanded": s.open,
"aria-controls": s.open ? s.contentId : void 0,
"data-state": W(s.open),
...o,
ref: l,
onClick: a(e.onClick, s.onOpenToggle)
});
return s.hasCustomAnchor ? u : /* @__PURE__ */ x(v, {
asChild: !0,
...c,
children: u
});
}, "PopoverTrigger")), P = "PopoverPortal", [F, I] = T(P, { forceMount: void 0 }), L = /* @__PURE__ */ C((e) => {
let { __scopePopover: t, forceMount: n, children: r, container: i } = e, a = O(P, t);
return /* @__PURE__ */ x(F, {
scope: t,
forceMount: n,
children: /* @__PURE__ */ x(s, {
present: n || a.open,
children: /* @__PURE__ */ x(m, {
asChild: !0,
container: i,
children: r
})
})
});
}, "PopoverPortal"), R = "PopoverContent", z = /* @__PURE__ */ y.forwardRef(/* @__PURE__ */ C(function(e, t) {
let n = I(R, e.__scopePopover), { forceMount: r = n.forceMount, ...i } = e, a = O(R, e.__scopePopover);
return /* @__PURE__ */ x(s, {
present: r || a.open,
children: a.modal ? /* @__PURE__ */ x(V, {
...i,
ref: t
}) : /* @__PURE__ */ x(H, {
...i,
ref: t
})
});
}, "PopoverContent")), B = n("PopoverContent.RemoveScroll"), V = /* @__PURE__ */ y.forwardRef(/* @__PURE__ */ C(function(e, n) {
let r = O(R, e.__scopePopover), i = y.useRef(null), o = t(n, i), s = y.useRef(!1);
return y.useEffect(() => {
let e = i.current;
if (e) return p(e);
}, []), /* @__PURE__ */ x(d, {
as: B,
allowPinchZoom: !0,
children: /* @__PURE__ */ x(U, {
...e,
ref: o,
trapFocus: r.open,
disableOutsidePointerEvents: !0,
onCloseAutoFocus: a(e.onCloseAutoFocus, (e) => {
e.preventDefault(), s.current || r.triggerRef.current?.focus();
}),
onPointerDownOutside: a(e.onPointerDownOutside, (e) => {
let t = e.detail.originalEvent, n = t.button === 0 && t.ctrlKey === !0, r = t.button === 2 || n;
s.current = r;
}, { checkForDefaultPrevented: !1 }),
onFocusOutside: a(e.onFocusOutside, (e) => e.preventDefault(), { checkForDefaultPrevented: !1 })
})
});
}, "PopoverContentModal")), H = /* @__PURE__ */ y.forwardRef(/* @__PURE__ */ C(function(e, t) {
let n = O(R, e.__scopePopover), r = y.useRef(!1), i = y.useRef(!1);
return /* @__PURE__ */ x(U, {
...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();
}
});
}, "PopoverContentNonModal")), U = /* @__PURE__ */ y.forwardRef(/* @__PURE__ */ C(function(e, t) {
let { __scopePopover: n, trapFocus: r, onOpenAutoFocus: i, onCloseAutoFocus: a, disableOutsidePointerEvents: o, onEscapeKeyDown: s, onPointerDownOutside: c, onFocusOutside: d, onInteractOutside: p, ...m } = e, h = O(R, n), _ = E(n);
return f(), /* @__PURE__ */ x(u, {
asChild: !0,
loop: !0,
trapped: r,
onMountAutoFocus: i,
onUnmountAutoFocus: a,
children: /* @__PURE__ */ x(l, {
asChild: !0,
disableOutsidePointerEvents: o,
onInteractOutside: p,
onEscapeKeyDown: s,
onPointerDownOutside: c,
onFocusOutside: d,
onDismiss: () => h.onOpenChange(!1),
deferPointerDownOutside: !0,
children: /* @__PURE__ */ x(g, {
"data-state": W(h.open),
role: "dialog",
id: h.contentId,
..._,
...m,
ref: t,
style: {
...m.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)"
}
})
})
});
}, "PopoverContentImpl"));
function W(e) {
return e ? "open" : "closed";
}
C(W, "getState");
var G = k, K = j, q = N, J = L, Y = z, X = G, Z = q, Q = K, $ = b.forwardRef(({ className: t, align: n = "center", sideOffset: r = 4, ...i }, a) => /* @__PURE__ */ x(J, { children: /* @__PURE__ */ x(Y, {
...i,
ref: a,
align: n,
sideOffset: r,
className: e("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 h-auto w-72 border border-stroke bg-surface/90 p-3 text-content-primary text-sm outline-hidden backdrop-blur-frosted data-[state=closed]:animate-out data-[state=open]:animate-in", t)
}) }));
$.displayName = Y.displayName;
//#endregion
export { Z as i, Q as n, $ as r, X as t };
//# sourceMappingURL=popover-CJlFZacQ.js.map