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.
Files changed (41) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +378 -378
  3. package/dist/__uno.css +1 -1
  4. package/dist/components/AndOrFields.d.ts +1 -1
  5. package/dist/components/AndOrFields.js +193 -74
  6. package/dist/components/Filter.d.ts +0 -1
  7. package/dist/hooks/useVirtualizer.d.ts +3 -0
  8. package/dist/hooks/useVirtualizer.js +12 -2
  9. package/dist/index.d.ts +3 -3
  10. package/dist/index.js +17 -11
  11. package/dist/loading-bold.js +6 -0
  12. package/dist/plugins/CellMergePlugin.js +15 -16
  13. package/dist/plugins/CellSelectionPlugin.js +97 -69
  14. package/dist/plugins/CommandPlugin.js +3 -1
  15. package/dist/plugins/CopyPastePlugin.js +1 -1
  16. package/dist/plugins/DiffPlugin.d.ts +0 -1
  17. package/dist/plugins/DiffPlugin.js +2 -2
  18. package/dist/plugins/EditablePlugin.js +74 -74
  19. package/dist/plugins/ExpandPlugin.js +0 -1
  20. package/dist/plugins/FilterPlugin.js +95 -53
  21. package/dist/plugins/ImportExportPlugin.d.ts +9 -0
  22. package/dist/plugins/ImportExportPlugin.js +37 -0
  23. package/dist/plugins/LoadMorePlugin.js +1 -1
  24. package/dist/plugins/MenuPlugin.d.ts +1 -0
  25. package/dist/plugins/MenuPlugin.js +7 -0
  26. package/dist/plugins/RenderPlugin/index.d.ts +3 -3
  27. package/dist/plugins/RenderPlugin/index.js +12 -12
  28. package/dist/plugins/ResizePlugin.js +45 -36
  29. package/dist/plugins/RowGroupPlugin.js +1 -1
  30. package/dist/plugins/TreePlugin.js +25 -23
  31. package/dist/plugins/ValidatorPlugin.js +14 -12
  32. package/dist/plugins/VirtualScrollPlugin.js +16 -2
  33. package/dist/style.css +2 -2
  34. package/dist/theme/antd.scss +41 -41
  35. package/dist/theme/dark.scss +46 -46
  36. package/dist/theme/element-plus.scss +38 -38
  37. package/dist/theme/github.scss +80 -80
  38. package/dist/theme/material.scss +73 -73
  39. package/dist/theme/shadcn.scss +66 -66
  40. package/dist/theme/stripe.scss +57 -57
  41. 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: r }) => (a) => (r._mergeMap ??= createMemo(() => {
31
- let { merge: e, data: t, columns: n } = r.props;
32
- return !e && !n?.some((e) => e.mergeRow) || !t?.length || !n?.length ? {
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, n, e);
34
+ } : buildMergeMap(t, r, e);
36
35
  }), createComponent(t, a)),
37
- Td: ({ Td: n }, { store: i }) => (a) => {
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 a = combineProps(a, {
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(n, a);
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
- var _tmpl$ = /* @__PURE__ */ template("<div class=area>"), inrange = (e, i, a) => e <= a && e >= i;
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: i, end: a } = e.selected, o = [i[0], a[0]].sort((e, i) => e - i), s = [i[1], a[1]].sort((e, i) => e - i);
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: o,
17
- ys: s
18
+ xs: s,
19
+ ys: c
18
20
  };
19
- }
21
+ })
20
22
  }),
