intable 0.0.58 → 0.0.59
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 +3 -1
- package/dist/index.js +30 -15
- package/dist/plugins/DiffPlugin.js +4 -1
- package/dist/plugins/EditablePlugin.js +75 -76
- 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/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,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 };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Ctx } from "../index.js";
|
|
2
1
|
import { RecycleList } from "../components/RecycleList.js";
|
|
3
2
|
import { useVirtualizer } from "../hooks/useVirtualizer.js";
|
|
4
3
|
import { createComponent, mergeProps } from "solid-js/web";
|
|
5
|
-
import { createEffect, createMemo, mergeProps as mergeProps$1
|
|
4
|
+
import { createEffect, createMemo, mergeProps as mergeProps$1 } from "solid-js";
|
|
6
5
|
import { combineProps } from "@solid-primitives/props";
|
|
7
6
|
import { defaultsDeep } from "es-toolkit/compat";
|
|
8
7
|
import { defaultRangeExtractor } from "@tanstack/solid-virtual";
|
|
@@ -10,17 +9,17 @@ var $ML = Symbol();
|
|
|
10
9
|
const VirtualScrollPlugin = {
|
|
11
10
|
name: "virtual-scroll",
|
|
12
11
|
store: (e) => ({
|
|
13
|
-
scrollToCell(r, i
|
|
14
|
-
|
|
15
|
-
let
|
|
16
|
-
|
|
12
|
+
scrollToCell(n, r, i) {
|
|
13
|
+
n = typeof n == "object" ? e.props.columns.indexOf(n) : n, r = typeof r == "object" ? e.props.data.indexOf(r) : r;
|
|
14
|
+
let a = e.virtualizerX, o = e.virtualizerY;
|
|
15
|
+
a.scrollToIndex(n, !0), o.scrollToIndex(r, !0);
|
|
17
16
|
},
|
|
18
|
-
scrollCellIfNeeded(r, i
|
|
19
|
-
|
|
20
|
-
let
|
|
21
|
-
if (!
|
|
22
|
-
let
|
|
23
|
-
(
|
|
17
|
+
scrollCellIfNeeded(n, r, i) {
|
|
18
|
+
n = typeof n == "object" ? e.props.columns.indexOf(n) : n, r = typeof r == "object" ? e.props.data.indexOf(r) : r;
|
|
19
|
+
let a = e.virtualizerX, o = e.virtualizerY, s = e.table.querySelector(`[x="${n}"][y="${r}"]`);
|
|
20
|
+
if (!s) return e.scrollToCell(n, r);
|
|
21
|
+
let c = s.getBoundingClientRect(), l = e.scroll_el.getBoundingClientRect();
|
|
22
|
+
(c.top < l.top || c.bottom > l.bottom) && o.scrollToIndex(r, !0), (c.left < l.left || c.right > l.right) && a.scrollToIndex(n, !0);
|
|
24
23
|
}
|
|
25
24
|
}),
|
|
26
25
|
rewriteProps: {
|
|
@@ -28,106 +27,106 @@ const VirtualScrollPlugin = {
|
|
|
28
27
|
x: { overscan: 2 },
|
|
29
28
|
y: { overscan: 2 }
|
|
30
29
|
}),
|
|
31
|
-
Scroll: ({ Scroll: e }, { store:
|
|
32
|
-
Table: ({ Table:
|
|
33
|
-
let { props:
|
|
34
|
-
getScrollElement: () =>
|
|
30
|
+
Scroll: ({ Scroll: e }, { store: n }) => (n) => (n = combineProps({ class: "virtual" }, n), createComponent(e, n)),
|
|
31
|
+
Table: ({ Table: e }, { store: i }) => (c) => {
|
|
32
|
+
let { props: l } = i, d = useVirtualizer(mergeProps$1(() => l.virtual?.y, {
|
|
33
|
+
getScrollElement: () => i.scroll_el,
|
|
35
34
|
get count() {
|
|
36
|
-
return
|
|
35
|
+
return l.data?.length || 0;
|
|
37
36
|
},
|
|
38
37
|
estimateSize: () => 32,
|
|
39
38
|
indexAttribute: "y",
|
|
40
|
-
extras: (e,
|
|
41
|
-
let
|
|
42
|
-
if (!
|
|
43
|
-
let a =
|
|
44
|
-
for (let [
|
|
45
|
-
if (
|
|
46
|
-
let [
|
|
47
|
-
if (
|
|
48
|
-
for (let e = 0; e <
|
|
39
|
+
extras: (e, n) => {
|
|
40
|
+
let r = i._mergeMap?.();
|
|
41
|
+
if (!r?.spans.size) return [];
|
|
42
|
+
let a = i.virtualizerX, o = a ? a.startIdx() : 0, s = a ? a.endIdx() : Infinity, c = [];
|
|
43
|
+
for (let [i, a] of r.spans) {
|
|
44
|
+
if (a.rowspan <= 1) continue;
|
|
45
|
+
let [r, l] = i.split(",").map(Number);
|
|
46
|
+
if (r > n || r + a.rowspan - 1 < e || l > s || l + a.colspan - 1 < o) continue;
|
|
47
|
+
for (let e = 0; e < a.rowspan; e++) c.push(r + e);
|
|
49
48
|
}
|
|
50
|
-
return
|
|
49
|
+
return c;
|
|
51
50
|
}
|
|
52
|
-
})),
|
|
51
|
+
})), f = useVirtualizer(mergeProps$1(() => l.virtual?.x, {
|
|
53
52
|
horizontal: !0,
|
|
54
|
-
getScrollElement: () =>
|
|
53
|
+
getScrollElement: () => i.scroll_el,
|
|
55
54
|
get count() {
|
|
56
|
-
return
|
|
55
|
+
return l.columns?.length || 0;
|
|
57
56
|
},
|
|
58
|
-
estimateSize: (e) =>
|
|
57
|
+
estimateSize: (e) => l.columns?.[e].width ?? 40,
|
|
59
58
|
indexAttribute: "x",
|
|
60
59
|
rangeExtractor(e) {
|
|
61
|
-
return [...new Set([...
|
|
60
|
+
return [...new Set([...l.columns?.map((e, n) => e.fixed ? n : void 0).filter((e) => e != null) || [], ...defaultRangeExtractor(e)])];
|
|
62
61
|
},
|
|
63
|
-
extras: (e,
|
|
64
|
-
let
|
|
65
|
-
if (!
|
|
66
|
-
let
|
|
67
|
-
for (let [
|
|
68
|
-
if (
|
|
69
|
-
let [
|
|
70
|
-
if (
|
|
71
|
-
for (let e = 0; e <
|
|
62
|
+
extras: (e, n) => {
|
|
63
|
+
let r = l.columns?.map((e, n) => e.fixed ? n : void 0).filter((e) => e != null) || [], a = i._headerGroupAnchors?.(e, n) || [], o = new Set([...r, ...a]), s = i._mergeMap?.();
|
|
64
|
+
if (!s?.spans.size) return [...o];
|
|
65
|
+
let c = d.startIdx(), u = d.endIdx();
|
|
66
|
+
for (let [r, i] of s.spans) {
|
|
67
|
+
if (i.colspan <= 1) continue;
|
|
68
|
+
let [a, s] = r.split(",").map(Number);
|
|
69
|
+
if (a > u || a + i.rowspan - 1 < c || s > n || s + i.colspan - 1 < e) continue;
|
|
70
|
+
for (let e = 0; e < i.colspan; e++) o.add(s + e);
|
|
72
71
|
}
|
|
73
|
-
return [...
|
|
72
|
+
return [...o];
|
|
74
73
|
}
|
|
75
74
|
}));
|
|
76
|
-
return
|
|
77
|
-
let e =
|
|
78
|
-
for (let
|
|
79
|
-
let
|
|
80
|
-
|
|
81
|
-
item:
|
|
82
|
-
offset:
|
|
75
|
+
return i.virtualizerY = d, i.virtualizerX = f, i[$ML] = createMemo(() => {
|
|
76
|
+
let e = i.virtualizerX.getVirtualItems(), n = {};
|
|
77
|
+
for (let r = 1; r < e.length; r++) {
|
|
78
|
+
let i = e[r], a = e[r - 1];
|
|
79
|
+
i.index - a.index > 1 && (n[i.index] = {
|
|
80
|
+
item: i,
|
|
81
|
+
offset: i.start - a.end
|
|
83
82
|
});
|
|
84
83
|
}
|
|
85
|
-
return
|
|
84
|
+
return n;
|
|
86
85
|
}), createEffect(() => {
|
|
87
|
-
let { table: e } =
|
|
88
|
-
e.style.width =
|
|
89
|
-
}), createComponent(
|
|
86
|
+
let { table: e } = i;
|
|
87
|
+
e.style.width = i.virtualizerX.getTotalSize() + "px", e.style.height = i.virtualizerY.getTotalSize() + (i.thead?.offsetHeight || 0) + "px";
|
|
88
|
+
}), createComponent(e, c);
|
|
90
89
|
},
|
|
91
|
-
Thead: ({ Thead: e }, { store:
|
|
92
|
-
return `transform: translate(${
|
|
90
|
+
Thead: ({ Thead: e }, { store: n }) => (i) => (i = combineProps({ get style() {
|
|
91
|
+
return `transform: translate(${n.virtualizerX.getVirtualItems()[0]?.start}px, 0px);`;
|
|
93
92
|
} }, i), createComponent(e, i)),
|
|
94
|
-
Tbody: ({ Tbody: e }, { store:
|
|
95
|
-
return `transform: translate(${
|
|
93
|
+
Tbody: ({ Tbody: e }, { store: n }) => (i) => (i = combineProps({ get style() {
|
|
94
|
+
return `transform: translate(${n.virtualizerX.getVirtualItems()[0]?.start}px, ${n.virtualizerY.getVirtualItems()[0]?.start}px)`;
|
|
96
95
|
} }, i), createComponent(e, i)),
|
|
97
|
-
Tr: ({ Tr: e }, { store:
|
|
98
|
-
Td: ({ Td: e }, { store:
|
|
99
|
-
let
|
|
96
|
+
Tr: ({ Tr: e }, { store: n }) => (i) => (createEffect(() => i.y != null && n.trSizes[i.y] && n.virtualizerY.resizeItem(i.y, n.trSizes[i.y].height)), createComponent(e, i)),
|
|
97
|
+
Td: ({ Td: e }, { store: n }) => (i) => {
|
|
98
|
+
let a = createMemo(() => n[$ML]()[i.x]), s = combineProps({ get style() {
|
|
100
99
|
let e = i.colspan ?? 1;
|
|
101
|
-
return `width: ${e > 1 ? Array.from({ length: e }, (e,
|
|
100
|
+
return `width: ${e > 1 ? Array.from({ length: e }, (e, r) => n.props.columns?.[i.x + r]?.width ?? 80).reduce((e, n) => e + n, 0) : i.col.width || 80}px; margin-left: ${i.col.fixed ? 0 : a()?.offset ?? 0}px`;
|
|
102
101
|
} }, i);
|
|
103
102
|
return createComponent(e, s);
|
|
104
103
|
},
|
|
105
|
-
Th: ({ Th: e }, { store:
|
|
106
|
-
createEffect(() => (i.colspan ?? 1) === 1 &&
|
|
107
|
-
let
|
|
104
|
+
Th: ({ Th: e }, { store: n }) => (i) => {
|
|
105
|
+
createEffect(() => (i.colspan ?? 1) === 1 && n.thSizes[i.x] && n.virtualizerX.resizeItem(i.x, n.thSizes[i.x].width));
|
|
106
|
+
let s = createMemo(() => n[$ML]?.()[i.x]), l = combineProps({ get style() {
|
|
108
107
|
let e = i.colspan ?? 1;
|
|
109
|
-
return `width: ${e > 1 ? Array.from({ length: e }, (e,
|
|
108
|
+
return `width: ${e > 1 ? Array.from({ length: e }, (e, r) => n.props.columns?.[i.x + r]?.width ?? 80).reduce((e, n) => e + n, 0) : i.col.width || 80}px; margin-left: ${i.col.fixed ? 0 : s()?.offset ?? 0}px`;
|
|
110
109
|
} }, i);
|
|
111
110
|
return createComponent(e, l);
|
|
112
111
|
},
|
|
113
|
-
EachRows: ({ EachRows:
|
|
114
|
-
|
|
115
|
-
let
|
|
116
|
-
return createComponent(
|
|
112
|
+
EachRows: ({ EachRows: n }, { store: a }) => (s) => {
|
|
113
|
+
n = RecycleList;
|
|
114
|
+
let c = createMemo(() => a.virtualizerY.getVirtualItems().map((e) => s.each[e.index]));
|
|
115
|
+
return createComponent(n, mergeProps(s, {
|
|
117
116
|
get each() {
|
|
118
|
-
return
|
|
117
|
+
return c();
|
|
119
118
|
},
|
|
120
|
-
children: (e,
|
|
119
|
+
children: (e, n) => s.children(e, createMemo(() => a.virtualizerY.getVirtualItems()[n()]?.index))
|
|
121
120
|
}));
|
|
122
121
|
},
|
|
123
|
-
EachCells: ({ EachCells:
|
|
124
|
-
if (
|
|
125
|
-
let
|
|
126
|
-
return createComponent(
|
|
122
|
+
EachCells: ({ EachCells: n }, { store: a }) => (s) => {
|
|
123
|
+
if (n = RecycleList, s.each?.length !== a.virtualizerX?.options?.count) return createComponent(n, s);
|
|
124
|
+
let c = createMemo(() => a.virtualizerX.getVirtualItems().map((e) => s.each[e.index]));
|
|
125
|
+
return createComponent(n, mergeProps(s, {
|
|
127
126
|
get each() {
|
|
128
|
-
return
|
|
127
|
+
return c();
|
|
129
128
|
},
|
|
130
|
-
children: (e,
|
|
129
|
+
children: (e, n) => s.children(e, createMemo(() => a.virtualizerX.getVirtualItems()[n()]?.index))
|
|
131
130
|
}));
|
|
132
131
|
}
|
|
133
132
|
}
|