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/__uno.css +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +97 -87
- package/dist/hooks/useSelector.d.ts +16 -0
- package/dist/hooks/useSelector.js +35 -0
- package/dist/index.d.ts +11 -4
- package/dist/index.js +184 -153
- package/dist/plugins/CellSelectionPlugin.js +2 -1
- package/dist/plugins/CommandPlugin.js +11 -5
- package/dist/plugins/CopyPastePlugin.js +1 -0
- package/dist/plugins/EditablePlugin.js +1 -0
- package/dist/plugins/ExpandPlugin.d.ts +3 -5
- package/dist/plugins/ExpandPlugin.js +40 -42
- package/dist/plugins/MenuPlugin.js +3 -2
- package/dist/plugins/RenderPlugin/index.js +1 -0
- package/dist/plugins/ResizePlugin.js +1 -0
- package/dist/plugins/RowGroupPlugin.js +4 -4
- package/dist/plugins/RowSelectionPlugin.d.ts +3 -15
- package/dist/plugins/RowSelectionPlugin.js +15 -31
- package/dist/style.css +2 -2
- package/dist/theme/element-plus.scss +5 -0
- package/dist/wc.js +6 -9
- package/package.json +1 -1
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 = (
|
|
27
|
-
|
|
28
|
-
let
|
|
28
|
+
}), Intable = (_) => {
|
|
29
|
+
_ = mergeProps$1({ rowKey: "id" }, _);
|
|
30
|
+
let J = createMemo(() => [
|
|
29
31
|
...defaultsPlugins,
|
|
30
|
-
...
|
|
32
|
+
..._.plugins || [],
|
|
31
33
|
RenderPlugin
|
|
32
|
-
].sort((
|
|
34
|
+
].sort((_, K) => (K.priority || 0) - (_.priority || 0))), Y = createMutable({
|
|
33
35
|
get rawProps() {
|
|
34
|
-
return
|
|
36
|
+
return _;
|
|
35
37
|
},
|
|
36
38
|
get plugins() {
|
|
37
|
-
return
|
|
39
|
+
return J();
|
|
38
40
|
}
|
|
39
|
-
}),
|
|
40
|
-
createComputed((
|
|
41
|
-
let
|
|
42
|
-
return runWithOwner(
|
|
43
|
-
|
|
44
|
-
}),
|
|
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
|
|
47
|
-
createComputed(mapArray(
|
|
48
|
-
let
|
|
49
|
-
|
|
50
|
-
}))
|
|
51
|
-
|
|
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:
|
|
57
|
-
store:
|
|
56
|
+
props: Y.props,
|
|
57
|
+
store: Y
|
|
58
58
|
});
|
|
59
|
-
return window.store =
|
|
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:
|
|
70
|
-
return createComponent(
|
|
71
|
-
return createComponent(
|
|
72
|
-
return createComponent(
|
|
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
|
|
74
|
+
return _.columns || [];
|
|
75
75
|
},
|
|
76
|
-
children: (
|
|
77
|
-
col
|
|
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
|
|
84
|
+
return K().name;
|
|
83
85
|
}
|
|
84
86
|
})
|
|
85
87
|
});
|
|
86
88
|
} });
|
|
87
89
|
} });
|
|
88
90
|
}, TBody = () => {
|
|
89
|
-
let { props:
|
|
90
|
-
return createComponent(
|
|
91
|
-
return createComponent(
|
|
91
|
+
let { props: _ } = useContext(Ctx);
|
|
92
|
+
return createComponent(_.Tbody, { get children() {
|
|
93
|
+
return createComponent(_.EachRows, {
|
|
92
94
|
get each() {
|
|
93
|
-
return
|
|
95
|
+
return _.data;
|
|
94
96
|
},
|
|
95
|
-
children: (
|
|
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(
|
|
105
|
+
return createComponent(_.EachCells, {
|
|
102
106
|
get each() {
|
|
103
|
-
return
|
|
107
|
+
return _.columns;
|
|
104
108
|
},
|
|
105
|
-
children: (
|
|
106
|
-
col
|
|
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
|
|
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
|
|
133
|
+
let K = {
|
|
126
134
|
col: null,
|
|
127
135
|
data: null
|
|
128
|
-
},
|
|
129
|
-
var
|
|
130
|
-
return spread(
|
|
131
|
-
})(),
|
|
132
|
-
var
|
|
133
|
-
return spread(
|
|
134
|
-
})(),
|
|
135
|
-
var
|
|
136
|
-
return spread(
|
|
137
|
-
})(),
|
|
138
|
-
var
|
|
139
|
-
return spread(
|
|
140
|
-
})(),
|
|
141
|
-
var
|
|
142
|
-
return spread(
|
|
143
|
-
})(),
|
|
144
|
-
var
|
|
145
|
-
return spread(
|
|
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: (
|
|
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:
|
|
159
|
-
columns: ({ columns:
|
|
160
|
-
newRow: ({ newRow:
|
|
161
|
-
Table: ({ Table:
|
|
162
|
-
let [
|
|
163
|
-
return
|
|
164
|
-
ref:
|
|
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 ${
|
|
175
|
+
return `data-table ${Y.class} ${Y.border && "data-table--border"} data-table--${Y.size}`;
|
|
167
176
|
},
|
|
168
177
|
get style() {
|
|
169
|
-
return
|
|
178
|
+
return Y.style;
|
|
170
179
|
}
|
|
171
|
-
},
|
|
180
|
+
}, K), createComponent(_, K);
|
|
172
181
|
},
|
|
173
|
-
Thead: ({ Thead:
|
|
174
|
-
Tbody: ({ Tbody:
|
|
175
|
-
Tr: ({ Tr:
|
|
176
|
-
let [
|
|
177
|
-
return
|
|
178
|
-
let { y:
|
|
179
|
-
|
|
180
|
-
}), createComponent(
|
|
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:
|
|
183
|
-
let [
|
|
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(
|
|
194
|
+
return unFn(Z.cellClass, J);
|
|
186
195
|
},
|
|
187
196
|
get style() {
|
|
188
|
-
return unFn(
|
|
197
|
+
return unFn(Z.cellStyle, J);
|
|
189
198
|
}
|
|
190
199
|
}, {
|
|
191
200
|
get class() {
|
|
192
|
-
return
|
|
201
|
+
return J.col.class;
|
|
193
202
|
},
|
|
194
203
|
get style() {
|
|
195
|
-
return
|
|
204
|
+
return J.col.style;
|
|
196
205
|
}
|
|
197
206
|
}, { get style() {
|
|
198
|
-
return
|
|
207
|
+
return J.col.width ? `width: ${J.col.width}px` : "";
|
|
199
208
|
} });
|
|
200
209
|
return createEffect(() => {
|
|
201
|
-
let { x:
|
|
202
|
-
|
|
203
|
-
}), createComponent(
|
|
204
|
-
return
|
|
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:
|
|
208
|
-
let { props:
|
|
216
|
+
Td: ({ Td: K = Q }, { store: q }) => (q) => {
|
|
217
|
+
let { props: J } = useContext(Ctx), Y = combineProps(q, {
|
|
209
218
|
get class() {
|
|
210
|
-
return unFn(
|
|
219
|
+
return unFn(J.cellClass, q);
|
|
211
220
|
},
|
|
212
221
|
get style() {
|
|
213
|
-
return unFn(
|
|
222
|
+
return unFn(J.cellStyle, q);
|
|
214
223
|
}
|
|
215
224
|
}, {
|
|
216
225
|
get class() {
|
|
217
|
-
return
|
|
226
|
+
return q.col.class;
|
|
218
227
|
},
|
|
219
228
|
get style() {
|
|
220
|
-
return
|
|
229
|
+
return q.col.style;
|
|
221
230
|
}
|
|
222
231
|
}, { get style() {
|
|
223
|
-
return
|
|
232
|
+
return q.col.width ? `width: ${q.col.width}px` : "";
|
|
224
233
|
} });
|
|
225
|
-
return createComponent(
|
|
226
|
-
return
|
|
234
|
+
return createComponent(K, mergeProps(Y, { get children() {
|
|
235
|
+
return q.children;
|
|
227
236
|
} }));
|
|
228
237
|
},
|
|
229
|
-
EachRows: ({ EachRows:
|
|
230
|
-
|
|
231
|
-
|
|
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
|
-
|
|
255
|
+
name: "index",
|
|
256
|
+
priority: -Infinity,
|
|
257
|
+
store: (_) => ({ $index: {
|
|
237
258
|
name: "",
|
|
238
259
|
id: Symbol("index"),
|
|
239
260
|
fixed: "left",
|
|
240
|
-
[
|
|
261
|
+
[_.internal]: 1,
|
|
241
262
|
width: 40,
|
|
242
263
|
style: "text-align: center",
|
|
243
264
|
class: "index",
|
|
244
|
-
render: solidComponent((
|
|
265
|
+
render: solidComponent((_) => memo(() => _.y + 1))
|
|
245
266
|
} }),
|
|
246
|
-
rewriteProps: { columns: (
|
|
247
|
-
}, StickyHeaderPlugin = {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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: (
|
|
264
|
-
let
|
|
265
|
-
return createResizeObserver(() =>
|
|
266
|
-
if (!
|
|
267
|
-
|
|
268
|
-
let
|
|
269
|
-
|
|
270
|
-
})), createComponent(
|
|
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:
|
|
273
|
-
...
|
|
274
|
-
...
|
|
275
|
-
[
|
|
276
|
-
})), untrack(() => batch(() => reconcile(
|
|
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: (
|
|
282
|
-
let
|
|
283
|
-
let
|
|
284
|
-
if (!
|
|
285
|
-
let
|
|
286
|
-
return
|
|
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
|
-
|
|
289
|
-
ref: (
|
|
317
|
+
_ = combineProps(_, {
|
|
318
|
+
ref: (_) => K.scroll_el = _,
|
|
290
319
|
class: "data-table--scroll-view"
|
|
291
320
|
}, { get class() {
|
|
292
|
-
return
|
|
321
|
+
return Y();
|
|
293
322
|
} });
|
|
294
|
-
let
|
|
323
|
+
let X = mapArray(() => K.plugins.flatMap((_) => _.layers ?? []), (_) => createComponent(_, K));
|
|
295
324
|
return (() => {
|
|
296
|
-
var
|
|
297
|
-
return spread(
|
|
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.
|
|
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 {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
14
|
-
|
|
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;
|