UNPKG

@artmate/chat

Version:

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

20 lines (19 loc) 583 B
import { ref as p, computed as f, unref as i } from "vue"; const x = (t) => { let o = p({ expandedKeys: [], onExpand: () => { } }); const n = f(() => { let e = i(o); return t ? (typeof t == "object" && (o.value = { ...o, ...t }), [!0, e.expandedKeys, e.onExpand]) : [!1, e.expandedKeys, e.onExpand]; }), a = p(n.value[1]), r = (e) => { const s = n.value[2], d = a.value, l = d.includes(e) ? d.filter((u) => u !== e) : [...d, e]; s == null || s(l), a.value = l; }; return [n.value[0], a, n.value[0] ? r : void 0]; }; export { x as default };