intable 0.0.23 → 0.0.24
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/LICENSE +21 -21
- package/README.md +378 -378
- package/dist/__uno.css +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +240 -231
- package/dist/plugins/FilterPlugin.d.ts +5 -1
- package/dist/plugins/FilterPlugin.js +58 -73
- package/dist/plugins/LoadMorePlugin.d.ts +24 -0
- package/dist/plugins/LoadMorePlugin.js +62 -0
- package/dist/plugins/VirtualScrollPlugin.js +73 -75
- package/dist/style.css +2 -2
- package/dist/theme/antd.scss +41 -41
- package/dist/theme/dark.scss +46 -46
- package/dist/theme/element-plus.scss +38 -38
- package/dist/theme/github.scss +80 -80
- package/dist/theme/material.scss +73 -73
- package/dist/theme/shadcn.scss +66 -66
- package/dist/theme/stripe.scss +57 -57
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17,120 +17,122 @@ import { CellMergePlugin } from "./plugins/CellMergePlugin.js";
|
|
|
17
17
|
import { TreePlugin } from "./plugins/TreePlugin.js";
|
|
18
18
|
import { HeaderGroupPlugin } from "./plugins/HeaderGroup.js";
|
|
19
19
|
import { ValidatorPlugin } from "./plugins/ValidatorPlugin.js";
|
|
20
|
-
import { createComponent, insert, memo, mergeProps, spread, template
|
|
21
|
-
import { $PROXY, For, batch, createContext, createEffect, createMemo, createSignal, getOwner, mapArray, mergeProps as mergeProps$1, on, onCleanup, onMount, runWithOwner, untrack, useContext } from "solid-js";
|
|
20
|
+
import { createComponent, insert, memo, mergeProps, spread, template } from "solid-js/web";
|
|
21
|
+
import { $PROXY, For, batch, createComputed, createContext, createEffect, createMemo, createSignal, getOwner, mapArray, mergeProps as mergeProps$1, on, onCleanup, onMount, runWithOwner, untrack, useContext } from "solid-js";
|
|
22
22
|
import { createMutable, reconcile } from "solid-js/store";
|
|
23
23
|
import { combineProps } from "@solid-primitives/props";
|
|
24
24
|
import { createLazyMemo } from "@solid-primitives/memo";
|
|
25
25
|
import { createElementSize, createResizeObserver, makeResizeObserver } from "@solid-primitives/resize-observer";
|
|
26
26
|
import { createScrollPosition } from "@solid-primitives/scroll";
|
|
27
27
|
import { difference, isEqual, memoize, sumBy } from "es-toolkit";
|
|
28
|
-
var _tmpl$ = /* @__PURE__ */ template("<
|
|
28
|
+
var _tmpl$ = /* @__PURE__ */ template("<div>"), _tmpl$2 = /* @__PURE__ */ template("<table>"), _tmpl$3 = /* @__PURE__ */ template("<thead>"), _tmpl$4 = /* @__PURE__ */ template("<tbody>"), _tmpl$5 = /* @__PURE__ */ template("<tr>"), _tmpl$6 = /* @__PURE__ */ template("<th>"), _tmpl$7 = /* @__PURE__ */ template("<td>"), _tmpl$8 = /* @__PURE__ */ template("<div class=data-table__layers>"), _tmpl$9 = /* @__PURE__ */ template("<div class=data-table__empty>No data");
|
|
29
29
|
const Ctx = createContext({
|
|
30
30
|
props: {},
|
|
31
31
|
store: {}
|
|
32
|
-
}), Intable = (
|
|
33
|
-
|
|
34
|
-
let
|
|
32
|
+
}), Intable = (K) => {
|
|
33
|
+
K = mergeProps$1({ rowKey: "id" }, K);
|
|
34
|
+
let q = getOwner(), J = createMutable({
|
|
35
35
|
get rawProps() {
|
|
36
|
-
return
|
|
36
|
+
return K;
|
|
37
37
|
},
|
|
38
38
|
get plugins() {
|
|
39
|
-
return
|
|
39
|
+
return X();
|
|
40
40
|
}
|
|
41
|
-
}),
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
let
|
|
53
|
-
function
|
|
54
|
-
return createMemo(() =>
|
|
41
|
+
}), Y = memoize((K) => runWithOwner(q, () => unFn(K, J))), X = createMemo(() => [
|
|
42
|
+
...defaultsPlugins,
|
|
43
|
+
...K.plugins || [],
|
|
44
|
+
RenderPlugin
|
|
45
|
+
].map(Y).sort((_, K) => (K.priority || 0) - (_.priority || 0)));
|
|
46
|
+
createComputed((_) => {
|
|
47
|
+
let K = difference(X(), _);
|
|
48
|
+
return runWithOwner(q, () => {
|
|
49
|
+
K.forEach((_) => Object.assign(J, _.store?.(J)));
|
|
50
|
+
}), X();
|
|
51
|
+
}, []), J.props = (() => {
|
|
52
|
+
let _ = getOwner(), q = {}, Y = (K) => q[K] ??= runWithOwner(_, () => createMemo(() => Z(K)));
|
|
53
|
+
function Z(_) {
|
|
54
|
+
return createMemo(() => X().map((K) => K.rewriteProps?.[_]).filter((_) => _), void 0, { equals: isEqual })().reduce((K, q) => q({ [_]: K }, { store: J }), K[_]);
|
|
55
55
|
}
|
|
56
|
-
return new Proxy({}, { get(
|
|
57
|
-
return
|
|
56
|
+
return new Proxy({}, { get(_, K, q) {
|
|
57
|
+
return K == $PROXY ? q : Y(K)();
|
|
58
58
|
} });
|
|
59
59
|
})(), onMount(() => {
|
|
60
|
-
createEffect(mapArray(
|
|
60
|
+
createEffect(mapArray(X, (_) => _.onMount?.(J)));
|
|
61
61
|
});
|
|
62
|
-
let
|
|
63
|
-
props:
|
|
64
|
-
store:
|
|
62
|
+
let Q = createMutable({
|
|
63
|
+
props: J.props,
|
|
64
|
+
store: J
|
|
65
65
|
});
|
|
66
|
-
return window.store =
|
|
67
|
-
let
|
|
68
|
-
await Promise.resolve(),
|
|
66
|
+
return window.store = J, window.ctx = Q, createEffect(async () => {
|
|
67
|
+
let _ = J.props.store;
|
|
68
|
+
await Promise.resolve(), _ && (typeof _ == "function" ? _(J) : "value" in _ ? _.value = J : "current" in _ && (_.current = J));
|
|
69
69
|
}), createComponent(Ctx.Provider, {
|
|
70
|
-
value:
|
|
70
|
+
value: Q,
|
|
71
71
|
get children() {
|
|
72
|
-
return createComponent(
|
|
73
|
-
return
|
|
72
|
+
return createComponent(Q.props.Scroll, { get children() {
|
|
73
|
+
return createComponent(Q.props.Table, { get children() {
|
|
74
|
+
return [createComponent(THead, {}), createComponent(TBody, {})];
|
|
75
|
+
} });
|
|
74
76
|
} });
|
|
75
77
|
}
|
|
76
78
|
});
|
|
77
79
|
};
|
|
78
80
|
var THead = () => {
|
|
79
|
-
let { props:
|
|
80
|
-
return createComponent(
|
|
81
|
-
return createComponent(
|
|
82
|
-
return createComponent(
|
|
81
|
+
let { props: _, store: K } = useContext(Ctx);
|
|
82
|
+
return createComponent(_.Thead, { get children() {
|
|
83
|
+
return createComponent(_.Tr, { get children() {
|
|
84
|
+
return createComponent(_.EachCells, {
|
|
83
85
|
get each() {
|
|
84
|
-
return
|
|
86
|
+
return _.columns || [];
|
|
85
87
|
},
|
|
86
|
-
children: (
|
|
88
|
+
children: (q, J) => createComponent(_.Th, {
|
|
87
89
|
get col() {
|
|
88
|
-
return
|
|
90
|
+
return q();
|
|
89
91
|
},
|
|
90
92
|
get x() {
|
|
91
|
-
return
|
|
93
|
+
return J();
|
|
92
94
|
},
|
|
93
95
|
get children() {
|
|
94
|
-
return renderComponent(
|
|
96
|
+
return renderComponent(q().name, void 0, K);
|
|
95
97
|
}
|
|
96
98
|
})
|
|
97
99
|
});
|
|
98
100
|
} });
|
|
99
101
|
} });
|
|
100
102
|
}, TBody = () => {
|
|
101
|
-
let { props:
|
|
102
|
-
return createComponent(
|
|
103
|
-
return createComponent(
|
|
103
|
+
let { props: _ } = useContext(Ctx);
|
|
104
|
+
return createComponent(_.Tbody, { get children() {
|
|
105
|
+
return createComponent(_.EachRows, {
|
|
104
106
|
get each() {
|
|
105
|
-
return
|
|
107
|
+
return _.data;
|
|
106
108
|
},
|
|
107
|
-
children: (
|
|
109
|
+
children: (K, q) => createComponent(_.Tr, {
|
|
108
110
|
get y() {
|
|
109
|
-
return
|
|
111
|
+
return q();
|
|
110
112
|
},
|
|
111
113
|
get data() {
|
|
112
|
-
return
|
|
114
|
+
return K();
|
|
113
115
|
},
|
|
114
116
|
get children() {
|
|
115
|
-
return createComponent(
|
|
117
|
+
return createComponent(_.EachCells, {
|
|
116
118
|
get each() {
|
|
117
|
-
return
|
|
119
|
+
return _.columns;
|
|
118
120
|
},
|
|
119
|
-
children: (
|
|
121
|
+
children: (J, Y) => createComponent(_.Td, {
|
|
120
122
|
get col() {
|
|
121
|
-
return
|
|
123
|
+
return J();
|
|
122
124
|
},
|
|
123
125
|
get x() {
|
|
124
|
-
return
|
|
126
|
+
return Y();
|
|
125
127
|
},
|
|
126
128
|
get y() {
|
|
127
|
-
return
|
|
129
|
+
return q();
|
|
128
130
|
},
|
|
129
131
|
get data() {
|
|
130
|
-
return
|
|
132
|
+
return K();
|
|
131
133
|
},
|
|
132
134
|
get children() {
|
|
133
|
-
return
|
|
135
|
+
return K()[J().id];
|
|
134
136
|
}
|
|
135
137
|
})
|
|
136
138
|
});
|
|
@@ -140,56 +142,59 @@ var THead = () => {
|
|
|
140
142
|
} });
|
|
141
143
|
}, src_default = Intable;
|
|
142
144
|
function BasePlugin() {
|
|
143
|
-
let
|
|
145
|
+
let K = {
|
|
144
146
|
col: null,
|
|
145
147
|
data: null
|
|
146
|
-
},
|
|
147
|
-
var
|
|
148
|
-
return spread(
|
|
149
|
-
})(),
|
|
150
|
-
var
|
|
151
|
-
return spread(
|
|
152
|
-
})(),
|
|
153
|
-
var
|
|
154
|
-
return spread(
|
|
155
|
-
})(),
|
|
156
|
-
var
|
|
157
|
-
return spread(
|
|
158
|
-
})(),
|
|
159
|
-
var
|
|
160
|
-
return spread(
|
|
161
|
-
})(),
|
|
162
|
-
var
|
|
163
|
-
return spread(
|
|
148
|
+
}, q = (_) => (() => {
|
|
149
|
+
var K = _tmpl$();
|
|
150
|
+
return spread(K, _, !1, !1), K;
|
|
151
|
+
})(), J = (_) => (() => {
|
|
152
|
+
var K = _tmpl$2();
|
|
153
|
+
return spread(K, _, !1, !1), K;
|
|
154
|
+
})(), Y = (_) => (() => {
|
|
155
|
+
var K = _tmpl$3();
|
|
156
|
+
return spread(K, _, !1, !1), K;
|
|
157
|
+
})(), X = (_) => (() => {
|
|
158
|
+
var K = _tmpl$4();
|
|
159
|
+
return spread(K, _, !1, !1), K;
|
|
160
|
+
})(), Z = (_) => (() => {
|
|
161
|
+
var q = _tmpl$5();
|
|
162
|
+
return spread(q, mergeProps(_, K), !1, !1), q;
|
|
163
|
+
})(), Q = (_) => (() => {
|
|
164
|
+
var q = _tmpl$6();
|
|
165
|
+
return spread(q, mergeProps(_, K), !1, !1), q;
|
|
166
|
+
})(), $ = (_) => (() => {
|
|
167
|
+
var q = _tmpl$7();
|
|
168
|
+
return spread(q, mergeProps(_, K), !1, !1), q;
|
|
164
169
|
})();
|
|
165
170
|
return {
|
|
166
171
|
name: "base",
|
|
167
172
|
priority: Infinity,
|
|
168
|
-
store: (
|
|
169
|
-
let
|
|
173
|
+
store: (_) => {
|
|
174
|
+
let K = makeResizeObserver((K) => {
|
|
170
175
|
batch(() => {
|
|
171
|
-
for (let
|
|
172
|
-
let
|
|
173
|
-
|
|
174
|
-
width:
|
|
175
|
-
height:
|
|
176
|
+
for (let q of K) {
|
|
177
|
+
let K = q.target, { inlineSize: J, blockSize: Y } = q.borderBoxSize[0], X = K.getAttribute("x");
|
|
178
|
+
X >= 0 && K.parentElement && (_.thSizes[X] = {
|
|
179
|
+
width: J,
|
|
180
|
+
height: Y
|
|
176
181
|
});
|
|
177
182
|
}
|
|
178
183
|
});
|
|
179
|
-
}),
|
|
184
|
+
}), q = makeResizeObserver((K) => {
|
|
180
185
|
batch(() => {
|
|
181
|
-
for (let
|
|
182
|
-
let
|
|
183
|
-
|
|
184
|
-
width:
|
|
185
|
-
height:
|
|
186
|
+
for (let q of K) {
|
|
187
|
+
let K = q.target, { inlineSize: J, blockSize: Y } = q.borderBoxSize[0], X = K.getAttribute("y");
|
|
188
|
+
X >= 0 && K.parentElement && (_.trSizes[X] = {
|
|
189
|
+
width: J,
|
|
190
|
+
height: Y
|
|
186
191
|
});
|
|
187
192
|
}
|
|
188
193
|
});
|
|
189
194
|
});
|
|
190
195
|
return {
|
|
191
|
-
thObs:
|
|
192
|
-
trObs:
|
|
196
|
+
thObs: K,
|
|
197
|
+
trObs: q,
|
|
193
198
|
ths: [],
|
|
194
199
|
thSizes: [],
|
|
195
200
|
trs: [],
|
|
@@ -200,202 +205,206 @@ function BasePlugin() {
|
|
|
200
205
|
};
|
|
201
206
|
},
|
|
202
207
|
rewriteProps: {
|
|
203
|
-
data: ({ data:
|
|
204
|
-
columns: ({ columns:
|
|
205
|
-
newRow: ({ newRow:
|
|
206
|
-
|
|
207
|
-
let
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
data: ({ data: _ = [] }) => _,
|
|
209
|
+
columns: ({ columns: _ = [] }) => _,
|
|
210
|
+
newRow: ({ newRow: _ = () => ({}) }) => _,
|
|
211
|
+
Scroll: ({ Scroll: _ = q }, { store: K }) => (q) => {
|
|
212
|
+
let J = createScrollPosition(() => K.scroll_el), Y = createElementSize(() => K.scroll_el), X = createMemo(() => {
|
|
213
|
+
let _ = K.scroll_el;
|
|
214
|
+
if (!_) return;
|
|
215
|
+
let q = J.x == 0, X = J.x >= _.scrollWidth - (Y.width || 0);
|
|
216
|
+
return q && X ? "" : !q && !X ? "is-scroll-mid" : q ? "is-scroll-left" : X ? "is-scroll-right" : "";
|
|
217
|
+
});
|
|
218
|
+
q = combineProps(q, {
|
|
219
|
+
ref: (_) => K.scroll_el = _,
|
|
220
|
+
class: "data-table--scroll-view"
|
|
221
|
+
}, { get class() {
|
|
222
|
+
return `data-table ${K.props.border && "data-table--border"} data-table--${K.props.size}`;
|
|
223
|
+
} }, {
|
|
210
224
|
get class() {
|
|
211
|
-
return
|
|
225
|
+
return K.props.class;
|
|
212
226
|
},
|
|
213
227
|
get style() {
|
|
214
|
-
return
|
|
228
|
+
return K.props.style;
|
|
215
229
|
}
|
|
216
|
-
},
|
|
230
|
+
}, { get class() {
|
|
231
|
+
return X();
|
|
232
|
+
} });
|
|
233
|
+
let Z = mapArray(() => K.plugins.flatMap((_) => _.layers ?? []), (_) => createComponent(_, K));
|
|
234
|
+
return createComponent(_, mergeProps({ tabindex: -1 }, q, { get children() {
|
|
235
|
+
return [
|
|
236
|
+
(() => {
|
|
237
|
+
var _ = _tmpl$8();
|
|
238
|
+
return insert(_, Z), _;
|
|
239
|
+
})(),
|
|
240
|
+
memo(() => q.children),
|
|
241
|
+
createComponent(K.props.Footer, {}),
|
|
242
|
+
memo(() => memo(() => !K.props.data.length)() && _tmpl$9())
|
|
243
|
+
];
|
|
244
|
+
} }));
|
|
217
245
|
},
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
246
|
+
Footer: ({ Footer: _ }) => (_ ??= (_) => (() => {
|
|
247
|
+
var K = _tmpl$();
|
|
248
|
+
return spread(K, mergeProps(() => combineProps({ class: "data-table__footer" }, _)), !1, !1), K;
|
|
249
|
+
})(), (K) => createComponent(_, K)),
|
|
250
|
+
Table: ({ Table: _ = J }, { store: K }) => (q) => (q = combineProps({
|
|
251
|
+
ref: (_) => K.table = _,
|
|
252
|
+
class: "data-table--table"
|
|
253
|
+
}, q), createComponent(_, q)),
|
|
254
|
+
Thead: ({ Thead: _ = Y }, { store: K }) => (q) => (q = combineProps({ ref: (_) => K.thead = _ }, q), createComponent(_, q)),
|
|
255
|
+
Tbody: ({ Tbody: _ = X }, { store: K }) => (q) => (q = combineProps({ ref: (_) => K.tbody = _ }, q), createComponent(_, q)),
|
|
256
|
+
Tr: ({ Tr: _ = Z }, { store: K }) => (q) => {
|
|
257
|
+
let [J, Y] = createSignal();
|
|
258
|
+
return q = combineProps({ ref: Y }, q), createEffect(() => {
|
|
259
|
+
let { y: _ } = q;
|
|
260
|
+
_ != null && (K.trs[_] = J(), K.trObs.observe(J()), onCleanup(() => {
|
|
261
|
+
K.trSizes[_] = K.trs[_] = void 0, K.trObs.unobserve(J());
|
|
226
262
|
}));
|
|
227
|
-
}), createComponent(
|
|
263
|
+
}), createComponent(_, q);
|
|
228
264
|
},
|
|
229
|
-
Th: ({ Th:
|
|
230
|
-
let [
|
|
265
|
+
Th: ({ Th: K = Q }, { store: q }) => (J) => {
|
|
266
|
+
let [Y, X] = createSignal(), { props: Z } = useContext(Ctx), Q = combineProps(J, { ref: X }, {
|
|
231
267
|
get class() {
|
|
232
|
-
return unFn(
|
|
268
|
+
return unFn(Z.cellClass, J);
|
|
233
269
|
},
|
|
234
270
|
get style() {
|
|
235
|
-
return unFn(
|
|
271
|
+
return unFn(Z.cellStyle, J);
|
|
236
272
|
}
|
|
237
273
|
}, {
|
|
238
274
|
get class() {
|
|
239
|
-
return
|
|
275
|
+
return J.col.class;
|
|
240
276
|
},
|
|
241
277
|
get style() {
|
|
242
|
-
return
|
|
278
|
+
return J.col.style;
|
|
243
279
|
}
|
|
244
280
|
}, { get style() {
|
|
245
|
-
return
|
|
281
|
+
return J.col.width ? `width: ${J.col.width}px` : "";
|
|
246
282
|
} });
|
|
247
283
|
return createEffect(() => {
|
|
248
|
-
if (
|
|
249
|
-
let { x:
|
|
250
|
-
|
|
251
|
-
|
|
284
|
+
if (J.covered || (J.colspan ?? 1) != 1) return;
|
|
285
|
+
let { x: _ } = J;
|
|
286
|
+
q.ths[_] = Y(), q.thObs.observe(Y()), onCleanup(() => {
|
|
287
|
+
q.thSizes[_] = q.ths[_] = void 0, q.thObs.unobserve(Y());
|
|
252
288
|
});
|
|
253
|
-
}), createComponent(
|
|
254
|
-
return
|
|
289
|
+
}), createComponent(K, mergeProps(Q, { get children() {
|
|
290
|
+
return J.children;
|
|
255
291
|
} }));
|
|
256
292
|
},
|
|
257
|
-
Td: ({ Td:
|
|
258
|
-
let { props:
|
|
293
|
+
Td: ({ Td: K = $ }, { store: q }) => (q) => {
|
|
294
|
+
let { props: J } = useContext(Ctx), Y = combineProps(q, {
|
|
259
295
|
get class() {
|
|
260
|
-
return unFn(
|
|
296
|
+
return unFn(J.cellClass, q);
|
|
261
297
|
},
|
|
262
298
|
get style() {
|
|
263
|
-
return unFn(
|
|
299
|
+
return unFn(J.cellStyle, q);
|
|
264
300
|
}
|
|
265
301
|
}, {
|
|
266
302
|
get class() {
|
|
267
|
-
return
|
|
303
|
+
return q.col.class;
|
|
268
304
|
},
|
|
269
305
|
get style() {
|
|
270
|
-
return
|
|
306
|
+
return q.col.style;
|
|
271
307
|
}
|
|
272
308
|
}, { get style() {
|
|
273
|
-
return
|
|
309
|
+
return q.col.width ? `width: ${q.col.width}px` : "";
|
|
274
310
|
} });
|
|
275
|
-
return createComponent(
|
|
276
|
-
return
|
|
311
|
+
return createComponent(K, mergeProps(Y, { get children() {
|
|
312
|
+
return q.children;
|
|
277
313
|
} }));
|
|
278
314
|
},
|
|
279
|
-
EachRows: ({ EachRows:
|
|
315
|
+
EachRows: ({ EachRows: _ }) => _ || ((_) => createComponent(For, {
|
|
280
316
|
get each() {
|
|
281
|
-
return
|
|
317
|
+
return _.each;
|
|
282
318
|
},
|
|
283
|
-
children: (
|
|
319
|
+
children: (K, q) => _.children(() => K, q)
|
|
284
320
|
})),
|
|
285
|
-
EachCells: ({ EachCells:
|
|
321
|
+
EachCells: ({ EachCells: _ }) => _ || ((_) => createComponent(For, {
|
|
286
322
|
get each() {
|
|
287
|
-
return
|
|
323
|
+
return _.each;
|
|
288
324
|
},
|
|
289
|
-
children: (
|
|
325
|
+
children: (K, q) => _.children(() => K, q)
|
|
290
326
|
})),
|
|
291
|
-
renderer: ({ renderer:
|
|
327
|
+
renderer: ({ renderer: _ = (_) => _ }) => _
|
|
292
328
|
}
|
|
293
329
|
};
|
|
294
330
|
}
|
|
295
|
-
|
|
296
|
-
name: "index",
|
|
297
|
-
priority: -Infinity,
|
|
298
|
-
store: (v) => ({ $index: {
|
|
299
|
-
name: "",
|
|
300
|
-
id: Symbol("index"),
|
|
301
|
-
fixed: "left",
|
|
302
|
-
[v.internal]: 1,
|
|
303
|
-
width: 40,
|
|
304
|
-
style: "text-align: center",
|
|
305
|
-
class: "index",
|
|
306
|
-
render: solidComponent((v) => memo(() => v.y + 1))
|
|
307
|
-
} }),
|
|
308
|
-
rewriteProps: { columns: ({ columns: v }, { store: q }) => q.props?.index ? [q.$index, ...v || []] : v }
|
|
309
|
-
}, StickyHeaderPlugin = {
|
|
310
|
-
name: "sticky-header",
|
|
311
|
-
rewriteProps: { Thead: ({ Thead: v }) => (q) => {
|
|
312
|
-
let { props: J } = useContext(Ctx);
|
|
313
|
-
return q = combineProps({ get class() {
|
|
314
|
-
return J.stickyHeader ? "sticky-header" : "";
|
|
315
|
-
} }, q), createComponent(v, q);
|
|
316
|
-
} }
|
|
317
|
-
}, FixedColumnPlugin = (q) => {
|
|
318
|
-
let J = createLazyMemo(() => {
|
|
319
|
-
let v = {};
|
|
320
|
-
for (let [J, Y] of q.props.columns.entries()) Y.fixed === "left" && (v[J] = sumBy(q.thSizes.slice(0, J), (v) => v?.width || 0)), Y.fixed === "right" && (v[J] = sumBy(q.thSizes.slice(J + 1), (v) => v?.width || 0));
|
|
321
|
-
return v;
|
|
322
|
-
}), Y = createLazyMemo(() => q.props.columns.filter((v) => v.fixed == "left").length - 1), X = createLazyMemo(() => q.props.columns.length - q.props.columns.filter((v) => v.fixed == "right").length);
|
|
323
|
-
return {
|
|
324
|
-
name: "fixed-column",
|
|
325
|
-
rewriteProps: {
|
|
326
|
-
columns: ({ columns: v }) => [
|
|
327
|
-
...v?.filter((v) => v.fixed == "left") || [],
|
|
328
|
-
...v?.filter((v) => !v.fixed) || [],
|
|
329
|
-
...v?.filter((v) => v.fixed == "right") || []
|
|
330
|
-
],
|
|
331
|
-
cellClass: ({ cellClass: q }) => (J) => (unFn(q, J) || "") + (J.col.fixed ? ` fixed-${J.col.fixed} ${J.x == Y() ? "is-last" : ""} ${J.x == X() ? "is-first" : ""}` : ""),
|
|
332
|
-
cellStyle: ({ cellStyle: q }) => (Y) => (unFn(q, Y) || "") + (Y.col.fixed ? `; ${Y.col.fixed}: ${J()[Y.x]}px` : "")
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
}, FitColWidthPlugin = (v) => {
|
|
336
|
-
let q = createMutable({ width: 0 });
|
|
337
|
-
createResizeObserver(() => v.scroll_el, (v, J, Y) => q.width = Y.contentBoxSize[0].inlineSize);
|
|
338
|
-
let J = createMutable([]), Y = !1;
|
|
339
|
-
return createEffect(on(() => [q.width, v.props.columns.map((v) => v.width)], async () => {
|
|
340
|
-
if (!q.width || Y) return;
|
|
341
|
-
J.length = 0, Y = !0, await Promise.resolve();
|
|
342
|
-
let X = (q.width - v.table.getBoundingClientRect().width) / v.props.columns.filter((v) => !v.width).length, Z = v.props.columns.map((q, J) => q.width ? null : { width: Math.max((v.ths[J]?.getBoundingClientRect().width || 0) + X, 80) });
|
|
343
|
-
J.push(...Z), Y = !1;
|
|
344
|
-
})), {
|
|
345
|
-
name: "fit-col-width",
|
|
346
|
-
priority: -Infinity,
|
|
347
|
-
rewriteProps: { columns: ({ columns: v }, { store: q }) => (v = v.map((v, Y) => ({
|
|
348
|
-
...v,
|
|
349
|
-
...J?.[Y],
|
|
350
|
-
[q.ID]: v[q.ID] ??= Symbol()
|
|
351
|
-
})), untrack(() => batch(() => reconcile(v, { key: q.ID })(q.__fit_col_width__cols ??= [])))) }
|
|
352
|
-
};
|
|
353
|
-
};
|
|
354
|
-
const ScrollPlugin = {
|
|
355
|
-
name: "scroll",
|
|
356
|
-
priority: Infinity,
|
|
357
|
-
rewriteProps: { Table: (v, { store: q }) => (v) => {
|
|
358
|
-
let J = createScrollPosition(() => q.scroll_el), Y = createElementSize(() => q.scroll_el), X = createMemo(() => {
|
|
359
|
-
let v = q.scroll_el;
|
|
360
|
-
if (!v) return;
|
|
361
|
-
let X = J.x == 0, Z = J.x >= v.scrollWidth - (Y.width || 0);
|
|
362
|
-
return X && Z ? "" : !X && !Z ? "is-scroll-mid" : X ? "is-scroll-left" : Z ? "is-scroll-right" : "";
|
|
363
|
-
});
|
|
364
|
-
v = combineProps(v, {
|
|
365
|
-
ref: (v) => q.scroll_el = v,
|
|
366
|
-
class: "data-table--scroll-view"
|
|
367
|
-
}, { get class() {
|
|
368
|
-
return X();
|
|
369
|
-
} });
|
|
370
|
-
let Z = mapArray(() => q.plugins.flatMap((v) => v.layers ?? []), (v) => createComponent(v, q));
|
|
371
|
-
return (() => {
|
|
372
|
-
var J = _tmpl$7(), Y = J.firstChild, X = Y.nextSibling;
|
|
373
|
-
return spread(J, v, !1, !0), insert(Y, Z), use((v) => q.table = v, X), insert(X, () => v.children), insert(J, (() => {
|
|
374
|
-
var v = memo(() => !q.props.data.length);
|
|
375
|
-
return () => v() && _tmpl$8();
|
|
376
|
-
})(), null), J;
|
|
377
|
-
})();
|
|
378
|
-
} }
|
|
379
|
-
}, defaultsPlugins = [
|
|
380
|
-
ScrollPlugin,
|
|
331
|
+
const defaultsPlugins = [
|
|
381
332
|
BasePlugin,
|
|
382
333
|
CommandPlugin,
|
|
383
334
|
MenuPlugin,
|
|
384
335
|
CellSelectionPlugin,
|
|
385
|
-
|
|
336
|
+
{
|
|
337
|
+
name: "sticky-header",
|
|
338
|
+
rewriteProps: { Thead: ({ Thead: _ }) => (K) => {
|
|
339
|
+
let { props: q } = useContext(Ctx);
|
|
340
|
+
return K = combineProps({ get class() {
|
|
341
|
+
return q.stickyHeader ? "sticky-header" : "";
|
|
342
|
+
} }, K), createComponent(_, K);
|
|
343
|
+
} }
|
|
344
|
+
},
|
|
386
345
|
HeaderGroupPlugin,
|
|
387
|
-
|
|
346
|
+
(K) => {
|
|
347
|
+
let q = createLazyMemo(() => {
|
|
348
|
+
let _ = {};
|
|
349
|
+
for (let [q, J] of K.props.columns.entries()) J.fixed === "left" && (_[q] = sumBy(K.thSizes.slice(0, q), (_) => _?.width || 0)), J.fixed === "right" && (_[q] = sumBy(K.thSizes.slice(q + 1), (_) => _?.width || 0));
|
|
350
|
+
return _;
|
|
351
|
+
}), J = createLazyMemo(() => K.props.columns.filter((_) => _.fixed == "left").length - 1), Y = createLazyMemo(() => K.props.columns.length - K.props.columns.filter((_) => _.fixed == "right").length);
|
|
352
|
+
return {
|
|
353
|
+
name: "fixed-column",
|
|
354
|
+
rewriteProps: {
|
|
355
|
+
columns: ({ columns: _ }) => [
|
|
356
|
+
..._?.filter((_) => _.fixed == "left") || [],
|
|
357
|
+
..._?.filter((_) => !_.fixed) || [],
|
|
358
|
+
..._?.filter((_) => _.fixed == "right") || []
|
|
359
|
+
],
|
|
360
|
+
cellClass: ({ cellClass: K }) => (q) => (unFn(K, q) || "") + (q.col.fixed ? ` fixed-${q.col.fixed} ${q.x == J() ? "is-last" : ""} ${q.x == Y() ? "is-first" : ""}` : ""),
|
|
361
|
+
cellStyle: ({ cellStyle: K }) => (J) => (unFn(K, J) || "") + (J.col.fixed ? `; ${J.col.fixed}: ${q()[J.x]}px` : "")
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
},
|
|
388
365
|
DragPlugin,
|
|
389
366
|
ClipboardPlugin,
|
|
390
367
|
ExpandPlugin,
|
|
391
368
|
RowSelectionPlugin,
|
|
392
|
-
|
|
369
|
+
{
|
|
370
|
+
name: "index",
|
|
371
|
+
priority: -Infinity,
|
|
372
|
+
store: (_) => ({ $index: {
|
|
373
|
+
name: "",
|
|
374
|
+
id: Symbol("index"),
|
|
375
|
+
fixed: "left",
|
|
376
|
+
[_.internal]: 1,
|
|
377
|
+
width: 40,
|
|
378
|
+
style: "text-align: center",
|
|
379
|
+
class: "index",
|
|
380
|
+
render: solidComponent((_) => memo(() => _.y + 1))
|
|
381
|
+
} }),
|
|
382
|
+
rewriteProps: { columns: ({ columns: _ }, { store: K }) => K.props?.index ? [K.$index, ..._ || []] : _ }
|
|
383
|
+
},
|
|
393
384
|
ValidatorPlugin,
|
|
394
385
|
EditablePlugin,
|
|
395
386
|
CellMergePlugin,
|
|
396
387
|
TreePlugin,
|
|
397
|
-
|
|
388
|
+
(_) => {
|
|
389
|
+
let K = createMutable({ width: 0 });
|
|
390
|
+
createResizeObserver(() => _.scroll_el, (_, q, J) => K.width = J.contentBoxSize[0].inlineSize);
|
|
391
|
+
let q = createMutable([]), J = !1;
|
|
392
|
+
return createEffect(on(() => [K.width, _.props.columns.map((_) => _.width)], async () => {
|
|
393
|
+
if (!K.width || J) return;
|
|
394
|
+
q.length = 0, J = !0, await Promise.resolve();
|
|
395
|
+
let Y = (K.width - _.table.getBoundingClientRect().width) / _.props.columns.filter((_) => !_.width).length, X = _.props.columns.map((K, q) => K.width ? null : { width: Math.max((_.ths[q]?.getBoundingClientRect().width || 0) + Y, 80) });
|
|
396
|
+
q.push(...X), J = !1;
|
|
397
|
+
})), {
|
|
398
|
+
name: "fit-col-width",
|
|
399
|
+
priority: -Infinity,
|
|
400
|
+
rewriteProps: { columns: ({ columns: _ }, { store: K }) => (_ = _.map((_, J) => ({
|
|
401
|
+
..._,
|
|
402
|
+
...q?.[J],
|
|
403
|
+
[K.ID]: _[K.ID] ??= Symbol()
|
|
404
|
+
})), untrack(() => batch(() => reconcile(_, { key: K.ID })(K.__fit_col_width__cols ??= [])))) }
|
|
405
|
+
};
|
|
406
|
+
},
|
|
398
407
|
RowGroupPlugin,
|
|
399
408
|
ResizePlugin
|
|
400
409
|
];
|
|
401
|
-
export { Ctx, Intable,
|
|
410
|
+
export { Ctx, Intable, src_default as default, defaultsPlugins };
|
|
@@ -2,7 +2,11 @@ import type { Plugin } from '..';
|
|
|
2
2
|
import type { AndOrNode } from '../components/AndOr';
|
|
3
3
|
declare module '../index' {
|
|
4
4
|
interface TableProps {
|
|
5
|
-
|
|
5
|
+
filter?: {
|
|
6
|
+
onChange?: (value: AndOrNode[]) => void;
|
|
7
|
+
/** @default true */
|
|
8
|
+
autoMatch?: boolean;
|
|
9
|
+
};
|
|
6
10
|
}
|
|
7
11
|
interface TableColumn {
|
|
8
12
|
filterable?: boolean;
|