@monolith-forensics/monolith-ui 1.1.32 → 1.1.34
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.
|
@@ -5,10 +5,10 @@ import getTheme, { Themes } from "../theme";
|
|
|
5
5
|
import { createContext, useState } from "react";
|
|
6
6
|
import GlobalStyle from "./GlobalStyle";
|
|
7
7
|
export const MonolithUIContext = createContext(undefined);
|
|
8
|
-
const MonolithUIProvider = ({ children, theme = {}, defaultColorScheme = "
|
|
8
|
+
const MonolithUIProvider = ({ children, theme = {}, defaultColorScheme = "DARK", }) => {
|
|
9
9
|
const [colorScheme, setColorScheme] = useState(defaultColorScheme);
|
|
10
10
|
const toggleColorScheme = () => {
|
|
11
|
-
setColorScheme(colorScheme === "
|
|
11
|
+
setColorScheme(colorScheme === "LIGHT" ? "DARK" : "LIGHT");
|
|
12
12
|
};
|
|
13
13
|
const defaultTheme = getTheme(colorScheme);
|
|
14
14
|
// override default theme with the provided theme
|
package/dist/Table/Table.js
CHANGED
|
@@ -21,6 +21,7 @@ import { Maximize2Icon } from "lucide-react";
|
|
|
21
21
|
import { ArrowUpIcon, ArrowDownIcon } from "lucide-react";
|
|
22
22
|
import moment from "moment";
|
|
23
23
|
import { CheckBox } from "..";
|
|
24
|
+
import { Themes } from "../theme";
|
|
24
25
|
const MIN_COLUMN_WIDTH = 125;
|
|
25
26
|
export const Column = ({ dataField, caption, columnId = shortUUID.generate(), sorting, format, }) => {
|
|
26
27
|
return null;
|
|
@@ -157,7 +158,7 @@ const StyledTh = styled.th `
|
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
&:hover {
|
|
160
|
-
background-color: ${({ theme }) => theme.name ===
|
|
161
|
+
background-color: ${({ theme }) => theme.name === Themes.DARK ? "#2e2e2e" : "#f5f5f5"};
|
|
161
162
|
cursor: pointer;
|
|
162
163
|
}
|
|
163
164
|
&.dragging:active {
|
|
@@ -334,7 +335,7 @@ const InnerElement = forwardRef((_a, ref) => {
|
|
|
334
335
|
return (_jsxs(StyledTable, Object.assign({ ref: ref }, rest, { children: [_jsx(HeaderRowComponent, { columns: columns, resizeState: resizeState, _compact: _compact, headerHeight: headerHeight, onHeaderClick: onHeaderClick, dropColumn: dropColumn, dragColumn: dragColumn, showSelection: showSelection, selectAll: selectAll, selectionState: selectionState, handleSelectAll: handleSelectAll, handleColumnReorder: handleColumnReorder, onColumnResize: onColumnResize }), _jsx(StyledTbody, { className: "tbody" + (stripes ? " striped" : ""), stripes: stripes, children: children })] })));
|
|
335
336
|
});
|
|
336
337
|
const Row = ({ data, index, style }) => {
|
|
337
|
-
const { data: dataRows, columns, focusedRow, keyValue, _compact, queryKey, reloadFn, headerHeight, resizeState, onRowUpdated, } = data;
|
|
338
|
+
const { data: dataRows, columns, focusedRow, keyValue, _compact, queryKey, reloadFn, headerHeight, resizeState, onRowUpdated, onRowClick, onRowDoubleClick, } = data;
|
|
338
339
|
const item = (dataRows === null || dataRows === void 0 ? void 0 : dataRows[index]) || {};
|
|
339
340
|
const handleRowUpdated = (data) => {
|
|
340
341
|
onRowUpdated === null || onRowUpdated === void 0 ? void 0 : onRowUpdated({ rowData: item, updateData: data });
|
|
@@ -390,7 +391,15 @@ const Row = ({ data, index, style }) => {
|
|
|
390
391
|
: savedColSize || MIN_COLUMN_WIDTH,
|
|
391
392
|
}, children: [column.props.resizeEnabled !== false && _jsx(Resizer, { column: column }), value] }, shortUUID.generate()));
|
|
392
393
|
});
|
|
393
|
-
return (_jsx(StyledTr, { className: `tr${isRowFocused ? " focused" : ""}`, "data-key": item[keyValue], "data-type": "tr", "data-even": index % 2 === 0 ? "true" : "false", compact: _compact,
|
|
394
|
+
return (_jsx(StyledTr, { className: `tr${isRowFocused ? " focused" : ""}`, "data-key": item[keyValue], "data-type": "tr", "data-even": index % 2 === 0 ? "true" : "false", compact: _compact, onClick: (e) => {
|
|
395
|
+
// dblclick event
|
|
396
|
+
if (e.detail === 2) {
|
|
397
|
+
onRowDoubleClick === null || onRowDoubleClick === void 0 ? void 0 : onRowDoubleClick(item);
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(item);
|
|
401
|
+
}
|
|
402
|
+
}, style: Object.assign(Object.assign({}, style), { top: ((style === null || style === void 0 ? void 0 : style.top) || 0) + headerHeight }), children: row }, shortUUID.generate()));
|
|
394
403
|
};
|
|
395
404
|
export const useTable = () => {
|
|
396
405
|
const [tableInstance, setTableInstance] = useState(null);
|
|
@@ -408,7 +417,7 @@ export const useTable = () => {
|
|
|
408
417
|
onColumnResize: (e) => tableInstance === null || tableInstance === void 0 ? void 0 : tableInstance.onColumnResize(e),
|
|
409
418
|
};
|
|
410
419
|
};
|
|
411
|
-
const Table = styled(({ className, children, data, rowHeight, headerHeight, tableInstance, queryKey, totalRecords, compact, focusedRow, keyValue, onScroll, allowColumnResize, allowColumnReorder, showActionColumn, showSelection, selectAll, reloadFn, onColumnReorder, onSelectionChanged, onActionButtonClick, onHeaderClick, onColumnResize, onRowUpdated, }) => {
|
|
420
|
+
const Table = styled(({ className, children, data, rowHeight, headerHeight, tableInstance, queryKey, totalRecords, compact, focusedRow, keyValue, onScroll, allowColumnResize, allowColumnReorder, showActionColumn, showSelection, selectAll, reloadFn, onColumnReorder, onSelectionChanged, onActionButtonClick, onHeaderClick, onColumnResize, onRowUpdated, onRowClick, onRowDoubleClick, }) => {
|
|
412
421
|
const rootRef = useRef(null);
|
|
413
422
|
const [initialize, getInstance] = useOverlayScrollbars({
|
|
414
423
|
options: {
|
|
@@ -669,6 +678,8 @@ const Table = styled(({ className, children, data, rowHeight, headerHeight, tabl
|
|
|
669
678
|
: 38,
|
|
670
679
|
resizeState,
|
|
671
680
|
onRowUpdated,
|
|
681
|
+
onRowClick,
|
|
682
|
+
onRowDoubleClick,
|
|
672
683
|
tableWidth: width,
|
|
673
684
|
}, height: height, innerElementType: (props) => (_jsx(InnerElement, Object.assign({}, props, { columns: columns.filter((col) => !hiddenColumns.includes(col.props.dataField)), tableWidth: width, resizeState: resizeState, _compact: _compact, stripes: stripes, onHeaderClick: onHeaderClick, dropColumn: dropColumn, dragColumn: dragColumn, showSelection: showSelection, selectAll: selectAll, selectionState: selectionState, handleSelectAll: handleSelectAll, handleColumnReorder: handleColumnReorder, onColumnResize: onColumnResize }))), itemCount: data === null || data === void 0 ? void 0 : data.length, itemSize: rowHeight ? rowHeight : _compact ? 28 : 38, width: width, outerRef: setListElm, children: Row }) })) }) }));
|
|
674
685
|
}) `
|
package/dist/theme/variants.js
CHANGED
|
@@ -2,8 +2,8 @@ import merge from "deepmerge";
|
|
|
2
2
|
import typography from "./typography";
|
|
3
3
|
// Themes
|
|
4
4
|
export const THEMES = {
|
|
5
|
-
DARK: "
|
|
6
|
-
LIGHT: "
|
|
5
|
+
DARK: "DARK",
|
|
6
|
+
LIGHT: "LIGHT",
|
|
7
7
|
};
|
|
8
8
|
const customBlue = {
|
|
9
9
|
50: "#e9f0fb",
|
|
@@ -45,7 +45,7 @@ const lightVariant = {
|
|
|
45
45
|
name: THEMES.LIGHT,
|
|
46
46
|
typography,
|
|
47
47
|
palette: {
|
|
48
|
-
mode:
|
|
48
|
+
mode: THEMES.LIGHT,
|
|
49
49
|
primary: {
|
|
50
50
|
main: customBlue[700],
|
|
51
51
|
contrastText: "#FFF",
|
|
@@ -168,7 +168,7 @@ const lightVariant = {
|
|
|
168
168
|
const darkVariant = merge(lightVariant, {
|
|
169
169
|
name: THEMES.DARK,
|
|
170
170
|
palette: {
|
|
171
|
-
mode:
|
|
171
|
+
mode: THEMES.DARK,
|
|
172
172
|
divider: "rgba(255, 255, 255, 0.15)",
|
|
173
173
|
action: {
|
|
174
174
|
hover: "rgba(255, 255, 255, 0.05)",
|