@undp/design-system-react
Version:
React based design system for UNDP
138 lines (137 loc) • 3.47 kB
JavaScript
import { t as e } from "./dist-BKfyhBSH.js";
import * as t from "react";
//#region node_modules/@radix-ui/primitive/dist/index.mjs
var n = Object.defineProperty, r = (e, t) => n(e, "name", {
value: t,
configurable: !0
}), i = !!(typeof window < "u" && window.document && window.document.createElement);
function a(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
return /* @__PURE__ */ r(function(r) {
if (e?.(r), n === !1 || !r || !r.defaultPrevented) return t?.(r);
}, "handleEvent");
}
r(a, "composeEventHandlers");
function o(e) {
if (!i) throw Error("Cannot access window outside of the DOM");
return e?.ownerDocument?.defaultView ?? window;
}
r(o, "getOwnerWindow");
function s(e) {
if (!i) throw Error("Cannot access document outside of the DOM");
return e?.ownerDocument ?? document;
}
r(s, "getOwnerDocument");
function c(e, t = !1) {
let { activeElement: n } = s(e);
if (!n?.nodeName) return null;
if (l(n) && n.contentDocument) return c(n.contentDocument.body, t);
if (t) {
let e = n.getAttribute("aria-activedescendant");
if (e) {
let t = s(n).getElementById(e);
if (t) return t;
}
}
return n;
}
r(c, "getActiveElement");
function l(e) {
return e.tagName === "IFRAME";
}
r(l, "isFrame");
//#endregion
//#region node_modules/@radix-ui/react-use-effect-event/dist/index.mjs
var u = t.useEffectEvent, d = t.useInsertionEffect;
function f(n) {
if (typeof u == "function") return u(n);
let r = t.useRef(() => {
throw Error("Cannot call an event handler while rendering.");
});
return typeof d == "function" ? d(() => {
r.current = n;
}) : e(() => {
r.current = n;
}), t.useMemo(() => ((...e) => r.current?.(...e)), []);
}
//#endregion
//#region node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
var p = Object.defineProperty, m = (e, t) => p(e, "name", {
value: t,
configurable: !0
}), h = t.useInsertionEffect || e;
function g({ prop: e, defaultProp: n, onChange: r = /* @__PURE__ */ m(() => {}, "onChange"), caller: i }) {
let [a, o, s] = _({
defaultProp: n,
onChange: r
}), c = e !== void 0;
return [c ? e : a, t.useCallback((t) => {
if (c) {
let n = v(t) ? t(e) : t;
n !== e && s.current?.(n);
} else o(t);
}, [
c,
e,
o,
s
])];
}
m(g, "useControllableState");
function _({ defaultProp: e, onChange: n }) {
let [r, i] = t.useState(e), a = t.useRef(r), o = t.useRef(n);
return h(() => {
o.current = n;
}, [n]), t.useEffect(() => {
a.current !== r && (o.current?.(r), a.current = r);
}, [r, a]), [
r,
i,
o
];
}
m(_, "useUncontrolledState");
function v(e) {
return typeof e == "function";
}
m(v, "isFunction");
var y = Symbol("RADIX:SYNC_STATE");
function b(e, n, r, i) {
let { prop: a, defaultProp: o, onChange: s, caller: c } = n, l = a !== void 0, u = f(s), d = [{
...r,
state: o
}];
i && d.push(i);
let [p, m] = t.useReducer((t, n) => {
if (n.type === y) return {
...t,
state: n.state
};
let r = e(t, n);
return l && !Object.is(r.state, t.state) && u(r.state), r;
}, ...d), h = p.state, g = t.useRef(h);
t.useEffect(() => {
g.current !== h && (g.current = h, l || u(h));
}, [
h,
g,
l
]);
let _ = t.useMemo(() => a === void 0 ? p : {
...p,
state: a
}, [p, a]);
return t.useEffect(() => {
l && !Object.is(a, p.state) && m({
type: y,
state: a
});
}, [
a,
p.state,
l
]), [_, m];
}
m(b, "useControllableStateReducer");
//#endregion
export { a as n, g as t };
//# sourceMappingURL=dist-CwCVtfik.js.map