@monolith-forensics/monolith-ui 1.2.14 → 1.2.16
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/Table/Table.js +8 -11
- package/dist/Table/TableComponents.js +0 -1
- package/dist/Table/TableMenu/TableMenu.js +7 -6
- package/dist/Table/TableProvider.js +2 -2
- package/dist/Table/index.d.ts +0 -1
- package/dist/Table/index.js +0 -1
- package/dist/Table/types.d.ts +15 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/Table/Column.d.ts +0 -3
- package/dist/Table/Column.js +0 -5
package/dist/Table/Table.js
CHANGED
|
@@ -11,7 +11,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
14
|
-
import Column from "./Column";
|
|
15
14
|
import { useOverlayScrollbars } from "overlayscrollbars-react";
|
|
16
15
|
import { StyledTable } from "./TableComponents";
|
|
17
16
|
import TableHeader from "./TableHeader";
|
|
@@ -32,21 +31,21 @@ const StyledTableContainer = styled.div `
|
|
|
32
31
|
flex: 1 1 auto;
|
|
33
32
|
`;
|
|
34
33
|
const TableContent = () => {
|
|
35
|
-
const { columnState, tableElement, headerRowElm, tableDimensions, targetElm, listElm, rowHeight, headerRowHeight, compactState, virtualized, loading, } = useTable();
|
|
34
|
+
const { columnState, tableElement, tableHeight, tableMaxHeight, tableMinHeight, headerRowElm, tableDimensions, targetElm, listElm, rowHeight, headerRowHeight, compactState, virtualized, loading, } = useTable();
|
|
36
35
|
const visibleColumnCount = columnState.filter((column) => column.visible === true).length;
|
|
37
|
-
return (_jsxs(StyledTableContainer, { children: [_jsx(TableMenu, {}), _jsxs(StyledTable, { className: "mfui-table",
|
|
36
|
+
return (_jsxs(StyledTableContainer, { children: [_jsx(TableMenu, {}), _jsxs(StyledTable, { className: "mfui-table", style: {
|
|
37
|
+
height: tableHeight || "100%",
|
|
38
|
+
maxHeight: tableMaxHeight,
|
|
39
|
+
minHeight: tableMinHeight,
|
|
40
|
+
}, ref: tableElement, "data-compact": compactState, children: [_jsx(LoadingIndicator, { visible: loading }), _jsx(TableHeader, { headerRowElm: headerRowElm }), visibleColumnCount === 0 && _jsx(_Fragment, {}), virtualized === true ? (_jsx(VirtualizedRows, { tableDimensions: tableDimensions, targetElm: targetElm, listElm: listElm, rowHeight: rowHeight, headerRowHeight: headerRowHeight })) : (_jsx(StaticRows, { targetElm: targetElm, listElm: listElm }))] })] }));
|
|
38
41
|
};
|
|
39
42
|
const Table = (_a) => {
|
|
40
|
-
var { data,
|
|
43
|
+
var { data, columnProps } = _a, props = __rest(_a, ["data", "columnProps"]) // pass through props straight to table context
|
|
41
44
|
;
|
|
42
45
|
const tableElement = useRef(null);
|
|
43
46
|
const targetElm = useRef(null);
|
|
44
47
|
const listElm = useRef(null);
|
|
45
48
|
const headerRowElm = useRef(null);
|
|
46
|
-
// check if children is array and convert if not
|
|
47
|
-
if (!Array.isArray(children)) {
|
|
48
|
-
children = [children];
|
|
49
|
-
}
|
|
50
49
|
const [tableDimensions, setTableDimensions] = useState({
|
|
51
50
|
width: 0,
|
|
52
51
|
height: 0,
|
|
@@ -111,8 +110,6 @@ const Table = (_a) => {
|
|
|
111
110
|
};
|
|
112
111
|
}, []);
|
|
113
112
|
const __data = useMemo(() => data === null || data === void 0 ? void 0 : data.map((d, i) => (Object.assign(Object.assign({}, d), { __key: shortUUID.generate(), __index: i }))), [data]);
|
|
114
|
-
return (_jsx(TableProvider, Object.assign({ columns: children
|
|
115
|
-
.filter((child) => child.type === Column)
|
|
116
|
-
.map((child) => child.props), data: __data, tableElement: tableElement, headerRowElm: headerRowElm, tableDimensions: tableDimensions, targetElm: targetElm, listElm: listElm }, props, { children: _jsx(TableContent, {}) })));
|
|
113
|
+
return (_jsx(TableProvider, Object.assign({ columns: columnProps, data: __data, tableElement: tableElement, headerRowElm: headerRowElm, tableDimensions: tableDimensions, targetElm: targetElm, listElm: listElm }, props, { children: _jsx(TableContent, {}) })));
|
|
117
114
|
};
|
|
118
115
|
export default Table;
|
|
@@ -27,11 +27,11 @@ const FlexedRow = styled.div `
|
|
|
27
27
|
}
|
|
28
28
|
`;
|
|
29
29
|
const TableMenu = () => {
|
|
30
|
-
var _a, _b, _c
|
|
30
|
+
var _a, _b, _c;
|
|
31
31
|
const { data, columnState, searchState, toggleColumnVisibility, tableMenuOptions, runSearch, enableSelection, compactState, toggleCompact, totalRecords, getCalculatedSelectionTotal, filterState, handleFilterChange, } = useTable();
|
|
32
32
|
if ((tableMenuOptions === null || tableMenuOptions === void 0 ? void 0 : tableMenuOptions.enabled) !== true)
|
|
33
33
|
return null;
|
|
34
|
-
const { filterOptions } = tableMenuOptions;
|
|
34
|
+
const { addButtonOptions, filterOptions, tableCountOptions, exportOptions, compactOptions, columnSelectorOptions, searchOptions, } = tableMenuOptions;
|
|
35
35
|
const queryFilter = useQueryFilter({
|
|
36
36
|
defaultFilter: filterState,
|
|
37
37
|
filterDefinitions: (filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.filterDefinitions) || [],
|
|
@@ -58,7 +58,7 @@ const TableMenu = () => {
|
|
|
58
58
|
label: item.label,
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
|
-
return (_jsxs(StyledContainer, { children: [_jsxs(FlexedRow, { className: "justify-sb", children: [_jsxs(FlexedRow, { children: [(
|
|
61
|
+
return (_jsxs(StyledContainer, { children: [_jsxs(FlexedRow, { className: "justify-sb", children: [_jsxs(FlexedRow, { children: [(addButtonOptions === null || addButtonOptions === void 0 ? void 0 : addButtonOptions.enabled) === true && (_jsx(Button, { color: "primary", variant: "contained", size: "xxs", onClick: () => { var _a, _b; return (_b = (_a = tableMenuOptions === null || tableMenuOptions === void 0 ? void 0 : tableMenuOptions.addButtonOptions) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a); }, children: ((_a = tableMenuOptions === null || tableMenuOptions === void 0 ? void 0 : tableMenuOptions.addButtonOptions) === null || _a === void 0 ? void 0 : _a.label) || "+ Add Record" })), (filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.enabled) === true && (_jsx(DropDownMenu, { variant: "outlined", size: "xs", data: ((_b = filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.filterDefinitions) === null || _b === void 0 ? void 0 : _b.map((filter) => ({
|
|
62
62
|
label: filter.label,
|
|
63
63
|
value: filter.dataField,
|
|
64
64
|
data: filter,
|
|
@@ -68,7 +68,8 @@ const TableMenu = () => {
|
|
|
68
68
|
leftSection: _jsx(FilterIcon, { size: 12 }),
|
|
69
69
|
}, onItemSelect: handleSelectFilter, dropDownProps: {
|
|
70
70
|
style: { width: 175, maxWidth: 400 },
|
|
71
|
-
}, searchable: true, children: "Filter" })),
|
|
71
|
+
}, searchable: true, children: "Filter" })), (tableCountOptions === null || tableCountOptions === void 0 ? void 0 : tableCountOptions.recordsTotalEnabled) === true && (_jsx(InfoBadge, { total: totalRecords || data.length })), enableSelection === true &&
|
|
72
|
+
(tableCountOptions === null || tableCountOptions === void 0 ? void 0 : tableCountOptions.selectionTotalEnabled) === true && (_jsx(InfoBadge, { total: getCalculatedSelectionTotal(), hint: "Selected Items", icon: CheckSquareIcon }))] }), _jsxs(FlexedRow, { children: [(exportOptions === null || exportOptions === void 0 ? void 0 : exportOptions.enabled) === true && (_jsx(DropDownMenu, { variant: "outlined", size: "xs", data: [
|
|
72
73
|
{
|
|
73
74
|
label: "Export Visible Columns",
|
|
74
75
|
value: TableExportOptions.ExportVisible,
|
|
@@ -86,7 +87,7 @@ const TableMenu = () => {
|
|
|
86
87
|
return (_b = (_a = tableMenuOptions === null || tableMenuOptions === void 0 ? void 0 : tableMenuOptions.exportOptions) === null || _a === void 0 ? void 0 : _a.onExport) === null || _b === void 0 ? void 0 : _b.call(_a, item.value);
|
|
87
88
|
}, dropDownProps: {
|
|
88
89
|
style: { width: 175, maxWidth: 400 },
|
|
89
|
-
}, children: _jsx(DownloadIcon, { size: 14 }) })), (
|
|
90
|
+
}, children: _jsx(DownloadIcon, { size: 14 }) })), (compactOptions === null || compactOptions === void 0 ? void 0 : compactOptions.enabled) === true && (_jsx(Button, { variant: "outlined", title: "Toggle Compact", size: "xxs", style: { padding: "0px 4px" }, onClick: () => toggleCompact(), children: compactState ? _jsx(Rows4Icon, { size: 14 }) : _jsx(Rows3Icon, { size: 14 }) })), (columnSelectorOptions === null || columnSelectorOptions === void 0 ? void 0 : columnSelectorOptions.enabled) === true && (_jsx(DropDownMenu, { variant: "outlined", size: "xs", data: columnState.map((col) => ({
|
|
90
91
|
label: (col === null || col === void 0 ? void 0 : col.caption) || col.dataField,
|
|
91
92
|
value: col.dataField,
|
|
92
93
|
onClick: () => toggleColumnVisibility(col.dataField),
|
|
@@ -101,6 +102,6 @@ const TableMenu = () => {
|
|
|
101
102
|
style: { padding: "0px 4px" },
|
|
102
103
|
}, dropDownProps: {
|
|
103
104
|
style: { width: 175, maxWidth: 400 },
|
|
104
|
-
}, children: _jsx(Columns3Icon, { size: 14 }) })), (
|
|
105
|
+
}, children: _jsx(Columns3Icon, { size: 14 }) })), (searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.enabled) === true && (_jsx(TextInput, { size: "xs", placeholder: ((_c = tableMenuOptions === null || tableMenuOptions === void 0 ? void 0 : tableMenuOptions.searchOptions) === null || _c === void 0 ? void 0 : _c.placeholder) || "Search", defaultValue: searchState, onChange: handleSearch }))] })] }), _jsx(QueryFilter, { queryFilter: queryFilter })] }));
|
|
105
106
|
};
|
|
106
107
|
export default TableMenu;
|
|
@@ -19,7 +19,7 @@ import { SelectionStatus } from "./enums";
|
|
|
19
19
|
import moment from "moment";
|
|
20
20
|
export const TableContext = createContext(null);
|
|
21
21
|
const TableProvider = (_a) => {
|
|
22
|
-
var { children, columns, tableInstanceRef, stateStorage } = _a, props = __rest(_a, ["children", "columns", "tableInstanceRef", "stateStorage"]);
|
|
22
|
+
var { children, columns, tableInstanceRef, stateStorage, height, maxHeight, minHeight } = _a, props = __rest(_a, ["children", "columns", "tableInstanceRef", "stateStorage", "height", "maxHeight", "minHeight"]);
|
|
23
23
|
const _columns = columns
|
|
24
24
|
.map((child, index) => {
|
|
25
25
|
if (child.dataField === "__key") {
|
|
@@ -501,6 +501,6 @@ const TableProvider = (_a) => {
|
|
|
501
501
|
filterState,
|
|
502
502
|
compactState,
|
|
503
503
|
toggleCompact,
|
|
504
|
-
getCalculatedSelectionTotal }, props), { data: _data }), children: children }));
|
|
504
|
+
getCalculatedSelectionTotal, tableHeight: height, tableMaxHeight: maxHeight, tableMinHeight: minHeight }, props), { data: _data }), children: children }));
|
|
505
505
|
};
|
|
506
506
|
export default TableProvider;
|
package/dist/Table/index.d.ts
CHANGED
package/dist/Table/index.js
CHANGED
package/dist/Table/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LucideIcon } from "lucide-react";
|
|
2
|
-
import { MutableRefObject,
|
|
2
|
+
import { MutableRefObject, Ref } from "react";
|
|
3
3
|
import { SelectionStatus, TableExportOptions } from "./enums";
|
|
4
4
|
import { FilterDefinition, Query } from "../QueryFilter";
|
|
5
5
|
export type StateStorage = {
|
|
@@ -91,6 +91,9 @@ export type TableContextType = {
|
|
|
91
91
|
totalRecords?: number;
|
|
92
92
|
setColumnState: React.Dispatch<React.SetStateAction<ColumnState[]>>;
|
|
93
93
|
keyField?: string;
|
|
94
|
+
tableHeight?: number;
|
|
95
|
+
tableMaxHeight?: number;
|
|
96
|
+
tableMinHeight?: number;
|
|
94
97
|
compact?: boolean;
|
|
95
98
|
headerRowHeight?: number;
|
|
96
99
|
rowHeight?: number;
|
|
@@ -142,6 +145,9 @@ export interface TableProviderProps {
|
|
|
142
145
|
totalRecords?: number;
|
|
143
146
|
keyField?: string;
|
|
144
147
|
tableInstanceRef?: MutableRefObject<TableInstance | undefined>;
|
|
148
|
+
height?: number;
|
|
149
|
+
maxHeight?: number;
|
|
150
|
+
minHeight?: number;
|
|
145
151
|
compact?: boolean;
|
|
146
152
|
headerRowHeight?: number;
|
|
147
153
|
rowHeight?: number;
|
|
@@ -203,6 +209,10 @@ export type TableMenuOptions = {
|
|
|
203
209
|
label?: string;
|
|
204
210
|
onClick?: () => void;
|
|
205
211
|
};
|
|
212
|
+
tableCountOptions?: {
|
|
213
|
+
recordsTotalEnabled?: boolean;
|
|
214
|
+
selectionTotalEnabled?: boolean;
|
|
215
|
+
};
|
|
206
216
|
searchOptions?: {
|
|
207
217
|
enabled?: boolean;
|
|
208
218
|
placeholder?: string;
|
|
@@ -218,11 +228,14 @@ export type TableMenuOptions = {
|
|
|
218
228
|
};
|
|
219
229
|
};
|
|
220
230
|
export interface TableProps {
|
|
221
|
-
|
|
231
|
+
columnProps: ColumnProps[];
|
|
222
232
|
data: any[];
|
|
223
233
|
totalRecords?: number;
|
|
224
234
|
keyField?: string;
|
|
225
235
|
tableInstanceRef?: MutableRefObject<TableInstance | undefined>;
|
|
236
|
+
height?: number;
|
|
237
|
+
maxHeight?: number;
|
|
238
|
+
minHeight?: number;
|
|
226
239
|
virtualized?: boolean;
|
|
227
240
|
loading?: boolean;
|
|
228
241
|
compact?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -33,5 +33,5 @@ export { default as Loader } from "./Loader";
|
|
|
33
33
|
export type { LoaderProps } from "./Loader";
|
|
34
34
|
export * from "./hooks";
|
|
35
35
|
export { QueryFilter, useQueryFilter } from "./QueryFilter";
|
|
36
|
-
export { Table
|
|
36
|
+
export { Table } from "./Table";
|
|
37
37
|
export type { ColumnProps, TableProps } from "./Table";
|
package/dist/index.js
CHANGED
|
@@ -27,4 +27,4 @@ export { default as RichTextEditor, Extensions, SlashCommands, Controls, } from
|
|
|
27
27
|
export { default as Loader } from "./Loader";
|
|
28
28
|
export * from "./hooks";
|
|
29
29
|
export { QueryFilter, useQueryFilter } from "./QueryFilter";
|
|
30
|
-
export { Table
|
|
30
|
+
export { Table } from "./Table";
|
package/package.json
CHANGED
package/dist/Table/Column.d.ts
DELETED