UNPKG

@aplus-frontend/ui

Version:

47 lines (46 loc) 1.19 kB
import { isBoolean as p } from "lodash-unified"; import { ref as f, computed as c } from "vue"; import { getStringName as m } from "../../item-group/helper.mjs"; import "../../../utils/index.mjs"; import { getTargetNode as d } from "./use-collapse-input-count.mjs"; import { isDef as u } from "../../../utils/is.mjs"; function l(n, r) { const i = new Set(n.map((o) => o.name)), a = /* @__PURE__ */ new Map(); for (const o of r) { const e = String(m(d(o).props?.name)); e && i.has(e) && a.set(e, o); } const s = /* @__PURE__ */ new Set(), t = []; for (const o of n) { const e = a.get(o.name); e && (t.push(e), s.add(e)); } for (const o of r) s.has(o) || t.push(o); return t; } const C = (n) => { const r = f(!1), i = c(() => (n.value || []).map((t) => { const e = d(t).props; return { label: e.description || e.label || e.placeholder, name: m(e.name), isHidden: p(e.hidden) ? !!e.hidden : u(e.hidden) }; })); function a(s) { const t = l( s || [], n.value || [] ); r.value = !0, n.value = t; } return { items: i, handleClickConfirm: a, sorted: r }; }; export { C as useSorter };