@sqrzro/admin 2.1.0-bz.28 → 2.1.0-bz.29
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.
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { Errorable } from '@sqrzro/interfaces';
|
|
3
|
-
import type { TableClientComponentProps } from '../TableClientComponent';
|
|
4
|
-
export interface TableProps<
|
|
5
|
-
fn: (
|
|
6
|
-
|
|
3
|
+
import type { TableClientComponentProps, TableItemObject } from '../TableClientComponent';
|
|
4
|
+
export interface TableProps<Item, Params> extends Omit<TableClientComponentProps, 'data'> {
|
|
5
|
+
fn: (params?: Params, searchParams?: URLSearchParams) => Promise<Errorable<Item[]>>;
|
|
6
|
+
params?: Params;
|
|
7
|
+
searchParams?: URLSearchParams;
|
|
8
|
+
transformer?: (item: Item) => TableItemObject;
|
|
7
9
|
}
|
|
8
|
-
declare function Table<
|
|
10
|
+
declare function Table<Item extends object, Params>({ columns, fn, params, searchParams, transformer, }: Readonly<TableProps<Item, Params>>): Promise<React.ReactElement>;
|
|
9
11
|
export default Table;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import TableClientComponent from '../TableClientComponent';
|
|
3
3
|
function defaultTransformer(item) {
|
|
4
4
|
return {
|
|
@@ -6,12 +6,12 @@ function defaultTransformer(item) {
|
|
|
6
6
|
...item,
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
async function Table({ columns, fn, searchParams, }) {
|
|
10
|
-
const [response, error] = await fn(searchParams);
|
|
9
|
+
async function Table({ columns, fn, params, searchParams, transformer, }) {
|
|
10
|
+
const [response, error] = await fn(params, searchParams);
|
|
11
11
|
if (error) {
|
|
12
|
-
return
|
|
12
|
+
return _jsxs("div", { children: ["Error - ", error.message] });
|
|
13
13
|
}
|
|
14
|
-
const data = response.map(defaultTransformer);
|
|
14
|
+
const data = response.map(transformer || defaultTransformer);
|
|
15
15
|
return _jsx(TableClientComponent, { columns: columns, data: data });
|
|
16
16
|
}
|
|
17
17
|
export default Table;
|
|
@@ -19,7 +19,7 @@ export { default as List } from './List';
|
|
|
19
19
|
export type { ListClientComponentProps } from './ListClientComponent';
|
|
20
20
|
export { default as ListClientComponent } from './ListClientComponent';
|
|
21
21
|
export type { ListObject } from './ListItem';
|
|
22
|
-
export type { ListActionsProps } from './ListActions';
|
|
22
|
+
export type { ListAction, ListActionsProps } from './ListActions';
|
|
23
23
|
export { default as ListActions } from './ListActions';
|
|
24
24
|
export type { PageProps } from './Page';
|
|
25
25
|
export { default as Page } from './Page';
|
|
@@ -35,3 +35,4 @@ export { default as SettingsPage } from './SettingsPage';
|
|
|
35
35
|
export type { TableColumnObject } from './TableClientComponent';
|
|
36
36
|
export type { TableProps } from './Table';
|
|
37
37
|
export { default as Table } from './Table';
|
|
38
|
+
export type { TableItemObject } from './TableClientComponent';
|