@symply.io/basic-components 1.3.11-alpha.1 → 1.3.11-alpha.11

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