intable 0.0.4 → 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.
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";
@@ -23,40 +25,38 @@ var _tmpl$ = /* @__PURE__ */ template("<table>"), _tmpl$2 = /* @__PURE__ */ temp
23
25
  const Ctx = createContext({
24
26
  props: {},
25
27
  store: {}
26
- }), Intable = (g) => {
27
- g = mergeProps$1({ rowKey: "id" }, g);
28
- let q = createMemo(() => [
28
+ }), Intable = (_) => {
29
+ _ = mergeProps$1({ rowKey: "id" }, _);
30
+ let J = createMemo(() => [
29
31
  ...defaultsPlugins,
30
- ...g.plugins || [],
32
+ ..._.plugins || [],
31
33
  RenderPlugin
32
- ].sort((g, G) => (G.priority || 0) - (g.priority || 0))), J = createMutable({
34
+ ].sort((_, K) => (K.priority || 0) - (_.priority || 0))), Y = createMutable({
33
35
  get rawProps() {
34
- return g;
36
+ return _;
35
37
  },
36
38
  get plugins() {
37
- return q();
39
+ return J();
38
40
  }
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();
41
+ }), X = getOwner();
42
+ createComputed((_) => {
43
+ let K = difference(J(), _);
44
+ return runWithOwner(X, () => {
45
+ K.forEach((_) => Object.assign(Y, _.store?.(Y)));
46
+ }), J();
45
47
  }, []);
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);
50
- }));
51
- let Q = toReactive(() => X()[X().length - 1][0]());
52
- J.props = Q, onMount(() => {
53
- createEffect(mapArray(q, (g) => g.onMount?.(J)));
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)));
54
54
  });
55
55
  let $ = createMutable({
56
- props: Q,
57
- store: J
56
+ props: Y.props,
57
+ store: Y
58
58
  });
