@symply.io/basic-components 1.3.11-alpha.9 → 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.
Files changed (70) hide show
  1. package/AlertDialog/index.js +30 -8
  2. package/Autocomplete/index.js +32 -10
  3. package/Autocomplete/useInteractions.js +3 -3
  4. package/AutocompleteWithFilter/index.js +35 -12
  5. package/BasicModal/Content.js +16 -5
  6. package/BasicModal/index.js +31 -9
  7. package/BreadCrumbs/index.js +19 -8
  8. package/CheckBox/CheckBox.js +26 -4
  9. package/CheckBox/CheckBoxGroup.js +24 -2
  10. package/Copyright/index.js +14 -3
  11. package/DataTable/TableBody.js +24 -2
  12. package/DataTable/TableBodyRow.js +52 -41
  13. package/DataTable/TableFooter.js +41 -30
  14. package/DataTable/TableHeader.js +47 -36
  15. package/DataTable/index.js +28 -17
  16. package/DataTable/useTable.js +54 -46
  17. package/DateInput/FullDateInput/index.js +42 -20
  18. package/DateInput/FullDateInput/useInteractions.js +10 -10
  19. package/DateInput/MonthDayInput/index.js +36 -14
  20. package/DateInput/MonthDayInput/useInteractions.js +9 -9
  21. package/DateInput/MonthYearInput/index.js +36 -14
  22. package/DateInput/MonthYearInput/useInteractions.js +9 -9
  23. package/DigitInput/index.js +28 -6
  24. package/DigitInput/useInteractions.js +9 -9
  25. package/DynamicHeaderBar/HeaderBar.js +17 -6
  26. package/DynamicHeaderBar/HeaderButtons.js +24 -13
  27. package/DynamicHeaderBar/HeaderLine.js +2 -2
  28. package/DynamicHeaderBar/index.js +26 -15
  29. package/FeinInput/index.js +38 -16
  30. package/FeinInput/useInteractions.js +9 -9
  31. package/FileUploader/index.js +33 -11
  32. package/FileUploader/useInteractions.js +44 -29
  33. package/FormRadioGroup/index.js +29 -4
  34. package/FormSelector/MultipleSelector.js +32 -9
  35. package/FormSelector/SimpleSelector.js +32 -9
  36. package/FormSelector/useInteractions.js +7 -7
  37. package/HelpCaption/index.js +17 -6
  38. package/HelpCaption/useInteractions.js +2 -2
  39. package/LoadingModal/Modal.js +15 -4
  40. package/LoadingModal/useLoadingModal.js +33 -15
  41. package/MenuButtonGroup/MenuItem.js +14 -3
  42. package/MenuButtonGroup/index.js +82 -14
  43. package/NumberInput/index.js +27 -5
  44. package/NumberInput/useInteractions.js +17 -17
  45. package/PasswordInput/ConfirmPassword.js +28 -6
  46. package/PasswordInput/Password.js +37 -15
  47. package/PhoneNumberInput/index.js +39 -17
  48. package/PhoneNumberInput/useInteractions.js +10 -10
  49. package/Sidebar/SidebarItem.js +17 -6
  50. package/Sidebar/SidebarItemsGroup.js +21 -10
  51. package/Sidebar/SidebarLink.js +27 -5
  52. package/Sidebar/index.js +17 -6
  53. package/SocialInput/index.js +40 -18
  54. package/SocialInput/useInteractions.js +14 -14
  55. package/TabGroup/index.js +25 -14
  56. package/TablePagination/Actions.js +15 -4
  57. package/TablePagination/index.js +14 -3
  58. package/TablePagination/useInteractions.js +9 -9
  59. package/TextInput/index.js +30 -8
  60. package/TextInput/useInteractions.js +4 -4
  61. package/ToastPrompt/Prompt.d.ts +2 -1
  62. package/ToastPrompt/Prompt.js +20 -55
  63. package/ToastPrompt/index.js +18 -7
  64. package/ToastPrompt/types.d.ts +2 -8
  65. package/ToastPrompt/useInteractions.d.ts +2 -1
  66. package/ToastPrompt/useInteractions.js +21 -10
  67. package/VideoPlayerModal/index.js +27 -5
  68. package/package.json +1 -1
  69. package/useCustomTheme.js +16 -11
  70. 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
