intable 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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 +1 -0
- package/dist/hooks/index.js +103 -130
- package/dist/hooks/useDir.js +22 -39
- package/dist/hooks/useSelector.d.ts +16 -0
- package/dist/hooks/useSelector.js +35 -0
- package/dist/hooks/useSort.js +47 -70
- package/dist/hooks/useVirtualizer.js +43 -68
- package/dist/index.d.ts +11 -4
- package/dist/index.js +194 -218
- package/dist/loading.js +3 -5
- package/dist/plugins/CellMergePlugin.d.ts +0 -2
- package/dist/plugins/CellSelectionPlugin.js +78 -117
- package/dist/plugins/CommandPlugin.js +11 -8
- package/dist/plugins/CopyPastePlugin.js +25 -37
- package/dist/plugins/DiffPlugin.js +33 -45
- package/dist/plugins/DragPlugin.d.ts +2 -2
- package/dist/plugins/DragPlugin.js +29 -45
- package/dist/plugins/EditablePlugin.js +89 -139
- package/dist/plugins/ExpandPlugin.d.ts +3 -5
- package/dist/plugins/ExpandPlugin.js +41 -47
- package/dist/plugins/HistoryPlugin.js +16 -21
- package/dist/plugins/MenuPlugin.js +52 -76
- package/dist/plugins/RenderPlugin/components.js +45 -63
- package/dist/plugins/RenderPlugin/index.js +30 -42
- package/dist/plugins/ResizePlugin.js +45 -80
- package/dist/plugins/RowGroupPlugin.js +58 -74
- package/dist/plugins/RowSelectionPlugin.d.ts +3 -15
- package/dist/plugins/RowSelectionPlugin.js +21 -48
- package/dist/plugins/VirtualScrollPlugin.js +54 -79
- package/dist/plus.js +3 -5
- package/dist/style.css +2 -192
- package/dist/theme/element-plus.scss +5 -0
- package/dist/utils.js +44 -65
- package/dist/wc.js +10 -13
- package/dist/x.js +3 -5
- package/package.json +2 -1
- 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
package/dist/hooks/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { unFn } from "../utils.js";
|
|
2
|
-
import { $PROXY, createComputed, createEffect, createMemo, createRenderEffect, createRoot, createSignal, mergeProps, on, onCleanup, untrack } from "solid-js";
|
|
2
|
+
import { $PROXY, batch, 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
5
|
import { createEventListener, createEventListenerMap } from "@solid-primitives/event-listener";
|
|
@@ -9,176 +9,149 @@ 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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
let move;
|
|
21
|
-
let end;
|
|
22
|
-
options.start?.(e, (cb) => move = cb, (cb) => end = cb);
|
|
23
|
-
createRoot((dispose) => {
|
|
12
|
+
function usePointerDrag(h, L) {
|
|
13
|
+
L = mergeProps({ preventDefault: !0 }, L), createPointerListeners({
|
|
14
|
+
target: h,
|
|
15
|
+
passive: !1,
|
|
16
|
+
onDown(h) {
|
|
17
|
+
L.preventDefault && h.preventDefault();
|
|
18
|
+
let [R, z] = [h.x, h.y], B, V;
|
|
19
|
+
L.start?.(h, (h) => B = h, (h) => V = h), createRoot((L) => {
|
|
24
20
|
createPointerListeners({
|
|
25
21
|
target: document,
|
|
26
|
-
onMove(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
sx,
|
|
30
|
-
sy,
|
|
31
|
-
ox,
|
|
32
|
-
oy
|
|
22
|
+
onMove(h) {
|
|
23
|
+
let [L, V] = [h.x - R, h.y - z];
|
|
24
|
+
B?.(h, {
|
|
25
|
+
sx: R,
|
|
26
|
+
sy: z,
|
|
27
|
+
ox: L,
|
|
28
|
+
oy: V
|
|
33
29
|
});
|
|
34
30
|
},
|
|
35
31
|
onUp() {
|
|
36
|
-
|
|
37
|
-
dispose();
|
|
38
|
-
move = void 0;
|
|
39
|
-
end = void 0;
|
|
32
|
+
V?.(h), L(), B = void 0, V = void 0;
|
|
40
33
|
}
|
|
41
|
-
});
|
|
42
|
-
createEventListenerMap(document, { drop: dispose });
|
|
34
|
+
}), createEventListenerMap(document, { drop: L });
|
|
43
35
|
});
|
|
44
36
|
}
|
|
45
37
|
});
|
|
46
38
|
}
|
|
47
|
-
function model(
|
|
48
|
-
|
|
49
|
-
createRenderEffect(() =>
|
|
50
|
-
el.addEventListener("input", (e) => setField(e.target.value));
|
|
39
|
+
function model(h, L) {
|
|
40
|
+
let [R, z] = L();
|
|
41
|
+
createRenderEffect(() => h.value = R()), h.addEventListener("input", (h) => z(h.target.value));
|
|
51
42
|
}
|
|
52
|
-
function toSignle(
|
|
53
|
-
return [() =>
|
|
43
|
+
function toSignle(h, L) {
|
|
44
|
+
return [() => h[L], (R) => h[L] = R];
|
|
54
45
|
}
|
|
55
46
|
function useDark() {
|
|
56
|
-
|
|
57
|
-
const prefersDark = () => window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
58
|
-
const dark = makePersisted(createSignal(prefersDark()), {
|
|
47
|
+
let h = (h) => h == "dark" || R() && !h, L = (h) => h ? "dark" : "light", R = () => window.matchMedia("(prefers-color-scheme: dark)").matches, z = makePersisted(createSignal(R()), {
|
|
59
48
|
name: "color-schema",
|
|
60
49
|
storage: localStorage,
|
|
61
50
|
sync: storageSync,
|
|
62
|
-
serialize:
|
|
63
|
-
deserialize:
|
|
51
|
+
serialize: L,
|
|
52
|
+
deserialize: h
|
|
64
53
|
});
|
|
65
|
-
createEffect(() => document.documentElement.classList[
|
|
66
|
-
createEffect(() => window.dispatchEvent(new StorageEvent("storage", {
|
|
54
|
+
return createEffect(() => document.documentElement.classList[z[0]() ? "add" : "remove"]("dark")), createEffect(() => window.dispatchEvent(new StorageEvent("storage", {
|
|
67
55
|
key: "color-schema",
|
|
68
|
-
newValue:
|
|
69
|
-
})));
|
|
70
|
-
return dark;
|
|
56
|
+
newValue: L(z[0]())
|
|
57
|
+
}))), z;
|
|
71
58
|
}
|
|
72
|
-
function useMemoAsync(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}) : ret;
|
|
81
|
-
v == REJECT || setVal(() => v);
|
|
82
|
-
});
|
|
83
|
-
return val;
|
|
59
|
+
function useMemoAsync(h, L) {
|
|
60
|
+
let R = Symbol(), [B, V] = createSignal(L);
|
|
61
|
+
return createComputed(async () => {
|
|
62
|
+
let L = h(untrack(B)), z = L instanceof Promise ? await new Promise((h) => {
|
|
63
|
+
L.then(h), onCleanup(() => h(R));
|
|
64
|
+
}) : L;
|
|
65
|
+
z == R || V(() => z);
|
|
66
|
+
}), B;
|
|
84
67
|
}
|
|
85
|
-
function useSignle2(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const fned = useMemoAsync(() => before(v()));
|
|
94
|
-
createComputed(() => state[1](fned()));
|
|
68
|
+
function useSignle2(h, L) {
|
|
69
|
+
let R = createSignal(isFunction(h) ? void 0 : h), B = (h) => {
|
|
70
|
+
let R = L?.before?.(h);
|
|
71
|
+
return isPromise(R) ? R.then((L) => L === void 0 ? h : L) : R ?? h;
|
|
72
|
+
}, V = useMemoAsync(() => B(R[0]()));
|
|
73
|
+
if (isFunction(h)) {
|
|
74
|
+
let L = useMemoAsync(() => B(h()));
|
|
75
|
+
createComputed(() => R[1](L()));
|
|
95
76
|
}
|
|
96
|
-
return [
|
|
77
|
+
return [V, R[1]];
|
|
97
78
|
}
|
|
98
79
|
var $MEMO = Symbol();
|
|
99
|
-
function toReactive(
|
|
100
|
-
|
|
101
|
-
const trueFn = () => true;
|
|
102
|
-
const get = (k) => ((e) => typeof e == "function" && $MEMO in e ? e() : e)(v()[k]);
|
|
80
|
+
function toReactive(R) {
|
|
81
|
+
let z = () => unFn(R), B = () => !0, V = (h) => ((h) => typeof h == "function" && $MEMO in h ? h() : h)(z()[h]);
|
|
103
82
|
return new Proxy(Object.create(null), {
|
|
104
|
-
get: (
|
|
105
|
-
set:
|
|
106
|
-
defineProperty: (
|
|
107
|
-
deleteProperty:
|
|
108
|
-
getPrototypeOf: () => Object.getPrototypeOf(
|
|
109
|
-
has: (
|
|
110
|
-
ownKeys: (
|
|
111
|
-
getOwnPropertyDescriptor: (
|
|
112
|
-
enumerable:
|
|
113
|
-
configurable:
|
|
83
|
+
get: (h, R, B) => R == $PROXY || R == $RAW ? B : ((h) => typeof h == "function" && $MEMO in h ? h() : h)(z()[R]),
|
|
84
|
+
set: B,
|
|
85
|
+
defineProperty: (h, L, R) => Object.defineProperty(z(), L, R),
|
|
86
|
+
deleteProperty: B,
|
|
87
|
+
getPrototypeOf: () => Object.getPrototypeOf(z()),
|
|
88
|
+
has: (h, R) => R == $PROXY || R in z(),
|
|
89
|
+
ownKeys: (h) => Object.keys(z()),
|
|
90
|
+
getOwnPropertyDescriptor: (h, L) => ({
|
|
91
|
+
enumerable: !0,
|
|
92
|
+
configurable: !0,
|
|
114
93
|
get() {
|
|
115
|
-
return
|
|
94
|
+
return V(L);
|
|
116
95
|
},
|
|
117
|
-
set:
|
|
96
|
+
set: B
|
|
118
97
|
})
|
|
119
98
|
});
|
|
120
99
|
}
|
|
121
|
-
function useMemo(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return ret;
|
|
100
|
+
function useMemo(h) {
|
|
101
|
+
let L = createMemo(h);
|
|
102
|
+
return L[$MEMO] = 1, L;
|
|
125
103
|
}
|
|
126
|
-
function useHover(
|
|
127
|
-
|
|
128
|
-
createEventListener(
|
|
129
|
-
createEventListener(el, "pointerleave", () => setHover(false));
|
|
130
|
-
return hover;
|
|
104
|
+
function useHover(h) {
|
|
105
|
+
let [L, R] = createSignal(!1);
|
|
106
|
+
return createEventListener(h, "pointerenter", () => R(!0)), createEventListener(h, "pointerleave", () => R(!1)), L;
|
|
131
107
|
}
|
|
132
|
-
function useMouseDown(
|
|
133
|
-
|
|
134
|
-
createEventListener(
|
|
135
|
-
createEventListener(document.body, "pointerup", () => setDown(false));
|
|
136
|
-
return down;
|
|
108
|
+
function useMouseDown(h) {
|
|
109
|
+
let [L, R] = createSignal(!1);
|
|
110
|
+
return createEventListener(h, "pointerdown", () => R(!0)), createEventListener(document.body, "pointerup", () => R(!1)), L;
|
|
137
111
|
}
|
|
138
|
-
function useClicked(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
createEventListener(() => els().map((e) => e?.getRootNode()), "click", (e) => setClicked(els().some((el$1) => el$1?.contains(e.target))));
|
|
142
|
-
return clicked;
|
|
112
|
+
function useClicked(h) {
|
|
113
|
+
let [L, R] = createSignal(!1), z = () => castArray(access(h));
|
|
114
|
+
return createEventListener(() => z().map((h) => h?.getRootNode()), "click", (h) => R(z().some((L) => L?.contains(h.target)))), L;
|
|
143
115
|
}
|
|
144
|
-
function useMutation(
|
|
145
|
-
|
|
146
|
-
createMutationObserver(
|
|
147
|
-
return ret[0];
|
|
116
|
+
function useMutation(h, L, R) {
|
|
117
|
+
let z = createSignal(R());
|
|
118
|
+
return createMutationObserver(h, L, (h) => z[1](R())), z[0];
|
|
148
119
|
}
|
|
149
|
-
function useTinykeys(
|
|
150
|
-
createEventListener(
|
|
151
|
-
|
|
152
|
-
cb(e);
|
|
120
|
+
function useTinykeys(h, L) {
|
|
121
|
+
createEventListener(h, "keydown", createKeybindingsHandler({ ...mapValues(L, (h) => (L) => {
|
|
122
|
+
L.preventDefault(), h(L);
|
|
153
123
|
}) }));
|
|
154
124
|
}
|
|
155
|
-
function useHistory([
|
|
156
|
-
let
|
|
157
|
-
const state = createMutable({
|
|
125
|
+
function useHistory([h, L]) {
|
|
126
|
+
let R = 1, z = createMutable({
|
|
158
127
|
index: -1,
|
|
159
128
|
history: []
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
state.history[++state.index] = ret;
|
|
171
|
-
}));
|
|
172
|
-
return {
|
|
173
|
-
undo,
|
|
174
|
-
redo,
|
|
175
|
-
clear,
|
|
129
|
+
}), B = () => (z.index = 0, z.history = [h()]), V = () => z.index > 0, H = () => z.index < z.history.length - 1;
|
|
130
|
+
return createRenderEffect(on(h, (h) => {
|
|
131
|
+
if (h != null) {
|
|
132
|
+
if (!R) return R = 1;
|
|
133
|
+
H() && (z.history = z.history.slice(0, z.index + 1)), z.history[++z.index] = h;
|
|
134
|
+
}
|
|
135
|
+
})), {
|
|
136
|
+
undo: () => V() && ((R = 0) || L(z.history[--z.index])),
|
|
137
|
+
redo: () => H() && ((R = 0) || L(z.history[++z.index])),
|
|
138
|
+
clear: B,
|
|
176
139
|
get index() {
|
|
177
|
-
return
|
|
140
|
+
return z.index;
|
|
178
141
|
},
|
|
179
142
|
get history() {
|
|
180
|
-
return
|
|
143
|
+
return z.history;
|
|
181
144
|
}
|
|
182
145
|
};
|
|
183
146
|
}
|
|
184
|
-
|
|
147
|
+
function useMemoState(h) {
|
|
148
|
+
let L = createMutable({});
|
|
149
|
+
return createComputed(() => {
|
|
150
|
+
let z = h();
|
|
151
|
+
untrack(() => batch(() => {
|
|
152
|
+
for (let h in L) h in z || delete L[h];
|
|
153
|
+
Object.assign(L, z);
|
|
154
|
+
}));
|
|
155
|
+
}), L;
|
|
156
|
+
}
|
|
157
|
+
export { model, toReactive, toSignle, useClicked, useDark, useHistory, useHover, useMemo, useMemoAsync, useMemoState, useMouseDown, useMutation, usePointerDrag, useSignle2, useTinykeys };
|
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 };
|