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