21
23
  commands: (e) => ({ getAreaRows() {
22
- let { start: i, end: a } = e.selected, [o, s] = [i[1], a[1]].sort((e, i) => e - i);
23
- return e.props.data.slice(o, s + 1);
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: o }) => (s) => (usePointerDrag(() => o.table, {
28
+ Table: ({ Table: a }, { store: s }) => (c) => (usePointerDrag(() => s.table, {
27
29
  preventDefault: !1,
28
- start(e, i, a) {
30
+ start(e, a, o) {
29
31
  batch(() => {
30
- let a = (e) => e.composedPath().find((e) => e.tagName == "TH" || e.tagName == "TD"), s = (e) => [e.getAttribute("x"), e.getAttribute("y")], c = a(e);
31
- if (c && !(e.buttons != 1 && c.classList.contains("range-selected"))) {
32
- if (c.tagName == "TH") {
33
- let [e, l] = s(c);
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
- o.selected.start = [+e, 0], o.selected.end = [+e, Infinity], i((e) => {
36
- let i = a(e);
37
- if (!i) return;
38
- let [c, l] = s(i);
39
- c != null && (o.selected.end = [+c, Infinity]);
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 (c.classList.contains("index")) {
43
- let [e, l] = s(c);
44
- if (e == null || l == null) return;
45
- o.selected.start = [0, +l], o.selected.end = [Infinity, +l], i((e) => {
46
- let i = a(e);
47
- if (!i) return;
48
- let [c, l] = s(i);
49
- c == null || l == null || (o.selected.end = [Infinity, +l]);
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 (c.tagName == "TD") {
52
- let [e, l] = s(c);
53
- if (e == null || l == null) return;
54
- o.selected.start = [+e, +l], o.selected.end = [...o.selected.start], i((e) => {
55
- let i = a(e);
56
- if (!i) return;
57
- let [c, l] = s(i);
58
- c == null || l == null || (o.selected.end = [+c, +l]);
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
- }), s = combineProps({ class: "select-none" }, s), createComponent(a, s)),
65
- Th: ({ Th: e }, { store: s }) => (c) => {
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: i } = s.selected;
68
- return inrange(c.x, ...[e[0], i[0]].sort((e, i) => e - i)) ? "col-range-highlight" : "";
69
- }), d = combineProps(c, { get class() {
70
- return u();
71
- } });
72
- return createComponent(e, mergeProps(d, { get children() {
73
- return [memo(() => d.children), memo(() => memo(() => !!u())() && _tmpl$())];
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: s }) => (c) => {
81
+ Td: ({ Td: e }, { store: a }) => (l) => {
77
82
  let u = createMemo(() => {
78
- let e = "", { xs: i, ys: a } = s.cellSelectionRect(), o = inrange(c.x, i[0], i[1]), l = inrange(c.y, a[0], a[1]);
79
- return o && l && (e += "range-selected ", c.x == i[0] && (e += "range-selected-l "), c.x == i[1] && (e += "range-selected-r "), c.y == a[0] && (e += "range-selected-t "), c.y == a[1] && (e += "range-selected-b ")), c.col.id == s.$index?.id && l && (e += "row-range-highlight "), e;
80
- }), d = combineProps(c, {
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
- return createComponent(e, mergeProps(d, { get children() {
87
- return [memo(() => d.children), memo(() => memo(() => !!u())() && _tmpl$())];
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: i, end: a } = e.selected;
94
- i.length && (i[0] = a[0] = Math.max(i[0] - 1, 0), a[1] = i[1], e.scrollCellIfNeeded(i[0], i[1]));
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: i, end: a } = e.selected;
98
- i.length && (i[0] = a[0] = Math.min(i[0] + 1, e.props.columns.length - 1), a[1] = i[1], e.scrollCellIfNeeded(i[0], i[1]));
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: i, end: a } = e.selected;
102
- i.length && (i[1] = a[1] = Math.max(i[1] - 1, 0), a[0] = i[0], e.scrollCellIfNeeded(i[0], i[1]));
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: i, end: a } = e.selected;
106
- i.length && (i[1] = a[1] = Math.min(i[1] + 1, e.props.data.length - 1), a[0] = i[0], e.scrollCellIfNeeded(i[0], i[1]));
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: i, data: a } = e.props;
110
- !i?.length || !a?.length || (e.selected.start = [0, 0], e.selected.end = [i.length - 1, a.length - 1], e.scrollCellIfNeeded(e.selected.start[0], e.selected.start[1]));
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 && (o.scrollIntoViewIfNeeded(a), o.focus());
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.props.onDataChange?.(y);
69
+ t.selected.end = [S, x], t.commands.rowsChange?.(y);
70
70
  }
71
71
  })
72
72
  };
@@ -3,7 +3,6 @@ declare module '../index' {
3
3
  interface TableProps {
4
4
  diff?: {
5
5
  /** @default false */
6
- enable?: boolean;
7
6
  data?: any[];
8
7
  /** @default true */
9
8
  added?: boolean;
@@ -33,7 +33,7 @@ const DiffPlugin = {
33
33
  ...e
34
34
  }),
35
35
  data: ({ data: e }, { store: o }) => {
36
- if (!o.props.diff?.enable) return e;
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?.enable ? (p) => {
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("<input style=position:absolute;margin-top:1em;width:0;height:0;pointer-events:none;opacity:0>"), _tmpl$2 = /* @__PURE__ */ template("<div class=in-cell-edit-wrapper>"), _tmpl$3 = /* @__PURE__ */ template("<span class=cell-validating>"), _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>");
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: h }) => (_) => {
16
- let v = [_.col.editable, e].filter((e) => e != null);
17
- return !!v.length && v.every((e) => unFn(e, _)) && !_.data[h.internal] && !_.col[h.internal];
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: h }) => (_) => {
20
- let v, { props: x } = useContext(Ctx), S = createMemo(() => unFn(x.editable, _)), [w, T] = createSignal(!1), A = "", j = createMemo(() => (([e, h]) => _.x == e && _.y == h)(h.selected.start || [])), M = createMemo(() => j() && S() && !w()), [N, P] = createSignal(!1), F = createAsyncMemo(() => {
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, g = _.data[_.col.id], v = ((e) => typeof e == "string" ? h.editors[e] : e)(_.col.editor ?? _.col.type ?? "text"), y = {
23
- props: _.col.editorProps,
24
- col: _.col,
25
- eventKey: A,
26
- data: _.data,
27
- value: g,
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 I(b.getValue()), T(!1);
29
+ await L(S.getValue()), E(!1);
30
30
  },
31
- cancel: () => (e = !0, T(!1)),
32
- onChange: (e) => w() && I(e).catch(() => {})
33
- }, b = v(y);
31
+ cancel: () => (e = !0, E(!1)),
32
+ onChange: (e) => w() && L(e).catch(() => {})
33
+ }, S = b(x);
34
34
  return onCleanup(() => {
35
- !e && b.getValue() !== g && h.commands.rowChange({
36
- ...x.data[_.y],
37
- [_.col.id]: b.getValue()
38
- }), e || I(b.getValue()).catch(() => {}), A = "", b.destroy();
39
- }), [y, b];
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 I(e) {
42
+ async function L(e) {
43
43
  try {
44
- P(!0), await h.validateCell(e, _.data, _.col);
44
+ F(!0), await _.validateCell(e, y.data, y.col);
45
45
  } finally {
46
- P(!1);
46
+ F(!1);
47
47
  }
48
48
  }
49
49
  createEffect(() => {
50
- F()?.[1]?.focus?.();
50
+ I()?.[1]?.focus?.();
51
51
  }), createEffect(() => {
52
52
  if (w()) {
53
- let e = createMemo(() => JSON.stringify(h.selected));
54
- createEffect(on(e, () => T(!1), { defer: !0 }));
53
+ let e = createMemo(() => JSON.stringify(_.selected ?? "{}"));
54
+ createEffect(on(e, () => E(!1), { defer: !0 }));
55
55
  }
56
56
  });
57
- let L, R = createMutable({
57
+ let R, z = createMutable({
58
58
  w: 0,
59
59
  h: 0
60
60
  });
61
- return createComputed(() => w() && (R.w = v.getBoundingClientRect().width, R.h = v.getBoundingClientRect().height)), _ = combineProps(_, {
62
- ref: (e) => v = 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: ${R.w}px; height: ${R.h}px; padding: 0; ` : "";
67
+ return w() ? `width: ${z.w}px; height: ${z.h}px; padding: 0; ` : "";
68
68
  },
69
- onClick: () => L?.focus?.(),
70
- onDblClick: () => T(S()),
71
- onKeyDown: (e) => e.key == "Escape" && F()?.[0].cancel()
72
- }), createComponent(e, mergeProps(_, { get children() {
73
- return [memo(() => memo(() => !!M())() && (() => {
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
- T(!0);
82
+ E(!0);
77
83
  }), e.$$input = (e) => {
78
- A = e.target.value, T(!e.isComposing);
84
+ D = e.target.value, E(!e.isComposing);
79
85
  }, e.$$keydown = (e) => {
80
86
  e.key == " " && e.preventDefault();
81
87
  }, use((e) => {
82
- L = e, delay(0).then(() => e.focus({ preventScroll: !0 }));
88
+ R = e, delay(0).then(() => e.focus({ preventScroll: !0 }));
83
89
  }, e), e;
84
- })()), memo(() => memo(() => !!F()?.[1]?.el)() ? (() => {
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, g, _) => ({ eventKey: v, value: y, col: x, ok: S, cancel: C, props: w, onChange: T }) => createRoot((E) => {
96
- let [D, O] = createSignal(v || y), k;
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) => k = 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 D();
101
+ return O();
102
102
  },
103
- onInput: (e) => (O(e instanceof Event ? e.target.value : e), T?.(D())),
104
- onChange: (e) => (O(e instanceof Event ? e.target.value : e), T?.(D()), _ && S()),
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 && S(), e.key == "Escape" && C();
107
+ e.stopPropagation(), e.key == "Enter" && !e.shiftKey && C(), e.key == "Escape" && w();
108
108
  },
109
109
  get options() {
110
- return memo(() => !!x.enum)() ? resolveOptions(x.enum ?? []) : void 0;
110
+ return memo(() => !!S.enum)() ? resolveOptions(S.enum ?? []) : void 0;
111
111
  }
112
- }, g, w)), {
113
- el: k,
114
- getValue: D,
115
- focus: () => k.focus(),
116
- destroy: E
112
+ }, v, T)), {
113
+ el: A,
114
+ getValue: O,
115
+ focus: () => A.focus(),
116
+ destroy: D
117
117
  };
118
118
  }), Input = (e) => (() => {
119
- var h = _tmpl$4();
120
- return spread(h, e, !1, !1), h;
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 h = _tmpl$5();
126
- return spread(h, e, !1, !1), h;
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((h) => createComponent(Files, mergeProps(h, {
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) => h.onChange([...h.value || [], ...e.map((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 h = _tmpl$6(), g = e.ref;
145
- return typeof g == "function" ? use(g, h) : e.ref = h, insert(h, createComponent(Checkbox, mergeProps(e, {
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
- }))), h;
149
+ }))), _;
150
150
  })()),
151
151
  select: createEditor((e) => (() => {
152
- var h = _tmpl$7();
153
- return spread(h, e, !1, !0), insert(h, () => e.options?.map((e) => (() => {
154
- var h = _tmpl$8();
155
- return insert(h, () => e.label), effect(() => h.value = e.value), h;
156
- })())), h;
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"]);
@@ -17,7 +17,6 @@ const ExpandPlugin = {
17
17
  return m.data;
18
18
  }
19
19
  })),
20
- props: (m) => ({ onClick: () => e.commands.expand.toggle(m.data) }),
21
20
  [e.internal]: 1
22
21
  } }),
23
22
  commands: (e) => ({ expand: useSelector({ multiple: !0 }) }),