adverich-kun-ui 0.1.337 → 0.1.338
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { computed as
|
|
2
|
-
import { getNestedValue as
|
|
1
|
+
import { computed as i, createElementBlock as d, openBlock as c, normalizeClass as V, createElementVNode as m, createVNode as S, renderSlot as f, createTextVNode as b, toDisplayString as v, Fragment as K, renderList as x, unref as k, withCtx as C } from "vue";
|
|
2
|
+
import { getNestedValue as s } from "../../../../utils/tableFormatters.js";
|
|
3
3
|
import N from "../../../KunVirtualScroller/src/components/KunVirtualScroller.vue.js";
|
|
4
4
|
import P from "../../../KunCheckbox/src/components/KunCheckbox.vue.js";
|
|
5
|
-
const
|
|
5
|
+
const B = { class: "sticky top-0 z-10 flex border-b text-sm font-semibold" }, T = { class: "p-2 border-r flex-1" }, j = { class: "flex border-b text-sm" }, z = { class: "p-2 border-r flex-1" }, U = {
|
|
6
6
|
__name: "KunRelationMatrix",
|
|
7
7
|
props: {
|
|
8
8
|
rows: Array,
|
|
@@ -27,61 +27,69 @@ const T = { class: "sticky top-0 z-10 flex border-b text-sm font-semibold" }, w
|
|
|
27
27
|
rounded: { type: String, default: "rounded" }
|
|
28
28
|
},
|
|
29
29
|
emits: ["update:modelValue"],
|
|
30
|
-
setup(
|
|
31
|
-
const r =
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
30
|
+
setup(o, { emit: A }) {
|
|
31
|
+
const r = o, L = A, y = i(() => r.rowKey), u = i(() => r.columnKey), w = i(() => r.rowLabel), $ = i(() => r.columnLabel), g = i(() => {
|
|
32
|
+
if (Object.keys(r.modelValue).length) return r.modelValue;
|
|
33
|
+
const l = {};
|
|
34
|
+
for (const a of r.rows) {
|
|
35
|
+
const t = s(a, r.rowKey), e = s(a, r.relationPath);
|
|
36
|
+
Array.isArray(e) && (l[t] = e.map((n) => s(n, r.relationKey)).filter(Boolean));
|
|
37
|
+
}
|
|
38
|
+
return l;
|
|
39
|
+
});
|
|
40
|
+
function p(l, a, t) {
|
|
41
|
+
const e = structuredClone(g.value);
|
|
42
|
+
Array.isArray(e[l]) || (e[l] = []), t ? e[l].includes(a) || e[l].push(a) : e[l] = e[l].filter((n) => n !== a), L("update:modelValue", e);
|
|
35
43
|
}
|
|
36
|
-
function
|
|
44
|
+
function h(l, a) {
|
|
37
45
|
var e;
|
|
38
46
|
if (!r.relationPath)
|
|
39
|
-
return (((e =
|
|
40
|
-
const t =
|
|
41
|
-
return Array.isArray(t) ? t.some((
|
|
47
|
+
return (((e = g.value) == null ? void 0 : e[l[y.value]]) ?? []).includes(a);
|
|
48
|
+
const t = s(l, r.relationPath);
|
|
49
|
+
return Array.isArray(t) ? t.some((n) => s(n, r.relationKey) === a) : !1;
|
|
42
50
|
}
|
|
43
|
-
return (l,
|
|
44
|
-
class:
|
|
51
|
+
return (l, a) => (c(), d("div", {
|
|
52
|
+
class: V(["overflow-auto", [o.border, o.rounded]])
|
|
45
53
|
}, [
|
|
46
|
-
m("div",
|
|
47
|
-
m("div",
|
|
48
|
-
|
|
49
|
-
b(
|
|
54
|
+
m("div", B, [
|
|
55
|
+
m("div", T, [
|
|
56
|
+
f(l.$slots, "row-header", {}, () => [
|
|
57
|
+
b(v(o.relationTitle), 1)
|
|
50
58
|
])
|
|
51
59
|
]),
|
|
52
|
-
(
|
|
53
|
-
key: t[
|
|
60
|
+
(c(!0), d(K, null, x(o.columns, (t) => (c(), d("div", {
|
|
61
|
+
key: t[u.value],
|
|
54
62
|
class: "p-2 border-r text-center"
|
|
55
63
|
}, [
|
|
56
|
-
|
|
57
|
-
b(
|
|
64
|
+
f(l.$slots, "column-header", { column: t }, () => [
|
|
65
|
+
b(v(k(s)(t, $.value)), 1)
|
|
58
66
|
])
|
|
59
67
|
]))), 128))
|
|
60
68
|
]),
|
|
61
|
-
|
|
62
|
-
items:
|
|
69
|
+
S(N, {
|
|
70
|
+
items: o.rows,
|
|
63
71
|
estimatedItemHeight: 48
|
|
64
72
|
}, {
|
|
65
73
|
default: C(({ item: t }) => [
|
|
66
|
-
m("div",
|
|
67
|
-
m("div",
|
|
68
|
-
|
|
69
|
-
b(
|
|
74
|
+
m("div", j, [
|
|
75
|
+
m("div", z, [
|
|
76
|
+
f(l.$slots, "row-label", { row: t }, () => [
|
|
77
|
+
b(v(k(s)(t, w.value)), 1)
|
|
70
78
|
])
|
|
71
79
|
]),
|
|
72
|
-
(
|
|
73
|
-
key: e[
|
|
74
|
-
class:
|
|
80
|
+
(c(!0), d(K, null, x(o.columns, (e) => (c(), d("div", {
|
|
81
|
+
key: e[u.value],
|
|
82
|
+
class: V(["p-2 border-r text-center", o.cellClass])
|
|
75
83
|
}, [
|
|
76
|
-
|
|
84
|
+
f(l.$slots, "cell", {
|
|
77
85
|
row: t,
|
|
78
86
|
column: e,
|
|
79
|
-
checked:
|
|
80
|
-
toggle: (
|
|
87
|
+
checked: h(t, e[u.value]),
|
|
88
|
+
toggle: (n) => p(t[y.value], e[u.value], n)
|
|
81
89
|
}, () => [
|
|
82
|
-
|
|
83
|
-
modelValue:
|
|
84
|
-
"onUpdate:modelValue": (
|
|
90
|
+
S(P, {
|
|
91
|
+
modelValue: h(t, e[u.value]),
|
|
92
|
+
"onUpdate:modelValue": (n) => p(t[y.value], e[u.value], n)
|
|
85
93
|
}, null, 8, ["modelValue", "onUpdate:modelValue"])
|
|
86
94
|
])
|
|
87
95
|
], 2))), 128))
|
|
@@ -93,5 +101,5 @@ const T = { class: "sticky top-0 z-10 flex border-b text-sm font-semibold" }, w
|
|
|
93
101
|
}
|
|
94
102
|
};
|
|
95
103
|
export {
|
|
96
|
-
|
|
104
|
+
U as default
|
|
97
105
|
};
|