@symply.io/basic-components 1.3.11-alpha.8 → 1.4.0-beta.1
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/AlertDialog/index.js +30 -8
- package/Autocomplete/index.js +32 -10
- package/Autocomplete/useInteractions.js +3 -3
- package/AutocompleteWithFilter/index.js +35 -12
- package/BasicModal/Content.js +16 -5
- package/BasicModal/index.js +31 -9
- package/BreadCrumbs/index.js +19 -8
- package/CheckBox/CheckBox.js +26 -4
- package/CheckBox/CheckBoxGroup.js +24 -2
- package/Copyright/index.js +14 -3
- package/DataTable/TableBody.js +24 -2
- package/DataTable/TableBodyRow.js +52 -41
- package/DataTable/TableFooter.js +41 -30
- package/DataTable/TableHeader.js +47 -36
- package/DataTable/index.js +28 -17
- package/DataTable/useTable.js +54 -46
- package/DateInput/FullDateInput/index.js +42 -20
- package/DateInput/FullDateInput/useInteractions.js +10 -10
- package/DateInput/MonthDayInput/index.js +36 -14
- package/DateInput/MonthDayInput/useInteractions.js +9 -9
- package/DateInput/MonthYearInput/index.js +36 -14
- package/DateInput/MonthYearInput/useInteractions.js +9 -9
- package/DigitInput/index.js +28 -6
- package/DigitInput/useInteractions.js +9 -9
- package/DynamicHeaderBar/HeaderBar.js +17 -6
- package/DynamicHeaderBar/HeaderButtons.js +24 -13
- package/DynamicHeaderBar/HeaderLine.js +2 -2
- package/DynamicHeaderBar/index.js +26 -15
- package/FeinInput/index.js +38 -16
- package/FeinInput/useInteractions.js +9 -9
- package/FileUploader/index.js +33 -11
- package/FileUploader/useInteractions.js +44 -29
- package/FormRadioGroup/index.js +29 -4
- package/FormSelector/MultipleSelector.js +32 -9
- package/FormSelector/SimpleSelector.js +32 -9
- package/FormSelector/useInteractions.js +7 -7
- package/HelpCaption/index.js +17 -6
- package/HelpCaption/useInteractions.js +2 -2
- package/LoadingModal/Modal.js +15 -4
- package/LoadingModal/useLoadingModal.js +33 -15
- package/MenuButtonGroup/MenuItem.js +14 -3
- package/MenuButtonGroup/index.js +82 -14
- package/NumberInput/index.js +27 -5
- package/NumberInput/useInteractions.js +17 -17
- package/PasswordInput/ConfirmPassword.js +28 -6
- package/PasswordInput/Password.js +37 -15
- package/PhoneNumberInput/index.js +39 -17
- package/PhoneNumberInput/useInteractions.js +10 -10
- package/Sidebar/SidebarItem.js +17 -6
- package/Sidebar/SidebarItemsGroup.js +21 -10
- package/Sidebar/SidebarLink.js +27 -5
- package/Sidebar/index.js +17 -6
- package/SocialInput/index.js +40 -18
- package/SocialInput/useInteractions.js +14 -14
- package/TabGroup/index.js +25 -14
- package/TablePagination/Actions.js +15 -4
- package/TablePagination/index.js +14 -3
- package/TablePagination/useInteractions.js +9 -9
- package/TextInput/index.js +30 -8
- package/TextInput/useInteractions.js +4 -4
- package/ToastPrompt/Prompt.d.ts +2 -1
- package/ToastPrompt/Prompt.js +22 -57
- package/ToastPrompt/index.js +18 -7
- package/ToastPrompt/types.d.ts +2 -8
- package/ToastPrompt/useInteractions.d.ts +2 -1
- package/ToastPrompt/useInteractions.js +21 -10
- package/VideoPlayerModal/index.js +27 -5
- package/package.json +1 -1
- package/useCustomTheme.js +16 -11
- package/utils/uuid.js +11 -10
@@ -1,3 +1,14 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
1
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
13
|
import { cloneElement, useState, useMemo } from "react";
|
3
14
|
import TableRow from "@mui/material/TableRow";
|
@@ -5,54 +16,54 @@ import TableCell from "@mui/material/TableCell";
|
|
5
16
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
6
17
|
import useTheme from "@mui/material/styles/useTheme";
|
7
18
|
function TableBodyRow(props) {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
19
|
+
var row = props.row, rows = props.rows, columns = props.columns, leftShadowVisible = props.leftShadowVisible, rightShadowVisible = props.rightShadowVisible, onRowClick = props.onRowClick, onCustomizeRowBgColor = props.onCustomizeRowBgColor;
|
20
|
+
var _a = useState(), rowEl = _a[0], setRowEl = _a[1];
|
21
|
+
var theme = useTheme();
|
22
|
+
var isUpMd = useMediaQuery(theme.breakpoints.up("md"));
|
23
|
+
var _b = useMemo(function () {
|
13
24
|
if (isUpMd) {
|
14
|
-
|
15
|
-
|
16
|
-
|
25
|
+
var left = columns.filter(function (c) { return c.fixable === "left"; });
|
26
|
+
var right = columns.filter(function (c) { return c.fixable === "right"; });
|
27
|
+
var dynamic = columns.filter(function (c) { return !c.fixable; });
|
17
28
|
return [left, dynamic, right];
|
18
29
|
}
|
19
30
|
else {
|
20
31
|
return [[], columns, []];
|
21
32
|
}
|
22
|
-
}, [isUpMd, columns]);
|
23
|
-
|
33
|
+
}, [isUpMd, columns]), fixedLeftCols = _b[0], dynamicCols = _b[1], fixedRightCols = _b[2];
|
34
|
+
var _c = useMemo(function () {
|
24
35
|
if (onCustomizeRowBgColor) {
|
25
|
-
|
26
|
-
|
36
|
+
var regex = /^#(\d|[a-f]|[A-F]){6}/i;
|
37
|
+
var _a = onCustomizeRowBgColor({ row: row, columns: columns }), normal_1 = _a.normal, hover_1 = _a.hover;
|
27
38
|
return {
|
28
|
-
normal:
|
29
|
-
hover:
|
39
|
+
normal: normal_1 && regex.test(normal_1) ? normal_1 : "#FEFEFE",
|
40
|
+
hover: hover_1 && regex.test(hover_1) ? hover_1 : "#F2F1F3"
|
30
41
|
};
|
31
42
|
}
|
32
43
|
return { normal: "#FEFEFE", hover: "#F2F1F3" };
|
33
|
-
}, [row, columns, onCustomizeRowBgColor]);
|
34
|
-
return (_jsxs(TableRow, { sx: {
|
44
|
+
}, [row, columns, onCustomizeRowBgColor]), normal = _c.normal, hover = _c.hover;
|
45
|
+
return (_jsxs(TableRow, __assign({ sx: {
|
35
46
|
backgroundColor: normal,
|
36
47
|
"&:hover": {
|
37
48
|
cursor: onRowClick ? "pointer" : "default",
|
38
49
|
backgroundColor: onRowClick ? hover : normal
|
39
50
|
}
|
40
|
-
}, onMouseEnter: event
|
51
|
+
}, onMouseEnter: function (event) {
|
41
52
|
setRowEl(event.currentTarget);
|
42
|
-
}, onMouseLeave: ()
|
53
|
+
}, onMouseLeave: function () {
|
43
54
|
setRowEl(undefined);
|
44
55
|
}, onClick: onRowClick
|
45
|
-
? ()
|
56
|
+
? function () {
|
46
57
|
onRowClick(row);
|
47
58
|
}
|
48
|
-
: undefined, children: [fixedLeftCols.map((col, index)
|
49
|
-
|
50
|
-
|
59
|
+
: undefined }, { children: [fixedLeftCols.map(function (col, index) {
|
60
|
+
var accessor = col.accessor, Cell = col.Cell, width = col.width, _a = col.align, align = _a === void 0 ? "center" : _a;
|
61
|
+
var left = fixedLeftCols
|
51
62
|
.slice(0, index)
|
52
|
-
.reduce((w, t)
|
53
|
-
return (_jsx(TableCell, { align: align, sx: {
|
54
|
-
width,
|
55
|
-
left,
|
63
|
+
.reduce(function (w, t) { return w + (t.width || 0); }, 0);
|
64
|
+
return (_jsx(TableCell, __assign({ align: align, sx: {
|
65
|
+
width: width,
|
66
|
+
left: left,
|
56
67
|
position: "sticky",
|
57
68
|
zIndex: 10,
|
58
69
|
backgroundColor: onRowClick && rowEl ? hover : normal,
|
@@ -69,22 +80,22 @@ function TableBodyRow(props) {
|
|
69
80
|
boxShadow: "inset 10px 0 10px -8px rgba(0, 0, 0, 0.1)"
|
70
81
|
}
|
71
82
|
: undefined
|
72
|
-
}, children: cloneElement(Cell, { column: col, rows, row }) }, accessor));
|
73
|
-
}), dynamicCols.map(col
|
74
|
-
|
75
|
-
return (_jsx(TableCell, { align: align, sx: {
|
76
|
-
width,
|
83
|
+
} }, { children: cloneElement(Cell, { column: col, rows: rows, row: row }) }), accessor));
|
84
|
+
}), dynamicCols.map(function (col) {
|
85
|
+
var accessor = col.accessor, Cell = col.Cell, width = col.width, _a = col.align, align = _a === void 0 ? "center" : _a;
|
86
|
+
return (_jsx(TableCell, __assign({ align: align, sx: {
|
87
|
+
width: width,
|
77
88
|
zIndex: 9,
|
78
89
|
backgroundColor: onRowClick && rowEl ? hover : normal
|
79
|
-
}, children: cloneElement(Cell, { column: col, rows, row }) }, accessor));
|
80
|
-
}), fixedRightCols.map((col, index)
|
81
|
-
|
82
|
-
|
90
|
+
} }, { children: cloneElement(Cell, { column: col, rows: rows, row: row }) }), accessor));
|
91
|
+
}), fixedRightCols.map(function (col, index) {
|
92
|
+
var accessor = col.accessor, Cell = col.Cell, width = col.width, _a = col.align, align = _a === void 0 ? "center" : _a;
|
93
|
+
var right = fixedRightCols
|
83
94
|
.slice(0, fixedRightCols.length - 1 - index)
|
84
|
-
.reduce((w, t)
|
85
|
-
return (_jsx(TableCell, { align: align, sx: {
|
86
|
-
width,
|
87
|
-
right,
|
95
|
+
.reduce(function (w, t) { return w + (t.width || 0); }, 0);
|
96
|
+
return (_jsx(TableCell, __assign({ align: align, sx: {
|
97
|
+
width: width,
|
98
|
+
right: right,
|
88
99
|
position: "sticky",
|
89
100
|
zIndex: 10,
|
90
101
|
backgroundColor: onRowClick && rowEl ? hover : normal,
|
@@ -101,7 +112,7 @@ function TableBodyRow(props) {
|
|
101
112
|
boxShadow: "inset -10px 0 10px -8px rgba(0, 0, 0, 0.1)"
|
102
113
|
}
|
103
114
|
: undefined
|
104
|
-
}, children: cloneElement(Cell, { column: col, rows, row }) }, accessor));
|
105
|
-
})] }));
|
115
|
+
} }, { children: cloneElement(Cell, { column: col, rows: rows, row: row }) }), accessor));
|
116
|
+
})] })));
|
106
117
|
}
|
107
118
|
export default TableBodyRow;
|
package/DataTable/TableFooter.js
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
1
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
13
|
import { cloneElement, useMemo } from "react";
|
3
14
|
import TableRow from "@mui/material/TableRow";
|
@@ -6,31 +17,31 @@ import TableCell from "@mui/material/TableCell";
|
|
6
17
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
7
18
|
import useTheme from "@mui/material/styles/useTheme";
|
8
19
|
function TableFooter(props) {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
20
|
+
var footers = props.footers, noData = props.noData, leftShadowVisible = props.leftShadowVisible, rightShadowVisible = props.rightShadowVisible;
|
21
|
+
var theme = useTheme();
|
22
|
+
var isUpMd = useMediaQuery(theme.breakpoints.up("md"));
|
23
|
+
var _a = useMemo(function () {
|
13
24
|
if (isUpMd && !noData) {
|
14
|
-
|
15
|
-
|
16
|
-
|
25
|
+
var left = footers.filter(function (f) { return f.fixable === "left"; });
|
26
|
+
var right = footers.filter(function (f) { return f.fixable === "right"; });
|
27
|
+
var dynamic = footers.filter(function (f) { return !f.fixable; });
|
17
28
|
return [left, dynamic, right];
|
18
29
|
}
|
19
30
|
else {
|
20
31
|
return [[], footers, []];
|
21
32
|
}
|
22
|
-
}, [isUpMd, noData, footers]);
|
23
|
-
return (_jsx(Footer, { sx: { position: "sticky", bottom: "-1px", zIndex: 20 }, children: _jsxs(TableRow, { sx: { backgroundColor: "#eaf0f6" }, children: [fixedLeftFooters.map((footer, index)
|
24
|
-
|
25
|
-
|
33
|
+
}, [isUpMd, noData, footers]), fixedLeftFooters = _a[0], dynamicFooters = _a[1], fixedRightFooters = _a[2];
|
34
|
+
return (_jsx(Footer, __assign({ sx: { position: "sticky", bottom: "-1px", zIndex: 20 } }, { children: _jsxs(TableRow, __assign({ sx: { backgroundColor: "#eaf0f6" } }, { children: [fixedLeftFooters.map(function (footer, index) {
|
35
|
+
var accessor = footer.accessor, Cell = footer.Cell, _a = footer.align, align = _a === void 0 ? "center" : _a, width = footer.width;
|
36
|
+
var left = fixedLeftFooters
|
26
37
|
.slice(0, index)
|
27
|
-
.reduce((w, t)
|
28
|
-
return (_jsx(TableCell, { align: align, sx: {
|
38
|
+
.reduce(function (w, t) { return w + (t.width || 0); }, 0);
|
39
|
+
return (_jsx(TableCell, __assign({ align: align, sx: {
|
29
40
|
position: "sticky",
|
30
41
|
backgroundColor: "#eaf0f6",
|
31
42
|
zIndex: 10,
|
32
|
-
left,
|
33
|
-
width,
|
43
|
+
left: left,
|
44
|
+
width: width,
|
34
45
|
userSelect: "none",
|
35
46
|
"&::after": index === fixedLeftFooters.length - 1 && leftShadowVisible
|
36
47
|
? {
|
@@ -45,24 +56,24 @@ function TableFooter(props) {
|
|
45
56
|
boxShadow: "inset 10px 0 10px -8px rgba(0, 0, 0, 0.1)"
|
46
57
|
}
|
47
58
|
: undefined
|
48
|
-
}, children: cloneElement(Cell) }, accessor));
|
49
|
-
}), dynamicFooters.map(footer
|
50
|
-
|
51
|
-
return (_jsx(TableCell, { align: align, sx: {
|
59
|
+
} }, { children: cloneElement(Cell) }), accessor));
|
60
|
+
}), dynamicFooters.map(function (footer) {
|
61
|
+
var accessor = footer.accessor, Cell = footer.Cell, _a = footer.align, align = _a === void 0 ? "center" : _a, width = footer.width;
|
62
|
+
return (_jsx(TableCell, __assign({ align: align, sx: {
|
52
63
|
zIndex: 9,
|
53
|
-
width,
|
64
|
+
width: width,
|
54
65
|
userSelect: "none"
|
55
|
-
}, children: cloneElement(Cell) }, accessor));
|
56
|
-
}), fixedRightFooters.map((footer, index)
|
57
|
-
|
58
|
-
|
66
|
+
} }, { children: cloneElement(Cell) }), accessor));
|
67
|
+
}), fixedRightFooters.map(function (footer, index) {
|
68
|
+
var accessor = footer.accessor, Cell = footer.Cell, _a = footer.align, align = _a === void 0 ? "center" : _a, width = footer.width;
|
69
|
+
var right = fixedRightFooters
|
59
70
|
.slice(0, fixedRightFooters.length - 1 - index)
|
60
|
-
.reduce((w, t)
|
61
|
-
return (_jsx(TableCell, { align: align, sx: {
|
71
|
+
.reduce(function (w, t) { return w + (t.width || 0); }, 0);
|
72
|
+
return (_jsx(TableCell, __assign({ align: align, sx: {
|
62
73
|
position: "sticky",
|
63
74
|
zIndex: 10,
|
64
|
-
width,
|
65
|
-
right,
|
75
|
+
width: width,
|
76
|
+
right: right,
|
66
77
|
backgroundColor: "#eaf0f6",
|
67
78
|
userSelect: "none",
|
68
79
|
"&::after": index === 0 && rightShadowVisible
|
@@ -78,7 +89,7 @@ function TableFooter(props) {
|
|
78
89
|
boxShadow: "inset -10px 0 10px -8px rgba(0, 0, 0, 0.1)"
|
79
90
|
}
|
80
91
|
: undefined
|
81
|
-
}, children: cloneElement(Cell) }, accessor));
|
82
|
-
})] }) }));
|
92
|
+
} }, { children: cloneElement(Cell) }), accessor));
|
93
|
+
})] })) })));
|
83
94
|
}
|
84
95
|
export default TableFooter;
|
package/DataTable/TableHeader.js
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
1
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
13
|
import { cloneElement, useMemo } from "react";
|
3
14
|
import TableRow from "@mui/material/TableRow";
|
@@ -6,31 +17,31 @@ import TableCell from "@mui/material/TableCell";
|
|
6
17
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
7
18
|
import useTheme from "@mui/material/styles/useTheme";
|
8
19
|
function TableHeader(props) {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
20
|
+
var headers = props.headers, noData = props.noData, leftShadowVisible = props.leftShadowVisible, rightShadowVisible = props.rightShadowVisible;
|
21
|
+
var theme = useTheme();
|
22
|
+
var isUpMd = useMediaQuery(theme.breakpoints.up("md"));
|
23
|
+
var _a = useMemo(function () {
|
13
24
|
if (isUpMd && !noData) {
|
14
|
-
|
15
|
-
|
16
|
-
|
25
|
+
var left = headers.filter(function (h) { return h.fixable === "left"; });
|
26
|
+
var right = headers.filter(function (h) { return h.fixable === "right"; });
|
27
|
+
var dynamic = headers.filter(function (h) { return !h.fixable; });
|
17
28
|
return [left, dynamic, right];
|
18
29
|
}
|
19
30
|
else {
|
20
31
|
return [[], headers, []];
|
21
32
|
}
|
22
|
-
}, [isUpMd, noData, headers]);
|
23
|
-
return (_jsx(TableHead, { sx: { position: "sticky", top: 0, zIndex: 20 }, children: _jsxs(TableRow, { sx: { backgroundColor: "#eaf0f6" }, children: [fixedLeftHeaders.map((header, index)
|
24
|
-
|
25
|
-
|
33
|
+
}, [isUpMd, noData, headers]), fixedLeftHeaders = _a[0], dynamicHeaders = _a[1], fixedRightHeaders = _a[2];
|
34
|
+
return (_jsx(TableHead, __assign({ sx: { position: "sticky", top: 0, zIndex: 20 } }, { children: _jsxs(TableRow, __assign({ sx: { backgroundColor: "#eaf0f6" } }, { children: [fixedLeftHeaders.map(function (header, index) {
|
35
|
+
var accessor = header.accessor, Cell = header.Cell, _a = header.align, align = _a === void 0 ? "center" : _a, width = header.width, title = header.title, _b = header.sortable, sortable = _b === void 0 ? false : _b, onSort = header.onSort;
|
36
|
+
var left = fixedLeftHeaders
|
26
37
|
.slice(0, index)
|
27
|
-
.reduce((w, t)
|
28
|
-
return (_jsx(TableCell, { title: title, align: align, sx: {
|
38
|
+
.reduce(function (w, t) { return w + (t.width || 0); }, 0);
|
39
|
+
return (_jsx(TableCell, __assign({ title: title, align: align, sx: {
|
29
40
|
position: "sticky",
|
30
41
|
backgroundColor: "#eaf0f6",
|
31
42
|
zIndex: 10,
|
32
|
-
width,
|
33
|
-
left,
|
43
|
+
width: width,
|
44
|
+
left: left,
|
34
45
|
userSelect: "none",
|
35
46
|
cursor: sortable ? "pointer" : "default",
|
36
47
|
"&::after": index === fixedLeftHeaders.length - 1 && leftShadowVisible
|
@@ -46,30 +57,30 @@ function TableHeader(props) {
|
|
46
57
|
boxShadow: "inset 10px 0 10px -8px rgba(0, 0, 0, 0.1)"
|
47
58
|
}
|
48
59
|
: undefined
|
49
|
-
}, onClick: ()
|
50
|
-
onSort({ accessor });
|
51
|
-
}, children: cloneElement(Cell) }, accessor));
|
52
|
-
}), dynamicHeaders.map(header
|
53
|
-
|
54
|
-
return (_jsx(TableCell, { title: title, align: align, sx: {
|
55
|
-
width,
|
60
|
+
}, onClick: function () {
|
61
|
+
onSort({ accessor: accessor });
|
62
|
+
} }, { children: cloneElement(Cell) }), accessor));
|
63
|
+
}), dynamicHeaders.map(function (header) {
|
64
|
+
var accessor = header.accessor, Cell = header.Cell, _a = header.align, align = _a === void 0 ? "center" : _a, width = header.width, title = header.title, _b = header.sortable, sortable = _b === void 0 ? false : _b, onSort = header.onSort;
|
65
|
+
return (_jsx(TableCell, __assign({ title: title, align: align, sx: {
|
66
|
+
width: width,
|
56
67
|
zIndex: 9,
|
57
68
|
userSelect: "none",
|
58
69
|
cursor: sortable ? "pointer" : "default"
|
59
|
-
}, onClick: ()
|
60
|
-
onSort({ accessor });
|
61
|
-
}, children: cloneElement(Cell) }, accessor));
|
62
|
-
}), fixedRightHeaders.map((header, index)
|
63
|
-
|
64
|
-
|
70
|
+
}, onClick: function () {
|
71
|
+
onSort({ accessor: accessor });
|
72
|
+
} }, { children: cloneElement(Cell) }), accessor));
|
73
|
+
}), fixedRightHeaders.map(function (header, index) {
|
74
|
+
var accessor = header.accessor, Cell = header.Cell, _a = header.align, align = _a === void 0 ? "center" : _a, width = header.width, title = header.title, _b = header.sortable, sortable = _b === void 0 ? false : _b, onSort = header.onSort;
|
75
|
+
var right = fixedRightHeaders
|
65
76
|
.slice(0, fixedRightHeaders.length - 1 - index)
|
66
|
-
.reduce((w, t)
|
67
|
-
return (_jsx(TableCell, { title: title, align: align, sx: {
|
77
|
+
.reduce(function (w, t) { return w + (t.width || 0); }, 0);
|
78
|
+
return (_jsx(TableCell, __assign({ title: title, align: align, sx: {
|
68
79
|
position: "sticky",
|
69
80
|
backgroundColor: "#eaf0f6",
|
70
81
|
zIndex: 10,
|
71
|
-
width,
|
72
|
-
right,
|
82
|
+
width: width,
|
83
|
+
right: right,
|
73
84
|
userSelect: "none",
|
74
85
|
cursor: sortable ? "pointer" : "default",
|
75
86
|
"&::after": index === 0 && rightShadowVisible
|
@@ -85,9 +96,9 @@ function TableHeader(props) {
|
|
85
96
|
boxShadow: "inset -10px 0 10px -8px rgba(0, 0, 0, 0.1)"
|
86
97
|
}
|
87
98
|
: undefined
|
88
|
-
}, onClick: ()
|
89
|
-
onSort({ accessor });
|
90
|
-
}, children: cloneElement(Cell) }, accessor));
|
91
|
-
})] }) }));
|
99
|
+
}, onClick: function () {
|
100
|
+
onSort({ accessor: accessor });
|
101
|
+
} }, { children: cloneElement(Cell) }), accessor));
|
102
|
+
})] })) })));
|
92
103
|
}
|
93
104
|
export default TableHeader;
|
package/DataTable/index.js
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
1
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
2
13
|
import { useState, useCallback, useRef, useEffect } from "react";
|
3
14
|
import Table from "@mui/material/Table";
|
@@ -8,34 +19,34 @@ import TableBody from "./TableBody";
|
|
8
19
|
import TableHeader from "./TableHeader";
|
9
20
|
import TableFooter from "./TableFooter";
|
10
21
|
function DataTable(props) {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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, onCustomizeRowBgColor = props.onCustomizeRowBgColor;
|
23
|
+
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
24
|
+
var tableRef = useRef(null);
|
25
|
+
var _f = useState(false), leftShadowVisible = _f[0], setLeftShadowVisible = _f[1];
|
26
|
+
var _g = useState(false), rightShadowVisible = _g[0], setRightShadowVisible = _g[1];
|
27
|
+
var onProcessShadowVisible = useCallback(function () {
|
17
28
|
if (tableRef.current) {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
29
|
+
var target = tableRef.current;
|
30
|
+
var scrollLeft = target.scrollLeft;
|
31
|
+
var scrollWidth = target.scrollWidth;
|
32
|
+
var clientWidth = target.clientWidth;
|
33
|
+
var hasScrollBar = scrollWidth > clientWidth;
|
23
34
|
setLeftShadowVisible(hasScrollBar && scrollLeft > 0);
|
24
35
|
setRightShadowVisible(hasScrollBar && scrollWidth - scrollLeft > clientWidth + 1);
|
25
36
|
}
|
26
37
|
}, []);
|
27
|
-
useEffect(()
|
38
|
+
useEffect(function () {
|
28
39
|
if (columns) {
|
29
40
|
onProcessShadowVisible();
|
30
41
|
}
|
31
42
|
}, [columns, onProcessShadowVisible]);
|
32
|
-
useEffect(()
|
43
|
+
useEffect(function () {
|
33
44
|
window.addEventListener("resize", onProcessShadowVisible);
|
34
45
|
}, [onProcessShadowVisible]);
|
35
|
-
useEffect(()
|
46
|
+
useEffect(function () { return function () {
|
36
47
|
window.removeEventListener("scroll", onProcessShadowVisible);
|
37
|
-
}, [onProcessShadowVisible]);
|
38
|
-
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(TableContainer, { ref: tableRef, onScroll: onProcessShadowVisible, sx: {
|
48
|
+
}; }, [onProcessShadowVisible]);
|
49
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(TableContainer, __assign({ ref: tableRef, onScroll: onProcessShadowVisible, sx: {
|
39
50
|
maxHeight: "inherit",
|
40
51
|
borderWidth: "thin",
|
41
52
|
borderColor: "#e5e5e5",
|
@@ -43,7 +54,7 @@ function DataTable(props) {
|
|
43
54
|
borderRadius: "4px",
|
44
55
|
borderCollapse: "unset !important",
|
45
56
|
transition: "all 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms"
|
46
|
-
}, children: _jsxs(Table, { 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, onCustomizeRowBgColor: onCustomizeRowBgColor, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), footers.length > 0 ? (_jsx(TableFooter, { footers: footers, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible })) : (_jsx(_Fragment, {}))] }) }) }));
|
57
|
+
} }, { 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, onCustomizeRowBgColor: onCustomizeRowBgColor, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), footers.length > 0 ? (_jsx(TableFooter, { footers: footers, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible })) : (_jsx(_Fragment, {}))] })) })) })));
|
47
58
|
}
|
48
59
|
export default DataTable;
|
49
60
|
export * from "./types";
|
package/DataTable/useTable.js
CHANGED
@@ -1,40 +1,63 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
13
|
+
var t = {};
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
15
|
+
t[p] = s[p];
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
19
|
+
t[p[i]] = s[p[i]];
|
20
|
+
}
|
21
|
+
return t;
|
22
|
+
};
|
1
23
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
24
|
import { cloneElement, useState, useMemo, useCallback } from "react";
|
3
25
|
function useTable(props) {
|
4
|
-
|
26
|
+
var data = props.data, columns = props.columns, initialState = props.initialState, disableSortBy = props.disableSortBy, onSort = props.onSort, rest = __rest(props, ["data", "columns", "initialState", "disableSortBy", "onSort"]);
|
5
27
|
if (!data) {
|
6
28
|
throw new Error('"data" is required but got null or undefined');
|
7
29
|
}
|
8
30
|
if (!columns) {
|
9
31
|
throw new Error('"columns" is required but got null or undefined');
|
10
32
|
}
|
11
|
-
|
12
|
-
|
13
|
-
|
33
|
+
var sortBy = (initialState || {}).sortBy;
|
34
|
+
var _a = sortBy || {}, accessor = _a.accessor, order = _a.order;
|
35
|
+
var _b = useState({
|
14
36
|
accessor: accessor || "",
|
15
37
|
order: !!accessor ? order || "NONE" : "NONE"
|
16
|
-
});
|
17
|
-
|
38
|
+
}), sortingProps = _b[0], setSortingProps = _b[1];
|
39
|
+
var handleSort = useCallback(function (_a) {
|
40
|
+
var accessor = _a.accessor;
|
18
41
|
if (!disableSortBy) {
|
19
|
-
|
42
|
+
var newSortingProps = __assign({}, sortingProps);
|
20
43
|
if (accessor !== sortingProps.accessor ||
|
21
44
|
sortingProps.order === "NONE") {
|
22
|
-
newSortingProps = { accessor, order: "ASC" };
|
45
|
+
newSortingProps = { accessor: accessor, order: "ASC" };
|
23
46
|
}
|
24
47
|
else if (sortingProps.order === "ASC") {
|
25
|
-
newSortingProps = {
|
48
|
+
newSortingProps = __assign(__assign({}, sortingProps), { order: "DESC" });
|
26
49
|
}
|
27
50
|
else {
|
28
|
-
newSortingProps = {
|
51
|
+
newSortingProps = __assign(__assign({}, sortingProps), { order: "NONE" });
|
29
52
|
}
|
30
53
|
if (onSort) {
|
31
|
-
onSort({
|
54
|
+
onSort(__assign({}, newSortingProps));
|
32
55
|
}
|
33
|
-
setSortingProps({
|
56
|
+
setSortingProps(__assign({}, newSortingProps));
|
34
57
|
}
|
35
58
|
}, [disableSortBy, onSort, sortingProps]);
|
36
|
-
|
37
|
-
|
59
|
+
var renderSortingSymbol = useCallback(function (accessor) {
|
60
|
+
var field = sortingProps.accessor, order = sortingProps.order;
|
38
61
|
if (accessor !== field || order === "NONE") {
|
39
62
|
return "";
|
40
63
|
}
|
@@ -43,44 +66,29 @@ function useTable(props) {
|
|
43
66
|
}
|
44
67
|
return "↓";
|
45
68
|
}, [sortingProps]);
|
46
|
-
|
47
|
-
|
48
|
-
return columns.map(col
|
49
|
-
|
50
|
-
return {
|
51
|
-
Cell: cloneElement(Body || _jsx(_Fragment, {}), { column: col }),
|
52
|
-
...col,
|
53
|
-
...rest
|
54
|
-
};
|
69
|
+
var rows = useMemo(function () { return data.map(function (d) { return (__assign({}, d)); }); }, [data]);
|
70
|
+
var cols = useMemo(function () {
|
71
|
+
return columns.map(function (col) {
|
72
|
+
var Body = col.Body;
|
73
|
+
return __assign(__assign({ Cell: cloneElement(Body || _jsx(_Fragment, {}), { column: col }) }, col), rest);
|
55
74
|
});
|
56
75
|
}, [columns, rest]);
|
57
|
-
|
58
|
-
return columns.map(col
|
59
|
-
|
60
|
-
|
61
|
-
return {
|
62
|
-
Cell: (_jsxs(_Fragment, { children: [cloneElement(Header || _jsx(_Fragment, {}), { column: col }), canSortBy && renderSortingSymbol(accessor)] })),
|
63
|
-
title: `${headerTip || ""}${canSortBy ? " (Click to sort)" : ""}`,
|
64
|
-
sortable: canSortBy,
|
65
|
-
onSort: canSortBy ? handleSort : () => { },
|
66
|
-
...col,
|
67
|
-
...rest
|
68
|
-
};
|
76
|
+
var headers = useMemo(function () {
|
77
|
+
return columns.map(function (col) {
|
78
|
+
var Header = col.Header, accessor = col.accessor, sortable = col.sortable, headerTip = col.headerTip;
|
79
|
+
var canSortBy = sortable && !disableSortBy;
|
80
|
+
return __assign(__assign({ Cell: (_jsxs(_Fragment, { children: [cloneElement(Header || _jsx(_Fragment, {}), { column: col }), canSortBy && renderSortingSymbol(accessor)] })), title: "".concat(headerTip || "").concat(canSortBy ? " (Click to sort)" : ""), sortable: canSortBy, onSort: canSortBy ? handleSort : function () { } }, col), rest);
|
69
81
|
});
|
70
82
|
}, [columns, disableSortBy, handleSort, renderSortingSymbol, rest]);
|
71
|
-
|
72
|
-
return columns.map(col
|
73
|
-
|
74
|
-
return {
|
75
|
-
Cell: cloneElement(Footer || _jsx(_Fragment, {}), {
|
83
|
+
var footers = useMemo(function () {
|
84
|
+
return columns.map(function (col) {
|
85
|
+
var Footer = col.Footer;
|
86
|
+
return __assign(__assign({ Cell: cloneElement(Footer || _jsx(_Fragment, {}), {
|
76
87
|
column: col,
|
77
|
-
rows
|
78
|
-
}),
|
79
|
-
...col,
|
80
|
-
...rest
|
81
|
-
};
|
88
|
+
rows: rows
|
89
|
+
}) }, col), rest);
|
82
90
|
});
|
83
91
|
}, [columns, rest, rows]);
|
84
|
-
return { headers, footers, columns: cols, rows };
|
92
|
+
return { headers: headers, footers: footers, columns: cols, rows: rows };
|
85
93
|
}
|
86
94
|
export default useTable;
|