- const { row, rows, columns, leftShadowVisible, rightShadowVisible, onRowClick, onCustomizeRowBgColor } = props;
9
- const [rowEl, setRowEl] = useState();
10
- const theme = useTheme();
11
- const isUpMd = useMediaQuery(theme.breakpoints.up("md"));
12
- const [fixedLeftCols, dynamicCols, fixedRightCols] = useMemo(() => {
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
- const left = columns.filter(c => c.fixable === "left");
15
- const right = columns.filter(c => c.fixable === "right");
16
- const dynamic = columns.filter(c => !c.fixable);
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
- const { normal, hover } = useMemo(() => {
33
+ }, [isUpMd, columns]), fixedLeftCols = _b[0], dynamicCols = _b[1], fixedRightCols = _b[2];
34
+ var _c = useMemo(function () {
24
35
  if (onCustomizeRowBgColor) {
25
- const regex = /^#(\d|[a-f]|[A-F]){6}/i;
26
- const { normal, hover } = onCustomizeRowBgColor({ row, columns });
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: normal && regex.test(normal) ? normal : "#FEFEFE",
29
- hover: hover && regex.test(hover) ? hover : "#F2F1F3"
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
- const { accessor, Cell, width, align = "center" } = col;
50
- const left = fixedLeftCols
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) => w + (t.width || 0), 0);
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
- const { accessor, Cell, width, align = "center" } = col;
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
- const { accessor, Cell, width, align = "center" } = col;
82
- const right = fixedRightCols
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) => w + (t.width || 0), 0);
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;
@@ -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
- const { footers, noData, leftShadowVisible, rightShadowVisible } = props;
10
- const theme = useTheme();
11
- const isUpMd = useMediaQuery(theme.breakpoints.up("md"));
12
- const [fixedLeftFooters, dynamicFooters, fixedRightFooters] = useMemo(() => {
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
- const left = footers.filter(f => f.fixable === "left");
15
- const right = footers.filter(f => f.fixable === "right");
16
- const dynamic = footers.filter(f => !f.fixable);
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
- const { accessor, Cell, align = "center", width } = footer;
25
- const left = fixedLeftFooters
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) => w + (t.width || 0), 0);
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
- const { accessor, Cell, align = "center", width } = footer;
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
- const { accessor, Cell, align = "center", width } = footer;
58
- const right = fixedRightFooters
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) => w + (t.width || 0), 0);
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;
@@ -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
- const { headers, noData, leftShadowVisible, rightShadowVisible } = props;
10
- const theme = useTheme();
11
- const isUpMd = useMediaQuery(theme.breakpoints.up("md"));
12
- const [fixedLeftHeaders, dynamicHeaders, fixedRightHeaders] = useMemo(() => {
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
- const left = headers.filter(h => h.fixable === "left");
15
- const right = headers.filter(h => h.fixable === "right");
16
- const dynamic = headers.filter(h => !h.fixable);
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
- const { accessor, Cell, align = "center", width, title, sortable = false, onSort } = header;
25
- const left = fixedLeftHeaders
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) => w + (t.width || 0), 0);
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
- const { accessor, Cell, align = "center", width, title, sortable = false, onSort } = header;
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
- const { accessor, Cell, align = "center", width, title, sortable = false, onSort } = header;
64
- const right = fixedRightHeaders
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) => w + (t.width || 0), 0);
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;
@@ -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
- const { columns = [], rows = [], headers = [], footers = [], noDataText = "No Data!", dense, stickyHeader, primaryColor, secondaryColor, onRowClick, onCustomizeRowBgColor } = props;
12
- const theme = useCustomTheme({ primaryColor, secondaryColor });
13
- const tableRef = useRef(null);
14
- const [leftShadowVisible, setLeftShadowVisible] = useState(false);
15
- const [rightShadowVisible, setRightShadowVisible] = useState(false);
16
- const onProcessShadowVisible = useCallback(() => {
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
- const target = tableRef.current;
19
- const scrollLeft = target.scrollLeft;
20
- const scrollWidth = target.scrollWidth;
21
- const clientWidth = target.clientWidth;
22
- const hasScrollBar = scrollWidth > clientWidth;
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";
@@ -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
- const { data, columns, initialState, disableSortBy, onSort, ...rest } = props;
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
- const { sortBy } = initialState || {};
12
- const { accessor, order } = sortBy || {};
13
- const [sortingProps, setSortingProps] = useState({
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
- const handleSort = useCallback(({ accessor }) => {
38
+ }), sortingProps = _b[0], setSortingProps = _b[1];
39
+ var handleSort = useCallback(function (_a) {
40
+ var accessor = _a.accessor;
18
41
  if (!disableSortBy) {
19
- let newSortingProps = { ...sortingProps };
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 = { ...sortingProps, order: "DESC" };
48
+ newSortingProps = __assign(__assign({}, sortingProps), { order: "DESC" });
26
49
  }
27
50
  else {
28
- newSortingProps = { ...sortingProps, order: "NONE" };
51
+ newSortingProps = __assign(__assign({}, sortingProps), { order: "NONE" });
29
52
  }
30
53
  if (onSort) {
31
- onSort({ ...newSortingProps });
54
+ onSort(__assign({}, newSortingProps));
32
55
  }
33
- setSortingProps({ ...newSortingProps });
56
+ setSortingProps(__assign({}, newSortingProps));
34
57
  }
35
58
  }, [disableSortBy, onSort, sortingProps]);
36
- const renderSortingSymbol = useCallback((accessor) => {
37
- const { accessor: field, order } = sortingProps;
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
- const rows = useMemo(() => data.map(d => ({ ...d })), [data]);
47
- const cols = useMemo(() => {
48
- return columns.map(col => {
49
- const { Body } = col;
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
- const headers = useMemo(() => {
58
- return columns.map(col => {
59
- const { Header, accessor, sortable, headerTip } = col;
60
- const canSortBy = sortable && !disableSortBy;
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
- const footers = useMemo(() => {
72
- return columns.map(col => {
73
- const { Footer } = col;
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;