vuux
Version:
Vue3 Nuxt3 Nuxt4 组件库
20 lines (19 loc) • 693 B
JavaScript
import { toRefs as v, computed as a, inject as x } from "vue";
const b = (i) => {
const { tableData: l, isFixedHead: o } = v(i), u = (e) => e.fixed && `is-fixed-${e.fixed}` || "", c = (e) => e.some((t) => t.select || t.children && c(t.children)), r = (e) => e.every((t) => t.select && (!t.children || r(t.children))), n = a(() => l.value.length == 0 ? !1 : r(l.value)), d = a(() => n.value ? !1 : c(l.value)), f = x("tableContext"), s = a({
get: () => n.value,
set: (e) => f?.selectAll(e)
});
return {
classNames: u,
isFixedHead: o,
isPartiallySelect: d,
isModel: s,
onUpdate: () => {
s.value = !s.value;
}
};
};
export {
b as useTableHeader
};