UNPKG

@spark-ui/internal-utils

Version:

package for sharing reusable code and resources across the codebase

46 lines (45 loc) 1.66 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", "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, t) => r || c(t), !1); } function f(e, r) { let t; return u.toArray(e).find((o, n, s) => r(o, n, s) ? (t = o, !0) : !(!c(o) || !d(o)) && (t = f(o.props.children, r), t !== void 0)), t; } const h = () => (e, r) => r.reduce((t, o) => { const [n, s] = t, a = o; return s[a] !== void 0 && (n[a] = s[a]), delete s[a], [n, s]; }, [{}, { ...e }]); function _(e, r) { const t = {}; return Object.keys(e).forEach((o) => { const n = o; r.includes(n) || (t[n] = e[n]); }), t; } function v(e, r = {}) { const { sync: t = !1 } = r, o = function(n) { const s = l(n); return s.current = n, s; }(e); return i((...n) => t ? queueMicrotask(() => o.current?.(...n)) : o.current?.(...n), [t, 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 };