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.
- package/LICENSE +21 -21
- package/README.md +379 -132
- 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 +41 -0
- package/dist/hooks/index.js +174 -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 +116 -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 +67 -0
- package/dist/plugins/DragPlugin.d.ts +14 -0
- package/dist/plugins/DragPlugin.js +48 -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 +89 -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/{packages/intable/src → dist}/theme/antd.scss +42 -42
- package/{packages/intable/src → dist}/theme/dark.scss +46 -46
- package/{packages/intable/src → dist}/theme/element-plus.scss +38 -38
- package/{packages/intable/src → dist}/theme/github.scss +80 -80
- package/{packages/intable/src → dist}/theme/material.scss +73 -73
- package/{packages/intable/src → dist}/theme/shadcn.scss +66 -66
- package/{packages/intable/src → dist}/theme/stripe.scss +57 -57
- 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
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useMemoAsync } from "../hooks/index.js";
|
|
2
|
+
import { Tree } from "./Tree.js";
|
|
3
|
+
import { createComponent, insert, spread, template } from "solid-js/web";
|
|
4
|
+
import { createEffect, createMemo, createSignal, splitProps } from "solid-js";
|
|
5
|
+
import { delay } from "es-toolkit";
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ template("<div class=doc-tree>");
|
|
7
|
+
function DocTree(d) {
|
|
8
|
+
let [f, p] = splitProps(d, ["editor"]), [m, h] = createSignal(0);
|
|
9
|
+
createEffect(() => f.editor.on("update", () => h((e) => ++e)));
|
|
10
|
+
let g = useMemoAsync(() => (m(), delay(300).then(() => f.editor.getJSON())), {}), _ = createMemo(() => function e(s, c = [], l = []) {
|
|
11
|
+
if (s.type === "heading") {
|
|
12
|
+
let e = c.length;
|
|
13
|
+
for (; e-- && !(c[e].level < s.attrs.level););
|
|
14
|
+
let u = {
|
|
15
|
+
label: s.content?.map((e) => e.text).join(""),
|
|
16
|
+
level: s.attrs.level
|
|
17
|
+
};
|
|
18
|
+
c.push(u), e > -1 ? (c[e].children ??= []).push(u) : l.push(u);
|
|
19
|
+
} else s.content?.forEach((s) => e(s, c, l));
|
|
20
|
+
return l;
|
|
21
|
+
}(g()));
|
|
22
|
+
return (() => {
|
|
23
|
+
var e = _tmpl$();
|
|
24
|
+
return spread(e, p, !1, !0), insert(e, createComponent(Tree, {
|
|
25
|
+
get data() {
|
|
26
|
+
return _();
|
|
27
|
+
},
|
|
28
|
+
class: "min-h-40 max-h-100 overflow-auto"
|
|
29
|
+
})), e;
|
|
30
|
+
})();
|
|
31
|
+
}
|
|
32
|
+
export { DocTree };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Menu(props: any): import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { unFn } from "../utils.js";
|
|
2
|
+
import { useSignle2 } from "../hooks/index.js";
|
|
3
|
+
import { createRender } from "./Render.js";
|
|
4
|
+
import { VDir } from "../hooks/useDir.js";
|
|
5
|
+
import { Popover } from "./Popover.js";
|
|
6
|
+
import loading_default from "../loading.js";
|
|
7
|
+
import { className, createComponent, effect, insert, memo, mergeProps, spread, template, use } from "solid-js/web";
|
|
8
|
+
import { children, createContext, createEffect, createMemo, createSignal, onMount, splitProps, useContext } from "solid-js";
|
|
9
|
+
import { createMutable } from "solid-js/store";
|
|
10
|
+
import { combineProps } from "@solid-primitives/props";
|
|
11
|
+
import { delay } from "es-toolkit";
|
|
12
|
+
import { pointerHover } from "@solid-primitives/pointer";
|
|
13
|
+
import { isEmpty } from "es-toolkit/compat";
|
|
14
|
+
import { autoUpdate, createFloating, offset } from "floating-ui-solid";
|
|
15
|
+
var _tmpl$ = /* @__PURE__ */ template("<div><div>"), _tmpl$2 = /* @__PURE__ */ template("<div>"), _tmpl$3 = /* @__PURE__ */ template("<div class=\"px-4 py-2 op40\">无内容");
|
|
16
|
+
function Menu(k) {
|
|
17
|
+
let P = createContext({ deep: 0 }), F = createRender({
|
|
18
|
+
is: (D) => {
|
|
19
|
+
let O = useContext(P), [A, j] = splitProps(D, [
|
|
20
|
+
"children",
|
|
21
|
+
"label",
|
|
22
|
+
"icon",
|
|
23
|
+
"isActive",
|
|
24
|
+
"cb",
|
|
25
|
+
"menu",
|
|
26
|
+
"popover"
|
|
27
|
+
]), M = createMemo(() => k.x && O.deep == 1), N, [F, L] = createSignal(), [R, z] = useSignle2(!1, { before: () => delay(100) }), B = createMemo(() => F() ? createFloating({
|
|
28
|
+
strategy: "fixed",
|
|
29
|
+
placement: M() ? "bottom-start" : "right-start",
|
|
30
|
+
...A.menu,
|
|
31
|
+
elements: {
|
|
32
|
+
reference: () => N,
|
|
33
|
+
floating: F
|
|
34
|
+
},
|
|
35
|
+
whileElementsMounted(i, E, D) {
|
|
36
|
+
return autoUpdate(i, E, D, {
|
|
37
|
+
ancestorResize: !0,
|
|
38
|
+
elementResize: !0,
|
|
39
|
+
layoutShift: !0,
|
|
40
|
+
ancestorScroll: !0
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}).floatingStyles : void 0);
|
|
44
|
+
createEffect(() => {
|
|
45
|
+
F() && Object.assign(F().style, B()?.() ?? {});
|
|
46
|
+
});
|
|
47
|
+
let V = createMutable({ loading: !1 });
|
|
48
|
+
async function H() {
|
|
49
|
+
if (V.loading) return;
|
|
50
|
+
let i = A.cb?.();
|
|
51
|
+
if (i instanceof Promise) try {
|
|
52
|
+
await i, V.loading = !0;
|
|
53
|
+
} finally {
|
|
54
|
+
V.loading = !1, k.onAction?.(A);
|
|
55
|
+
}
|
|
56
|
+
else k.onAction?.(A);
|
|
57
|
+
}
|
|
58
|
+
return onMount(() => {
|
|
59
|
+
createComponent(Popover, mergeProps({
|
|
60
|
+
strategy: "fixed",
|
|
61
|
+
reference: N,
|
|
62
|
+
portal: N
|
|
63
|
+
}, () => D.popover, { get middleware() {
|
|
64
|
+
return [offset({ mainAxis: 4 })];
|
|
65
|
+
} }));
|
|
66
|
+
}), children(() => A.children), (() => {
|
|
67
|
+
var E = _tmpl$(), D = E.firstChild;
|
|
68
|
+
use(pointerHover, E, () => z);
|
|
69
|
+
var O = N;
|
|
70
|
+
return typeof O == "function" ? use(O, E) : N = E, spread(E, mergeProps(() => combineProps({ class: `li flex aic rd-2 ${M() ? "my-1 p-1" : "mx-1 pl-1 pr-4 py-1"} ${unFn(A.isActive) && "active"}` }, j), { "on:click": H }), !1, !0), insert(D, (() => {
|
|
71
|
+
var i = memo(() => !!V.loading);
|
|
72
|
+
return () => i() ? createComponent(loading_default, {}) : A.icon;
|
|
73
|
+
})()), insert(E, () => A.label, null), insert(E, (() => {
|
|
74
|
+
var i = memo(() => !!(R() && A.children));
|
|
75
|
+
return () => i() && createComponent(I, {
|
|
76
|
+
ref: L,
|
|
77
|
+
class: "z-1",
|
|
78
|
+
get children() {
|
|
79
|
+
return A.children;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
})(), null), effect(() => className(D, `flex aic ${M() ? "" : k.density == "comfortable" ? "ml-1 mr-2.5" : "ml-.5 mr-1"} `)), E;
|
|
83
|
+
})();
|
|
84
|
+
},
|
|
85
|
+
processProps: (i) => {
|
|
86
|
+
let E = 0;
|
|
87
|
+
return Array.isArray(i.children) && i.children.forEach((i) => !i.is && typeof i == "object" && (i["data-index"] = E++)), i;
|
|
88
|
+
}
|
|
89
|
+
}), I = (i) => {
|
|
90
|
+
let E = useContext(P), D = createMutable({ deep: E.deep + 1 });
|
|
91
|
+
return createComponent(P.Provider, {
|
|
92
|
+
value: D,
|
|
93
|
+
get children() {
|
|
94
|
+
var E = _tmpl$2();
|
|
95
|
+
return use(VDir, E, () => i.usedir), spread(E, mergeProps(() => combineProps({ class: `${k.x && D.deep == 1 ? "tt-menu-x flex" : "tt-menu max-h-100"} overflow-auto` }, i), { "on:click": (i) => i.stopPropagation() }), !1, !0), insert(E, () => ((i) => isEmpty(i) ? _tmpl$3() : i)(i.children)), E;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
return createComponent(F, mergeProps(() => combineProps({}, k), {
|
|
100
|
+
is: I,
|
|
101
|
+
items: null,
|
|
102
|
+
get children() {
|
|
103
|
+
return k.items;
|
|
104
|
+
}
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
export { Menu };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type JSX } from 'solid-js';
|
|
2
|
+
import { type createFloatingProps, type ReferenceType } from 'floating-ui-solid';
|
|
3
|
+
import type { AutoUpdateOptions } from '@floating-ui/dom';
|
|
4
|
+
export declare function Popover(attrs: FloatingProps): JSX.Element;
|
|
5
|
+
type FloatingProps = {
|
|
6
|
+
reference: ReferenceType;
|
|
7
|
+
floating?: JSX.Element | (() => JSX.Element);
|
|
8
|
+
portal?: HTMLElement;
|
|
9
|
+
trigger?: 'click' | 'hover';
|
|
10
|
+
} & createFloatingProps;
|
|
11
|
+
export declare function Floating(attrs: FloatingProps & {
|
|
12
|
+
update?: Partial<AutoUpdateOptions>;
|
|
13
|
+
}): JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useClicked, useHover, useMemoAsync } from "../hooks/index.js";
|
|
2
|
+
import { Portal, createComponent, memo, mergeProps } from "solid-js/web";
|
|
3
|
+
import { children, createEffect, createMemo, splitProps } from "solid-js";
|
|
4
|
+
import { delay } from "es-toolkit";
|
|
5
|
+
import { autoUpdate, createFloating } from "floating-ui-solid";
|
|
6
|
+
function Popover(s) {
|
|
7
|
+
let [c, u] = splitProps(s, ["reference", "floating"]), d = (s.trigger == "click" ? useClicked : useHover)(() => [m(), h()].filter((e) => e)), p = useMemoAsync(() => s.trigger == "click" ? d() : d() ? delay(100).then(() => !0) : delay(200).then(() => !1)), m = children(() => s.reference), h = children(() => p() ? s.floating : void 0);
|
|
8
|
+
return createComponent(Floating, mergeProps(u, {
|
|
9
|
+
reference: m,
|
|
10
|
+
floating: h
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
function Floating(e) {
|
|
14
|
+
let [a, o] = splitProps(e, ["reference", "floating"]), l = children(() => e.reference), f = children(() => e.floating), h = createMemo(() => f() ? createFloating({
|
|
15
|
+
whileElementsMounted(a, o, s) {
|
|
16
|
+
return autoUpdate(a, o, s, {
|
|
17
|
+
ancestorResize: !0,
|
|
18
|
+
elementResize: !0,
|
|
19
|
+
layoutShift: !0,
|
|
20
|
+
ancestorScroll: !0,
|
|
21
|
+
...e.update
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
...o,
|
|
25
|
+
elements: {
|
|
26
|
+
reference: l,
|
|
27
|
+
floating: f
|
|
28
|
+
}
|
|
29
|
+
}).floatingStyles : void 0);
|
|
30
|
+
return createEffect(() => {
|
|
31
|
+
f() && Object.assign(f().style, h()?.() ?? {});
|
|
32
|
+
}), [memo(l), memo(() => memo(() => !!(o.portal && f()))() ? createComponent(Portal, {
|
|
33
|
+
get mount() {
|
|
34
|
+
return o.portal;
|
|
35
|
+
},
|
|
36
|
+
get children() {
|
|
37
|
+
return f();
|
|
38
|
+
}
|
|
39
|
+
}) : f())];
|
|
40
|
+
}
|
|
41
|
+
export { Floating, Popover };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type JSX } from 'solid-js';
|
|
2
|
+
/**
|
|
3
|
+
* RecycleList — a keyed list component with DOM recycling.
|
|
4
|
+
*
|
|
5
|
+
* Works like SolidJS `<For>` (keyed by reference identity) but instead of
|
|
6
|
+
* destroying DOM when items leave the list, it hides and pools those DOM
|
|
7
|
+
* nodes. When new items enter, a pooled slot is reused by swapping the
|
|
8
|
+
* reactive signals, avoiding the cost of creating & hydrating fresh DOM.
|
|
9
|
+
*
|
|
10
|
+
* Each slot gets its own `createRoot` so that its inner reactive tree
|
|
11
|
+
* (memos, effects) is NOT owned by the reconciliation memo — preventing
|
|
12
|
+
* SolidJS from disposing child computations when the outer memo re-runs.
|
|
13
|
+
*
|
|
14
|
+
* Ideal for virtual-scroll scenarios where items constantly enter/leave
|
|
15
|
+
* the viewport but the DOM structure per item is identical.
|
|
16
|
+
*
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <RecycleList each={visibleItems()}>
|
|
19
|
+
* {(item, index) => <div>{item().name} at {index()}</div>}
|
|
20
|
+
* </RecycleList>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function RecycleList<T>(props: {
|
|
24
|
+
each: T[];
|
|
25
|
+
children: (item: () => T, index: () => number) => JSX.Element;
|
|
26
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createComponent, memo } from "solid-js/web";
|
|
2
|
+
import { For, createMemo, getOwner, onCleanup, runWithOwner } from "solid-js";
|
|
3
|
+
import { createMutable } from "solid-js/store";
|
|
4
|
+
function RecycleList(c) {
|
|
5
|
+
let l = /* @__PURE__ */ new Map(), u = [], d = getOwner();
|
|
6
|
+
function f(e) {
|
|
7
|
+
return runWithOwner(d, () => createMutable(e));
|
|
8
|
+
}
|
|
9
|
+
let p = createMemo(() => {
|
|
10
|
+
let e = c.each || [], a = new Set(e);
|
|
11
|
+
for (let [e, o] of l) a.has(e) || (u.push(o), l.delete(e), o.active = !1);
|
|
12
|
+
let o = [];
|
|
13
|
+
for (let a = 0; a < e.length; a++) {
|
|
14
|
+
let s = e[a];
|
|
15
|
+
if (l.has(s)) {
|
|
16
|
+
let e = l.get(s);
|
|
17
|
+
e.i = a, e.v = s;
|
|
18
|
+
} else if (u.length > 0) {
|
|
19
|
+
let e = u.pop();
|
|
20
|
+
e.i = a, e.v = s, e.active = !0, l.set(s, e);
|
|
21
|
+
} else l.set(s, f({
|
|
22
|
+
v: s,
|
|
23
|
+
i: a,
|
|
24
|
+
active: !0
|
|
25
|
+
}));
|
|
26
|
+
o.push(l.get(s));
|
|
27
|
+
}
|
|
28
|
+
return o.concat(...u);
|
|
29
|
+
});
|
|
30
|
+
return onCleanup(() => {
|
|
31
|
+
l.clear(), u.length = 0;
|
|
32
|
+
}), createComponent(For, {
|
|
33
|
+
get each() {
|
|
34
|
+
return p();
|
|
35
|
+
},
|
|
36
|
+
children: (e) => memo(() => memo(() => !!e.active)() && runWithOwner(d, () => e.el ??= c.children(() => e.v, () => e.i)))
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export { RecycleList };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Dynamic, createComponent, memo, mergeProps } from "solid-js/web";
|
|
2
|
+
import { splitProps } from "solid-js";
|
|
3
|
+
var unFn = (e, ...a) => typeof e == "function" ? e(...a) : e;
|
|
4
|
+
function createRender({ is: o, processProps: s = (e) => e } = {}) {
|
|
5
|
+
let c = (c) => {
|
|
6
|
+
let [u, d] = splitProps(s?.(c), [
|
|
7
|
+
"is",
|
|
8
|
+
"vIf",
|
|
9
|
+
"children"
|
|
10
|
+
]);
|
|
11
|
+
return memo(() => memo(() => !!(!("vIf" in u) || unFn(u.vIf)))() && createComponent(Dynamic, mergeProps({ get component() {
|
|
12
|
+
return u.is ?? o;
|
|
13
|
+
} }, d, { get children() {
|
|
14
|
+
return l(u.children);
|
|
15
|
+
} })));
|
|
16
|
+
}, l = (e) => Array.isArray(e) ? e.map((e) => typeof e == "object" ? c(e) : e) : e;
|
|
17
|
+
return c;
|
|
18
|
+
}
|
|
19
|
+
const Render = createRender({ is: "div" });
|
|
20
|
+
export { Render, createRender };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type JSXElement } from 'solid-js';
|
|
2
|
+
type SplitProps = {
|
|
3
|
+
container?: Element;
|
|
4
|
+
cells: () => Element[];
|
|
5
|
+
handle?: (i: number) => JSXElement;
|
|
6
|
+
size?: number;
|
|
7
|
+
dir?: 'x' | 'y';
|
|
8
|
+
leading?: boolean;
|
|
9
|
+
trailing?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const Split: (props: SplitProps & {
|
|
12
|
+
children?: JSXElement;
|
|
13
|
+
}) => import("solid-js").JSX.Element;
|
|
14
|
+
export declare const useSplit: (props: SplitProps) => void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { unFn } from "../utils.js";
|
|
2
|
+
import { Portal, createComponent, effect, insert, memo, spread, style, template, use } from "solid-js/web";
|
|
3
|
+
import { For, children, createEffect, mapArray, mergeProps as mergeProps$1, onMount } from "solid-js";
|
|
4
|
+
import { createElementBounds } from "@solid-primitives/bounds";
|
|
5
|
+
var _tmpl$ = /* @__PURE__ */ template("<div class=relative>"), _tmpl$2 = /* @__PURE__ */ template("<div class=\"absolute z-1\">");
|
|
6
|
+
const Split = (e) => {
|
|
7
|
+
let d, f = children(() => e.children);
|
|
8
|
+
return onMount(() => {
|
|
9
|
+
useSplit({
|
|
10
|
+
...e,
|
|
11
|
+
container: d,
|
|
12
|
+
cells: () => e.cells ? e.cells() : f()
|
|
13
|
+
});
|
|
14
|
+
}), (() => {
|
|
15
|
+
var p = _tmpl$(), m = d;
|
|
16
|
+
return typeof m == "function" ? use(m, p) : d = p, spread(p, e, !1, !0), insert(p, f), p;
|
|
17
|
+
})();
|
|
18
|
+
}, useSplit = (h) => {
|
|
19
|
+
h = mergeProps$1({
|
|
20
|
+
dir: "x",
|
|
21
|
+
size: 4
|
|
22
|
+
}, h);
|
|
23
|
+
let g, _ = mapArray(() => h.cells(), (e) => createElementBounds(e)), v = createElementBounds(() => g);
|
|
24
|
+
createEffect(() => g.style.position = "absolute");
|
|
25
|
+
let y = (e, d) => h.dir == "x" ? `transform: translate(${(d ? e.left + e.width : e.left) - h.size / 2}px, ${e.top}px); width: ${h.size}px; height: ${e.height}px;` : `transform: translate(${e.left}px, ${(d ? e.top + e.height : e.top) - h.size / 2}px); width: ${e.width}px; height: ${h.size}px;`, b = (e) => (() => {
|
|
26
|
+
var d = _tmpl$2();
|
|
27
|
+
return insert(d, () => h.handle?.(e.i)), effect((f) => style(d, y({
|
|
28
|
+
...e.e,
|
|
29
|
+
left: e.e.left - v.left,
|
|
30
|
+
top: e.e.top - v.top
|
|
31
|
+
}, e.bool), f)), d;
|
|
32
|
+
})();
|
|
33
|
+
createComponent(Portal, {
|
|
34
|
+
ref(e) {
|
|
35
|
+
var d = g;
|
|
36
|
+
typeof d == "function" ? d(e) : g = e;
|
|
37
|
+
},
|
|
38
|
+
get mount() {
|
|
39
|
+
return h.container || document.body;
|
|
40
|
+
},
|
|
41
|
+
get children() {
|
|
42
|
+
return [
|
|
43
|
+
createComponent(For, {
|
|
44
|
+
get each() {
|
|
45
|
+
return _().slice(0, -1);
|
|
46
|
+
},
|
|
47
|
+
children: (d, p) => createComponent(b, {
|
|
48
|
+
get e() {
|
|
49
|
+
return unFn(d);
|
|
50
|
+
},
|
|
51
|
+
bool: 1,
|
|
52
|
+
get i() {
|
|
53
|
+
return unFn(p);
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
}),
|
|
57
|
+
memo(() => memo(() => !!(_().length && h.leading))() && createComponent(b, {
|
|
58
|
+
get e() {
|
|
59
|
+
return _()[0];
|
|
60
|
+
},
|
|
61
|
+
i: -1
|
|
62
|
+
})),
|
|
63
|
+
memo(() => memo(() => !!(_().length && h.trailing))() && createComponent(b, {
|
|
64
|
+
get e() {
|
|
65
|
+
return _()[_().length - 1];
|
|
66
|
+
},
|
|
67
|
+
bool: 1,
|
|
68
|
+
get i() {
|
|
69
|
+
return _().length - 1;
|
|
70
|
+
}
|
|
71
|
+
}))
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
export { Split, useSplit };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare abstract class $Node {
|
|
2
|
+
data: any;
|
|
3
|
+
constructor(data: any);
|
|
4
|
+
get label(): any;
|
|
5
|
+
abstract getChildren(): $Node[] | undefined;
|
|
6
|
+
children: $Node[] | undefined;
|
|
7
|
+
$children: import("solid-js").Accessor<$Node[]>;
|
|
8
|
+
parent: $Node | undefined;
|
|
9
|
+
$parent: import("solid-js").Signal<unknown>;
|
|
10
|
+
deep: number;
|
|
11
|
+
$deep: import("solid-js").Accessor<number>;
|
|
12
|
+
index: number;
|
|
13
|
+
$index: import("solid-js").Accessor<number>;
|
|
14
|
+
prev: $Node | undefined;
|
|
15
|
+
$prev: import("solid-js").Accessor<$Node>;
|
|
16
|
+
next: $Node | undefined;
|
|
17
|
+
$next: import("solid-js").Accessor<$Node>;
|
|
18
|
+
root: $Node;
|
|
19
|
+
$root: any;
|
|
20
|
+
path: $Node[];
|
|
21
|
+
$path: import("solid-js").Accessor<$Node[]>;
|
|
22
|
+
get descendants(): $Node[];
|
|
23
|
+
contains(node: $Node): boolean;
|
|
24
|
+
remove(): void;
|
|
25
|
+
}
|
|
26
|
+
export declare class $TreeItem extends $Node {
|
|
27
|
+
get is(): any;
|
|
28
|
+
get props(): any;
|
|
29
|
+
get id(): any;
|
|
30
|
+
getChildren(): any;
|
|
31
|
+
}
|
|
32
|
+
export declare function Tree(_: {
|
|
33
|
+
data: any;
|
|
34
|
+
Node: {
|
|
35
|
+
new (data: any): $TreeItem;
|
|
36
|
+
};
|
|
37
|
+
}): import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Dynamic, createComponent, insert, mergeProps, spread, template } from "solid-js/web";
|
|
2
|
+
import { Index, createEffect, createMemo, createSignal, onCleanup, splitProps } from "solid-js";
|
|
3
|
+
import { combineProps } from "@solid-primitives/props";
|
|
4
|
+
import { createLazyMemo } from "@solid-primitives/memo";
|
|
5
|
+
import { castArray } from "es-toolkit/compat";
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ template("<div>");
|
|
7
|
+
function define(e, d) {
|
|
8
|
+
let f = createSignal();
|
|
9
|
+
return Object.defineProperty(e, d, {
|
|
10
|
+
get() {
|
|
11
|
+
return f[0]();
|
|
12
|
+
},
|
|
13
|
+
set(e) {
|
|
14
|
+
f[1](e);
|
|
15
|
+
}
|
|
16
|
+
}), f;
|
|
17
|
+
}
|
|
18
|
+
function memo$1(e, d, f) {
|
|
19
|
+
let p = createLazyMemo(f);
|
|
20
|
+
return Object.defineProperty(e, d, { get() {
|
|
21
|
+
return p();
|
|
22
|
+
} }), p;
|
|
23
|
+
}
|
|
24
|
+
var $Node = class {
|
|
25
|
+
constructor(e) {
|
|
26
|
+
this.$children = memo$1(this, "children", () => this.getChildren()), this.$parent = define(this, "parent"), this.$deep = memo$1(this, "deep", () => this.parent ? this.parent.deep + 1 : 0), this.$index = memo$1(this, "index", () => this.parent?.children?.indexOf(this)), this.$prev = memo$1(this, "prev", () => this.parent?.children?.[this.index - 1]), this.$next = memo$1(this, "next", () => this.parent?.children?.[this.index + 1]), this.$root = memo$1(this, "root", () => this.parent ? this.parent.root : this), this.$path = memo$1(this, "path", () => {
|
|
27
|
+
let e = [this], d = this;
|
|
28
|
+
for (; d.parent;) e.push(d = d.parent);
|
|
29
|
+
return e.reverse();
|
|
30
|
+
}), this.data = e, createEffect(() => {
|
|
31
|
+
let e = this.children;
|
|
32
|
+
e?.map((e) => e.parent = this), onCleanup(() => e?.map((e) => e.parent = void 0));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
get label() {
|
|
36
|
+
return this.data.label;
|
|
37
|
+
}
|
|
38
|
+
get descendants() {
|
|
39
|
+
return this.children?.flatMap((e) => [e, ...e.descendants]) || [];
|
|
40
|
+
}
|
|
41
|
+
contains(e) {
|
|
42
|
+
return e.path.includes(this);
|
|
43
|
+
}
|
|
44
|
+
remove() {}
|
|
45
|
+
}, $TreeItem = class e extends $Node {
|
|
46
|
+
get is() {
|
|
47
|
+
return this.data.is;
|
|
48
|
+
}
|
|
49
|
+
get props() {
|
|
50
|
+
return this.data;
|
|
51
|
+
}
|
|
52
|
+
get id() {
|
|
53
|
+
return this.data.id;
|
|
54
|
+
}
|
|
55
|
+
getChildren() {
|
|
56
|
+
return this.data.children?.map((d) => new e(d));
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
function Tree(h) {
|
|
60
|
+
let [g, _] = splitProps(h, ["data", "Node"]), v = g.Node ?? $TreeItem, y = createMemo(() => new class extends v {
|
|
61
|
+
getChildren() {
|
|
62
|
+
return castArray(this.data || []).map((e) => new v(e));
|
|
63
|
+
}
|
|
64
|
+
}(g.data)), b = createMemo(() => y().descendants);
|
|
65
|
+
return (() => {
|
|
66
|
+
var h = _tmpl$();
|
|
67
|
+
return spread(h, mergeProps(() => combineProps({ class: "tt-menu" }, _)), !1, !0), insert(h, createComponent(Index, {
|
|
68
|
+
get each() {
|
|
69
|
+
return b();
|
|
70
|
+
},
|
|
71
|
+
children: (f, m) => createComponent(Dynamic, mergeProps({ get component() {
|
|
72
|
+
return f().is ?? "div";
|
|
73
|
+
} }, () => combineProps({
|
|
74
|
+
class: "li py-1 px-4",
|
|
75
|
+
style: `padding-left: ${f().deep * 16}px`
|
|
76
|
+
}, f().props), { get children() {
|
|
77
|
+
return f().label;
|
|
78
|
+
} }))
|
|
79
|
+
})), h;
|
|
80
|
+
})();
|
|
81
|
+
}
|
|
82
|
+
export { $Node, $TreeItem, Tree };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createComponent } from "solid-js/web";
|
|
2
|
+
function solidComponent(e) {
|
|
3
|
+
return e.__solid = 1, e;
|
|
4
|
+
}
|
|
5
|
+
function renderComponent(t, n, r) {
|
|
6
|
+
return t ? (t.__solid || (t = r(t)), createComponent(t, n)) : null;
|
|
7
|
+
}
|
|
8
|
+
export { renderComponent, solidComponent };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type Signal } from 'solid-js';
|
|
2
|
+
import { type Many, type MaybeAccessor } from '@solid-primitives/utils';
|
|
3
|
+
interface UseMoveOptions {
|
|
4
|
+
preventDefault?: boolean;
|
|
5
|
+
start?(e: PointerEvent, move: (cb: MoveCB) => void, end: (cb: EndCb) => void): void;
|
|
6
|
+
}
|
|
7
|
+
type MoveCB = (e: PointerEvent, o: {
|
|
8
|
+
sx: number;
|
|
9
|
+
sy: number;
|
|
10
|
+
ox: number;
|
|
11
|
+
oy: number;
|
|
12
|
+
}) => void;
|
|
13
|
+
type EndCb = (e: PointerEvent) => void;
|
|
14
|
+
export declare function usePointerDrag(el: MaybeAccessor<HTMLElement | undefined>, options: UseMoveOptions): void;
|
|
15
|
+
export declare function model(el: any, value: () => [() => string, (v: string) => any]): void;
|
|
16
|
+
export declare function toSignle<T extends Record<string, any>>(state: T, k: keyof T): ((v: any) => any)[];
|
|
17
|
+
export declare function useDark(): [get: import("solid-js").Accessor<boolean>, set: import("solid-js").Setter<boolean>, init: string | Promise<string>];
|
|
18
|
+
export declare function useMemoAsync<T>(fn: (prev?: T) => Promise<T> | T, init?: Awaited<T>): import("solid-js").Accessor<Awaited<T>>;
|
|
19
|
+
export declare function useSignle2<T>(v: T | (() => T), opt?: {
|
|
20
|
+
before?: (v: T) => Promise<T | void> | T;
|
|
21
|
+
}): Signal<T>;
|
|
22
|
+
type Reactive<T extends object> = {
|
|
23
|
+
[K in keyof T]: T[K] extends () => infer V ? V : T[K];
|
|
24
|
+
};
|
|
25
|
+
export declare function toReactive<T extends object>(fn: (() => T) | T): Reactive<T>;
|
|
26
|
+
export declare function useMemo<T>(fn: () => T): import("solid-js").Accessor<T>;
|
|
27
|
+
export declare function useHover(el: MaybeAccessor<Many<HTMLElement | undefined>>): import("solid-js").Accessor<boolean>;
|
|
28
|
+
export declare function useMouseDown(el: MaybeAccessor<Many<HTMLElement | undefined>>): import("solid-js").Accessor<boolean>;
|
|
29
|
+
export declare function useClicked(el: MaybeAccessor<Many<HTMLElement | undefined>>): import("solid-js").Accessor<boolean>;
|
|
30
|
+
export declare function useMutation<T>(initial: MaybeAccessor<Node | Node[]>, options: MutationObserverInit, cb: () => T): import("solid-js").Accessor<T>;
|
|
31
|
+
export declare function useTinykeys(el: MaybeAccessor<HTMLElement | undefined>, handlers: any): void;
|
|
32
|
+
export declare function useHistory([val, setVal]: [any, any]): {
|
|
33
|
+
undo: () => any;
|
|
34
|
+
redo: () => any;
|
|
35
|
+
clear: () => any[];
|
|
36
|
+
readonly index: number;
|
|
37
|
+
readonly history: any[];
|
|
38
|
+
};
|
|
39
|
+
export declare function createShallowState(state: any): any;
|
|
40
|
+
export declare function useMemoState(fn: any): any;
|
|
41
|
+
export {};
|