intable 0.0.8 → 0.0.9
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/README.md +263 -16
- package/dist/__uno.css +1 -0
- package/dist/chevron-right.js +6 -0
- package/dist/components/Columns.d.ts +3 -0
- package/dist/components/Columns.js +71 -0
- package/dist/components/DocTree.d.ts +4 -0
- package/dist/components/DocTree.js +32 -0
- package/dist/components/Menu.d.ts +1 -0
- package/dist/components/Menu.js +107 -0
- package/dist/components/Popover.d.ts +14 -0
- package/dist/components/Popover.js +41 -0
- package/dist/components/RecycleList.d.ts +26 -0
- package/dist/components/RecycleList.js +39 -0
- package/dist/components/Render.d.ts +4 -0
- package/dist/components/Render.js +20 -0
- package/dist/components/Split.d.ts +15 -0
- package/dist/components/Split.js +76 -0
- package/dist/components/Tree.d.ts +37 -0
- package/dist/components/Tree.js +82 -0
- package/dist/components/utils.d.ts +3 -0
- package/dist/components/utils.js +8 -0
- package/dist/hooks/index.d.ts +40 -0
- package/dist/hooks/index.js +157 -0
- package/dist/hooks/useDir.d.ts +11 -0
- package/dist/hooks/useDir.js +42 -0
- package/dist/hooks/useSelector.d.ts +16 -0
- package/dist/hooks/useSelector.js +69 -0
- package/dist/hooks/useSort.d.ts +18 -0
- package/dist/hooks/useSort.js +83 -0
- package/dist/hooks/useVirtualizer.d.ts +30 -0
- package/dist/hooks/useVirtualizer.js +97 -0
- package/dist/index.d.ts +147 -0
- package/dist/index.js +386 -0
- package/dist/loading.js +6 -0
- package/dist/plugins/CellChangeHighlightPlugin.d.ts +2 -0
- package/dist/plugins/CellChangeHighlightPlugin.js +4 -0
- package/dist/plugins/CellMergePlugin.d.ts +45 -0
- package/dist/plugins/CellMergePlugin.js +78 -0
- package/dist/plugins/CellSelectionPlugin.d.ts +15 -0
- package/dist/plugins/CellSelectionPlugin.js +113 -0
- package/dist/plugins/CommandPlugin.d.ts +14 -0
- package/dist/plugins/CommandPlugin.js +31 -0
- package/dist/plugins/CopyPastePlugin.d.ts +14 -0
- package/dist/plugins/CopyPastePlugin.js +47 -0
- package/dist/plugins/DiffPlugin.d.ts +29 -0
- package/dist/plugins/DiffPlugin.js +66 -0
- package/dist/plugins/DragPlugin.d.ts +14 -0
- package/dist/plugins/DragPlugin.js +47 -0
- package/dist/plugins/EditablePlugin.d.ts +51 -0
- package/dist/plugins/EditablePlugin.js +177 -0
- package/dist/plugins/ExpandPlugin.d.ts +18 -0
- package/dist/plugins/ExpandPlugin.js +46 -0
- package/dist/plugins/HeaderGroup.d.ts +11 -0
- package/dist/plugins/HeaderGroup.js +171 -0
- package/dist/plugins/HistoryPlugin.d.ts +10 -0
- package/dist/plugins/HistoryPlugin.js +27 -0
- package/dist/plugins/MenuPlugin.d.ts +19 -0
- package/dist/plugins/MenuPlugin.js +132 -0
- package/dist/plugins/RenderPlugin/components.d.ts +5 -0
- package/dist/plugins/RenderPlugin/components.js +87 -0
- package/dist/plugins/RenderPlugin/index.d.ts +30 -0
- package/dist/plugins/RenderPlugin/index.js +49 -0
- package/dist/plugins/ResizePlugin.d.ts +27 -0
- package/dist/plugins/ResizePlugin.js +82 -0
- package/dist/plugins/RowGroupPlugin.d.ts +18 -0
- package/dist/plugins/RowGroupPlugin.js +88 -0
- package/dist/plugins/RowSelectionPlugin.d.ts +20 -0
- package/dist/plugins/RowSelectionPlugin.js +42 -0
- package/dist/plugins/TreePlugin.d.ts +24 -0
- package/dist/plugins/TreePlugin.js +110 -0
- package/dist/plugins/VirtualScrollPlugin.d.ts +15 -0
- package/dist/plugins/VirtualScrollPlugin.js +123 -0
- package/dist/plugins/ZodValidatorPlugin.d.ts +38 -0
- package/dist/plugins/ZodValidatorPlugin.js +12 -0
- package/dist/plus.js +6 -0
- package/dist/rolldown_runtime.js +9 -0
- package/dist/style.css +3 -0
- package/dist/tree.d.ts +1 -0
- package/dist/tree.js +12 -0
- package/dist/types/auto-imports.d.js +0 -0
- package/dist/utils.d.ts +31 -0
- package/dist/utils.js +71 -0
- package/dist/wc.d.ts +1 -0
- package/dist/wc.js +21 -0
- package/dist/web-component.d.ts +1 -0
- package/dist/web-component.js +2 -0
- package/dist/x.js +6 -0
- package/package.json +38 -35
- package/.github/copilot-instructions.md +0 -102
- package/docs/index-BaMALNy6.css +0 -1
- package/docs/index-CDN48t9E.js +0 -3
- package/docs/index-Cc4RNkLY.css +0 -1
- package/docs/index-MRnbkYmU.js +0 -3
- package/docs/index.html +0 -15
- package/docs/vite.svg +0 -1
- package/index.html +0 -13
- package/packages/intable/README.md +0 -379
- package/packages/intable/package.json +0 -51
- package/packages/intable/src/assets/ClearFormat.svg +0 -3
- package/packages/intable/src/assets/Forms.svg +0 -4
- package/packages/intable/src/assets/MergeCell.svg +0 -4
- package/packages/intable/src/assets/SplitCell.svg +0 -4
- package/packages/intable/src/assets/gap.svg +0 -3
- package/packages/intable/src/assets/loading.svg +0 -12
- package/packages/intable/src/assets/paint.svg +0 -9
- package/packages/intable/src/assets/solid.svg +0 -1
- package/packages/intable/src/components/Columns.tsx +0 -86
- package/packages/intable/src/components/DocTree.tsx +0 -36
- package/packages/intable/src/components/Menu.tsx +0 -109
- package/packages/intable/src/components/Popover.tsx +0 -55
- package/packages/intable/src/components/RecycleList.tsx +0 -99
- package/packages/intable/src/components/Render.tsx +0 -26
- package/packages/intable/src/components/Split.tsx +0 -56
- package/packages/intable/src/components/Tree.tsx +0 -115
- package/packages/intable/src/components/utils.tsx +0 -12
- package/packages/intable/src/hooks/index.ts +0 -200
- package/packages/intable/src/hooks/useDir.ts +0 -78
- package/packages/intable/src/hooks/useSelector.ts +0 -91
- package/packages/intable/src/hooks/useSort.tsx +0 -118
- package/packages/intable/src/hooks/useVirtualizer.ts +0 -180
- package/packages/intable/src/index.tsx +0 -489
- package/packages/intable/src/plugins/CellChangeHighlightPlugin.tsx +0 -5
- package/packages/intable/src/plugins/CellMergePlugin.tsx +0 -153
- package/packages/intable/src/plugins/CellSelectionPlugin.tsx +0 -175
- package/packages/intable/src/plugins/CommandPlugin.tsx +0 -74
- package/packages/intable/src/plugins/CopyPastePlugin.tsx +0 -99
- package/packages/intable/src/plugins/DiffPlugin.tsx +0 -120
- package/packages/intable/src/plugins/DragPlugin.tsx +0 -81
- package/packages/intable/src/plugins/EditablePlugin.tsx +0 -252
- package/packages/intable/src/plugins/ExpandPlugin.tsx +0 -80
- package/packages/intable/src/plugins/HeaderGroup.tsx +0 -289
- package/packages/intable/src/plugins/HistoryPlugin.tsx +0 -49
- package/packages/intable/src/plugins/MenuPlugin.tsx +0 -195
- package/packages/intable/src/plugins/RenderPlugin/components.tsx +0 -51
- package/packages/intable/src/plugins/RenderPlugin/index.tsx +0 -81
- package/packages/intable/src/plugins/ResizePlugin.tsx +0 -122
- package/packages/intable/src/plugins/RowGroupPlugin.tsx +0 -122
- package/packages/intable/src/plugins/RowSelectionPlugin.tsx +0 -65
- package/packages/intable/src/plugins/TreePlugin.tsx +0 -212
- package/packages/intable/src/plugins/VirtualScrollPlugin.tsx +0 -190
- package/packages/intable/src/plugins/ZodValidatorPlugin.tsx +0 -61
- package/packages/intable/src/style.scss +0 -244
- package/packages/intable/src/tree.ts +0 -13
- package/packages/intable/src/types/auto-imports.d.ts +0 -13
- package/packages/intable/src/utils.ts +0 -122
- package/packages/intable/src/wc.tsx +0 -35
- package/packages/intable/src/web-component.ts +0 -1
- package/packages/react/package.json +0 -36
- package/packages/react/src/index.ts +0 -44
- package/packages/react/src/plugins/antd.ts +0 -94
- package/packages/react/src/style.scss +0 -12
- package/packages/react/src/types/auto-imports.d.ts +0 -10
- package/packages/vue/package.json +0 -34
- package/packages/vue/src/index.ts +0 -63
- package/packages/vue/src/plugins/element-plus.ts +0 -69
- package/packages/vue/src/style.scss +0 -12
- package/packages/vue/src/types/auto-imports.d.ts +0 -10
- package/pnpm-workspace.yaml +0 -2
- package/public/vite.svg +0 -1
- package/scripts/build.js +0 -184
- package/scripts/publish.js +0 -95
- package/src/assets/ClearFormat.svg +0 -3
- package/src/assets/Forms.svg +0 -4
- package/src/assets/MergeCell.svg +0 -4
- package/src/assets/SplitCell.svg +0 -4
- package/src/assets/gap.svg +0 -3
- package/src/assets/loading.svg +0 -12
- package/src/assets/paint.svg +0 -9
- package/src/assets/solid.svg +0 -1
- package/src/demo-vue.ts +0 -54
- package/src/index.scss +0 -105
- package/src/index.tsx +0 -20
- package/src/pages/demo/BasicDemo.tsx +0 -19
- package/src/pages/demo/CellMergeDemo.tsx +0 -41
- package/src/pages/demo/CellSelectionDemo.tsx +0 -24
- package/src/pages/demo/CompositeDemo.tsx +0 -60
- package/src/pages/demo/CopyPasteDemo.tsx +0 -26
- package/src/pages/demo/DiffDemo.tsx +0 -33
- package/src/pages/demo/DragDemo.tsx +0 -25
- package/src/pages/demo/EditableDemo.tsx +0 -58
- package/src/pages/demo/ExpandDemo.tsx +0 -32
- package/src/pages/demo/HeaderGroupDemo.tsx +0 -36
- package/src/pages/demo/HistoryDemo.tsx +0 -28
- package/src/pages/demo/ReactDemo.tsx +0 -59
- package/src/pages/demo/ResizeDemo.tsx +0 -24
- package/src/pages/demo/RowGroupDemo.tsx +0 -43
- package/src/pages/demo/RowSelectionDemo.tsx +0 -27
- package/src/pages/demo/TreeDemo.tsx +0 -45
- package/src/pages/demo/VirtualScrollDemo.tsx +0 -21
- package/src/pages/demo/helpers.tsx +0 -39
- package/src/pages/demo/index.tsx +0 -180
- package/src/pages/index.tsx +0 -2
- package/src/pages/website.scss +0 -37
- package/src/pages/website.tsx +0 -651
- package/src/styles/index.scss +0 -172
- package/src/types/auto-imports.d.ts +0 -13
- package/stats.html +0 -4949
- package/tsconfig.app.json +0 -34
- package/tsconfig.json +0 -7
- package/tsconfig.node.json +0 -26
- package/vite.config.ts +0 -70
- /package/{packages/intable/src → dist}/theme/antd.scss +0 -0
- /package/{packages/intable/src → dist}/theme/dark.scss +0 -0
- /package/{packages/intable/src → dist}/theme/element-plus.scss +0 -0
- /package/{packages/intable/src → dist}/theme/github.scss +0 -0
- /package/{packages/intable/src → dist}/theme/material.scss +0 -0
- /package/{packages/intable/src → dist}/theme/shadcn.scss +0 -0
- /package/{packages/intable/src → dist}/theme/stripe.scss +0 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { unFn } from "./utils.js";
|
|
2
|
+
import { toReactive, useMemo } from "./hooks/index.js";
|
|
3
|
+
import './style.css';;/* empty css */
|
|
4
|
+
/* empty css */
|
|
5
|
+
import { CellSelectionPlugin } from "./plugins/CellSelectionPlugin.js";
|
|
6
|
+
import { ClipboardPlugin } from "./plugins/CopyPastePlugin.js";
|
|
7
|
+
import { EditablePlugin } from "./plugins/EditablePlugin.js";
|
|
8
|
+
import { solidComponent } from "./components/utils.js";
|
|
9
|
+
import { RenderPlugin } from "./plugins/RenderPlugin/index.js";
|
|
10
|
+
import { MenuPlugin } from "./plugins/MenuPlugin.js";
|
|
11
|
+
import { CommandPlugin } from "./plugins/CommandPlugin.js";
|
|
12
|
+
import { RowSelectionPlugin } from "./plugins/RowSelectionPlugin.js";
|
|
13
|
+
import { ResizePlugin } from "./plugins/ResizePlugin.js";
|
|
14
|
+
import { DragPlugin } from "./plugins/DragPlugin.js";
|
|
15
|
+
import { RowGroupPlugin } from "./plugins/RowGroupPlugin.js";
|
|
16
|
+
import { ExpandPlugin } from "./plugins/ExpandPlugin.js";
|
|
17
|
+
import { CellMergePlugin } from "./plugins/CellMergePlugin.js";
|
|
18
|
+
import { TreePlugin } from "./plugins/TreePlugin.js";
|
|
19
|
+
import { HeaderGroupPlugin } from "./plugins/HeaderGroup.js";
|
|
20
|
+
import { createComponent, insert, memo, mergeProps, spread, template, use } from "solid-js/web";
|
|
21
|
+
import { For, batch, createComputed, createContext, createEffect, createMemo, createSignal, getOwner, mapArray, mergeProps as mergeProps$1, on, onCleanup, onMount, runWithOwner, untrack, useContext } from "solid-js";
|
|
22
|
+
import { createMutable, reconcile } from "solid-js/store";
|
|
23
|
+
import { combineProps } from "@solid-primitives/props";
|
|
24
|
+
import { createLazyMemo } from "@solid-primitives/memo";
|
|
25
|
+
import { createElementSize, createResizeObserver, makeResizeObserver } from "@solid-primitives/resize-observer";
|
|
26
|
+
import { createScrollPosition } from "@solid-primitives/scroll";
|
|
27
|
+
import { difference, mapValues, memoize, sumBy } from "es-toolkit";
|
|
28
|
+
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 tabindex=-1><div class=data-table__layers></div><table class=data-table--table>");
|
|
29
|
+
const Ctx = createContext({
|
|
30
|
+
props: {},
|
|
31
|
+
store: {}
|
|
32
|
+
}), Intable = (K) => {
|
|
33
|
+
K = mergeProps$1({ rowKey: "id" }, K);
|
|
34
|
+
let q = getOwner(), J = createMutable({
|
|
35
|
+
get rawProps() {
|
|
36
|
+
return K;
|
|
37
|
+
},
|
|
38
|
+
get plugins() {
|
|
39
|
+
return Z();
|
|
40
|
+
}
|
|
41
|
+
}), Y = memoize((W) => runWithOwner(q, () => unFn(W, J))), Z = createMemo(() => [
|
|
42
|
+
...defaultsPlugins,
|
|
43
|
+
...K.plugins || [],
|
|
44
|
+
RenderPlugin
|
|
45
|
+
].map(Y).sort((h, W) => (W.priority || 0) - (h.priority || 0)));
|
|
46
|
+
createComputed((h) => {
|
|
47
|
+
let W = difference(Z(), h);
|
|
48
|
+
return runWithOwner(q, () => {
|
|
49
|
+
W.forEach((h) => Object.assign(J, h.store?.(J)));
|
|
50
|
+
}), Z();
|
|
51
|
+
}, []);
|
|
52
|
+
let Q = mapArray(Z, () => createSignal());
|
|
53
|
+
J.props = toReactive(createMemo(() => Q()[Q().length - 1][0]() || K)), createComputed(mapArray(Z, (h, q) => {
|
|
54
|
+
let Y = createMemo(() => Q()[q() - 1]?.[0]() || K), X = mergeProps$1(Y, toReactive(mapValues(h.rewriteProps || {}, (h) => useMemo(() => h(Y(), { store: J })))));
|
|
55
|
+
Q()[q()][1](X);
|
|
56
|
+
})), onMount(() => {
|
|
57
|
+
createEffect(mapArray(Z, (h) => h.onMount?.(J)));
|
|
58
|
+
});
|
|
59
|
+
let $ = createMutable({
|
|
60
|
+
props: J.props,
|
|
61
|
+
store: J
|
|
62
|
+
});
|
|
63
|
+
return window.store = J, window.ctx = $, createComponent(Ctx.Provider, {
|
|
64
|
+
value: $,
|
|
65
|
+
get children() {
|
|
66
|
+
return createComponent($.props.Table, { get children() {
|
|
67
|
+
return [createComponent(THead, {}), createComponent(TBody, {})];
|
|
68
|
+
} });
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
var THead = () => {
|
|
73
|
+
let { props: h } = useContext(Ctx);
|
|
74
|
+
return createComponent(h.Thead, { get children() {
|
|
75
|
+
return createComponent(h.Tr, { get children() {
|
|
76
|
+
return createComponent(h.EachCells, {
|
|
77
|
+
get each() {
|
|
78
|
+
return h.columns || [];
|
|
79
|
+
},
|
|
80
|
+
children: (W, G) => createComponent(h.Th, {
|
|
81
|
+
get col() {
|
|
82
|
+
return W();
|
|
83
|
+
},
|
|
84
|
+
get x() {
|
|
85
|
+
return G();
|
|
86
|
+
},
|
|
87
|
+
get children() {
|
|
88
|
+
return W().name;
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
} });
|
|
93
|
+
} });
|
|
94
|
+
}, TBody = () => {
|
|
95
|
+
let { props: h } = useContext(Ctx);
|
|
96
|
+
return createComponent(h.Tbody, { get children() {
|
|
97
|
+
return createComponent(h.EachRows, {
|
|
98
|
+
get each() {
|
|
99
|
+
return h.data;
|
|
100
|
+
},
|
|
101
|
+
children: (W, G) => createComponent(h.Tr, {
|
|
102
|
+
get y() {
|
|
103
|
+
return G();
|
|
104
|
+
},
|
|
105
|
+
get data() {
|
|
106
|
+
return W();
|
|
107
|
+
},
|
|
108
|
+
get children() {
|
|
109
|
+
return createComponent(h.EachCells, {
|
|
110
|
+
get each() {
|
|
111
|
+
return h.columns;
|
|
112
|
+
},
|
|
113
|
+
children: (K, q) => createComponent(h.Td, {
|
|
114
|
+
get col() {
|
|
115
|
+
return K();
|
|
116
|
+
},
|
|
117
|
+
get x() {
|
|
118
|
+
return q();
|
|
119
|
+
},
|
|
120
|
+
get y() {
|
|
121
|
+
return G();
|
|
122
|
+
},
|
|
123
|
+
get data() {
|
|
124
|
+
return W();
|
|
125
|
+
},
|
|
126
|
+
get children() {
|
|
127
|
+
return W()[K().id];
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
});
|
|
134
|
+
} });
|
|
135
|
+
}, src_default = Intable;
|
|
136
|
+
function BasePlugin() {
|
|
137
|
+
let W = {
|
|
138
|
+
col: null,
|
|
139
|
+
data: null
|
|
140
|
+
}, G = (h) => (() => {
|
|
141
|
+
var W = _tmpl$();
|
|
142
|
+
return spread(W, h, !1, !1), W;
|
|
143
|
+
})(), K = (h) => (() => {
|
|
144
|
+
var W = _tmpl$2();
|
|
145
|
+
return spread(W, h, !1, !1), W;
|
|
146
|
+
})(), q = (h) => (() => {
|
|
147
|
+
var W = _tmpl$3();
|
|
148
|
+
return spread(W, h, !1, !1), W;
|
|
149
|
+
})(), J = (h) => (() => {
|
|
150
|
+
var G = _tmpl$4();
|
|
151
|
+
return spread(G, mergeProps(h, W), !1, !1), G;
|
|
152
|
+
})(), Y = (h) => (() => {
|
|
153
|
+
var G = _tmpl$5();
|
|
154
|
+
return spread(G, mergeProps(h, W), !1, !1), G;
|
|
155
|
+
})(), X = (h) => (() => {
|
|
156
|
+
var G = _tmpl$6();
|
|
157
|
+
return spread(G, mergeProps(h, W), !1, !1), G;
|
|
158
|
+
})();
|
|
159
|
+
return {
|
|
160
|
+
name: "base",
|
|
161
|
+
priority: Infinity,
|
|
162
|
+
store: (h) => {
|
|
163
|
+
let W = makeResizeObserver((W) => {
|
|
164
|
+
for (let G of W) {
|
|
165
|
+
let W = G.target, { inlineSize: K, blockSize: q } = G.borderBoxSize[0], J = h.ths.indexOf(W);
|
|
166
|
+
J >= 0 && W.parentElement && (h.thSizes[J] = {
|
|
167
|
+
width: K,
|
|
168
|
+
height: q
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}), G = makeResizeObserver((W) => {
|
|
172
|
+
for (let G of W) {
|
|
173
|
+
let W = G.target, { inlineSize: K, blockSize: q } = G.borderBoxSize[0], J = h.trs.indexOf(W);
|
|
174
|
+
J >= 0 && W.parentElement && (h.trSizes[J] = {
|
|
175
|
+
width: K,
|
|
176
|
+
height: q
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
return {
|
|
181
|
+
thObs: W,
|
|
182
|
+
trObs: G,
|
|
183
|
+
ths: [],
|
|
184
|
+
thSizes: [],
|
|
185
|
+
trs: [],
|
|
186
|
+
trSizes: [],
|
|
187
|
+
internal: Symbol("internal"),
|
|
188
|
+
raw: Symbol("raw")
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
rewriteProps: {
|
|
192
|
+
data: ({ data: h = [] }) => h,
|
|
193
|
+
columns: ({ columns: h = [] }) => h,
|
|
194
|
+
newRow: ({ newRow: h = () => ({}) }) => h,
|
|
195
|
+
Table: ({ Table: h = G }, { store: W }) => (W) => {
|
|
196
|
+
let [G, K] = createSignal(), { props: q } = useContext(Ctx);
|
|
197
|
+
return W = combineProps({
|
|
198
|
+
ref: K,
|
|
199
|
+
get class() {
|
|
200
|
+
return `data-table ${q.class} ${q.border && "data-table--border"} data-table--${q.size}`;
|
|
201
|
+
},
|
|
202
|
+
get style() {
|
|
203
|
+
return q.style;
|
|
204
|
+
}
|
|
205
|
+
}, W), createComponent(h, W);
|
|
206
|
+
},
|
|
207
|
+
Thead: ({ Thead: h = K }, { store: W }) => (G) => (G = combineProps({ ref: (h) => W.thead = h }, G), createComponent(h, G)),
|
|
208
|
+
Tbody: ({ Tbody: h = q }, { store: W }) => (G) => (G = combineProps({ ref: (h) => W.tbody = h }, G), createComponent(h, G)),
|
|
209
|
+
Tr: ({ Tr: h = J }, { store: W }) => (G) => {
|
|
210
|
+
let [K, q] = createSignal();
|
|
211
|
+
return G = combineProps({ ref: q }, G), createEffect(() => {
|
|
212
|
+
let { y: h } = G;
|
|
213
|
+
h != null && (W.trs[h] = K(), W.trObs.observe(K()), onCleanup(() => {
|
|
214
|
+
W.trSizes[h] = W.trs[h] = void 0, W.trObs.unobserve(K());
|
|
215
|
+
}));
|
|
216
|
+
}), createComponent(h, G);
|
|
217
|
+
},
|
|
218
|
+
Th: ({ Th: W = Y }, { store: G }) => (K) => {
|
|
219
|
+
let [q, J] = createSignal(), { props: Y } = useContext(Ctx), X = combineProps(K, { ref: J }, {
|
|
220
|
+
get class() {
|
|
221
|
+
return unFn(Y.cellClass, K);
|
|
222
|
+
},
|
|
223
|
+
get style() {
|
|
224
|
+
return unFn(Y.cellStyle, K);
|
|
225
|
+
}
|
|
226
|
+
}, {
|
|
227
|
+
get class() {
|
|
228
|
+
return K.col.class;
|
|
229
|
+
},
|
|
230
|
+
get style() {
|
|
231
|
+
return K.col.style;
|
|
232
|
+
}
|
|
233
|
+
}, { get style() {
|
|
234
|
+
return K.col.width ? `width: ${K.col.width}px` : "";
|
|
235
|
+
} });
|
|
236
|
+
return createEffect(() => {
|
|
237
|
+
if (K.covered || (K.colspan ?? 1) != 1) return;
|
|
238
|
+
let { x: h } = K;
|
|
239
|
+
G.ths[h] = q(), G.thObs.observe(q()), onCleanup(() => {
|
|
240
|
+
G.thSizes[h] = G.ths[h] = void 0, G.thObs.unobserve(q());
|
|
241
|
+
});
|
|
242
|
+
}), createComponent(W, mergeProps(X, { get children() {
|
|
243
|
+
return K.children;
|
|
244
|
+
} }));
|
|
245
|
+
},
|
|
246
|
+
Td: ({ Td: W = X }, { store: G }) => (G) => {
|
|
247
|
+
let { props: K } = useContext(Ctx), q = combineProps(G, {
|
|
248
|
+
get class() {
|
|
249
|
+
return unFn(K.cellClass, G);
|
|
250
|
+
},
|
|
251
|
+
get style() {
|
|
252
|
+
return unFn(K.cellStyle, G);
|
|
253
|
+
}
|
|
254
|
+
}, {
|
|
255
|
+
get class() {
|
|
256
|
+
return G.col.class;
|
|
257
|
+
},
|
|
258
|
+
get style() {
|
|
259
|
+
return G.col.style;
|
|
260
|
+
}
|
|
261
|
+
}, { get style() {
|
|
262
|
+
return G.col.width ? `width: ${G.col.width}px` : "";
|
|
263
|
+
} });
|
|
264
|
+
return createComponent(W, mergeProps(q, { get children() {
|
|
265
|
+
return G.children;
|
|
266
|
+
} }));
|
|
267
|
+
},
|
|
268
|
+
EachRows: ({ EachRows: h }) => h || ((h) => createComponent(For, {
|
|
269
|
+
get each() {
|
|
270
|
+
return h.each;
|
|
271
|
+
},
|
|
272
|
+
children: (W, G) => h.children(() => W, G)
|
|
273
|
+
})),
|
|
274
|
+
EachCells: ({ EachCells: h }) => h || ((h) => createComponent(For, {
|
|
275
|
+
get each() {
|
|
276
|
+
return h.each;
|
|
277
|
+
},
|
|
278
|
+
children: (W, G) => h.children(() => W, G)
|
|
279
|
+
})),
|
|
280
|
+
renderer: ({ renderer: h = (h) => h }) => h
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
var IndexPlugin = {
|
|
285
|
+
name: "index",
|
|
286
|
+
priority: -Infinity,
|
|
287
|
+
store: (h) => ({ $index: {
|
|
288
|
+
name: "",
|
|
289
|
+
id: Symbol("index"),
|
|
290
|
+
fixed: "left",
|
|
291
|
+
[h.internal]: 1,
|
|
292
|
+
width: 40,
|
|
293
|
+
style: "text-align: center",
|
|
294
|
+
class: "index",
|
|
295
|
+
render: solidComponent((h) => memo(() => h.y + 1))
|
|
296
|
+
} }),
|
|
297
|
+
rewriteProps: { columns: ({ columns: h }, { store: W }) => W.props?.index ? [W.$index, ...h || []] : h }
|
|
298
|
+
}, StickyHeaderPlugin = {
|
|
299
|
+
name: "sticky-header",
|
|
300
|
+
rewriteProps: { Thead: ({ Thead: h }) => (W) => {
|
|
301
|
+
let { props: G } = useContext(Ctx);
|
|
302
|
+
return W = combineProps({ get class() {
|
|
303
|
+
return G.stickyHeader ? "sticky-header" : "";
|
|
304
|
+
} }, W), createComponent(h, W);
|
|
305
|
+
} }
|
|
306
|
+
}, FixedColumnPlugin = (W) => {
|
|
307
|
+
let G = createLazyMemo(() => {
|
|
308
|
+
let h = {};
|
|
309
|
+
for (let [G, K] of W.props.columns.entries()) K.fixed === "left" && (h[G] = sumBy(W.thSizes.slice(0, G), (h) => h?.width || 0)), K.fixed === "right" && (h[G] = sumBy(W.thSizes.slice(G + 1), (h) => h?.width || 0));
|
|
310
|
+
return h;
|
|
311
|
+
}), K = createLazyMemo(() => W.props.columns.filter((h) => h.fixed == "left").length - 1), q = createLazyMemo(() => W.props.columns.length - W.props.columns.filter((h) => h.fixed == "right").length);
|
|
312
|
+
return {
|
|
313
|
+
name: "fixed-column",
|
|
314
|
+
rewriteProps: {
|
|
315
|
+
columns: ({ columns: h }) => [
|
|
316
|
+
...h?.filter((h) => h.fixed == "left") || [],
|
|
317
|
+
...h?.filter((h) => !h.fixed) || [],
|
|
318
|
+
...h?.filter((h) => h.fixed == "right") || []
|
|
319
|
+
],
|
|
320
|
+
cellClass: ({ cellClass: W }) => (G) => (unFn(W, G) || "") + (G.col.fixed ? ` fixed-${G.col.fixed} ${G.x == K() ? "is-last" : ""} ${G.x == q() ? "is-first" : ""}` : ""),
|
|
321
|
+
cellStyle: ({ cellStyle: W }) => (K) => (unFn(W, K) || "") + (K.col.fixed ? `; ${K.col.fixed}: ${G()[K.x]}px` : "")
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
}, FitColWidthPlugin = (h) => {
|
|
325
|
+
let W = createMutable({ width: 0 });
|
|
326
|
+
createResizeObserver(() => h.scroll_el, (h, G, K) => W.width = K.contentBoxSize[0].inlineSize);
|
|
327
|
+
let G = createMutable([]), K = !1;
|
|
328
|
+
return createEffect(on(() => [W.width, h.props.columns.map((h) => h.width)], async () => {
|
|
329
|
+
if (!W.width || K) return;
|
|
330
|
+
G.length = 0, K = !0, await Promise.resolve();
|
|
331
|
+
let q = (W.width - h.table.getBoundingClientRect().width) / h.props.columns.filter((h) => !h.width).length, J = h.props.columns.map((W, G) => W.width ? null : { width: Math.max((h.ths[G]?.getBoundingClientRect().width || 0) + q, 80) });
|
|
332
|
+
G.push(...J), K = !1;
|
|
333
|
+
})), {
|
|
334
|
+
name: "fit-col-width",
|
|
335
|
+
priority: -Infinity,
|
|
336
|
+
rewriteProps: { columns: ({ columns: h }, { store: W }) => (h = h.map((h, K) => ({
|
|
337
|
+
...h,
|
|
338
|
+
...G?.[K],
|
|
339
|
+
[W.raw]: h[W.raw] ?? h
|
|
340
|
+
})), untrack(() => batch(() => reconcile(h, { key: W.raw })(W.__fit_col_width__cols ??= [])))) }
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
const ScrollPlugin = {
|
|
344
|
+
name: "scroll",
|
|
345
|
+
priority: Infinity,
|
|
346
|
+
rewriteProps: { Table: (h, { store: W }) => (h) => {
|
|
347
|
+
let G = createScrollPosition(() => W.scroll_el), K = createElementSize(() => W.scroll_el), q = createMemo(() => {
|
|
348
|
+
let h = W.scroll_el;
|
|
349
|
+
if (!h) return;
|
|
350
|
+
let q = G.x == 0, J = G.x >= h.scrollWidth - (K.width || 0);
|
|
351
|
+
return q && J ? "" : !q && !J ? "is-scroll-mid" : q ? "is-scroll-left" : J ? "is-scroll-right" : "";
|
|
352
|
+
});
|
|
353
|
+
h = combineProps(h, {
|
|
354
|
+
ref: (h) => W.scroll_el = h,
|
|
355
|
+
class: "data-table--scroll-view"
|
|
356
|
+
}, { get class() {
|
|
357
|
+
return q();
|
|
358
|
+
} });
|
|
359
|
+
let J = mapArray(() => W.plugins.flatMap((h) => h.layers ?? []), (h) => createComponent(h, W));
|
|
360
|
+
return (() => {
|
|
361
|
+
var G = _tmpl$7(), K = G.firstChild, q = K.nextSibling;
|
|
362
|
+
return spread(G, h, !1, !0), insert(K, J), use((h) => W.table = h, q), insert(q, () => h.children), G;
|
|
363
|
+
})();
|
|
364
|
+
} }
|
|
365
|
+
}, defaultsPlugins = [
|
|
366
|
+
ScrollPlugin,
|
|
367
|
+
BasePlugin,
|
|
368
|
+
CommandPlugin,
|
|
369
|
+
MenuPlugin,
|
|
370
|
+
CellSelectionPlugin,
|
|
371
|
+
StickyHeaderPlugin,
|
|
372
|
+
HeaderGroupPlugin,
|
|
373
|
+
FixedColumnPlugin,
|
|
374
|
+
DragPlugin,
|
|
375
|
+
ClipboardPlugin,
|
|
376
|
+
ExpandPlugin,
|
|
377
|
+
RowSelectionPlugin,
|
|
378
|
+
IndexPlugin,
|
|
379
|
+
EditablePlugin,
|
|
380
|
+
CellMergePlugin,
|
|
381
|
+
TreePlugin,
|
|
382
|
+
FitColWidthPlugin,
|
|
383
|
+
RowGroupPlugin,
|
|
384
|
+
ResizePlugin
|
|
385
|
+
];
|
|
386
|
+
export { Ctx, Intable, ScrollPlugin, src_default as default, defaultsPlugins };
|
package/dist/loading.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { spread, template } from "solid-js/web";
|
|
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;
|
|
5
|
+
})();
|
|
6
|
+
export { loading_default as default };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createMemo } from 'solid-js';
|
|
2
|
+
import { type Plugin } from '../index';
|
|
3
|
+
declare module '../index' {
|
|
4
|
+
interface TableProps {
|
|
5
|
+
/**
|
|
6
|
+
* Per-cell merge config. Return `{ rowspan?, colspan? }` for an anchor cell.
|
|
7
|
+
* Covered cells are hidden automatically.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* merge={(row, col, y, x) => {
|
|
11
|
+
* if (col.id === 'name' && row.name === data[y - 1]?.name) return null
|
|
12
|
+
* if (col.id === 'name') {
|
|
13
|
+
* let rowspan = 1
|
|
14
|
+
* while (data[y + rowspan]?.name === row.name) rowspan++
|
|
15
|
+
* return rowspan > 1 ? { rowspan } : null
|
|
16
|
+
* }
|
|
17
|
+
* }}
|
|
18
|
+
*/
|
|
19
|
+
merge?: (row: any, col: TableColumn, y: number, x: number) => {
|
|
20
|
+
rowspan?: number;
|
|
21
|
+
colspan?: number;
|
|
22
|
+
} | null | void;
|
|
23
|
+
}
|
|
24
|
+
interface TableColumn {
|
|
25
|
+
/**
|
|
26
|
+
* Shorthand: auto-merge consecutive rows in this column that share the same cell value.
|
|
27
|
+
* Equivalent to writing a `merge` function that compares adjacent row values.
|
|
28
|
+
*/
|
|
29
|
+
mergeRow?: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface TableStore {
|
|
32
|
+
/** Pre-computed merge result: anchor spans and covered cell keys. */
|
|
33
|
+
_mergeMap?: ReturnType<typeof createMemo<MergeMap>>;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
type CellKey = `${number},${number}`;
|
|
37
|
+
interface MergeMap {
|
|
38
|
+
spans: Map<CellKey, {
|
|
39
|
+
rowspan: number;
|
|
40
|
+
colspan: number;
|
|
41
|
+
}>;
|
|
42
|
+
covered: Set<CellKey>;
|
|
43
|
+
}
|
|
44
|
+
export declare const CellMergePlugin: Plugin;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createComponent } from "solid-js/web";
|
|
2
|
+
import { Show, createMemo } from "solid-js";
|
|
3
|
+
import { combineProps } from "@solid-primitives/props";
|
|
4
|
+
function buildMergeMap(e, t, n) {
|
|
5
|
+
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
6
|
+
for (let a = 0; a < e.length; a++) for (let o = 0; o < t.length; o++) {
|
|
7
|
+
let s = `${a},${o}`;
|
|
8
|
+
if (i.has(s)) continue;
|
|
9
|
+
let c = t[o], l = e[a], u = 1, d = 1;
|
|
10
|
+
if (n) {
|
|
11
|
+
let e = n(l, c, a, o);
|
|
12
|
+
e && (u = e.rowspan ?? 1, d = e.colspan ?? 1);
|
|
13
|
+
} else if (c.mergeRow) for (; a + u < e.length && e[a + u]?.[c.id] === l[c.id];) u++;
|
|
14
|
+
if (u > 1 || d > 1) {
|
|
15
|
+
r.set(s, {
|
|
16
|
+
rowspan: u,
|
|
17
|
+
colspan: d
|
|
18
|
+
});
|
|
19
|
+
for (let e = 0; e < u; e++) for (let t = 0; t < d; t++) e === 0 && t === 0 || i.add(`${a + e},${o + t}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
spans: r,
|
|
24
|
+
covered: i
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const CellMergePlugin = {
|
|
28
|
+
name: "cell-merge",
|
|
29
|
+
rewriteProps: {
|
|
30
|
+
Table: ({ Table: t }, { store: r }) => (a) => (r._mergeMap ??= createMemo(() => {
|
|
31
|
+
let { merge: e, data: t, columns: n } = r.props;
|
|
32
|
+
return !e && !n?.some((e) => e.mergeRow) || !t?.length || !n?.length ? {
|
|
33
|
+
spans: /* @__PURE__ */ new Map(),
|
|
34
|
+
covered: /* @__PURE__ */ new Set()
|
|
35
|
+
} : buildMergeMap(t, n, e);
|
|
36
|
+
}), createComponent(t, a)),
|
|
37
|
+
Td: ({ Td: n }, { store: i }) => (a) => {
|
|
38
|
+
let o = () => `${a.y},${a.x}`, s = () => i._mergeMap?.().covered.has(o()) ?? !1, c = () => i._mergeMap?.().spans.get(o());
|
|
39
|
+
return a = combineProps(a, {
|
|
40
|
+
get rowspan() {
|
|
41
|
+
return c()?.rowspan;
|
|
42
|
+
},
|
|
43
|
+
get colspan() {
|
|
44
|
+
return c()?.colspan;
|
|
45
|
+
}
|
|
46
|
+
}), createComponent(Show, {
|
|
47
|
+
get when() {
|
|
48
|
+
return !s();
|
|
49
|
+
},
|
|
50
|
+
get children() {
|
|
51
|
+
return createComponent(n, a);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
newRow: ({ newRow: e }, { store: t }) => function(n) {
|
|
56
|
+
let r = e(n), { data: i, columns: a, merge: o } = t.props;
|
|
57
|
+
return !i?.length || !a?.length || a.forEach((e, a) => {
|
|
58
|
+
if (e.mergeRow) {
|
|
59
|
+
let t = i[n] ?? i[n - 1];
|
|
60
|
+
t != null && (r[e.id] ??= t[e.id]);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (o && t._mergeMap) {
|
|
64
|
+
let o = `${n},${a}`;
|
|
65
|
+
if (!t._mergeMap().covered.has(o) || !t._mergeMap().spans.has(o)) return;
|
|
66
|
+
for (let o = n; o >= 0; o--) {
|
|
67
|
+
let n = `${o},${a}`, s = t._mergeMap().spans.get(n);
|
|
68
|
+
if (s && s.rowspan > 1) {
|
|
69
|
+
r[e.id] ??= i[o]?.[e.id];
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}), r;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export { CellMergePlugin };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Plugin } from '..';
|
|
2
|
+
declare module '../index' {
|
|
3
|
+
interface TableProps {
|
|
4
|
+
}
|
|
5
|
+
interface TableStore {
|
|
6
|
+
selected: {
|
|
7
|
+
start: number[];
|
|
8
|
+
end: number[];
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
interface Commands {
|
|
12
|
+
getAreaRows(): any[];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export declare const CellSelectionPlugin: Plugin;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { usePointerDrag } from "../hooks/index.js";
|
|
2
|
+
import { createComponent, memo, mergeProps, template } from "solid-js/web";
|
|
3
|
+
import { batch, createMemo } from "solid-js";
|
|
4
|
+
import { combineProps } from "@solid-primitives/props";
|
|
5
|
+
var _tmpl$ = /* @__PURE__ */ template("<div class=area>"), inrange = (e, i, a) => e <= a && e >= i;
|
|
6
|
+
const CellSelectionPlugin = {
|
|
7
|
+
name: "cell-selection",
|
|
8
|
+
store: () => ({ selected: {
|
|
9
|
+
start: [],
|
|
10
|
+
end: []
|
|
11
|
+
} }),
|
|
12
|
+
commands: (e) => ({ getAreaRows() {
|
|
13
|
+
let { start: i, end: a } = e.selected, [o, s] = [i[1], a[1]].sort((e, i) => e - i);
|
|
14
|
+
return e.props.data.slice(o, s + 1);
|
|
15
|
+
} }),
|
|
16
|
+
rewriteProps: {
|
|
17
|
+
Table: ({ Table: a }, { store: o }) => (s) => (o.cellSelectionRect ??= createMemo(() => {
|
|
18
|
+
let { start: e, end: i } = o.selected, a = [e[0], i[0]].sort((e, i) => e - i), s = [e[1], i[1]].sort((e, i) => e - i);
|
|
19
|
+
return {
|
|
20
|
+
xs: a,
|
|
21
|
+
ys: s
|
|
22
|
+
};
|
|
23
|
+
}), usePointerDrag(() => o.table, {
|
|
24
|
+
preventDefault: !1,
|
|
25
|
+
start(e, i, a) {
|
|
26
|
+
batch(() => {
|
|
27
|
+
let a = (e) => e.composedPath().find((e) => e.tagName == "TH" || e.tagName == "TD"), s = (e) => [e.getAttribute("x"), e.getAttribute("y")], c = a(e);
|
|
28
|
+
if (c && !(e.buttons != 1 && c.classList.contains("range-selected"))) {
|
|
29
|
+
if (c.tagName == "TH") {
|
|
30
|
+
let [e, l] = s(c);
|
|
31
|
+
if (e == null) return;
|
|
32
|
+
o.selected.start = [+e, 0], o.selected.end = [+e, Infinity], i((e) => {
|
|
33
|
+
let i = a(e);
|
|
34
|
+
if (!i) return;
|
|
35
|
+
let [c, l] = s(i);
|
|
36
|
+
c != null && (o.selected.end = [+c, Infinity]);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (c.classList.contains("index")) {
|
|
40
|
+
let [e, l] = s(c);
|
|
41
|
+
if (e == null || l == null) return;
|
|
42
|
+
o.selected.start = [0, +l], o.selected.end = [Infinity, +l], i((e) => {
|
|
43
|
+
let i = a(e);
|
|
44
|
+
if (!i) return;
|
|
45
|
+
let [c, l] = s(i);
|
|
46
|
+
c == null || l == null || (o.selected.end = [Infinity, +l]);
|
|
47
|
+
});
|
|
48
|
+
} else if (c.tagName == "TD") {
|
|
49
|
+
let [e, l] = s(c);
|
|
50
|
+
if (e == null || l == null) return;
|
|
51
|
+
o.selected.start = [+e, +l], o.selected.end = [...o.selected.start], i((e) => {
|
|
52
|
+
let i = a(e);
|
|
53
|
+
if (!i) return;
|
|
54
|
+
let [c, l] = s(i);
|
|
55
|
+
c == null || l == null || (o.selected.end = [+c, +l]);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}), s = combineProps({ class: "select-none" }, s), createComponent(a, s)),
|
|
62
|
+
Th: ({ Th: e }, { store: s }) => (c) => {
|
|
63
|
+
let u = createMemo(() => {
|
|
64
|
+
let { start: e, end: i } = s.selected;
|
|
65
|
+
return inrange(c.x, ...[e[0], i[0]].sort((e, i) => e - i)) ? "col-range-highlight" : "";
|
|
66
|
+
}), d = combineProps(c, { get class() {
|
|
67
|
+
return u();
|
|
68
|
+
} });
|
|
69
|
+
return createComponent(e, mergeProps(d, { get children() {
|
|
70
|
+
return [memo(() => d.children), memo(() => memo(() => !!u())() && _tmpl$())];
|
|
71
|
+
} }));
|
|
72
|
+
},
|
|
73
|
+
Td: ({ Td: e }, { store: s }) => (c) => {
|
|
74
|
+
let u = createMemo(() => {
|
|
75
|
+
let e = "", { xs: i, ys: a } = s.cellSelectionRect(), o = inrange(c.x, i[0], i[1]), l = inrange(c.y, a[0], a[1]);
|
|
76
|
+
return o && l && (e += "range-selected ", c.x == i[0] && (e += "range-selected-l "), c.x == i[1] && (e += "range-selected-r "), c.y == a[0] && (e += "range-selected-t "), c.y == a[1] && (e += "range-selected-b ")), c.col.id == s.$index.id && l && (e += "row-range-highlight "), e;
|
|
77
|
+
}), d = combineProps(c, {
|
|
78
|
+
get class() {
|
|
79
|
+
return u();
|
|
80
|
+
},
|
|
81
|
+
tabindex: -1
|
|
82
|
+
});
|
|
83
|
+
return createComponent(e, mergeProps(d, { get children() {
|
|
84
|
+
return [memo(() => d.children), memo(() => memo(() => !!u())() && _tmpl$())];
|
|
85
|
+
} }));
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
keybindings: (e) => {
|
|
89
|
+
let i = () => {
|
|
90
|
+
let i = e.table?.querySelector(`td[x="${e.selected.start[0]}"][y="${e.selected.start[1]}"]`);
|
|
91
|
+
i?.scrollIntoViewIfNeeded(!1), i?.focus();
|
|
92
|
+
};
|
|
93
|
+
return {
|
|
94
|
+
ArrowLeft: () => {
|
|
95
|
+
let { start: a, end: o } = e.selected;
|
|
96
|
+
a.length && (a[0] = o[0] = Math.max(a[0] - 1, 0), o[1] = a[1], i());
|
|
97
|
+
},
|
|
98
|
+
ArrowRight: () => {
|
|
99
|
+
let { start: a, end: o } = e.selected;
|
|
100
|
+
a.length && (a[0] = o[0] = Math.min(a[0] + 1, e.props.columns.length - 1), o[1] = a[1], i());
|
|
101
|
+
},
|
|
102
|
+
ArrowUp: () => {
|
|
103
|
+
let { start: a, end: o } = e.selected;
|
|
104
|
+
a.length && (a[1] = o[1] = Math.max(a[1] - 1, 0), o[0] = a[0], i());
|
|
105
|
+
},
|
|
106
|
+
ArrowDown: () => {
|
|
107
|
+
let { start: a, end: o } = e.selected;
|
|
108
|
+
a.length && (a[1] = o[1] = Math.min(a[1] + 1, e.props.data.length - 1), o[0] = a[0], i());
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
export { CellSelectionPlugin };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Plugin } from '..';
|
|
2
|
+
declare module '../index' {
|
|
3
|
+
interface TableProps {
|
|
4
|
+
}
|
|
5
|
+
interface TableStore {
|
|
6
|
+
commands: Commands;
|
|
7
|
+
}
|
|
8
|
+
interface Plugin {
|
|
9
|
+
commands?: (store: TableStore, commands: Partial<Commands>) => Partial<Commands> & Record<string, any>;
|
|
10
|
+
}
|
|
11
|
+
interface Commands {
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare const CommandPlugin: Plugin;
|