UNPKG

dk-plus

Version:
29 lines (28 loc) 769 B
import { computed as u, reactive as s, toRefs as y } from "vue"; import { DK_TYPE as d, DK_SIZE as z } from "../../../_tokens/public/index.js"; import { isArray as a } from "../../../_utils/typeof/index.js"; const K = (t) => { const i = (e = "default") => u(() => !t || t.type && !d.includes(t.type) ? e : t.type || e), f = (e = "large") => u(() => !t || t.size && !z.includes(t.size) ? e : t.size || e), c = { type: i, size: f }; return { getType: i, getSize: f, getProp: (e, o) => { const r = {}; return a(e) && e.forEach((n, g) => { if (c[n]) { const m = o && o[g]; r[n] = c[n](m); } }), t ? s({ ...y(t), ...r }) : s(r); } }; }; export { K as getGlobal };