intable 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +2 -1
- package/dist/__uno.css +1 -1
- package/dist/chevron-right.js +3 -5
- package/dist/components/Columns.js +50 -84
- package/dist/components/DocTree.js +21 -29
- package/dist/components/Menu.js +81 -105
- package/dist/components/Popover.js +23 -31
- package/dist/components/Render.js +10 -11
- package/dist/components/Split.js +34 -46
- package/dist/components/Tree.js +38 -57
- package/dist/components/utils.js +4 -6
- package/dist/hooks/index.d.ts +3 -2
- package/dist/hooks/index.js +93 -128
- package/dist/hooks/useDir.js +22 -39
- package/dist/hooks/useSort.d.ts +18 -0
- package/dist/hooks/useSort.js +83 -0
- package/dist/hooks/useVirtualizer.js +43 -68
- package/dist/index.d.ts +8 -2
- package/dist/index.js +175 -213
- package/dist/loading.js +3 -5
- package/dist/plugins/CellMergePlugin.d.ts +12 -0
- package/dist/plugins/CellMergePlugin.js +2 -0
- package/dist/plugins/CellSelectionPlugin.js +89 -125
- package/dist/plugins/CommandPlugin.js +3 -6
- package/dist/plugins/CopyPastePlugin.js +24 -37
- package/dist/plugins/DiffPlugin.js +33 -45
- package/dist/plugins/DragPlugin.d.ts +14 -0
- package/dist/plugins/DragPlugin.js +47 -0
- package/dist/plugins/EditablePlugin.js +88 -139
- package/dist/plugins/ExpandPlugin.js +26 -30
- package/dist/plugins/HistoryPlugin.js +16 -21
- package/dist/plugins/MenuPlugin.js +51 -76
- package/dist/plugins/RenderPlugin/components.js +45 -63
- package/dist/plugins/RenderPlugin/index.js +29 -42
- package/dist/plugins/ResizePlugin.d.ts +2 -2
- package/dist/plugins/ResizePlugin.js +71 -94
- package/dist/plugins/RowGroupPlugin.js +57 -73
- package/dist/plugins/RowSelectionPlugin.js +31 -42
- package/dist/plugins/VirtualScrollPlugin.js +54 -79
- package/dist/plus.js +3 -5
- package/dist/style.css +2 -184
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +46 -64
- package/dist/wc.js +11 -11
- package/dist/x.js +3 -5
- package/package.json +3 -2
- package/dist/plugins/DragColumnPlugin.d.ts +0 -2
- package/dist/plugins/DragColumnPlugin.js +0 -4
package/dist/components/Split.js
CHANGED
|
@@ -2,83 +2,71 @@ import { unFn } from "../utils.js";
|
|
|
2
2
|
import { Portal, createComponent, effect, insert, memo, spread, style, template, use } from "solid-js/web";
|
|
3
3
|
import { For, children, createEffect, mapArray, mergeProps as mergeProps$1, onMount } from "solid-js";
|
|
4
4
|
import { createElementBounds } from "@solid-primitives/bounds";
|
|
5
|
-
var _tmpl$ = /* @__PURE__ */ template(
|
|
6
|
-
const Split = (
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
onMount(() => {
|
|
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(() => {
|
|
10
9
|
useSplit({
|
|
11
|
-
...
|
|
12
|
-
container:
|
|
13
|
-
cells: () =>
|
|
10
|
+
...e,
|
|
11
|
+
container: d,
|
|
12
|
+
cells: () => e.cells ? e.cells() : f()
|
|
14
13
|
});
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _ref$ = el;
|
|
19
|
-
typeof _ref$ === "function" ? use(_ref$, _el$) : el = _el$;
|
|
20
|
-
spread(_el$, props, false, true);
|
|
21
|
-
insert(_el$, child);
|
|
22
|
-
return _el$;
|
|
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;
|
|
23
17
|
})();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
props = mergeProps$1({
|
|
18
|
+
}, useSplit = (h) => {
|
|
19
|
+
h = mergeProps$1({
|
|
27
20
|
dir: "x",
|
|
28
21
|
size: 4
|
|
29
|
-
},
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const Handle = (e) => (() => {
|
|
36
|
-
var _el$2 = _tmpl$2();
|
|
37
|
-
insert(_el$2, () => props.handle?.(e.i));
|
|
38
|
-
effect((_$p) => style(_el$2, style$1({
|
|
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({
|
|
39
28
|
...e.e,
|
|
40
|
-
left: e.e.left -
|
|
41
|
-
top: e.e.top -
|
|
42
|
-
}, e.bool),
|
|
43
|
-
return _el$2;
|
|
29
|
+
left: e.e.left - v.left,
|
|
30
|
+
top: e.e.top - v.top
|
|
31
|
+
}, e.bool), f)), d;
|
|
44
32
|
})();
|
|
45
33
|
createComponent(Portal, {
|
|
46
|
-
ref(
|
|
47
|
-
var
|
|
48
|
-
typeof
|
|
34
|
+
ref(e) {
|
|
35
|
+
var d = g;
|
|
36
|
+
typeof d == "function" ? d(e) : g = e;
|
|
49
37
|
},
|
|
50
38
|
get mount() {
|
|
51
|
-
return
|
|
39
|
+
return h.container || document.body;
|
|
52
40
|
},
|
|
53
41
|
get children() {
|
|
54
42
|
return [
|
|
55
43
|
createComponent(For, {
|
|
56
44
|
get each() {
|
|
57
|
-
return
|
|
45
|
+
return _().slice(0, -1);
|
|
58
46
|
},
|
|
59
|
-
children: (
|
|
47
|
+
children: (d, p) => createComponent(b, {
|
|
60
48
|
get e() {
|
|
61
|
-
return unFn(
|
|
49
|
+
return unFn(d);
|
|
62
50
|
},
|
|
63
51
|
bool: 1,
|
|
64
52
|
get i() {
|
|
65
|
-
return unFn(
|
|
53
|
+
return unFn(p);
|
|
66
54
|
}
|
|
67
55
|
})
|
|
68
56
|
}),
|
|
69
|
-
memo(() => memo(() => !!(
|
|
57
|
+
memo(() => memo(() => !!(_().length && h.leading))() && createComponent(b, {
|
|
70
58
|
get e() {
|
|
71
|
-
return
|
|
59
|
+
return _()[0];
|
|
72
60
|
},
|
|
73
61
|
i: -1
|
|
74
62
|
})),
|
|
75
|
-
memo(() => memo(() => !!(
|
|
63
|
+
memo(() => memo(() => !!(_().length && h.trailing))() && createComponent(b, {
|
|
76
64
|
get e() {
|
|
77
|
-
return
|
|
65
|
+
return _()[_().length - 1];
|
|
78
66
|
},
|
|
79
67
|
bool: 1,
|
|
80
68
|
get i() {
|
|
81
|
-
return
|
|
69
|
+
return _().length - 1;
|
|
82
70
|
}
|
|
83
71
|
}))
|
|
84
72
|
];
|
package/dist/components/Tree.js
CHANGED
|
@@ -3,46 +3,33 @@ import { Index, createEffect, createMemo, createSignal, onCleanup, splitProps }
|
|
|
3
3
|
import { combineProps } from "@solid-primitives/props";
|
|
4
4
|
import { castArray } from "es-toolkit/compat";
|
|
5
5
|
import { createLazyMemo } from "@solid-primitives/memo";
|
|
6
|
-
var _tmpl$ = /* @__PURE__ */ template(
|
|
7
|
-
function define(
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ template("<div>");
|
|
7
|
+
function define(e, d) {
|
|
8
|
+
let f = createSignal();
|
|
9
|
+
return Object.defineProperty(e, d, {
|
|
10
10
|
get() {
|
|
11
|
-
return
|
|
11
|
+
return f[0]();
|
|
12
12
|
},
|
|
13
|
-
set(
|
|
14
|
-
|
|
13
|
+
set(e) {
|
|
14
|
+
f[1](e);
|
|
15
15
|
}
|
|
16
|
-
});
|
|
17
|
-
return signal;
|
|
16
|
+
}), f;
|
|
18
17
|
}
|
|
19
|
-
function memo$1(
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(
|
|
22
|
-
return
|
|
23
|
-
} });
|
|
24
|
-
return signal;
|
|
18
|
+
function memo$1(e, d, f) {
|
|
19
|
+
let p = createLazyMemo(f);
|
|
20
|
+
return Object.defineProperty(e, d, { get() {
|
|
21
|
+
return p();
|
|
22
|
+
} }), p;
|
|
25
23
|
}
|
|
26
24
|
var $Node = class {
|
|
27
|
-
constructor(
|
|
28
|
-
this.$children = memo$1(this, "children", () => this.getChildren())
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.$path = memo$1(this, "path", () => {
|
|
36
|
-
const ret = [this];
|
|
37
|
-
let e = this;
|
|
38
|
-
while (e.parent) ret.push(e = e.parent);
|
|
39
|
-
return ret.reverse();
|
|
40
|
-
});
|
|
41
|
-
this.data = data;
|
|
42
|
-
createEffect(() => {
|
|
43
|
-
const children$1 = this.children;
|
|
44
|
-
children$1?.map((e) => e.parent = this);
|
|
45
|
-
onCleanup(() => children$1?.map((e) => e.parent = void 0));
|
|
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));
|
|
46
33
|
});
|
|
47
34
|
}
|
|
48
35
|
get label() {
|
|
@@ -51,12 +38,11 @@ var $Node = class {
|
|
|
51
38
|
get descendants() {
|
|
52
39
|
return this.children?.flatMap((e) => [e, ...e.descendants]) || [];
|
|
53
40
|
}
|
|
54
|
-
contains(
|
|
55
|
-
return
|
|
41
|
+
contains(e) {
|
|
42
|
+
return e.path.includes(this);
|
|
56
43
|
}
|
|
57
44
|
remove() {}
|
|
58
|
-
}
|
|
59
|
-
var $TreeItem = class $TreeItem extends $Node {
|
|
45
|
+
}, $TreeItem = class e extends $Node {
|
|
60
46
|
get is() {
|
|
61
47
|
return this.data.is;
|
|
62
48
|
}
|
|
@@ -67,35 +53,30 @@ var $TreeItem = class $TreeItem extends $Node {
|
|
|
67
53
|
return this.data.id;
|
|
68
54
|
}
|
|
69
55
|
getChildren() {
|
|
70
|
-
return this.data.children?.map((
|
|
56
|
+
return this.data.children?.map((d) => new e(d));
|
|
71
57
|
}
|
|
72
58
|
};
|
|
73
|
-
function Tree(
|
|
74
|
-
|
|
75
|
-
const Node = props.Node ?? $TreeItem;
|
|
76
|
-
const root = createMemo(() => new class extends Node {
|
|
59
|
+
function Tree(h) {
|
|
60
|
+
let [g, _] = splitProps(h, ["data", "Node"]), v = g.Node ?? $TreeItem, y = createMemo(() => new class extends v {
|
|
77
61
|
getChildren() {
|
|
78
|
-
return castArray(this.data || []).map((e) => new
|
|
62
|
+
return castArray(this.data || []).map((e) => new v(e));
|
|
79
63
|
}
|
|
80
|
-
}(
|
|
81
|
-
const flated = createMemo(() => root().descendants);
|
|
64
|
+
}(g.data)), b = createMemo(() => y().descendants);
|
|
82
65
|
return (() => {
|
|
83
|
-
var
|
|
84
|
-
spread(
|
|
85
|
-
insert(_el$, createComponent(Index, {
|
|
66
|
+
var h = _tmpl$();
|
|
67
|
+
return spread(h, mergeProps(() => combineProps({ class: "tt-menu" }, _)), !1, !0), insert(h, createComponent(Index, {
|
|
86
68
|
get each() {
|
|
87
|
-
return
|
|
69
|
+
return b();
|
|
88
70
|
},
|
|
89
|
-
children: (
|
|
90
|
-
return
|
|
71
|
+
children: (f, m) => createComponent(Dynamic, mergeProps({ get component() {
|
|
72
|
+
return f().is ?? "div";
|
|
91
73
|
} }, () => combineProps({
|
|
92
74
|
class: "li py-1 px-4",
|
|
93
|
-
style: `padding-left: ${
|
|
94
|
-
},
|
|
95
|
-
return
|
|
75
|
+
style: `padding-left: ${f().deep * 16}px`
|
|
76
|
+
}, f().props), { get children() {
|
|
77
|
+
return f().label;
|
|
96
78
|
} }))
|
|
97
|
-
}));
|
|
98
|
-
return _el$;
|
|
79
|
+
})), h;
|
|
99
80
|
})();
|
|
100
81
|
}
|
|
101
82
|
export { $Node, $TreeItem, Tree };
|
package/dist/components/utils.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { createComponent } from "solid-js/web";
|
|
2
|
-
function solidComponent(
|
|
3
|
-
|
|
4
|
-
return comp;
|
|
2
|
+
function solidComponent(e) {
|
|
3
|
+
return e.__solid = 1, e;
|
|
5
4
|
}
|
|
6
|
-
function renderComponent(
|
|
7
|
-
|
|
8
|
-
return createComponent(Comp, props);
|
|
5
|
+
function renderComponent(t, n, r) {
|
|
6
|
+
return t.__solid || (t = r(t)), createComponent(t, n);
|
|
9
7
|
}
|
|
10
8
|
export { renderComponent, solidComponent };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Signal } from 'solid-js';
|
|
2
2
|
import { type Many, type MaybeAccessor } from '@solid-primitives/utils';
|
|
3
|
-
interface
|
|
3
|
+
interface UseMoveOptions {
|
|
4
|
+
preventDefault?: boolean;
|
|
4
5
|
start?(e: PointerEvent, move: (cb: MoveCB) => void, end: (cb: EndCb) => void): void;
|
|
5
6
|
}
|
|
6
7
|
type MoveCB = (e: PointerEvent, o: {
|
|
@@ -10,7 +11,7 @@ type MoveCB = (e: PointerEvent, o: {
|
|
|
10
11
|
oy: number;
|
|
11
12
|
}) => void;
|
|
12
13
|
type EndCb = (e: PointerEvent) => void;
|
|
13
|
-
export declare function usePointerDrag(el: MaybeAccessor<HTMLElement | undefined>, options:
|
|
14
|
+
export declare function usePointerDrag(el: MaybeAccessor<HTMLElement | undefined>, options: UseMoveOptions): void;
|
|
14
15
|
export declare function model(el: any, value: () => [() => string, (v: string) => any]): void;
|
|
15
16
|
export declare function toSignle<T extends Record<string, any>>(state: T, k: keyof T): ((v: any) => any)[];
|
|
16
17
|
export declare function useDark(): [get: import("solid-js").Accessor<boolean>, set: import("solid-js").Setter<boolean>, init: string | Promise<string>];
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,181 +1,146 @@
|
|
|
1
1
|
import { unFn } from "../utils.js";
|
|
2
|
-
import { $PROXY, createComputed, createEffect, createMemo, createRenderEffect, createRoot, createSignal, on, onCleanup, untrack } from "solid-js";
|
|
2
|
+
import { $PROXY, createComputed, createEffect, createMemo, createRenderEffect, createRoot, createSignal, mergeProps, on, onCleanup, untrack } from "solid-js";
|
|
3
3
|
import { $RAW, createMutable } from "solid-js/store";
|
|
4
4
|
import { isFunction, isPromise, mapValues } from "es-toolkit";
|
|
5
|
-
import { createEventListener } from "@solid-primitives/event-listener";
|
|
5
|
+
import { createEventListener, createEventListenerMap } from "@solid-primitives/event-listener";
|
|
6
6
|
import { createPointerListeners } from "@solid-primitives/pointer";
|
|
7
7
|
import { access } from "@solid-primitives/utils";
|
|
8
8
|
import { makePersisted, storageSync } from "@solid-primitives/storage";
|
|
9
9
|
import { createMutationObserver } from "@solid-primitives/mutation-observer";
|
|
10
10
|
import { castArray } from "es-toolkit/compat";
|
|
11
11
|
import { createKeybindingsHandler } from "tinykeys";
|
|
12
|
-
function usePointerDrag(
|
|
13
|
-
createPointerListeners({
|
|
14
|
-
target:
|
|
15
|
-
passive:
|
|
16
|
-
onDown(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
let end;
|
|
21
|
-
options.start?.(e, (cb) => move = cb, (cb) => end = cb);
|
|
22
|
-
createRoot((dispose) => {
|
|
12
|
+
function usePointerDrag(m, P) {
|
|
13
|
+
P = mergeProps({ preventDefault: !0 }, P), createPointerListeners({
|
|
14
|
+
target: m,
|
|
15
|
+
passive: !1,
|
|
16
|
+
onDown(m) {
|
|
17
|
+
P.preventDefault && m.preventDefault();
|
|
18
|
+
let [F, I] = [m.x, m.y], L, R;
|
|
19
|
+
P.start?.(m, (m) => L = m, (m) => R = m), createRoot((P) => {
|
|
23
20
|
createPointerListeners({
|
|
24
21
|
target: document,
|
|
25
|
-
onMove(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
sx,
|
|
29
|
-
sy,
|
|
30
|
-
ox,
|
|
31
|
-
oy
|
|
22
|
+
onMove(m) {
|
|
23
|
+
let [P, R] = [m.x - F, m.y - I];
|
|
24
|
+
L?.(m, {
|
|
25
|
+
sx: F,
|
|
26
|
+
sy: I,
|
|
27
|
+
ox: P,
|
|
28
|
+
oy: R
|
|
32
29
|
});
|
|
33
30
|
},
|
|
34
31
|
onUp() {
|
|
35
|
-
|
|
36
|
-
dispose();
|
|
37
|
-
move = void 0;
|
|
38
|
-
end = void 0;
|
|
32
|
+
R?.(m), P(), L = void 0, R = void 0;
|
|
39
33
|
}
|
|
40
|
-
});
|
|
34
|
+
}), createEventListenerMap(document, { drop: P });
|
|
41
35
|
});
|
|
42
36
|
}
|
|
43
37
|
});
|
|
44
38
|
}
|
|
45
|
-
function model(
|
|
46
|
-
|
|
47
|
-
createRenderEffect(() =>
|
|
48
|
-
el.addEventListener("input", (e) => setField(e.target.value));
|
|
39
|
+
function model(m, P) {
|
|
40
|
+
let [F, I] = P();
|
|
41
|
+
createRenderEffect(() => m.value = F()), m.addEventListener("input", (m) => I(m.target.value));
|
|
49
42
|
}
|
|
50
|
-
function toSignle(
|
|
51
|
-
return [() =>
|
|
43
|
+
function toSignle(m, P) {
|
|
44
|
+
return [() => m[P], (F) => m[P] = F];
|
|
52
45
|
}
|
|
53
46
|
function useDark() {
|
|
54
|
-
|
|
55
|
-
const prefersDark = () => window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
56
|
-
const dark = makePersisted(createSignal(prefersDark()), {
|
|
47
|
+
let m = (m) => m == "dark" || F() && !m, P = (m) => m ? "dark" : "light", F = () => window.matchMedia("(prefers-color-scheme: dark)").matches, L = makePersisted(createSignal(F()), {
|
|
57
48
|
name: "color-schema",
|
|
58
49
|
storage: localStorage,
|
|
59
50
|
sync: storageSync,
|
|
60
|
-
serialize:
|
|
61
|
-
deserialize:
|
|
51
|
+
serialize: P,
|
|
52
|
+
deserialize: m
|
|
62
53
|
});
|
|
63
|
-
createEffect(() => document.documentElement.classList[
|
|
64
|
-
createEffect(() => window.dispatchEvent(new StorageEvent("storage", {
|
|
54
|
+
return createEffect(() => document.documentElement.classList[L[0]() ? "add" : "remove"]("dark")), createEffect(() => window.dispatchEvent(new StorageEvent("storage", {
|
|
65
55
|
key: "color-schema",
|
|
66
|
-
newValue:
|
|
67
|
-
})));
|
|
68
|
-
return dark;
|
|
56
|
+
newValue: P(L[0]())
|
|
57
|
+
}))), L;
|
|
69
58
|
}
|
|
70
|
-
function useMemoAsync(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}) : ret;
|
|
79
|
-
v == REJECT || setVal(() => v);
|
|
80
|
-
});
|
|
81
|
-
return val;
|
|
59
|
+
function useMemoAsync(m, P) {
|
|
60
|
+
let I = Symbol(), [L, R] = createSignal(P);
|
|
61
|
+
return createComputed(async () => {
|
|
62
|
+
let P = m(untrack(L)), F = P instanceof Promise ? await new Promise((m) => {
|
|
63
|
+
P.then(m), onCleanup(() => m(I));
|
|
64
|
+
}) : P;
|
|
65
|
+
F == I || R(() => F);
|
|
66
|
+
}), L;
|
|
82
67
|
}
|
|
83
|
-
function useSignle2(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const fned = useMemoAsync(() => before(v()));
|
|
92
|
-
createComputed(() => state[1](fned()));
|
|
68
|
+
function useSignle2(m, P) {
|
|
69
|
+
let I = createSignal(isFunction(m) ? void 0 : m), L = (m) => {
|
|
70
|
+
let F = P?.before?.(m);
|
|
71
|
+
return isPromise(F) ? F.then((P) => P === void 0 ? m : P) : F ?? m;
|
|
72
|
+
}, R = useMemoAsync(() => L(I[0]()));
|
|
73
|
+
if (isFunction(m)) {
|
|
74
|
+
let P = useMemoAsync(() => L(m()));
|
|
75
|
+
createComputed(() => I[1](P()));
|
|
93
76
|
}
|
|
94
|
-
return [
|
|
77
|
+
return [R, I[1]];
|
|
95
78
|
}
|
|
96
79
|
var $MEMO = Symbol();
|
|
97
|
-
function toReactive(
|
|
98
|
-
|
|
99
|
-
const trueFn = () => true;
|
|
100
|
-
const get = (k) => ((e) => typeof e == "function" && $MEMO in e ? e() : e)(v()[k]);
|
|
80
|
+
function toReactive(F) {
|
|
81
|
+
let I = () => unFn(F), L = () => !0, R = (m) => ((m) => typeof m == "function" && $MEMO in m ? m() : m)(I()[m]);
|
|
101
82
|
return new Proxy(Object.create(null), {
|
|
102
|
-
get: (
|
|
103
|
-
set:
|
|
104
|
-
defineProperty: (
|
|
105
|
-
deleteProperty:
|
|
106
|
-
getPrototypeOf: () => Object.getPrototypeOf(
|
|
107
|
-
has: (
|
|
108
|
-
ownKeys: (
|
|
109
|
-
getOwnPropertyDescriptor: (
|
|
110
|
-
enumerable:
|
|
111
|
-
configurable:
|
|
83
|
+
get: (m, F, L) => F == $PROXY || F == $RAW ? L : ((m) => typeof m == "function" && $MEMO in m ? m() : m)(I()[F]),
|
|
84
|
+
set: L,
|
|
85
|
+
defineProperty: (m, P, F) => Object.defineProperty(I(), P, F),
|
|
86
|
+
deleteProperty: L,
|
|
87
|
+
getPrototypeOf: () => Object.getPrototypeOf(I()),
|
|
88
|
+
has: (m, F) => F == $PROXY || F in I(),
|
|
89
|
+
ownKeys: (m) => Object.keys(I()),
|
|
90
|
+
getOwnPropertyDescriptor: (m, P) => ({
|
|
91
|
+
enumerable: !0,
|
|
92
|
+
configurable: !0,
|
|
112
93
|
get() {
|
|
113
|
-
return
|
|
94
|
+
return R(P);
|
|
114
95
|
},
|
|
115
|
-
set:
|
|
96
|
+
set: L
|
|
116
97
|
})
|
|
117
98
|
});
|
|
118
99
|
}
|
|
119
|
-
function useMemo(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return ret;
|
|
100
|
+
function useMemo(m) {
|
|
101
|
+
let P = createMemo(m);
|
|
102
|
+
return P[$MEMO] = 1, P;
|
|
123
103
|
}
|
|
124
|
-
function useHover(
|
|
125
|
-
|
|
126
|
-
createEventListener(
|
|
127
|
-
createEventListener(el, "pointerleave", () => setHover(false));
|
|
128
|
-
return hover;
|
|
104
|
+
function useHover(m) {
|
|
105
|
+
let [P, F] = createSignal(!1);
|
|
106
|
+
return createEventListener(m, "pointerenter", () => F(!0)), createEventListener(m, "pointerleave", () => F(!1)), P;
|
|
129
107
|
}
|
|
130
|
-
function useMouseDown(
|
|
131
|
-
|
|
132
|
-
createEventListener(
|
|
133
|
-
createEventListener(document.body, "pointerup", () => setDown(false));
|
|
134
|
-
return down;
|
|
108
|
+
function useMouseDown(m) {
|
|
109
|
+
let [P, F] = createSignal(!1);
|
|
110
|
+
return createEventListener(m, "pointerdown", () => F(!0)), createEventListener(document.body, "pointerup", () => F(!1)), P;
|
|
135
111
|
}
|
|
136
|
-
function useClicked(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
createEventListener(() => els().map((e) => e?.getRootNode()), "click", (e) => setClicked(els().some((el$1) => el$1?.contains(e.target))));
|
|
140
|
-
return clicked;
|
|
112
|
+
function useClicked(m) {
|
|
113
|
+
let [P, F] = createSignal(!1), I = () => castArray(access(m));
|
|
114
|
+
return createEventListener(() => I().map((m) => m?.getRootNode()), "click", (m) => F(I().some((P) => P?.contains(m.target)))), P;
|
|
141
115
|
}
|
|
142
|
-
function useMutation(
|
|
143
|
-
|
|
144
|
-
createMutationObserver(
|
|
145
|
-
return ret[0];
|
|
116
|
+
function useMutation(m, P, F) {
|
|
117
|
+
let I = createSignal(F());
|
|
118
|
+
return createMutationObserver(m, P, (m) => I[1](F())), I[0];
|
|
146
119
|
}
|
|
147
|
-
function useTinykeys(
|
|
148
|
-
createEventListener(
|
|
149
|
-
|
|
150
|
-
cb(e);
|
|
120
|
+
function useTinykeys(m, P) {
|
|
121
|
+
createEventListener(m, "keydown", createKeybindingsHandler({ ...mapValues(P, (m) => (P) => {
|
|
122
|
+
P.preventDefault(), m(P);
|
|
151
123
|
}) }));
|
|
152
124
|
}
|
|
153
|
-
function useHistory([
|
|
154
|
-
let
|
|
155
|
-
const state = createMutable({
|
|
125
|
+
function useHistory([m, P]) {
|
|
126
|
+
let F = 1, I = createMutable({
|
|
156
127
|
index: -1,
|
|
157
128
|
history: []
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
state.history[++state.index] = ret;
|
|
169
|
-
}));
|
|
170
|
-
return {
|
|
171
|
-
undo,
|
|
172
|
-
redo,
|
|
173
|
-
clear,
|
|
129
|
+
}), L = () => (I.index = 0, I.history = [m()]), z = () => I.index > 0, B = () => I.index < I.history.length - 1;
|
|
130
|
+
return createRenderEffect(on(m, (m) => {
|
|
131
|
+
if (m != null) {
|
|
132
|
+
if (!F) return F = 1;
|
|
133
|
+
B() && (I.history = I.history.slice(0, I.index + 1)), I.history[++I.index] = m;
|
|
134
|
+
}
|
|
135
|
+
})), {
|
|
136
|
+
undo: () => z() && ((F = 0) || P(I.history[--I.index])),
|
|
137
|
+
redo: () => B() && ((F = 0) || P(I.history[++I.index])),
|
|
138
|
+
clear: L,
|
|
174
139
|
get index() {
|
|
175
|
-
return
|
|
140
|
+
return I.index;
|
|
176
141
|
},
|
|
177
142
|
get history() {
|
|
178
|
-
return
|
|
143
|
+
return I.history;
|
|
179
144
|
}
|
|
180
145
|
};
|
|
181
146
|
}
|
package/dist/hooks/useDir.js
CHANGED
|
@@ -2,58 +2,41 @@ import { createEffect, mergeProps } from "solid-js";
|
|
|
2
2
|
import { createEventListener } from "@solid-primitives/event-listener";
|
|
3
3
|
import { access } from "@solid-primitives/utils";
|
|
4
4
|
import { createMutationObserver } from "@solid-primitives/mutation-observer";
|
|
5
|
-
function useDir(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const ref = () => access(options.ref) ?? access(options.list);
|
|
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);
|
|
9
8
|
createEffect(() => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
13
|
-
createEventListener(ref, "keydown", (e) => {
|
|
9
|
+
s().tabIndex > -1 || (s().tabIndex = 0);
|
|
10
|
+
}), createEventListener(s, "keydown", (e) => {
|
|
14
11
|
if (![
|
|
15
12
|
"ArrowDown",
|
|
16
13
|
"ArrowUp",
|
|
17
14
|
"Enter"
|
|
18
15
|
].includes(e.key)) return;
|
|
19
|
-
e.stopPropagation();
|
|
20
|
-
|
|
21
|
-
let hover = list()?.querySelector(".hover");
|
|
16
|
+
e.stopPropagation(), e.preventDefault();
|
|
17
|
+
let n = o()?.querySelector(".hover");
|
|
22
18
|
if (e.key == "Enter") {
|
|
23
|
-
|
|
19
|
+
n?.click();
|
|
24
20
|
return;
|
|
25
21
|
}
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
hover?.classList.remove("hover");
|
|
35
|
-
el.classList.add("hover");
|
|
36
|
-
}
|
|
37
|
-
}, options.options);
|
|
38
|
-
createEffect(() => {
|
|
39
|
-
if (!options.defaultFirst) return;
|
|
40
|
-
const el = list();
|
|
41
|
-
if (!el) return;
|
|
42
|
-
const hover = () => {
|
|
43
|
-
if (el.querySelector(".hover")) return;
|
|
44
|
-
el.querySelector(`[data-index]`)?.classList.add("hover");
|
|
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");
|
|
45
30
|
};
|
|
46
|
-
createMutationObserver(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
createEventListener(list, "mouseover", () => {
|
|
50
|
-
list()?.querySelector(".hover")?.classList.remove("hover");
|
|
31
|
+
createMutationObserver(e, { childList: !0 }, n), n();
|
|
32
|
+
}), createEventListener(o, "mouseover", () => {
|
|
33
|
+
o()?.querySelector(".hover")?.classList.remove("hover");
|
|
51
34
|
});
|
|
52
35
|
}
|
|
53
|
-
function VDir(
|
|
36
|
+
function VDir(e, n) {
|
|
54
37
|
useDir({
|
|
55
|
-
...
|
|
56
|
-
list:
|
|
38
|
+
...n(),
|
|
39
|
+
list: e
|
|
57
40
|
});
|
|
58
41
|
}
|
|
59
42
|
export { VDir, useDir };
|