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