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.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -1
  3. package/dist/__uno.css +1 -1
  4. package/dist/chevron-right.js +3 -5
  5. package/dist/components/Columns.js +50 -84
  6. package/dist/components/DocTree.js +21 -29
  7. package/dist/components/Menu.js +81 -105
  8. package/dist/components/Popover.js +23 -31
  9. package/dist/components/Render.js +10 -11
  10. package/dist/components/Split.js +34 -46
  11. package/dist/components/Tree.js +38 -57
  12. package/dist/components/utils.js +4 -6
  13. package/dist/hooks/index.d.ts +3 -2
  14. package/dist/hooks/index.js +93 -128
  15. package/dist/hooks/useDir.js +22 -39
  16. package/dist/hooks/useSort.d.ts +18 -0
  17. package/dist/hooks/useSort.js +83 -0
  18. package/dist/hooks/useVirtualizer.js +43 -68
  19. package/dist/index.d.ts +8 -2
  20. package/dist/index.js +175 -213
  21. package/dist/loading.js +3 -5
  22. package/dist/plugins/CellMergePlugin.d.ts +12 -0
  23. package/dist/plugins/CellMergePlugin.js +2 -0
  24. package/dist/plugins/CellSelectionPlugin.js +89 -125
  25. package/dist/plugins/CommandPlugin.js +3 -6
  26. package/dist/plugins/CopyPastePlugin.js +24 -37
  27. package/dist/plugins/DiffPlugin.js +33 -45
  28. package/dist/plugins/DragPlugin.d.ts +14 -0
  29. package/dist/plugins/DragPlugin.js +47 -0
  30. package/dist/plugins/EditablePlugin.js +88 -139
  31. package/dist/plugins/ExpandPlugin.js +26 -30
  32. package/dist/plugins/HistoryPlugin.js +16 -21
  33. package/dist/plugins/MenuPlugin.js +51 -76
  34. package/dist/plugins/RenderPlugin/components.js +45 -63
  35. package/dist/plugins/RenderPlugin/index.js +29 -42
  36. package/dist/plugins/ResizePlugin.d.ts +2 -2
  37. package/dist/plugins/ResizePlugin.js +71 -94
  38. package/dist/plugins/RowGroupPlugin.js +57 -73
  39. package/dist/plugins/RowSelectionPlugin.js +31 -42
  40. package/dist/plugins/VirtualScrollPlugin.js +54 -79
  41. package/dist/plus.js +3 -5
  42. package/dist/style.css +2 -184
  43. package/dist/utils.d.ts +1 -0
  44. package/dist/utils.js +46 -64
  45. package/dist/wc.js +11 -11
  46. package/dist/x.js +3 -5
  47. package/package.json +3 -2
  48. package/dist/plugins/DragColumnPlugin.d.ts +0 -2
  49. package/dist/plugins/DragColumnPlugin.js +0 -4
package/dist/utils.js CHANGED
@@ -1,88 +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;
48
+ }
49
+ async function findAsync(e, g) {
50
+ for (let _ = 0; _ < e.length; _++) if (await g(e[_], _)) return e[_];
62
51
  }
63
52
  var cache = /* @__PURE__ */ new WeakMap();
64
- function resolveOptions(opts) {
65
- let ret = opts;
66
- if (isFunction(ret)) ret = ret();
67
- if (isPromise(ret)) {
68
- if (cache.has(ret)) return cache.get(ret)();
69
- cache.set(ret, useMemoAsync(() => ret.then((e) => e.map((e$1) => resolveOptions(e$1)))));
70
- return cache.get(ret)();
71
- }
72
- if (isPlainObject(ret)) ret = Object.entries(ret).map(([k, v]) => ({
73
- value: k,
74
- label: v,
75
- ...v
76
- }));
77
- 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)) || []);
78
60
  }
79
- function resolveOpt(opt) {
80
- return isPlainObject(opt) ? opt : Array.isArray(opt) ? {
81
- label: opt[0],
82
- value: opt[1]
61
+ function resolveOpt(e) {
62
+ return isPlainObject(e) ? e : Array.isArray(e) ? {
63
+ label: e[0],
64
+ value: e[1]
83
65
  } : {
84
- label: opt,
85
- value: opt
66
+ label: e,
67
+ value: e
86
68
  };
87
69
  }
88
- export { chooseFile, chooseImage, emptyObject, file2base64, findret, getStyles, log, mergeRect, parseStyle, print, resolveOptions, unFn };
70
+ export { chooseFile, chooseImage, emptyObject, file2base64, findAsync, findret, getStyles, log, mergeRect, parseStyle, print, resolveOptions, unFn };
package/dist/wc.js CHANGED
@@ -8,17 +8,17 @@ const TableElement = customElement("wc-table", {
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
+ }, (c, { element: l }) => {
17
+ c.noShadow && noShadowDOM();
18
+ let u = createMutable(c.options);
19
+ return createEffect(() => {
20
+ let { options: e } = c;
21
+ untrack(() => batch(() => reconcile(e)(u)));
22
+ }), createComponent(Intable, u);
23
23
  });
24
24
  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.2",
3
+ "version": "0.0.4",
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"
@@ -46,4 +47,4 @@
46
47
  "devDependencies": {
47
48
  "diff": "^8.0.2"
48
49
  }
49
- }
50
+ }
@@ -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 };