intable 0.0.26 → 0.0.28
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 +378 -378
- package/dist/__uno.css +1 -1
- package/dist/components/AndOrFields.d.ts +1 -1
- package/dist/components/AndOrFields.js +193 -74
- package/dist/components/Filter.d.ts +0 -1
- package/dist/hooks/useVirtualizer.d.ts +3 -0
- package/dist/hooks/useVirtualizer.js +12 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +17 -11
- package/dist/loading-bold.js +6 -0
- package/dist/plugins/CellMergePlugin.js +15 -16
- package/dist/plugins/CellSelectionPlugin.js +97 -69
- package/dist/plugins/CommandPlugin.js +3 -1
- package/dist/plugins/CopyPastePlugin.js +1 -1
- package/dist/plugins/DiffPlugin.d.ts +0 -1
- package/dist/plugins/DiffPlugin.js +2 -2
- package/dist/plugins/EditablePlugin.js +74 -74
- package/dist/plugins/ExpandPlugin.js +0 -1
- package/dist/plugins/FilterPlugin.js +95 -53
- package/dist/plugins/ImportExportPlugin.d.ts +9 -0
- package/dist/plugins/ImportExportPlugin.js +37 -0
- package/dist/plugins/LoadMorePlugin.js +1 -1
- package/dist/plugins/MenuPlugin.d.ts +1 -0
- package/dist/plugins/MenuPlugin.js +7 -0
- package/dist/plugins/RenderPlugin/index.d.ts +3 -3
- package/dist/plugins/RenderPlugin/index.js +12 -12
- package/dist/plugins/ResizePlugin.js +45 -36
- package/dist/plugins/RowGroupPlugin.js +1 -1
- package/dist/plugins/TreePlugin.js +25 -23
- package/dist/plugins/ValidatorPlugin.js +14 -12
- package/dist/plugins/VirtualScrollPlugin.js +16 -2
- 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 +3 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { createComponent } from "solid-js/web";
|
|
1
|
+
import { createComponent, mergeProps } from "solid-js/web";
|
|
2
2
|
import { Show, createMemo } from "solid-js";
|
|
3
|
-
import { combineProps } from "@solid-primitives/props";
|
|
4
3
|
function buildMergeMap(e, t, n) {
|
|
5
4
|
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
6
5
|
for (let a = 0; a < e.length; a++) for (let o = 0; o < t.length; o++) {
|
|
@@ -27,28 +26,28 @@ function buildMergeMap(e, t, n) {
|
|
|
27
26
|
const CellMergePlugin = {
|
|
28
27
|
name: "cell-merge",
|
|
29
28
|
rewriteProps: {
|
|
30
|
-
Table: ({ Table: t }, { store:
|
|
31
|
-
let { merge: e, data: t, columns:
|
|
32
|
-
return !e && !
|
|
29
|
+
Table: ({ Table: t }, { store: n }) => (a) => (n._mergeMap ??= createMemo(() => {
|
|
30
|
+
let { merge: e, data: t, columns: r } = n.props;
|
|
31
|
+
return !e && !r?.some((e) => e.mergeRow) || !t?.length || !r?.length ? {
|
|
33
32
|
spans: /* @__PURE__ */ new Map(),
|
|
34
33
|
covered: /* @__PURE__ */ new Set()
|
|
35
|
-
} : buildMergeMap(t,
|
|
34
|
+
} : buildMergeMap(t, r, e);
|
|
36
35
|
}), createComponent(t, a)),
|
|
37
|
-
Td: ({ Td:
|
|
36
|
+
Td: ({ Td: r }, { store: i }) => (a) => {
|
|
38
37
|
let o = () => `${a.y},${a.x}`, s = () => i._mergeMap?.().covered.has(o()) ?? !1, c = () => i._mergeMap?.().spans.get(o());
|
|
39
|
-
return
|
|
40
|
-
get rowspan() {
|
|
41
|
-
return c()?.rowspan;
|
|
42
|
-
},
|
|
43
|
-
get colspan() {
|
|
44
|
-
return c()?.colspan;
|
|
45
|
-
}
|
|
46
|
-
}), createComponent(Show, {
|
|
38
|
+
return createComponent(Show, {
|
|
47
39
|
get when() {
|
|
48
40
|
return !s();
|
|
49
41
|
},
|
|
50
42
|
get children() {
|
|
51
|
-
return createComponent(
|
|
43
|
+
return createComponent(r, mergeProps(a, {
|
|
44
|
+
get rowspan() {
|
|
45
|
+
return c()?.rowspan;
|
|
46
|
+
},
|
|
47
|
+
get colspan() {
|
|
48
|
+
return c()?.colspan;
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
52
51
|
}
|
|
53
52
|
});
|
|
54
53
|
},
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { usePointerDrag } from "../hooks/index.js";
|
|
2
|
+
import { unFn } from "../utils.js";
|
|
2
3
|
import { createComponent, memo, mergeProps, template } from "solid-js/web";
|
|
3
4
|
import { batch, createMemo } from "solid-js";
|
|
4
5
|
import { combineProps } from "@solid-primitives/props";
|
|
5
|
-
|
|
6
|
+
import { createLazyMemo } from "@solid-primitives/memo";
|
|
7
|
+
var _tmpl$ = /* @__PURE__ */ template("<div class=area>"), inrange = (e, a, o) => e <= o && e >= a;
|
|
6
8
|
const CellSelectionPlugin = {
|
|
7
9
|
name: "cell-selection",
|
|
8
10
|
store: (e) => ({
|
|
@@ -10,104 +12,130 @@ const CellSelectionPlugin = {
|
|
|
10
12
|
start: [],
|
|
11
13
|
end: []
|
|
12
14
|
},
|
|
13
|
-
cellSelectionRect: () => {
|
|
14
|
-
let { start:
|
|
15
|
+
cellSelectionRect: createLazyMemo(() => {
|
|
16
|
+
let { start: a, end: o } = e.selected, s = [a[0], o[0]].sort((e, a) => e - a), c = [a[1], o[1]].sort((e, a) => e - a);
|
|
15
17
|
return {
|
|
16
|
-
xs:
|
|
17
|
-
ys:
|
|
18
|
+
xs: s,
|
|
19
|
+
ys: c
|
|
18
20
|
};
|
|
19
|
-
}
|
|
21
|
+
})
|
|
20
22
|
}),
|
|
21
23
|
commands: (e) => ({ getAreaRows() {
|
|
22
|
-
let { start:
|
|
23
|
-
return e.props.data.slice(
|
|
24
|
+
let { start: a, end: o } = e.selected, [s, c] = [a[1], o[1]].sort((e, a) => e - a);
|
|
25
|
+
return e.props.data.slice(s, c + 1);
|
|
24
26
|
} }),
|
|
25
27
|
rewriteProps: {
|
|
26
|
-
Table: ({ Table: a }, { store:
|
|
28
|
+
Table: ({ Table: a }, { store: s }) => (c) => (usePointerDrag(() => s.table, {
|
|
27
29
|
preventDefault: !1,
|
|
28
|
-
start(e,
|
|
30
|
+
start(e, a, o) {
|
|
29
31
|
batch(() => {
|
|
30
|
-
let
|
|
31
|
-
if (
|
|
32
|
-
if (
|
|
33
|
-
let [e,
|
|
32
|
+
let o = (e) => e.composedPath().find((e) => e.tagName == "TH" || e.tagName == "TD"), c = (e) => [e.getAttribute("x"), e.getAttribute("y")], l = o(e);
|
|
33
|
+
if (l && !(e.buttons != 1 && l.classList.contains("range-selected"))) {
|
|
34
|
+
if (l.tagName == "TH") {
|
|
35
|
+
let [e, u] = c(l);
|
|
34
36
|
if (e == null) return;
|
|
35
|
-
|
|
36
|
-
let
|
|
37
|
-
if (!
|
|
38
|
-
let [
|
|
39
|
-
|
|
37
|
+
s.selected.start = [+e, 0], s.selected.end = [+e, Infinity], a((e) => {
|
|
38
|
+
let a = o(e);
|
|
39
|
+
if (!a) return;
|
|
40
|
+
let [l, u] = c(a);
|
|
41
|
+
l != null && (s.selected.end = [+l, Infinity]);
|
|
40
42
|
});
|
|
41
43
|
}
|
|
42
|
-
if (
|
|
43
|
-
let [e,
|
|
44
|
-
if (e == null ||
|
|
45
|
-
|
|
46
|
-
let
|
|
47
|
-
if (!
|
|
48
|
-
let [
|
|
49
|
-
|
|
44
|
+
if (l.classList.contains("index")) {
|
|
45
|
+
let [e, u] = c(l);
|
|
46
|
+
if (e == null || u == null) return;
|
|
47
|
+
s.selected.start = [0, +u], s.selected.end = [Infinity, +u], a((e) => {
|
|
48
|
+
let a = o(e);
|
|
49
|
+
if (!a) return;
|
|
50
|
+
let [l, u] = c(a);
|
|
51
|
+
l == null || u == null || (s.selected.end = [Infinity, +u]);
|
|
50
52
|
});
|
|
51
|
-
} else if (
|
|
52
|
-
let [e,
|
|
53
|
-
if (e == null ||
|
|
54
|
-
|
|
55
|
-
let
|
|
56
|
-
if (!
|
|
57
|
-
let [
|
|
58
|
-
|
|
53
|
+
} else if (l.tagName == "TD") {
|
|
54
|
+
let [e, u] = c(l);
|
|
55
|
+
if (e == null || u == null) return;
|
|
56
|
+
s.selected.start = [+e, +u], s.selected.end = [...s.selected.start], a((e) => {
|
|
57
|
+
let a = o(e);
|
|
58
|
+
if (!a) return;
|
|
59
|
+
let [l, u] = c(a);
|
|
60
|
+
l == null || u == null || (s.selected.end = [+l, +u]);
|
|
59
61
|
});
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
});
|
|
63
65
|
}
|
|
64
|
-
}),
|
|
65
|
-
Th: ({ Th: e }, { store:
|
|
66
|
+
}), c = combineProps({ class: "select-none" }, c), createComponent(a, c)),
|
|
67
|
+
Th: ({ Th: e }, { store: a }) => (l) => {
|
|
66
68
|
let u = createMemo(() => {
|
|
67
|
-
let { start: e, end:
|
|
68
|
-
return inrange(
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
let { start: e, end: o } = a.selected;
|
|
70
|
+
return inrange(l.x, ...[e[0], o[0]].sort((e, a) => e - a)) ? "col-range-highlight" : "";
|
|
71
|
+
});
|
|
72
|
+
return createComponent(e, mergeProps(l, {
|
|
73
|
+
get class() {
|
|
74
|
+
return `${l.class} ${u()}`;
|
|
75
|
+
},
|
|
76
|
+
get children() {
|
|
77
|
+
return [l.children, memo(() => memo(() => !!u())() && _tmpl$())];
|
|
78
|
+
}
|
|
79
|
+
}));
|
|
75
80
|
},
|
|
76
|
-
Td: ({ Td: e }, { store:
|
|
81
|
+
Td: ({ Td: e }, { store: a }) => (l) => {
|
|
77
82
|
let u = createMemo(() => {
|
|
78
|
-
let e = "", { xs:
|
|
79
|
-
return
|
|
80
|
-
})
|
|
83
|
+
let e = "", { xs: o, ys: s } = a.cellSelectionRect(), c = inrange(l.x, o[0], o[1]), u = inrange(l.y, s[0], s[1]);
|
|
84
|
+
return c && u && (e += "range-selected ", l.x == o[0] && (e += "range-selected-l "), l.x == o[1] && (e += "range-selected-r "), l.y == s[0] && (e += "range-selected-t "), l.y == s[1] && (e += "range-selected-b ")), l.col.id == a.$index?.id && u && (e += "row-range-highlight "), e;
|
|
85
|
+
});
|
|
86
|
+
return createComponent(e, mergeProps(l, {
|
|
81
87
|
get class() {
|
|
82
|
-
return u()
|
|
88
|
+
return `${l.class} ${u()}`;
|
|
83
89
|
},
|
|
84
|
-
tabindex: -1
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
90
|
+
tabindex: -1,
|
|
91
|
+
get children() {
|
|
92
|
+
return [l.children, memo(() => memo(() => !!u())() && _tmpl$())];
|
|
93
|
+
}
|
|
94
|
+
}));
|
|
89
95
|
}
|
|
90
96
|
},
|
|
91
97
|
keybindings: (e) => ({
|
|
92
|
-
ArrowLeft: () => {
|
|
93
|
-
let { start:
|
|
94
|
-
|
|
98
|
+
ArrowLeft: async () => {
|
|
99
|
+
let { start: a, end: o } = e.selected;
|
|
100
|
+
a.length && (a[0] = o[0] = Math.max(a[0] - 1, 0), o[1] = a[1], e.scrollCellIfNeeded(a[0], a[1]), await new Promise(requestAnimationFrame), e.table.querySelector(`[x="${a[0]}"][y="${a[1]}"]`)?.focus());
|
|
95
101
|
},
|
|
96
|
-
ArrowRight: () => {
|
|
97
|
-
let { start:
|
|
98
|
-
|
|
102
|
+
ArrowRight: async () => {
|
|
103
|
+
let { start: a, end: o } = e.selected;
|
|
104
|
+
a.length && (a[0] = o[0] = Math.min(a[0] + 1, e.props.columns.length - 1), o[1] = a[1], e.scrollCellIfNeeded(a[0], a[1]), await new Promise(requestAnimationFrame), e.table.querySelector(`[x="${a[0]}"][y="${a[1]}"]`)?.focus());
|
|
99
105
|
},
|
|
100
|
-
ArrowUp: () => {
|
|
101
|
-
let { start:
|
|
102
|
-
|
|
106
|
+
ArrowUp: async () => {
|
|
107
|
+
let { start: a, end: o } = e.selected;
|
|
108
|
+
a.length && (a[1] = o[1] = Math.max(a[1] - 1, 0), o[0] = a[0], e.scrollCellIfNeeded(a[0], a[1]), await new Promise(requestAnimationFrame), e.table.querySelector(`[x="${a[0]}"][y="${a[1]}"]`)?.focus());
|
|
103
109
|
},
|
|
104
|
-
ArrowDown: () => {
|
|
105
|
-
let { start:
|
|
106
|
-
|
|
110
|
+
ArrowDown: async () => {
|
|
111
|
+
let { start: a, end: o } = e.selected;
|
|
112
|
+
a.length && (a[1] = o[1] = Math.min(a[1] + 1, e.props.data.length - 1), o[0] = a[0], e.scrollCellIfNeeded(a[0], a[1]), await new Promise(requestAnimationFrame), e.table.querySelector(`[x="${a[0]}"][y="${a[1]}"]`)?.focus());
|
|
107
113
|
},
|
|
108
114
|
"$mod+a": () => {
|
|
109
|
-
let { columns:
|
|
110
|
-
!
|
|
115
|
+
let { columns: a, data: o } = e.props;
|
|
116
|
+
!a?.length || !o?.length || (e.selected.start = [0, 0], e.selected.end = [a.length - 1, o.length - 1]);
|
|
117
|
+
},
|
|
118
|
+
backspace: () => {
|
|
119
|
+
let { start: o, end: s } = e.selected;
|
|
120
|
+
if (!o.length) return;
|
|
121
|
+
let [c, l] = [o[0], s[0]].sort((e, a) => e - a), [u, d] = [o[1], s[1]].sort((e, a) => e - a), f = [...e.props.data];
|
|
122
|
+
for (let o = u; o <= d; o++) {
|
|
123
|
+
let s = e.props.data[o], u = {};
|
|
124
|
+
for (let d = c; d <= l; d++) {
|
|
125
|
+
let c = e.props.columns[d];
|
|
126
|
+
unFn(e.props.editable, {
|
|
127
|
+
col: c,
|
|
128
|
+
data: s,
|
|
129
|
+
x: d,
|
|
130
|
+
y: o
|
|
131
|
+
}) && (u[c.id] = "");
|
|
132
|
+
}
|
|
133
|
+
f[o] = {
|
|
134
|
+
...f[o],
|
|
135
|
+
...u
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
e.commands.rowsChange(f.slice(u, d + 1));
|
|
111
139
|
}
|
|
112
140
|
})
|
|
113
141
|
};
|
|
@@ -15,13 +15,15 @@ const CommandPlugin = {
|
|
|
15
15
|
let o = e.table.querySelector(`[x="${r}"][y="${i}"]`);
|
|
16
16
|
o && o.scrollIntoView({
|
|
17
17
|
behavior: "smooth",
|
|
18
|
+
block: "center",
|
|
19
|
+
inline: "center",
|
|
18
20
|
...a
|
|
19
21
|
});
|
|
20
22
|
},
|
|
21
23
|
scrollCellIfNeeded(r, i, a = !1) {
|
|
22
24
|
r = typeof r == "object" ? e.props.columns.indexOf(r) : r, i = typeof i == "object" ? e.props.data.indexOf(i) : i;
|
|
23
25
|
let o = e.table.querySelector(`[x="${r}"][y="${i}"]`);
|
|
24
|
-
o &&
|
|
26
|
+
o && o.scrollIntoViewIfNeeded(a);
|
|
25
27
|
}
|
|
26
28
|
};
|
|
27
29
|
},
|
|
@@ -66,7 +66,7 @@ const ClipboardPlugin = {
|
|
|
66
66
|
}
|
|
67
67
|
let S = l, C = 0;
|
|
68
68
|
for (let e = l; e < _.length && C < v.length; e++) _[e][t.internal] || (S = e, C++);
|
|
69
|
-
t.selected.end = [S, x], t.
|
|
69
|
+
t.selected.end = [S, x], t.commands.rowsChange?.(y);
|
|
70
70
|
}
|
|
71
71
|
})
|
|
72
72
|
};
|
|
@@ -33,7 +33,7 @@ const DiffPlugin = {
|
|
|
33
33
|
...e
|
|
34
34
|
}),
|
|
35
35
|
data: ({ data: e }, { store: o }) => {
|
|
36
|
-
if (!o.props.diff?.
|
|
36
|
+
if (!o.props.diff?.data) return e;
|
|
37
37
|
let { rowKey: s, diff: c } = o.props || {}, l = o.diffData();
|
|
38
38
|
if (e.length === l.length && e.length > 0) {
|
|
39
39
|
let o = !0;
|
|
@@ -49,7 +49,7 @@ const DiffPlugin = {
|
|
|
49
49
|
[o.internal]: 1
|
|
50
50
|
})) : [] : e.value);
|
|
51
51
|
},
|
|
52
|
-
Td: ({ Td: u }, { store: f }) => f.props.diff?.
|
|
52
|
+
Td: ({ Td: u }, { store: f }) => f.props.diff?.data ? (p) => {
|
|
53
53
|
let m = createMemo(() => {
|
|
54
54
|
let { diff: e } = f.props, o = p.data[f.props.rowKey];
|
|
55
55
|
return [p.data[NEW] ? "bg-green!" : p.data[DEL] ? "bg-red!" : p.data[f.internal] ? "" : e.changed && p.data[p.col.id] != f.diffDataKeyed()[o]?.[p.col.id] ? "bg-green!" : ""].join(" ");
|
|
@@ -1,129 +1,129 @@
|
|
|
1
1
|
import { chooseFile, resolveOptions, unFn } from "../utils.js";
|
|
2
2
|
import { Checkbox, Files } from "./RenderPlugin/components.js";
|
|
3
3
|
import { Ctx } from "../index.js";
|
|
4
|
-
import { createComponent, delegateEvents, effect, insert, memo, mergeProps, spread, template, use } from "solid-js/web";
|
|
4
|
+
import { addEventListener, createComponent, delegateEvents, effect, insert, memo, mergeProps, spread, template, use } from "solid-js/web";
|
|
5
5
|
import { createComputed, createEffect, createMemo, createRoot, createSignal, on, onCleanup, useContext } from "solid-js";
|
|
6
6
|
import { createMutable } from "solid-js/store";
|
|
7
7
|
import { combineProps } from "@solid-primitives/props";
|
|
8
8
|
import { createAsyncMemo } from "@solid-primitives/memo";
|
|
9
9
|
import { delay } from "es-toolkit";
|
|
10
|
-
var _tmpl$ = /* @__PURE__ */ template("<
|
|
10
|
+
var _tmpl$ = /* @__PURE__ */ template("<div class=in-cell-edit-wrapper tabindex=-1>"), _tmpl$2 = /* @__PURE__ */ template("<span class=cell-validating>"), _tmpl$3 = /* @__PURE__ */ template("<input style=position:absolute;margin-top:1em;width:0;height:0;pointer-events:none;opacity:0>"), _tmpl$4 = /* @__PURE__ */ template("<input>"), _tmpl$5 = /* @__PURE__ */ template("<textarea>"), _tmpl$6 = /* @__PURE__ */ template("<label class=\"h-full flex items-center\">"), _tmpl$7 = /* @__PURE__ */ template("<select>"), _tmpl$8 = /* @__PURE__ */ template("<option>");
|
|
11
11
|
const EditablePlugin = {
|
|
12
12
|
name: "editable",
|
|
13
13
|
store: () => ({ editors: { ...editors } }),
|
|
14
14
|
rewriteProps: {
|
|
15
|
-
editable: ({ editable: e }, { store:
|
|
16
|
-
let
|
|
17
|
-
return !!
|
|
15
|
+
editable: ({ editable: e }, { store: _ }) => (y) => {
|
|
16
|
+
let b = [y.col.editable, e].filter((e) => e != null);
|
|
17
|
+
return !!b.length && b.every((e) => unFn(e, y)) && !y.data[_.internal] && !y.col[_.internal];
|
|
18
18
|
},
|
|
19
|
-
Td: ({ Td: e }, { store:
|
|
20
|
-
let
|
|
19
|
+
Td: ({ Td: e }, { store: _ }) => (y) => {
|
|
20
|
+
let b, { props: C } = useContext(Ctx), [w, E] = createSignal(!1), D = "", j = () => unFn(C.editable, y), M = () => (([e, _]) => y.x == e && y.y == _)(_.selected.start || []), N = () => M() && j() && !w(), [P, F] = createSignal(!1), I = createAsyncMemo(() => {
|
|
21
21
|
if (w()) {
|
|
22
|
-
let e = !1,
|
|
23
|
-
props:
|
|
24
|
-
col:
|
|
25
|
-
eventKey:
|
|
26
|
-
data:
|
|
27
|
-
value:
|
|
22
|
+
let e = !1, v = y.data[y.col.id], b = ((e) => typeof e == "string" ? _.editors[e] : e)(y.col.editor ?? y.col.type ?? "text"), x = {
|
|
23
|
+
props: y.col.editorProps,
|
|
24
|
+
col: y.col,
|
|
25
|
+
eventKey: D,
|
|
26
|
+
data: y.data,
|
|
27
|
+
value: v,
|
|
28
28
|
ok: async () => {
|
|
29
|
-
await
|
|
29
|
+
await L(S.getValue()), E(!1);
|
|
30
30
|
},
|
|
31
|
-
cancel: () => (e = !0,
|
|
32
|
-
onChange: (e) => w() &&
|
|
33
|
-
},
|
|
31
|
+
cancel: () => (e = !0, E(!1)),
|
|
32
|
+
onChange: (e) => w() && L(e).catch(() => {})
|
|
33
|
+
}, S = b(x);
|
|
34
34
|
return onCleanup(() => {
|
|
35
|
-
!e &&
|
|
36
|
-
...
|
|
37
|
-
[
|
|
38
|
-
}), e ||
|
|
39
|
-
}), [
|
|
35
|
+
!e && S.getValue() !== v && _.commands.rowChange({
|
|
36
|
+
...C.data[y.y],
|
|
37
|
+
[y.col.id]: S.getValue()
|
|
38
|
+
}), e || L(S.getValue()).catch(() => {}), D = "", S.destroy();
|
|
39
|
+
}), [x, S];
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
async function
|
|
42
|
+
async function L(e) {
|
|
43
43
|
try {
|
|
44
|
-
|
|
44
|
+
F(!0), await _.validateCell(e, y.data, y.col);
|
|
45
45
|
} finally {
|
|
46
|
-
|
|
46
|
+
F(!1);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
createEffect(() => {
|
|
50
|
-
|
|
50
|
+
I()?.[1]?.focus?.();
|
|
51
51
|
}), createEffect(() => {
|
|
52
52
|
if (w()) {
|
|
53
|
-
let e = createMemo(() => JSON.stringify(
|
|
54
|
-
createEffect(on(e, () =>
|
|
53
|
+
let e = createMemo(() => JSON.stringify(_.selected ?? "{}"));
|
|
54
|
+
createEffect(on(e, () => E(!1), { defer: !0 }));
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
|
-
let
|
|
57
|
+
let R, z = createMutable({
|
|
58
58
|
w: 0,
|
|
59
59
|
h: 0
|
|
60
60
|
});
|
|
61
|
-
return createComputed(() => w() && (
|
|
62
|
-
ref: (e) =>
|
|
61
|
+
return createComputed(() => w() && (z.w = b.getBoundingClientRect().width, z.h = b.getBoundingClientRect().height)), y = combineProps(y, {
|
|
62
|
+
ref: (e) => b = e,
|
|
63
63
|
get class() {
|
|
64
64
|
return w() ? "is-editing" : "";
|
|
65
65
|
},
|
|
66
66
|
get style() {
|
|
67
|
-
return w() ? `width: ${
|
|
67
|
+
return w() ? `width: ${z.w}px; height: ${z.h}px; padding: 0; ` : "";
|
|
68
68
|
},
|
|
69
|
-
onClick: () =>
|
|
70
|
-
onDblClick: () =>
|
|
71
|
-
onKeyDown: (e) => e.key == "Escape" &&
|
|
72
|
-
}), createComponent(e, mergeProps(
|
|
73
|
-
return [memo(() => memo(() => !!
|
|
69
|
+
onClick: () => R?.focus?.(),
|
|
70
|
+
onDblClick: () => E(j()),
|
|
71
|
+
onKeyDown: (e) => e.key == "Escape" && I()?.[0].cancel()
|
|
72
|
+
}), createComponent(e, mergeProps(y, { get children() {
|
|
73
|
+
return [memo(() => memo(() => !!I()?.[1]?.el)() ? (() => {
|
|
74
74
|
var e = _tmpl$();
|
|
75
|
+
return addEventListener(e, "keydown", (e) => e.stopPropagation()), insert(e, () => I()?.[1]?.el, null), insert(e, (() => {
|
|
76
|
+
var e = memo(() => !!P());
|
|
77
|
+
return () => e() && _tmpl$2();
|
|
78
|
+
})(), null), e;
|
|
79
|
+
})() : y.children), memo(() => memo(() => !!N())() && (() => {
|
|
80
|
+
var e = _tmpl$3();
|
|
75
81
|
return e.addEventListener("compositionend", () => {
|
|
76
|
-
|
|
82
|
+
E(!0);
|
|
77
83
|
}), e.$$input = (e) => {
|
|
78
|
-
|
|
84
|
+
D = e.target.value, E(!e.isComposing);
|
|
79
85
|
}, e.$$keydown = (e) => {
|
|
80
86
|
e.key == " " && e.preventDefault();
|
|
81
87
|
}, use((e) => {
|
|
82
|
-
|
|
88
|
+
R = e, delay(0).then(() => e.focus({ preventScroll: !0 }));
|
|
83
89
|
}, e), e;
|
|
84
|
-
})())
|
|
85
|
-
var e = _tmpl$2();
|
|
86
|
-
return insert(e, () => F()?.[1]?.el, null), insert(e, (() => {
|
|
87
|
-
var e = memo(() => !!N());
|
|
88
|
-
return () => e() && _tmpl$3();
|
|
89
|
-
})(), null), e;
|
|
90
|
-
})() : _.children)];
|
|
90
|
+
})())];
|
|
91
91
|
} }));
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
|
-
var createEditor = (e,
|
|
96
|
-
let [
|
|
95
|
+
var createEditor = (e, v, y) => ({ eventKey: b, value: x, col: S, ok: C, cancel: w, props: T, onChange: E }) => createRoot((D) => {
|
|
96
|
+
let [O, k] = createSignal(b || x), A;
|
|
97
97
|
return createComponent(e, mergeProps({
|
|
98
|
-
ref: (e) =>
|
|
98
|
+
ref: (e) => A = e,
|
|
99
99
|
class: "relative block px-2 size-full z-9 box-border resize-none outline-0",
|
|
100
100
|
get value() {
|
|
101
|
-
return
|
|
101
|
+
return O();
|
|
102
102
|
},
|
|
103
|
-
onInput: (e) => (
|
|
104
|
-
onChange: (e) => (
|
|
103
|
+
onInput: (e) => (k(e instanceof Event ? e.target.value : e), E?.(O())),
|
|
104
|
+
onChange: (e) => (k(e instanceof Event ? e.target.value : e), E?.(O()), y && C()),
|
|
105
105
|
"on:pointerdown": (e) => e.stopPropagation(),
|
|
106
106
|
"on:keydown": (e) => {
|
|
107
|
-
e.stopPropagation(), e.key == "Enter" && !e.shiftKey &&
|
|
107
|
+
e.stopPropagation(), e.key == "Enter" && !e.shiftKey && C(), e.key == "Escape" && w();
|
|
108
108
|
},
|
|
109
109
|
get options() {
|
|
110
|
-
return memo(() => !!
|
|
110
|
+
return memo(() => !!S.enum)() ? resolveOptions(S.enum ?? []) : void 0;
|
|
111
111
|
}
|
|
112
|
-
},
|
|
113
|
-
el:
|
|
114
|
-
getValue:
|
|
115
|
-
focus: () =>
|
|
116
|
-
destroy:
|
|
112
|
+
}, v, T)), {
|
|
113
|
+
el: A,
|
|
114
|
+
getValue: O,
|
|
115
|
+
focus: () => A.focus(),
|
|
116
|
+
destroy: D
|
|
117
117
|
};
|
|
118
118
|
}), Input = (e) => (() => {
|
|
119
|
-
var
|
|
120
|
-
return spread(
|
|
119
|
+
var _ = _tmpl$4();
|
|
120
|
+
return spread(_, e, !1, !1), _;
|
|
121
121
|
})();
|
|
122
122
|
const editors = {
|
|
123
123
|
text: createEditor(Input),
|
|
124
124
|
textarea: createEditor((e) => (() => {
|
|
125
|
-
var
|
|
126
|
-
return spread(
|
|
125
|
+
var _ = _tmpl$5();
|
|
126
|
+
return spread(_, e, !1, !1), _;
|
|
127
127
|
})()),
|
|
128
128
|
number: createEditor(Input, { type: "number" }),
|
|
129
129
|
range: createEditor(Input, { type: "range" }),
|
|
@@ -133,27 +133,27 @@ const editors = {
|
|
|
133
133
|
color: createEditor(Input, { type: "color" }),
|
|
134
134
|
tel: createEditor(Input, { type: "tel" }),
|
|
135
135
|
password: createEditor(Input, { type: "password" }),
|
|
136
|
-
file: createEditor((
|
|
136
|
+
file: createEditor((_) => createComponent(Files, mergeProps(_, {
|
|
137
137
|
class: "relative z-9 outline-2 outline-blue min-h-a! h-a! p-1 bg-#fff",
|
|
138
|
-
onAdd: () => chooseFile({ multiple: !0 }).then((e) =>
|
|
138
|
+
onAdd: () => chooseFile({ multiple: !0 }).then((e) => _.onChange([..._.value || [], ...e.map((e) => ({
|
|
139
139
|
name: e.name,
|
|
140
140
|
size: e.size
|
|
141
141
|
}))]))
|
|
142
142
|
}))),
|
|
143
143
|
checkbox: createEditor((e) => (() => {
|
|
144
|
-
var
|
|
145
|
-
return typeof
|
|
144
|
+
var _ = _tmpl$6(), v = e.ref;
|
|
145
|
+
return typeof v == "function" ? use(v, _) : e.ref = _, insert(_, createComponent(Checkbox, mergeProps(e, {
|
|
146
146
|
ref: () => {},
|
|
147
147
|
onInput: () => {},
|
|
148
148
|
class: "mx-3!"
|
|
149
|
-
}))),
|
|
149
|
+
}))), _;
|
|
150
150
|
})()),
|
|
151
151
|
select: createEditor((e) => (() => {
|
|
152
|
-
var
|
|
153
|
-
return spread(
|
|
154
|
-
var
|
|
155
|
-
return insert(
|
|
156
|
-
})())),
|
|
152
|
+
var _ = _tmpl$7();
|
|
153
|
+
return spread(_, e, !1, !0), insert(_, () => e.options?.map((e) => (() => {
|
|
154
|
+
var _ = _tmpl$8();
|
|
155
|
+
return insert(_, () => e.label), effect(() => _.value = e.value), _;
|
|
156
|
+
})())), _;
|
|
157
157
|
})(), {}, !0)
|
|
158
158
|
};
|
|
159
159
|
delegateEvents(["keydown", "input"]);
|