@intable/react 0.0.8 → 0.0.10

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 (32) hide show
  1. package/LICENSE +21 -21
  2. package/dist/index.js +14 -14
  3. package/dist/intable/src/components/Menu.d.ts +1 -0
  4. package/dist/intable/src/components/Popover.d.ts +14 -0
  5. package/dist/intable/src/components/Render.d.ts +4 -0
  6. package/dist/intable/src/components/utils.d.ts +3 -0
  7. package/dist/intable/src/hooks/index.d.ts +41 -0
  8. package/dist/intable/src/hooks/useDir.d.ts +11 -0
  9. package/dist/intable/src/hooks/useSelector.d.ts +16 -0
  10. package/dist/intable/src/hooks/useSort.d.ts +18 -0
  11. package/dist/intable/src/index.d.ts +147 -0
  12. package/dist/intable/src/plugins/CellMergePlugin.d.ts +45 -0
  13. package/dist/intable/src/plugins/CellSelectionPlugin.d.ts +15 -0
  14. package/dist/intable/src/plugins/CommandPlugin.d.ts +14 -0
  15. package/dist/intable/src/plugins/CopyPastePlugin.d.ts +14 -0
  16. package/dist/intable/src/plugins/DragPlugin.d.ts +14 -0
  17. package/dist/intable/src/plugins/EditablePlugin.d.ts +51 -0
  18. package/dist/intable/src/plugins/ExpandPlugin.d.ts +18 -0
  19. package/dist/intable/src/plugins/HeaderGroup.d.ts +11 -0
  20. package/dist/intable/src/plugins/MenuPlugin.d.ts +19 -0
  21. package/dist/intable/src/plugins/RenderPlugin/components.d.ts +5 -0
  22. package/dist/intable/src/plugins/RenderPlugin/index.d.ts +30 -0
  23. package/dist/intable/src/plugins/ResizePlugin.d.ts +27 -0
  24. package/dist/intable/src/plugins/RowGroupPlugin.d.ts +18 -0
  25. package/dist/intable/src/plugins/RowSelectionPlugin.d.ts +20 -0
  26. package/dist/intable/src/plugins/TreePlugin.d.ts +24 -0
  27. package/dist/intable/src/tree.d.ts +1 -0
  28. package/dist/intable/src/utils.d.ts +31 -0
  29. package/dist/intable/src/wc.d.ts +1 -0
  30. package/dist/{index.d.ts → react/src/index.d.ts} +2 -1
  31. package/package.json +2 -2
  32. /package/dist/{plugins → react/src/plugins}/antd.d.ts +0 -0
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 huodoushigemi
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 huodoushigemi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.js CHANGED
@@ -3,24 +3,24 @@ import { createElement, useEffect, useRef } from "react";
3
3
  import { createRoot } from "react-dom/client";
4
4
  import { flushSync } from "react-dom";
5
5
  import "intable/wc";
