intable 0.0.22 → 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/dist/__uno.css +1 -1
- package/dist/components/AndOr.d.ts +35 -0
- package/dist/components/AndOr.js +188 -0
- package/dist/components/AndOrFields.d.ts +38 -0
- package/dist/components/AndOrFields.js +280 -0
- package/dist/components/Filter.d.ts +10 -0
- package/dist/components/Filter.js +97 -0
- package/dist/filter.js +6 -0
- package/dist/hooks/index.js +4 -1
- package/dist/hooks/useVirtualizer.js +55 -59
- package/dist/index.d.ts +4 -3
- package/dist/index.js +245 -232
- package/dist/plugins/CommandPlugin.js +19 -21
- package/dist/plugins/EditablePlugin.js +6 -10
- package/dist/plugins/FilterPlugin.d.ts +18 -0
- package/dist/plugins/FilterPlugin.js +123 -0
- package/dist/plugins/LoadMorePlugin.d.ts +24 -0
- package/dist/plugins/LoadMorePlugin.js +62 -0
- package/dist/plugins/MenuPlugin.js +4 -3
- package/dist/plugins/RenderPlugin/index.d.ts +1 -0
- package/dist/plugins/RenderPlugin/index.js +1 -1
- package/dist/plugins/ValidatorPlugin.js +36 -35
- package/dist/plugins/VirtualScrollPlugin.js +73 -75
- package/dist/style.css +2 -2
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +42 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ 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
|
|
20
|
+
import { createComponent, insert, memo, mergeProps, spread, template } from "solid-js/web";
|
|
21
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";
|
|
@@ -25,112 +25,114 @@ 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
|
-
}),
|
|
41
|
+
}), Y = memoize((K) => runWithOwner(q, () => unFn(K, J))), X = createMemo(() => [
|
|
42
42
|
...defaultsPlugins,
|
|
43
|
-
...
|
|
43
|
+
...K.plugins || [],
|
|
44
44
|
RenderPlugin
|
|
45
|
-
].map(
|
|
46
|
-
createComputed((
|
|
47
|
-
let
|
|
48
|
-
return runWithOwner(
|
|
49
|
-
|
|
50
|
-
}),
|
|
51
|
-
}, []),
|
|
52
|
-
let
|
|
53
|
-
function
|
|
54
|
-
return createMemo(() =>
|
|
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,52 +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
|
|
170
|
-
|
|
171
|
-
let q
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
173
|
+
store: (_) => {
|
|
174
|
+
let K = makeResizeObserver((K) => {
|
|
175
|
+
batch(() => {
|
|
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
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}), q = makeResizeObserver((K) => {
|
|
185
|
+
batch(() => {
|
|
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
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
});
|
|
185
194
|
});
|
|
186
195
|
return {
|
|
187
|
-
thObs:
|
|
188
|
-
trObs:
|
|
196
|
+
thObs: K,
|
|
197
|
+
trObs: q,
|
|
189
198
|
ths: [],
|
|
190
199
|
thSizes: [],
|
|
191
200
|
trs: [],
|
|
@@ -196,202 +205,206 @@ function BasePlugin() {
|
|
|
196
205
|
};
|
|
197
206
|
},
|
|
198
207
|
rewriteProps: {
|
|
199
|
-
data: ({ data:
|
|
200
|
-
columns: ({ columns:
|
|
201
|
-
newRow: ({ newRow:
|
|
202
|
-
|
|
203
|
-
let
|
|
204
|
-
|
|
205
|
-
|
|
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
|
+
} }, {
|
|
206
224
|
get class() {
|
|
207
|
-
return
|
|
225
|
+
return K.props.class;
|
|
208
226
|
},
|
|
209
227
|
get style() {
|
|
210
|
-
return
|
|
228
|
+
return K.props.style;
|
|
211
229
|
}
|
|
212
|
-
},
|
|
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
|
+
} }));
|
|
213
245
|
},
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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());
|
|
222
262
|
}));
|
|
223
|
-
}), createComponent(
|
|
263
|
+
}), createComponent(_, q);
|
|
224
264
|
},
|
|
225
|
-
Th: ({ Th:
|
|
226
|
-
let [
|
|
265
|
+
Th: ({ Th: K = Q }, { store: q }) => (J) => {
|
|
266
|
+
let [Y, X] = createSignal(), { props: Z } = useContext(Ctx), Q = combineProps(J, { ref: X }, {
|
|
227
267
|
get class() {
|
|
228
|
-
return unFn(
|
|
268
|
+
return unFn(Z.cellClass, J);
|
|
229
269
|
},
|
|
230
270
|
get style() {
|
|
231
|
-
return unFn(
|
|
271
|
+
return unFn(Z.cellStyle, J);
|
|
232
272
|
}
|
|
233
273
|
}, {
|
|
234
274
|
get class() {
|
|
235
|
-
return
|
|
275
|
+
return J.col.class;
|
|
236
276
|
},
|
|
237
277
|
get style() {
|
|
238
|
-
return
|
|
278
|
+
return J.col.style;
|
|
239
279
|
}
|
|
240
280
|
}, { get style() {
|
|
241
|
-
return
|
|
281
|
+
return J.col.width ? `width: ${J.col.width}px` : "";
|
|
242
282
|
} });
|
|
243
283
|
return createEffect(() => {
|
|
244
|
-
if (
|
|
245
|
-
let { x:
|
|
246
|
-
|
|
247
|
-
|
|
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());
|
|
248
288
|
});
|
|
249
|
-
}), createComponent(
|
|
250
|
-
return
|
|
289
|
+
}), createComponent(K, mergeProps(Q, { get children() {
|
|
290
|
+
return J.children;
|
|
251
291
|
} }));
|
|
252
292
|
},
|
|
253
|
-
Td: ({ Td:
|
|
254
|
-
let { props:
|
|
293
|
+
Td: ({ Td: K = $ }, { store: q }) => (q) => {
|
|
294
|
+
let { props: J } = useContext(Ctx), Y = combineProps(q, {
|
|
255
295
|
get class() {
|
|
256
|
-
return unFn(
|
|
296
|
+
return unFn(J.cellClass, q);
|
|
257
297
|
},
|
|
258
298
|
get style() {
|
|
259
|
-
return unFn(
|
|
299
|
+
return unFn(J.cellStyle, q);
|
|
260
300
|
}
|
|
261
301
|
}, {
|
|
262
302
|
get class() {
|
|
263
|
-
return
|
|
303
|
+
return q.col.class;
|
|
264
304
|
},
|
|
265
305
|
get style() {
|
|
266
|
-
return
|
|
306
|
+
return q.col.style;
|
|
267
307
|
}
|
|
268
308
|
}, { get style() {
|
|
269
|
-
return
|
|
309
|
+
return q.col.width ? `width: ${q.col.width}px` : "";
|
|
270
310
|
} });
|
|
271
|
-
return createComponent(
|
|
272
|
-
return
|
|
311
|
+
return createComponent(K, mergeProps(Y, { get children() {
|
|
312
|
+
return q.children;
|
|
273
313
|
} }));
|
|
274
314
|
},
|
|
275
|
-
EachRows: ({ EachRows:
|
|
315
|
+
EachRows: ({ EachRows: _ }) => _ || ((_) => createComponent(For, {
|
|
276
316
|
get each() {
|
|
277
|
-
return
|
|
317
|
+
return _.each;
|
|
278
318
|
},
|
|
279
|
-
children: (
|
|
319
|
+
children: (K, q) => _.children(() => K, q)
|
|
280
320
|
})),
|
|
281
|
-
EachCells: ({ EachCells:
|
|
321
|
+
EachCells: ({ EachCells: _ }) => _ || ((_) => createComponent(For, {
|
|
282
322
|
get each() {
|
|
283
|
-
return
|
|
323
|
+
return _.each;
|
|
284
324
|
},
|
|
285
|
-
children: (
|
|
325
|
+
children: (K, q) => _.children(() => K, q)
|
|
286
326
|
})),
|
|
287
|
-
renderer: ({ renderer:
|
|
327
|
+
renderer: ({ renderer: _ = (_) => _ }) => _
|
|
288
328
|
}
|
|
289
329
|
};
|
|
290
330
|
}
|
|
291
|
-
|
|
292
|
-
name: "index",
|
|
293
|
-
priority: -Infinity,
|
|
294
|
-
store: (v) => ({ $index: {
|
|
295
|
-
name: "",
|
|
296
|
-
id: Symbol("index"),
|
|
297
|
-
fixed: "left",
|
|
298
|
-
[v.internal]: 1,
|
|
299
|
-
width: 40,
|
|
300
|
-
style: "text-align: center",
|
|
301
|
-
class: "index",
|
|
302
|
-
render: solidComponent((v) => memo(() => v.y + 1))
|
|
303
|
-
} }),
|
|
304
|
-
rewriteProps: { columns: ({ columns: v }, { store: q }) => q.props?.index ? [q.$index, ...v || []] : v }
|
|
305
|
-
}, StickyHeaderPlugin = {
|
|
306
|
-
name: "sticky-header",
|
|
307
|
-
rewriteProps: { Thead: ({ Thead: v }) => (q) => {
|
|
308
|
-
let { props: J } = useContext(Ctx);
|
|
309
|
-
return q = combineProps({ get class() {
|
|
310
|
-
return J.stickyHeader ? "sticky-header" : "";
|
|
311
|
-
} }, q), createComponent(v, q);
|
|
312
|
-
} }
|
|
313
|
-
}, FixedColumnPlugin = (q) => {
|
|
314
|
-
let J = createLazyMemo(() => {
|
|
315
|
-
let v = {};
|
|
316
|
-
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));
|
|
317
|
-
return v;
|
|
318
|
-
}), 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);
|
|
319
|
-
return {
|
|
320
|
-
name: "fixed-column",
|
|
321
|
-
rewriteProps: {
|
|
322
|
-
columns: ({ columns: v }) => [
|
|
323
|
-
...v?.filter((v) => v.fixed == "left") || [],
|
|
324
|
-
...v?.filter((v) => !v.fixed) || [],
|
|
325
|
-
...v?.filter((v) => v.fixed == "right") || []
|
|
326
|
-
],
|
|
327
|
-
cellClass: ({ cellClass: q }) => (J) => (unFn(q, J) || "") + (J.col.fixed ? ` fixed-${J.col.fixed} ${J.x == Y() ? "is-last" : ""} ${J.x == X() ? "is-first" : ""}` : ""),
|
|
328
|
-
cellStyle: ({ cellStyle: q }) => (Y) => (unFn(q, Y) || "") + (Y.col.fixed ? `; ${Y.col.fixed}: ${J()[Y.x]}px` : "")
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
}, FitColWidthPlugin = (v) => {
|
|
332
|
-
let q = createMutable({ width: 0 });
|
|
333
|
-
createResizeObserver(() => v.scroll_el, (v, J, Y) => q.width = Y.contentBoxSize[0].inlineSize);
|
|
334
|
-
let J = createMutable([]), Y = !1;
|
|
335
|
-
return createEffect(on(() => [q.width, v.props.columns.map((v) => v.width)], async () => {
|
|
336
|
-
if (!q.width || Y) return;
|
|
337
|
-
J.length = 0, Y = !0, await Promise.resolve();
|
|
338
|
-
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) });
|
|
339
|
-
J.push(...Z), Y = !1;
|
|
340
|
-
})), {
|
|
341
|
-
name: "fit-col-width",
|
|
342
|
-
priority: -Infinity,
|
|
343
|
-
rewriteProps: { columns: ({ columns: v }, { store: q }) => (v = v.map((v, Y) => ({
|
|
344
|
-
...v,
|
|
345
|
-
...J?.[Y],
|
|
346
|
-
[q.ID]: v[q.ID] ??= Symbol()
|
|
347
|
-
})), untrack(() => batch(() => reconcile(v, { key: q.ID })(q.__fit_col_width__cols ??= [])))) }
|
|
348
|
-
};
|
|
349
|
-
};
|
|
350
|
-
const ScrollPlugin = {
|
|
351
|
-
name: "scroll",
|
|
352
|
-
priority: Infinity,
|
|
353
|
-
rewriteProps: { Table: (v, { store: q }) => (v) => {
|
|
354
|
-
let J = createScrollPosition(() => q.scroll_el), Y = createElementSize(() => q.scroll_el), X = createMemo(() => {
|
|
355
|
-
let v = q.scroll_el;
|
|
356
|
-
if (!v) return;
|
|
357
|
-
let X = J.x == 0, Z = J.x >= v.scrollWidth - (Y.width || 0);
|
|
358
|
-
return X && Z ? "" : !X && !Z ? "is-scroll-mid" : X ? "is-scroll-left" : Z ? "is-scroll-right" : "";
|
|
359
|
-
});
|
|
360
|
-
v = combineProps(v, {
|
|
361
|
-
ref: (v) => q.scroll_el = v,
|
|
362
|
-
class: "data-table--scroll-view"
|
|
363
|
-
}, { get class() {
|
|
364
|
-
return X();
|
|
365
|
-
} });
|
|
366
|
-
let Z = mapArray(() => q.plugins.flatMap((v) => v.layers ?? []), (v) => createComponent(v, q));
|
|
367
|
-
return (() => {
|
|
368
|
-
var J = _tmpl$7(), Y = J.firstChild, X = Y.nextSibling;
|
|
369
|
-
return spread(J, v, !1, !0), insert(Y, Z), use((v) => q.table = v, X), insert(X, () => v.children), insert(J, (() => {
|
|
370
|
-
var v = memo(() => !q.props.data.length);
|
|
371
|
-
return () => v() && _tmpl$8();
|
|
372
|
-
})(), null), J;
|
|
373
|
-
})();
|
|
374
|
-
} }
|
|
375
|
-
}, defaultsPlugins = [
|
|
376
|
-
ScrollPlugin,
|
|
331
|
+
const defaultsPlugins = [
|
|
377
332
|
BasePlugin,
|
|
378
333
|
CommandPlugin,
|
|
379
334
|
MenuPlugin,
|
|
380
335
|
CellSelectionPlugin,
|
|
381
|
-
|
|
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
|
+
},
|
|
382
345
|
HeaderGroupPlugin,
|
|
383
|
-
|
|
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
|
+
},
|
|
384
365
|
DragPlugin,
|
|
385
366
|
ClipboardPlugin,
|
|
386
367
|
ExpandPlugin,
|
|
387
368
|
RowSelectionPlugin,
|
|
388
|
-
|
|
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
|
+
},
|
|
389
384
|
ValidatorPlugin,
|
|
390
385
|
EditablePlugin,
|
|
391
386
|
CellMergePlugin,
|
|
392
387
|
TreePlugin,
|
|
393
|
-
|
|
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
|
+
},
|
|
394
407
|
RowGroupPlugin,
|
|
395
408
|
ResizePlugin
|
|
396
409
|
];
|
|
397
|
-
export { Ctx, Intable,
|
|
410
|
+
export { Ctx, Intable, src_default as default, defaultsPlugins };
|