@symply.io/basic-components 1.1.2 → 1.1.3-beta.2
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.
@@ -14,9 +14,9 @@ import { cloneElement, useState, useMemo } from "react";
|
|
14
14
|
import TableRow from "@mui/material/TableRow";
|
15
15
|
import TableCell from "@mui/material/TableCell";
|
16
16
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
17
|
-
import useTheme from "@mui/material/styles
|
17
|
+
import { useTheme } from "@mui/material/styles";
|
18
18
|
function TableBodyRow(props) {
|
19
|
-
var row = props.row, rows = props.rows, columns = props.columns, leftShadowVisible = props.leftShadowVisible, rightShadowVisible = props.rightShadowVisible, onRowClick = props.onRowClick;
|
19
|
+
var row = props.row, rows = props.rows, columns = props.columns, leftShadowVisible = props.leftShadowVisible, rightShadowVisible = props.rightShadowVisible, onRowClick = props.onRowClick, onCustomizeRowSxProps = props.onCustomizeRowSxProps;
|
20
20
|
var _a = useState(), rowEl = _a[0], setRowEl = _a[1];
|
21
21
|
var theme = useTheme();
|
22
22
|
var isUpMd = useMediaQuery(theme.breakpoints.up("md"));
|
@@ -31,12 +31,16 @@ function TableBodyRow(props) {
|
|
31
31
|
return [[], columns, []];
|
32
32
|
}
|
33
33
|
}, [isUpMd, columns]), fixedLeftCols = _b[0], dynamicCols = _b[1], fixedRightCols = _b[2];
|
34
|
-
|
35
|
-
|
34
|
+
var customRowSx = useMemo(function () {
|
35
|
+
if (onCustomizeRowSxProps) {
|
36
|
+
return onCustomizeRowSxProps({ row: row, columns: columns });
|
37
|
+
}
|
38
|
+
return {};
|
39
|
+
}, [row, columns, onCustomizeRowSxProps]);
|
40
|
+
return (_jsxs(TableRow, __assign({ sx: __assign(__assign({}, customRowSx), { "&:hover": {
|
36
41
|
cursor: onRowClick ? "pointer" : "default",
|
37
42
|
backgroundColor: onRowClick ? "#F2F1F3" : "#FEFEFE"
|
38
|
-
}
|
39
|
-
}, onMouseEnter: function (event) {
|
43
|
+
} }), onMouseEnter: function (event) {
|
40
44
|
setRowEl(event.currentTarget);
|
41
45
|
}, onMouseLeave: function () {
|
42
46
|
setRowEl(undefined);
|
package/DataTable/index.js
CHANGED
@@ -19,7 +19,7 @@ import TableBody from "./TableBody";
|
|
19
19
|
import TableHeader from "./TableHeader";
|
20
20
|
import TableFooter from "./TableFooter";
|
21
21
|
function DataTable(props) {
|
22
|
-
var _a = props.columns, columns = _a === void 0 ? [] : _a, _b = props.rows, rows = _b === void 0 ? [] : _b, _c = props.headers, headers = _c === void 0 ? [] : _c, _d = props.footers, footers = _d === void 0 ? [] : _d, _e = props.noDataText, noDataText = _e === void 0 ? "No Data!" : _e, dense = props.dense, stickyHeader = props.stickyHeader, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, onRowClick = props.onRowClick;
|
22
|
+
var _a = props.columns, columns = _a === void 0 ? [] : _a, _b = props.rows, rows = _b === void 0 ? [] : _b, _c = props.headers, headers = _c === void 0 ? [] : _c, _d = props.footers, footers = _d === void 0 ? [] : _d, _e = props.noDataText, noDataText = _e === void 0 ? "No Data!" : _e, dense = props.dense, stickyHeader = props.stickyHeader, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, onRowClick = props.onRowClick, onCustomizeRowSxProps = props.onCustomizeRowSxProps;
|
23
23
|
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
24
24
|
var tableRef = useRef(null);
|
25
25
|
var _f = useState(false), leftShadowVisible = _f[0], setLeftShadowVisible = _f[1];
|
@@ -53,7 +53,7 @@ function DataTable(props) {
|
|
53
53
|
borderRadius: "4px",
|
54
54
|
borderCollapse: "unset !important",
|
55
55
|
transition: "all 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms"
|
56
|
-
} }, { children: _jsxs(Table, __assign({ sx: { minWidth: 600, tableLayout: "fixed" }, stickyHeader: stickyHeader, size: dense ? "small" : "medium" }, { children: [_jsx(TableHeader, { headers: headers, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), _jsx(TableBody, { rows: rows, columns: columns, noDataText: noDataText, onRowClick: onRowClick, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), footers.length > 0 ? (_jsx(TableFooter, { footers: footers, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible })) : (_jsx(_Fragment, {}))] })) })) })));
|
56
|
+
} }, { children: _jsxs(Table, __assign({ sx: { minWidth: 600, tableLayout: "fixed" }, stickyHeader: stickyHeader, size: dense ? "small" : "medium" }, { children: [_jsx(TableHeader, { headers: headers, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), _jsx(TableBody, { rows: rows, columns: columns, noDataText: noDataText, onRowClick: onRowClick, onCustomizeRowSxProps: onCustomizeRowSxProps, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), footers.length > 0 ? (_jsx(TableFooter, { footers: footers, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible })) : (_jsx(_Fragment, {}))] })) })) })));
|
57
57
|
}
|
58
58
|
export default DataTable;
|
59
59
|
export { default as useDataTable } from "./useTable";
|
package/DataTable/types.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { ReactElement, CSSProperties } from "react";
|
2
|
+
import { SxProps } from "@mui/material/styles";
|
2
3
|
export declare type OrderType = "ASC" | "DESC" | "NONE";
|
3
4
|
export declare type KvProps = Record<string, unknown>;
|
4
5
|
export declare type SortingProps = {
|
@@ -57,6 +58,10 @@ export declare type TableBodyProps<RowProps extends KvProps, ExtendedProps exten
|
|
57
58
|
rightShadowVisible?: boolean;
|
58
59
|
noDataText?: string;
|
59
60
|
onRowClick?: (row: RowProps) => unknown;
|
61
|
+
onCustomizeRowSxProps?: ({ row, columns }: {
|
62
|
+
row: RowProps;
|
63
|
+
columns: Array<TableBodyCellProps<RowProps, ExtendedProps>>;
|
64
|
+
}) => SxProps;
|
60
65
|
};
|
61
66
|
export declare type TableBodyRowProps<RowProps extends KvProps, ExtendedProps extends KvProps> = Omit<TableBodyProps<RowProps, ExtendedProps>, "noDataText"> & {
|
62
67
|
row: RowProps;
|
package/NumberInput/index.js
CHANGED
@@ -31,7 +31,7 @@ function NumberInput(props) {
|
|
31
31
|
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
32
32
|
var EXCEED_ERROR = "Your value exceeds the exceptable input range";
|
33
33
|
if (maxValue < minValue)
|
34
|
-
throw new Error("Max should be bigger than
|
34
|
+
throw new Error("Max should be bigger than the `miniValue`!");
|
35
35
|
var _e = useInteractions({ maxValue: maxValue, minValue: minValue, value: value, onChange: onChange }), exceedError = _e.exceedError, tooltipOpen = _e.tooltipOpen, handleBlur = _e.handleBlur, handleChange = _e.handleChange, onOpenTooltip = _e.onOpenTooltip, onCloseTooltip = _e.onCloseTooltip;
|
36
36
|
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Tooltip, __assign({ title: tooltip !== null && tooltip !== void 0 ? tooltip : "", open: !!tooltip && tooltipOpen }, { children: _jsx(Field, __assign({ size: size, margin: "dense", type: "number", value: value === undefined || value === null ? "" : value, onFocus: onOpenTooltip, onBlur: function () {
|
37
37
|
onCloseTooltip();
|