welcome-ui
Version:
Customizable design system with react • styled-components • styled-system and ariakit.
345 lines (339 loc) • 10.3 kB
JavaScript
"use client";
import { i as ot, Z as C, $ as at, a0 as st, a1 as ut, P as F, a2 as it, A as ct, C as ft, a3 as lt, I as dt, E as G, d as St, g as U, b as pt, a4 as vt } from "./LVA2YJMS-C-kJ1lkr.mjs";
import * as T from "react";
import Q from "react";
import { g as _t } from "./_commonjsHelpers-CXJ7dpIk.mjs";
function A(t, n) {
const e = t.__unstableInternals;
return ot(e, "Invalid store"), e[n];
}
function W(t, ...n) {
let e = t, l = e, s = Symbol(), o = lt;
const u = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), g = (a) => (v.add(a), () => v.delete(a)), x = () => {
const a = u.size, r = Symbol();
u.add(r);
const b = () => {
u.delete(r), !u.size && o();
};
if (a) return b;
const w = ut(e).map(
(L) => F(
...n.map((V) => {
var h;
const I = (h = V == null ? void 0 : V.getState) == null ? void 0 : h.call(V);
if (I && C(I, L))
return tt(V, [L], (j) => {
p(
L,
j[L],
// @ts-expect-error - Not public API. This is just to prevent
// infinite loops.
!0
);
});
})
)
), D = [];
for (const L of v)
D.push(L());
const K = n.map(X);
return o = F(...w, ...D, ...K), b;
}, E = (a, r, b = m) => (b.add(r), d.set(r, a), () => {
var w;
(w = i.get(r)) == null || w(), i.delete(r), d.delete(r), b.delete(r);
}), R = (a, r) => E(a, r), q = (a, r) => (i.set(r, r(e, e)), E(a, r)), B = (a, r) => (i.set(r, r(e, l)), E(a, r, _)), S = (a) => W(st(e, a), y), f = (a) => W(at(e, a), y), O = () => e, p = (a, r, b = !1) => {
var w;
if (!C(e, a)) return;
const D = it(r, e[a]);
if (D === e[a]) return;
if (!b)
for (const h of n)
(w = h == null ? void 0 : h.setState) == null || w.call(h, a, D);
const K = e;
e = ct(ft({}, e), { [a]: D });
const L = Symbol();
s = L, c.add(a);
const V = (h, I, j) => {
var $;
const H = d.get(h), rt = (z) => j ? j.has(z) : z === a;
(!H || H.some(rt)) && (($ = i.get(h)) == null || $(), i.set(h, h(e, I)));
};
for (const h of m)
V(h, K);
queueMicrotask(() => {
if (s !== L) return;
const h = e;
for (const I of _)
V(I, l, c);
l = h, c.clear();
});
}, y = {
getState: O,
setState: p,
__unstableInternals: {
setup: g,
init: x,
subscribe: R,
sync: q,
batch: B,
pick: S,
omit: f
}
};
return y;
}
function Rt(t, ...n) {
if (t)
return A(t, "setup")(...n);
}
function X(t, ...n) {
if (t)
return A(t, "init")(...n);
}
function k(t, ...n) {
if (t)
return A(t, "subscribe")(...n);
}
function tt(t, ...n) {
if (t)
return A(t, "sync")(...n);
}
function ht(t, ...n) {
if (t)
return A(t, "batch")(...n);
}
function Vt(t, ...n) {
if (t)
return A(t, "omit")(...n);
}
function At(t, ...n) {
if (t)
return A(t, "pick")(...n);
}
function Dt(...t) {
const n = t.reduce((l, s) => {
var o;
const u = (o = s == null ? void 0 : s.getState) == null ? void 0 : o.call(s);
return u ? Object.assign(l, u) : l;
}, {}), e = W(n, ...t);
return Object.assign({}, ...t, e);
}
function It(t, n) {
if (process.env.NODE_ENV === "production" || !n) return;
const e = Object.entries(t).filter(([o, u]) => o.startsWith("default") && u !== void 0).map(([o]) => {
var u;
const c = o.replace("default", "");
return `${((u = c[0]) == null ? void 0 : u.toLowerCase()) || ""}${c.slice(1)}`;
});
if (!e.length) return;
const l = n.getState();
if (e.filter(
(o) => C(l, o)
).length)
throw new Error(
`Passing a store prop in conjunction with a default state is not supported.
const store = useSelectStore();
<SelectProvider store={store} defaultValue="Apple" />
^ ^
Instead, pass the default state to the topmost store:
const store = useSelectStore({ defaultValue: "Apple" });
<SelectProvider store={store} />
See https://github.com/ariakit/ariakit/pull/2745 for more details.
If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
`
);
}
var P = { exports: {} }, M = {}, Y;
function mt() {
if (Y) return M;
Y = 1;
var t = Q;
function n(i, d) {
return i === d && (i !== 0 || 1 / i === 1 / d) || i !== i && d !== d;
}
var e = typeof Object.is == "function" ? Object.is : n, l = t.useState, s = t.useEffect, o = t.useLayoutEffect, u = t.useDebugValue;
function c(i, d) {
var g = d(), x = l({ inst: { value: g, getSnapshot: d } }), E = x[0].inst, R = x[1];
return o(function() {
E.value = g, E.getSnapshot = d, v(E) && R({ inst: E });
}, [i, g, d]), s(function() {
return v(E) && R({ inst: E }), i(function() {
v(E) && R({ inst: E });
});
}, [i]), u(g), g;
}
function v(i) {
var d = i.getSnapshot;
i = i.value;
try {
var g = d();
return !e(i, g);
} catch {
return !0;
}
}
function m(i, d) {
return d();
}
var _ = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? m : c;
return M.useSyncExternalStore = t.useSyncExternalStore !== void 0 ? t.useSyncExternalStore : _, M;
}
var N = {}, Z;
function Et() {
return Z || (Z = 1, process.env.NODE_ENV !== "production" && function() {
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
var t = Q, n = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function e(S) {
{
for (var f = arguments.length, O = new Array(f > 1 ? f - 1 : 0), p = 1; p < f; p++)
O[p - 1] = arguments[p];
l("error", S, O);
}
}
function l(S, f, O) {
{
var p = n.ReactDebugCurrentFrame, y = p.getStackAddendum();
y !== "" && (f += "%s", O = O.concat([y]));
var a = O.map(function(r) {
return String(r);
});
a.unshift("Warning: " + f), Function.prototype.apply.call(console[S], console, a);
}
}
function s(S, f) {
return S === f && (S !== 0 || 1 / S === 1 / f) || S !== S && f !== f;
}
var o = typeof Object.is == "function" ? Object.is : s, u = t.useState, c = t.useEffect, v = t.useLayoutEffect, m = t.useDebugValue, _ = !1, i = !1;
function d(S, f, O) {
_ || t.startTransition !== void 0 && (_ = !0, e("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
var p = f();
if (!i) {
var y = f();
o(p, y) || (e("The result of getSnapshot should be cached to avoid an infinite loop"), i = !0);
}
var a = u({
inst: {
value: p,
getSnapshot: f
}
}), r = a[0].inst, b = a[1];
return v(function() {
r.value = p, r.getSnapshot = f, g(r) && b({
inst: r
});
}, [S, p, f]), c(function() {
g(r) && b({
inst: r
});
var w = function() {
g(r) && b({
inst: r
});
};
return S(w);
}, [S]), m(p), p;
}
function g(S) {
var f = S.getSnapshot, O = S.value;
try {
var p = f();
return !o(O, p);
} catch {
return !0;
}
}
function x(S, f, O) {
return f();
}
var E = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", R = !E, q = R ? x : d, B = t.useSyncExternalStore !== void 0 ? t.useSyncExternalStore : q;
N.useSyncExternalStore = B, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
}()), N;
}
var J;
function gt() {
return J || (J = 1, process.env.NODE_ENV === "production" ? P.exports = mt() : P.exports = Et()), P.exports;
}
var Ot = gt();
const bt = /* @__PURE__ */ _t(Ot);
var { useSyncExternalStore: et } = bt, nt = () => () => {
};
function yt(t, n = dt) {
const e = T.useCallback(
(s) => t ? k(t, null, s) : nt(),
[t]
), l = () => {
const s = typeof n == "string" ? n : null, o = typeof n == "function" ? n : null, u = t == null ? void 0 : t.getState();
if (o) return o(u);
if (u && s && C(u, s))
return u[s];
};
return et(e, l, l);
}
function Tt(t, n) {
const e = T.useRef(
{}
), l = T.useCallback(
(o) => t ? k(t, null, o) : nt(),
[t]
), s = () => {
const o = t == null ? void 0 : t.getState();
let u = !1;
const c = e.current;
for (const v in n) {
const m = n[v];
if (typeof m == "function") {
const _ = m(o);
_ !== c[v] && (c[v] = _, u = !0);
}
if (typeof m == "string") {
if (!o || !C(o, m)) continue;
const _ = o[m];
_ !== c[v] && (c[v] = _, u = !0);
}
}
return u && (e.current = U({}, c)), e.current;
};
return et(l, s, s);
}
function Ct(t, n, e, l) {
const s = C(n, e) ? n[e] : void 0, o = l ? n[l] : void 0, u = vt({ value: s, setValue: o });
G(() => tt(t, [e], (c, v) => {
const { value: m, setValue: _ } = u.current;
_ && c[e] !== v[e] && c[e] !== m && _(c[e]);
}), [t, e]), G(() => {
if (s !== void 0)
return t.setState(e, s), ht(t, [e], () => {
s !== void 0 && t.setState(e, s);
});
});
}
function jt(t, n) {
const [e, l] = T.useState(() => t(n));
G(() => X(e), [e]);
const s = T.useCallback(
(c) => yt(e, c),
[e]
), o = T.useMemo(
() => St(U({}, e), { useState: s }),
[e, s]
), u = pt(() => {
l((c) => t(U(U({}, n), c.getState())));
});
return [o, u];
}
export {
jt as a,
Ct as b,
W as c,
tt as d,
k as e,
Tt as f,
ht as g,
X as i,
Dt as m,
Vt as o,
At as p,
Rt as s,
It as t,
yt as u
};