59
- return window.store = J, window.ctx = $, createComponent(Ctx.Provider, {
59
+ return window.store = Y, window.ctx = $, createComponent(Ctx.Provider, {
60
60
  value: $,
61
61
  get children() {
62
62
  return createComponent($.props.Table, { get children() {
@@ -66,53 +66,61 @@ const Ctx = createContext({
66
66
  });
67
67
  };
68
68
  var THead = () => {
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, {
69
+ let { props: _ } = useContext(Ctx);
70
+ return createComponent(_.Thead, { get children() {
71
+ return createComponent(_.Tr, { get children() {
72
+ return createComponent(_.EachCells, {
73
73
  get each() {
74
- return g.columns || [];
74
+ return _.columns || [];
75
75
  },
76
- children: (G, K) => createComponent(g.Th, {
77
- col: G,
78
- get x() {
76
+ children: (K, q) => createComponent(_.Th, {
77
+ get col() {
79
78
  return K();
80
79
  },
80
+ get x() {
81
+ return q();
82
+ },
81
83
  get children() {
82
- return G.name;
84
+ return K().name;
83
85
  }
84
86
  })
85
87
  });
86
88
  } });
87
89
  } });
88
90
  }, TBody = () => {
89
- let { props: g } = useContext(Ctx);
90
- return createComponent(g.Tbody, { get children() {
91
- return createComponent(g.EachRows, {
91
+ let { props: _ } = useContext(Ctx);
92
+ return createComponent(_.Tbody, { get children() {
93
+ return createComponent(_.EachRows, {
92
94
  get each() {
93
- return g.data;
95
+ return _.data;
94
96
  },
95
- children: (G, K) => createComponent(g.Tr, {
97
+ children: (K, q) => createComponent(_.Tr, {
96
98
  get y() {
99
+ return q();
100
+ },
101
+ get data() {
97
102
  return K();
98
103
  },
99
- data: G,
100
104
  get children() {
101
- return createComponent(g.EachCells, {
105
+ return createComponent(_.EachCells, {
102
106
  get each() {
103
- return g.columns;
107
+ return _.columns;
104
108
  },
105
- children: (q, J) => createComponent(g.Td, {
106
- col: q,
107
- get x() {
109
+ children: (J, Y) => createComponent(_.Td, {
110
+ get col() {
108
111
  return J();
109
112
  },
113
+ get x() {
114
+ return Y();
115
+ },
110
116
  get y() {
117
+ return q();
118
+ },
119
+ get data() {
111
120
  return K();
112
121
  },
113
- data: G,
114
122
  get children() {
115
- return G[q.id];
123
+ return K()[J().id];
116
124
  }
117
125
  })
118
126
  });
@@ -122,31 +130,32 @@ var THead = () => {
122
130
  } });
123
131
  }, src_default = Intable;
124
132
  function BasePlugin() {
125
- let G = {
133
+ let K = {
126
134
  col: null,
127
135
  data: null
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;
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;
146
154
  })();
147
155
  return {
156
+ name: "base",
148
157
  priority: Infinity,
149
- store: (g) => ({
158
+ store: (_) => ({
150
159
  ths: [],
151
160
  thSizes: [],
152
161
  trs: [],
@@ -155,146 +164,166 @@ function BasePlugin() {
155
164
  raw: Symbol("raw")
156
165
  }),
157
166
  rewriteProps: {
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,
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,
165
174
  get class() {
166
- return `data-table ${J.class} ${J.border && "data-table--border"} data-table--${J.size}`;
175
+ return `data-table ${Y.class} ${Y.border && "data-table--border"} data-table--${Y.size}`;
167
176
  },
168
177
  get style() {
169
- return J.style;
178
+ return Y.style;
170
179
  }
171
- }, G), createComponent(g, G);
180
+ }, K), createComponent(_, K);
172
181
  },
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);
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);
181
190
  },
182
- Th: ({ Th: G = X }, { store: K }) => (q) => {
183
- let [J, Y] = createSignal(), { props: X } = useContext(Ctx), Z = combineProps(q, { ref: Y }, {
191
+ Th: ({ Th: K = Z }, { store: q }) => (J) => {
192
+ let [Y, X] = createSignal(), { props: Z } = useContext(Ctx), Q = combineProps(J, { ref: X }, {
184
193
  get class() {
185
- return unFn(X.cellClass, q);
194
+ return unFn(Z.cellClass, J);
186
195
  },
187
196
  get style() {
188
- return unFn(X.cellStyle, q);
197
+ return unFn(Z.cellStyle, J);
189
198
  }
190
199
  }, {
191
200
  get class() {
192
- return q.col.class;
201
+ return J.col.class;
193
202
  },
194
203
  get style() {
195
- return q.col.style;
204
+ return J.col.style;
196
205
  }
197
206
  }, { get style() {
198
- return q.col.width ? `width: ${q.col.width}px` : "";
207
+ return J.col.width ? `width: ${J.col.width}px` : "";
199
208
  } });
200
209
  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;
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;
205
214
  } }));
206
215
  },
207
- Td: ({ Td: G = Z }, { store: K }) => (K) => {
208
- let { props: q } = useContext(Ctx), J = combineProps(K, {
216
+ Td: ({ Td: K = Q }, { store: q }) => (q) => {
217
+ let { props: J } = useContext(Ctx), Y = combineProps(q, {
209
218
  get class() {
210
- return unFn(q.cellClass, K);
219
+ return unFn(J.cellClass, q);
211
220
  },
212
221
  get style() {
213
- return unFn(q.cellStyle, K);
222
+ return unFn(J.cellStyle, q);
214
223
  }
215
224
  }, {
216
225
  get class() {
217
- return K.col.class;
226
+ return q.col.class;
218
227
  },
219
228
  get style() {
220
- return K.col.style;
229
+ return q.col.style;
221
230
  }
222
231
  }, { get style() {
223
- return K.col.width ? `width: ${K.col.width}px` : "";
232
+ return q.col.width ? `width: ${q.col.width}px` : "";
224
233
  } });
225
- return createComponent(G, mergeProps(J, { get children() {
226
- return K.children;
234
+ return createComponent(K, mergeProps(Y, { get children() {
235
+ return q.children;
227
236
  } }));
228
237
  },
229
- EachRows: ({ EachRows: g }) => g || For,
230
- EachCells: ({ EachCells: g }) => g || For,
231
- renderer: ({ renderer: g = (g) => g }) => g
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: _ = (_) => _ }) => _
232
251
  }
233
252
  };
234
253
  }
235
254
  var IndexPlugin = {
236
- store: (g) => ({ $index: {
255
+ name: "index",
256
+ priority: -Infinity,
257
+ store: (_) => ({ $index: {
237
258
  name: "",
238
259
  id: Symbol("index"),
239
260
  fixed: "left",
240
- [g.internal]: 1,
261
+ [_.internal]: 1,
241
262
  width: 40,
242
263
  style: "text-align: center",
243
264
  class: "index",
244
- render: solidComponent((g) => memo(() => g.y + 1))
265
+ render: solidComponent((_) => memo(() => _.y + 1))
245
266
  } }),
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") || []
257
- ],
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 = {
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",
261
289
  priority: -Infinity,
262
290
  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);
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);
271
299
  },
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 ??= []))))
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 ??= []))))
277
305
  }
278
306
  };
279
307
  const ScrollPlugin = {
308
+ name: "scroll",
280
309
  priority: Infinity,
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" : "";
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" : "";
287
316
  });
288
- g = combineProps(g, {
289
- ref: (g) => G.scroll_el = g,
317
+ _ = combineProps(_, {
318
+ ref: (_) => K.scroll_el = _,
290
319
  class: "data-table--scroll-view"
291
320
  }, { get class() {
292
- return J();
321
+ return Y();
293
322
  } });
294
- let Y = mapArray(() => G.plugins.flatMap((g) => g.layers ?? []), (g) => createComponent(g, G));
323
+ let X = mapArray(() => K.plugins.flatMap((_) => _.layers ?? []), (_) => createComponent(_, K));
295
324
  return (() => {
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;
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;
298
327
  })();
299
328
  } }
300
329
  }, defaultsPlugins = [
@@ -303,14 +332,16 @@ const ScrollPlugin = {
303
332
  CommandPlugin,
304
333
  MenuPlugin,
305
334
  CellSelectionPlugin,
306
- RowSelectionPlugin,
307
- IndexPlugin,
308
335
  StickyHeaderPlugin,
309
336
  FixedColumnPlugin,
310
337
  ResizePlugin,
311
338
  DragPlugin,
312
339
  ClipboardPlugin,
340
+ ExpandPlugin,
341
+ RowSelectionPlugin,
342
+ IndexPlugin,
313
343
  EditablePlugin,
314
- FitColWidthPlugin
344
+ FitColWidthPlugin,
345
+ RowGroupPlugin
315
346
  ];
316
347
  export { Ctx, Intable, ScrollPlugin, src_default as default, defaultsPlugins };
@@ -5,6 +5,7 @@ import { batch, createMemo, useContext } from "solid-js";
5
5
  import { combineProps } from "@solid-primitives/props";
6
6
  var _tmpl$ = /* @__PURE__ */ template("<div class=area>"), inrange = (e, a, o) => e <= o && e >= a;
7
7
  const CellSelectionPlugin = {
8
+ name: "cell-selection",
8
9
  store: () => ({ selected: {
9
10
  start: [],
10
11
  end: []
@@ -98,7 +99,7 @@ const CellSelectionPlugin = {
98
99
  Td: ({ Td: e }, { store: a }) => (o) => {
99
100
  let u = createMemo(() => {
100
101
  let e = "", { xs: s, ys: c } = a.cellSelectionRect(), l = inrange(o.x, s[0], s[1]), u = inrange(o.y, c[0], c[1]);
101
- return l && u && (e += "range-selected ", o.x == s[0] && (e += "range-selected-l "), o.x == s[1] && (e += "range-selected-r "), o.y == c[0] && (e += "range-selected-t "), o.y == c[1] && (e += "range-selected-b ")), o.x == 0 && u && (e += "row-range-highlight "), e;
102
+ return l && u && (e += "range-selected ", o.x == s[0] && (e += "range-selected-l "), o.x == s[1] && (e += "range-selected-r "), o.y == c[0] && (e += "range-selected-t "), o.y == c[1] && (e += "range-selected-b ")), o.col.id == a.$index.id && u && (e += "row-range-highlight "), e;
102
103
  }), d = combineProps(o, {
103
104
  get class() {
104
105
  return u();
@@ -1,6 +1,12 @@
1
- import { createComponent } from "solid-js/web";
2
- import { createComputed } from "solid-js";
3
- const CommandPlugin = { rewriteProps: { Table: ({ Table: n }, { store: r }) => (i) => (createComputed(() => {
4
- r.commands = r.plugins.reduce((e, t) => Object.assign(e, t.commands?.(r, { ...e })), {});
5
- }), createComponent(n, i)) } };
1
+ import { createMemo, getOwner, runWithOwner } from "solid-js";
2
+ const CommandPlugin = {
3
+ name: "command",
4
+ priority: Infinity,
5
+ store: (r) => {
6
+ let i = getOwner(), a = createMemo(() => r.plugins.reduce((e, n) => Object.assign(e, runWithOwner(i, () => n.commands?.(r, { ...e }))), {}));
7
+ return { get commands() {
8
+ return a();
9
+ } };
10
+ }
11
+ };
6
12
  export { CommandPlugin };
@@ -3,6 +3,7 @@ import { createComponent } from "solid-js/web";
3
3
  import { createEffect } from "solid-js";
4
4
  import { combineProps } from "@solid-primitives/props";
5
5
  const ClipboardPlugin = {
6
+ name: "clipboard",
6
7
  rewriteProps: { Table: ({ Table: i }, { store: a }) => (o) => {
7
8
  let s;
8
9
  return useTinykeys(() => s, {
@@ -9,6 +9,7 @@ import { delay } from "es-toolkit";
9
9
  import { createAsyncMemo } from "@solid-primitives/memo";
10
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("<input>"), _tmpl$4 = /* @__PURE__ */ template("<select>"), _tmpl$5 = /* @__PURE__ */ template("<option>"), _tmpl$6 = /* @__PURE__ */ template("<label class=\"h-full flex items-center\">");
11
11
  const EditablePlugin = {
12
+ name: "editable",
12
13
  store: () => ({ editors: { ...editors } }),
13
14
  rewriteProps: { Td: ({ Td: i }, { store: O }) => (k) => {
14
15
  let A, { props: N } = useContext(Ctx), P = createMemo(() => !!k.col.editable && !k.data[O.internal] && !k.col[O.internal]), [I, L] = createSignal(!1), H = "", U = createMemo(() => (([i, O]) => k.x == i && k.y == O)(O.selected.start || [])), W = createMemo(() => U() && P() && !I()), G = createAsyncMemo(async () => {
@@ -1,5 +1,6 @@
1
1
  import type { JSX } from 'solid-js';
2
2
  import { type Plugin } from '..';
3
+ import { useSelector } from '../hooks/useSelector';
3
4
  declare module '../index' {
4
5
  interface TableProps {
5
6
  expand?: {
@@ -10,11 +11,8 @@ declare module '../index' {
10
11
  }) => JSX.Element;
11
12
  };
12
13
  }
13
- interface TableStore {
14
- expands: any[];
15
- expandCol: TableColumn;
16
- isExpand: (data: any) => boolean;
17
- toggleExpand: (data: any) => void;
14
+ interface Commands {
15
+ expand: ReturnType<typeof useSelector<any[]>>;
18
16
  }
19
17
  }
20
18
  export declare const ExpandPlugin: Plugin;