intable 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/README.md +263 -16
  2. package/dist/__uno.css +1 -0
  3. package/dist/chevron-right.js +6 -0
  4. package/dist/components/Columns.d.ts +3 -0
  5. package/dist/components/Columns.js +71 -0
  6. package/dist/components/DocTree.d.ts +4 -0
  7. package/dist/components/DocTree.js +32 -0
  8. package/dist/components/Menu.d.ts +1 -0
  9. package/dist/components/Menu.js +107 -0
  10. package/dist/components/Popover.d.ts +14 -0
  11. package/dist/components/Popover.js +41 -0
  12. package/dist/components/RecycleList.d.ts +26 -0
  13. package/dist/components/RecycleList.js +39 -0
  14. package/dist/components/Render.d.ts +4 -0
  15. package/dist/components/Render.js +20 -0
  16. package/dist/components/Split.d.ts +15 -0
  17. package/dist/components/Split.js +76 -0
  18. package/dist/components/Tree.d.ts +37 -0
  19. package/dist/components/Tree.js +82 -0
  20. package/dist/components/utils.d.ts +3 -0
  21. package/dist/components/utils.js +8 -0
  22. package/dist/hooks/index.d.ts +40 -0
  23. package/dist/hooks/index.js +157 -0
  24. package/dist/hooks/useDir.d.ts +11 -0
  25. package/dist/hooks/useDir.js +42 -0
  26. package/dist/hooks/useSelector.d.ts +16 -0
  27. package/dist/hooks/useSelector.js +69 -0
  28. package/dist/hooks/useSort.d.ts +18 -0
  29. package/dist/hooks/useSort.js +83 -0
  30. package/dist/hooks/useVirtualizer.d.ts +30 -0
  31. package/dist/hooks/useVirtualizer.js +97 -0
  32. package/dist/index.d.ts +147 -0
  33. package/dist/index.js +386 -0
  34. package/dist/loading.js +6 -0
  35. package/dist/plugins/CellChangeHighlightPlugin.d.ts +2 -0
  36. package/dist/plugins/CellChangeHighlightPlugin.js +4 -0
  37. package/dist/plugins/CellMergePlugin.d.ts +45 -0
  38. package/dist/plugins/CellMergePlugin.js +78 -0
  39. package/dist/plugins/CellSelectionPlugin.d.ts +15 -0
  40. package/dist/plugins/CellSelectionPlugin.js +113 -0
  41. package/dist/plugins/CommandPlugin.d.ts +14 -0
  42. package/dist/plugins/CommandPlugin.js +31 -0
  43. package/dist/plugins/CopyPastePlugin.d.ts +14 -0
  44. package/dist/plugins/CopyPastePlugin.js +47 -0
  45. package/dist/plugins/DiffPlugin.d.ts +29 -0
  46. package/dist/plugins/DiffPlugin.js +66 -0
  47. package/dist/plugins/DragPlugin.d.ts +14 -0
  48. package/dist/plugins/DragPlugin.js +47 -0
  49. package/dist/plugins/EditablePlugin.d.ts +51 -0
  50. package/dist/plugins/EditablePlugin.js +177 -0
  51. package/dist/plugins/ExpandPlugin.d.ts +18 -0
  52. package/dist/plugins/ExpandPlugin.js +46 -0
  53. package/dist/plugins/HeaderGroup.d.ts +11 -0
  54. package/dist/plugins/HeaderGroup.js +171 -0
  55. package/dist/plugins/HistoryPlugin.d.ts +10 -0
  56. package/dist/plugins/HistoryPlugin.js +27 -0
  57. package/dist/plugins/MenuPlugin.d.ts +19 -0
  58. package/dist/plugins/MenuPlugin.js +132 -0
  59. package/dist/plugins/RenderPlugin/components.d.ts +5 -0
  60. package/dist/plugins/RenderPlugin/components.js +87 -0
  61. package/dist/plugins/RenderPlugin/index.d.ts +30 -0
  62. package/dist/plugins/RenderPlugin/index.js +49 -0
  63. package/dist/plugins/ResizePlugin.d.ts +27 -0
  64. package/dist/plugins/ResizePlugin.js +82 -0
  65. package/dist/plugins/RowGroupPlugin.d.ts +18 -0
  66. package/dist/plugins/RowGroupPlugin.js +88 -0
  67. package/dist/plugins/RowSelectionPlugin.d.ts +20 -0
  68. package/dist/plugins/RowSelectionPlugin.js +42 -0
  69. package/dist/plugins/TreePlugin.d.ts +24 -0
  70. package/dist/plugins/TreePlugin.js +110 -0
  71. package/dist/plugins/VirtualScrollPlugin.d.ts +15 -0
  72. package/dist/plugins/VirtualScrollPlugin.js +123 -0
  73. package/dist/plugins/ZodValidatorPlugin.d.ts +38 -0
  74. package/dist/plugins/ZodValidatorPlugin.js +12 -0
  75. package/dist/plus.js +6 -0
  76. package/dist/rolldown_runtime.js +9 -0
  77. package/dist/style.css +3 -0
  78. package/dist/theme/dark.scss +46 -0
  79. package/dist/theme/github.scss +80 -0
  80. package/dist/theme/material.scss +73 -0
  81. package/dist/theme/shadcn.scss +66 -0
  82. package/dist/theme/stripe.scss +57 -0
  83. package/dist/tree.d.ts +1 -0
  84. package/dist/tree.js +12 -0
  85. package/dist/types/auto-imports.d.js +0 -0
  86. package/dist/utils.d.ts +31 -0
  87. package/dist/utils.js +71 -0
  88. package/dist/wc.d.ts +1 -0
  89. package/dist/wc.js +21 -0
  90. package/dist/web-component.d.ts +1 -0
  91. package/dist/web-component.js +2 -0
  92. package/dist/x.js +6 -0
  93. package/package.json +38 -30
  94. package/docs/index-BaMALNy6.css +0 -1
  95. package/docs/index-CDN48t9E.js +0 -3
  96. package/docs/index-Cc4RNkLY.css +0 -1
  97. package/docs/index-MRnbkYmU.js +0 -3
  98. package/docs/index.html +0 -15
  99. package/docs/vite.svg +0 -1
  100. package/index.html +0 -14
  101. package/packages/intable/README.md +0 -379
  102. package/packages/intable/package.json +0 -51
  103. package/packages/intable/src/assets/ClearFormat.svg +0 -3
  104. package/packages/intable/src/assets/Forms.svg +0 -4
  105. package/packages/intable/src/assets/MergeCell.svg +0 -4
  106. package/packages/intable/src/assets/SplitCell.svg +0 -4
  107. package/packages/intable/src/assets/gap.svg +0 -3
  108. package/packages/intable/src/assets/loading.svg +0 -12
  109. package/packages/intable/src/assets/paint.svg +0 -9
  110. package/packages/intable/src/assets/solid.svg +0 -1
  111. package/packages/intable/src/components/Columns.tsx +0 -86
  112. package/packages/intable/src/components/DocTree.tsx +0 -36
  113. package/packages/intable/src/components/Menu.tsx +0 -109
  114. package/packages/intable/src/components/Popover.tsx +0 -55
  115. package/packages/intable/src/components/RecycleList.tsx +0 -99
  116. package/packages/intable/src/components/Render.tsx +0 -26
  117. package/packages/intable/src/components/Split.tsx +0 -56
  118. package/packages/intable/src/components/Tree.tsx +0 -115
  119. package/packages/intable/src/components/utils.tsx +0 -12
  120. package/packages/intable/src/hooks/index.ts +0 -200
  121. package/packages/intable/src/hooks/useDir.ts +0 -78
  122. package/packages/intable/src/hooks/useSelector.ts +0 -91
  123. package/packages/intable/src/hooks/useSort.tsx +0 -118
  124. package/packages/intable/src/hooks/useVirtualizer.ts +0 -180
  125. package/packages/intable/src/index.tsx +0 -481
  126. package/packages/intable/src/plugins/CellChangeHighlightPlugin.tsx +0 -5
  127. package/packages/intable/src/plugins/CellMergePlugin.tsx +0 -153
  128. package/packages/intable/src/plugins/CellSelectionPlugin.tsx +0 -175
  129. package/packages/intable/src/plugins/CommandPlugin.tsx +0 -74
  130. package/packages/intable/src/plugins/CopyPastePlugin.tsx +0 -63
  131. package/packages/intable/src/plugins/DiffPlugin.tsx +0 -107
  132. package/packages/intable/src/plugins/DragPlugin.tsx +0 -81
  133. package/packages/intable/src/plugins/EditablePlugin.tsx +0 -252
  134. package/packages/intable/src/plugins/ExpandPlugin.tsx +0 -80
  135. package/packages/intable/src/plugins/HeaderGroup.tsx +0 -289
  136. package/packages/intable/src/plugins/HistoryPlugin.tsx +0 -49
  137. package/packages/intable/src/plugins/MenuPlugin.tsx +0 -195
  138. package/packages/intable/src/plugins/RenderPlugin/components.tsx +0 -51
  139. package/packages/intable/src/plugins/RenderPlugin/index.tsx +0 -81
  140. package/packages/intable/src/plugins/ResizePlugin.tsx +0 -122
  141. package/packages/intable/src/plugins/RowGroupPlugin.tsx +0 -122
  142. package/packages/intable/src/plugins/RowSelectionPlugin.tsx +0 -65
  143. package/packages/intable/src/plugins/TreePlugin.tsx +0 -212
  144. package/packages/intable/src/plugins/VirtualScrollPlugin.tsx +0 -190
  145. package/packages/intable/src/plugins/ZodValidatorPlugin.tsx +0 -61
  146. package/packages/intable/src/style.scss +0 -244
  147. package/packages/intable/src/tree.ts +0 -13
  148. package/packages/intable/src/types/auto-imports.d.ts +0 -13
  149. package/packages/intable/src/utils.ts +0 -122
  150. package/packages/intable/src/wc.tsx +0 -35
  151. package/packages/intable/src/web-component.ts +0 -1
  152. package/packages/react/package.json +0 -31
  153. package/packages/react/src/index.ts +0 -44
  154. package/packages/react/src/plugins/antd.ts +0 -94
  155. package/packages/react/src/style.scss +0 -12
  156. package/packages/react/src/types/auto-imports.d.ts +0 -10
  157. package/packages/vue/package.json +0 -34
  158. package/packages/vue/src/index.ts +0 -63
  159. package/packages/vue/src/plugins/element-plus.ts +0 -69
  160. package/packages/vue/src/style.scss +0 -12
  161. package/packages/vue/src/types/auto-imports.d.ts +0 -10
  162. package/pnpm-workspace.yaml +0 -2
  163. package/public/vite.svg +0 -1
  164. package/scripts/build.js +0 -184
  165. package/scripts/publish.js +0 -95
  166. package/src/assets/ClearFormat.svg +0 -3
  167. package/src/assets/Forms.svg +0 -4
  168. package/src/assets/MergeCell.svg +0 -4
  169. package/src/assets/SplitCell.svg +0 -4
  170. package/src/assets/gap.svg +0 -3
  171. package/src/assets/loading.svg +0 -12
  172. package/src/assets/paint.svg +0 -9
  173. package/src/assets/solid.svg +0 -1
  174. package/src/demo-vue.ts +0 -54
  175. package/src/demo.tsx +0 -107
  176. package/src/index.scss +0 -105
  177. package/src/styles/index.scss +0 -172
  178. package/src/types/auto-imports.d.ts +0 -13
  179. package/stats.html +0 -4949
  180. package/tsconfig.app.json +0 -34
  181. package/tsconfig.json +0 -7
  182. package/tsconfig.node.json +0 -26
  183. package/vite.config.ts +0 -63
  184. /package/{packages/intable/src → dist}/theme/antd.scss +0 -0
  185. /package/{packages/intable/src → dist}/theme/element-plus.scss +0 -0
