UNPKG

dk-plus

Version:
43 lines (42 loc) 1.23 kB
import { computed as u, ref as m } from "vue"; import { isBoolean as a } from "../../../_utils/typeof/index.js"; import { humpConversion as c, sizeChange as h } from "../../../_utils/filtration/index.js"; import { getProps as L } from "../get-props/index.js"; import "../../../_icon/index.js"; const j = (f, i) => { const { filter: o } = L(f), p = (t, n) => u(() => { const s = m([]), e = o(t); n && s.value.push(n); for (const r in e) e[r] && s.value.push( `dk-${i}_${a(e[r]) ? c(r) : e[r]}` ); return s.value; }), l = (t, n, s = !0) => { const r = (typeof s == "boolean" ? s : s === n || Array.isArray(s) && s.includes(t.toString())) ? h(t) : t; return String(r); }; return { classes: p, styles: (t, n = !0) => { const s = o(t), e = Object.fromEntries( Object.entries(s).filter(([, r]) => r).map(([r, y]) => [ `--${i}-${c(r)}`, l(y, r, n) ]) ); return u(() => e); }, stylesList: (t, n = 0) => { if (Array.isArray(t)) { if (t.length > n) return t[n]; } else if (typeof t == "string" && n === 0) return t; return null; } }; }; export { j as getStyleList };