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.
Files changed (49) hide show
  1. package/README.md +2 -1
  2. package/dist/__uno.css +1 -1
  3. package/dist/chevron-right.js +3 -5
  4. package/dist/components/Columns.js +50 -84
  5. package/dist/components/DocTree.js +21 -29
  6. package/dist/components/Menu.js +81 -105
  7. package/dist/components/Popover.js +23 -31
  8. package/dist/components/Render.js +10 -11
  9. package/dist/components/Split.js +34 -46
  10. package/dist/components/Tree.js +38 -57
  11. package/dist/components/utils.js +4 -6
  12. package/dist/hooks/index.d.ts +1 -0
  13. package/dist/hooks/index.js +103 -130
  14. package/dist/hooks/useDir.js +22 -39
  15. package/dist/hooks/useSelector.d.ts +16 -0
  16. package/dist/hooks/useSelector.js +35 -0
  17. package/dist/hooks/useSort.js +47 -70
  18. package/dist/hooks/useVirtualizer.js +43 -68
  19. package/dist/index.d.ts +11 -4
  20. package/dist/index.js +194 -218
  21. package/dist/loading.js +3 -5
  22. package/dist/plugins/CellMergePlugin.d.ts +0 -2
  23. package/dist/plugins/CellSelectionPlugin.js +78 -117
  24. package/dist/plugins/CommandPlugin.js +11 -8
  25. package/dist/plugins/CopyPastePlugin.js +25 -37
  26. package/dist/plugins/DiffPlugin.js +33 -45
  27. package/dist/plugins/DragPlugin.d.ts +2 -2
  28. package/dist/plugins/DragPlugin.js +29 -45
  29. package/dist/plugins/EditablePlugin.js +89 -139
  30. package/dist/plugins/ExpandPlugin.d.ts +3 -5
  31. package/dist/plugins/ExpandPlugin.js +41 -47
  32. package/dist/plugins/HistoryPlugin.js +16 -21
  33. package/dist/plugins/MenuPlugin.js +52 -76
  34. package/dist/plugins/RenderPlugin/components.js +45 -63
  35. package/dist/plugins/RenderPlugin/index.js +30 -42
  36. package/dist/plugins/ResizePlugin.js +45 -80
  37. package/dist/plugins/RowGroupPlugin.js +58 -74
  38. package/dist/plugins/RowSelectionPlugin.d.ts +3 -15
  39. package/dist/plugins/RowSelectionPlugin.js +21 -48
  40. package/dist/plugins/VirtualScrollPlugin.js +54 -79
  41. package/dist/plus.js +3 -5
  42. package/dist/style.css +2 -192
  43. package/dist/theme/element-plus.scss +5 -0
  44. package/dist/utils.js +44 -65
  45. package/dist/wc.js +10 -13
  46. package/dist/x.js +3 -5
  47. package/package.json +2 -1
  48. package/dist/plugins/DragColumnPlugin.d.ts +0 -2
  49. package/dist/plugins/DragColumnPlugin.js +0 -4
package/dist/utils.js CHANGED
@@ -1,91 +1,70 @@
1
1
  import { useMemoAsync } from "./hooks/index.js";
2
2
  import { delay, isFunction, isPlainObject, isPromise } from "es-toolkit";