@@ -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,4 @@
1
+ export declare function createRender({ is, processProps }?: {
2
+ processProps?: (e: any) => any;
3
+ }): (props: any) => import("solid-js").JSX.Element;
4
+ export declare const Render: (props: any) => import("solid-js").JSX.Element;
@@ -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,3 @@
1
+ import type { JSX } from 'solid-js';
2
+ export declare function solidComponent<T extends (...arg: any[]) => JSX.Element>(comp: T): T;
3
+ export declare function renderComponent(Comp: any, props: any, renderer: any): JSX.Element;
@@ -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,40 @@
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 useMemoState(fn: any): {};
40
+ export {};
@@ -0,0 +1,157 @@
1
+ import { unFn } from "../utils.js";
2
+ import { $PROXY, batch, createComputed, createEffect, createMemo, createRenderEffect, createRoot, createSignal, mergeProps, on, onCleanup, 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, 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) => {
20
+ createPointerListeners({
21
+ target: document,
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
29
+ });
30
+ },
31
+ onUp() {
32
+ V?.(h), L(), B = void 0, V = void 0;
33
+ }
34
+ }), createEventListenerMap(document, { drop: L });
35
+ });
36
+ }
37
+ });
38
+ }
39
+ function model(h, L) {
40
+ let [R, z] = L();
41
+ createRenderEffect(() => h.value = R()), h.addEventListener("input", (h) => z(h.target.value));
42
+ }
43
+ function toSignle(h, L) {
44
+ return [() => h[L], (R) => h[L] = R];
45
+ }
46
+ function useDark() {
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()), {
48
+ name: "color-schema",
49
+ storage: localStorage,
50
+ sync: storageSync,
51
+ serialize: L,
52
+ deserialize: h
53
+ });
54
+ return createEffect(() => document.documentElement.classList[z[0]() ? "add" : "remove"]("dark")), createEffect(() => window.dispatchEvent(new StorageEvent("storage", {
55
+ key: "color-schema",
56
+ newValue: L(z[0]())
57
+ }))), z;
58
+ }
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;
67
+ }
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()));
76
+ }
77
+ return [V, R[1]];
78
+ }
79
+ var $MEMO = Symbol();
80
+ function toReactive(R) {
81
+ let z = () => unFn(R), B = () => !0, V = (h) => ((h) => typeof h == "function" && $MEMO in h ? h() : h)(z()[h]);
82
+ return new Proxy(Object.create(null), {
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,
93
+ get() {
94
+ return V(L);
95
+ },
96
+ set: B
97
+ })
98
+ });
99
+ }
100
+ function useMemo(h) {
101
+ let L = createMemo(h);
102
+ return L[$MEMO] = 1, L;
103
+ }
104
+ function useHover(h) {
105
+ let [L, R] = createSignal(!1);
106
+ return createEventListener(h, "pointerenter", () => R(!0)), createEventListener(h, "pointerleave", () => R(!1)), L;
107
+ }
108
+ function useMouseDown(h) {
109
+ let [L, R] = createSignal(!1);
110
+ return createEventListener(h, "pointerdown", () => R(!0)), createEventListener(document.body, "pointerup", () => R(!1)), L;
111
+ }
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;
115
+ }
116
+ function useMutation(h, L, R) {
117
+ let z = createSignal(R());
118
+ return createMutationObserver(h, L, (h) => z[1](R())), z[0];
119
+ }
120
+ function useTinykeys(h, L) {
121
+ createEventListener(h, "keydown", createKeybindingsHandler({ ...mapValues(L, (h) => (L) => {
122
+ L.preventDefault(), h(L);
123
+ }) }));
124
+ }
125
+ function useHistory([h, L]) {
126
+ let R = 1, z = createMutable({
127
+ index: -1,
128
+ history: []
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,
139
+ get index() {
140
+ return z.index;
141
+ },
142
+ get history() {
143
+ return z.history;
144
+ }
145
+ };
146
+ }
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 };
@@ -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 {};