intable 0.0.3 → 0.0.5

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