intable 0.0.58 → 0.0.60
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.
- package/LICENSE +21 -21
- package/README.md +97 -97
- package/dist/__uno.css +1 -1
- package/dist/hooks/useSelector.d.ts +2 -1
- package/dist/hooks/useSelector.js +48 -51
- package/dist/index.d.ts +4 -1
- package/dist/index.js +30 -15
- package/dist/plugins/DiffPlugin.js +4 -1
- package/dist/plugins/EditablePlugin.d.ts +1 -15
- package/dist/plugins/EditablePlugin.js +85 -80
- package/dist/plugins/ExpandPlugin.js +4 -1
- package/dist/plugins/HeaderGroup.js +38 -39
- package/dist/plugins/LoadMorePlugin.d.ts +1 -1
- package/dist/plugins/LoadMorePlugin.js +30 -31
- package/dist/plugins/PaginationPlugin.d.ts +22 -0
- package/dist/plugins/PaginationPlugin.js +105 -0
- package/dist/plugins/RenderPlugin/components.d.ts +4 -0
- package/dist/plugins/RenderPlugin/components.js +102 -47
- package/dist/plugins/RenderPlugin/index.d.ts +5 -0
- package/dist/plugins/RenderPlugin/index.js +51 -18
- package/dist/plugins/RowGroupPlugin.js +57 -58
- package/dist/plugins/RowSelectionPlugin.js +4 -1
- package/dist/plugins/TreePlugin.d.ts +4 -1
- package/dist/plugins/TreePlugin.js +54 -48
- package/dist/plugins/VirtualScrollPlugin.js +76 -77
- package/dist/style.css +2 -2
- package/dist/theme/antd.scss +41 -41
- package/dist/theme/dark.scss +46 -46
- package/dist/theme/element-plus.scss +38 -38
- package/dist/theme/github.scss +80 -80
- package/dist/theme/material.scss +73 -73
- package/dist/theme/shadcn.scss +66 -66
- package/dist/theme/stripe.scss +57 -57
- package/package.json +1 -1
|
@@ -1,100 +1,154 @@
|
|
|
1
1
|
import plus_default from "../../plus.js";
|
|
2
2
|
import x_default from "../../x.js";
|
|
3
|
-
import { createComponent, insert, memo, mergeProps, spread, template } from "solid-js/web";
|
|
4
|
-
import { For, splitProps } from "solid-js";
|
|
3
|
+
import { className, createComponent, delegateEvents, effect, insert, memo, mergeProps, setAttribute, setStyleProperty, spread, template } from "solid-js/web";
|
|
4
|
+
import { For, mergeProps as mergeProps$1, splitProps } from "solid-js";
|
|
5
5
|
import { combineProps } from "@solid-primitives/props";
|
|
6
|
-
var _tmpl$ = /* @__PURE__ */ template("<input type=checkbox>"), _tmpl$2 = /* @__PURE__ */ template("<div>");
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ template("<input type=checkbox>"), _tmpl$2 = /* @__PURE__ */ template("<div>"), _tmpl$3 = /* @__PURE__ */ template("<span>★"), _tmpl$4 = /* @__PURE__ */ template("<div><div class=\"flex-1 h-2 rd-full bg-gray-200 overflow-hidden\"><div class=\"h-full rd-full transition-all duration-300\"></div></div><span class=\"ml-1 text-11px c-gray-500 min-w-30px text-right\">%");
|
|
7
7
|
const Checkbox = (e) => {
|
|
8
|
-
let
|
|
9
|
-
return [e,
|
|
8
|
+
let x;
|
|
9
|
+
return [e, x] = splitProps(e, ["value", "onChange"]), x = combineProps({ get class() {
|
|
10
10
|
return `you-checkbox ${e.value && "checked"}`;
|
|
11
|
-
} },
|
|
12
|
-
var
|
|
13
|
-
return
|
|
11
|
+
} }, x), (() => {
|
|
12
|
+
var S = _tmpl$();
|
|
13
|
+
return S.addEventListener("change", (x) => e.onChange?.(x.currentTarget.checked)), spread(S, mergeProps({ get checked() {
|
|
14
14
|
return e.value || !1;
|
|
15
|
-
} },
|
|
15
|
+
} }, x), !1, !1), S;
|
|
16
16
|
})();
|
|
17
17
|
}, Files = (e) => {
|
|
18
|
-
let
|
|
19
|
-
return [e,
|
|
20
|
-
}, Tags = (
|
|
21
|
-
let
|
|
22
|
-
[
|
|
18
|
+
let x;
|
|
19
|
+
return [e, x] = splitProps(e, []), createComponent(Tags, mergeProps(x, { color: "" }));
|
|
20
|
+
}, Tags = (x) => {
|
|
21
|
+
let S;
|
|
22
|
+
[x, S] = splitProps(x, [
|
|
23
23
|
"value",
|
|
24
24
|
"children",
|
|
25
25
|
"disabled",
|
|
26
26
|
"onChange",
|
|
27
27
|
"onAdd",
|
|
28
28
|
"color"
|
|
29
|
-
]),
|
|
30
|
-
let
|
|
29
|
+
]), S = combineProps({ class: "in-tags flex flex-wrap items-center gap-2 h-full" }, S);
|
|
30
|
+
let w = (e) => Array.isArray(e) ? e : e == null ? [] : [e];
|
|
31
31
|
return (() => {
|
|
32
|
-
var
|
|
33
|
-
return spread(
|
|
32
|
+
var T = _tmpl$2();
|
|
33
|
+
return spread(T, S, !1, !0), insert(T, createComponent(For, {
|
|
34
34
|
get each() {
|
|
35
|
-
return
|
|
35
|
+
return w(x.value);
|
|
36
36
|
},
|
|
37
37
|
children: (e) => createComponent(Tag, {
|
|
38
38
|
get disabled() {
|
|
39
|
-
return
|
|
39
|
+
return x.disabled;
|
|
40
40
|
},
|
|
41
41
|
get value() {
|
|
42
42
|
return e?.text ?? e?.label ?? e?.name ?? e;
|
|
43
43
|
},
|
|
44
44
|
get color() {
|
|
45
|
-
return
|
|
45
|
+
return x.color ?? e?.color;
|
|
46
46
|
},
|
|
47
|
-
onDel: () =>
|
|
47
|
+
onDel: () => x.onChange(w(x.value).filter((x) => x != e)),
|
|
48
48
|
get children() {
|
|
49
|
-
return memo(() => !!
|
|
49
|
+
return memo(() => !!x.children)() ? x.children(e) : e?.text ?? e?.label ?? e?.name ?? e;
|
|
50
50
|
}
|
|
51
51
|
})
|
|
52
|
-
}), null), insert(
|
|
53
|
-
var
|
|
54
|
-
return () =>
|
|
52
|
+
}), null), insert(T, (() => {
|
|
53
|
+
var S = memo(() => !x.disabled);
|
|
54
|
+
return () => S() && createComponent(Tag, {
|
|
55
55
|
disabled: !0,
|
|
56
56
|
get onClick() {
|
|
57
|
-
return
|
|
57
|
+
return x.onAdd;
|
|
58
58
|
},
|
|
59
59
|
get children() {
|
|
60
60
|
return createComponent(plus_default, {});
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
|
-
})(), null),
|
|
63
|
+
})(), null), T;
|
|
64
64
|
})();
|
|
65
65
|
}, Tag = (e) => {
|
|
66
|
-
let
|
|
67
|
-
[e,
|
|
66
|
+
let S;
|
|
67
|
+
[e, S] = splitProps(e, [
|
|
68
68
|
"disabled",
|
|
69
69
|
"value",
|
|
70
70
|
"children",
|
|
71
71
|
"color",
|
|
72
72
|
"onDel"
|
|
73
73
|
]);
|
|
74
|
-
let
|
|
75
|
-
return
|
|
74
|
+
let w = e.color === void 0 && e.value != null ? stringToColor(String(e.value)) : e.color;
|
|
75
|
+
return S = combineProps({
|
|
76
76
|
get class() {
|
|
77
|
-
return `in-tag flex items-center px-2 py-1 rd-sm text-3 lh-[1] ${
|
|
77
|
+
return `in-tag flex items-center px-2 py-1 rd-sm text-3 lh-[1] ${w ? "" : "bg-gray/20"}`;
|
|
78
78
|
},
|
|
79
79
|
get style() {
|
|
80
|
-
return
|
|
80
|
+
return w ? `color: ${w}; background: color-mix(in srgb, ${w} 15%, transparent)` : void 0;
|
|
81
81
|
}
|
|
82
|
-
},
|
|
83
|
-
var
|
|
84
|
-
return spread(
|
|
85
|
-
var
|
|
86
|
-
return () =>
|
|
82
|
+
}, S), (() => {
|
|
83
|
+
var w = _tmpl$2();
|
|
84
|
+
return spread(w, S, !1, !0), insert(w, () => e.children, null), insert(w, (() => {
|
|
85
|
+
var S = memo(() => !e.disabled);
|
|
86
|
+
return () => S() && createComponent(x_default, {
|
|
87
87
|
class: "icon-clickable flex-shrink-0 size-4! ml-1 mr--1 op-75",
|
|
88
88
|
get onClick() {
|
|
89
89
|
return e.onDel;
|
|
90
90
|
}
|
|
91
91
|
});
|
|
92
|
-
})(), null),
|
|
92
|
+
})(), null), w;
|
|
93
93
|
})();
|
|
94
|
-
},
|
|
94
|
+
}, Rate = (e) => {
|
|
95
|
+
let x;
|
|
96
|
+
[e, x] = splitProps(e, [
|
|
97
|
+
"value",
|
|
98
|
+
"disabled",
|
|
99
|
+
"max",
|
|
100
|
+
"onChange"
|
|
101
|
+
]), e = mergeProps$1({ max: 5 }, e);
|
|
102
|
+
let w = () => Math.round(Number(e.value) || 0);
|
|
103
|
+
return x = combineProps({ get class() {
|
|
104
|
+
return `in-rate inline-flex items-center gap-0.5 ${e.disabled ? "" : "cursor-pointer"}`;
|
|
105
|
+
} }, x), (() => {
|
|
106
|
+
var D = _tmpl$2();
|
|
107
|
+
return spread(D, x, !1, !0), insert(D, createComponent(For, {
|
|
108
|
+
get each() {
|
|
109
|
+
return Array.from({ length: e.max }, (e, x) => x + 1);
|
|
110
|
+
},
|
|
111
|
+
children: (x) => (() => {
|
|
112
|
+
var C = _tmpl$3();
|
|
113
|
+
return C.$$click = () => !e.disabled && e.onChange?.(x), effect((T) => {
|
|
114
|
+
var E = `lh-none select-none ${e.disabled ? "" : "hover:scale-110"} transition-transform`, D = x <= w() ? "#f59e0b" : "#d1d5db", O = e.disabled ? "default" : "pointer";
|
|
115
|
+
return E !== T.e && className(C, T.e = E), D !== T.t && setStyleProperty(C, "color", T.t = D), O !== T.a && setStyleProperty(C, "cursor", T.a = O), T;
|
|
116
|
+
}, {
|
|
117
|
+
e: void 0,
|
|
118
|
+
t: void 0,
|
|
119
|
+
a: void 0
|
|
120
|
+
}), C;
|
|
121
|
+
})()
|
|
122
|
+
})), D;
|
|
123
|
+
})();
|
|
124
|
+
}, Progress = (e) => {
|
|
125
|
+
let x;
|
|
126
|
+
[e, x] = splitProps(e, [
|
|
127
|
+
"value",
|
|
128
|
+
"disabled",
|
|
129
|
+
"onChange"
|
|
130
|
+
]);
|
|
131
|
+
let S = () => {
|
|
132
|
+
let x = Number(e.value) || 0;
|
|
133
|
+
return x <= 1 ? Math.round(x * 100) : Math.min(100, Math.max(0, Math.round(x)));
|
|
134
|
+
}, C = () => "var(--c-primary)";
|
|
135
|
+
return x = combineProps({ get class() {
|
|
136
|
+
return "in-progress flex items-center h-full w-full";
|
|
137
|
+
} }, x), (() => {
|
|
138
|
+
var e = _tmpl$4(), w = e.firstChild, D = w.firstChild, O = w.nextSibling, k = O.firstChild;
|
|
139
|
+
return spread(e, x, !1, !0), insert(O, S, k), effect((e) => {
|
|
140
|
+
var x = `${S()}%`, T = `${S()}%`, E = C();
|
|
141
|
+
return x !== e.e && setAttribute(w, "title", e.e = x), T !== e.t && setStyleProperty(D, "width", e.t = T), E !== e.a && setStyleProperty(D, "background", e.a = E), e;
|
|
142
|
+
}, {
|
|
143
|
+
e: void 0,
|
|
144
|
+
t: void 0,
|
|
145
|
+
a: void 0
|
|
146
|
+
}), e;
|
|
147
|
+
})();
|
|
148
|
+
}, evaluateFormula = (e, x) => {
|
|
95
149
|
try {
|
|
96
|
-
let
|
|
97
|
-
return Function(...Object.keys(
|
|
150
|
+
let S = { data: x };
|
|
151
|
+
return Function(...Object.keys(S), "return " + e)(...Object.values(S));
|
|
98
152
|
} catch {
|
|
99
153
|
return "公式错误";
|
|
100
154
|
}
|
|
@@ -163,8 +217,9 @@ const Checkbox = (e) => {
|
|
|
163
217
|
};
|
|
164
218
|
var stringToColor = (e) => {
|
|
165
219
|
if (e = e.trim().toLowerCase(), text2colorMap[e]) return text2colorMap[e];
|
|
166
|
-
let
|
|
167
|
-
for (let
|
|
168
|
-
return `hsl(${Math.abs(
|
|
220
|
+
let x = 0;
|
|
221
|
+
for (let S = 0; S < e.length; S++) x = (x << 5) - x + e.charCodeAt(S) | 0;
|
|
222
|
+
return `hsl(${Math.abs(x * 137) % 360} 55% 40%)`;
|
|
169
223
|
};
|
|
170
|
-
|
|
224
|
+
delegateEvents(["click"]);
|
|
225
|
+
export { Checkbox, Files, Progress, Rate, Tag, Tags, evaluateFormula, text2colorMap };
|
|
@@ -11,6 +11,7 @@ declare module '../../index' {
|
|
|
11
11
|
label?: string;
|
|
12
12
|
value: any;
|
|
13
13
|
}[];
|
|
14
|
+
max?: number;
|
|
14
15
|
}
|
|
15
16
|
interface TableStore {
|
|
16
17
|
renders: {
|
|
@@ -26,4 +27,8 @@ export declare const renders: {
|
|
|
26
27
|
switch: Render;
|
|
27
28
|
checkbox: Render;
|
|
28
29
|
file: Render;
|
|
30
|
+
rate: Render;
|
|
31
|
+
progress: Render;
|
|
32
|
+
obj: Render;
|
|
33
|
+
objs: Render;
|
|
29
34
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { renderComponent, solidComponent } from "../../components/utils.js";
|
|
2
2
|
import { getOpt, toArr } from "../../utils.js";
|
|
3
3
|
import { mergeProps as mergeProps$2 } from "../../mergeProps2.js";
|
|
4
|
-
import { Checkbox, Files, Tags, text2colorMap } from "./components.js";
|
|
4
|
+
import { Checkbox, Files, Progress, Rate, Tags, text2colorMap } from "./components.js";
|
|
5
5
|
import { createComponent, insert, template } from "solid-js/web";
|
|
6
6
|
import { createMemo } from "solid-js";
|
|
7
7
|
var _tmpl$ = /* @__PURE__ */ template("<div class=\"flex items-center h-full\">");
|
|
@@ -9,19 +9,19 @@ const RenderPlugin = {
|
|
|
9
9
|
name: "render",
|
|
10
10
|
priority: -Infinity,
|
|
11
11
|
store: () => ({ renders: { ...renders } }),
|
|
12
|
-
rewriteProps: { Td: ({ Td:
|
|
13
|
-
let
|
|
14
|
-
return
|
|
12
|
+
rewriteProps: { Td: ({ Td: x }, { store: S }) => (C) => (S.props.cpu && (C = mergeProps$2(() => ({}), C)), createComponent(x, mergeProps$2(C, { children: createMemo(() => {
|
|
13
|
+
let x = ((e) => typeof e == "string" ? S.renders[e] : e)(C.col.render ?? (C.col.enum && text) ?? C.col.type) ?? text;
|
|
14
|
+
return x == text ? text(C) : renderComponent(x, C, S);
|
|
15
15
|
}) }))) }
|
|
16
16
|
};
|
|
17
17
|
var text = (e) => e.col.enum ? createComponent(Tags, {
|
|
18
18
|
disabled: !0,
|
|
19
19
|
get value() {
|
|
20
|
-
return toArr(e.value).map((
|
|
20
|
+
return toArr(e.value).map((x) => getOpt(e.col.enum, x) ?? x);
|
|
21
21
|
}
|
|
22
22
|
}) : e.value, checkbox = (e) => (() => {
|
|
23
|
-
var
|
|
24
|
-
return insert(
|
|
23
|
+
var x = _tmpl$();
|
|
24
|
+
return insert(x, createComponent(Checkbox, {
|
|
25
25
|
class: "",
|
|
26
26
|
get value() {
|
|
27
27
|
return e.value;
|
|
@@ -29,21 +29,54 @@ var text = (e) => e.col.enum ? createComponent(Tags, {
|
|
|
29
29
|
get onChange() {
|
|
30
30
|
return e.onChange;
|
|
31
31
|
}
|
|
32
|
-
})),
|
|
33
|
-
})()
|
|
32
|
+
})), x;
|
|
33
|
+
})(), file = (e) => createComponent(Files, {
|
|
34
|
+
get value() {
|
|
35
|
+
return e.value;
|
|
36
|
+
},
|
|
37
|
+
get onChange() {
|
|
38
|
+
return e.onChange;
|
|
39
|
+
},
|
|
40
|
+
disabled: !0
|
|
41
|
+
}), rate = (e) => createComponent(Rate, {
|
|
42
|
+
get value() {
|
|
43
|
+
return e.value;
|
|
44
|
+
},
|
|
45
|
+
get max() {
|
|
46
|
+
return e.col.max ?? 5;
|
|
47
|
+
},
|
|
48
|
+
get onChange() {
|
|
49
|
+
return e.onChange;
|
|
50
|
+
},
|
|
51
|
+
disabled: !0
|
|
52
|
+
}), progress = (e) => createComponent(Progress, {
|
|
53
|
+
get value() {
|
|
54
|
+
return e.value;
|
|
55
|
+
},
|
|
56
|
+
get onChange() {
|
|
57
|
+
return e.onChange;
|
|
58
|
+
}
|
|
59
|
+
}), obj = (e) => {
|
|
60
|
+
let x = () => e.col.table?.columns?.[0].id, S = () => e.col.table?.rowKey ?? "id";
|
|
61
|
+
return createComponent(Tags, {
|
|
62
|
+
disabled: !0,
|
|
63
|
+
get value() {
|
|
64
|
+
return toArr(e.value).map((e) => ({
|
|
65
|
+
label: e[x()],
|
|
66
|
+
value: e[S()]
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
};
|
|
34
71
|
const renders = {
|
|
35
72
|
text,
|
|
36
73
|
switch: checkbox,
|
|
37
74
|
checkbox,
|
|
38
|
-
file
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return e.onChange;
|
|
44
|
-
},
|
|
45
|
-
disabled: !0
|
|
46
|
-
})
|
|
75
|
+
file,
|
|
76
|
+
rate,
|
|
77
|
+
progress,
|
|
78
|
+
obj,
|
|
79
|
+
objs: obj
|
|
47
80
|
};
|
|
48
81
|
for (let e in renders) renders[e] = solidComponent(renders[e]);
|
|
49
82
|
export { RenderPlugin, renders, text2colorMap };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { mergeProps as mergeProps$2 } from "../mergeProps2.js";
|
|
2
2
|
import chevron_right_default from "../chevron-right.js";
|
|
3
|
-
import { Ctx } from "../index.js";
|
|
4
3
|
import { createComponent, delegateEvents, effect, insert, memo, style, template } from "solid-js/web";
|
|
5
|
-
import { batch, createMemo
|
|
4
|
+
import { batch, createMemo } from "solid-js";
|
|
6
5
|
import { groupBy, zipObject } from "es-toolkit";
|
|
7
6
|
import { findLast } from "es-toolkit/compat";
|
|
8
7
|
var _tmpl$ = /* @__PURE__ */ template("<div class=\"flex items-center\">"), pathKey = (e) => e.join("\0");
|
|
@@ -11,79 +10,79 @@ const RowGroupPlugin = {
|
|
|
11
10
|
priority: -Infinity,
|
|
12
11
|
store: (e) => ({ rowGroup: {
|
|
13
12
|
expandKeys: {},
|
|
14
|
-
isExpand: (
|
|
15
|
-
expand: (
|
|
16
|
-
e.rowGroup.expandKeys[pathKey(
|
|
17
|
-
}) : e.rowGroup.expandKeys[pathKey(
|
|
18
|
-
toggleExpand: (
|
|
19
|
-
let
|
|
20
|
-
e.rowGroup.expandKeys[
|
|
13
|
+
isExpand: (c) => !!e.rowGroup.expandKeys[pathKey(c[GROUP].path)],
|
|
14
|
+
expand: (c, l) => batch(() => l ? c[GROUP].path2.forEach((c) => {
|
|
15
|
+
e.rowGroup.expandKeys[pathKey(c[GROUP].path)] = !0;
|
|
16
|
+
}) : e.rowGroup.expandKeys[pathKey(c[GROUP].path)] = !0),
|
|
17
|
+
toggleExpand: (c) => {
|
|
18
|
+
let l = pathKey(c[GROUP].path);
|
|
19
|
+
e.rowGroup.expandKeys[l] ? delete e.rowGroup.expandKeys[l] : e.rowGroup.expandKeys[l] = !0;
|
|
21
20
|
}
|
|
22
21
|
} }),
|
|
23
|
-
commands: (e, { addRows:
|
|
24
|
-
let { data:
|
|
25
|
-
if (
|
|
26
|
-
let
|
|
27
|
-
if (
|
|
28
|
-
let
|
|
29
|
-
return
|
|
30
|
-
}(
|
|
31
|
-
e.rowGroup.expand(
|
|
32
|
-
let
|
|
33
|
-
|
|
22
|
+
commands: (e, { addRows: c }) => ({ addRows(l, u, d) {
|
|
23
|
+
let { data: f, rowGroup: p, rowKey: m } = e.props;
|
|
24
|
+
if (p?.fields?.length) {
|
|
25
|
+
let p = findLast(f, (e) => e[GROUP], l);
|
|
26
|
+
if (p && f[l][GROUP]) {
|
|
27
|
+
let c = function e(c) {
|
|
28
|
+
return c[GROUP]?.children[0]?.[GROUP] ? e(c[GROUP].children[0]) : c;
|
|
29
|
+
}(p);
|
|
30
|
+
e.rowGroup.expand(c, !0);
|
|
31
|
+
let u = c[GROUP].children[0];
|
|
32
|
+
l = e.props.data.indexOf(u), d = !0;
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
} else
|
|
34
|
+
c?.(l, u, d);
|
|
35
|
+
} else c?.(...arguments);
|
|
37
36
|
} }),
|
|
38
37
|
rewriteProps: {
|
|
39
|
-
data: ({ data: e }, { store:
|
|
40
|
-
newRow: ({ newRow: e }, { store:
|
|
41
|
-
let
|
|
42
|
-
if (
|
|
43
|
-
let e = findLast(
|
|
38
|
+
data: ({ data: e }, { store: c }) => c.props?.rowGroup?.fields?.length ? expandData(e, c) : e,
|
|
39
|
+
newRow: ({ newRow: e }, { store: c }) => function(l) {
|
|
40
|
+
let u = e(...arguments), { data: d, rowGroup: f } = c.props;
|
|
41
|
+
if (f?.fields?.length) {
|
|
42
|
+
let e = findLast(d, (e) => e[GROUP], l);
|
|
44
43
|
if (e) {
|
|
45
|
-
let
|
|
46
|
-
return
|
|
47
|
-
}(e),
|
|
48
|
-
Object.assign(
|
|
44
|
+
let c = function e(c) {
|
|
45
|
+
return c[GROUP]?.children[0]?.[GROUP] ? e(c[GROUP].children[0]) : c;
|
|
46
|
+
}(e), l = zipObject(f.fields, c[GROUP].path);
|
|
47
|
+
Object.assign(u, l);
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
|
-
return
|
|
50
|
+
return u;
|
|
52
51
|
},
|
|
53
|
-
Td: ({ Td:
|
|
54
|
-
if (!
|
|
55
|
-
let { props:
|
|
56
|
-
return createComponent(
|
|
57
|
-
return memo(() =>
|
|
52
|
+
Td: ({ Td: u }, { store: h }) => h.props?.rowGroup?.fields ? (g) => {
|
|
53
|
+
if (!g.data?.[GROUP]) return u(g);
|
|
54
|
+
let { props: _ } = h, v = createMemo(() => h.rowGroup.isExpand(g.data));
|
|
55
|
+
return createComponent(u, mergeProps$2(g, { get children() {
|
|
56
|
+
return memo(() => _.columns?.findIndex((e) => !e[h.internal]) == g.x)() ? (() => {
|
|
58
57
|
var e = _tmpl$();
|
|
59
|
-
return e.$$dblclick = () =>
|
|
58
|
+
return e.$$dblclick = () => h.rowGroup.toggleExpand(g.data), insert(e, createComponent(chevron_right_default, {
|
|
60
59
|
class: "icon-clickable mr-2",
|
|
61
60
|
get style() {
|
|
62
|
-
return `transform: rotate(${
|
|
61
|
+
return `transform: rotate(${v() ? 90 : 0}deg); opacity: .6`;
|
|
63
62
|
},
|
|
64
|
-
onClick: () =>
|
|
65
|
-
}), null), insert(e, () =>
|
|
66
|
-
})() :
|
|
63
|
+
onClick: () => h.rowGroup.toggleExpand(g.data)
|
|
64
|
+
}), null), insert(e, () => g.data[GROUP].value, null), effect((c) => style(e, `padding-left: ${(g.data[GROUP].path.length - 1) * 16}px`, c)), e;
|
|
65
|
+
})() : g.children;
|
|
67
66
|
} }));
|
|
68
|
-
} :
|
|
67
|
+
} : u
|
|
69
68
|
}
|
|
70
69
|
};
|
|
71
|
-
var GROUP = Symbol("row-group"), expandData = (e,
|
|
72
|
-
let
|
|
73
|
-
if (!
|
|
74
|
-
let
|
|
75
|
-
return Object.keys(
|
|
76
|
-
let
|
|
77
|
-
[
|
|
78
|
-
[
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
path: [...
|
|
70
|
+
var GROUP = Symbol("row-group"), expandData = (e, c, l = []) => {
|
|
71
|
+
let u = c.props.rowGroup.fields, d = c.props.columns.find((e) => !e[c.internal]);
|
|
72
|
+
if (!d || u.length == l.length) return e;
|
|
73
|
+
let f = l[l.length - 1]?.[GROUP].path || [], p = groupBy(e, (e) => e[u[f.length]]);
|
|
74
|
+
return Object.keys(p).flatMap((e) => {
|
|
75
|
+
let u = {
|
|
76
|
+
[d.id]: e,
|
|
77
|
+
[c.internal]: 1
|
|
78
|
+
}, m = [...l, u];
|
|
79
|
+
u[GROUP] = {
|
|
80
|
+
path: [...f, e],
|
|
82
81
|
value: e,
|
|
83
|
-
path2:
|
|
84
|
-
},
|
|
85
|
-
let
|
|
86
|
-
return [
|
|
82
|
+
path2: m
|
|
83
|
+
}, u[GROUP].children = expandData(p[e], c, m);
|
|
84
|
+
let h = c.rowGroup.isExpand(u) ? u[GROUP].children : [];
|
|
85
|
+
return [u, ...h];
|
|
87
86
|
});
|
|
88
87
|
};
|
|
89
88
|
delegateEvents(["dblclick"]);
|
|
@@ -40,7 +40,10 @@ const RowSelectionPlugin = {
|
|
|
40
40
|
})), l;
|
|
41
41
|
})())
|
|
42
42
|
} }),
|
|
43
|
-
commands: (e) => ({ rowSelector: useSelector(mergeProps$1(() => ({
|
|
43
|
+
commands: (e) => ({ rowSelector: useSelector(mergeProps$1(() => ({
|
|
44
|
+
...e.props?.rowSelection,
|
|
45
|
+
key: e.props.rowKey
|
|
46
|
+
}))) }),
|
|
44
47
|
rewriteProps: {
|
|
45
48
|
rowSelection: ({ rowSelection: e }) => mergeProps$1({
|
|
46
49
|
enable: !1,
|
|
@@ -8,7 +8,6 @@ declare module '../index' {
|
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
interface TableStore {
|
|
11
|
-
tree: ReturnType<typeof useSelector<any[]>>;
|
|
12
11
|
/**
|
|
13
12
|
* Lookup map populated as a side-effect of the `data` rewriteProp.
|
|
14
13
|
* Maps each row's rowKey → its tree metadata.
|
|
@@ -18,7 +17,11 @@ declare module '../index' {
|
|
|
18
17
|
depth: number;
|
|
19
18
|
hasChildren: boolean;
|
|
20
19
|
parentKey: any;
|
|
20
|
+
row: any;
|
|
21
21
|
}>;
|
|
22
22
|
}
|
|
23
|
+
interface Commands {
|
|
24
|
+
tree: ReturnType<typeof useSelector<any[]>>;
|
|
25
|
+
}
|
|
23
26
|
}
|
|
24
27
|
export declare const TreePlugin: Plugin$0;
|
|
@@ -10,8 +10,9 @@ function flattenTree(e, t, n, r, i = 0, a = null, o = [], s = /* @__PURE__ */ ne
|
|
|
10
10
|
s.set(e, {
|
|
11
11
|
depth: i,
|
|
12
12
|
hasChildren: u,
|
|
13
|
-
parentKey: a
|
|
14
|
-
|
|
13
|
+
parentKey: a,
|
|
14
|
+
row: c
|
|
15
|
+
}), o.push(c), u && r(c) && flattenTree(l, t, n, r, i + 1, e, o, s);
|
|
15
16
|
}
|
|
16
17
|
return {
|
|
17
18
|
flat: o,
|
|
@@ -23,7 +24,6 @@ const TreePlugin = (c) => {
|
|
|
23
24
|
return {
|
|
24
25
|
name: "tree",
|
|
25
26
|
store: (e) => ({
|
|
26
|
-
tree: useSelector({ multiple: !0 }),
|
|
27
27
|
_treeMeta: /* @__PURE__ */ new Map(),
|
|
28
28
|
_hasChildren: !1
|
|
29
29
|
}),
|
|
@@ -34,14 +34,14 @@ const TreePlugin = (c) => {
|
|
|
34
34
|
}),
|
|
35
35
|
data: ({ data: e }, { store: t }) => {
|
|
36
36
|
if (!t.props?.tree) return e;
|
|
37
|
-
let n = t.props.tree.children || "children", r = t.props.rowKey, { flat: i, meta: a } = flattenTree(e, n, r, (e) => t.tree.has(e));
|
|
37
|
+
let n = t.props.tree.children || "children", r = t.props.rowKey, { flat: i, meta: a } = flattenTree(e, n, r, (e) => t.commands.tree.has(e));
|
|
38
38
|
return t._treeMeta = a, t._haschildren = Object.values(Object.fromEntries(a)).some((e) => e.hasChildren), i;
|
|
39
39
|
},
|
|
40
40
|
Td: ({ Td: t }, { store: c }) => c._haschildren ? (l) => {
|
|
41
41
|
let f = () => c.props.rowKey, m = () => c._treeMeta?.get(l.data?.[f()]);
|
|
42
42
|
return createComponent(t, mergeProps$1(l, {
|
|
43
43
|
onDblClick: (e) => {
|
|
44
|
-
l.onDblClick?.(e), m()?.hasChildren && c.tree.toggle(l.data
|
|
44
|
+
l.onDblClick?.(e), l.x == p() && m()?.hasChildren && c.commands.tree.toggle(l.data);
|
|
45
45
|
},
|
|
46
46
|
get children() {
|
|
47
47
|
return memo(() => !!(c._haschildren && l.x === p()))() ? (() => {
|
|
@@ -51,10 +51,10 @@ const TreePlugin = (c) => {
|
|
|
51
51
|
return () => e() ? createComponent(chevron_right_default, {
|
|
52
52
|
class: "icon-clickable mr-1",
|
|
53
53
|
get style() {
|
|
54
|
-
return `transform: rotate(${c.tree.has(l.data
|
|
54
|
+
return `transform: rotate(${c.commands.tree.has(l.data) ? 90 : 0}deg); opacity: .6; flex-shrink: 0; transition: transform .15s`;
|
|
55
55
|
},
|
|
56
56
|
onClick: (e) => {
|
|
57
|
-
e.stopPropagation(), c.tree.toggle(l.data
|
|
57
|
+
e.stopPropagation(), c.commands.tree.toggle(l.data);
|
|
58
58
|
}
|
|
59
59
|
}) : _tmpl$2();
|
|
60
60
|
})(), null), insert(e, () => l.children, null), effect((t) => style(e, `padding-left: ${m()?.depth * 16}px`, t)), e;
|
|
@@ -63,52 +63,58 @@ const TreePlugin = (c) => {
|
|
|
63
63
|
}));
|
|
64
64
|
} : t
|
|
65
65
|
},
|
|
66
|
-
commands: (e, { addRows:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
commands: (e, { addRows: n }) => ({
|
|
67
|
+
tree: useSelector({
|
|
68
|
+
multiple: !0,
|
|
69
|
+
key: e.props.rowKey
|
|
70
|
+
}),
|
|
71
|
+
addRows(t, r, i = !0) {
|
|
72
|
+
if (!e.props?.tree) return n?.(t, r, i);
|
|
73
|
+
let { data: a, rowKey: o } = e.props, s = e.props.tree.children || "children", c = a[t];
|
|
74
|
+
if (c?.[e.internal]) {
|
|
75
|
+
let n = null, r = null;
|
|
76
|
+
for (let r = t - 1; r >= 0; r--) if (!a[r]?.[e.internal]) {
|
|
77
|
+
n = a[r];
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
for (let n = t + 1; n < a.length; n++) if (!a[n]?.[e.internal]) {
|
|
81
|
+
r = a[n];
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
c = i ? n || r : r || n;
|
|
74
85
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
if (!c) return n?.(t, r, i);
|
|
87
|
+
let l = c[o], u = e._treeMeta?.get(l);
|
|
88
|
+
if (!u || u.depth === 0) return n?.(t, r, i);
|
|
89
|
+
let d = e._treeMeta.get(u.parentKey)?.row, f = u.parentKey, p = a.findIndex((e) => e[o] === l);
|
|
90
|
+
if (p >= 0 && e.selected) {
|
|
91
|
+
let t = p + (i ? 0 : 1);
|
|
92
|
+
e.selected.start = [0, t], e.selected.end = [Infinity, t + r.length - 1];
|
|
78
93
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
[s]: a
|
|
98
|
-
}, !0;
|
|
99
|
-
}
|
|
100
|
-
if (Array.isArray(n[s]) && n[s].length) {
|
|
101
|
-
let r = [...n[s]];
|
|
102
|
-
if (m(r)) return e[t] = {
|
|
103
|
-
...n,
|
|
104
|
-
[s]: r
|
|
105
|
-
}, !0;
|
|
94
|
+
let m = [...e.rawProps.data || []];
|
|
95
|
+
function h(e) {
|
|
96
|
+
for (let t = 0; t < e.length; t++) {
|
|
97
|
+
let n = e[t];
|
|
98
|
+
if (n[o] === f) {
|
|
99
|
+
let a = [...n[s] || []], c = a.findIndex((e) => e[o] === l), u = c >= 0 ? c + (i ? 0 : 1) : a.length;
|
|
100
|
+
return a.splice(u, 0, ...r), e[t] = {
|
|
101
|
+
...n,
|
|
102
|
+
[s]: a
|
|
103
|
+
}, !0;
|
|
104
|
+
}
|
|
105
|
+
if (Array.isArray(n[s]) && n[s].length) {
|
|
106
|
+
let r = [...n[s]];
|
|
107
|
+
if (h(r)) return e[t] = {
|
|
108
|
+
...n,
|
|
109
|
+
[s]: r
|
|
110
|
+
}, !0;
|
|
111
|
+
}
|
|
106
112
|
}
|
|
113
|
+
return !1;
|
|
107
114
|
}
|
|
108
|
-
|
|
115
|
+
h(m), e.commands.tree.add(d), e.props?.onDataChange?.(m);
|
|
109
116
|
}
|
|
110
|
-
|
|
111
|
-
} })
|
|
117
|
+
})
|
|
112
118
|
};
|
|
113
119
|
};
|
|
114
120
|
export { TreePlugin };
|