UNPKG

@artmate/chat

Version:

借鉴字节开源react库AntX,通过vue实现的版本

35 lines (34 loc) 851 B
import { computed as p } from "vue"; const s = "__ungrouped", f = (u, i = []) => { const o = p(() => { if (!u) return [!1, void 0, void 0]; let e = { sort: void 0, title: void 0 }; return typeof u == "object" && (e = { ...e, ...u }), [!0, e.sort, e.title]; }); return p(() => { if (!o.value[0]) return [[ { name: s, data: i, title: void 0 } ], o.value[0]]; const e = i.reduce((t, n) => { const r = n.group || s; return t[r] || (t[r] = []), t[r].push(n), t; }, {}); return [(o.value[1] && typeof o.value[1] != "boolean" ? Object.keys(e).sort(o.value[1]) : Object.keys(e)).map((t) => ({ name: t === s ? void 0 : t, title: o.value[2], data: e[t] })), o.value[0]]; }).value; }; export { f as default };