intable 0.0.59 → 0.0.61
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/dist/__uno.css +1 -1
- package/dist/components/Tooltip.js +9 -8
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.js +118 -111
- package/dist/hooks/useSelector.d.ts +5 -1
- package/dist/hooks/useSelector.js +27 -24
- package/dist/index.d.ts +12 -6
- package/dist/index.js +19 -8
- package/dist/plugins/BranchGraphPlugin.d.ts +24 -0
- package/dist/plugins/BranchGraphPlugin.js +218 -0
- package/dist/plugins/EditablePlugin.d.ts +1 -15
- package/dist/plugins/EditablePlugin.js +74 -68
- package/dist/plugins/ExpandPlugin.js +3 -2
- package/dist/plugins/ImportExportPlugin.js +8 -2
- 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/RowSelectionPlugin.d.ts +1 -0
- package/dist/plugins/TooltipPlugin.d.ts +3 -3
- package/dist/plugins/TooltipPlugin.js +46 -35
- package/dist/style.css +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Plugin$0 } from '../index';
|
|
2
|
+
declare module '../index' {
|
|
3
|
+
interface TableProps {
|
|
4
|
+
/**
|
|
5
|
+
* Render a git-style branch graph in a dedicated leading column.
|
|
6
|
+
*
|
|
7
|
+
* Each row links to its parent(s) via a `parentid` field (a single id or an
|
|
8
|
+
* array of ids for merge rows). Display order must be topological: a parent
|
|
9
|
+
* must appear above its children. The connecting lines are drawn as a single
|
|
10
|
+
* SVG overlay injected through `rewriteProps.Table`.
|
|
11
|
+
*/
|
|
12
|
+
branchGraph?: {
|
|
13
|
+
/** Field holding a row's parent id(s). Default `'parentid'`. */
|
|
14
|
+
parentField?: string;
|
|
15
|
+
/** Branch graph column width. Default `120`. */
|
|
16
|
+
width?: number;
|
|
17
|
+
/** Pixel gap between lanes. Default `18`. */
|
|
18
|
+
laneGap?: number;
|
|
19
|
+
/** Lane color palette (cycled by lane index). */
|
|
20
|
+
colors?: string[];
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export declare const BranchGraphPlugin: Plugin$0;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { solidComponent } from "../components/utils.js";
|
|
2
|
+
import { toArr } from "../utils.js";
|
|
3
|
+
import { createComponent, effect, insert, memo, mergeProps, setAttribute, setStyleProperty, template } from "solid-js/web";
|
|
4
|
+
import { Show, createMemo } from "solid-js";
|
|
5
|
+
import { combineProps } from "@solid-primitives/props";
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ template("<svg><path fill=none stroke-width=1.5></svg>", !1, !0, !1), _tmpl$2 = /* @__PURE__ */ template("<svg><line stroke-width=1.5></svg>", !1, !0, !1), _tmpl$3 = /* @__PURE__ */ template("<svg><g></svg>", !1, !0, !1), _tmpl$4 = /* @__PURE__ */ template("<svg><circle r=4 stroke=#fff stroke-width=1></svg>", !1, !0, !1), _tmpl$5 = /* @__PURE__ */ template("<svg class=branch-graph-svg style=position:absolute;pointer-events:none;z-index:3>"), _tmpl$6 = /* @__PURE__ */ template("<span style=display:none>");
|
|
7
|
+
function computeLayout(e, i, a) {
|
|
8
|
+
if (!e?.length) return null;
|
|
9
|
+
let o = (e) => e?.[i], s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
10
|
+
e.forEach((e, i) => {
|
|
11
|
+
let u = o(e);
|
|
12
|
+
s.set(u, i);
|
|
13
|
+
for (let o of toArr(e?.[a])) c.set(o, i), l.has(o) || l.set(o, []), l.get(o).push(u);
|
|
14
|
+
});
|
|
15
|
+
let u = (e, r) => [Math.min(e, ...r.map((r) => s.get(r) ?? e)), Math.max(e, ...r.map((r) => s.get(r) ?? e))], d = /* @__PURE__ */ new Map(), f = (e) => {
|
|
16
|
+
if (d.has(e)) return d.get(e);
|
|
17
|
+
let r = l.get(e)?.length ?? 0;
|
|
18
|
+
for (let i of l.get(e) ?? []) r += f(i);
|
|
19
|
+
return d.set(e, r), r;
|
|
20
|
+
};
|
|
21
|
+
for (let r of e) f(o(r));
|
|
22
|
+
let p = [], m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = [];
|
|
23
|
+
return e.forEach((i, f) => {
|
|
24
|
+
let _ = o(i), v = toArr(i?.[a]);
|
|
25
|
+
for (let i = 0; i < g.length; i++) {
|
|
26
|
+
let o = g[i];
|
|
27
|
+
if (o == null) continue;
|
|
28
|
+
let l = c.get(o);
|
|
29
|
+
if (l != null && l < f) {
|
|
30
|
+
let c = s.get(o);
|
|
31
|
+
c != null && toArr(e[c]?.[a]).some((e) => (s.get(e) ?? -1) >= f) || (g[i] = null);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
let y = -1;
|
|
35
|
+
for (let e of v) {
|
|
36
|
+
let r = g.indexOf(e);
|
|
37
|
+
if (r === -1) continue;
|
|
38
|
+
let i = l.get(e);
|
|
39
|
+
if (!i) continue;
|
|
40
|
+
if (i.reduce((e, r) => (d.get(r) ?? 0) > (d.get(e) ?? 0) ? r : e, i[0]) === _) {
|
|
41
|
+
y = r;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (y === -1) {
|
|
46
|
+
let e = h.get(_);
|
|
47
|
+
e != null && g[e.lane] != null && (y = e.lane);
|
|
48
|
+
}
|
|
49
|
+
if (y === -1) {
|
|
50
|
+
let [i, o] = u(f, v);
|
|
51
|
+
for (let l = 0; l < g.length; l++) {
|
|
52
|
+
let d = g[l];
|
|
53
|
+
if (d == null) {
|
|
54
|
+
y = l;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
if (c.get(d) != null) continue;
|
|
58
|
+
let p = s.get(d), m = toArr(e[p]?.[a]);
|
|
59
|
+
if (m.some((e) => (s.get(e) ?? -1) >= f)) continue;
|
|
60
|
+
let [h, _] = u(p, m);
|
|
61
|
+
if (_ < i || o < h) {
|
|
62
|
+
y = l;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
y === -1 && (y = g.length);
|
|
67
|
+
}
|
|
68
|
+
m.set(_, y), p.push({
|
|
69
|
+
y: f,
|
|
70
|
+
nodeLane: y,
|
|
71
|
+
parents: v,
|
|
72
|
+
key: _
|
|
73
|
+
}), g[y] = _;
|
|
74
|
+
for (let e of v) {
|
|
75
|
+
if (g.indexOf(e) !== -1) continue;
|
|
76
|
+
let r = h.get(e), i = d.get(_) ?? 0;
|
|
77
|
+
(!r || i > (d.get(r.claimant) ?? 0)) && h.set(e, {
|
|
78
|
+
lane: y,
|
|
79
|
+
claimant: _
|
|
80
|
+
});
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}), {
|
|
84
|
+
rows: p,
|
|
85
|
+
laneByKey: m,
|
|
86
|
+
indexByKey: s
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
var DEFAULT_COLORS = [
|
|
90
|
+
"#51a2ff",
|
|
91
|
+
"#f5a623",
|
|
92
|
+
"#7ed321",
|
|
93
|
+
"#d6418c",
|
|
94
|
+
"#9b59b6",
|
|
95
|
+
"#1abc9c",
|
|
96
|
+
"#e74c3c",
|
|
97
|
+
"#34495e"
|
|
98
|
+
];
|
|
99
|
+
function curve(e, r, i, a, o, s) {
|
|
100
|
+
let c = Math.sign(a - r);
|
|
101
|
+
if (Math.abs(r - a) <= 30) {
|
|
102
|
+
let s = (r + a) / 2;
|
|
103
|
+
return (() => {
|
|
104
|
+
var c = _tmpl$();
|
|
105
|
+
return setAttribute(c, "d", `M ${e} ${r} C ${e} ${s} ${i} ${s} ${i} ${a}`), setAttribute(c, "stroke", o), c;
|
|
106
|
+
})();
|
|
107
|
+
}
|
|
108
|
+
return s ? (() => {
|
|
109
|
+
var s = _tmpl$();
|
|
110
|
+
return setAttribute(s, "d", `M ${e} ${r} L ${e} ${r + c * 15 * 2} C ${e} ${r + c * 15} ${i} ${r + c * 15} ${i} ${a}`), setAttribute(s, "stroke", o), s;
|
|
111
|
+
})() : (() => {
|
|
112
|
+
var s = _tmpl$();
|
|
113
|
+
return setAttribute(s, "d", `M ${e} ${r} L ${e} ${a - c * 15 * 2} C ${e} ${a - c * 15} ${i} ${a - c * 15} ${i} ${a}`), setAttribute(s, "stroke", o), s;
|
|
114
|
+
})();
|
|
115
|
+
}
|
|
116
|
+
function BranchGraphSVG(e) {
|
|
117
|
+
let r = e.store, c = () => r.props.branchGraph, d = () => c()?.colors || DEFAULT_COLORS, m = () => c()?.laneGap ?? 18, h = createMemo(() => {
|
|
118
|
+
let e = c();
|
|
119
|
+
return e ? computeLayout(r.props.data, r.props.rowKey, e.parentField || "parentid") : null;
|
|
120
|
+
}), b = createMemo(() => r.props.columns.findIndex((e) => e.id == r.$branchCol.id)), S = createMemo(() => r.thSizes.slice(0, b()).reduce((e, r) => e + (r?.width || 0), 0)), C = createMemo(() => r.thSizes[b()]?.width ?? c()?.width ?? 120), w = createMemo(() => r.thSizes[0]?.height ?? 0), T = createMemo(() => {
|
|
121
|
+
let e = r.props.data, i = r.trSizes[0]?.height ?? 36, a = 0;
|
|
122
|
+
return e.map((e, o) => {
|
|
123
|
+
let s = r.trSizes[o]?.height ?? i, c = a + s / 2;
|
|
124
|
+
return a += s, c;
|
|
125
|
+
});
|
|
126
|
+
}), E = (e) => d()[e % d().length], D = (e) => m() + e * m(), O = createMemo(() => {
|
|
127
|
+
let e = h(), r = /* @__PURE__ */ new Map();
|
|
128
|
+
if (!e) return r;
|
|
129
|
+
for (let i of e.rows) r.set(i.key, i.parents);
|
|
130
|
+
return r;
|
|
131
|
+
}), k = createMemo(() => {
|
|
132
|
+
let e = r._branchHoverKey;
|
|
133
|
+
if (e == null) return null;
|
|
134
|
+
let i = O(), a = new Set([e]), o = [e];
|
|
135
|
+
for (; o.length;) {
|
|
136
|
+
let e = o.pop();
|
|
137
|
+
for (let r of i.get(e) ?? []) a.has(r) || (a.add(r), o.push(r));
|
|
138
|
+
}
|
|
139
|
+
return a;
|
|
140
|
+
}), A = createMemo(() => {
|
|
141
|
+
let e = h();
|
|
142
|
+
if (!e) return [];
|
|
143
|
+
let r = T(), { rows: i, laneByKey: s, indexByKey: c } = e, u = k(), d = [], f = [];
|
|
144
|
+
for (let e of i) {
|
|
145
|
+
let i = D(e.nodeLane), p = r[e.y], m = E(e.nodeLane), h = e.parents.some((r) => s.get(r) === e.nodeLane);
|
|
146
|
+
for (let a of e.parents) {
|
|
147
|
+
let f = s.get(a), v = c.get(a);
|
|
148
|
+
if (f == null || v == null) continue;
|
|
149
|
+
let y = D(f), b = r[v], x = u == null || u.has(e.key) && u.has(a) ? 1 : .12;
|
|
150
|
+
e.nodeLane === f ? d.push((() => {
|
|
151
|
+
var e = _tmpl$2();
|
|
152
|
+
return setAttribute(e, "x1", i), setAttribute(e, "y1", p), setAttribute(e, "x2", y), setAttribute(e, "y2", b), setAttribute(e, "stroke", m), setAttribute(e, "opacity", x), e;
|
|
153
|
+
})()) : d.push((() => {
|
|
154
|
+
var r = _tmpl$3();
|
|
155
|
+
return setAttribute(r, "opacity", x), insert(r, () => curve(i, p, y, b, E(h ? f : e.nodeLane), h)), r;
|
|
156
|
+
})());
|
|
157
|
+
}
|
|
158
|
+
f.push((() => {
|
|
159
|
+
var r = _tmpl$4();
|
|
160
|
+
return setAttribute(r, "cx", i), setAttribute(r, "cy", p), setAttribute(r, "fill", m), effect(() => setAttribute(r, "opacity", u == null || u.has(e.key) ? 1 : .2)), r;
|
|
161
|
+
})());
|
|
162
|
+
}
|
|
163
|
+
return [...d, ...f];
|
|
164
|
+
});
|
|
165
|
+
return createComponent(Show, {
|
|
166
|
+
get when() {
|
|
167
|
+
return memo(() => !!h())() && b() >= 0;
|
|
168
|
+
},
|
|
169
|
+
get children() {
|
|
170
|
+
var e = _tmpl$5();
|
|
171
|
+
return insert(e, A), effect((r) => {
|
|
172
|
+
var i = `${S()}px`, a = `${w()}px`, o = `${C()}px`, s = `calc(100% - ${w()}px)`;
|
|
173
|
+
return i !== r.e && setStyleProperty(e, "left", r.e = i), a !== r.t && setStyleProperty(e, "top", r.t = a), o !== r.a && setStyleProperty(e, "width", r.a = o), s !== r.o && setStyleProperty(e, "height", r.o = s), r;
|
|
174
|
+
}, {
|
|
175
|
+
e: void 0,
|
|
176
|
+
t: void 0,
|
|
177
|
+
a: void 0,
|
|
178
|
+
o: void 0
|
|
179
|
+
}), e;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
const BranchGraphPlugin = () => ({
|
|
184
|
+
name: "branch-graph",
|
|
185
|
+
store: (r) => ({
|
|
186
|
+
_branchHoverKey: null,
|
|
187
|
+
$branchCol: {
|
|
188
|
+
id: Symbol("branch-graph"),
|
|
189
|
+
name: "",
|
|
190
|
+
width: 120,
|
|
191
|
+
[r.internal]: 1,
|
|
192
|
+
class: "branch-graph-col",
|
|
193
|
+
render: solidComponent(() => _tmpl$6())
|
|
194
|
+
}
|
|
195
|
+
}),
|
|
196
|
+
rewriteProps: {
|
|
197
|
+
branchGraph: ({ branchGraph: e }) => e && {
|
|
198
|
+
parentField: "parentid",
|
|
199
|
+
width: 120,
|
|
200
|
+
laneGap: 18,
|
|
201
|
+
colors: DEFAULT_COLORS,
|
|
202
|
+
...e
|
|
203
|
+
},
|
|
204
|
+
columns: ({ columns: e }, { store: r }) => r.props.branchGraph ? [r.$branchCol, ...e || []] : e,
|
|
205
|
+
Tr: ({ Tr: e }, { store: r }) => (a) => (a = combineProps(a, {
|
|
206
|
+
onPointerEnter: () => {
|
|
207
|
+
r._branchHoverKey = a.data?.[r.props.rowKey];
|
|
208
|
+
},
|
|
209
|
+
onPointerLeave: () => {
|
|
210
|
+
r._branchHoverKey = null;
|
|
211
|
+
}
|
|
212
|
+
}), createComponent(e, a)),
|
|
213
|
+
Table: ({ Table: e }, { store: r }) => (a) => (a = combineProps(a, { class: "relative" }), createComponent(e, mergeProps(a, { get children() {
|
|
214
|
+
return [memo(() => a.children), createComponent(BranchGraphSVG, { store: r })];
|
|
215
|
+
} })))
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
export { BranchGraphPlugin };
|
|
@@ -34,18 +34,4 @@ export interface EditorOpt {
|
|
|
34
34
|
props?: any;
|
|
35
35
|
}
|
|
36
36
|
export declare const EditablePlugin: Plugin;
|
|
37
|
-
export declare const editors:
|
|
38
|
-
text: Editor;
|
|
39
|
-
textarea: Editor;
|
|
40
|
-
number: Editor;
|
|
41
|
-
range: Editor;
|
|
42
|
-
date: Editor;
|
|
43
|
-
time: Editor;
|
|
44
|
-
datetime: Editor;
|
|
45
|
-
color: Editor;
|
|
46
|
-
tel: Editor;
|
|
47
|
-
password: Editor;
|
|
48
|
-
file: Editor;
|
|
49
|
-
checkbox: Editor;
|
|
50
|
-
select: Editor;
|
|
51
|
-
};
|
|
37
|
+
export declare const editors: Record<string, Editor>;
|
|
@@ -12,40 +12,40 @@ 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: p }) => (h) => {
|
|
16
|
+
let g = [h.col.editable, e].filter((e) => e != null);
|
|
17
|
+
return !!g.length && g.every((e) => unFn(e, h)) && !h.data[p.internal] && !h.col[p.internal];
|
|
18
18
|
},
|
|
19
|
-
Td: ({ Td: e }, { store:
|
|
20
|
-
let
|
|
21
|
-
return createMemo(() =>
|
|
22
|
-
let
|
|
23
|
-
if (
|
|
24
|
-
let e = createMemo(() => JSON.stringify(
|
|
25
|
-
createEffect(on(e, () => w(!1), { defer: !0 })), F.w =
|
|
26
|
-
let
|
|
27
|
-
props:
|
|
28
|
-
col:
|
|
29
|
-
eventKey:
|
|
30
|
-
data:
|
|
31
|
-
value:
|
|
19
|
+
Td: ({ Td: e }, { store: p }) => (g) => {
|
|
20
|
+
let { props: _ } = p, v, x = () => unFn(p.props.editable, g);
|
|
21
|
+
return createMemo(() => x() ? unFn(() => {
|
|
22
|
+
let m = "", [S, w] = createSignal(!1), T = () => (([e, p]) => g.x == e && g.y == p)(p.selected.start || []), k = () => x() && !S() && T(), [A, j] = createSignal(!1), M = createAsyncMemo(() => {
|
|
23
|
+
if (S()) {
|
|
24
|
+
let e = createMemo(() => JSON.stringify(p.selected ?? "{}"));
|
|
25
|
+
createEffect(on(e, () => w(!1), { defer: !0 })), F.w = v.getBoundingClientRect().width, F.h = v.getBoundingClientRect().height;
|
|
26
|
+
let h = !1, y = g.data[g.col.id], b = ((e) => typeof e == "string" ? p.editors[e] : e)(g.col.editor ?? g.col.type ?? (g.col.enum && "select")) ?? (y == null ? null : p.editors[typeof y]) ?? p.editors.text, x = {
|
|
27
|
+
props: g.col.editorProps,
|
|
28
|
+
col: g.col,
|
|
29
|
+
eventKey: m,
|
|
30
|
+
data: g.data,
|
|
31
|
+
value: y,
|
|
32
32
|
ok: async () => {
|
|
33
|
-
await N(
|
|
33
|
+
await N(C.getValue()), w(!1);
|
|
34
34
|
},
|
|
35
|
-
cancel: () => (
|
|
36
|
-
onChange: (e) =>
|
|
37
|
-
},
|
|
38
|
-
return queueMicrotask(() =>
|
|
39
|
-
!
|
|
40
|
-
...
|
|
41
|
-
[
|
|
42
|
-
}),
|
|
43
|
-
}), [
|
|
35
|
+
cancel: () => (h = !0, w(!1)),
|
|
36
|
+
onChange: (e) => S() && N(e).catch(() => {})
|
|
37
|
+
}, C = b(x);
|
|
38
|
+
return queueMicrotask(() => C.focus?.()), onCleanup(() => {
|
|
39
|
+
!h && C.getValue() !== y && p.commands.rowChange({
|
|
40
|
+
..._.data[g.y],
|
|
41
|
+
[g.col.id]: C.getValue()
|
|
42
|
+
}), h || N(C.getValue()).catch(() => {}), m = "", C.destroy();
|
|
43
|
+
}), [x, C];
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
async function N(e) {
|
|
47
47
|
try {
|
|
48
|
-
j(!0), await
|
|
48
|
+
j(!0), await p.validateCell(e, g.data, g.col);
|
|
49
49
|
} finally {
|
|
50
50
|
j(!1);
|
|
51
51
|
}
|
|
@@ -53,17 +53,17 @@ const EditablePlugin = {
|
|
|
53
53
|
let P, F = createMutable({
|
|
54
54
|
w: 0,
|
|
55
55
|
h: 0
|
|
56
|
-
}), I = mergeProps$2(
|
|
57
|
-
ref: (e) => (
|
|
56
|
+
}), I = mergeProps$2(g, {
|
|
57
|
+
ref: (e) => (v = e, g.ref?.(e)),
|
|
58
58
|
get class() {
|
|
59
|
-
return [
|
|
59
|
+
return [S() ? "is-editing" : "", g.class].filter(Boolean).join(" ");
|
|
60
60
|
},
|
|
61
61
|
get style() {
|
|
62
|
-
return [
|
|
62
|
+
return [S() ? `width: ${F.w}px; height: ${F.h}px; padding: 0; ` : "", g.style].filter(Boolean).join(" ");
|
|
63
63
|
},
|
|
64
|
-
onClick: (e) => (P?.focus?.(),
|
|
65
|
-
onDblClick: (e) => (w(
|
|
66
|
-
onKeyDown: (e) => (e.key == "Escape" && M()?.[0].cancel(),
|
|
64
|
+
onClick: (e) => (P?.focus?.(), g.onClick?.(e)),
|
|
65
|
+
onDblClick: (e) => (w(x()), g.onDblClick?.(e)),
|
|
66
|
+
onKeyDown: (e) => (e.key == "Escape" && M()?.[0].cancel(), g.onKeyDown?.(e))
|
|
67
67
|
});
|
|
68
68
|
return createComponent(e, mergeProps$2(I, { get children() {
|
|
69
69
|
return [() => M()?.[1]?.el ? (() => {
|
|
@@ -74,12 +74,12 @@ const EditablePlugin = {
|
|
|
74
74
|
var e = memo(() => !!A());
|
|
75
75
|
return () => e() && _tmpl$2();
|
|
76
76
|
})(), null), e;
|
|
77
|
-
})() :
|
|
77
|
+
})() : g.children, () => k() && (() => {
|
|
78
78
|
var e = _tmpl$3();
|
|
79
79
|
return e.addEventListener("compositionend", () => {
|
|
80
80
|
w(!0);
|
|
81
81
|
}), e.$$input = (e) => {
|
|
82
|
-
|
|
82
|
+
m = e.target.value, w(!e.isComposing);
|
|
83
83
|
}, e.$$keydown = (e) => {
|
|
84
84
|
e.key == " " && e.preventDefault();
|
|
85
85
|
}, use((e) => {
|
|
@@ -87,34 +87,34 @@ const EditablePlugin = {
|
|
|
87
87
|
}, e), e;
|
|
88
88
|
})()];
|
|
89
89
|
} }));
|
|
90
|
-
}) : createComponent(e,
|
|
90
|
+
}) : createComponent(e, g));
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
-
var createEditor = (e,
|
|
95
|
-
let [
|
|
94
|
+
var createEditor = (e, m, g) => ({ eventKey: _, value: v, col: y, ok: x, cancel: S, props: C, onChange: w }) => createRoot((S) => {
|
|
95
|
+
let T = m?.out ?? ((e) => e), [E, D] = createSignal(_ || v), O;
|
|
96
96
|
return createComponent(e, mergeProps$2({
|
|
97
|
-
ref: (e) =>
|
|
97
|
+
ref: (e) => O = e,
|
|
98
98
|
class: "relative block px-2 size-full z-9 box-border resize-none outline-0",
|
|
99
99
|
get value() {
|
|
100
|
-
return
|
|
100
|
+
return E();
|
|
101
101
|
},
|
|
102
|
-
onInput: (e) => (
|
|
103
|
-
onChange: (e) => (
|
|
102
|
+
onInput: (e) => (D(T(e instanceof Event ? e.target.value : e)), w?.(E())),
|
|
103
|
+
onChange: (e) => (D(T(e instanceof Event ? e.target.value : e)), w?.(E()), g && x()),
|
|
104
104
|
get options() {
|
|
105
|
-
return memo(() => !!
|
|
105
|
+
return memo(() => !!y.enum)() ? resolveOptions(y.enum ?? []) : void 0;
|
|
106
106
|
}
|
|
107
|
-
},
|
|
108
|
-
|
|
107
|
+
}, m, C)), setTimeout(() => {
|
|
108
|
+
g && O?.showPicker?.();
|
|
109
109
|
}, 0), {
|
|
110
|
-
el:
|
|
111
|
-
getValue:
|
|
112
|
-
focus: () =>
|
|
113
|
-
destroy:
|
|
110
|
+
el: O,
|
|
111
|
+
getValue: E,
|
|
112
|
+
focus: () => O.focus(),
|
|
113
|
+
destroy: S
|
|
114
114
|
};
|
|
115
115
|
}), Input = (e) => (() => {
|
|
116
|
-
var
|
|
117
|
-
return spread(
|
|
116
|
+
var p = _tmpl$4();
|
|
117
|
+
return spread(p, e, !1, !1), p;
|
|
118
118
|
})();
|
|
119
119
|
const editors = {
|
|
120
120
|
text: createEditor(Input),
|
|
@@ -124,39 +124,45 @@ const editors = {
|
|
|
124
124
|
} }, e, { get class() {
|
|
125
125
|
return `${e.class} bg-[--table-bg] outline-1.5px outline-solid outline-[--c-primary]`;
|
|
126
126
|
} }))),
|
|
127
|
-
number: createEditor(Input, {
|
|
128
|
-
|
|
127
|
+
number: createEditor(Input, {
|
|
128
|
+
type: "number",
|
|
129
|
+
out: (e) => Number(e)
|
|
130
|
+
}),
|
|
131
|
+
range: createEditor(Input, {
|
|
132
|
+
type: "range",
|
|
133
|
+
out: (e) => Number(e)
|
|
134
|
+
}),
|
|
129
135
|
date: createEditor(Input, { type: "date" }, !0),
|
|
130
136
|
time: createEditor(Input, { type: "time" }, !0),
|
|
131
137
|
datetime: createEditor(Input, { type: "datetime-local" }, !0),
|
|
132
138
|
color: createEditor(Input, { type: "color" }),
|
|
133
139
|
tel: createEditor(Input, { type: "tel" }),
|
|
134
140
|
password: createEditor(Input, { type: "password" }),
|
|
135
|
-
file: createEditor((
|
|
141
|
+
file: createEditor((p) => createComponent(Files, mergeProps$2(p, {
|
|
136
142
|
class: "relative z-9 outline-2 outline-blue min-h-a! h-a! p-1 bg-#fff",
|
|
137
|
-
onAdd: () => chooseFile({ multiple: !0 }).then((e) =>
|
|
143
|
+
onAdd: () => chooseFile({ multiple: !0 }).then((e) => p.onChange([...p.value || [], ...e.map((e) => ({
|
|
138
144
|
name: e.name,
|
|
139
145
|
size: e.size
|
|
140
146
|
}))]))
|
|
141
147
|
}))),
|
|
142
148
|
checkbox: createEditor((e) => (() => {
|
|
143
|
-
var
|
|
144
|
-
return typeof
|
|
149
|
+
var p = _tmpl$5(), m = e.ref;
|
|
150
|
+
return typeof m == "function" ? use(m, p) : e.ref = p, insert(p, createComponent(Checkbox, mergeProps$2(e, {
|
|
145
151
|
ref: () => {},
|
|
146
152
|
onInput: () => {},
|
|
147
153
|
class: "mx-3!"
|
|
148
|
-
}))),
|
|
154
|
+
}))), p;
|
|
149
155
|
})()),
|
|
150
156
|
select: createEditor((e) => (() => {
|
|
151
|
-
var
|
|
152
|
-
return spread(
|
|
153
|
-
var
|
|
154
|
-
return () =>
|
|
155
|
-
})(), null), insert(
|
|
156
|
-
var
|
|
157
|
-
return insert(
|
|
158
|
-
})()), null), effect(() =>
|
|
157
|
+
var p = _tmpl$6();
|
|
158
|
+
return spread(p, e, !1, !0), insert(p, (() => {
|
|
159
|
+
var p = memo(() => !e.multiple);
|
|
160
|
+
return () => p() && _tmpl$7();
|
|
161
|
+
})(), null), insert(p, () => e.options?.map((e) => (() => {
|
|
162
|
+
var p = _tmpl$8();
|
|
163
|
+
return insert(p, () => e.label), effect(() => p.value = e.value), p;
|
|
164
|
+
})()), null), effect(() => p.value = e.value), p;
|
|
159
165
|
})(), {}, !0)
|
|
160
166
|
};
|
|
161
|
-
delegateEvents(["keydown", "input"]);
|
|
167
|
+
editors.boolean = editors.checkbox, delegateEvents(["keydown", "input"]);
|
|
162
168
|
export { EditablePlugin, editors };
|
|
@@ -4,7 +4,7 @@ import chevron_right_default from "../chevron-right.js";
|
|
|
4
4
|
import { createComponent, effect, insert, memo, mergeProps, setAttribute, template } from "solid-js/web";
|
|
5
5
|
import { mergeProps as mergeProps$1 } from "solid-js";
|
|
6
6
|
import { combineProps } from "@solid-primitives/props";
|
|
7
|
-
var _tmpl$ = /* @__PURE__ */ template("<td style=width:
|
|
7
|
+
var _tmpl$ = /* @__PURE__ */ template("<td style=width:fit-content>"), _tmpl$2 = /* @__PURE__ */ template("<div style=display:flex;align-items:center;width:100%;height:100%;opacity:.4>");
|
|
8
8
|
const ExpandPlugin = {
|
|
9
9
|
name: "expand",
|
|
10
10
|
store: (e) => ({ expandCol: {
|
|
@@ -21,7 +21,8 @@ const ExpandPlugin = {
|
|
|
21
21
|
} }),
|
|
22
22
|
commands: (e) => ({ expand: useSelector({
|
|
23
23
|
multiple: !0,
|
|
24
|
-
key: e.props.rowKey
|
|
24
|
+
key: e.props.rowKey,
|
|
25
|
+
initialValue: []
|
|
25
26
|
}) }),
|
|
26
27
|
rewriteProps: {
|
|
27
28
|
expand: ({ expand: e }) => mergeProps$1({ enable: !1 }, e),
|
|
@@ -13,7 +13,10 @@ const ImportExportPlugin = {
|
|
|
13
13
|
name: "ImportExportPlugin",
|
|
14
14
|
commands: (r) => ({
|
|
15
15
|
createExcel: async (e = r.props.data) => {
|
|
16
|
-
let t = await import(
|
|
16
|
+
let t = await import(
|
|
17
|
+
/* @vite-ignore */
|
|
18
|
+
"xlsx"
|
|
19
|
+
), n = r.props.columns.filter((e) => !e[r.internal]), i = e.map((e) => Object.fromEntries(n.map((t) => [t.name, e[t.id]]))), a = t.utils.json_to_sheet(i), o = t.utils.book_new();
|
|
17
20
|
t.utils.book_append_sheet(o, a, "Data");
|
|
18
21
|
let s = t.write(o, {
|
|
19
22
|
bookType: "xlsx",
|
|
@@ -27,7 +30,10 @@ const ImportExportPlugin = {
|
|
|
27
30
|
},
|
|
28
31
|
readExcel: async (n) => {
|
|
29
32
|
n ??= await chooseFile({ accept: ".xlsx,.xls,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel" });
|
|
30
|
-
let i = await readFileAsArrayBuffer(n), a = await import(
|
|
33
|
+
let i = await readFileAsArrayBuffer(n), a = await import(
|
|
34
|
+
/* @vite-ignore */
|
|
35
|
+
"xlsx"
|
|
36
|
+
), o = a.read(i, { type: "array" }), s = o.Sheets[o.SheetNames[0]], c = a.utils.sheet_to_json(s);
|
|
31
37
|
if (c.length < 1) return [];
|
|
32
38
|
let l = r.props.columns.filter((e) => !e[r.internal]);
|
|
33
39
|
return c.slice(1).map((e) => Object.fromEntries(l.map((t) => [t.id, e[t.name]])));
|
|
@@ -2,5 +2,9 @@ export declare const Checkbox: import("solid-js").Component<Record<string, any>>
|
|
|
2
2
|
export declare const Files: import("solid-js").Component<Record<string, any>>;
|
|
3
3
|
export declare const Tags: import("solid-js").Component<Record<string, any>>;
|
|
4
4
|
export declare const Tag: import("solid-js").Component<Record<string, any>>;
|
|
5
|
+
/** Star rating component. max defaults to 5. */
|
|
6
|
+
export declare const Rate: import("solid-js").Component<Record<string, any>>;
|
|
7
|
+
/** Progress bar component. value is 0–100 or 0–1. */
|
|
8
|
+
export declare const Progress: import("solid-js").Component<Record<string, any>>;
|
|
5
9
|
export declare const evaluateFormula: (formula: string, data: any) => any;
|
|
6
10
|
export declare const text2colorMap: Record<string, string>;
|