UNPKG

@spark-ui/internal-utils

Version:

package for sharing reusable code and resources across the codebase

46 lines (45 loc) 1.7 kB
import { isValidElement as c, Children as u, useCallback as i, useRef as l } from "react"; function m(e) { return e; } function b(e) { return e; } const y = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), g = Object.freeze(Object.defineProperty({ __proto__: null, designs: ["filled", "outlined", "tinted", "ghost", "contrast", "dashed"], intents: ["current", "main", "support", "success", "error", "info", "alert", "danger", "neutral", "surface", "surfaceInverse", "accent", "basic"], shapes: ["rounded", "square", "pill"], sizes: ["current", "sm", "md", "lg", "xl"] }, Symbol.toStringTag, { value: "Module" })); function d(e) { return c(e) && (function(r) { return c(r) && !!r.props.children; })(e) && u.toArray(e.props.children).reduce(((r, n) => r || c(n)), !1); } function f(e, r) { let n; return u.toArray(e).find(((o, t, s) => r(o, t, s) ? (n = o, !0) : !(!c(o) || !d(o)) && (n = f(o.props.children, r), n !== void 0))), n; } const h = () => (e, r) => r.reduce(((n, o) => { const [t, s] = n, a = o; return s[a] !== void 0 && (t[a] = s[a]), delete s[a], [t, s]; }), [{}, { ...e }]); function _(e, r) { const n = {}; return Object.keys(e).forEach(((o) => { const t = o; r.includes(t) || (n[t] = e[t]); })), n; } function v(e, r = {}) { const { sync: n = !1 } = r, o = (function(t) { const s = l(t); return s.current = t, s; })(e); return i(((...t) => n ? queueMicrotask((() => o.current?.(...t))) : o.current?.(...t)), [n, o]); } export { y as VariantTypes, h as createSplitProps, f as deepFind, b as makeVariants, _ as omit, m as tw, v as useEvent, g as variantConstants };