intable 0.0.8 → 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.
- package/README.md +263 -16
- package/dist/__uno.css +1 -0
- package/dist/chevron-right.js +6 -0
- package/dist/components/Columns.d.ts +3 -0
- package/dist/components/Columns.js +71 -0
- package/dist/components/DocTree.d.ts +4 -0
- package/dist/components/DocTree.js +32 -0
- package/dist/components/Menu.d.ts +1 -0
- package/dist/components/Menu.js +107 -0
- package/dist/components/Popover.d.ts +14 -0
- package/dist/components/Popover.js +41 -0
- package/dist/components/RecycleList.d.ts +26 -0
- package/dist/components/RecycleList.js +39 -0
- package/dist/components/Render.d.ts +4 -0
- package/dist/components/Render.js +20 -0
- package/dist/components/Split.d.ts +15 -0
- package/dist/components/Split.js +76 -0
- package/dist/components/Tree.d.ts +37 -0
- package/dist/components/Tree.js +82 -0
- package/dist/components/utils.d.ts +3 -0
- package/dist/components/utils.js +8 -0
- package/dist/hooks/index.d.ts +40 -0
- package/dist/hooks/index.js +157 -0
- package/dist/hooks/useDir.d.ts +11 -0
- package/dist/hooks/useDir.js +42 -0
- package/dist/hooks/useSelector.d.ts +16 -0
- package/dist/hooks/useSelector.js +69 -0
- package/dist/hooks/useSort.d.ts +18 -0
- package/dist/hooks/useSort.js +83 -0
- package/dist/hooks/useVirtualizer.d.ts +30 -0
- package/dist/hooks/useVirtualizer.js +97 -0
- package/dist/index.d.ts +147 -0
- package/dist/index.js +386 -0
- package/dist/loading.js +6 -0
- package/dist/plugins/CellChangeHighlightPlugin.d.ts +2 -0
- package/dist/plugins/CellChangeHighlightPlugin.js +4 -0
- package/dist/plugins/CellMergePlugin.d.ts +45 -0
- package/dist/plugins/CellMergePlugin.js +78 -0
- package/dist/plugins/CellSelectionPlugin.d.ts +15 -0
- package/dist/plugins/CellSelectionPlugin.js +113 -0
- package/dist/plugins/CommandPlugin.d.ts +14 -0
- package/dist/plugins/CommandPlugin.js +31 -0
- package/dist/plugins/CopyPastePlugin.d.ts +14 -0
- package/dist/plugins/CopyPastePlugin.js +47 -0
- package/dist/plugins/DiffPlugin.d.ts +29 -0
- package/dist/plugins/DiffPlugin.js +66 -0
- package/dist/plugins/DragPlugin.d.ts +14 -0
- package/dist/plugins/DragPlugin.js +47 -0
- package/dist/plugins/EditablePlugin.d.ts +51 -0
- package/dist/plugins/EditablePlugin.js +177 -0
- package/dist/plugins/ExpandPlugin.d.ts +18 -0
- package/dist/plugins/ExpandPlugin.js +46 -0
- package/dist/plugins/HeaderGroup.d.ts +11 -0
- package/dist/plugins/HeaderGroup.js +171 -0
- package/dist/plugins/HistoryPlugin.d.ts +10 -0
- package/dist/plugins/HistoryPlugin.js +27 -0
- package/dist/plugins/MenuPlugin.d.ts +19 -0
- package/dist/plugins/MenuPlugin.js +132 -0
- package/dist/plugins/RenderPlugin/components.d.ts +5 -0
- package/dist/plugins/RenderPlugin/components.js +87 -0
- package/dist/plugins/RenderPlugin/index.d.ts +30 -0
- package/dist/plugins/RenderPlugin/index.js +49 -0
- package/dist/plugins/ResizePlugin.d.ts +27 -0
- package/dist/plugins/ResizePlugin.js +82 -0
- package/dist/plugins/RowGroupPlugin.d.ts +18 -0
- package/dist/plugins/RowGroupPlugin.js +88 -0
- package/dist/plugins/RowSelectionPlugin.d.ts +20 -0
- package/dist/plugins/RowSelectionPlugin.js +42 -0
- package/dist/plugins/TreePlugin.d.ts +24 -0
- package/dist/plugins/TreePlugin.js +110 -0
- package/dist/plugins/VirtualScrollPlugin.d.ts +15 -0
- package/dist/plugins/VirtualScrollPlugin.js +123 -0
- package/dist/plugins/ZodValidatorPlugin.d.ts +38 -0
- package/dist/plugins/ZodValidatorPlugin.js +12 -0
- package/dist/plus.js +6 -0
- package/dist/rolldown_runtime.js +9 -0
- package/dist/style.css +3 -0
- package/dist/tree.d.ts +1 -0
- package/dist/tree.js +12 -0
- package/dist/types/auto-imports.d.js +0 -0
- package/dist/utils.d.ts +31 -0
- package/dist/utils.js +71 -0
- package/dist/wc.d.ts +1 -0
- package/dist/wc.js +21 -0
- package/dist/web-component.d.ts +1 -0
- package/dist/web-component.js +2 -0
- package/dist/x.js +6 -0
- package/package.json +38 -35
- package/.github/copilot-instructions.md +0 -102
- package/docs/index-BaMALNy6.css +0 -1
- package/docs/index-CDN48t9E.js +0 -3
- package/docs/index-Cc4RNkLY.css +0 -1
- package/docs/index-MRnbkYmU.js +0 -3
- package/docs/index.html +0 -15
- package/docs/vite.svg +0 -1
- package/index.html +0 -13
- package/packages/intable/README.md +0 -379
- package/packages/intable/package.json +0 -51
- package/packages/intable/src/assets/ClearFormat.svg +0 -3
- package/packages/intable/src/assets/Forms.svg +0 -4
- package/packages/intable/src/assets/MergeCell.svg +0 -4
- package/packages/intable/src/assets/SplitCell.svg +0 -4
- package/packages/intable/src/assets/gap.svg +0 -3
- package/packages/intable/src/assets/loading.svg +0 -12
- package/packages/intable/src/assets/paint.svg +0 -9
- package/packages/intable/src/assets/solid.svg +0 -1
- package/packages/intable/src/components/Columns.tsx +0 -86
- package/packages/intable/src/components/DocTree.tsx +0 -36
- package/packages/intable/src/components/Menu.tsx +0 -109
- package/packages/intable/src/components/Popover.tsx +0 -55
- package/packages/intable/src/components/RecycleList.tsx +0 -99
- package/packages/intable/src/components/Render.tsx +0 -26
- package/packages/intable/src/components/Split.tsx +0 -56
- package/packages/intable/src/components/Tree.tsx +0 -115
- package/packages/intable/src/components/utils.tsx +0 -12
- package/packages/intable/src/hooks/index.ts +0 -200
- package/packages/intable/src/hooks/useDir.ts +0 -78
- package/packages/intable/src/hooks/useSelector.ts +0 -91
- package/packages/intable/src/hooks/useSort.tsx +0 -118
- package/packages/intable/src/hooks/useVirtualizer.ts +0 -180
- package/packages/intable/src/index.tsx +0 -489
- package/packages/intable/src/plugins/CellChangeHighlightPlugin.tsx +0 -5
- package/packages/intable/src/plugins/CellMergePlugin.tsx +0 -153
- package/packages/intable/src/plugins/CellSelectionPlugin.tsx +0 -175
- package/packages/intable/src/plugins/CommandPlugin.tsx +0 -74
- package/packages/intable/src/plugins/CopyPastePlugin.tsx +0 -99
- package/packages/intable/src/plugins/DiffPlugin.tsx +0 -120
- package/packages/intable/src/plugins/DragPlugin.tsx +0 -81
- package/packages/intable/src/plugins/EditablePlugin.tsx +0 -252
- package/packages/intable/src/plugins/ExpandPlugin.tsx +0 -80
- package/packages/intable/src/plugins/HeaderGroup.tsx +0 -289
- package/packages/intable/src/plugins/HistoryPlugin.tsx +0 -49
- package/packages/intable/src/plugins/MenuPlugin.tsx +0 -195
- package/packages/intable/src/plugins/RenderPlugin/components.tsx +0 -51
- package/packages/intable/src/plugins/RenderPlugin/index.tsx +0 -81
- package/packages/intable/src/plugins/ResizePlugin.tsx +0 -122
- package/packages/intable/src/plugins/RowGroupPlugin.tsx +0 -122
- package/packages/intable/src/plugins/RowSelectionPlugin.tsx +0 -65
- package/packages/intable/src/plugins/TreePlugin.tsx +0 -212
- package/packages/intable/src/plugins/VirtualScrollPlugin.tsx +0 -190
- package/packages/intable/src/plugins/ZodValidatorPlugin.tsx +0 -61
- package/packages/intable/src/style.scss +0 -244
- package/packages/intable/src/tree.ts +0 -13
- package/packages/intable/src/types/auto-imports.d.ts +0 -13
- package/packages/intable/src/utils.ts +0 -122
- package/packages/intable/src/wc.tsx +0 -35
- package/packages/intable/src/web-component.ts +0 -1
- package/packages/react/package.json +0 -36
- package/packages/react/src/index.ts +0 -44
- package/packages/react/src/plugins/antd.ts +0 -94
- package/packages/react/src/style.scss +0 -12
- package/packages/react/src/types/auto-imports.d.ts +0 -10
- package/packages/vue/package.json +0 -34
- package/packages/vue/src/index.ts +0 -63
- package/packages/vue/src/plugins/element-plus.ts +0 -69
- package/packages/vue/src/style.scss +0 -12
- package/packages/vue/src/types/auto-imports.d.ts +0 -10
- package/pnpm-workspace.yaml +0 -2
- package/public/vite.svg +0 -1
- package/scripts/build.js +0 -184
- package/scripts/publish.js +0 -95
- package/src/assets/ClearFormat.svg +0 -3
- package/src/assets/Forms.svg +0 -4
- package/src/assets/MergeCell.svg +0 -4
- package/src/assets/SplitCell.svg +0 -4
- package/src/assets/gap.svg +0 -3
- package/src/assets/loading.svg +0 -12
- package/src/assets/paint.svg +0 -9
- package/src/assets/solid.svg +0 -1
- package/src/demo-vue.ts +0 -54
- package/src/index.scss +0 -105
- package/src/index.tsx +0 -20
- package/src/pages/demo/BasicDemo.tsx +0 -19
- package/src/pages/demo/CellMergeDemo.tsx +0 -41
- package/src/pages/demo/CellSelectionDemo.tsx +0 -24
- package/src/pages/demo/CompositeDemo.tsx +0 -60
- package/src/pages/demo/CopyPasteDemo.tsx +0 -26
- package/src/pages/demo/DiffDemo.tsx +0 -33
- package/src/pages/demo/DragDemo.tsx +0 -25
- package/src/pages/demo/EditableDemo.tsx +0 -58
- package/src/pages/demo/ExpandDemo.tsx +0 -32
- package/src/pages/demo/HeaderGroupDemo.tsx +0 -36
- package/src/pages/demo/HistoryDemo.tsx +0 -28
- package/src/pages/demo/ReactDemo.tsx +0 -59
- package/src/pages/demo/ResizeDemo.tsx +0 -24
- package/src/pages/demo/RowGroupDemo.tsx +0 -43
- package/src/pages/demo/RowSelectionDemo.tsx +0 -27
- package/src/pages/demo/TreeDemo.tsx +0 -45
- package/src/pages/demo/VirtualScrollDemo.tsx +0 -21
- package/src/pages/demo/helpers.tsx +0 -39
- package/src/pages/demo/index.tsx +0 -180
- package/src/pages/index.tsx +0 -2
- package/src/pages/website.scss +0 -37
- package/src/pages/website.tsx +0 -651
- package/src/styles/index.scss +0 -172
- package/src/types/auto-imports.d.ts +0 -13
- package/stats.html +0 -4949
- package/tsconfig.app.json +0 -34
- package/tsconfig.json +0 -7
- package/tsconfig.node.json +0 -26
- package/vite.config.ts +0 -70
- /package/{packages/intable/src → dist}/theme/antd.scss +0 -0
- /package/{packages/intable/src → dist}/theme/dark.scss +0 -0
- /package/{packages/intable/src → dist}/theme/element-plus.scss +0 -0
- /package/{packages/intable/src → dist}/theme/github.scss +0 -0
- /package/{packages/intable/src → dist}/theme/material.scss +0 -0
- /package/{packages/intable/src → dist}/theme/shadcn.scss +0 -0
- /package/{packages/intable/src → dist}/theme/stripe.scss +0 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import chevron_right_default from "../chevron-right.js";
|
|
2
|
+
import { Ctx } from "../index.js";
|
|
3
|
+
import { createComponent, delegateEvents, effect, insert, memo, mergeProps, style, template } from "solid-js/web";
|
|
4
|
+
import { batch, createMemo, useContext } from "solid-js";
|
|
5
|
+
import { groupBy, zipObject } from "es-toolkit";
|
|
6
|
+
import { findLast } from "es-toolkit/compat";
|
|
7
|
+
var _tmpl$ = /* @__PURE__ */ template("<div class=\"flex items-center\">"), pathKey = (e) => e.join("\0");
|
|
8
|
+
const RowGroupPlugin = {
|
|
9
|
+
priority: -Infinity,
|
|
10
|
+
store: (e) => ({ rowGroup: {
|
|
11
|
+
expandKeys: {},
|
|
12
|
+
isExpand: (l) => !!e.rowGroup.expandKeys[pathKey(l[GROUP].path)],
|
|
13
|
+
expand: (l, u) => batch(() => u ? l[GROUP].path2.forEach((l) => {
|
|
14
|
+
e.rowGroup.expandKeys[pathKey(l[GROUP].path)] = !0;
|
|
15
|
+
}) : e.rowGroup.expandKeys[pathKey(l[GROUP].path)] = !0),
|
|
16
|
+
toggleExpand: (l) => {
|
|
17
|
+
let u = pathKey(l[GROUP].path);
|
|
18
|
+
e.rowGroup.expandKeys[u] ? delete e.rowGroup.expandKeys[u] : e.rowGroup.expandKeys[u] = !0;
|
|
19
|
+
}
|
|
20
|
+
} }),
|
|
21
|
+
commands: (e, { addRows: l }) => ({ addRows(u, d, f) {
|
|
22
|
+
let { data: p, rowGroup: m, rowKey: h } = e.props;
|
|
23
|
+
if (m?.fields?.length) {
|
|
24
|
+
let m = findLast(p, (e) => e[GROUP], u);
|
|
25
|
+
if (m && p[u][GROUP]) {
|
|
26
|
+
let l = function e(l) {
|
|
27
|
+
return l[GROUP]?.children[0]?.[GROUP] ? e(l[GROUP].children[0]) : l;
|
|
28
|
+
}(m);
|
|
29
|
+
e.rowGroup.expand(l, !0);
|
|
30
|
+
let d = l[GROUP].children[0];
|
|
31
|
+
u = e.props.data.indexOf(d), f = !0;
|
|
32
|
+
}
|
|
33
|
+
l?.(u, d, f);
|
|
34
|
+
} else l?.(...arguments);
|
|
35
|
+
} }),
|
|
36
|
+
rewriteProps: {
|
|
37
|
+
data: ({ data: e }, { store: l }) => l.props?.rowGroup?.fields?.length ? expandData(e, l) : e,
|
|
38
|
+
newRow: ({ newRow: e }, { store: l }) => function(u) {
|
|
39
|
+
let d = e(...arguments), { data: f, rowGroup: p } = l.props;
|
|
40
|
+
if (p?.fields?.length) {
|
|
41
|
+
let e = findLast(f, (e) => e[GROUP], u);
|
|
42
|
+
if (e) {
|
|
43
|
+
let l = function e(l) {
|
|
44
|
+
return l[GROUP]?.children[0]?.[GROUP] ? e(l[GROUP].children[0]) : l;
|
|
45
|
+
}(e), u = zipObject(p.fields, l[GROUP].path);
|
|
46
|
+
Object.assign(d, u);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return d;
|
|
50
|
+
},
|
|
51
|
+
Td: ({ Td: d }, { store: _ }) => (v) => {
|
|
52
|
+
if (!v.data?.[GROUP]) return createComponent(d, v);
|
|
53
|
+
let { props: y } = useContext(Ctx), b = createMemo(() => _.rowGroup.isExpand(v.data));
|
|
54
|
+
return createComponent(d, mergeProps(v, { get children() {
|
|
55
|
+
return memo(() => y.columns?.findIndex((e) => !e[_.internal]) == v.x)() ? (() => {
|
|
56
|
+
var l = _tmpl$();
|
|
57
|
+
return l.$$dblclick = () => _.rowGroup.toggleExpand(v.data), insert(l, createComponent(chevron_right_default, {
|
|
58
|
+
class: "icon-clickable mr-2",
|
|
59
|
+
get style() {
|
|
60
|
+
return `transform: rotate(${b() ? 90 : 0}deg); opacity: .6`;
|
|
61
|
+
},
|
|
62
|
+
onClick: () => _.rowGroup.toggleExpand(v.data)
|
|
63
|
+
}), null), insert(l, () => v.data[GROUP].value, null), effect((e) => style(l, `padding-left: ${(v.data[GROUP].path.length - 1) * 16}px`, e)), l;
|
|
64
|
+
})() : v.children;
|
|
65
|
+
} }));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var GROUP = Symbol("row-group"), expandData = (e, l, u = []) => {
|
|
70
|
+
let d = l.props.rowGroup.fields, f = l.props.columns.find((e) => !e[l.internal]);
|
|
71
|
+
if (!f || d.length == u.length) return e;
|
|
72
|
+
let p = u[u.length - 1]?.[GROUP].path || [], m = groupBy(e, (e) => e[d[p.length]]);
|
|
73
|
+
return Object.keys(m).flatMap((e) => {
|
|
74
|
+
let d = {
|
|
75
|
+
[f.id]: e,
|
|
76
|
+
[l.internal]: 1
|
|
77
|
+
}, h = [...u, d];
|
|
78
|
+
d[GROUP] = {
|
|
79
|
+
path: [...p, e],
|
|
80
|
+
value: e,
|
|
81
|
+
path2: h
|
|
82
|
+
}, d[GROUP].children = expandData(m[e], l, h);
|
|
83
|
+
let g = l.rowGroup.isExpand(d) ? d[GROUP].children : [];
|
|
84
|
+
return [d, ...g];
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
delegateEvents(["dblclick"]);
|
|
88
|
+
export { RowGroupPlugin };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Plugin } from '..';
|
|
2
|
+
import { useSelector } from '../hooks/useSelector';
|
|
3
|
+
declare module '../index' {
|
|
4
|
+
interface TableProps {
|
|
5
|
+
rowSelection?: {
|
|
6
|
+
enable?: boolean;
|
|
7
|
+
multiple?: boolean;
|
|
8
|
+
value?: any;
|
|
9
|
+
selectable?: (row: any) => boolean;
|
|
10
|
+
onChange?: (selected: any) => void;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
interface TableStore {
|
|
14
|
+
rowSelectionCol: TableColumn;
|
|
15
|
+
}
|
|
16
|
+
interface Commands {
|
|
17
|
+
rowSelector: ReturnType<typeof useSelector>;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export declare const RowSelectionPlugin: Plugin;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Checkbox } from "./RenderPlugin/components.js";
|
|
2
|
+
import { solidComponent } from "../components/utils.js";
|
|
3
|
+
import { useSelector } from "../hooks/useSelector.js";
|
|
4
|
+
import { createComponent, insert, template } from "solid-js/web";
|
|
5
|
+
import { mergeProps as mergeProps$1 } from "solid-js";
|
|
6
|
+
import { defaultsDeep } from "es-toolkit/compat";
|
|
7
|
+
var _tmpl$ = /* @__PURE__ */ template("<label>");
|
|
8
|
+
const RowSelectionPlugin = {
|
|
9
|
+
name: "row-selection",
|
|
10
|
+
priority: -Infinity,
|
|
11
|
+
store: (c) => ({ rowSelectionCol: {
|
|
12
|
+
[c.internal]: 1,
|
|
13
|
+
id: Symbol("row-selection"),
|
|
14
|
+
fixed: "left",
|
|
15
|
+
class: "row-selection",
|
|
16
|
+
width: 45,
|
|
17
|
+
resizable: !1,
|
|
18
|
+
render: solidComponent((s) => (() => {
|
|
19
|
+
var l = _tmpl$();
|
|
20
|
+
return insert(l, createComponent(Checkbox, {
|
|
21
|
+
style: "position: absolute",
|
|
22
|
+
get value() {
|
|
23
|
+
return c.commands.rowSelector.has(s.data);
|
|
24
|
+
},
|
|
25
|
+
onChange: (e) => e ? c.commands.rowSelector.add(s.data) : c.commands.rowSelector.del(s.data),
|
|
26
|
+
get disabled() {
|
|
27
|
+
return !c.props?.rowSelection?.selectable?.(s.data);
|
|
28
|
+
}
|
|
29
|
+
})), l;
|
|
30
|
+
})())
|
|
31
|
+
} }),
|
|
32
|
+
commands: (e) => ({ rowSelector: useSelector(mergeProps$1(() => ({ ...e.props?.rowSelection }))) }),
|
|
33
|
+
rewriteProps: {
|
|
34
|
+
rowSelection: ({ rowSelection: e }) => defaultsDeep(e, {
|
|
35
|
+
enable: !1,
|
|
36
|
+
multiple: !1,
|
|
37
|
+
selectable: () => !0
|
|
38
|
+
}),
|
|
39
|
+
columns: ({ columns: e }, { store: s }) => s.props?.rowSelection?.enable ? [s.rowSelectionCol, ...e] : e
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export { RowSelectionPlugin };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Plugin$0 } from '../index';
|
|
2
|
+
import { useSelector } from '../hooks/useSelector';
|
|
3
|
+
declare module '../index' {
|
|
4
|
+
interface TableProps {
|
|
5
|
+
tree?: {
|
|
6
|
+
/** Field name that holds children rows. Default: `'children'`. */
|
|
7
|
+
children?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
interface TableStore {
|
|
11
|
+
tree: ReturnType<typeof useSelector<any[]>>;
|
|
12
|
+
/**
|
|
13
|
+
* Lookup map populated as a side-effect of the `data` rewriteProp.
|
|
14
|
+
* Maps each row's rowKey → its tree metadata.
|
|
15
|
+
* Written via createMutable so reads are reactive.
|
|
16
|
+
*/
|
|
17
|
+
_treeMeta: Map<any, {
|
|
18
|
+
depth: number;
|
|
19
|
+
hasChildren: boolean;
|
|
20
|
+
parentKey: any;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export declare const TreePlugin: Plugin$0;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { useSelector } from "../hooks/useSelector.js";
|
|
2
|
+
import chevron_right_default from "../chevron-right.js";
|
|
3
|
+
import { createComponent, effect, insert, memo, mergeProps, style, template } from "solid-js/web";
|
|
4
|
+
import { combineProps } from "@solid-primitives/props";
|
|
5
|
+
import { createLazyMemo } from "@solid-primitives/memo";
|
|
6
|
+
var _tmpl$ = /* @__PURE__ */ template("<div class=\"flex items-center\">"), _tmpl$2 = /* @__PURE__ */ template("<span style=display:inline-block;width:16px;flex-shrink:0;margin-right:4px>");
|
|
7
|
+
function flattenTree(e, t, n, r, i = 0, a = null, o = [], s = /* @__PURE__ */ new Map()) {
|
|
8
|
+
for (let c of e || []) {
|
|
9
|
+
let e = c[n], l = c[t], u = Array.isArray(l) && l.length > 0;
|
|
10
|
+
s.set(e, {
|
|
11
|
+
depth: i,
|
|
12
|
+
hasChildren: u,
|
|
13
|
+
parentKey: a
|
|
14
|
+
}), o.push(c), u && r(e) && flattenTree(l, t, n, r, i + 1, e, o, s);
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
flat: o,
|
|
18
|
+
meta: s
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const TreePlugin = (c) => {
|
|
22
|
+
let m = createLazyMemo(() => c.props.columns?.findIndex((e) => !e[c.internal]) ?? -1);
|
|
23
|
+
return {
|
|
24
|
+
name: "tree",
|
|
25
|
+
store: (t) => ({
|
|
26
|
+
tree: useSelector({ multiple: !0 }),
|
|
27
|
+
_treeMeta: /* @__PURE__ */ new Map()
|
|
28
|
+
}),
|
|
29
|
+
rewriteProps: {
|
|
30
|
+
tree: ({ tree: e }) => ({
|
|
31
|
+
children: "children",
|
|
32
|
+
...e
|
|
33
|
+
}),
|
|
34
|
+
data: ({ data: e }, { store: t }) => {
|
|
35
|
+
if (!t.props?.tree) return e;
|
|
36
|
+
let n = t.props.tree.children || "children", r = t.props.rowKey, { flat: i, meta: a } = flattenTree(e, n, r, (e) => t.tree.has(e));
|
|
37
|
+
return t._treeMeta = a, i;
|
|
38
|
+
},
|
|
39
|
+
Td: ({ Td: e }, { store: c }) => (u) => {
|
|
40
|
+
let p = () => c.props.rowKey, h = () => c._treeMeta?.get(u.data?.[p()]);
|
|
41
|
+
return u = combineProps(u, { onDblClick() {
|
|
42
|
+
h()?.hasChildren && c.tree.toggle(u.data?.[p()]);
|
|
43
|
+
} }), createComponent(e, mergeProps(u, { get children() {
|
|
44
|
+
return memo(() => u.x === m())() ? (() => {
|
|
45
|
+
var e = _tmpl$();
|
|
46
|
+
return insert(e, (() => {
|
|
47
|
+
var e = memo(() => !!h()?.hasChildren);
|
|
48
|
+
return () => e() ? createComponent(chevron_right_default, {
|
|
49
|
+
class: "icon-clickable mr-1",
|
|
50
|
+
get style() {
|
|
51
|
+
return `transform: rotate(${c.tree.has(u.data?.[p()]) ? 90 : 0}deg); opacity: .6; flex-shrink: 0; transition: transform .15s`;
|
|
52
|
+
},
|
|
53
|
+
onClick: (e) => {
|
|
54
|
+
e.stopPropagation(), c.tree.toggle(u.data?.[p()]);
|
|
55
|
+
}
|
|
56
|
+
}) : _tmpl$2();
|
|
57
|
+
})(), null), insert(e, () => u.children, null), effect((t) => style(e, `padding-left: ${h()?.depth * 16}px`, t)), e;
|
|
58
|
+
})() : u.children;
|
|
59
|
+
} }));
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
commands: (e, { addRows: t }) => ({ addRows(n, r, i = !0) {
|
|
63
|
+
if (!e.props?.tree) return t?.(n, r, i);
|
|
64
|
+
let { data: a, rowKey: o } = e.props, s = e.props.tree.children || "children", c = a[n];
|
|
65
|
+
if (c?.[e.internal]) {
|
|
66
|
+
let t = null, r = null;
|
|
67
|
+
for (let r = n - 1; r >= 0; r--) if (!a[r]?.[e.internal]) {
|
|
68
|
+
t = a[r];
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
for (let t = n + 1; t < a.length; t++) if (!a[t]?.[e.internal]) {
|
|
72
|
+
r = a[t];
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
c = i ? t || r : r || t;
|
|
76
|
+
}
|
|
77
|
+
if (!c) return t?.(n, r, i);
|
|
78
|
+
let l = c[o], u = e._treeMeta?.get(l);
|
|
79
|
+
if (!u || u.depth === 0) return t?.(n, r, i);
|
|
80
|
+
let d = u.parentKey, f = a.findIndex((e) => e[o] === l);
|
|
81
|
+
if (f >= 0 && e.selected) {
|
|
82
|
+
let t = f + (i ? 0 : 1);
|
|
83
|
+
e.selected.start = [0, t], e.selected.end = [Infinity, t + r.length - 1];
|
|
84
|
+
}
|
|
85
|
+
let p = [...e.rawProps.data || []];
|
|
86
|
+
function m(e) {
|
|
87
|
+
for (let t = 0; t < e.length; t++) {
|
|
88
|
+
let n = e[t];
|
|
89
|
+
if (n[o] === d) {
|
|
90
|
+
let a = [...n[s] || []], c = a.findIndex((e) => e[o] === l), u = c >= 0 ? c + (i ? 0 : 1) : a.length;
|
|
91
|
+
return a.splice(u, 0, ...r), e[t] = {
|
|
92
|
+
...n,
|
|
93
|
+
[s]: a
|
|
94
|
+
}, !0;
|
|
95
|
+
}
|
|
96
|
+
if (Array.isArray(n[s]) && n[s].length) {
|
|
97
|
+
let r = [...n[s]];
|
|
98
|
+
if (m(r)) return e[t] = {
|
|
99
|
+
...n,
|
|
100
|
+
[s]: r
|
|
101
|
+
}, !0;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return !1;
|
|
105
|
+
}
|
|
106
|
+
m(p), e.tree.has(d) || e.tree.toggle(d), e.props?.onDataChange?.(p);
|
|
107
|
+
} })
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
export { TreePlugin };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useVirtualizer } from '../hooks/useVirtualizer';
|
|
2
|
+
import { type Plugin } from '..';
|
|
3
|
+
declare module '../index' {
|
|
4
|
+
interface TableProps {
|
|
5
|
+
virtual?: {
|
|
6
|
+
x?: Partial<Parameters<typeof useVirtualizer>[0]>;
|
|
7
|
+
y?: Partial<Parameters<typeof useVirtualizer>[0]>;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
interface TableStore {
|
|
11
|
+
virtualizerY: ReturnType<typeof useVirtualizer>;
|
|
12
|
+
virtualizerX: ReturnType<typeof useVirtualizer>;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export declare const VirtualScrollPlugin: Plugin;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Ctx } from "../index.js";
|
|
2
|
+
import { RecycleList } from "../components/RecycleList.js";
|
|
3
|
+
import { useVirtualizer } from "../hooks/useVirtualizer.js";
|
|
4
|
+
import { createComponent, mergeProps } from "solid-js/web";
|
|
5
|
+
import { createEffect, createMemo, mergeProps as mergeProps$1, useContext } from "solid-js";
|
|
6
|
+
import { combineProps } from "@solid-primitives/props";
|
|
7
|
+
import { defaultsDeep } from "es-toolkit/compat";
|
|
8
|
+
import { defaultRangeExtractor } from "@tanstack/solid-virtual";
|
|
9
|
+
var $ML = Symbol();
|
|
10
|
+
const VirtualScrollPlugin = {
|
|
11
|
+
name: "virtual-scroll",
|
|
12
|
+
rewriteProps: {
|
|
13
|
+
virtual: ({ virtual: e }) => defaultsDeep(e, {
|
|
14
|
+
x: { overscan: 5 },
|
|
15
|
+
y: { overscan: 10 }
|
|
16
|
+
}),
|
|
17
|
+
Table: ({ Table: i }, { store: s }) => (f) => {
|
|
18
|
+
let p, { props: m } = useContext(Ctx), h = useVirtualizer(mergeProps$1(() => m.virtual?.y, {
|
|
19
|
+
getScrollElement: () => p,
|
|
20
|
+
get count() {
|
|
21
|
+
return m.data?.length || 0;
|
|
22
|
+
},
|
|
23
|
+
estimateSize: () => 32,
|
|
24
|
+
indexAttribute: "y",
|
|
25
|
+
extras: (e, i) => {
|
|
26
|
+
let a = s._mergeMap?.();
|
|
27
|
+
if (!a?.spans.size) return [];
|
|
28
|
+
let o = s.virtualizerX, c = o ? o.startIdx() : 0, l = o ? o.endIdx() : Infinity, u = [];
|
|
29
|
+
for (let [o, s] of a.spans) {
|
|
30
|
+
if (s.rowspan <= 1) continue;
|
|
31
|
+
let [a, d] = o.split(",").map(Number);
|
|
32
|
+
if (a > i || a + s.rowspan - 1 < e || d > l || d + s.colspan - 1 < c) continue;
|
|
33
|
+
for (let e = 0; e < s.rowspan; e++) u.push(a + e);
|
|
34
|
+
}
|
|
35
|
+
return u;
|
|
36
|
+
}
|
|
37
|
+
})), g = useVirtualizer(mergeProps$1(() => m.virtual?.x, {
|
|
38
|
+
horizontal: !0,
|
|
39
|
+
getScrollElement: () => p,
|
|
40
|
+
get count() {
|
|
41
|
+
return m.columns?.length || 0;
|
|
42
|
+
},
|
|
43
|
+
estimateSize: (e) => m.columns?.[e].width ?? 40,
|
|
44
|
+
indexAttribute: "x",
|
|
45
|
+
rangeExtractor(e) {
|
|
46
|
+
return [...new Set([...m.columns?.map((e, i) => e.fixed ? i : void 0).filter((e) => e != null) || [], ...defaultRangeExtractor(e)])];
|
|
47
|
+
},
|
|
48
|
+
extras: (e, i) => {
|
|
49
|
+
let a = m.columns?.map((e, i) => e.fixed ? i : void 0).filter((e) => e != null) || [], o = s._headerGroupAnchors?.(e, i) || [], c = new Set([...a, ...o]), l = s._mergeMap?.();
|
|
50
|
+
if (!l?.spans.size) return [...c];
|
|
51
|
+
let u = h.startIdx(), d = h.endIdx();
|
|
52
|
+
for (let [a, o] of l.spans) {
|
|
53
|
+
if (o.colspan <= 1) continue;
|
|
54
|
+
let [s, l] = a.split(",").map(Number);
|
|
55
|
+
if (s > d || s + o.rowspan - 1 < u || l > i || l + o.colspan - 1 < e) continue;
|
|
56
|
+
for (let e = 0; e < o.colspan; e++) c.add(l + e);
|
|
57
|
+
}
|
|
58
|
+
return [...c];
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
61
|
+
return s.virtualizerY = h, s.virtualizerX = g, s[$ML] = createMemo(() => {
|
|
62
|
+
let e = s.virtualizerX.getVirtualItems(), i = {};
|
|
63
|
+
for (let a = 1; a < e.length; a++) {
|
|
64
|
+
let o = e[a], s = e[a - 1];
|
|
65
|
+
o.index - s.index > 1 && (i[o.index] = {
|
|
66
|
+
item: o,
|
|
67
|
+
offset: o.start - s.end
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return i;
|
|
71
|
+
}), f = combineProps({
|
|
72
|
+
ref: (e) => p = e,
|
|
73
|
+
class: "virtual"
|
|
74
|
+
}, f), createEffect(() => {
|
|
75
|
+
let { table: e } = s;
|
|
76
|
+
e.style.width = s.virtualizerX.getTotalSize() + "px", e.style.height = s.virtualizerY.getTotalSize() + (s.thead?.offsetHeight || 0) + "px";
|
|
77
|
+
}), createComponent(i, f);
|
|
78
|
+
},
|
|
79
|
+
Thead: ({ Thead: e }, { store: i }) => (a) => (a = combineProps({ get style() {
|
|
80
|
+
return `transform: translate(${i.virtualizerX.getVirtualItems()[0]?.start}px, 0px);`;
|
|
81
|
+
} }, a), createComponent(e, a)),
|
|
82
|
+
Tbody: ({ Tbody: e }, { store: i }) => (a) => (a = combineProps({ get style() {
|
|
83
|
+
return `transform: translate(${i.virtualizerX.getVirtualItems()[0]?.start}px, ${i.virtualizerY.getVirtualItems()[0]?.start}px)`;
|
|
84
|
+
} }, a), createComponent(e, a)),
|
|
85
|
+
Tr: ({ Tr: e }, { store: i }) => (a) => (createEffect(() => a.y != null && i.trSizes[a.y] && i.virtualizerY.resizeItem(a.y, i.trSizes[a.y].height)), createComponent(e, a)),
|
|
86
|
+
Td: ({ Td: e }, { store: i }) => (a) => {
|
|
87
|
+
let s = createMemo(() => i[$ML]()[a.x]), c = combineProps({ get style() {
|
|
88
|
+
let e = a.colspan ?? 1;
|
|
89
|
+
return `width: ${e > 1 ? Array.from({ length: e }, (e, o) => i.props.columns?.[a.x + o]?.width ?? 80).reduce((e, i) => e + i, 0) : a.col.width || 80}px; margin-left: ${a.col.fixed ? 0 : s()?.offset ?? 0}px`;
|
|
90
|
+
} }, a);
|
|
91
|
+
return createComponent(e, c);
|
|
92
|
+
},
|
|
93
|
+
Th: ({ Th: e }, { store: i }) => (a) => {
|
|
94
|
+
createEffect(() => (a.colspan ?? 1) === 1 && i.thSizes[a.x] && i.virtualizerX.resizeItem(a.x, i.thSizes[a.x].width));
|
|
95
|
+
let s = createMemo(() => i[$ML]?.()[a.x]), u = combineProps({ get style() {
|
|
96
|
+
let e = a.colspan ?? 1;
|
|
97
|
+
return `width: ${e > 1 ? Array.from({ length: e }, (e, o) => i.props.columns?.[a.x + o]?.width ?? 80).reduce((e, i) => e + i, 0) : a.col.width || 80}px; margin-left: ${a.col.fixed ? 0 : s()?.offset ?? 0}px`;
|
|
98
|
+
} }, a);
|
|
99
|
+
return createComponent(e, u);
|
|
100
|
+
},
|
|
101
|
+
EachRows: ({ EachRows: e }, { store: a }) => (c) => {
|
|
102
|
+
e = RecycleList;
|
|
103
|
+
let u = createMemo(() => a.virtualizerY.getVirtualItems().map((e) => c.each[e.index]));
|
|
104
|
+
return createComponent(e, mergeProps(c, {
|
|
105
|
+
get each() {
|
|
106
|
+
return u();
|
|
107
|
+
},
|
|
108
|
+
children: (e, i) => c.children(e, createMemo(() => a.virtualizerY.getVirtualItems()[i()]?.index))
|
|
109
|
+
}));
|
|
110
|
+
},
|
|
111
|
+
EachCells: ({ EachCells: e }, { store: a }) => (c) => {
|
|
112
|
+
if (e = RecycleList, c.each?.length !== a.virtualizerX?.options?.count) return createComponent(e, c);
|
|
113
|
+
let u = createMemo(() => a.virtualizerX.getVirtualItems().map((e) => c.each[e.index]));
|
|
114
|
+
return createComponent(e, mergeProps(c, {
|
|
115
|
+
get each() {
|
|
116
|
+
return u();
|
|
117
|
+
},
|
|
118
|
+
children: (e, i) => c.children(e, createMemo(() => a.virtualizerX.getVirtualItems()[i()]?.index))
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
export { VirtualScrollPlugin };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ZodType } from 'zod';
|
|
2
|
+
import type { Plugin } from '..';
|
|
3
|
+
declare module '../index' {
|
|
4
|
+
interface TableColumn {
|
|
5
|
+
/**
|
|
6
|
+
* Zod schema to validate the edited value for this column.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* { id: 'age', zodSchema: z.number().int().min(0).max(150) }
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
zodSchema?: ZodType<any, any, any>;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* ZodValidatorPlugin — three-level validation pipeline for editable cells.
|
|
17
|
+
*
|
|
18
|
+
* Validation runs in order; the first failure short-circuits the rest:
|
|
19
|
+
* 1. `col.zodSchema` — Zod schema declared on the column
|
|
20
|
+
* 2. `col.validator` — per-column custom validator function
|
|
21
|
+
* 3. `props.validator` — table-level validator (passed as a prop to `<Intable>`)
|
|
22
|
+
*
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const cols = [
|
|
25
|
+
* {
|
|
26
|
+
* id: 'email',
|
|
27
|
+
* zodSchema: z.string().email('Invalid email'),
|
|
28
|
+
* validator: async (value) => {
|
|
29
|
+
* const taken = await checkEmailTaken(value)
|
|
30
|
+
* return taken ? 'Email already in use' : true
|
|
31
|
+
* },
|
|
32
|
+
* },
|
|
33
|
+
* { id: 'age', zodSchema: z.coerce.number().int().min(0).max(150) },
|
|
34
|
+
* ]
|
|
35
|
+
* <Intable columns={cols} plugins={[ZodValidatorPlugin]} />
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare const ZodValidatorPlugin: Plugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const ZodValidatorPlugin = {
|
|
2
|
+
name: "zod-validator",
|
|
3
|
+
rewriteProps: { validator: ({ validator: e }) => async (t, n, r) => {
|
|
4
|
+
let i = r.zodSchema;
|
|
5
|
+
if (i) {
|
|
6
|
+
let e = i.safeParse(t);
|
|
7
|
+
if (!e.success) return e.error.issues[0]?.message ?? !1;
|
|
8
|
+
}
|
|
9
|
+
return e ? e(t, n, r) : !0;
|
|
10
|
+
} }
|
|
11
|
+
};
|
|
12
|
+
export { ZodValidatorPlugin };
|
package/dist/plus.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
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=\"M5 12h14m-7-7v14\">"), plus_default = (n = {}) => (() => {
|
|
3
|
+
var r = _tmpl$();
|
|
4
|
+
return spread(r, n, !0, !0), r;
|
|
5
|
+
})();
|
|
6
|
+
export { plus_default as default };
|
package/dist/style.css
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--un-bg-opacity:100%;--un-content:"";--un-translate-x:initial;--un-translate-y:initial;--un-translate-z:initial;--un-text-opacity:100%;--un-border-opacity:100%;--un-space-y-reverse:initial;--un-space-x-reverse:initial;--un-outline-style:solid;--un-outline-opacity:100%;--un-leading:initial}}@property --un-leading{syntax:"*";inherits:false}@property --un-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --un-outline-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-bg-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-translate-x{syntax:"*";inherits:false;initial-value:0}@property --un-translate-y{syntax:"*";inherits:false;initial-value:0}@property --un-translate-z{syntax:"*";inherits:false;initial-value:0}:root,:host{--spacing:.25rem;--colors-gray-DEFAULT:#99a1af;--text-sm-fontSize:.875rem;--text-sm-lineHeight:1.25rem;--default-transition-timingFunction:cubic-bezier(.4,0,.2,1);--default-transition-duration:.15s;--radius-sm:.25rem;--colors-blue-DEFAULT:#54a2ff;--font-sans:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--default-font-family:var(--font-sans);--default-monoFont-family:var(--font-mono)}@supports (color:lab(0% 0 0)){:root,:host{--colors-gray-DEFAULT:lab(65.9269% -.832707 -8.17474);--colors-blue-DEFAULT:lab(65.0361% -1.42062 -56.9803)}}*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-featureSettings,normal);font-variation-settings:var(--default-font-variationSettings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-monoFont-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-monoFont-featureSettings,normal);font-variation-settings:var(--default-monoFont-variationSettings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden~=until-found])){display:none!important}.container{width:100%}.aic{align-items:center}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.text-3\.5{font-size:.875rem}.lh-\[1\]{--un-leading:1;line-height:1}.m9{margin:36px}.mx-1{margin-inline:4px}.mx-3\!{margin-inline:12px!important}.my-1{margin-block:4px}.ml{margin-left:16px}.ml-\.5{margin-left:2px}.ml-1{margin-left:4px}.mr--1{margin-right:-4px}.mr-1{margin-right:4px}.mr-2{margin-right:8px}.mr-2\.5{margin-right:10px}.p-1{padding:4px}.px,.px-4{padding-inline:16px}.px-2{padding-inline:8px}.py-1{padding-block:4px}.py-2{padding-block:8px}.pl-1{padding-left:4px}.pr-4{padding-right:16px}.ps{padding-inline-start:16px}.outline-0{outline-style:var(--un-outline-style);outline-width:0}.outline-2{outline-style:var(--un-outline-style);outline-width:2px}.outline-blue{outline-color:color-mix(in srgb,var(--colors-blue-DEFAULT)var(--un-outline-opacity),transparent)}.b{border-width:1px}.rd-2{border-radius:.5rem}.rd-sm{border-radius:var(--radius-sm)}.bg-\#dafaea\!{background-color:color-mix(in oklab,#dafaea var(--un-bg-opacity),transparent)!important}.bg-\#ffe8e8\!{background-color:color-mix(in oklab,#ffe8e8 var(--un-bg-opacity),transparent)!important}.bg-\#fff{background-color:color-mix(in oklab,#fff var(--un-bg-opacity),transparent)}.bg-gray\/20{background-color:color-mix(in srgb,var(--colors-gray-DEFAULT)20%,transparent)}.op-75{opacity:.75}.op40{opacity:.4}.flex{display:flex}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.gap-2{gap:8px}.grid{display:grid}.size-4\!{width:16px!important;height:16px!important}.size-full{width:100%;height:100%}.h-1\!{height:4px!important}.h-a\!{height:auto!important}.h-full{height:100%}.max-h-100{max-height:400px}.min-h-40{min-height:160px}.min-h-a\!{min-height:auto!important}.w-10px\!{width:10px!important}.after\:h-1:after{height:4px}.after\:w-1:after{width:4px}.inline{display:inline}.block{display:block}.hidden{display:none}.visible{visibility:visible}.collapse{visibility:collapse}.cursor-s-resize{cursor:s-resize}.cursor-w-resize{cursor:w-resize}.resize{resize:both}.resize-none{resize:none}.select-none{-webkit-user-select:none;user-select:none}.translate-x-1\/2{--un-translate-x:50%;translate:var(--un-translate-x)var(--un-translate-y)}.transform{transform:var(--un-rotate-x)var(--un-rotate-y)var(--un-rotate-z)var(--un-skew-x)var(--un-skew-y)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,--un-gradient-from,--un-gradient-via,--un-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter;transition-timing-function:var(--un-ease,var(--default-transition-timingFunction));transition-duration:var(--un-duration,var(--default-transition-duration))}.items-center{align-items:center}.box-border{box-sizing:border-box}.bottom-0{bottom:0}.left-0{left:0}.right-0{right:0}.top-0{top:0}.justify-end\!{justify-content:flex-end!important}.justify-center{justify-content:center}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.z-1{z-index:1}.z-9{z-index:9}.overflow-auto{overflow:auto}.table{display:table}.table-cell{display:table-cell}@supports (color:color-mix(in lab, red, red)){.outline-blue{outline-color:color-mix(in oklab,var(--colors-blue-DEFAULT)var(--un-outline-opacity),transparent)}.bg-gray\/20{background-color:color-mix(in oklab,var(--colors-gray-DEFAULT)20%,transparent)}}
|
|
2
|
+
|
|
3
|
+
.data-table{--bg:#fff;--c-primary:#51a2ff;--menu-bg:#fff;--li-hover-bg:#99a1af33;--table-b:1px solid var(--table-b-c);--table-b-c:#ebeef5;--table-c:#606266;--table-bg:#fff;--table-header-c:#909399;--table-header-bg:var(--table-bg);--table-row-hover-bg:#f5f7fa;--select-area-bg:#5292f71a;color:color-mix(in oklab,var(--table-c)var(--un-text-opacity),transparent);border-color:color-mix(in oklab,var(--table-b-c)var(--un-border-opacity),transparent);font-size:14px;position:relative}@property --un-text-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-border-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}.data-table--table{color:color-mix(in oklab,var(--table-c)var(--un-text-opacity),transparent);outline-style:var(--un-outline-style);border-collapse:collapse;table-layout:fixed;border-collapse:separate;border-spacing:0;border-width:0;outline-width:0;width:max-content}@property --un-outline-style{syntax:"*";inherits:false;initial-value:solid}.data-table thead{color:color-mix(in oklab,var(--table-header-c)var(--un-text-opacity),transparent)}.data-table tr:hover>td{background-color:color-mix(in oklab,var(--table-row-hover-bg)var(--un-bg-opacity),transparent)}@property --un-bg-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}.data-table th{background-color:color-mix(in oklab,var(--table-header-bg)var(--un-bg-opacity),transparent)}.data-table td{background-color:color-mix(in oklab,var(--table-bg)var(--un-bg-opacity),transparent)}.data-table td,.data-table th{vertical-align:middle;outline-style:var(--un-outline-style);border-width:0;border-color:color-mix(in oklab,var(--table-b-c)var(--un-border-opacity),transparent);--un-border-style:solid;box-sizing:border-box;text-align:inherit;background-image:linear-gradient(var(--table-b-c),var(--table-b-c));background-position:100% 100%,100% 0;background-repeat:no-repeat;background-size:100% 1px,1px 100%;border-style:solid;outline-width:0;padding-block:2px;padding-inline:8px}.data-table td:empty:after{content:"ㅤ"!important}.data-table--border{border-width:1px}.data-table--border th,.data-table--border td{background-image:linear-gradient(var(--table-b-c),var(--table-b-c)),linear-gradient(var(--table-b-c),var(--table-b-c))}.data-table--scroll-view{overflow:auto}.data-table__layers{pointer-events:none;z-index:1;position:absolute;top:0;left:0}.data-table__layers>*{position:absolute}.range-selected{position:relative}.range-selected>.area{border-width:0;border-color:color-mix(in oklab,var(--c-primary)var(--un-border-opacity),transparent);--un-border-style:solid;background-color:color-mix(in oklab,var(--select-area-bg)var(--un-bg-opacity),transparent);pointer-events:none;border-style:solid;position:absolute;inset:0}.range-selected-l>.area{border-left-width:1.5px}.range-selected-r>.area{border-right-width:1.5px}.range-selected-t>.area{border-top-width:1.5px}.range-selected-b>.area{border-bottom-width:1.5px}.row-range-highlight,.col-range-highlight{position:relative}.row-range-highlight>.area,.col-range-highlight>.area{border-width:0;border-color:color-mix(in oklab,var(--c-primary)var(--un-border-opacity),transparent);--un-border-style:solid;background-color:color-mix(in oklab,var(--c-primary)10%,transparent);pointer-events:none;border-style:solid;position:absolute;inset:0}.row-range-highlight.index>.area{border-right-width:1px}.col-range-highlight>.area{border-bottom-width:1px}.sticky-header{background-color:color-mix(in oklab,#fff var(--un-bg-opacity),transparent);z-index:9;position:sticky;top:0}.sticky-header:after{pointer-events:none;--un-content:"";content:var(--un-content);width:100%;height:10px;position:absolute;top:100%;box-shadow:inset 0 10px 10px -10px #00000026}@property --un-content{syntax:"*";inherits:false;initial-value:""}.fixed-left,.fixed-right{background-color:color-mix(in oklab,#fff var(--un-bg-opacity),transparent);z-index:1;position:sticky!important}.fixed-left.is-first:after,.fixed-left.is-last:after,.fixed-right.is-first:after,.fixed-right.is-last:after{pointer-events:none;--un-content:"";content:var(--un-content);width:10px;height:100%;position:absolute;top:0}.is-scroll-right .fixed-left.is-last:after,.is-scroll-mid .fixed-left.is-last:after{left:100%;box-shadow:inset 10px 0 10px -10px #00000026}.is-scroll-left .fixed-right.is-first:after,.is-scroll-mid .fixed-right.is-first:after{right:100%;box-shadow:inset -10px 0 10px -10px #00000026}.copied .range-selected>.area{border-style:dashed}.data-table.virtual{display:block;overflow:auto}.data-table.virtual thead{width:fit-content;display:block}.data-table.virtual thead>tr{display:flex}.data-table.virtual thead>tr>th{flex:none;display:block}.data-table.virtual tbody{width:fit-content;display:block}.data-table.virtual tbody>tr{display:flex}.data-table.virtual tbody>tr>td{flex:none;display:block}.row-selection{width:40px;position:relative}.row-selection>label{justify-content:center;align-items:center;width:100%;height:100%;display:flex;position:absolute;inset:0}.icon-clickable{box-sizing:border-box;border-radius:.25rem;justify-content:center;align-items:center;width:20px;height:20px;padding:2px;display:flex}.icon-clickable:hover{background-color:color-mix(in srgb,var(--colors-gray-DEFAULT)30%,transparent)}@supports (color:color-mix(in lab, red, red)){.icon-clickable:hover{background-color:color-mix(in oklab,var(--colors-gray-DEFAULT)30%,transparent)}}.icon-clickable>svg{width:100%;height:100%}input[type=checkbox].you-checkbox{color:color-mix(in oklab,#2196f3 var(--un-text-opacity),transparent);appearance:none;outline-offset:0px;--un-border-style:solid;border:2px solid;border-radius:.25rem;width:16px;height:16px;margin:4px;position:relative}input[type=checkbox].you-checkbox:focus{outline-style:var(--un-outline-style);--un-outline-style:solid;outline:4px solid oklab(65.8156% -.0610626 -.157539/.4)}@property --un-outline-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}input[type=checkbox].you-checkbox:checked{background-color:currentColor}input[type=checkbox].you-checkbox.checked:after{color:color-mix(in oklab,#fff var(--un-text-opacity),transparent);--un-content:"✓";content:var(--un-content);--un-translate-x:-50%;--un-translate-y:-50%;translate:var(--un-translate-x)var(--un-translate-y);z-index:1;font-size:.75rem;position:absolute;top:50%;left:50%}@property --un-translate-x{syntax:"*";inherits:false;initial-value:0}@property --un-translate-y{syntax:"*";inherits:false;initial-value:0}@property --un-translate-z{syntax:"*";inherits:false;initial-value:0}td.is-editing{position:relative}td.is-invalid{outline-offset:-1.5px;outline:1.5px solid #ff4d4f;position:relative}.in-cell-edit-wrapper{z-index:1;position:absolute;inset:0;box-shadow:0 0 10px -2px #00000050}.cell-validating{border-width:2px;border-color:color-mix(in oklab,var(--c-primary)var(--un-border-opacity),transparent);pointer-events:none;--un-translate-y:-50%;width:12px;height:12px;translate:var(--un-translate-x)var(--un-translate-y);border-top-color:#0000;border-radius:3.40282e38px;animation:1s linear infinite spin;display:block;position:absolute;top:50%;right:4px}.cell-validation-error{z-index:10;color:#ff4d4f;white-space:nowrap;pointer-events:none;background:#fff1f0;border:1px solid #ffccc7;border-radius:4px;padding:2px 8px;font-size:12px;position:absolute;top:100%;left:0;box-shadow:0 2px 8px #00000020}.cell-validation-error:empty{display:none}.in-cell__resize-handle{width:100%;height:100%;position:absolute}.in-cell__resize-handle:hover:after{background-color:color-mix(in oklab,var(--c-primary)40%,transparent)}.in-cell__resize-handle:active:after{background-color:color-mix(in oklab,var(--c-primary)var(--un-bg-opacity),transparent)}.in-cell__resize-handle:after{--un-content:"";content:var(--un-content)}.li{cursor:pointer;position:relative}.li:hover,.li.hover{background-color:color-mix(in oklab,var(--li-hover-bg)var(--un-bg-opacity),transparent)}.li:active:before,.li.selected:before,.li.active:before{content:"";border-radius:inherit;background-color:color-mix(in srgb,var(--colors-gray-DEFAULT)15%,transparent);position:absolute;inset:0}@supports (color:color-mix(in lab, red, red)){.li:active:before,.li.selected:before,.li.active:before{background-color:color-mix(in oklab,var(--colors-gray-DEFAULT)15%,transparent)}}.li.disabled,.li[disabled]{opacity:.4}.tt-menu{font-size:var(--text-sm-fontSize);line-height:var(--un-leading,var(--text-sm-lineHeight));border-width:1px;border-color:color-mix(in srgb,var(--colors-gray-DEFAULT)30%,transparent);--un-border-style:solid;background-color:color-mix(in oklab,var(--menu-bg)var(--un-bg-opacity),transparent);cursor:default;--un-shadow:0 10px 15px -3px var(--un-shadow-color,#0000001a),0 4px 6px -4px var(--un-shadow-color,#0000001a);box-shadow:var(--un-inset-shadow),var(--un-inset-ring-shadow),var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow);border-style:solid;border-radius:.5rem;padding-block:4px}@supports (color:color-mix(in lab, red, red)){.tt-menu{border-color:color-mix(in oklab,var(--colors-gray-DEFAULT)30%,transparent)}}@property --un-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-shadow-color{syntax:"*";inherits:false}@property --un-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-inset-shadow-color{syntax:"*";inherits:false}@property --un-ring-color{syntax:"*";inherits:false}@property --un-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-inset-ring-color{syntax:"*";inherits:false}@property --un-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-ring-inset{syntax:"*";inherits:false}@property --un-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --un-ring-offset-color{syntax:"*";inherits:false}@property --un-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}:where(.tt-menu>:not(:last-child)){--un-space-y-reverse:0;margin-block-start:calc(calc(4px*.5)*var(--un-space-y-reverse));margin-block-end:calc(calc(4px*.5)*calc(1 - var(--un-space-y-reverse)))}@property --un-space-y-reverse{syntax:"*";inherits:false;initial-value:0}.tt-menu-x{font-size:var(--text-sm-fontSize);line-height:var(--un-leading,var(--text-sm-lineHeight));border-width:1px;border-color:color-mix(in srgb,var(--colors-gray-DEFAULT)30%,transparent);--un-border-style:solid;background-color:color-mix(in oklab,var(--menu-bg)var(--un-bg-opacity),transparent);cursor:default;--un-shadow:0 10px 15px -3px var(--un-shadow-color,#0000001a),0 4px 6px -4px var(--un-shadow-color,#0000001a);box-shadow:var(--un-inset-shadow),var(--un-inset-ring-shadow),var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow);border-style:solid;border-radius:.5rem;padding-inline:4px}@supports (color:color-mix(in lab, red, red)){.tt-menu-x{border-color:color-mix(in oklab,var(--colors-gray-DEFAULT)30%,transparent)}}:where(.tt-menu-x>:not(:last-child)){--un-space-x-reverse:0;margin-inline-start:calc(calc(4px*.5)*var(--un-space-x-reverse));margin-inline-end:calc(calc(4px*.5)*calc(1 - var(--un-space-x-reverse)))}@property --un-space-x-reverse{syntax:"*";inherits:false;initial-value:0}.tt-menu-x>.hr{background-color:color-mix(in srgb,var(--colors-gray-DEFAULT)30%,transparent);width:1px;margin-block:6px}@supports (color:color-mix(in lab, red, red)){.tt-menu-x>.hr{background-color:color-mix(in oklab,var(--colors-gray-DEFAULT)30%,transparent)}}.col__guide-line,.row__guide-line{background-color:color-mix(in oklab,var(--c-primary)var(--un-bg-opacity),transparent);pointer-events:none;z-index:9;position:fixed;top:0;left:0}th[draggable=true],td[draggable=true]{cursor:move}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
|
package/dist/tree.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const findParent: (data: any[], cb: any, childrenField?: string) => any;
|
package/dist/tree.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __export } from "./rolldown_runtime.js";
|
|
2
|
+
var tree_exports = /* @__PURE__ */ __export({ findParent: () => findParent });
|
|
3
|
+
const findParent = (e, t, n = "children") => {
|
|
4
|
+
let r = null, i = [...e];
|
|
5
|
+
for (; i.length;) {
|
|
6
|
+
let e = i.pop();
|
|
7
|
+
if (t(e)) return r;
|
|
8
|
+
Array.isArray(e[n]) && (i.push(...e[n]), r = e);
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
};
|
|
12
|
+
export { findParent, tree_exports };
|
|
File without changes
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export * as tree from './tree';
|
|
2
|
+
export declare function file2base64(file: File): Promise<string>;
|
|
3
|
+
export declare function chooseFile(opts: {
|
|
4
|
+
accept?: string;
|
|
5
|
+
multiple?: false;
|
|
6
|
+
}): Promise<File>;
|
|
7
|
+
export declare function chooseFile(opts: {
|
|
8
|
+
accept?: string;
|
|
9
|
+
multiple: true;
|
|
10
|
+
}): Promise<File[]>;
|
|
11
|
+
export declare function chooseImage(): Promise<File>;
|
|
12
|
+
export declare function print(html: string): Promise<void>;
|
|
13
|
+
export declare function mergeRect(rect1: DOMRect, rect2: DOMRect): DOMRect;
|
|
14
|
+
export declare function getStyles(el?: ParentNode): string;
|
|
15
|
+
export declare const unFn: (fn: any, ...args: any[]) => any;
|
|
16
|
+
export declare const log: (...args: any[]) => any;
|
|
17
|
+
export declare const toArr: (v: any) => any[];
|
|
18
|
+
export declare const parseStyle: (s: any) => any;
|
|
19
|
+
export declare function findret<T, R>(arr: readonly T[], cb: (e: T, i: number) => R): R | undefined;
|
|
20
|
+
export declare function emptyObject(o: any): any;
|
|
21
|
+
export declare function findAsync<T>(arr: T[], cb: (e: T, i: number) => Promise<boolean> | boolean): Promise<T>;
|
|
22
|
+
type Fnable<T> = T | (() => T);
|
|
23
|
+
type Awatable<T> = T | Promise<T>;
|
|
24
|
+
type BaseType = string | number | boolean | null;
|
|
25
|
+
export declare function resolveOptions(opts: Fnable<Awatable<Record<string, any> | ({
|
|
26
|
+
label: any;
|
|
27
|
+
value: any;
|
|
28
|
+
} | BaseType)[]>>): {
|
|
29
|
+
label: any;
|
|
30
|
+
value: any;
|
|
31
|
+
}[];
|