intable 0.0.2 → 0.0.4

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 (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -1
  3. package/dist/__uno.css +1 -1
  4. package/dist/chevron-right.js +3 -5
  5. package/dist/components/Columns.js +50 -84
  6. package/dist/components/DocTree.js +21 -29
  7. package/dist/components/Menu.js +81 -105
  8. package/dist/components/Popover.js +23 -31
  9. package/dist/components/Render.js +10 -11
  10. package/dist/components/Split.js +34 -46
  11. package/dist/components/Tree.js +38 -57
  12. package/dist/components/utils.js +4 -6
  13. package/dist/hooks/index.d.ts +3 -2
  14. package/dist/hooks/index.js +93 -128
  15. package/dist/hooks/useDir.js +22 -39
  16. package/dist/hooks/useSort.d.ts +18 -0
  17. package/dist/hooks/useSort.js +83 -0
  18. package/dist/hooks/useVirtualizer.js +43 -68
  19. package/dist/index.d.ts +8 -2
  20. package/dist/index.js +175 -213
  21. package/dist/loading.js +3 -5
  22. package/dist/plugins/CellMergePlugin.d.ts +12 -0
  23. package/dist/plugins/CellMergePlugin.js +2 -0
  24. package/dist/plugins/CellSelectionPlugin.js +89 -125
  25. package/dist/plugins/CommandPlugin.js +3 -6
  26. package/dist/plugins/CopyPastePlugin.js +24 -37
  27. package/dist/plugins/DiffPlugin.js +33 -45
  28. package/dist/plugins/DragPlugin.d.ts +14 -0
  29. package/dist/plugins/DragPlugin.js +47 -0
  30. package/dist/plugins/EditablePlugin.js +88 -139
  31. package/dist/plugins/ExpandPlugin.js +26 -30
  32. package/dist/plugins/HistoryPlugin.js +16 -21
  33. package/dist/plugins/MenuPlugin.js +51 -76
  34. package/dist/plugins/RenderPlugin/components.js +45 -63
  35. package/dist/plugins/RenderPlugin/index.js +29 -42
  36. package/dist/plugins/ResizePlugin.d.ts +2 -2
  37. package/dist/plugins/ResizePlugin.js +71 -94
  38. package/dist/plugins/RowGroupPlugin.js +57 -73
  39. package/dist/plugins/RowSelectionPlugin.js +31 -42
  40. package/dist/plugins/VirtualScrollPlugin.js +54 -79
  41. package/dist/plus.js +3 -5
  42. package/dist/style.css +2 -184
  43. package/dist/utils.d.ts +1 -0
  44. package/dist/utils.js +46 -64
  45. package/dist/wc.js +11 -11
  46. package/dist/x.js +3 -5
  47. package/package.json +3 -2
  48. package/dist/plugins/DragColumnPlugin.d.ts +0 -2
  49. package/dist/plugins/DragColumnPlugin.js +0 -4
package/dist/index.js CHANGED
@@ -11,107 +11,108 @@ import { MenuPlugin } from "./plugins/MenuPlugin.js";
11
11
  import { CommandPlugin } from "./plugins/CommandPlugin.js";
12
12
  import { RowSelectionPlugin } from "./plugins/RowSelectionPlugin.js";
13
13
  import { ResizePlugin } from "./plugins/ResizePlugin.js";
14
- import { createComponent, insert, mergeProps, spread, template, use } from "solid-js/web";
15
- import { For, createComputed, createContext, createEffect, createMemo, createSignal, getOwner, mapArray, mergeProps as mergeProps$1, on, onCleanup, runWithOwner, useContext } from "solid-js";
14
+ import { DragPlugin } from "./plugins/DragPlugin.js";
15
+ import { createComponent, insert, memo, mergeProps, spread, template, use } from "solid-js/web";
16
+ import { For, batch, createComputed, createContext, createEffect, createMemo, createSignal, getOwner, mapArray, mergeProps as mergeProps$1, on, onCleanup, onMount, runWithOwner, untrack, useContext } from "solid-js";
16
17
  import { createMutable, reconcile } from "solid-js/store";
17
18
  import { combineProps } from "@solid-primitives/props";
18
19
  import { difference, mapValues, sumBy } from "es-toolkit";
19
- import { createElementSize } from "@solid-primitives/resize-observer";
20
+ import { createElementSize, createResizeObserver } from "@solid-primitives/resize-observer";
20
21
  import { createScrollPosition } from "@solid-primitives/scroll";
21
- var _tmpl$ = /* @__PURE__ */ template(`<table>`), _tmpl$2 = /* @__PURE__ */ template(`<thead>`), _tmpl$3 = /* @__PURE__ */ template(`<tbody>`), _tmpl$4 = /* @__PURE__ */ template(`<tr>`), _tmpl$5 = /* @__PURE__ */ template(`<th>`), _tmpl$6 = /* @__PURE__ */ template(`<td>`), _tmpl$7 = /* @__PURE__ */ template(`<div><div class=data-table__layers></div><table class=data-table--table>`);
22
- const Ctx = createContext({ props: {} });
23
- const Intable = (props) => {
24
- props = mergeProps$1({ rowKey: "id" }, props);
25
- const plugins = createMemo(() => [
22
+ var _tmpl$ = /* @__PURE__ */ template("<table>"), _tmpl$2 = /* @__PURE__ */ template("<thead>"), _tmpl$3 = /* @__PURE__ */ template("<tbody>"), _tmpl$4 = /* @__PURE__ */ template("<tr>"), _tmpl$5 = /* @__PURE__ */ template("<th>"), _tmpl$6 = /* @__PURE__ */ template("<td>"), _tmpl$7 = /* @__PURE__ */ template("<div><div class=data-table__layers></div><table class=data-table--table>");
23
+ const Ctx = createContext({
24
+ props: {},
25
+ store: {}
26
+ }), Intable = (g) => {
27
+ g = mergeProps$1({ rowKey: "id" }, g);
28
+ let q = createMemo(() => [
26
29
  ...defaultsPlugins,
27
- ...props.plugins || [],
30
+ ...g.plugins || [],
28
31
  RenderPlugin
29
- ].sort((a, b) => (b.priority || 0) - (a.priority || 0)));
30
- const store = createMutable({
32
+ ].sort((g, G) => (G.priority || 0) - (g.priority || 0))), J = createMutable({
31
33
  get rawProps() {
32
- return props;
34
+ return g;
33
35
  },
34
36
  get plugins() {
35
- return plugins();
37
+ return q();
36
38
  }
37
- });
38
- const owner = getOwner();
39
- createComputed((old) => {
40
- const added = difference(plugins(), old);
41
- runWithOwner(owner, () => {
42
- added.forEach((e) => Object.assign(store, e.store?.(store)));
43
- });
44
- return plugins();
39
+ }), Y = getOwner();
40
+ createComputed((g) => {
41
+ let G = difference(q(), g);
42
+ return runWithOwner(Y, () => {
43
+ G.forEach((g) => Object.assign(J, g.store?.(J)));
44
+ }), q();
45
45
  }, []);
46
- const pluginsProps = mapArray(plugins, () => createSignal({}));
47
- createComputed(mapArray(plugins, (e, i) => {
48
- const prev = () => pluginsProps()[i() - 1]?.[0]() || props;
49
- const ret = mergeProps$1(prev, toReactive(mapValues(e.rewriteProps || {}, (v) => useMemo(() => v(prev(), { store })))));
50
- pluginsProps()[i()][1](ret);
46
+ let X = mapArray(q, () => createSignal({}));
47
+ createComputed(mapArray(q, (q, Y) => {
48
+ let Z = () => X()[Y() - 1]?.[0]() || g, Q = mergeProps$1(Z, toReactive(mapValues(q.rewriteProps || {}, (g) => useMemo(() => g(Z(), { store: J })))));
49
+ X()[Y()][1](Q);
51
50
  }));
52
- const mProps = toReactive(() => pluginsProps()[pluginsProps().length - 1][0]());
53
- store.props = mProps;
54
- const ctx = createMutable({ props: mProps });
55
- window.store = store;
56
- window.ctx = ctx;
57
- return createComponent(Ctx.Provider, {
58
- value: ctx,
51
+ let Q = toReactive(() => X()[X().length - 1][0]());
52
+ J.props = Q, onMount(() => {
53
+ createEffect(mapArray(q, (g) => g.onMount?.(J)));
54
+ });
55
+ let $ = createMutable({
56
+ props: Q,
57
+ store: J
58
+ });
59
+ return window.store = J, window.ctx = $, createComponent(Ctx.Provider, {
60
+ value: $,
59
61
  get children() {
60
- return createComponent(ctx.props.Table, { get children() {
62
+ return createComponent($.props.Table, { get children() {
61
63
  return [createComponent(THead, {}), createComponent(TBody, {})];
62
64
  } });
63
65
  }
64
66
  });
65
67
  };
66
68
  var THead = () => {
67
- const { props } = useContext(Ctx);
68
- return createComponent(props.Thead, { get children() {
69
- return createComponent(props.Tr, { get children() {
70
- return createComponent(props.EachCells, {
69
+ let { props: g } = useContext(Ctx);
70
+ return createComponent(g.Thead, { get children() {
71
+ return createComponent(g.Tr, { get children() {
72
+ return createComponent(g.EachCells, {
71
73
  get each() {
72
- return props.columns || [];
74
+ return g.columns || [];
73
75
  },
74
- children: (col, colIndex) => createComponent(props.Th, {
75
- col,
76
+ children: (G, K) => createComponent(g.Th, {
77
+ col: G,
76
78
  get x() {
77
- return colIndex();
79
+ return K();
78
80
  },
79
81
  get children() {
80
- return col.name;
82
+ return G.name;
81
83
  }
82
84
  })
83
85
  });
84
86
  } });
85
87
  } });
86
- };
87
- var TBody = () => {
88
- const { props } = useContext(Ctx);
89
- return createComponent(props.Tbody, { get children() {
90
- return createComponent(props.EachRows, {
88
+ }, TBody = () => {
89
+ let { props: g } = useContext(Ctx);
90
+ return createComponent(g.Tbody, { get children() {
91
+ return createComponent(g.EachRows, {
91
92
  get each() {
92
- return props.data;
93
+ return g.data;
93
94
  },
94
- children: (row, rowIndex) => createComponent(props.Tr, {
95
+ children: (G, K) => createComponent(g.Tr, {
95
96
  get y() {
96
- return rowIndex();
97
+ return K();
97
98
  },
98
- data: row,
99
+ data: G,
99
100
  get children() {
100
- return createComponent(props.EachCells, {
101
+ return createComponent(g.EachCells, {
101
102
  get each() {
102
- return props.columns;
103
+ return g.columns;
103
104
  },
104
- children: (col, colIndex) => createComponent(props.Td, {
105
- col,
105
+ children: (q, J) => createComponent(g.Td, {
106
+ col: q,
106
107
  get x() {
107
- return colIndex();
108
+ return J();
108
109
  },
109
110
  get y() {
110
- return rowIndex();
111
+ return K();
111
112
  },
112
- data: row,
113
+ data: G,
113
114
  get children() {
114
- return row[col.id];
115
+ return G[q.id];
115
116
  }
116
117
  })
117
118
  });
@@ -119,224 +120,184 @@ var TBody = () => {
119
120
  })
120
121
  });
121
122
  } });
122
- };
123
- var src_default = Intable;
123
+ }, src_default = Intable;
124
124
  function BasePlugin() {
125
- const omits = {
125
+ let G = {
126
126
  col: null,
127
127
  data: null
128
- };
129
- const table = (o) => (() => {
130
- var _el$ = _tmpl$();
131
- spread(_el$, o, false, false);
132
- return _el$;
133
- })();
134
- const thead = (o) => (() => {
135
- var _el$2 = _tmpl$2();
136
- spread(_el$2, o, false, false);
137
- return _el$2;
138
- })();
139
- const tbody = (o) => (() => {
140
- var _el$3 = _tmpl$3();
141
- spread(_el$3, o, false, false);
142
- return _el$3;
143
- })();
144
- const tr = (o) => (() => {
145
- var _el$4 = _tmpl$4();
146
- spread(_el$4, mergeProps(o, omits), false, false);
147
- return _el$4;
148
- })();
149
- const th = (o) => (() => {
150
- var _el$5 = _tmpl$5();
151
- spread(_el$5, mergeProps(o, omits), false, false);
152
- return _el$5;
153
- })();
154
- const td = (o) => (() => {
155
- var _el$6 = _tmpl$6();
156
- spread(_el$6, mergeProps(o, omits), false, false);
157
- return _el$6;
128
+ }, K = (g) => (() => {
129
+ var G = _tmpl$();
130
+ return spread(G, g, !1, !1), G;
131
+ })(), q = (g) => (() => {
132
+ var G = _tmpl$2();
133
+ return spread(G, g, !1, !1), G;
134
+ })(), J = (g) => (() => {
135
+ var G = _tmpl$3();
136
+ return spread(G, g, !1, !1), G;
137
+ })(), Y = (g) => (() => {
138
+ var K = _tmpl$4();
139
+ return spread(K, mergeProps(g, G), !1, !1), K;
140
+ })(), X = (g) => (() => {
141
+ var K = _tmpl$5();
142
+ return spread(K, mergeProps(g, G), !1, !1), K;
143
+ })(), Z = (g) => (() => {
144
+ var K = _tmpl$6();
145
+ return spread(K, mergeProps(g, G), !1, !1), K;
158
146
  })();
159
147
  return {
160
148
  priority: Infinity,
161
- store: (store) => ({
149
+ store: (g) => ({
162
150
  ths: [],
163
151
  thSizes: [],
164
152
  trs: [],
165
153
  trSizes: [],
166
- internal: Symbol("internal")
154
+ internal: Symbol("internal"),
155
+ raw: Symbol("raw")
167
156
  }),
168
157
  rewriteProps: {
169
- data: ({ data = [] }) => data,
170
- columns: ({ columns = [] }) => columns,
171
- newRow: ({ newRow = () => ({}) }) => newRow,
172
- Table: ({ Table = table }, { store }) => (o) => {
173
- const [el, setEl] = createSignal();
174
- const { props } = useContext(Ctx);
175
- o = combineProps({
176
- ref: setEl,
158
+ data: ({ data: g = [] }) => g,
159
+ columns: ({ columns: g = [] }) => g,
160
+ newRow: ({ newRow: g = () => ({}) }) => g,
161
+ Table: ({ Table: g = K }, { store: G }) => (G) => {
162
+ let [K, q] = createSignal(), { props: J } = useContext(Ctx);
163
+ return G = combineProps({
164
+ ref: q,
177
165
  get class() {
178
- return `data-table ${props.class} ${props.border && "data-table--border"} data-table--${props.size}`;
166
+ return `data-table ${J.class} ${J.border && "data-table--border"} data-table--${J.size}`;
179
167
  },
180
168
  get style() {
181
- return props.style;
169
+ return J.style;
182
170
  }
183
- }, o);
184
- return createComponent(Table, o);
185
- },
186
- Thead: ({ Thead = thead }, { store }) => (o) => {
187
- o = combineProps({ ref: (el) => store.thead = el }, o);
188
- return createComponent(Thead, o);
189
- },
190
- Tbody: ({ Tbody = tbody }, { store }) => (o) => {
191
- o = combineProps({ ref: (el) => store.tbody = el }, o);
192
- return createComponent(Tbody, o);
171
+ }, G), createComponent(g, G);
193
172
  },
194
- Tr: ({ Tr = tr }, { store }) => (o) => {
195
- const [el, setEl] = createSignal();
196
- o = combineProps({ ref: setEl }, o);
197
- createEffect(() => {
198
- const { y } = o;
199
- store.trs[y] = el();
200
- store.trSizes[y] = createElementSize(el());
201
- onCleanup(() => store.trSizes[y] = store.trs[y] = void 0);
202
- });
203
- return createComponent(Tr, o);
173
+ Thead: ({ Thead: g = q }, { store: G }) => (K) => (K = combineProps({ ref: (g) => G.thead = g }, K), createComponent(g, K)),
174
+ Tbody: ({ Tbody: g = J }, { store: G }) => (K) => (K = combineProps({ ref: (g) => G.tbody = g }, K), createComponent(g, K)),
175
+ Tr: ({ Tr: g = Y }, { store: G }) => (K) => {
176
+ let [q, J] = createSignal();
177
+ return K = combineProps({ ref: J }, K), createEffect(() => {
178
+ let { y: g } = K;
179
+ G.trs[g] = q(), G.trSizes[g] = createElementSize(q()), onCleanup(() => G.trSizes[g] = G.trs[g] = void 0);
180
+ }), createComponent(g, K);
204
181
  },
205
- Th: ({ Th = th }, { store }) => (o) => {
206
- const [el, setEl] = createSignal();
207
- const { props } = useContext(Ctx);
208
- const mProps = combineProps(o, { ref: setEl }, {
182
+ Th: ({ Th: G = X }, { store: K }) => (q) => {
183
+ let [J, Y] = createSignal(), { props: X } = useContext(Ctx), Z = combineProps(q, { ref: Y }, {
209
184
  get class() {
210
- return unFn(props.cellClass, o);
185
+ return unFn(X.cellClass, q);
211
186
  },
212
187
  get style() {
213
- return unFn(props.cellStyle, o);
188
+ return unFn(X.cellStyle, q);
214
189
  }
215
190
  }, {
216
191
  get class() {
217
- return o.col.class;
192
+ return q.col.class;
218
193
  },
219
194
  get style() {
220
- return o.col.style;
195
+ return q.col.style;
221
196
  }
222
197
  }, { get style() {
223
- return o.col.width ? `width: ${o.col.width}px` : "";
198
+ return q.col.width ? `width: ${q.col.width}px` : "";
224
199
  } });
225
- createEffect(() => {
226
- const { x } = o;
227
- store.ths[x] = el();
228
- store.thSizes[x] = createElementSize(el());
229
- onCleanup(() => store.thSizes[x] = store.ths[x] = void 0);
230
- });
231
- return createComponent(Th, mergeProps(mProps, { get children() {
232
- return o.children;
200
+ return createEffect(() => {
201
+ let { x: g } = q;
202
+ K.ths[g] = J(), K.thSizes[g] = createElementSize(J()), onCleanup(() => K.thSizes[g] = K.ths[g] = void 0);
203
+ }), createComponent(G, mergeProps(Z, { get children() {
204
+ return q.children;
233
205
  } }));
234
206
  },
235
- Td: ({ Td = td }, { store }) => (o) => {
236
- const { props } = useContext(Ctx);
237
- const mProps = combineProps(o, {
207
+ Td: ({ Td: G = Z }, { store: K }) => (K) => {
208
+ let { props: q } = useContext(Ctx), J = combineProps(K, {
238
209
  get class() {
239
- return unFn(props.cellClass, o);
210
+ return unFn(q.cellClass, K);
240
211
  },
241
212
  get style() {
242
- return unFn(props.cellStyle, o);
213
+ return unFn(q.cellStyle, K);
243
214
  }
244
215
  }, {
245
216
  get class() {
246
- return o.col.class;
217
+ return K.col.class;
247
218
  },
248
219
  get style() {
249
- return o.col.style;
220
+ return K.col.style;
250
221
  }
251
222
  }, { get style() {
252
- return o.col.width ? `width: ${o.col.width}px` : "";
223
+ return K.col.width ? `width: ${K.col.width}px` : "";
253
224
  } });
254
- return createComponent(Td, mergeProps(mProps, { get children() {
255
- return o.children;
225
+ return createComponent(G, mergeProps(J, { get children() {
226
+ return K.children;
256
227
  } }));
257
228
  },
258
- EachRows: ({ EachRows }) => EachRows || For,
259
- EachCells: ({ EachCells }) => EachCells || For,
260
- renderer: ({ renderer = (a) => a }) => renderer
229
+ EachRows: ({ EachRows: g }) => g || For,
230
+ EachCells: ({ EachCells: g }) => g || For,
231
+ renderer: ({ renderer: g = (g) => g }) => g
261
232
  }
262
233
  };
263
234
  }
264
235
  var IndexPlugin = {
265
- store: (store) => ({ $index: {
236
+ store: (g) => ({ $index: {
266
237
  name: "",
267
238
  id: Symbol("index"),
268
239
  fixed: "left",
269
- [store.internal]: 1,
240
+ [g.internal]: 1,
270
241
  width: 40,
271
242
  style: "text-align: center",
272
243
  class: "index",
273
- render: solidComponent((o) => o.y + 1)
244
+ render: solidComponent((g) => memo(() => g.y + 1))
274
245
  } }),
275
- rewriteProps: { columns: (props, { store }) => store.props?.index ? [store.$index, ...props.columns || []] : props.columns }
276
- };
277
- var StickyHeaderPlugin = { rewriteProps: { Thead: ({ Thead }) => (o) => {
278
- const { props } = useContext(Ctx);
279
- o = combineProps({ get class() {
280
- return props.stickyHeader ? "sticky-header" : "";
281
- } }, o);
282
- return createComponent(Thead, o);
283
- } } };
284
- var FixedColumnPlugin = { rewriteProps: {
285
- columns: ({ columns }) => [
286
- ...columns?.filter((e) => e.fixed == "left") || [],
287
- ...columns?.filter((e) => !e.fixed) || [],
288
- ...columns?.filter((e) => e.fixed == "right") || []
246
+ rewriteProps: { columns: (g, { store: G }) => G.props?.index ? [G.$index, ...g.columns || []] : g.columns }
247
+ }, StickyHeaderPlugin = { rewriteProps: { Thead: ({ Thead: g }) => (G) => {
248
+ let { props: K } = useContext(Ctx);
249
+ return G = combineProps({ get class() {
250
+ return K.stickyHeader ? "sticky-header" : "";
251
+ } }, G), createComponent(g, G);
252
+ } } }, FixedColumnPlugin = { rewriteProps: {
253
+ columns: ({ columns: g }) => [
254
+ ...g?.filter((g) => g.fixed == "left") || [],
255
+ ...g?.filter((g) => !g.fixed) || [],
256
+ ...g?.filter((g) => g.fixed == "right") || []
289
257
  ],
290
- cellClass: ({ cellClass }) => (o) => (unFn(cellClass, o) || "") + (o.col.fixed ? ` fixed-${o.col.fixed}` : ""),
291
- cellStyle: ({ cellStyle }, { store }) => (o) => (unFn(cellStyle, o) || "") + (o.col.fixed ? `; ${o.col.fixed}: ${sumBy(store.thSizes.slice(o.col.fixed == "left" ? 0 : o.x + 1, o.col.fixed == "left" ? o.x : Infinity), (size) => size?.width || 0)}px` : "")
292
- } };
293
- var FitColWidthPlugin = { rewriteProps: {
294
- Table: (prev, { store }) => (o) => {
295
- const size1 = createElementSize(() => store.scroll_el);
296
- createEffect(on(() => [size1.width, prev.columns], async () => {
297
- const w = store.scroll_el.clientWidth;
298
- store._fit_col_width__cols_temp = null;
299
- await Promise.resolve();
300
- const gap = (w - store.table.offsetWidth) / store.props.columns.filter((e) => !e.width).length;
301
- store._fit_col_width__cols_temp = prev.columns.map((e, i) => ({ width: e.width ?? Math.max((store.thSizes[i]?.width || 0) + gap, 80) }));
302
- }));
303
- return createComponent(prev.Table, o);
304
- },
305
- columns: ({ columns }, { store }) => reconcile(columns.map((e, i) => ({
306
- ...e,
307
- ...store._fit_col_width__cols_temp?.[i]
308
- })))(store._fit_col_width__cols ??= [])
309
- } };
258
+ cellClass: ({ cellClass: G }) => (K) => (unFn(G, K) || "") + (K.col.fixed ? ` fixed-${K.col.fixed}` : ""),
259
+ cellStyle: ({ cellStyle: G }, { store: K }) => (q) => (unFn(G, q) || "") + (q.col.fixed ? `; ${q.col.fixed}: ${sumBy(K.thSizes.slice(q.col.fixed == "left" ? 0 : q.x + 1, q.col.fixed == "left" ? q.x : Infinity), (g) => g?.width || 0)}px` : "")
260
+ } }, FitColWidthPlugin = {
261
+ priority: -Infinity,
262
+ rewriteProps: {
263
+ Table: (g, { store: G }) => (K) => {
264
+ let q = createMutable({ width: 0 });
265
+ return createResizeObserver(() => G.scroll_el, (g, G, K) => q.width = K.contentBoxSize[0].inlineSize), createEffect(on(() => [q.width, g.columns.map((g) => g.width)], async () => {
266
+ if (!q.width) return;
267
+ G.__fit_col_width__cols_temp = null, await Promise.resolve();
268
+ let g = (q.width - G.table.getBoundingClientRect().width) / G.props.columns.filter((g) => !g.width).length;
269
+ G.__fit_col_width__cols_temp = G.props.columns.map((K, q) => K.width ? null : { width: Math.max((G.ths[q]?.getBoundingClientRect().width || 0) + g, 80) });
270
+ })), createComponent(g.Table, K);
271
+ },
272
+ columns: ({ columns: g }, { store: G }) => (g = g.map((g, K) => ({
273
+ ...g,
274
+ ...G.__fit_col_width__cols_temp?.[K],
275
+ [G.raw]: g[G.raw] ?? g
276
+ })), untrack(() => batch(() => reconcile(g, { key: G.raw })(G.__fit_col_width__cols ??= []))))
277
+ }
278
+ };
310
279
  const ScrollPlugin = {
311
280
  priority: Infinity,
312
- rewriteProps: { Table: (prev, { store }) => (o) => {
313
- const pos = createScrollPosition(() => store.scroll_el);
314
- const size = createElementSize(() => store.scroll_el);
315
- const clazz = createMemo(() => {
316
- const el = store.scroll_el;
317
- if (!el) return;
318
- const isleft = pos.x == 0;
319
- const isright = pos.x >= el.scrollWidth - (size.width || 0);
320
- return isleft && isright ? "" : !isleft && !isright ? "is-scroll-mid" : isleft ? "is-scroll-left" : isright ? "is-scroll-right" : "";
281
+ rewriteProps: { Table: (g, { store: G }) => (g) => {
282
+ let K = createScrollPosition(() => G.scroll_el), q = createElementSize(() => G.scroll_el), J = createMemo(() => {
283
+ let g = G.scroll_el;
284
+ if (!g) return;
285
+ let J = K.x == 0, Y = K.x >= g.scrollWidth - (q.width || 0);
286
+ return J && Y ? "" : !J && !Y ? "is-scroll-mid" : J ? "is-scroll-left" : Y ? "is-scroll-right" : "";
321
287
  });
322
- o = combineProps(o, {
323
- ref: (el) => store.scroll_el = el,
288
+ g = combineProps(g, {
289
+ ref: (g) => G.scroll_el = g,
324
290
  class: "data-table--scroll-view"
325
291
  }, { get class() {
326
- return clazz();
292
+ return J();
327
293
  } });
328
- const layers = mapArray(() => store.plugins.flatMap((e) => e.layers ?? []), (Layer) => createComponent(Layer, store));
294
+ let Y = mapArray(() => G.plugins.flatMap((g) => g.layers ?? []), (g) => createComponent(g, G));
329
295
  return (() => {
330
- var _el$7 = _tmpl$7(), _el$8 = _el$7.firstChild, _el$9 = _el$8.nextSibling;
331
- spread(_el$7, o, false, true);
332
- insert(_el$8, layers);
333
- use((el) => store.table = el, _el$9);
334
- insert(_el$9, () => o.children);
335
- return _el$7;
296
+ var K = _tmpl$7(), q = K.firstChild, J = q.nextSibling;
297
+ return spread(K, g, !1, !0), insert(q, Y), use((g) => G.table = g, J), insert(J, () => g.children), K;
336
298
  })();
337
299
  } }
338
- };
339
- const defaultsPlugins = [
300
+ }, defaultsPlugins = [
340
301
  ScrollPlugin,
341
302
  BasePlugin(),
342
303
  CommandPlugin,
@@ -347,6 +308,7 @@ const defaultsPlugins = [
347
308
  StickyHeaderPlugin,
348
309
  FixedColumnPlugin,
349
310
  ResizePlugin,
311
+ DragPlugin,
350
312
  ClipboardPlugin,
351
313
  EditablePlugin,
352
314
  FitColWidthPlugin
package/dist/loading.js CHANGED
@@ -1,8 +1,6 @@
1
1
  import { spread, template } from "solid-js/web";
2
- var _tmpl$ = /* @__PURE__ */ template(`<svg width=1.2em height=1.2em xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"><g><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.14></rect><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.29 transform="rotate(30 12 12)"></rect><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.43 transform="rotate(60 12 12)"></rect><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.57 transform="rotate(90 12 12)"></rect><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.71 transform="rotate(120 12 12)"></rect><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.86 transform="rotate(150 12 12)"></rect><rect width=2 height=5 x=11 y=1 fill=currentColor transform="rotate(180 12 12)"></rect><animateTransform attributeName=transform calcMode=discrete dur=0.75s repeatCount=indefinite type=rotate values="0 12 12;30 12 12;60 12 12;90 12 12;120 12 12;150 12 12;180 12 12;210 12 12;240 12 12;270 12 12;300 12 12;330 12 12;360 12 12">`);
3
- var loading_default = (props = {}) => (() => {
4
- var _el$ = _tmpl$();
5
- spread(_el$, props, true, true);
6
- return _el$;
2
+ var _tmpl$ = /* @__PURE__ */ template("<svg width=1.2em height=1.2em xmlns=http://www.w3.org/2000/svg viewBox=\"0 0 24 24\"><g><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.14></rect><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.29 transform=\"rotate(30 12 12)\"></rect><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.43 transform=\"rotate(60 12 12)\"></rect><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.57 transform=\"rotate(90 12 12)\"></rect><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.71 transform=\"rotate(120 12 12)\"></rect><rect width=2 height=5 x=11 y=1 fill=currentColor opacity=.86 transform=\"rotate(150 12 12)\"></rect><rect width=2 height=5 x=11 y=1 fill=currentColor transform=\"rotate(180 12 12)\"></rect><animateTransform attributeName=transform calcMode=discrete dur=0.75s repeatCount=indefinite type=rotate values=\"0 12 12;30 12 12;60 12 12;90 12 12;120 12 12;150 12 12;180 12 12;210 12 12;240 12 12;270 12 12;300 12 12;330 12 12;360 12 12\">"), loading_default = (n = {}) => (() => {
3
+ var r = _tmpl$();
4
+ return spread(r, n, !0, !0), r;
7
5
  })();
8
6
  export { loading_default as default };
@@ -0,0 +1,12 @@
1
+ import { type Plugin } from "../index";
2
+ declare module '../index' {
3
+ interface TableProps {
4
+ }
5
+ interface TableColumn {
6
+ }
7
+ interface TableStore {
8
+ }
9
+ interface Commands {
10
+ }
11
+ }
12
+ export declare const CellMergePlugin: Plugin;
@@ -0,0 +1,2 @@
1
+ const CellMergePlugin = { rewriteProps: {} };
2
+ export { CellMergePlugin };