intable 0.0.75 → 0.0.77
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/dist/index.d.ts +2 -11
- package/dist/index.js +3 -25
- package/dist/plugins/RequestPlugin.d.ts +32 -0
- package/dist/plugins/RequestPlugin.js +44 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type JSX, type Component, type Owner } from 'solid-js';
|
|
2
|
-
import type { AndOrNode } from './components/AndOr';
|
|
3
2
|
import 'virtual:uno.css';
|
|
4
3
|
import './style.scss';
|
|
5
4
|
import './plugins/CellSelectionPlugin';
|
|
@@ -13,7 +12,7 @@ import './plugins/ResizePlugin';
|
|
|
13
12
|
import './plugins/DragPlugin';
|
|
14
13
|
import './plugins/RowGroupPlugin';
|
|
15
14
|
import './plugins/ExpandPlugin';
|
|
16
|
-
import
|
|
15
|
+
import './plugins/SortPlugin';
|
|
17
16
|
import './plugins/CellMergePlugin';
|
|
18
17
|
import './plugins/TreePlugin';
|
|
19
18
|
import './plugins/HeaderGroup';
|
|
@@ -25,6 +24,7 @@ import './plugins/TooltipPlugin';
|
|
|
25
24
|
import './plugins/KeyEachPlugin';
|
|
26
25
|
import './plugins/PaginationPlugin';
|
|
27
26
|
import './plugins/BranchGraphPlugin';
|
|
27
|
+
import './plugins/RequestPlugin';
|
|
28
28
|
import './plugins/OrmPlugin';
|
|
29
29
|
import './plugins/ExpressPlugin';
|
|
30
30
|
export declare const Ctx: import("solid-js").Context<{
|
|
@@ -81,15 +81,6 @@ export interface TableProps {
|
|
|
81
81
|
x?: number | string;
|
|
82
82
|
};
|
|
83
83
|
newRow?: (i: number) => any;
|
|
84
|
-
request?: (params: {
|
|
85
|
-
page?: number;
|
|
86
|
-
pageSize?: number;
|
|
87
|
-
filters?: AndOrNode[];
|
|
88
|
-
sorts?: SortKey[];
|
|
89
|
-
}) => Promise<{
|
|
90
|
-
data: any[];
|
|
91
|
-
total?: number;
|
|
92
|
-
}>;
|
|
93
84
|
Scroll?: Component<any>;
|
|
94
85
|
Table?: Component<any>;
|
|
95
86
|
Thead?: Component<any>;
|
package/dist/index.js
CHANGED
|
@@ -26,11 +26,12 @@ import { TooltipPlugin } from "./plugins/TooltipPlugin.js";
|
|
|
26
26
|
import { KeyEachPlugin } from "./plugins/KeyEachPlugin.js";
|
|
27
27
|
import { PaginationPlugin } from "./plugins/PaginationPlugin.js";
|
|
28
28
|
import { BranchGraphPlugin } from "./plugins/BranchGraphPlugin.js";
|
|
29
|
+
import { RequestPlugin } from "./plugins/RequestPlugin.js";
|
|
29
30
|
import { OrmPlugin } from "./plugins/OrmPlugin.js";
|
|
30
31
|
import { ExpressPlugin } from "./plugins/ExpressPlugin.js";
|
|
31
32
|
import loading_bold_default from "./loading-bold.js";
|
|
32
33
|
import { className, createComponent, effect, insert, memo, mergeProps, spread, template, use } from "solid-js/web";
|
|
33
|
-
import { $PROXY, For, batch, createComputed, createContext, createEffect, createMemo, createRenderEffect,
|
|
34
|
+
import { $PROXY, For, batch, createComputed, createContext, createEffect, createMemo, createRenderEffect, createSignal, getOwner, mapArray, mergeProps as mergeProps$1, onCleanup, onMount, runWithOwner, useContext } from "solid-js";
|
|
34
35
|
import { createMutable } from "solid-js/store";
|
|
35
36
|
import { combineProps } from "@solid-primitives/props";
|
|
36
37
|
import { createLazyMemo } from "@solid-primitives/memo";
|
|
@@ -448,30 +449,7 @@ const defaultsPlugins = [
|
|
|
448
449
|
KeyEachPlugin,
|
|
449
450
|
PaginationPlugin,
|
|
450
451
|
BranchGraphPlugin,
|
|
451
|
-
|
|
452
|
-
name: "request",
|
|
453
|
-
priority: -Infinity,
|
|
454
|
-
store: (g) => ({}),
|
|
455
|
-
rewriteProps: {
|
|
456
|
-
request: ({ request: g }, { store: G }) => g && (Promise.resolve().then(() => {
|
|
457
|
-
untrack(() => G._req ??= runWithOwner(G.owner, () => createResource(() => JSON.stringify({
|
|
458
|
-
filters: G.props.filter?.value,
|
|
459
|
-
sorts: G.props.sort?.value,
|
|
460
|
-
page: G.props.pagination?.value,
|
|
461
|
-
pageSize: G.props.pagination?.pageSize
|
|
462
|
-
}), (g) => G.props.request(JSON.parse(g)), { initialValue: {
|
|
463
|
-
data: [],
|
|
464
|
-
total: 0
|
|
465
|
-
} })));
|
|
466
|
-
}), g),
|
|
467
|
-
data: ({ data: g = [] }, { store: G }) => G.props.request ? G._req?.[0]()?.data ?? [] : g,
|
|
468
|
-
loading: ({ loading: g }, { store: G }) => G.props.request ? g || G._req?.[0].loading : g,
|
|
469
|
-
pagination: ({ pagination: g }, { store: G }) => ({
|
|
470
|
-
...g,
|
|
471
|
-
total: G.props.request ? G._req?.[0]()?.total : g?.total
|
|
472
|
-
})
|
|
473
|
-
}
|
|
474
|
-
},
|
|
452
|
+
RequestPlugin,
|
|
475
453
|
OrmPlugin,
|
|
476
454
|
ExpressPlugin
|
|
477
455
|
];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Setter } from 'solid-js';
|
|
2
|
+
import { type Plugin } from '..';
|
|
3
|
+
import type { AndOrNode } from '../components/AndOr';
|
|
4
|
+
import type { SortKey } from './SortPlugin';
|
|
5
|
+
declare module '..' {
|
|
6
|
+
interface TableProps {
|
|
7
|
+
request?: (params: {
|
|
8
|
+
page?: number;
|
|
9
|
+
pageSize?: number;
|
|
10
|
+
filters?: AndOrNode[];
|
|
11
|
+
sorts?: SortKey[];
|
|
12
|
+
}) => Promise<{
|
|
13
|
+
data: any[];
|
|
14
|
+
total: number;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
interface TableColumn {
|
|
18
|
+
}
|
|
19
|
+
interface TableStore {
|
|
20
|
+
request?: {
|
|
21
|
+
data: {
|
|
22
|
+
data: any[];
|
|
23
|
+
total: number;
|
|
24
|
+
};
|
|
25
|
+
loading: boolean;
|
|
26
|
+
error: any;
|
|
27
|
+
mutate: Setter<any>;
|
|
28
|
+
refresh: () => void;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export declare const RequestPlugin: Plugin;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createResource, runWithOwner, untrack } from "solid-js";
|
|
2
|
+
import { createAsyncMemo, createDebouncedMemo } from "@solid-primitives/memo";
|
|
3
|
+
const RequestPlugin = {
|
|
4
|
+
name: "request",
|
|
5
|
+
priority: -Infinity,
|
|
6
|
+
store: (e) => ({}),
|
|
7
|
+
rewriteProps: {
|
|
8
|
+
request: ({ request: a }, { store: o }) => a ? (untrack(() => {
|
|
9
|
+
let i = runWithOwner(o.owner, () => createResource(createDebouncedMemo(createAsyncMemo(async () => JSON.stringify({
|
|
10
|
+
filters: o.props.filter?.value,
|
|
11
|
+
sorts: o.props.sort?.value,
|
|
12
|
+
page: o.props.pagination?.value,
|
|
13
|
+
pageSize: o.props.pagination?.pageSize
|
|
14
|
+
})), 300), (e) => o.props.request(JSON.parse(e)), { initialValue: {
|
|
15
|
+
data: [],
|
|
16
|
+
total: 0
|
|
17
|
+
} }));
|
|
18
|
+
o.request = {
|
|
19
|
+
get data() {
|
|
20
|
+
return i[0]();
|
|
21
|
+
},
|
|
22
|
+
get loading() {
|
|
23
|
+
return i[0].loading ?? !1;
|
|
24
|
+
},
|
|
25
|
+
get error() {
|
|
26
|
+
return i[0].error;
|
|
27
|
+
},
|
|
28
|
+
get mutate() {
|
|
29
|
+
return i[1].mutate;
|
|
30
|
+
},
|
|
31
|
+
get refresh() {
|
|
32
|
+
return i[1].refetch;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}), a) : (untrack(() => o.request = void 0), a),
|
|
36
|
+
data: ({ data: e = [] }, { store: r }) => r.request ? r.request.data?.data ?? [] : e,
|
|
37
|
+
loading: ({ loading: e }, { store: r }) => r.request ? e || r.request.loading : e,
|
|
38
|
+
pagination: ({ pagination: e }, { store: r }) => ({
|
|
39
|
+
...e,
|
|
40
|
+
total: r.request ? r.request.data.total : e?.total
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
export { RequestPlugin };
|