intable 0.0.8 → 0.0.10

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.
Files changed (209) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +379 -132
  3. package/dist/__uno.css +1 -0
  4. package/dist/chevron-right.js +6 -0
  5. package/dist/components/Columns.d.ts +3 -0
  6. package/dist/components/Columns.js +71 -0
  7. package/dist/components/DocTree.d.ts +4 -0
  8. package/dist/components/DocTree.js +32 -0
  9. package/dist/components/Menu.d.ts +1 -0
  10. package/dist/components/Menu.js +107 -0
  11. package/dist/components/Popover.d.ts +14 -0
  12. package/dist/components/Popover.js +41 -0
  13. package/dist/components/RecycleList.d.ts +26 -0
  14. package/dist/components/RecycleList.js +39 -0
  15. package/dist/components/Render.d.ts +4 -0
  16. package/dist/components/Render.js +20 -0
  17. package/dist/components/Split.d.ts +15 -0
  18. package/dist/components/Split.js +76 -0
  19. package/dist/components/Tree.d.ts +37 -0
  20. package/dist/components/Tree.js +82 -0
  21. package/dist/components/utils.d.ts +3 -0
  22. package/dist/components/utils.js +8 -0
  23. package/dist/hooks/index.d.ts +41 -0
  24. package/dist/hooks/index.js +174 -0
  25. package/dist/hooks/useDir.d.ts +11 -0
  26. package/dist/hooks/useDir.js +42 -0
  27. package/dist/hooks/useSelector.d.ts +16 -0
  28. package/dist/hooks/useSelector.js +69 -0
  29. package/dist/hooks/useSort.d.ts +18 -0
  30. package/dist/hooks/useSort.js +83 -0
  31. package/dist/hooks/useVirtualizer.d.ts +30 -0
  32. package/dist/hooks/useVirtualizer.js +97 -0
  33. package/dist/index.d.ts +147 -0
  34. package/dist/index.js +386 -0
  35. package/dist/loading.js +6 -0
  36. package/dist/plugins/CellChangeHighlightPlugin.d.ts +2 -0
  37. package/dist/plugins/CellChangeHighlightPlugin.js +4 -0
  38. package/dist/plugins/CellMergePlugin.d.ts +45 -0
  39. package/dist/plugins/CellMergePlugin.js +78 -0
  40. package/dist/plugins/CellSelectionPlugin.d.ts +15 -0
  41. package/dist/plugins/CellSelectionPlugin.js +116 -0
  42. package/dist/plugins/CommandPlugin.d.ts +14 -0
  43. package/dist/plugins/CommandPlugin.js +31 -0
  44. package/dist/plugins/CopyPastePlugin.d.ts +14 -0
  45. package/dist/plugins/CopyPastePlugin.js +47 -0
  46. package/dist/plugins/DiffPlugin.d.ts +29 -0
  47. package/dist/plugins/DiffPlugin.js +67 -0
  48. package/dist/plugins/DragPlugin.d.ts +14 -0
  49. package/dist/plugins/DragPlugin.js +48 -0
  50. package/dist/plugins/EditablePlugin.d.ts +51 -0
  51. package/dist/plugins/EditablePlugin.js +177 -0
  52. package/dist/plugins/ExpandPlugin.d.ts +18 -0
  53. package/dist/plugins/ExpandPlugin.js +46 -0
  54. package/dist/plugins/HeaderGroup.d.ts +11 -0
  55. package/dist/plugins/HeaderGroup.js +171 -0
  56. package/dist/plugins/HistoryPlugin.d.ts +10 -0
  57. package/dist/plugins/HistoryPlugin.js +27 -0
  58. package/dist/plugins/MenuPlugin.d.ts +19 -0
  59. package/dist/plugins/MenuPlugin.js +132 -0
  60. package/dist/plugins/RenderPlugin/components.d.ts +5 -0
  61. package/dist/plugins/RenderPlugin/components.js +87 -0
  62. package/dist/plugins/RenderPlugin/index.d.ts +30 -0
  63. package/dist/plugins/RenderPlugin/index.js +49 -0
  64. package/dist/plugins/ResizePlugin.d.ts +27 -0
  65. package/dist/plugins/ResizePlugin.js +82 -0
  66. package/dist/plugins/RowGroupPlugin.d.ts +18 -0
  67. package/dist/plugins/RowGroupPlugin.js +89 -0
  68. package/dist/plugins/RowSelectionPlugin.d.ts +20 -0
  69. package/dist/plugins/RowSelectionPlugin.js +42 -0
  70. package/dist/plugins/TreePlugin.d.ts +24 -0
  71. package/dist/plugins/TreePlugin.js +110 -0
  72. package/dist/plugins/VirtualScrollPlugin.d.ts +15 -0
  73. package/dist/plugins/VirtualScrollPlugin.js +123 -0
  74. package/dist/plugins/ZodValidatorPlugin.d.ts +38 -0
  75. package/dist/plugins/ZodValidatorPlugin.js +12 -0
  76. package/dist/plus.js +6 -0
  77. package/dist/rolldown_runtime.js +9 -0
  78. package/dist/style.css +3 -0
  79. package/{packages/intable/src → dist}/theme/antd.scss +42 -42
  80. package/{packages/intable/src → dist}/theme/dark.scss +46 -46
  81. package/{packages/intable/src → dist}/theme/element-plus.scss +38 -38
  82. package/{packages/intable/src → dist}/theme/github.scss +80 -80
  83. package/{packages/intable/src → dist}/theme/material.scss +73 -73
  84. package/{packages/intable/src → dist}/theme/shadcn.scss +66 -66
  85. package/{packages/intable/src → dist}/theme/stripe.scss +57 -57
  86. package/dist/tree.d.ts +1 -0
  87. package/dist/tree.js +12 -0
  88. package/dist/types/auto-imports.d.js +0 -0
  89. package/dist/utils.d.ts +31 -0
  90. package/dist/utils.js +71 -0
  91. package/dist/wc.d.ts +1 -0
  92. package/dist/wc.js +21 -0
  93. package/dist/web-component.d.ts +1 -0
  94. package/dist/web-component.js +2 -0
  95. package/dist/x.js +6 -0
  96. package/package.json +38 -35
  97. package/.github/copilot-instructions.md +0 -102
  98. package/docs/index-BaMALNy6.css +0 -1
  99. package/docs/index-CDN48t9E.js +0 -3
  100. package/docs/index-Cc4RNkLY.css +0 -1
  101. package/docs/index-MRnbkYmU.js +0 -3
  102. package/docs/index.html +0 -15
  103. package/docs/vite.svg +0 -1
  104. package/index.html +0 -13
  105. package/packages/intable/README.md +0 -379
  106. package/packages/intable/package.json +0 -51
  107. package/packages/intable/src/assets/ClearFormat.svg +0 -3
  108. package/packages/intable/src/assets/Forms.svg +0 -4
  109. package/packages/intable/src/assets/MergeCell.svg +0 -4
  110. package/packages/intable/src/assets/SplitCell.svg +0 -4
  111. package/packages/intable/src/assets/gap.svg +0 -3
  112. package/packages/intable/src/assets/loading.svg +0 -12
  113. package/packages/intable/src/assets/paint.svg +0 -9
  114. package/packages/intable/src/assets/solid.svg +0 -1
  115. package/packages/intable/src/components/Columns.tsx +0 -86
  116. package/packages/intable/src/components/DocTree.tsx +0 -36
  117. package/packages/intable/src/components/Menu.tsx +0 -109
  118. package/packages/intable/src/components/Popover.tsx +0 -55
  119. package/packages/intable/src/components/RecycleList.tsx +0 -99
  120. package/packages/intable/src/components/Render.tsx +0 -26
  121. package/packages/intable/src/components/Split.tsx +0 -56
  122. package/packages/intable/src/components/Tree.tsx +0 -115
  123. package/packages/intable/src/components/utils.tsx +0 -12
  124. package/packages/intable/src/hooks/index.ts +0 -200
  125. package/packages/intable/src/hooks/useDir.ts +0 -78
  126. package/packages/intable/src/hooks/useSelector.ts +0 -91
  127. package/packages/intable/src/hooks/useSort.tsx +0 -118
  128. package/packages/intable/src/hooks/useVirtualizer.ts +0 -180
  129. package/packages/intable/src/index.tsx +0 -489
  130. package/packages/intable/src/plugins/CellChangeHighlightPlugin.tsx +0 -5
  131. package/packages/intable/src/plugins/CellMergePlugin.tsx +0 -153
  132. package/packages/intable/src/plugins/CellSelectionPlugin.tsx +0 -175
  133. package/packages/intable/src/plugins/CommandPlugin.tsx +0 -74
  134. package/packages/intable/src/plugins/CopyPastePlugin.tsx +0 -99
  135. package/packages/intable/src/plugins/DiffPlugin.tsx +0 -120
  136. package/packages/intable/src/plugins/DragPlugin.tsx +0 -81
  137. package/packages/intable/src/plugins/EditablePlugin.tsx +0 -252
  138. package/packages/intable/src/plugins/ExpandPlugin.tsx +0 -80
  139. package/packages/intable/src/plugins/HeaderGroup.tsx +0 -289
  140. package/packages/intable/src/plugins/HistoryPlugin.tsx +0 -49
  141. package/packages/intable/src/plugins/MenuPlugin.tsx +0 -195
  142. package/packages/intable/src/plugins/RenderPlugin/components.tsx +0 -51
  143. package/packages/intable/src/plugins/RenderPlugin/index.tsx +0 -81
  144. package/packages/intable/src/plugins/ResizePlugin.tsx +0 -122
  145. package/packages/intable/src/plugins/RowGroupPlugin.tsx +0 -122
  146. package/packages/intable/src/plugins/RowSelectionPlugin.tsx +0 -65
  147. package/packages/intable/src/plugins/TreePlugin.tsx +0 -212
  148. package/packages/intable/src/plugins/VirtualScrollPlugin.tsx +0 -190
  149. package/packages/intable/src/plugins/ZodValidatorPlugin.tsx +0 -61
  150. package/packages/intable/src/style.scss +0 -244
  151. package/packages/intable/src/tree.ts +0 -13
  152. package/packages/intable/src/types/auto-imports.d.ts +0 -13
  153. package/packages/intable/src/utils.ts +0 -122
  154. package/packages/intable/src/wc.tsx +0 -35
  155. package/packages/intable/src/web-component.ts +0 -1
  156. package/packages/react/package.json +0 -36
  157. package/packages/react/src/index.ts +0 -44
  158. package/packages/react/src/plugins/antd.ts +0 -94
  159. package/packages/react/src/style.scss +0 -12
  160. package/packages/react/src/types/auto-imports.d.ts +0 -10
  161. package/packages/vue/package.json +0 -34
  162. package/packages/vue/src/index.ts +0 -63
  163. package/packages/vue/src/plugins/element-plus.ts +0 -69
  164. package/packages/vue/src/style.scss +0 -12
  165. package/packages/vue/src/types/auto-imports.d.ts +0 -10
  166. package/pnpm-workspace.yaml +0 -2
  167. package/public/vite.svg +0 -1
  168. package/scripts/build.js +0 -184
  169. package/scripts/publish.js +0 -95
  170. package/src/assets/ClearFormat.svg +0 -3
  171. package/src/assets/Forms.svg +0 -4
  172. package/src/assets/MergeCell.svg +0 -4
  173. package/src/assets/SplitCell.svg +0 -4
  174. package/src/assets/gap.svg +0 -3
  175. package/src/assets/loading.svg +0 -12
  176. package/src/assets/paint.svg +0 -9
  177. package/src/assets/solid.svg +0 -1
  178. package/src/demo-vue.ts +0 -54
  179. package/src/index.scss +0 -105
  180. package/src/index.tsx +0 -20
  181. package/src/pages/demo/BasicDemo.tsx +0 -19
  182. package/src/pages/demo/CellMergeDemo.tsx +0 -41
  183. package/src/pages/demo/CellSelectionDemo.tsx +0 -24
  184. package/src/pages/demo/CompositeDemo.tsx +0 -60
  185. package/src/pages/demo/CopyPasteDemo.tsx +0 -26
  186. package/src/pages/demo/DiffDemo.tsx +0 -33
  187. package/src/pages/demo/DragDemo.tsx +0 -25
  188. package/src/pages/demo/EditableDemo.tsx +0 -58
  189. package/src/pages/demo/ExpandDemo.tsx +0 -32
  190. package/src/pages/demo/HeaderGroupDemo.tsx +0 -36
  191. package/src/pages/demo/HistoryDemo.tsx +0 -28
  192. package/src/pages/demo/ReactDemo.tsx +0 -59
  193. package/src/pages/demo/ResizeDemo.tsx +0 -24
  194. package/src/pages/demo/RowGroupDemo.tsx +0 -43
  195. package/src/pages/demo/RowSelectionDemo.tsx +0 -27
  196. package/src/pages/demo/TreeDemo.tsx +0 -45
  197. package/src/pages/demo/VirtualScrollDemo.tsx +0 -21
  198. package/src/pages/demo/helpers.tsx +0 -39
  199. package/src/pages/demo/index.tsx +0 -180
  200. package/src/pages/index.tsx +0 -2
  201. package/src/pages/website.scss +0 -37
  202. package/src/pages/website.tsx +0 -651
  203. package/src/styles/index.scss +0 -172
  204. package/src/types/auto-imports.d.ts +0 -13
  205. package/stats.html +0 -4949
  206. package/tsconfig.app.json +0 -34
  207. package/tsconfig.json +0 -7
  208. package/tsconfig.node.json +0 -26
  209. package/vite.config.ts +0 -70
