adverich-kun-ui 0.1.340 → 0.1.341
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 c, createElementBlock as m, openBlock as f, normalizeClass as
|
|
2
|
-
import { getNestedValue as
|
|
3
|
-
import
|
|
1
|
+
import { computed as c, watchEffect as N, toRaw as O, createElementBlock as m, openBlock as f, normalizeClass as K, createElementVNode as y, createVNode as w, renderSlot as b, createTextVNode as V, toDisplayString as g, Fragment as A, renderList as x, unref as u, withCtx as P } from "vue";
|
|
2
|
+
import { getNestedValue as o } from "../../../../utils/tableFormatters.js";
|
|
3
|
+
import j from "../../../KunVirtualScroller/src/components/KunVirtualScroller.vue.js";
|
|
4
4
|
import B from "../../../KunCheckbox/src/components/KunCheckbox.vue.js";
|
|
5
|
-
const
|
|
5
|
+
const E = { class: "sticky top-0 z-10 flex border-b text-sm font-semibold" }, M = { class: "p-2 border-r w-[16rem] shrink-0" }, R = { class: "flex border-b text-sm" }, T = { class: "p-2 border-r w-[16rem] shrink-0" }, _ = { class: "text-xs p-2" }, J = {
|
|
6
6
|
__name: "KunRelationMatrix",
|
|
7
7
|
props: {
|
|
8
8
|
rows: Array,
|
|
@@ -28,81 +28,87 @@ const T = { class: "sticky top-0 z-10 flex border-b text-sm font-semibold" }, j
|
|
|
28
28
|
// 'row' o 'column'
|
|
29
29
|
},
|
|
30
30
|
emits: ["update:modelValue"],
|
|
31
|
-
setup(
|
|
32
|
-
const e =
|
|
31
|
+
setup(s, { emit: L }) {
|
|
32
|
+
const e = s, $ = L, h = c(() => e.rowKey), d = c(() => e.columnKey), C = c(() => e.rowLabel), D = c(() => e.columnLabel), p = c(() => {
|
|
33
33
|
if (Object.keys(e.modelValue).length) return e.modelValue;
|
|
34
|
-
const
|
|
35
|
-
for (const t of
|
|
36
|
-
const
|
|
37
|
-
Array.isArray(
|
|
34
|
+
const r = e.relationDirection === "column" ? e.columns : e.rows, a = e.relationDirection === "column" ? e.columnKey : e.rowKey, l = {};
|
|
35
|
+
for (const t of r) {
|
|
36
|
+
const n = o(t, a), i = o(t, e.relationPath);
|
|
37
|
+
Array.isArray(i) && (l[n] = i.map((v) => o(v, e.relationKey)).filter(Boolean));
|
|
38
38
|
}
|
|
39
|
-
return
|
|
39
|
+
return l;
|
|
40
40
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
N(() => {
|
|
42
|
+
console.log("internalModel:", JSON.stringify(O(p.value), null, 2));
|
|
43
|
+
});
|
|
44
|
+
function k(r, a, l) {
|
|
45
|
+
const t = structuredClone(
|
|
46
|
+
e.modelValue && Object.keys(e.modelValue).length ? e.modelValue : p.value
|
|
47
|
+
);
|
|
48
|
+
Array.isArray(t[r]) || (t[r] = []), l ? t[r].includes(a) || t[r].push(a) : t[r] = t[r].filter((n) => n !== a), $("update:modelValue", t);
|
|
44
49
|
}
|
|
45
|
-
function
|
|
46
|
-
const
|
|
50
|
+
function S(r, a) {
|
|
51
|
+
const l = o(r, h.value), t = o(a, d.value);
|
|
47
52
|
if (e.relationDirection === "column") {
|
|
48
|
-
const
|
|
49
|
-
return Array.isArray(
|
|
53
|
+
const i = o(a, e.relationPath);
|
|
54
|
+
return Array.isArray(i) ? i.some((v) => o(v, e.relationKey) === l) : !1;
|
|
50
55
|
}
|
|
51
|
-
const
|
|
52
|
-
return Array.isArray(
|
|
56
|
+
const n = o(r, e.relationPath);
|
|
57
|
+
return Array.isArray(n) ? n.some((i) => o(i, e.relationKey) === t) : !1;
|
|
53
58
|
}
|
|
54
|
-
return (
|
|
55
|
-
class:
|
|
59
|
+
return (r, a) => (f(), m("div", {
|
|
60
|
+
class: K(["overflow-auto", [s.border, s.rounded]])
|
|
56
61
|
}, [
|
|
57
|
-
y("div",
|
|
58
|
-
y("div",
|
|
59
|
-
b(
|
|
60
|
-
|
|
62
|
+
y("div", E, [
|
|
63
|
+
y("div", M, [
|
|
64
|
+
b(r.$slots, "row-header", {}, () => [
|
|
65
|
+
V(g(s.relationTitle), 1)
|
|
61
66
|
])
|
|
62
67
|
]),
|
|
63
|
-
(f(!0), m(
|
|
64
|
-
key:
|
|
68
|
+
(f(!0), m(A, null, x(s.columns, (l) => (f(), m("div", {
|
|
69
|
+
key: l[d.value],
|
|
65
70
|
class: "p-2 border-r text-center w-[8rem] shrink-0"
|
|
66
71
|
}, [
|
|
67
|
-
b(
|
|
68
|
-
|
|
72
|
+
b(r.$slots, "column-header", { column: l }, () => [
|
|
73
|
+
V(g(u(o)(l, D.value)), 1)
|
|
69
74
|
])
|
|
70
75
|
]))), 128))
|
|
71
76
|
]),
|
|
72
|
-
|
|
73
|
-
items:
|
|
77
|
+
w(j, {
|
|
78
|
+
items: s.rows,
|
|
74
79
|
estimatedItemHeight: 48
|
|
75
80
|
}, {
|
|
76
|
-
default:
|
|
77
|
-
y("div",
|
|
78
|
-
y("div",
|
|
79
|
-
b(
|
|
80
|
-
|
|
81
|
+
default: P(({ item: l }) => [
|
|
82
|
+
y("div", R, [
|
|
83
|
+
y("div", T, [
|
|
84
|
+
b(r.$slots, "row-label", { row: l }, () => [
|
|
85
|
+
V(g(u(o)(l, C.value)), 1)
|
|
81
86
|
])
|
|
82
87
|
]),
|
|
83
|
-
(f(!0), m(
|
|
88
|
+
(f(!0), m(A, null, x(s.columns, (t) => (f(), m("div", {
|
|
84
89
|
key: t[d.value],
|
|
85
|
-
class:
|
|
90
|
+
class: K(["p-2 border-r text-center w-[8rem] shrink-0", s.cellClass])
|
|
86
91
|
}, [
|
|
87
|
-
b(
|
|
88
|
-
row:
|
|
92
|
+
b(r.$slots, "cell", {
|
|
93
|
+
row: l,
|
|
89
94
|
column: t,
|
|
90
|
-
checked:
|
|
91
|
-
toggle: (
|
|
95
|
+
checked: S(l, t),
|
|
96
|
+
toggle: (n) => k(u(o)(l, h.value), u(o)(t, d.value), n)
|
|
92
97
|
}, () => [
|
|
93
|
-
|
|
94
|
-
modelValue:
|
|
95
|
-
"onUpdate:modelValue": (
|
|
98
|
+
w(B, {
|
|
99
|
+
modelValue: S(l, t),
|
|
100
|
+
"onUpdate:modelValue": (n) => k(u(o)(l, h.value), u(o)(t, d.value), n)
|
|
96
101
|
}, null, 8, ["modelValue", "onUpdate:modelValue"])
|
|
97
102
|
])
|
|
98
103
|
], 2))), 128))
|
|
99
104
|
])
|
|
100
105
|
]),
|
|
101
106
|
_: 3
|
|
102
|
-
}, 8, ["items"])
|
|
107
|
+
}, 8, ["items"]),
|
|
108
|
+
y("pre", _, g(p.value), 1)
|
|
103
109
|
], 2));
|
|
104
110
|
}
|
|
105
111
|
};
|
|
106
112
|
export {
|
|
107
|
-
|
|
113
|
+
J as default
|
|
108
114
|
};
|