UNPKG

welcome-ui

Version:

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

62 lines (61 loc) 2.24 kB
"use client"; import { c as F, _ as p, O as d, A as I, L as q, u as _, d as x, p as Y, a as T, W as j, X as w, j as L, h as H, Y as V, Z as W, f as X, b as Z } from "./OE2EFRVA-C3721cM3.js"; import { useRef as C, useState as D, useEffect as z } from "react"; var G = "button"; function M(s) { if (!s.isTrusted) return !1; const t = s.currentTarget; return s.key === "Enter" ? d(t) || t.tagName === "SUMMARY" || t.tagName === "A" : s.key === " " ? d(t) || t.tagName === "SUMMARY" || t.tagName === "INPUT" || t.tagName === "SELECT" : !1; } var J = Symbol("command"), Q = F( function(t) { var i = t, { clickOnEnter: m = !0, clickOnSpace: u = !0 } = i, r = p(i, ["clickOnEnter", "clickOnSpace"]); const c = C(null), [K, R] = D(!1); z(() => { c.current && R(d(c.current)); }, []); const [U, k] = D(!1), f = C(!1), y = I(r), [E, A] = q(r, J, !0), P = r.onKeyDown, O = _((e) => { P == null || P(e); const a = e.currentTarget; if (e.defaultPrevented || E || y || !L(e) || H(a) || a.isContentEditable) return; const o = m && e.key === "Enter", n = u && e.key === " ", g = e.key === "Enter" && !m, l = e.key === " " && !u; if (g || l) { e.preventDefault(); return; } if (o || n) { const v = M(e); if (o) { if (!v) { e.preventDefault(); const S = e, { view: $ } = S, B = p(S, ["view"]), N = () => w(a, B); V() ? W(a, "keyup", N) : queueMicrotask(N); } } else n && (f.current = !0, v || (e.preventDefault(), k(!0))); } }), b = r.onKeyUp, h = _((e) => { if (b == null || b(e), e.defaultPrevented || E || y || e.metaKey) return; const a = u && e.key === " "; if (f.current && a && (f.current = !1, !M(e))) { e.preventDefault(), k(!1); const o = e.currentTarget, n = e, { view: g } = n, l = p(n, ["view"]); queueMicrotask(() => w(o, l)); } }); return r = x(T(T({ "data-active": U || void 0, type: K ? "button" : void 0 }, A), r), { ref: Y(c, r.ref), onKeyDown: O, onKeyUp: h }), r = j(r), r; } ); X(function(t) { const i = Q(t); return Z(G, i); }); export { Q as u };