UNPKG

welcome-ui

Version:

Customizable design system with react, typescript, tailwindcss and ariakit.

347 lines (341 loc) 10.3 kB
"use client"; import { i as rt, v as C, N as ot, O as ut, P as st, Q as $, I as at, R as it, S as ct, k as M, u as ft, T as lt } from "./U6HHPQDW-CzxyP5H7.js"; import * as I from "react"; import J from "react"; import { g as St } from "./index-B6iGEm-i.js"; function V(t, n) { const e = t.__unstableInternals; return rt(e, "Invalid store"), e[n]; } function G(t, ...n) { let e = t, l = e, s = Symbol(), o = it; const a = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), g = (u) => (v.add(u), () => v.delete(u)), x = () => { const u = a.size, r = Symbol(); a.add(r); const b = () => { a.delete(r), !a.size && o(); }; if (u) return b; const w = st(e).map( (L) => $( ...n.map((T) => { var h; const D = (h = T == null ? void 0 : T.getState) == null ? void 0 : h.call(T); if (D && C(D, L)) return k(T, [L], (j) => { p( L, j[L], // @ts-expect-error - Not public API. This is just to prevent // infinite loops. !0 ); }); }) ) ), A = []; for (const L of v) A.push(L()); const q = n.map(X); return o = $(...w, ...A, ...q), b; }, E = (u, r, b = m) => (b.add(r), S.set(r, u), () => { var w; (w = i.get(r)) == null || w(), i.delete(r), S.delete(r), b.delete(r); }), R = (u, r) => E(u, r), N = (u, r) => (i.set(r, r(e, e)), E(u, r)), P = (u, r) => (i.set(r, r(e, l)), E(u, r, _)), d = (u) => G(ut(e, u), y), f = (u) => G(ot(e, u), y), O = () => e, p = (u, r, b = !1) => { var w; if (!C(e, u)) return; const A = at(r, e[u]); if (A === e[u]) return; if (!b) for (const h of n) (w = h == null ? void 0 : h.setState) == null || w.call(h, u, A); const q = e; e = { ...e, [u]: A }; const L = Symbol(); s = L, c.add(u); const T = (h, D, j) => { var W; const H = S.get(h), nt = (z) => j ? j.has(z) : z === u; (!H || H.some(nt)) && ((W = i.get(h)) == null || W(), i.set(h, h(e, D))); }; for (const h of m) T(h, q); queueMicrotask(() => { if (s !== L) return; const h = e; for (const D of _) T(D, l, c); l = h, c.clear(); }); }, y = { getState: O, setState: p, __unstableInternals: { setup: g, init: x, subscribe: R, sync: N, batch: P, pick: d, omit: f } }; return y; } function yt(t, ...n) { if (t) return V(t, "setup")(...n); } function X(t, ...n) { if (t) return V(t, "init")(...n); } function Z(t, ...n) { if (t) return V(t, "subscribe")(...n); } function k(t, ...n) { if (t) return V(t, "sync")(...n); } function dt(t, ...n) { if (t) return V(t, "batch")(...n); } function wt(t, ...n) { if (t) return V(t, "omit")(...n); } function Lt(t, ...n) { if (t) return V(t, "pick")(...n); } function xt(...t) { var n; const e = {}; for (const s of t) { const o = (n = s == null ? void 0 : s.getState) == null ? void 0 : n.call(s); o && Object.assign(e, o); } const l = G(e, ...t); return Object.assign({}, ...t, l); } function Rt(t, n) { if (process.env.NODE_ENV === "production" || !n) return; const e = Object.entries(t).filter(([o, a]) => o.startsWith("default") && a !== void 0).map(([o]) => { var a; const c = o.replace("default", ""); return `${((a = c[0]) == null ? void 0 : a.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 U = { exports: {} }, B = {}, F; function pt() { if (F) return B; F = 1; var t = J; function n(i, S) { return i === S && (i !== 0 || 1 / i === 1 / S) || i !== i && S !== S; } var e = typeof Object.is == "function" ? Object.is : n, l = t.useState, s = t.useEffect, o = t.useLayoutEffect, a = t.useDebugValue; function c(i, S) { var g = S(), x = l({ inst: { value: g, getSnapshot: S } }), E = x[0].inst, R = x[1]; return o(function() { E.value = g, E.getSnapshot = S, v(E) && R({ inst: E }); }, [i, g, S]), s(function() { return v(E) && R({ inst: E }), i(function() { v(E) && R({ inst: E }); }); }, [i]), a(g), g; } function v(i) { var S = i.getSnapshot; i = i.value; try { var g = S(); return !e(i, g); } catch { return !0; } } function m(i, S) { return S(); } var _ = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? m : c; return B.useSyncExternalStore = t.useSyncExternalStore !== void 0 ? t.useSyncExternalStore : _, B; } var K = {}, Y; function vt() { return Y || (Y = 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 = J, n = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; function e(d) { { 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", d, O); } } function l(d, f, O) { { var p = n.ReactDebugCurrentFrame, y = p.getStackAddendum(); y !== "" && (f += "%s", O = O.concat([y])); var u = O.map(function(r) { return String(r); }); u.unshift("Warning: " + f), Function.prototype.apply.call(console[d], console, u); } } function s(d, f) { return d === f && (d !== 0 || 1 / d === 1 / f) || d !== d && f !== f; } var o = typeof Object.is == "function" ? Object.is : s, a = t.useState, c = t.useEffect, v = t.useLayoutEffect, m = t.useDebugValue, _ = !1, i = !1; function S(d, 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 u = a({ inst: { value: p, getSnapshot: f } }), r = u[0].inst, b = u[1]; return v(function() { r.value = p, r.getSnapshot = f, g(r) && b({ inst: r }); }, [d, p, f]), c(function() { g(r) && b({ inst: r }); var w = function() { g(r) && b({ inst: r }); }; return d(w); }, [d]), m(p), p; } function g(d) { var f = d.getSnapshot, O = d.value; try { var p = f(); return !o(O, p); } catch { return !0; } } function x(d, f, O) { return f(); } var E = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", R = !E, N = R ? x : S, P = t.useSyncExternalStore !== void 0 ? t.useSyncExternalStore : N; K.useSyncExternalStore = P, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error()); }()), K; } var Q; function _t() { return Q || (Q = 1, process.env.NODE_ENV === "production" ? U.exports = pt() : U.exports = vt()), U.exports; } var ht = _t(); const mt = /* @__PURE__ */ St(ht); var { useSyncExternalStore: tt } = mt, et = () => () => { }; function Et(t, n = ct) { const e = I.useCallback( (s) => t ? Z(t, null, s) : et(), [t] ), l = () => { const s = typeof n == "string" ? n : null, o = typeof n == "function" ? n : null, a = t == null ? void 0 : t.getState(); if (o) return o(a); if (a && s && C(a, s)) return a[s]; }; return tt(e, l, l); } function Tt(t, n) { const e = I.useRef( {} ), l = I.useCallback( (o) => t ? Z(t, null, o) : et(), [t] ), s = () => { const o = t == null ? void 0 : t.getState(); let a = !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] = _, a = !0); } if (typeof m == "string") { if (!o || !C(o, m)) continue; const _ = o[m]; _ !== c[v] && (c[v] = _, a = !0); } } return a && (e.current = { ...c }), e.current; }; return tt(l, s, s); } function Vt(t, n, e, l) { const s = C(n, e) ? n[e] : void 0, o = l ? n[l] : void 0, a = lt({ value: s, setValue: o }); M(() => k(t, [e], (c, v) => { const { value: m, setValue: _ } = a.current; _ && c[e] !== v[e] && c[e] !== m && _(c[e]); }), [t, e]), M(() => { if (s !== void 0) return t.setState(e, s), dt(t, [e], () => { s !== void 0 && t.setState(e, s); }); }); } function At(t, n) { const [e, l] = I.useState(() => t(n)); M(() => X(e), [e]); const s = I.useCallback( (c) => Et(e, c), [e] ), o = I.useMemo( () => ({ ...e, useState: s }), [e, s] ), a = ft(() => { l((c) => t({ ...n, ...c.getState() })); }); return [o, a]; } export { Vt as a, Et as b, G as c, k as d, Z as e, Tt as f, dt as g, X as i, xt as m, wt as o, Lt as p, yt as s, Rt as t, At as u };