@aplus-frontend/ui
Version:
93 lines (92 loc) • 3.03 kB
JavaScript
import { defineComponent as U, ref as x, computed as v, unref as n, watch as D, createElementBlock as k, openBlock as s, normalizeClass as w, createElementVNode as b, createVNode as i, withCtx as d, createBlock as u, resolveDynamicComponent as C, Fragment as L, renderList as j, mergeProps as z } from "vue";
import { Checkbox as g, Row as F, Col as I } from "@aplus-frontend/antdv";
import "../../../../config-provider/index.mjs";
import { useInjectApTable as R } from "../../../context.mjs";
import { getLabelNode as y } from "../utils.mjs";
import { useNamespace as T } from "../../../../config-provider/hooks/use-namespace.mjs";
const M = /* @__PURE__ */ U({
__name: "index",
props: {
value: {}
},
setup(_) {
const r = _, { b: h } = T("ap-column-setting-select-group"), c = x(!1), { columnsBackup: S, renderConfig: m } = R(), f = v(() => n(S)?.find(
(t) => t.key === r.value?.key
));
function A(e) {
const t = r.value.children.find((o) => o.key === e.key);
return {
checked: t?.show,
disabled: r.value.disabled || t?.disabled
};
}
function B(e) {
const t = r.value;
t.children.forEach((o) => o.show = e), t.show = e, c.value = !1;
}
function N(e, t) {
const o = r.value, a = o.children.find((l) => l.key === e);
if (!a)
return;
a.show = t;
const p = o.children.every((l) => l.show), P = o.children.some((l) => l.show);
o.show = p, c.value = P && !p;
}
const E = v(() => r.value.disabled || r.value.children.every((e) => e.disabled));
return D(
() => r.value,
(e) => {
const t = e.children.every((a) => a.show), o = e.children.some((a) => a.show);
c.value = o && !t, e.show !== t && (e.show = t);
},
{
deep: !0,
immediate: !0
}
), (e, t) => (s(), k("div", {
class: w(n(h)())
}, [
b("div", {
class: w(n(h)("header"))
}, [
i(n(g), {
indeterminate: c.value,
checked: e.value?.show,
disabled: E.value,
"onUpdate:checked": B
}, {
default: d(() => [
(s(), u(C(n(y)(f.value, n(m)))))
]),
_: 1
}, 8, ["indeterminate", "checked", "disabled"])
], 2),
b("div", null, [
i(n(F), { align: "middle" }, {
default: d(() => [
(s(!0), k(L, null, j(f.value.children, (o) => (s(), u(n(I), {
key: o.key,
span: 8
}, {
default: d(() => [
i(n(g), z({ ref_for: !0 }, A(o), {
"onUpdate:checked": (a) => N(o.key, a)
}), {
default: d(() => [
(s(), u(C(n(y)(o, n(m)))))
]),
_: 2
}, 1040, ["onUpdate:checked"])
]),
_: 2
}, 1024))), 128))
]),
_: 1
})
])
], 2));
}
});
export {
M as default
};