@@ -0,0 +1,174 @@
1
+ import { unFn } from "../utils.js";
2
+ import { $PROXY, batch, createComputed, createEffect, createMemo, createRenderEffect, createRoot, createSignal, getOwner, mergeProps, on, onCleanup, runWithOwner, untrack } from "solid-js";
3
+ import { $RAW, createMutable } from "solid-js/store";
4
+ import { isFunction, isPromise, mapValues } from "es-toolkit";
5
+ import { createEventListener, createEventListenerMap } from "@solid-primitives/event-listener";
6
+ import { createPointerListeners } from "@solid-primitives/pointer";
7
+ import { access } from "@solid-primitives/utils";
8
+ import { makePersisted, storageSync } from "@solid-primitives/storage";
9
+ import { createMutationObserver } from "@solid-primitives/mutation-observer";
10
+ import { castArray } from "es-toolkit/compat";
11
+ import { createKeybindingsHandler } from "tinykeys";
12
+ function usePointerDrag(h, B) {
13
+ B = mergeProps({ preventDefault: !0 }, B), createPointerListeners({
14
+ target: h,
15
+ passive: !1,
16
+ onDown(h) {
17
+ B.preventDefault && h.preventDefault();
18
+ let [V, H] = [h.x, h.y], U, W;
19
+ B.start?.(h, (h) => U = h, (h) => W = h), createRoot((B) => {
20
+ createPointerListeners({
21
+ target: document,
22
+ onMove(h) {
23
+ let [B, W] = [h.x - V, h.y - H];
24
+ U?.(h, {
25
+ sx: V,
26
+ sy: H,
27
+ ox: B,
28
+ oy: W
29
+ });
30
+ },
31
+ onUp() {
32
+ W?.(h), B(), U = void 0, W = void 0;
33
+ }
34
+ }), createEventListenerMap(document, { drop: B });
35
+ });
36
+ }
37
+ });
38
+ }
39
+ function model(h, B) {
40
+ let [V, H] = B();
41
+ createRenderEffect(() => h.value = V()), h.addEventListener("input", (h) => H(h.target.value));
42
+ }
43
+ function toSignle(h, B) {
44
+ return [() => h[B], (V) => h[B] = V];
45
+ }
46
+ function useDark() {
47
+ let h = (h) => h == "dark" || V() && !h, B = (h) => h ? "dark" : "light", V = () => window.matchMedia("(prefers-color-scheme: dark)").matches, H = makePersisted(createSignal(V()), {
48
+ name: "color-schema",
49
+ storage: localStorage,
50
+ sync: storageSync,
51
+ serialize: B,
52
+ deserialize: h
53
+ });
54
+ return createEffect(() => document.documentElement.classList[H[0]() ? "add" : "remove"]("dark")), createEffect(() => window.dispatchEvent(new StorageEvent("storage", {
55
+ key: "color-schema",
56
+ newValue: B(H[0]())
57
+ }))), H;
58
+ }
59
+ function useMemoAsync(h, B) {
60
+ let V = Symbol(), [U, W] = createSignal(B);
61
+ return createComputed(async () => {
62
+ let B = h(untrack(U)), H = B instanceof Promise ? await new Promise((h) => {
63
+ B.then(h), onCleanup(() => h(V));
64
+ }) : B;
65
+ H == V || W(() => H);
66
+ }), U;
67
+ }
68
+ function useSignle2(h, B) {
69
+ let V = createSignal(isFunction(h) ? void 0 : h), U = (h) => {
70
+ let V = B?.before?.(h);
71
+ return isPromise(V) ? V.then((B) => B === void 0 ? h : B) : V ?? h;
72
+ }, W = useMemoAsync(() => U(V[0]()));
73
+ if (isFunction(h)) {
74
+ let B = useMemoAsync(() => U(h()));
75
+ createComputed(() => V[1](B()));
76
+ }
77
+ return [W, V[1]];
78
+ }
79
+ var $MEMO = Symbol();
80
+ function toReactive(V) {
81
+ let H = () => unFn(V), U = () => !0, W = (h) => ((h) => typeof h == "function" && $MEMO in h ? h() : h)(H()[h]);
82
+ return new Proxy(Object.create(null), {
83
+ get: (h, V, U) => V == $PROXY || V == $RAW ? U : ((h) => typeof h == "function" && $MEMO in h ? h() : h)(H()[V]),
84
+ set: U,
85
+ defineProperty: (h, B, V) => Object.defineProperty(H(), B, V),
86
+ deleteProperty: U,
87
+ getPrototypeOf: () => Object.getPrototypeOf(H()),
88
+ has: (h, V) => V == $PROXY || V in H(),
89
+ ownKeys: (h) => Object.keys(H()),
90
+ getOwnPropertyDescriptor: (h, B) => ({
91
+ enumerable: !0,
92
+ configurable: !0,
93
+ get() {
94
+ return W(B);
95
+ },
96
+ set: U
97
+ })
98
+ });
99
+ }
100
+ function useMemo(h) {
101
+ let B = createMemo(h);
102
+ return B[$MEMO] = 1, B;
103
+ }
104
+ function useHover(h) {
105
+ let [B, V] = createSignal(!1);
106
+ return createEventListener(h, "pointerenter", () => V(!0)), createEventListener(h, "pointerleave", () => V(!1)), B;
107
+ }
108
+ function useMouseDown(h) {
109
+ let [B, V] = createSignal(!1);
110
+ return createEventListener(h, "pointerdown", () => V(!0)), createEventListener(document.body, "pointerup", () => V(!1)), B;
111
+ }
112
+ function useClicked(h) {
113
+ let [B, V] = createSignal(!1), H = () => castArray(access(h));
114
+ return createEventListener(() => H().map((h) => h?.getRootNode()), "click", (h) => V(H().some((B) => B?.contains(h.target)))), B;
115
+ }
116
+ function useMutation(h, B, V) {
117
+ let H = createSignal(V());
118
+ return createMutationObserver(h, B, (h) => H[1](V())), H[0];
119
+ }
120
+ function useTinykeys(h, B) {
121
+ createEventListener(h, "keydown", createKeybindingsHandler({ ...mapValues(B, (h) => (B) => {
122
+ B.preventDefault(), h(B);
123
+ }) }));
124
+ }
125
+ function useHistory([h, B]) {
126
+ let V = 1, H = createMutable({
127
+ index: -1,
128
+ history: []
129
+ }), U = () => (H.index = 0, H.history = [h()]), W = () => H.index > 0, G = () => H.index < H.history.length - 1;
130
+ return createRenderEffect(on(h, (h) => {
131
+ if (h != null) {
132
+ if (!V) return V = 1;
133
+ G() && (H.history = H.history.slice(0, H.index + 1)), H.history[++H.index] = h;
134
+ }
135
+ })), {
136
+ undo: () => W() && ((V = 0) || B(H.history[--H.index])),
137
+ redo: () => G() && ((V = 0) || B(H.history[++H.index])),
138
+ clear: U,
139
+ get index() {
140
+ return H.index;
141
+ },
142
+ get history() {
143
+ return H.history;
144
+ }
145
+ };
146
+ }
147
+ function createShallowState(h) {
148
+ let V = getOwner(), H = {}, U = (h, B) => H[h] ??= runWithOwner(V, () => createSignal(B));
149
+ for (let B in h) U(B, h[B]);
150
+ return new Proxy(h, {
151
+ get(h, V, H) {
152
+ return V == $PROXY ? H : U(V)[0]();
153
+ },
154
+ set(h, B, V) {
155
+ return h[B] = V, U(B, V)[1](() => V), !0;
156
+ },
157
+ deleteProperty(h, B) {
158
+ return U(B)[1](void 0), delete h[B], delete H[B], !0;
159
+ },
160
+ has: (h, V) => V == $PROXY || V in H,
161
+ ownKeys: (h) => Reflect.ownKeys(H)
162
+ });
163
+ }
164
+ function useMemoState(h) {
165
+ let B = createShallowState({});
166
+ return createComputed(() => {
167
+ let H = { ...h() };
168
+ untrack(() => batch(() => {
169
+ for (let h in B) h in H || delete B[h];
170
+ Object.assign(B, H);
171
+ }));
172
+ }), B;
173
+ }
174
+ export { createShallowState, model, toReactive, toSignle, useClicked, useDark, useHistory, useHover, useMemo, useMemoAsync, useMemoState, useMouseDown, useMutation, usePointerDrag, useSignle2, useTinykeys };
@@ -0,0 +1,11 @@
1
+ import { type MaybeAccessor } from '@solid-primitives/utils';
2
+ interface UseDirOptions {
3
+ ref: MaybeAccessor<HTMLElement | undefined>;
4
+ list?: MaybeAccessor<HTMLElement | undefined>;
5
+ loop?: boolean;
6
+ options?: EventListenerOptions;
7
+ defaultFirst?: boolean;
8
+ }
9
+ export declare function useDir(options: UseDirOptions): void;
10
+ export declare function VDir(el: HTMLElement, options: any): void;
11
+ export {};
@@ -0,0 +1,42 @@
1
+ import { createEffect, mergeProps } from "solid-js";
2
+ import { createEventListener } from "@solid-primitives/event-listener";
3
+ import { access } from "@solid-primitives/utils";
4
+ import { createMutationObserver } from "@solid-primitives/mutation-observer";
5
+ function useDir(a) {
6
+ a = mergeProps({ loop: !0 }, a);
7
+ let o = () => access(a.list) ?? access(a.ref), s = () => access(a.ref) ?? access(a.list);
8
+ createEffect(() => {
9
+ s().tabIndex > -1 || (s().tabIndex = 0);
10
+ }), createEventListener(s, "keydown", (e) => {
11
+ if (![
12
+ "ArrowDown",
13
+ "ArrowUp",
14
+ "Enter"
15
+ ].includes(e.key)) return;
16
+ e.stopPropagation(), e.preventDefault();
17
+ let n = o()?.querySelector(".hover");
18
+ if (e.key == "Enter") {
19
+ n?.click();
20
+ return;
21
+ }
22
+ let r = e.key == "ArrowDown" ? n ? +n?.getAttribute("data-index") + 1 : 0 : e.key == "ArrowUp" ? n ? n?.getAttribute("data-index") - 1 : -1 : 0, i = o()?.querySelector(`[data-index='${r}']`);
23
+ i ? (n?.classList.remove("hover"), i.classList.add("hover")) : a.loop && (n?.classList.remove("hover"), r >= 0 ? o()?.querySelector("[data-index='0']")?.classList.add("hover") : [...o()?.querySelectorAll("[data-index]")].at(-1)?.classList.add("hover"));
24
+ }, a.options), createEffect(() => {
25
+ if (!a.defaultFirst) return;
26
+ let e = o();
27
+ if (!e) return;
28
+ let n = () => {
29
+ e.querySelector(".hover") || e.querySelector("[data-index]")?.classList.add("hover");
30
+ };
31
+ createMutationObserver(e, { childList: !0 }, n), n();
32
+ }), createEventListener(o, "mouseover", () => {
33
+ o()?.querySelector(".hover")?.classList.remove("hover");
34
+ });
35
+ }
36
+ function VDir(e, n) {
37
+ useDir({
38
+ ...n(),
39
+ list: e
40
+ });
41
+ }
42
+ export { VDir, useDir };
@@ -0,0 +1,16 @@
1
+ interface UseSelectorOpt<T> {
2
+ value?: T;
3
+ onChange?: (v: T) => void;
4
+ multiple?: boolean;
5
+ selectable?: (v: any) => boolean;
6
+ }
7
+ export declare function useSelector<T = any>(opt: UseSelectorOpt<T>): {
8
+ clear: () => void;
9
+ set: (v: T) => void;
10
+ has: (key: any) => boolean;
11
+ add: (v: T) => void;
12
+ del: (v: T) => void;
13
+ toggle: (v: T) => void;
14
+ readonly value: T;
15
+ };
16
+ export {};
@@ -0,0 +1,69 @@
1
+ import { toArr } from "../utils.js";
2
+ import { createMemo, createSelector, createSignal } from "solid-js";
3
+ var _Symbol$toStringTag, SingleSet = class {
4
+ static {
5
+ _Symbol$toStringTag = Symbol.toStringTag;
6
+ }
7
+ #value;
8
+ constructor(e) {
9
+ this[_Symbol$toStringTag] = "SingleSet", this.#value = Array.from(e || [])[0];
10
+ }
11
+ add(e) {
12
+ return this.#value = e, this;
13
+ }
14
+ clear() {
15
+ this.#value = void 0;
16
+ }
17
+ delete(e) {
18
+ return this.#value === e ? (this.#value = void 0, !0) : !1;
19
+ }
20
+ forEach(e) {
21
+ this.#value !== void 0 && e.call(this, this.#value, this.#value, this);
22
+ }
23
+ has(e) {
24
+ return this.#value === e;
25
+ }
26
+ get size() {
27
+ return this.#value === void 0 ? 0 : 1;
28
+ }
29
+ entries() {
30
+ return this.values();
31
+ }
32
+ keys() {
33
+ return this.values();
34
+ }
35
+ values() {
36
+ return this.#value === void 0 ? [].entries() : [[this.#value, this.#value]].entries();
37
+ }
38
+ [Symbol.iterator]() {
39
+ return this.values()[Symbol.iterator]();
40
+ }
41
+ };
42
+ function useSelector(a) {
43
+ let { value: o, onChange: s, multiple: c = !1, selectable: l } = a, u = c ? Set : SingleSet, [d, f] = createSignal(new u(toArr(o))), p = createSelector(d, (e, i) => i.has(e)), m = (e) => l ? l(e) : !0, h = () => {
44
+ f(new u()), s?.(b());
45
+ }, g = (i) => {
46
+ m(i) && (f(new u(toArr(i))), s?.(b()));
47
+ }, _ = (e) => {
48
+ if (!m(e)) return;
49
+ let i = new u(d());
50
+ i.add(e), f(i), s?.(b());
51
+ }, v = (e) => {
52
+ let i = new u(d());
53
+ i.delete(e), f(i), s?.(b());
54
+ }, y = (e) => {
55
+ p(e) ? v(e) : _(e);
56
+ }, b = createMemo(() => c ? Array.from(d()) : Array.from(d())[0]);
57
+ return {
58
+ clear: h,
59
+ set: g,
60
+ has: p,
61
+ add: _,
62
+ del: v,
63
+ toggle: y,
64
+ get value() {
65
+ return b();
66
+ }
67
+ };
68
+ }
69
+ export { useSelector };
@@ -0,0 +1,18 @@
1
+ import { type MaybeAccessor } from '@solid-primitives/utils';
2
+ type Awaitable<T> = T | Promise<T>;
3
+ interface UseSortOption {
4
+ enable?: boolean;
5
+ guideLine: any;
6
+ draggable: (el: HTMLElement) => Awaitable<boolean>;
7
+ dragover: (el: HTMLElement) => boolean;
8
+ children: (el: HTMLElement) => HTMLElement[];
9
+ dragend: () => void;
10
+ }
11
+ export declare const useSort: (el: MaybeAccessor<HTMLElement | undefined>, opt: UseSortOption) => {
12
+ style: any;
13
+ drag: any;
14
+ over: any;
15
+ rel: any;
16
+ type: string;
17
+ };
18
+ export {};
@@ -0,0 +1,83 @@
1
+ import { findAsync } from "../utils.js";
2
+ import { Portal, createComponent, memo, mergeProps, spread, template } from "solid-js/web";
3
+ import { createMutable, reconcile } from "solid-js/store";
4
+ import { createEventListenerMap } from "@solid-primitives/event-listener";
5
+ import { access } from "@solid-primitives/utils";
6
+ var _tmpl$ = /* @__PURE__ */ template("<div>");
7
+ const useSort = (l, f) => {
8
+ f = mergeProps({ enable: !0 }, f);
9
+ let p = 0;
10
+ createEventListenerMap(() => f.enable ? access(l) : void 0, {
11
+ async pointerdown(i) {
12
+ let a = p, o = await findAsync(i.composedPath(), (e) => e instanceof HTMLElement && f.draggable(e));
13
+ a == p && o && (i.stopPropagation(), h.drag = o, h.drag?.setAttribute("draggable", "true"));
14
+ },
15
+ pointerup() {
16
+ p++, m();
17
+ },
18
+ pointermove() {
19
+ p++;
20
+ },
21
+ dragstart(e) {
22
+ e.dataTransfer.setDragImage(document.createElement("img"), 0, 0);
23
+ },
24
+ dragover(e) {
25
+ if (!h.drag) return;
26
+ let i = h.over = e.composedPath().filter((e) => e instanceof HTMLElement).find((e) => f.dragover(e)) ?? h.over;
27
+ if (!i) return;
28
+ e.preventDefault(), e.stopPropagation();
29
+ let a = f.children(i);
30
+ if (a) {
31
+ let i = 0, o = Infinity, s = "";
32
+ a.forEach((a, c) => {
33
+ let l = getComputedStyle(a).display, u = ["table-cell", "inline"].some((e) => l.includes(e)), d = a.getBoundingClientRect();
34
+ if (u) {
35
+ let a = Math.sqrt((e.clientX - d.x) ** 2 + (e.clientY - d.y + d.height / 2) ** 2);
36
+ a < o && (i = c, o = a, s = "l"), a = Math.sqrt((e.clientX - d.right) ** 2 + (e.clientY - d.y + d.height / 2) ** 2), a < o && (i = c, o = a, s = "r");
37
+ } else {
38
+ let a = Math.sqrt((e.clientY - d.y) ** 2 + (e.clientX - d.x + d.width / 2) ** 2);
39
+ a < o && (i = c, o = a, s = "t"), a = Math.sqrt((e.clientY - d.bottom) ** 2 + (e.clientX - d.x + d.width / 2) ** 2), a < o && (i = c, o = a, s = "b");
40
+ }
41
+ });
42
+ let c = a[i].getBoundingClientRect(), l = s == "l" || s == "r", u = s == "t" || s == "b";
43
+ h.style = {
44
+ width: `${u ? c.width : 3}px`,
45
+ height: `${u ? 3 : c.height}px`,
46
+ translate: `${u ? c.x : (s == "l" ? c.x : c.right) - 3 / 2}px ${l ? c.y : (s == "t" ? c.y : c.bottom) - 3 / 2}px`
47
+ }, h.rel = a[i], h.type = s == "l" || s == "t" ? "before" : "after";
48
+ } else {
49
+ let e = i.getBoundingClientRect();
50
+ h.style = {
51
+ width: e.width,
52
+ height: e.height,
53
+ translate: `${e.x}px ${e.y}px`
54
+ }, h.rel = i, h.type = "inner";
55
+ }
56
+ },
57
+ dragend() {
58
+ m();
59
+ }
60
+ });
61
+ function m() {
62
+ h.drag?.removeAttribute("draggable"), h.drag && h.rel && f.dragend?.(), reconcile({})(h);
63
+ }
64
+ let h = createMutable({
65
+ style: void 0,
66
+ drag: void 0,
67
+ over: void 0,
68
+ rel: void 0,
69
+ type: ""
70
+ });
71
+ return memo(() => memo(() => !!h.style)() && createComponent(Portal, {
72
+ get mount() {
73
+ return access(l);
74
+ },
75
+ get children() {
76
+ var e = _tmpl$();
77
+ return spread(e, mergeProps(() => f.guideLine, { get style() {
78
+ return h.style;
79
+ } }), !1, !1), e;
80
+ }
81
+ })), h;
82
+ };
83
+ export { useSort };
@@ -0,0 +1,30 @@
1
+ interface VirtualizerOptions {
2
+ enable?: boolean;
3
+ overscan?: number;
4
+ batch?: number;
5
+ getScrollElement: () => Element;
6
+ horizontal?: boolean;
7
+ count: number;
8
+ estimateSize: (i: number) => number;
9
+ extras?: (startIdx: number, endIdx: number) => number[];
10
+ indexAttribute?: string;
11
+ rangeExtractor?: (range: any) => number[];
12
+ }
13
+ export declare function useVirtualizer(opt: VirtualizerOptions): {
14
+ options: VirtualizerOptions;
15
+ startIdx: import("solid-js").Accessor<number>;
16
+ endIdx: import("solid-js").Accessor<number>;
17
+ getTotalSize: () => number;
18
+ resizeItem: (i: number, newSize: number) => void;
19
+ getVirtualItems: import("solid-js").Accessor<{
20
+ start: number;
21
+ end: number;
22
+ index: number;
23
+ }[]>;
24
+ getVirtualItem: (i: number) => {
25
+ start: number;
26
+ end: number;
27
+ index: number;
28
+ };
29
+ };
30
+ export {};
@@ -0,0 +1,97 @@
1
+ import { createComputed, createMemo, createSignal, mergeProps, untrack } from "solid-js";
2
+ import { createElementSize } from "@solid-primitives/resize-observer";
3
+ import { createScrollPosition } from "@solid-primitives/scroll";
4
+ import { uniqBy } from "es-toolkit";
5
+ var FenwickTree = class e {
6
+ constructor(e) {
7
+ this.n = e, this.tree = new Float64Array(e + 1);
8
+ }
9
+ add(e, a) {
10
+ for (e += 1; e <= this.n; e += e & -e) this.tree[e] += a;
11
+ }
12
+ sum(e) {
13
+ let a = 0;
14
+ for (e += 1; e > 0; e -= e & -e) a += this.tree[e];
15
+ return a;
16
+ }
17
+ total() {
18
+ return this.n > 0 ? this.sum(this.n - 1) : 0;
19
+ }
20
+ findByOffset(e) {
21
+ let a = 0;
22
+ for (let o = 1 << Math.floor(Math.log2(this.n || 1)); o > 0; o >>= 1) a + o <= this.n && this.tree[a + o] <= e && (a += o, e -= this.tree[a]);
23
+ return Math.min(a, this.n - 1);
24
+ }
25
+ static build(a) {
26
+ let o = a.length, s = new e(o);
27
+ for (let e = 0; e < o; e++) {
28
+ s.tree[e + 1] += a[e];
29
+ let c = e + 1 + (e + 1 & -(e + 1));
30
+ c <= o && (s.tree[c] += s.tree[e + 1]);
31
+ }
32
+ return s;
33
+ }
34
+ };
35
+ function useVirtualizer(l) {
36
+ l = mergeProps({
37
+ overscan: 0,
38
+ batch: 0,
39
+ enable: !0
40
+ }, l);
41
+ let u = createElementSize(l.getScrollElement), d = createScrollPosition(l.getScrollElement), f = createMemo(() => l.horizontal ? d.x : d.y), p = createMemo(() => l.horizontal ? u.width : u.height), m = [], h = new FenwickTree(0), [g, _] = createSignal(void 0, { equals: !1 });
42
+ createComputed(() => {
43
+ let { count: e } = l;
44
+ untrack(() => {
45
+ if (e !== m.length) {
46
+ if (e > m.length) for (let a = m.length; a < e; a++) m.push(l.estimateSize(a));
47
+ else m.length = e;
48
+ h = FenwickTree.build(m.slice(0, e)), _();
49
+ }
50
+ });
51
+ });
52
+ let v = (e) => ({
53
+ index: e,
54
+ start: e > 0 ? h.sum(e - 1) : 0,
55
+ end: h.sum(e)
56
+ }), y = createMemo((e) => {
57
+ g();
58
+ let { batch: a, overscan: o = 0 } = l, s = h.findByOffset(f()) - o;
59
+ return a && (s > e ? s = s <= e + a ? e : s > e + a * 2 ? s : e + a : s -= a), Math.max(s, 0);
60
+ }, 0), b = createMemo((e) => {
61
+ g();
62
+ let { batch: a, overscan: o = 0 } = l, s = h.findByOffset(f() + p()) + o;
63
+ return a && (s < e ? s = s >= e - a ? e : s < e - a * 2 ? s : e - a : s += a), Math.min(s, l.count - 1);
64
+ }, 0), x = createMemo(() => {
65
+ if (g(), !l.enable) return Array.from({ length: l.count }, (e, a) => v(a));
66
+ let e = [];
67
+ for (let a = y(); a <= b(); a++) e.push(v(a));
68
+ return l.extras && (e.push(...l.extras(y(), b())?.map((e) => v(e)) || []), e = uniqBy(e, (e) => e.index).sort((e, a) => e.index - a.index)), e;
69
+ });
70
+ return {
71
+ options: l,
72
+ startIdx: y,
73
+ endIdx: b,
74
+ getTotalSize: () => (g(), h.total()),
75
+ resizeItem: (e, a) => {
76
+ let o = m[e] ?? 0;
77
+ if (o !== a) {
78
+ if (e < y()) {
79
+ let e = l.getScrollElement();
80
+ (l.horizontal ? e.scrollLeft : e.scrollTop) !== 0 && (l.horizontal ? e.scrollLeft += a - o : e.scrollTop += a - o);
81
+ }
82
+ h.add(e, a - o), m[e] = a, _();
83
+ }
84
+ },
85
+ getVirtualItems: x,
86
+ getVirtualItem: (() => {
87
+ let e = createMemo(() => {
88
+ g();
89
+ let e = {};
90
+ for (let a of x()) e[a.index] = a;
91
+ return e;
92
+ });
93
+ return (a) => e()[a];
94
+ })()
95
+ };
96
+ }
97
+ export { useVirtualizer };
@@ -0,0 +1,147 @@
1
+ import { type JSX, type Component } from 'solid-js';
2
+ import 'virtual:uno.css';
3
+ import './style.scss';
4
+ import './plugins/CellSelectionPlugin';
5
+ import './plugins/CopyPastePlugin';
6
+ import './plugins/EditablePlugin';
7
+ import './plugins/RenderPlugin';
8
+ import './plugins/MenuPlugin';
9
+ import './plugins/CommandPlugin';
10
+ import './plugins/RowSelectionPlugin';
11
+ import './plugins/ResizePlugin';
12
+ import './plugins/DragPlugin';
13
+ import './plugins/RowGroupPlugin';
14
+ import './plugins/ExpandPlugin';
15
+ import './plugins/CellMergePlugin';
16
+ import './plugins/TreePlugin';
17
+ import './plugins/HeaderGroup';
18
+ export declare const Ctx: import("solid-js").Context<{
19
+ props: TableProps2;
20
+ store: TableStore;
21
+ }>;
22
+ type Requireds<T, K extends keyof T> = Pri<Omit<T, K> & Required<Pick<T, K>>>;
23
+ type Pri<T> = {
24
+ [K in keyof T]: T[K];
25
+ };
26
+ type TableProps2 = Requireds<TableProps, ('Table' | 'Thead' | 'Tbody' | 'Tr' | 'Th' | 'Td' | 'EachRows' | 'EachCells' | 'rowKey' | 'data' | 'columns' | 'newRow')>;
27
+ type Each<T = any> = (props: {
28
+ each: T[];
29
+ children: (e: () => any, i: () => number) => JSX.Element;
30
+ }) => JSX.Element;
31
+ type ProcessProps = {
32
+ [K in keyof TableProps]?: (prev: TableProps2, ctx: {
33
+ store: TableStore;
34
+ }) => TableProps[K];
35
+ };
36
+ export interface Plugin {
37
+ name: string;
38
+ priority?: number;
39
+ store?: (store: TableStore) => Partial<TableStore> | void;
40
+ rewriteProps?: ProcessProps;
41
+ layers?: Component<TableStore>[];
42
+ onMount?: (store: TableStore) => void;
43
+ /**
44
+ * Declare keyboard shortcuts for this plugin.
45
+ * Collected and registered as a **single** keydown listener by CommandPlugin.
46
+ * Keys use tinykeys syntax, e.g. `'$mod+Z'`, `'$mod+Shift+K'`.
47
+ */
48
+ keybindings?: (store: TableStore) => Record<string, (e?: KeyboardEvent) => void>;
49
+ }
50
+ export type Plugin$0 = Plugin | ((store: TableStore) => Plugin);
51
+ export interface TableProps {
52
+ columns?: TableColumn[];
53
+ data?: any[];
54
+ index?: boolean;
55
+ border?: boolean;
56
+ stickyHeader?: boolean;
57
+ class?: any;
58
+ style?: any;
59
+ rowKey?: any;
60
+ size?: string;
61
+ newRow?: (i: number) => any;
62
+ Table?: Component<any>;
63
+ Thead?: Component<any>;
64
+ Tbody?: Component<any>;
65
+ Td?: TD;
66
+ Th?: Component<THProps>;
67
+ Tr?: Component<{
68
+ y?: number;
69
+ data?: any;
70
+ style?: any;
71
+ children: JSX.Element;
72
+ }>;
73
+ EachRows?: Each;
74
+ EachCells?: Each<TableColumn>;
75
+ cellClass?: ((props: Omit<TDProps, 'y' | 'data'> & {
76
+ y?: number;
77
+ data?: any;
78
+ }) => string) | string;
79
+ cellStyle?: ((props: Omit<TDProps, 'y' | 'data'> & {
80
+ y?: number;
81
+ data?: any;
82
+ }) => string) | string;
83
+ renderer?: (comp: (props: any) => JSX.Element) => ((props: any) => JSX.Element);
84
+ plugins?: Plugin$0[];
85
+ /**
86
+ * Override or disable individual plugin keybindings.
87
+ * - Override: `{ '$mod+Z': (e) => myUndo() }`
88
+ * - Disable: `{ '$mod+Z': false }`
89
+ */
90
+ keybindings?: Record<string, ((e?: KeyboardEvent) => void) | false>;
91
+ onDataChange?: (data: any[]) => void;
92
+ }
93
+ export type THProps = {
94
+ x: number;
95
+ col: TableColumn;
96
+ children: JSX.Element;
97
+ rowspan?: number;
98
+ colspan?: number;
99
+ style?: any;
100
+ };
101
+ export type TDProps = {
102
+ x: number;
103
+ y: number;
104
+ data: any;
105
+ col: TableColumn;
106
+ children: JSX.Element;
107
+ rowspan?: number;
108
+ colspan?: number;
109
+ };
110
+ export type TD = Component<TDProps>;
111
+ type Obj = Record<string | symbol, any>;
112
+ export interface TableColumn extends Obj {
113
+ id?: any;
114
+ name?: string;
115
+ width?: number;
116
+ fixed?: 'left' | 'right';
117
+ class?: any;
118
+ style?: any;
119
+ props?: (props: any) => JSX.HTMLAttributes<any>;
120
+ }
121
+ type Nullable<T> = T | undefined;
122
+ export interface TableStore extends Obj {
123
+ scroll_el?: HTMLElement;
124
+ table: HTMLElement;
125
+ thead: HTMLElement;
126
+ tbody: HTMLElement;
127
+ ths: Nullable<Element>[];
128
+ thSizes: Nullable<{
129
+ width: number;
130
+ height: number;
131
+ }>[];
132
+ trs: Nullable<Element>[];
133
+ trSizes: Nullable<{
134
+ width: number;
135
+ height: number;
136
+ }>[];
137
+ internal: symbol;
138
+ raw: symbol;
139
+ props: TableProps2;
140
+ rawProps: TableProps;
141
+ plugins: Plugin[];
142
+ }
143
+ export declare const Intable: (props: TableProps) => JSX.Element;
144
+ export default Intable;
145
+ declare function BasePlugin(): Plugin$0;
146
+ export declare const ScrollPlugin: Plugin;
147
+ export declare const defaultsPlugins: (Plugin$0 | typeof BasePlugin)[];