6
- import { onCleanup } from "solid-js";
7
- const Intable = (a) => {
8
- let o = useRef(null);
6
+ import { createComputed, onCleanup } from "solid-js";
7
+ const Intable = (o) => {
8
+ let s = useRef(null);
9
9
  return useEffect(() => {
10
- o.current && (o.current.options = {
11
- ...a,
12
- renderer: component,
13
- plugins: [...a.plugins || []]
10
+ s.current && (s.current.options = {
11
+ class: o.className,
12
+ ...o,
13
+ renderer: component
14
14
  });
15
- }, [a]), createElement("wc-table", {
16
- ref: o,
15
+ }, [o]), createElement("wc-table", {
16
+ ref: s,
17
17
  style: { display: "contents" }
18
18
  });
19
- }, component = (r) => (i) => {
20
- let s = document.createElement("div");
21
- s.remove ??= () => {};
22
- let c = createRoot(s);
23
- return flushSync(() => c.render(createElement(r, i))), onCleanup(() => c.unmount()), s;
19
+ }, component = (i) => (a) => {
20
+ let c = document.createDocumentFragment();
21
+ c.remove ??= () => {}, c.removeChild = (e) => e.parentElement?.removeChild(e);
22
+ let l = createRoot(c);
23
+ return createComputed(() => flushSync(() => l.render(createElement(i, a)))), onCleanup(() => l.unmount()), c;
24
24
  };
25
25
  var src_default = Intable;
26
26
  export { Intable, component, src_default as default };
@@ -0,0 +1 @@
1
+ export declare function Menu(props: any): import("solid-js").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { type JSX } from 'solid-js';
2
+ import { type createFloatingProps, type ReferenceType } from 'floating-ui-solid';
3
+ import type { AutoUpdateOptions } from '@floating-ui/dom';
4
+ export declare function Popover(attrs: FloatingProps): JSX.Element;
5
+ type FloatingProps = {
6
+ reference: ReferenceType;
7
+ floating?: JSX.Element | (() => JSX.Element);
8
+ portal?: HTMLElement;
9
+ trigger?: 'click' | 'hover';
10
+ } & createFloatingProps;
11
+ export declare function Floating(attrs: FloatingProps & {
12
+ update?: Partial<AutoUpdateOptions>;
13
+ }): JSX.Element;
14
+ export {};
@@ -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,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,41 @@
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 createShallowState(state: any): any;
40
+ export declare function useMemoState(fn: any): any;
41
+ export {};
@@ -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,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,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 {};
@@ -0,0 +1,147 @@
1
+ import { type JSX, type Component } from 'solid-js';
2
+ import 'virtual:uno.css';
3
+ import './style.scss';
4
+ import './plugins/CellSelectionPlugin';
5
+ import './plugins/CopyPastePlugin';
6
+ import './plugins/EditablePlugin';
7
+ import './plugins/RenderPlugin';
8
+ import './plugins/MenuPlugin';
9
+ import './plugins/CommandPlugin';
10
+ import './plugins/RowSelectionPlugin';
11
+ import './plugins/ResizePlugin';
12
+ import './plugins/DragPlugin';
13
+ import './plugins/RowGroupPlugin';
14
+ import './plugins/ExpandPlugin';
15
+ import './plugins/CellMergePlugin';
16
+ import './plugins/TreePlugin';
17
+ import './plugins/HeaderGroup';
18
+ export declare const Ctx: import("solid-js").Context<{
19
+ props: TableProps2;
20
+ store: TableStore;
21
+ }>;
22
+ type Requireds<T, K extends keyof T> = Pri<Omit<T, K> & Required<Pick<T, K>>>;
23
+ type Pri<T> = {
24
+ [K in keyof T]: T[K];
25
+ };
26
+ type TableProps2 = Requireds<TableProps, ('Table' | 'Thead' | 'Tbody' | 'Tr' | 'Th' | 'Td' | 'EachRows' | 'EachCells' | 'rowKey' | 'data' | 'columns' | 'newRow')>;
27
+ type Each<T = any> = (props: {
28
+ each: T[];
29
+ children: (e: () => any, i: () => number) => JSX.Element;
30
+ }) => JSX.Element;
31
+ type ProcessProps = {
32
+ [K in keyof TableProps]?: (prev: TableProps2, ctx: {
33
+ store: TableStore;
34
+ }) => TableProps[K];
35
+ };
36
+ export interface Plugin {
37
+ name: string;
38
+ priority?: number;
39
+ store?: (store: TableStore) => Partial<TableStore> | void;
40
+ rewriteProps?: ProcessProps;
41
+ layers?: Component<TableStore>[];
42
+ onMount?: (store: TableStore) => void;
43
+ /**
44
+ * Declare keyboard shortcuts for this plugin.
45
+ * Collected and registered as a **single** keydown listener by CommandPlugin.
46
+ * Keys use tinykeys syntax, e.g. `'$mod+Z'`, `'$mod+Shift+K'`.
47
+ */
48
+ keybindings?: (store: TableStore) => Record<string, (e?: KeyboardEvent) => void>;
49
+ }
50
+ export type Plugin$0 = Plugin | ((store: TableStore) => Plugin);
51
+ export interface TableProps {
52
+ columns?: TableColumn[];
53
+ data?: any[];
54
+ index?: boolean;
55
+ border?: boolean;
56
+ stickyHeader?: boolean;
57
+ class?: any;
58
+ style?: any;
59
+ rowKey?: any;
60
+ size?: string;
61
+ newRow?: (i: number) => any;
62
+ Table?: Component<any>;
63
+ Thead?: Component<any>;
64
+ Tbody?: Component<any>;
65
+ Td?: TD;
66
+ Th?: Component<THProps>;
67
+ Tr?: Component<{
68
+ y?: number;
69
+ data?: any;
70
+ style?: any;
71
+ children: JSX.Element;
72
+ }>;
73
+ EachRows?: Each;
74
+ EachCells?: Each<TableColumn>;
75
+ cellClass?: ((props: Omit<TDProps, 'y' | 'data'> & {
76
+ y?: number;
77
+ data?: any;
78
+ }) => string) | string;
79
+ cellStyle?: ((props: Omit<TDProps, 'y' | 'data'> & {
80
+ y?: number;
81
+ data?: any;
82
+ }) => string) | string;
83
+ renderer?: (comp: (props: any) => JSX.Element) => ((props: any) => JSX.Element);
84
+ plugins?: Plugin$0[];
85
+ /**
86
+ * Override or disable individual plugin keybindings.
87
+ * - Override: `{ '$mod+Z': (e) => myUndo() }`
88
+ * - Disable: `{ '$mod+Z': false }`
89
+ */
90
+ keybindings?: Record<string, ((e?: KeyboardEvent) => void) | false>;
91
+ onDataChange?: (data: any[]) => void;
92
+ }
93
+ export type THProps = {
94
+ x: number;
95
+ col: TableColumn;
96
+ children: JSX.Element;
97
+ rowspan?: number;
98
+ colspan?: number;
99
+ style?: any;
100
+ };
101
+ export type TDProps = {
102
+ x: number;
103
+ y: number;
104
+ data: any;
105
+ col: TableColumn;
106
+ children: JSX.Element;
107
+ rowspan?: number;
108
+ colspan?: number;
109
+ };
110
+ export type TD = Component<TDProps>;
111
+ type Obj = Record<string | symbol, any>;
112
+ export interface TableColumn extends Obj {
113
+ id?: any;
114
+ name?: string;
115
+ width?: number;
116
+ fixed?: 'left' | 'right';
117
+ class?: any;
118
+ style?: any;
119
+ props?: (props: any) => JSX.HTMLAttributes<any>;
120
+ }
121
+ type Nullable<T> = T | undefined;
122
+ export interface TableStore extends Obj {
123
+ scroll_el?: HTMLElement;
124
+ table: HTMLElement;
125
+ thead: HTMLElement;
126
+ tbody: HTMLElement;
127
+ ths: Nullable<Element>[];
128
+ thSizes: Nullable<{
129
+ width: number;
130
+ height: number;
131
+ }>[];
132
+ trs: Nullable<Element>[];
133
+ trSizes: Nullable<{
134
+ width: number;
135
+ height: number;
136
+ }>[];
137
+ internal: symbol;
138
+ raw: symbol;
139
+ props: TableProps2;
140
+ rawProps: TableProps;
141
+ plugins: Plugin[];
142
+ }
143
+ export declare const Intable: (props: TableProps) => JSX.Element;
144
+ export default Intable;
145
+ declare function BasePlugin(): Plugin$0;
146
+ export declare const ScrollPlugin: Plugin;
147
+ export declare const defaultsPlugins: (Plugin$0 | typeof BasePlugin)[];
@@ -0,0 +1,45 @@
1
+ import { createMemo } from 'solid-js';
2
+ import { type Plugin } from '../index';
3
+ declare module '../index' {
4
+ interface TableProps {
5
+ /**
6
+ * Per-cell merge config. Return `{ rowspan?, colspan? }` for an anchor cell.
7
+ * Covered cells are hidden automatically.
8
+ *
9
+ * @example
10
+ * merge={(row, col, y, x) => {
11
+ * if (col.id === 'name' && row.name === data[y - 1]?.name) return null
12
+ * if (col.id === 'name') {
13
+ * let rowspan = 1
14
+ * while (data[y + rowspan]?.name === row.name) rowspan++
15
+ * return rowspan > 1 ? { rowspan } : null
16
+ * }
17
+ * }}
18
+ */
19
+ merge?: (row: any, col: TableColumn, y: number, x: number) => {
20
+ rowspan?: number;
21
+ colspan?: number;
22
+ } | null | void;
23
+ }
24
+ interface TableColumn {
25
+ /**
26
+ * Shorthand: auto-merge consecutive rows in this column that share the same cell value.
27
+ * Equivalent to writing a `merge` function that compares adjacent row values.
28
+ */
29
+ mergeRow?: boolean;
30
+ }
31
+ interface TableStore {
32
+ /** Pre-computed merge result: anchor spans and covered cell keys. */
33
+ _mergeMap?: ReturnType<typeof createMemo<MergeMap>>;
34
+ }
35
+ }
36
+ type CellKey = `${number},${number}`;
37
+ interface MergeMap {
38
+ spans: Map<CellKey, {
39
+ rowspan: number;
40
+ colspan: number;
41
+ }>;
42
+ covered: Set<CellKey>;
43
+ }
44
+ export declare const CellMergePlugin: Plugin;
45
+ export {};
@@ -0,0 +1,15 @@
1
+ import { type Plugin } from '..';
2
+ declare module '../index' {
3
+ interface TableProps {
4
+ }
5
+ interface TableStore {
6
+ selected: {
7
+ start: number[];
8
+ end: number[];
9
+ };
10
+ }
11
+ interface Commands {
12
+ getAreaRows(): any[];
13
+ }
14
+ }
15
+ export declare const CellSelectionPlugin: Plugin;
@@ -0,0 +1,14 @@
1
+ import { type Plugin } from '..';
2
+ declare module '../index' {
3
+ interface TableProps {
4
+ }
5
+ interface TableStore {
6
+ commands: Commands;
7
+ }
8
+ interface Plugin {
9
+ commands?: (store: TableStore, commands: Partial<Commands>) => Partial<Commands> & Record<string, any>;
10
+ }
11
+ interface Commands {
12
+ }
13
+ }
14
+ export declare const CommandPlugin: Plugin;
@@ -0,0 +1,14 @@
1
+ import { type Plugin } from '..';
2
+ declare module '../index' {
3
+ interface TableProps {
4
+ }
5
+ interface TableStore {
6
+ }
7
+ interface Plugin {
8
+ }
9
+ interface Commands {
10
+ copy: () => void;
11
+ paste: () => void;
12
+ }
13
+ }
14
+ export declare const ClipboardPlugin: Plugin;
@@ -0,0 +1,14 @@
1
+ import { type Plugin } from "../index";
2
+ declare module '../index' {
3
+ interface TableProps {
4
+ colDrag?: boolean;
5
+ rowDrag?: boolean;
6
+ }
7
+ interface TableColumn {
8
+ }
9
+ interface TableStore {
10
+ }
11
+ interface Commands {
12
+ }
13
+ }
14
+ export declare const DragPlugin: Plugin;
@@ -0,0 +1,51 @@
1
+ import { type JSX } from 'solid-js';
2
+ import { type Plugin, type TableColumn } from '..';
3
+ declare module '../index' {
4
+ interface TableProps {
5
+ validator?: (value: any, data: any, col: TableColumn) => string | boolean | Promise<string | boolean>;
6
+ }
7
+ interface TableColumn {
8
+ editable?: boolean;
9
+ editor?: string | Editor;
10
+ editorProps?: any;
11
+ editorPopup?: boolean;
12
+ validator?: (value: any, rowData: any, col: TableColumn) => boolean | string | Promise<boolean | string>;
13
+ }
14
+ interface TableStore {
15
+ editors: {
16
+ [key: string]: Editor;
17
+ };
18
+ }
19
+ }
20
+ export type Editor = (props: EditorOpt) => {
21
+ el: JSX.Element;
22
+ getValue: () => any;
23
+ destroy: () => void;
24
+ focus?: () => void;
25
+ blur?: () => void;
26
+ };
27
+ export interface EditorOpt {
28
+ col: TableColumn;
29
+ data: any;
30
+ value: any;
31
+ eventKey?: string;
32
+ onChange?: (value: any) => void;
33
+ ok: () => void;
34
+ cancel: () => void;
35
+ props?: any;
36
+ }
37
+ export declare const EditablePlugin: Plugin;
38
+ export declare const editors: {
39
+ text: Editor;
40
+ number: Editor;
41
+ range: Editor;
42
+ date: Editor;
43
+ time: Editor;
44
+ datetime: Editor;
45
+ color: Editor;
46
+ tel: Editor;
47
+ password: Editor;
48
+ file: Editor;
49
+ checkbox: Editor;
50
+ select: Editor;
51
+ };
@@ -0,0 +1,18 @@
1
+ import type { JSX } from 'solid-js';
2
+ import { type Plugin } from '..';
3
+ import { useSelector } from '../hooks/useSelector';
4
+ declare module '../index' {
5
+ interface TableProps {
6
+ expand?: {
7
+ enable?: boolean;
8
+ render?: (props: {
9
+ data: any;
10
+ y: number;
11
+ }) => JSX.Element;
12
+ };
13
+ }
14
+ interface Commands {
15
+ expand: ReturnType<typeof useSelector<any[]>>;
16
+ }
17
+ }
18
+ export declare const ExpandPlugin: Plugin;
@@ -0,0 +1,11 @@
1
+ import { type Plugin$0 } from '..';
2
+ declare module '../index' {
3
+ interface TableColumn {
4
+ children?: TableColumn[];
5
+ }
6
+ interface TableStore {
7
+ /** Returns column indices of group anchors whose span overlaps [xStart, xEnd]. */
8
+ _headerGroupAnchors?: (xStart: number, xEnd: number) => number[];
9
+ }
10
+ }
11
+ export declare const HeaderGroupPlugin: Plugin$0;
@@ -0,0 +1,19 @@
1
+ import { type Plugin } from '..';
2
+ declare module '../index' {
3
+ interface TableProps {
4
+ }
5
+ interface TableStore {
6
+ }
7
+ interface Plugin {
8
+ menus?: (store: TableStore) => any[];
9
+ }
10
+ interface Commands {
11
+ rowEquals: (a: any, b: any) => boolean;
12
+ rowIndexOf: (data: any[], row: any) => number;
13
+ rowChange: (row: any, i?: any) => void;
14
+ addRows: (i: number, rows: any[], before?: boolean) => void;
15
+ deleteRows: (i: number[]) => void;
16
+ moveRows: (ii: number[], to: number) => void;
17
+ }
18
+ }
19
+ export declare const MenuPlugin: Plugin;
@@ -0,0 +1,5 @@
1
+ export declare const Checkbox: import("solid-js").Component<Record<string, any>>;
2
+ export declare const Files: import("solid-js").Component<Record<string, any>>;
3
+ export declare const Tags: import("solid-js").Component<Record<string, any>>;
4
+ export declare const Tag: import("solid-js").Component<Record<string, any>>;
5
+ export declare const evaluateFormula: (formula: string, data: any) => any;
@@ -0,0 +1,30 @@
1
+ import { type JSX } from 'solid-js';
2
+ import { type Plugin, type TD } from '../..';
3
+ declare module '../../index' {
4
+ interface TableProps {
5
+ }
6
+ interface TableColumn {
7
+ render?: Render;
8
+ enum?: Record<string, any> | {
9
+ label?: string;
10
+ value: any;
11
+ }[];
12
+ }
13
+ interface TableStore {
14
+ renders: {
15
+ [key: string]: Render;
16
+ };
17
+ }
18
+ }
19
+ export type RenderProps = Parameters<TD>[0] & {
20
+ onChange: (v: any) => void;
21
+ };
22
+ export type Render = (props: RenderProps) => JSX.Element | any;
23
+ export declare const RenderPlugin: Plugin;
24
+ export declare const renders: {
25
+ text: Render;
26
+ number: Render;
27
+ date: Render;
28
+ checkbox: Render;
29
+ file: Render;
30
+ };
@@ -0,0 +1,27 @@
1
+ import { type Plugin } from "../index";
2
+ declare module '../index' {
3
+ interface TableProps {
4
+ resizable?: {
5
+ col?: Partial<{
6
+ enable: boolean;
7
+ min: number;
8
+ max: number;
9
+ }>;
10
+ row?: Partial<{
11
+ enable: boolean;
12
+ min: number;
13
+ max: number;
14
+ }>;
15
+ };
16
+ onColumnsChange?: (columns: TableColumn[]) => void;
17
+ }
18
+ interface TableColumn {
19
+ resizable?: boolean;
20
+ onWidthChange?: (width: number) => void;
21
+ }
22
+ interface TableStore {
23
+ }
24
+ interface Commands {
25
+ }
26
+ }
27
+ export declare const ResizePlugin: Plugin;
@@ -0,0 +1,18 @@
1
+ import { type Plugin } from '..';
2
+ declare module '../index' {
3
+ interface TableProps {
4
+ rowGroup?: {
5
+ fields?: string[];
6
+ };
7
+ }
8
+ interface TableStore {
9
+ rowGroup: {
10
+ /** Plain-object map used as Set<string>; property access is tracked by createMutable */
11
+ expandKeys: Record<string, true | undefined>;
12
+ isExpand: (data: any) => boolean;
13
+ expand: (data: any, r?: any) => void;
14
+ toggleExpand: (data: any) => void;
15
+ };
16
+ }
17
+ }
18
+ export declare const RowGroupPlugin: Plugin;
@@ -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,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 @@
1
+ export declare const findParent: (data: any[], cb: any, childrenField?: string) => any;
@@ -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
+ }[];
@@ -0,0 +1 @@
1
+ export declare const TableElement: CustomElementConstructor;
@@ -1,7 +1,8 @@
1
1
  import { type FC } from 'react';
2
2
  import { type TableProps } from 'intable';
3
+ import '../../intable/src/wc';
3
4
  import 'intable/wc';
4
5
  import './style.scss';
5
6
  export declare const Intable: FC<TableProps>;
6
- export declare const component: <T extends Record<string, any>>(Comp: FC<T>) => (props: T) => HTMLDivElement;
7
+ export declare const component: <T extends Record<string, any>>(Comp: FC<T>) => (props: T) => DocumentFragment;
7
8
  export default Intable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intable/react",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,7 +18,7 @@
18
18
  ],
19
19
  "dependencies": {
20
20
  "solid-js": "^1.9.9",
21
- "intable": "^0.0.8"
21
+ "intable": "^0.0.10"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": "^18.0.0 || ^19.0.0 || ^20.0.0",
File without changes