3
- function file2base64(file) {
4
- return new Promise((resolve, reject) => {
5
- const reader = new FileReader();
6
- reader.readAsDataURL(file);
7
- reader.onload = () => resolve(reader.result);
3
+ function file2base64(e) {
4
+ return new Promise((g, _) => {
5
+ let v = new FileReader();
6
+ v.readAsDataURL(e), v.onload = () => g(v.result);
8
7
  });
9
8
  }
10
- function chooseFile(opts) {
11
- return new Promise((resolve, reject) => {
12
- const input = document.createElement("input");
13
- input.type = "file";
14
- input.accept = opts?.accept;
15
- input.multiple = opts?.multiple;
16
- input.onchange = () => {
17
- if (input.files && input.files.length > 0) resolve(input.multiple ? [...input.files] : input.files[0]);
18
- };
19
- input.oncancel = reject;
20
- input.click();
9
+ function chooseFile(e) {
10
+ return new Promise((g, _) => {
11
+ let v = document.createElement("input");
12
+ v.type = "file", v.accept = e?.accept, v.multiple = e?.multiple, v.onchange = () => {
13
+ v.files && v.files.length > 0 && g(v.multiple ? [...v.files] : v.files[0]);
14
+ }, v.oncancel = _, v.click();
21
15
  });
22
16
  }
23
17
  function chooseImage() {
24
18
  return chooseFile({ accept: "image/*" });
25
19
  }
26
- async function print(html) {
27
- const iframe = document.createElement("iframe");
28
- iframe.srcdoc = `${[...document.querySelectorAll("style"), ...document.querySelectorAll("link[rel=\"stylesheet\"]")].map((e) => e.outerHTML).join("\n")}\n\n${html}`;
29
- Object.assign(iframe.style, {
20
+ async function print(e) {
21
+ let _ = document.createElement("iframe");
22
+ _.srcdoc = `${[...document.querySelectorAll("style"), ...document.querySelectorAll("link[rel=\"stylesheet\"]")].map((e) => e.outerHTML).join("\n")}\n\n${e}`, Object.assign(_.style, {
30
23
  position: "fixed",
31
24
  display: "none"
32
- });
33
- document.body.append(iframe);
34
- await new Promise((resolve) => iframe.contentWindow.addEventListener("load", resolve, { once: true }));
35
- await delay(300);
36
- iframe.contentWindow.print();
37
- iframe.remove();
25
+ }), document.body.append(_), await new Promise((e) => _.contentWindow.addEventListener("load", e, { once: !0 })), await delay(300), _.contentWindow.print(), _.remove();
38
26
  }
39
- function mergeRect(rect1, rect2) {
27
+ function mergeRect(e, g) {
40
28
  return DOMRect.fromRect({
41
- x: Math.min(rect1.x, rect2.x),
42
- y: Math.min(rect1.y, rect2.y),
43
- width: Math.max(rect1.right, rect2.right) - Math.min(rect1.x, rect2.x),
44
- height: Math.max(rect1.bottom, rect2.bottom) - Math.min(rect1.y, rect2.y)
29
+ x: Math.min(e.x, g.x),
30
+ y: Math.min(e.y, g.y),
31
+ width: Math.max(e.right, g.right) - Math.min(e.x, g.x),
32
+ height: Math.max(e.bottom, g.bottom) - Math.min(e.y, g.y)
45
33
  });
46
34
  }
47
- function getStyles(el = document) {
48
- return [...el.querySelectorAll("style"), ...el.querySelectorAll("link[rel=\"stylesheet\"]")].map((e) => e.outerHTML).join("\n");
35
+ function getStyles(e = document) {
36
+ return [...e.querySelectorAll("style"), ...e.querySelectorAll("link[rel=\"stylesheet\"]")].map((e) => e.outerHTML).join("\n");
49
37
  }
50
- const unFn = (fn, ...args) => typeof fn == "function" ? fn(...args) : fn;
51
- const log = (...args) => (console.log(...args), args[0]);
52
- const parseStyle = (s) => s ? s.split(";").reduce((o, e) => ((([k, v]) => o[k.trim()] = v.trim())(e.split(":")), o), {}) : {};
53
- function findret(arr, cb) {
54
- for (let i = 0; i < arr.length; i++) {
55
- const ret = cb(arr[i], i);
56
- if (ret != null) return ret;
38
+ const unFn = (e, ...g) => typeof e == "function" ? e(...g) : e, log = (...e) => (console.log(...e), e[0]), parseStyle = (e) => e ? e.split(";").reduce((e, g) => ((([g, _]) => e[g.trim()] = _.trim())(g.split(":")), e), {}) : {};
39
+ function findret(e, g) {
40
+ for (let _ = 0; _ < e.length; _++) {
41
+ let v = g(e[_], _);
42
+ if (v != null) return v;
57
43
  }
58
44
  }
59
- function emptyObject(o) {
60
- for (const k of Object.keys(o)) delete o[k];
61
- return o;
45
+ function emptyObject(e) {
46
+ for (let g of Object.keys(e)) delete e[g];
47
+ return e;
62
48
  }
63
- async function findAsync(arr, cb) {
64
- for (let i = 0; i < arr.length; i++) if (await cb(arr[i], i)) return arr[i];
49
+ async function findAsync(e, g) {
50
+ for (let _ = 0; _ < e.length; _++) if (await g(e[_], _)) return e[_];
65
51
  }
66
52
  var cache = /* @__PURE__ */ new WeakMap();
67
- function resolveOptions(opts) {
68
- let ret = opts;
69
- if (isFunction(ret)) ret = ret();
70
- if (isPromise(ret)) {
71
- if (cache.has(ret)) return cache.get(ret)();
72
- cache.set(ret, useMemoAsync(() => ret.then((e) => e.map((e$1) => resolveOptions(e$1)))));
73
- return cache.get(ret)();
74
- }
75
- if (isPlainObject(ret)) ret = Object.entries(ret).map(([k, v]) => ({
76
- value: k,
77
- label: v,
78
- ...v
79
- }));
80
- return ret?.map((e) => resolveOpt(e)) || [];
53
+ function resolveOptions(g) {
54
+ let y = g;
55
+ return isFunction(y) && (y = y()), isPromise(y) ? (cache.has(y) || cache.set(y, useMemoAsync(() => y.then((e) => e.map((e) => resolveOptions(e))))), cache.get(y)()) : (isPlainObject(y) && (y = Object.entries(y).map(([e, g]) => ({
56
+ value: e,
57
+ label: g,
58
+ ...g
59
+ }))), y?.map((e) => resolveOpt(e)) || []);
81
60
  }
82
- function resolveOpt(opt) {
83
- return isPlainObject(opt) ? opt : Array.isArray(opt) ? {
84
- label: opt[0],
85
- value: opt[1]
61
+ function resolveOpt(e) {
62
+ return isPlainObject(e) ? e : Array.isArray(e) ? {
63
+ label: e[0],
64
+ value: e[1]
86
65
  } : {
87
- label: opt,
88
- value: opt
66
+ label: e,
67
+ value: e
89
68
  };
90
69
  }
91
70
  export { chooseFile, chooseImage, emptyObject, file2base64, findAsync, findret, getStyles, log, mergeRect, parseStyle, print, resolveOptions, unFn };
package/dist/wc.js CHANGED
@@ -1,24 +1,21 @@
1
+ import { useMemoState } from "./hooks/index.js";
1
2
  import { Intable } from "./index.js";
2
3
  import { createComponent } from "solid-js/web";
3
- import { batch, createEffect, createSignal, untrack } from "solid-js";
4
- import { createMutable, reconcile } from "solid-js/store";
4
+ import { createEffect, createSignal } from "solid-js";
5
5
  import { customElement, noShadowDOM } from "solid-element";
6
6
  const TableElement = customElement("wc-table", {
7
7
  options: {},
8
8
  css: {
9
9
  value: "",
10
10
  attribute: "css",
11
- notify: true,
12
- reflect: false
11
+ notify: !0,
12
+ reflect: !1
13
13
  },
14
- theme: ""
15
- }, (attrs, { element }) => {
16
- noShadowDOM();
17
- const props = createMutable(attrs.options);
18
- createEffect(() => {
19
- const { options } = attrs;
20
- untrack(() => batch(() => reconcile(options)(props)));
21
- });
22
- return createComponent(Intable, props);
14
+ theme: "",
15
+ noShadow: !0
16
+ }, (a, { element: o }) => {
17
+ a.noShadow && noShadowDOM();
18
+ let s = useMemoState(() => a.options);
19
+ return createComponent(Intable, s);
23
20
  });
24
21
  export { TableElement };
package/dist/x.js CHANGED
@@ -1,8 +1,6 @@
1
1
  import { spread, template } from "solid-js/web";
2
- var _tmpl$ = /* @__PURE__ */ template(`<svg viewBox="0 0 24 24"width=1.2em height=1.2em><path fill=none stroke=currentColor stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M18 6L6 18M6 6l12 12">`);
3
- var x_default = (props = {}) => (() => {
4
- var _el$ = _tmpl$();
5
- spread(_el$, props, true, true);
6
- return _el$;
2
+ var _tmpl$ = /* @__PURE__ */ template("<svg viewBox=\"0 0 24 24\"width=1.2em height=1.2em><path fill=none stroke=currentColor stroke-linecap=round stroke-linejoin=round stroke-width=2 d=\"M18 6L6 18M6 6l12 12\">"), x_default = (n = {}) => (() => {
3
+ var r = _tmpl$();
4
+ return spread(r, n, !0, !0), r;
7
5
  })();
8
6
  export { x_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intable",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "files": [
@@ -10,6 +10,7 @@
10
10
  "module": "./dist/index.js",
11
11
  "exports": {
12
12
  ".": "./dist/index.js",
13
+ "./theme/*": "./dist/theme/*",
13
14
  "./*": {
14
15
  "import": "./dist/*.js",
15
16
  "types": "./dist/*.d.ts"
@@ -1,2 +0,0 @@
1
- import type { Plugin } from '..';
2
- export declare function DragColumnPlugin(): Plugin;
@@ -1,4 +0,0 @@
1
- function DragColumnPlugin() {
2
- return {};
3
- }
4
- export { DragColumnPlugin };