admin_lsac 2.0.22 → 2.0.23
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 +2 -2
- package/dist/esm/src/components/AdminPage.js +13 -21
- package/dist/esm/src/schema.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ Import the component from above where you want to write your schemas! (See below
|
|
|
33
33
|
<AdminPage
|
|
34
34
|
pages={your_array}
|
|
35
35
|
selectedPage={page} // 'page' param from above
|
|
36
|
-
basePath={your_url_to_admin_panel}
|
|
36
|
+
basePath={your_url_to_admin_panel} // use '', NOT '/' if at root
|
|
37
37
|
apiURL={your_url_to_backend} // optional, for websockets
|
|
38
38
|
/>
|
|
39
39
|
}
|
|
@@ -46,7 +46,7 @@ Import the component from above where you want to write your schemas! (See below
|
|
|
46
46
|
<AdminPage
|
|
47
47
|
pages={your_array}
|
|
48
48
|
selectedPage={your_array[0]}
|
|
49
|
-
basePath={your_url_to_admin_panel}
|
|
49
|
+
basePath={your_url_to_admin_panel} // use '', NOT '/' if at root
|
|
50
50
|
apiURL={your_url_to_backend} // optional, for websockets
|
|
51
51
|
/>
|
|
52
52
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState
|
|
3
|
-
import { ChakraProvider } from '@chakra-ui/react';
|
|
4
|
-
import { Button, Modal, ModalHeader, ModalBody, useDisclosure, ModalOverlay, ModalContent, ModalCloseButton, Box, Stack, } from '@chakra-ui/react';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { Button, Modal, ModalHeader, ModalBody, ModalOverlay, ModalContent, ModalCloseButton, useDisclosure, Box, Stack, ChakraProvider, } from '@chakra-ui/react';
|
|
5
4
|
import { GenericForm } from './GenericForm';
|
|
6
5
|
import { ThemeProvider } from '@emotion/react';
|
|
7
6
|
import { createTheme } from '@mui/material/styles';
|
|
@@ -66,28 +65,21 @@ export function AdminPage({ pages, selectedPage, basePath, apiURL = '', }) {
|
|
|
66
65
|
});
|
|
67
66
|
}, [socket, selectedPage]);
|
|
68
67
|
useEffect(() => {
|
|
69
|
-
setDisplayData(data.map((
|
|
68
|
+
setDisplayData(data.map((row) => selectedPage.tableFields.map((field) => field.access(row))));
|
|
70
69
|
}, [data]);
|
|
71
|
-
|
|
72
|
-
const [tableHeight, setTableHeight] = useState('80vh');
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
const updateTableHeight = () => {
|
|
75
|
-
if (headerRef.current) {
|
|
76
|
-
const headerHeight = headerRef.current.clientHeight;
|
|
77
|
-
setTableHeight(`calc(88vh - ${headerHeight}px)`);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
updateTableHeight();
|
|
81
|
-
}, []);
|
|
82
|
-
return (_jsxs(ChakraProvider, { children: [_jsx(Box, { ref: headerRef, children: _jsx(Header, { pages: pages, data: [selectedPage.tableFields.map((field) => field.name), ...displayData], basePath: basePath }) }), _jsx(ThemeProvider, { theme: createTheme(), children: _jsx(MaterialReactTable, { columns: selectedPage.tableFields.map((field, index) => ({
|
|
70
|
+
return (_jsxs(ChakraProvider, { children: [_jsx(Box, { children: _jsx(Header, { pages: pages, data: [selectedPage.tableFields.map((field) => field.name), ...displayData], basePath: basePath }) }), _jsx(ThemeProvider, { theme: createTheme(), children: _jsx(MaterialReactTable, { columns: selectedPage.tableFields.map((field, colIndex) => ({
|
|
83
71
|
accessorFn: (row) => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
return row[index];
|
|
72
|
+
const value = row[colIndex];
|
|
73
|
+
return typeof value === 'boolean' ? String(value) : value;
|
|
88
74
|
},
|
|
89
75
|
header: field.name,
|
|
90
|
-
})), data: displayData, muiTableContainerProps: {
|
|
76
|
+
})), data: displayData, muiTableContainerProps: {
|
|
77
|
+
sx: {
|
|
78
|
+
maxHeight: 'none',
|
|
79
|
+
overflowY: 'visible',
|
|
80
|
+
overflowX: 'auto',
|
|
81
|
+
},
|
|
82
|
+
}, enableColumnResizing: true, enableColumnPinning: true, enableGlobalFilterModes: true, enablePagination: false, paginationDisplayMode: "pages", enableRowVirtualization: true, rowVirtualizerOptions: { overscan: 20 }, renderTopToolbarCustomActions: () => (_jsx(ChakraProvider, { children: _jsx(Stack, { margin: 0, padding: 2, direction: "row", wrap: "wrap", children: selectedPage.actions.map((action, index) => (_jsx(Button, { colorScheme: "blue", onClick: () => {
|
|
91
83
|
setSelectedAction(action);
|
|
92
84
|
onOpen();
|
|
93
85
|
}, children: action.name }, index))) }) })), enableRowActions: true, renderRowActionMenuItems: (obj) => {
|
package/dist/esm/src/schema.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface SimpleField {
|
|
|
6
6
|
name: string;
|
|
7
7
|
label: string;
|
|
8
8
|
type: 'string' | 'number' | 'file' | 'date' | 'datetime-local' | 'time';
|
|
9
|
-
validationSchema
|
|
9
|
+
validationSchema?: any;
|
|
10
10
|
}
|
|
11
11
|
export interface Option {
|
|
12
12
|
value: string | number | boolean;
|
|
@@ -48,6 +48,6 @@ export interface PageSchema {
|
|
|
48
48
|
name: string;
|
|
49
49
|
actions: Action[];
|
|
50
50
|
rowActions: RowAction[];
|
|
51
|
-
getRequest: () => Promise<any[]>;
|
|
51
|
+
getRequest: (filter?: any) => Promise<any[]>;
|
|
52
52
|
tableFields: TableField[];
|
|
53
53
|
}
|