@erpsquad/common 1.8.35 → 1.8.37
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/dist/_virtual/ArrowBack/index.esm.js +5 -0
- package/dist/_virtual/ArrowBack/index.esm.js.map +1 -0
- package/dist/_virtual/ArrowBack/index.js +2 -0
- package/dist/_virtual/ArrowBack/index.js.map +1 -0
- package/dist/_virtual/ArrowForward/index.esm.js +5 -0
- package/dist/_virtual/ArrowForward/index.esm.js.map +1 -0
- package/dist/_virtual/ArrowForward/index.js +2 -0
- package/dist/_virtual/ArrowForward/index.js.map +1 -0
- package/dist/_virtual/IndeterminateCheckBox/index.esm.js +5 -0
- package/dist/_virtual/IndeterminateCheckBox/index.esm.js.map +1 -0
- package/dist/_virtual/IndeterminateCheckBox/index.js +2 -0
- package/dist/_virtual/IndeterminateCheckBox/index.js.map +1 -0
- package/dist/_virtual/NorthEast/index.esm.js +5 -0
- package/dist/_virtual/NorthEast/index.esm.js.map +1 -0
- package/dist/_virtual/NorthEast/index.js +2 -0
- package/dist/_virtual/NorthEast/index.js.map +1 -0
- package/dist/_virtual/Visibility/index.esm.js +5 -0
- package/dist/_virtual/Visibility/index.esm.js.map +1 -0
- package/dist/_virtual/Visibility/index.js +2 -0
- package/dist/_virtual/Visibility/index.js.map +1 -0
- package/dist/_virtual/extends/index.esm.js +2 -4
- package/dist/_virtual/extends/index.esm.js.map +1 -1
- package/dist/_virtual/extends/index.js +1 -1
- package/dist/_virtual/index/index.esm2.js +4 -2
- package/dist/_virtual/index/index.esm2.js.map +1 -1
- package/dist/_virtual/index/index.esm3.js +2 -4
- package/dist/_virtual/index/index.esm3.js.map +1 -1
- package/dist/_virtual/index/index2.js +1 -1
- package/dist/_virtual/index/index3.js +1 -1
- package/dist/components/action-bar/action-bar/index.esm.js +1 -1
- package/dist/components/action-bar/action-bar/index.esm.js.map +1 -1
- package/dist/components/action-bar/action-bar/index.js +1 -1
- package/dist/components/action-bar/action-bar/index.js.map +1 -1
- package/dist/components/charts/line-chart/area-line-chart/index.esm.js +40 -0
- package/dist/components/charts/line-chart/area-line-chart/index.esm.js.map +1 -0
- package/dist/components/charts/line-chart/area-line-chart/index.js +2 -0
- package/dist/components/charts/line-chart/area-line-chart/index.js.map +1 -0
- package/dist/components/filter/fields/index.esm.js +180 -0
- package/dist/components/filter/fields/index.esm.js.map +1 -0
- package/dist/components/filter/fields/index.js +2 -0
- package/dist/components/filter/fields/index.js.map +1 -0
- package/dist/components/filter/filter/index.esm.js +1 -1
- package/dist/components/filter/filter/index.esm.js.map +1 -1
- package/dist/components/filter/filter/index.js +1 -1
- package/dist/components/filter/filter/index.js.map +1 -1
- package/dist/components/header/redux/actionCreator/index.esm.js +1 -1
- package/dist/components/header/redux/actionCreator/index.esm.js.map +1 -1
- package/dist/components/header/redux/actionCreator/index.js +1 -1
- package/dist/components/header/redux/actionCreator/index.js.map +1 -1
- package/dist/components/icons/action/index.esm.js +6 -7
- package/dist/components/icons/action/index.esm.js.map +1 -1
- package/dist/components/icons/action/index.js +6 -7
- package/dist/components/icons/action/index.js.map +1 -1
- package/dist/components/icons/criteria/index.esm.js +2 -5
- package/dist/components/icons/criteria/index.esm.js.map +1 -1
- package/dist/components/icons/criteria/index.js +2 -4
- package/dist/components/icons/criteria/index.js.map +1 -1
- package/dist/components/icons/share/index.esm.js +2 -5
- package/dist/components/icons/share/index.esm.js.map +1 -1
- package/dist/components/icons/share/index.js +1 -3
- package/dist/components/icons/share/index.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.esm.js +439 -433
- package/dist/components/index.esm.js.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/inventory-reports-title-bar/redux/actionCreator/index.esm.js +1 -1
- package/dist/components/inventory-reports-title-bar/redux/actionCreator/index.esm.js.map +1 -1
- package/dist/components/inventory-reports-title-bar/redux/actionCreator/index.js +1 -1
- package/dist/components/inventory-reports-title-bar/redux/actionCreator/index.js.map +1 -1
- package/dist/components/material-editable-table/components/inline-edit-fields/index.esm.js +312 -0
- package/dist/components/material-editable-table/components/inline-edit-fields/index.esm.js.map +1 -0
- package/dist/components/material-editable-table/components/inline-edit-fields/index.js +4 -0
- package/dist/components/material-editable-table/components/inline-edit-fields/index.js.map +1 -0
- package/dist/components/material-editable-table/material-editable-table/index.esm.js +1164 -0
- package/dist/components/material-editable-table/material-editable-table/index.esm.js.map +1 -0
- package/dist/components/material-editable-table/material-editable-table/index.js +28 -0
- package/dist/components/material-editable-table/material-editable-table/index.js.map +1 -0
- package/dist/components/material-table/aggregation-fns/index/index.esm.js +10 -0
- package/dist/components/material-table/aggregation-fns/index/index.esm.js.map +1 -1
- package/dist/components/material-table/aggregation-fns/index/index.js +1 -1
- package/dist/components/material-table/aggregation-fns/index/index.js.map +1 -1
- package/dist/components/material-table/components/number-aggregation/index.esm.js +133 -0
- package/dist/components/material-table/components/number-aggregation/index.esm.js.map +1 -0
- package/dist/components/material-table/components/number-aggregation/index.js +5 -0
- package/dist/components/material-table/components/number-aggregation/index.js.map +1 -0
- package/dist/components/reports-title-bar/redux/actionCreator/index.esm.js +1 -1
- package/dist/components/reports-title-bar/redux/actionCreator/index.esm.js.map +1 -1
- package/dist/components/reports-title-bar/redux/actionCreator/index.js +1 -1
- package/dist/components/reports-title-bar/redux/actionCreator/index.js.map +1 -1
- package/dist/components/share-modal/redux/actionCreator/index.esm.js +1 -1
- package/dist/components/share-modal/redux/actionCreator/index.esm.js.map +1 -1
- package/dist/components/share-modal/redux/actionCreator/index.js +1 -1
- package/dist/components/share-modal/redux/actionCreator/index.js.map +1 -1
- package/dist/components/upload/upload/index.esm.js +2 -2
- package/dist/components/upload/upload/index.esm.js.map +1 -1
- package/dist/components/upload/upload/index.js +2 -2
- package/dist/components/upload/upload/index.js.map +1 -1
- package/dist/contexts/AuthContext/index.esm.js +1 -1
- package/dist/contexts/AuthContext/index.esm.js.map +1 -1
- package/dist/contexts/AuthContext/index.js +1 -1
- package/dist/contexts/AuthContext/index.js.map +1 -1
- package/dist/contexts/languageContext/index.esm.js +1 -1
- package/dist/contexts/languageContext/index.esm.js.map +1 -1
- package/dist/contexts/languageContext/index.js +1 -1
- package/dist/contexts/languageContext/index.js.map +1 -1
- package/dist/index.esm.js +537 -525
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/node_modules/@asseinfo/react-kanban/dist/index/index.esm.js +1 -1
- package/dist/node_modules/@asseinfo/react-kanban/dist/index/index.js +1 -1
- package/dist/node_modules/@babel/runtime/helpers/extends/index.esm.js +23 -0
- package/dist/node_modules/@babel/runtime/helpers/extends/index.esm.js.map +1 -0
- package/dist/node_modules/@babel/runtime/helpers/extends/index.js +2 -0
- package/dist/node_modules/@babel/runtime/helpers/extends/index.js.map +1 -0
- package/dist/node_modules/@glideapps/glide-data-grid/dist/js/index/index.esm.js +32 -0
- package/dist/node_modules/@glideapps/glide-data-grid/dist/js/index/index.esm.js.map +1 -1
- package/dist/node_modules/@glideapps/glide-data-grid/dist/js/index/index.js +36 -36
- package/dist/node_modules/@glideapps/glide-data-grid/dist/js/index/index.js.map +1 -1
- package/dist/node_modules/@mui/icons-material/ArrowBack/index.esm.js +18 -0
- package/dist/node_modules/@mui/icons-material/ArrowBack/index.esm.js.map +1 -0
- package/dist/node_modules/@mui/icons-material/ArrowBack/index.js +2 -0
- package/dist/node_modules/@mui/icons-material/ArrowBack/index.js.map +1 -0
- package/dist/node_modules/@mui/icons-material/ArrowForward/index.esm.js +18 -0
- package/dist/node_modules/@mui/icons-material/ArrowForward/index.esm.js.map +1 -0
- package/dist/node_modules/@mui/icons-material/ArrowForward/index.js +2 -0
- package/dist/node_modules/@mui/icons-material/ArrowForward/index.js.map +1 -0
- package/dist/node_modules/@mui/icons-material/IndeterminateCheckBox/index.esm.js +18 -0
- package/dist/node_modules/@mui/icons-material/IndeterminateCheckBox/index.esm.js.map +1 -0
- package/dist/node_modules/@mui/icons-material/IndeterminateCheckBox/index.js +2 -0
- package/dist/node_modules/@mui/icons-material/IndeterminateCheckBox/index.js.map +1 -0
- package/dist/node_modules/@mui/icons-material/NorthEast/index.esm.js +18 -0
- package/dist/node_modules/@mui/icons-material/NorthEast/index.esm.js.map +1 -0
- package/dist/node_modules/@mui/icons-material/NorthEast/index.js +2 -0
- package/dist/node_modules/@mui/icons-material/NorthEast/index.js.map +1 -0
- package/dist/node_modules/@mui/icons-material/Visibility/index.esm.js +18 -0
- package/dist/node_modules/@mui/icons-material/Visibility/index.esm.js.map +1 -0
- package/dist/node_modules/@mui/icons-material/Visibility/index.js +2 -0
- package/dist/node_modules/@mui/icons-material/Visibility/index.js.map +1 -0
- package/dist/node_modules/@mui/icons-material/utils/createSvgIcon/index.esm.js +1 -1
- package/dist/node_modules/@mui/icons-material/utils/createSvgIcon/index.js +1 -1
- package/dist/node_modules/@mui/system/createStyled/index.esm.js +4 -4
- package/dist/node_modules/@mui/system/createStyled/index.esm.js.map +1 -1
- package/dist/node_modules/@mui/system/createStyled/index.js +1 -1
- package/dist/node_modules/@mui/system/createStyled/index.js.map +1 -1
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/components/material-editable-table/aggregation-fns/index.d.ts +13 -0
- package/dist/src/components/material-editable-table/components/default-aggregation.d.ts +9 -0
- package/dist/src/components/material-editable-table/components/header-cell.d.ts +5 -0
- package/dist/src/components/material-editable-table/components/inline-edit-fields.d.ts +17 -0
- package/dist/src/components/material-editable-table/components/number-aggregation.d.ts +9 -0
- package/dist/src/components/material-editable-table/material-editable-table.d.ts +40 -0
- package/dist/src/utils/index.d.ts +2 -1
- package/dist/src/views/index.d.ts +1 -0
- package/dist/style.css +3 -1
- package/dist/utils/api/index.esm.js +4 -4
- package/dist/utils/api/index.esm.js.map +1 -1
- package/dist/utils/api/index.js +1 -1
- package/dist/utils/api/index.js.map +1 -1
- package/dist/utils/common/index.esm.js +6 -6
- package/dist/utils/common/index.esm.js.map +1 -1
- package/dist/utils/common/index.js +1 -1
- package/dist/utils/common/index.js.map +1 -1
- package/dist/utils/fileSize/index.esm.js +22 -0
- package/dist/utils/fileSize/index.esm.js.map +1 -0
- package/dist/utils/fileSize/index.js +2 -0
- package/dist/utils/fileSize/index.js.map +1 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.esm.js +54 -50
- package/dist/utils/index.esm.js.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/views/beforeAuth/components/activity-tag-data/activity-tag-data/index.esm.js +48 -0
- package/dist/views/beforeAuth/components/activity-tag-data/activity-tag-data/index.esm.js.map +1 -0
- package/dist/views/beforeAuth/components/activity-tag-data/activity-tag-data/index.js +2 -0
- package/dist/views/beforeAuth/components/activity-tag-data/activity-tag-data/index.js.map +1 -0
- package/dist/views/beforeAuth/components/calendar-data/calendar-data/index.esm.js +50 -0
- package/dist/views/beforeAuth/components/calendar-data/calendar-data/index.esm.js.map +1 -0
- package/dist/views/beforeAuth/components/calendar-data/calendar-data/index.js +2 -0
- package/dist/views/beforeAuth/components/calendar-data/calendar-data/index.js.map +1 -0
- package/dist/views/beforeAuth/components/gantt-data/gantt-data/index.esm.js +57 -0
- package/dist/views/beforeAuth/components/gantt-data/gantt-data/index.esm.js.map +1 -0
- package/dist/views/beforeAuth/components/gantt-data/gantt-data/index.js +2 -0
- package/dist/views/beforeAuth/components/gantt-data/gantt-data/index.js.map +1 -0
- package/dist/views/beforeAuth/components/grid-data/grid-data/index.esm.js +41 -0
- package/dist/views/beforeAuth/components/grid-data/grid-data/index.esm.js.map +1 -0
- package/dist/views/beforeAuth/components/grid-data/grid-data/index.js +2 -0
- package/dist/views/beforeAuth/components/grid-data/grid-data/index.js.map +1 -0
- package/dist/views/beforeAuth/components/index/index.esm.js +1144 -0
- package/dist/views/beforeAuth/components/index/index.esm.js.map +1 -0
- package/dist/views/beforeAuth/components/index/index.js +206 -0
- package/dist/views/beforeAuth/components/index/index.js.map +1 -0
- package/dist/views/beforeAuth/components/kanbann-content/kanbann-raw/index.esm.js +72 -0
- package/dist/views/beforeAuth/components/kanbann-content/kanbann-raw/index.esm.js.map +1 -0
- package/dist/views/beforeAuth/components/kanbann-content/kanbann-raw/index.js +2 -0
- package/dist/views/beforeAuth/components/kanbann-content/kanbann-raw/index.js.map +1 -0
- package/dist/views/beforeAuth/components/list-content/column-raw/index.esm.js +54 -0
- package/dist/views/beforeAuth/components/list-content/column-raw/index.esm.js.map +1 -0
- package/dist/views/beforeAuth/components/list-content/column-raw/index.js +2 -0
- package/dist/views/beforeAuth/components/list-content/column-raw/index.js.map +1 -0
- package/dist/views/beforeAuth/components/list-content/list-data/index.esm.js +61 -0
- package/dist/views/beforeAuth/components/list-content/list-data/index.esm.js.map +1 -0
- package/dist/views/beforeAuth/components/list-content/list-data/index.js +2 -0
- package/dist/views/beforeAuth/components/list-content/list-data/index.js.map +1 -0
- package/dist/views/beforeAuth/components/multiline-data/multiline-data/index.esm.js +21 -0
- package/dist/views/beforeAuth/components/multiline-data/multiline-data/index.esm.js.map +1 -0
- package/dist/views/beforeAuth/components/multiline-data/multiline-data/index.js +2 -0
- package/dist/views/beforeAuth/components/multiline-data/multiline-data/index.js.map +1 -0
- package/dist/views/beforeAuth/components/tabs-data/tabs-data/index.esm.js +21 -0
- package/dist/views/beforeAuth/components/tabs-data/tabs-data/index.esm.js.map +1 -0
- package/dist/views/beforeAuth/components/tabs-data/tabs-data/index.js +2 -0
- package/dist/views/beforeAuth/components/tabs-data/tabs-data/index.js.map +1 -0
- package/dist/views/beforeAuth/components/user-dropdown-data/user-dropdown-data/index.esm.js +306 -0
- package/dist/views/beforeAuth/components/user-dropdown-data/user-dropdown-data/index.esm.js.map +1 -0
- package/dist/views/beforeAuth/components/user-dropdown-data/user-dropdown-data/index.js +2 -0
- package/dist/views/beforeAuth/components/user-dropdown-data/user-dropdown-data/index.js.map +1 -0
- package/dist/views/form-builder/redux/actionCreator/index.esm.js +1 -1
- package/dist/views/form-builder/redux/actionCreator/index.esm.js.map +1 -1
- package/dist/views/form-builder/redux/actionCreator/index.js +1 -1
- package/dist/views/form-builder/redux/actionCreator/index.js.map +1 -1
- package/dist/views/index.esm.js +2 -0
- package/dist/views/index.esm.js.map +1 -1
- package/dist/views/index.js +1 -1
- package/dist/views/template-editor/components/EditorSidebar/index.esm.js +1 -1
- package/dist/views/template-editor/components/EditorSidebar/index.esm.js.map +1 -1
- package/dist/views/template-editor/components/EditorSidebar/index.js +1 -1
- package/dist/views/template-editor/components/EditorSidebar/index.js.map +1 -1
- package/dist/views/template-editor/templates/index.esm.js +1 -1
- package/dist/views/template-editor/templates/index.esm.js.map +1 -1
- package/dist/views/template-editor/templates/index.js +1 -1
- package/dist/views/template-editor/templates/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,1164 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React__default, { useState, useEffect, useCallback, cloneElement } from "react";
|
|
3
|
+
import { useMaterialReactTable, MaterialReactTable } from "../../../node_modules/material-react-table/dist/index.esm/index.esm.js";
|
|
4
|
+
import default_1$1 from "../../../node_modules/@mui/icons-material/ChevronRight/index.esm.js";
|
|
5
|
+
import default_1 from "../../../node_modules/@mui/icons-material/ChevronLeft/index.esm.js";
|
|
6
|
+
import Menu from "../../menu/menu/index.esm.js";
|
|
7
|
+
import { Typography } from "../../typography/typography/index.esm.js";
|
|
8
|
+
import SearchBar from "../../search-bar/search-bar/index.esm.js";
|
|
9
|
+
import { images } from "../../../images/index.esm.js";
|
|
10
|
+
/* empty css */
|
|
11
|
+
import InlineEditFields from "../components/inline-edit-fields/index.esm.js";
|
|
12
|
+
import Tooltip from "../../tooltip/Tooltip/index.esm.js";
|
|
13
|
+
import Button from "../../button/button/index.esm.js";
|
|
14
|
+
import default_1$2 from "../../../node_modules/@mui/icons-material/Add/index.esm.js";
|
|
15
|
+
import dayjs from "dayjs";
|
|
16
|
+
import * as Yup from "yup";
|
|
17
|
+
import ConfirmPopUp from "../../confirm-modal/confirm-modal/index.esm.js";
|
|
18
|
+
import { useTranslation } from "react-i18next";
|
|
19
|
+
import { enqueueSnackbar } from "../../../node_modules/notistack/notistack.esm/index.esm.js";
|
|
20
|
+
import { usePages } from "../../../hooks/use-pages/index.esm.js";
|
|
21
|
+
import { useNavigate } from "react-router-dom";
|
|
22
|
+
import { PathnameDocument } from "../../../constants/pathnames/pathname.document/index.esm.js";
|
|
23
|
+
import { PathnameAccounting } from "../../../constants/pathnames/pathname.accounting/index.esm.js";
|
|
24
|
+
import { PathnameInventory } from "../../../constants/pathnames/pathname.inventory/index.esm.js";
|
|
25
|
+
import { PathnameManufacturing } from "../../../constants/pathnames/pathname.manufacturing/index.esm.js";
|
|
26
|
+
import { PathnamePurchase } from "../../../constants/pathnames/pathname.procurement/index.esm.js";
|
|
27
|
+
import { PathnameCrm } from "../../../constants/pathnames/pathname.crm/index.esm.js";
|
|
28
|
+
import { PathnameUsers } from "../../../constants/pathnames/pathname.user/index.esm.js";
|
|
29
|
+
import { PathnameRental } from "../../../constants/pathnames/pathname.rental/index.esm.js";
|
|
30
|
+
import useDeepMemo from "../../../hooks/use-deep-memo/index.esm.js";
|
|
31
|
+
import Box from "../../../node_modules/@mui/material/Box/Box/index.esm.js";
|
|
32
|
+
import IconButton from "../../../node_modules/@mui/material/IconButton/IconButton/index.esm.js";
|
|
33
|
+
import styled from "../../../node_modules/@mui/material/styles/styled/index.esm.js";
|
|
34
|
+
import MenuItem from "../../../node_modules/@mui/material/MenuItem/MenuItem/index.esm.js";
|
|
35
|
+
import ListItemIcon from "../../../node_modules/@mui/material/ListItemIcon/ListItemIcon/index.esm.js";
|
|
36
|
+
import ListItemText from "../../../node_modules/@mui/material/ListItemText/ListItemText/index.esm.js";
|
|
37
|
+
import Divider from "../../../node_modules/@mui/material/Divider/Divider/index.esm.js";
|
|
38
|
+
import { Close } from "../../icons/close/index.esm.js";
|
|
39
|
+
import { ArrowUpDown } from "../../icons/arrow-up-down/index.esm.js";
|
|
40
|
+
import { RecgtangleIcon } from "../../icons/rectangle/index.esm.js";
|
|
41
|
+
import { CheckBoxIcon } from "../../icons/check-box/index.esm.js";
|
|
42
|
+
import { Trash } from "../../icons/trash/index.esm.js";
|
|
43
|
+
const TableWrapper = styled(Box)(({ theme: { palette } }) => {
|
|
44
|
+
var _a, _b, _c, _d;
|
|
45
|
+
return {
|
|
46
|
+
".MuiTableCell-root": {
|
|
47
|
+
border: "1px solid #efefef",
|
|
48
|
+
borderBottom: 0,
|
|
49
|
+
borderLeft: 0,
|
|
50
|
+
padding: "0.19rem 0.5rem",
|
|
51
|
+
lineHeight: "19px",
|
|
52
|
+
fontSize: "14px",
|
|
53
|
+
minHeight: 40
|
|
54
|
+
// '&:first-child': {
|
|
55
|
+
// borderLeft: '1px solid #efefef'
|
|
56
|
+
// },
|
|
57
|
+
// '&:last-child': {
|
|
58
|
+
// borderBottom: '1px solid #efefef'
|
|
59
|
+
// }
|
|
60
|
+
},
|
|
61
|
+
".MuiTableCell-head": {
|
|
62
|
+
backgroundColor: (_a = palette.theme) == null ? void 0 : _a.secondary[100]
|
|
63
|
+
},
|
|
64
|
+
".MuiTableContainer-root": {
|
|
65
|
+
maxHeight: "clamp(350px, 100vh - 200px, 9999px) !important"
|
|
66
|
+
},
|
|
67
|
+
".MuiPaper-root": {
|
|
68
|
+
boxShadow: "none"
|
|
69
|
+
},
|
|
70
|
+
".MuiPaginationItem-root": {
|
|
71
|
+
"&.Mui-selected": {
|
|
72
|
+
backgroundColor: (_b = palette == null ? void 0 : palette.theme) == null ? void 0 : _b.primary[700],
|
|
73
|
+
color: "white"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
".MuiTableRow-root": {
|
|
77
|
+
"&.Mui-selected": {
|
|
78
|
+
backgroundColor: `${(_c = palette == null ? void 0 : palette.theme) == null ? void 0 : _c.primary[100]} !important`,
|
|
79
|
+
color: "white"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
".MuiCheckbox-indeterminate": {
|
|
83
|
+
color: `${(_d = palette == null ? void 0 : palette.theme) == null ? void 0 : _d.primary[700]} !important`,
|
|
84
|
+
"& svg": {
|
|
85
|
+
height: `20px !important`,
|
|
86
|
+
width: `20px !important`
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
const MaterialEditableTable = React__default.memo(({
|
|
92
|
+
enablePagination = false,
|
|
93
|
+
rows,
|
|
94
|
+
columns,
|
|
95
|
+
totalPages,
|
|
96
|
+
paginationModel,
|
|
97
|
+
columnOrder,
|
|
98
|
+
updateData,
|
|
99
|
+
handleColumnOrdering,
|
|
100
|
+
enableEditing,
|
|
101
|
+
enableColumnDragging,
|
|
102
|
+
states,
|
|
103
|
+
rowActionMenu,
|
|
104
|
+
destructiveActionMenu,
|
|
105
|
+
disableDefaultActionColumn,
|
|
106
|
+
enableRowSelection,
|
|
107
|
+
defaultActionColumnItems = [],
|
|
108
|
+
enableBottomToolbar,
|
|
109
|
+
SetSelectedRowId,
|
|
110
|
+
isResetRow,
|
|
111
|
+
onCreateRow,
|
|
112
|
+
onEditRow,
|
|
113
|
+
onDeleteRow,
|
|
114
|
+
editDisplayMode,
|
|
115
|
+
enableRowCreate,
|
|
116
|
+
onChangeRowField,
|
|
117
|
+
onSelectRow,
|
|
118
|
+
enableColumnResizing = true,
|
|
119
|
+
selectedRowIds = [],
|
|
120
|
+
onColumnVisibility,
|
|
121
|
+
onSortingChange,
|
|
122
|
+
getSelectedData,
|
|
123
|
+
disabledDefaultActionColumnIcon = false,
|
|
124
|
+
enableAddCustomField = true,
|
|
125
|
+
enableRowDragging = false,
|
|
126
|
+
handleColumnResizing = () => {
|
|
127
|
+
},
|
|
128
|
+
columnSizes = {},
|
|
129
|
+
// eslint-disable-next-line unused-imports/no-unused-vars, @typescript-eslint/no-unused-vars
|
|
130
|
+
// getRowId,
|
|
131
|
+
// onDelete,
|
|
132
|
+
// onUpdate,
|
|
133
|
+
...rest
|
|
134
|
+
}) => {
|
|
135
|
+
const { t } = useTranslation();
|
|
136
|
+
const { formData = null, updatePageInfo, activePage: aPage } = usePages();
|
|
137
|
+
const activePage = useDeepMemo(aPage);
|
|
138
|
+
const { pageNo } = paginationModel;
|
|
139
|
+
const [row, setRow] = useState({});
|
|
140
|
+
const [tableColumns, setTableColumns] = useState(columns);
|
|
141
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
142
|
+
const [popUpShow, setPopupShow] = useState(false);
|
|
143
|
+
const [rowAnchorEl, setRowAnchorEl] = useState(null);
|
|
144
|
+
const visibleColumns = tableColumns.filter((column) => column.visible);
|
|
145
|
+
const hiddenColumns = tableColumns.filter((column) => !column.visible);
|
|
146
|
+
const [filteredOptions, setFilteredOptions] = useState(hiddenColumns);
|
|
147
|
+
const [selectedRow, setSelectedRow] = useState(null);
|
|
148
|
+
const [validationErrors, setValidationErrors] = useState({});
|
|
149
|
+
const [validationSchema, setValidationSchema] = useState([]);
|
|
150
|
+
const [isCreatingRow, setIsCreatingRow] = useState(false);
|
|
151
|
+
const [isEditingRow, setIsEditingRow] = useState(false);
|
|
152
|
+
const [isDeletingRow, setIsDeletingRow] = useState(false);
|
|
153
|
+
const [rowToDelete, setRowToDelete] = useState(null);
|
|
154
|
+
const [rowSelection, setRowSelection] = useState({});
|
|
155
|
+
const [isChecked, setIsChecked] = useState(false);
|
|
156
|
+
const [sorting, setSorting] = useState([]);
|
|
157
|
+
const [disableNextEdit, setDisableNextEdit] = useState(false);
|
|
158
|
+
const [columnSizing, setColumnSizing] = useState(activePage.column_sizes);
|
|
159
|
+
const [columnSizingInfo, setColumnSizingInfo] = useState({
|
|
160
|
+
columnSizingStart: [],
|
|
161
|
+
deltaOffset: null,
|
|
162
|
+
deltaPercentage: null,
|
|
163
|
+
isResizingColumn: false,
|
|
164
|
+
startOffset: null,
|
|
165
|
+
startSize: null
|
|
166
|
+
});
|
|
167
|
+
useState(0);
|
|
168
|
+
const navigate = useNavigate();
|
|
169
|
+
const currentModule = location.pathname.split("/")[2];
|
|
170
|
+
let redirectionPath = "";
|
|
171
|
+
switch (currentModule) {
|
|
172
|
+
case "accounting":
|
|
173
|
+
redirectionPath = PathnameAccounting.CUSTOM_FORM;
|
|
174
|
+
break;
|
|
175
|
+
case "inventory":
|
|
176
|
+
redirectionPath = PathnameInventory.CUSTOM_FORM;
|
|
177
|
+
break;
|
|
178
|
+
case "manufacturing":
|
|
179
|
+
redirectionPath = PathnameManufacturing.CUSTOM_FORM;
|
|
180
|
+
break;
|
|
181
|
+
case "procurement":
|
|
182
|
+
redirectionPath = PathnamePurchase.CUSTOM_FORM;
|
|
183
|
+
break;
|
|
184
|
+
case "crm":
|
|
185
|
+
redirectionPath = PathnameCrm.CUSTOM_FORM;
|
|
186
|
+
break;
|
|
187
|
+
case "user":
|
|
188
|
+
redirectionPath = PathnameUsers.CUSTOM_FORM;
|
|
189
|
+
break;
|
|
190
|
+
case "rental":
|
|
191
|
+
redirectionPath = PathnameRental.CUSTOM_FORM;
|
|
192
|
+
break;
|
|
193
|
+
case "drive":
|
|
194
|
+
redirectionPath = PathnameDocument.ADD_CUSTOM_FIELDS;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
const path = `/dashboard/${currentModule}${redirectionPath}`;
|
|
198
|
+
const getValidationType = (column) => {
|
|
199
|
+
var _a;
|
|
200
|
+
switch (column.editVariant) {
|
|
201
|
+
case "select":
|
|
202
|
+
return ((_a = column == null ? void 0 : column.editProperties) == null ? void 0 : _a.is_multiple) ? Yup.array() : Yup.string();
|
|
203
|
+
case "number":
|
|
204
|
+
return Yup.number().nullable().transform((value, originalValue) => originalValue === "" ? null : value);
|
|
205
|
+
case "url":
|
|
206
|
+
return Yup.string().matches(
|
|
207
|
+
/^(https?:\/\/)?((([a-zA-Z0-9_-]+\.)+[a-zA-Z]{2,})|localhost)(:\d{2,5})?(\/[a-zA-Z0-9#_-]+\/?)*(\?[a-zA-Z0-9&=_-]+)?(#\S+)?$/,
|
|
208
|
+
{ excludeEmptyString: true, message: "Please enter valid URL." }
|
|
209
|
+
);
|
|
210
|
+
default:
|
|
211
|
+
return Yup.string();
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const validationReducer = (validations, validation, column) => {
|
|
215
|
+
var _a;
|
|
216
|
+
let vld = validations;
|
|
217
|
+
switch (validation.type) {
|
|
218
|
+
case "required":
|
|
219
|
+
vld = validation.value ? validations.required(validation.msg_en).typeError(validation.msg_en) : ((_a = column == null ? void 0 : column.editProperties) == null ? void 0 : _a.is_multiple) ? validations.min(1, validation.msg_en) : validations;
|
|
220
|
+
break;
|
|
221
|
+
case "min":
|
|
222
|
+
vld = validations.min(validation.value, validation.msg_en);
|
|
223
|
+
break;
|
|
224
|
+
case "email":
|
|
225
|
+
vld = validations.email(validation.value, validation.msg_en);
|
|
226
|
+
break;
|
|
227
|
+
case "max":
|
|
228
|
+
vld = validations.max(validation.value, validation.msg_en);
|
|
229
|
+
break;
|
|
230
|
+
case "positive":
|
|
231
|
+
vld = validation.value === true ? validations.test("is-positive-number", "Value must be a positive number", (value) => !value || value >= 0) : validations;
|
|
232
|
+
break;
|
|
233
|
+
case "when":
|
|
234
|
+
return validations.when(validation.relation, {
|
|
235
|
+
is: (val) => val === validation.values,
|
|
236
|
+
then: () => {
|
|
237
|
+
var _a2;
|
|
238
|
+
return ((_a2 = validation == null ? void 0 : validation.thenValidations) == null ? void 0 : _a2.reduce(
|
|
239
|
+
(validations2, validation2) => validationReducer(validations2, validation2, column),
|
|
240
|
+
validations
|
|
241
|
+
)) || validations;
|
|
242
|
+
},
|
|
243
|
+
otherwise: () => {
|
|
244
|
+
var _a2;
|
|
245
|
+
return ((_a2 = validation == null ? void 0 : validation.otherWiseValidations) == null ? void 0 : _a2.reduce(
|
|
246
|
+
(validations2, validation2) => validationReducer(validations2, validation2, column),
|
|
247
|
+
validations
|
|
248
|
+
)) || validations;
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
default:
|
|
252
|
+
vld = validations;
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
if (validation.type == "required" && validation.value && (!(column == null ? void 0 : column.editVariant) || (column == null ? void 0 : column.editVariant) == "text")) {
|
|
256
|
+
vld = validations.test("no-blank-spaces", "Blank space is not allowed", (value) => {
|
|
257
|
+
var _a2;
|
|
258
|
+
return value && ((_a2 = value.trim()) == null ? void 0 : _a2.length) > 0;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
return vld;
|
|
262
|
+
};
|
|
263
|
+
const generateValidationSchema = (columns2) => {
|
|
264
|
+
const schema = {};
|
|
265
|
+
columns2.forEach((clm) => {
|
|
266
|
+
var _a, _b, _c;
|
|
267
|
+
if ((_b = (_a = clm == null ? void 0 : clm.editProperties) == null ? void 0 : _a.validations) == null ? void 0 : _b.length) {
|
|
268
|
+
const fieldValidations = (_c = clm == null ? void 0 : clm.editProperties) == null ? void 0 : _c.validations.reduce(
|
|
269
|
+
(validations, validation) => validationReducer(validations, validation, clm),
|
|
270
|
+
getValidationType(clm)
|
|
271
|
+
);
|
|
272
|
+
schema[clm.accessorKey] = fieldValidations;
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
return schema;
|
|
276
|
+
};
|
|
277
|
+
useEffect(() => {
|
|
278
|
+
setTableColumns(columns);
|
|
279
|
+
const schema = generateValidationSchema(columns);
|
|
280
|
+
setValidationSchema(Yup.object().shape(schema));
|
|
281
|
+
}, [columns]);
|
|
282
|
+
useEffect(() => {
|
|
283
|
+
if (!(columnSizingInfo == null ? void 0 : columnSizingInfo.isResizingColumn)) {
|
|
284
|
+
updatePageInfo({ column_sizes: { ...activePage.column_sizes, ...columnSizing } });
|
|
285
|
+
handleColumnResizing == null ? void 0 : handleColumnResizing(columnSizing);
|
|
286
|
+
}
|
|
287
|
+
}, [columnSizingInfo == null ? void 0 : columnSizingInfo.isResizingColumn, columnSizing]);
|
|
288
|
+
const handleHeaderClick = (event) => {
|
|
289
|
+
setAnchorEl(event.currentTarget);
|
|
290
|
+
};
|
|
291
|
+
const handleHeaderClose = () => {
|
|
292
|
+
setAnchorEl(null);
|
|
293
|
+
};
|
|
294
|
+
const handleVisibleColumn = (column) => {
|
|
295
|
+
const updatedColumns = tableColumns.map((col) => ({
|
|
296
|
+
...col,
|
|
297
|
+
visible: col.accessorKey === column.accessorKey ? false : col.visible
|
|
298
|
+
}));
|
|
299
|
+
setTableColumns(updatedColumns);
|
|
300
|
+
onColumnVisibility == null ? void 0 : onColumnVisibility(JSON.parse(JSON.stringify(updatedColumns)));
|
|
301
|
+
setFilteredOptions([...filteredOptions, column]);
|
|
302
|
+
setAnchorEl(null);
|
|
303
|
+
};
|
|
304
|
+
const handleAddButtonClick = () => {
|
|
305
|
+
setPopupShow(true);
|
|
306
|
+
};
|
|
307
|
+
const handleBackButtonClick = () => {
|
|
308
|
+
setPopupShow(false);
|
|
309
|
+
};
|
|
310
|
+
const handleAddColumn = (column) => {
|
|
311
|
+
const updatedColumns = tableColumns.map((col) => ({
|
|
312
|
+
...col,
|
|
313
|
+
visible: col.accessorKey === column.accessorKey ? true : col.visible
|
|
314
|
+
}));
|
|
315
|
+
onColumnVisibility == null ? void 0 : onColumnVisibility(JSON.parse(JSON.stringify(updatedColumns)));
|
|
316
|
+
setTableColumns(updatedColumns);
|
|
317
|
+
const updatedFilteredOptions = filteredOptions.filter(
|
|
318
|
+
(option) => option.accessorKey !== column.accessorKey
|
|
319
|
+
);
|
|
320
|
+
setFilteredOptions(updatedFilteredOptions);
|
|
321
|
+
setAnchorEl(null);
|
|
322
|
+
setPopupShow(false);
|
|
323
|
+
};
|
|
324
|
+
const handleSearchEvent = (searchQuery) => {
|
|
325
|
+
const filteredColumns = hiddenColumns.filter(
|
|
326
|
+
(option) => option.header.toLowerCase().includes(searchQuery.toLowerCase())
|
|
327
|
+
);
|
|
328
|
+
setFilteredOptions(filteredColumns);
|
|
329
|
+
};
|
|
330
|
+
const handleCustomAddColumn = () => {
|
|
331
|
+
navigate(path, { state: formData });
|
|
332
|
+
setAnchorEl(null);
|
|
333
|
+
setPopupShow(false);
|
|
334
|
+
};
|
|
335
|
+
const handleActionsClick = (event, data) => {
|
|
336
|
+
setRow(data);
|
|
337
|
+
setRowAnchorEl(event.currentTarget);
|
|
338
|
+
};
|
|
339
|
+
const handleActionsClose = () => {
|
|
340
|
+
setRowAnchorEl(null);
|
|
341
|
+
};
|
|
342
|
+
const formtValues = useCallback((values, cells) => {
|
|
343
|
+
const v = {};
|
|
344
|
+
Object.keys(values).forEach((vl) => {
|
|
345
|
+
const val = values[vl];
|
|
346
|
+
const cell = cells.find((c) => c.accessorKey == vl);
|
|
347
|
+
if (val) {
|
|
348
|
+
if (val instanceof File) {
|
|
349
|
+
v[vl] = val.name;
|
|
350
|
+
} else if (cell && (cell == null ? void 0 : cell.editVariant) == "date") {
|
|
351
|
+
v[vl] = dayjs(val).format((cell == null ? void 0 : cell.dateFormat) || "DD-MM-YYYY");
|
|
352
|
+
} else if (cell && (cell == null ? void 0 : cell.editVariant) == "select" && typeof val === "object" && val !== null) {
|
|
353
|
+
v[vl] = val.name || val.label || val.display_name || val.title || val.value || val.id || val;
|
|
354
|
+
} else if (cell && (cell == null ? void 0 : cell.editVariant) == "select" && typeof val === "string") {
|
|
355
|
+
v[vl] = val;
|
|
356
|
+
} else {
|
|
357
|
+
v[vl] = val;
|
|
358
|
+
}
|
|
359
|
+
} else {
|
|
360
|
+
v[vl] = val;
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
return v;
|
|
364
|
+
}, []);
|
|
365
|
+
const handleRowDelete = async () => {
|
|
366
|
+
setIsDeletingRow(true);
|
|
367
|
+
if (rowToDelete) {
|
|
368
|
+
await (onDeleteRow == null ? void 0 : onDeleteRow(rowToDelete));
|
|
369
|
+
setRowToDelete(null);
|
|
370
|
+
}
|
|
371
|
+
setIsDeletingRow(false);
|
|
372
|
+
};
|
|
373
|
+
const checkRequired = useCallback((editProperties) => {
|
|
374
|
+
var _a;
|
|
375
|
+
return (_a = editProperties == null ? void 0 : editProperties.validations) == null ? void 0 : _a.some((validation) => validation.type === "required");
|
|
376
|
+
}, []);
|
|
377
|
+
useEffect(() => {
|
|
378
|
+
const selectedRows = {};
|
|
379
|
+
if (!isChecked && selectedRowIds.length) {
|
|
380
|
+
rows.forEach((row2) => {
|
|
381
|
+
if (selectedRowIds.includes(row2.id)) {
|
|
382
|
+
selectedRows[row2.id] = true;
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
setRowSelection(selectedRows);
|
|
386
|
+
setIsChecked(true);
|
|
387
|
+
}
|
|
388
|
+
}, [rows, selectedRowIds]);
|
|
389
|
+
useEffect(() => {
|
|
390
|
+
if (onSortingChange instanceof Function) {
|
|
391
|
+
const sortingArray = Array.isArray(sorting) ? sorting : [];
|
|
392
|
+
onSortingChange(sortingArray[0] || null);
|
|
393
|
+
}
|
|
394
|
+
}, [sorting]);
|
|
395
|
+
const resetRowSelection = () => {
|
|
396
|
+
setRowSelection({});
|
|
397
|
+
setDisableNextEdit(false);
|
|
398
|
+
};
|
|
399
|
+
const getTextWidth = (text) => {
|
|
400
|
+
const canvas = document.createElement("canvas");
|
|
401
|
+
const ctx = canvas.getContext("2d");
|
|
402
|
+
if (!ctx) return 50;
|
|
403
|
+
return ctx.measureText(text).width + 5;
|
|
404
|
+
};
|
|
405
|
+
const handleSaveRow = useCallback(async (row2, values, tableInstance) => {
|
|
406
|
+
console.log("handleSaveRow", onEditRow);
|
|
407
|
+
try {
|
|
408
|
+
await validationSchema.validate(values, {
|
|
409
|
+
abortEarly: false
|
|
410
|
+
});
|
|
411
|
+
setValidationErrors({});
|
|
412
|
+
setIsEditingRow(true);
|
|
413
|
+
setDisableNextEdit(false);
|
|
414
|
+
const cells = row2.getAllCells().map((c) => c.column.columnDef);
|
|
415
|
+
row2._valuesCache = formtValues(values, cells);
|
|
416
|
+
const data = { row: row2, values, table: tableInstance };
|
|
417
|
+
if (onEditRow) {
|
|
418
|
+
await onEditRow(data, "edit");
|
|
419
|
+
}
|
|
420
|
+
setIsEditingRow(false);
|
|
421
|
+
tableInstance.setEditingRow(null);
|
|
422
|
+
} catch (err) {
|
|
423
|
+
console.log("handleSaveRow error", err);
|
|
424
|
+
setIsEditingRow(false);
|
|
425
|
+
if (err instanceof Yup.ValidationError) {
|
|
426
|
+
const errors = {};
|
|
427
|
+
err.inner.forEach((error) => {
|
|
428
|
+
if (error.path) {
|
|
429
|
+
errors[error.path] = error.message;
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
setValidationErrors(errors);
|
|
433
|
+
} else if (err instanceof Error) {
|
|
434
|
+
enqueueSnackbar(err.message, { variant: "error" });
|
|
435
|
+
} else {
|
|
436
|
+
enqueueSnackbar("Something went wrong", { variant: "error" });
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}, [validationSchema, onEditRow, formtValues]);
|
|
440
|
+
const table = useMaterialReactTable({
|
|
441
|
+
// options:{
|
|
442
|
+
// tableLayout: "auto", // 👈 important
|
|
443
|
+
// padding: "dense",
|
|
444
|
+
// },
|
|
445
|
+
// columns: visibleColumns,
|
|
446
|
+
defaultColumn: {
|
|
447
|
+
minSize: 0,
|
|
448
|
+
// 👈 remove default min width
|
|
449
|
+
size: void 0
|
|
450
|
+
// 👈 optional, default size
|
|
451
|
+
},
|
|
452
|
+
columns: [
|
|
453
|
+
...visibleColumns.map((c) => {
|
|
454
|
+
getTextWidth(c.header || "");
|
|
455
|
+
Math.max(
|
|
456
|
+
...rows.map((row2) => getTextWidth(String(row2[c.accessorKey] ?? "")))
|
|
457
|
+
);
|
|
458
|
+
return {
|
|
459
|
+
...c,
|
|
460
|
+
...editDisplayMode === "row" ? {
|
|
461
|
+
Edit: ({ cell, row: row2, table: table2, column }) => {
|
|
462
|
+
return /* @__PURE__ */ jsx(
|
|
463
|
+
InlineEditFields,
|
|
464
|
+
{
|
|
465
|
+
cell,
|
|
466
|
+
column,
|
|
467
|
+
col: c,
|
|
468
|
+
row: row2,
|
|
469
|
+
table: table2,
|
|
470
|
+
callback: (s) => console.log("Save", s),
|
|
471
|
+
errors: validationErrors,
|
|
472
|
+
validationSchema,
|
|
473
|
+
setValidationErrors,
|
|
474
|
+
onChangeRowField,
|
|
475
|
+
getSelectedData: (name, row3) => getSelectedData == null ? void 0 : getSelectedData(name, row3)
|
|
476
|
+
}
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
} : {},
|
|
480
|
+
Header: /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", children: [
|
|
481
|
+
c.header,
|
|
482
|
+
(c == null ? void 0 : c.required) || checkRequired(c == null ? void 0 : c.editProperties) && /* @__PURE__ */ jsx(Typography, { type: "s5", color: "theme.error.600", children: "*" })
|
|
483
|
+
] }),
|
|
484
|
+
enableColumnDragging: c.id !== "actions",
|
|
485
|
+
// cellStyle: { ...c.cellStyle, width: finalWidth },
|
|
486
|
+
// headerStyle: { ...c.headerStyle, width: finalWidth },
|
|
487
|
+
// size: finalWidth
|
|
488
|
+
size: void 0,
|
|
489
|
+
// minSize: 40,
|
|
490
|
+
maxSize: 800
|
|
491
|
+
};
|
|
492
|
+
}),
|
|
493
|
+
...!disableDefaultActionColumn ? [
|
|
494
|
+
{
|
|
495
|
+
id: "actions",
|
|
496
|
+
enableEditing: false,
|
|
497
|
+
size: (defaultActionColumnItems == null ? void 0 : defaultActionColumnItems.length) > 1 ? 80 : 50,
|
|
498
|
+
header: /* @__PURE__ */ jsx(IconButton, { size: "small", sx: { p: 0.5, "&:hover": { backgroundColor: "transparent" } }, onClick: handleHeaderClick, children: /* @__PURE__ */ jsx("img", { src: images.common.arrowIcon, alt: "Arrow Icon" }) }),
|
|
499
|
+
enableColumnDragging: false,
|
|
500
|
+
visible: true,
|
|
501
|
+
muiTableHeadCellProps: {
|
|
502
|
+
className: "pinned-column"
|
|
503
|
+
},
|
|
504
|
+
muiTableBodyCellProps: {
|
|
505
|
+
className: "pinned-column",
|
|
506
|
+
sx: {
|
|
507
|
+
whiteSpace: "pre-wrap"
|
|
508
|
+
}
|
|
509
|
+
},
|
|
510
|
+
Cell: (props) => (defaultActionColumnItems == null ? void 0 : defaultActionColumnItems.length) ? defaultActionColumnItems.map((item) => {
|
|
511
|
+
const updatedProps = {
|
|
512
|
+
...item.props,
|
|
513
|
+
onClick: () => item.props.onClick(props)
|
|
514
|
+
};
|
|
515
|
+
return cloneElement(item, updatedProps);
|
|
516
|
+
}) : !disabledDefaultActionColumnIcon && /* @__PURE__ */ jsx(
|
|
517
|
+
IconButton,
|
|
518
|
+
{
|
|
519
|
+
onClick: (e) => handleActionsClick(e, props.row.original),
|
|
520
|
+
disabled: !(rowActionMenu == null ? void 0 : rowActionMenu.length) && !(destructiveActionMenu == null ? void 0 : destructiveActionMenu.length),
|
|
521
|
+
children: /* @__PURE__ */ jsx("img", { src: images.more, alt: "More Icon" })
|
|
522
|
+
}
|
|
523
|
+
)
|
|
524
|
+
}
|
|
525
|
+
] : []
|
|
526
|
+
],
|
|
527
|
+
data: rows,
|
|
528
|
+
muiTablePaperProps: {
|
|
529
|
+
sx: {
|
|
530
|
+
tableLayout: "auto"
|
|
531
|
+
// lets columns shrink to fit content
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
columnResizeMode: "onChange",
|
|
535
|
+
onEditingRowSave: async (data) => {
|
|
536
|
+
await handleSaveRow(data.row, data.values, data.table);
|
|
537
|
+
},
|
|
538
|
+
onCreatingRowSave: async (data) => {
|
|
539
|
+
try {
|
|
540
|
+
await validationSchema.validate(data.values, {
|
|
541
|
+
abortEarly: false
|
|
542
|
+
});
|
|
543
|
+
setValidationErrors({});
|
|
544
|
+
setIsCreatingRow(true);
|
|
545
|
+
setDisableNextEdit(false);
|
|
546
|
+
const cells = data.row.getAllCells().map((c) => c.column.columnDef);
|
|
547
|
+
data.row._valuesCache = formtValues(data.values, cells);
|
|
548
|
+
if (onCreateRow) {
|
|
549
|
+
await onCreateRow(data);
|
|
550
|
+
}
|
|
551
|
+
setIsCreatingRow(false);
|
|
552
|
+
data.table.setCreatingRow(null);
|
|
553
|
+
} catch (err) {
|
|
554
|
+
setIsCreatingRow(false);
|
|
555
|
+
if (err instanceof Yup.ValidationError) {
|
|
556
|
+
const errors = {};
|
|
557
|
+
err.inner.forEach((error) => {
|
|
558
|
+
if (error.path) {
|
|
559
|
+
errors[error.path] = error.message;
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
setValidationErrors(errors);
|
|
563
|
+
} else if (err instanceof Error) {
|
|
564
|
+
enqueueSnackbar(err.message, { variant: "error" });
|
|
565
|
+
} else {
|
|
566
|
+
enqueueSnackbar("Something went wrong", { variant: "error" });
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
onCreatingRowCancel: () => resetRowSelection(),
|
|
571
|
+
onEditingRowCancel: () => {
|
|
572
|
+
console.log("onEditingRowCancel called");
|
|
573
|
+
setDisableNextEdit(false);
|
|
574
|
+
},
|
|
575
|
+
onSortingChange: (states == null ? void 0 : states.sorting) ? onSortingChange : setSorting,
|
|
576
|
+
displayColumnDefOptions: {
|
|
577
|
+
"mrt-row-actions": {
|
|
578
|
+
// size: onDeleteRow ? 80 : 50,
|
|
579
|
+
Header: /* @__PURE__ */ jsx(IconButton, { onClick: handleHeaderClick, size: "small", children: /* @__PURE__ */ jsx("img", { src: images.common.arrowIcon, alt: "Arrow Icon" }) }),
|
|
580
|
+
muiTableBodyCellProps: ({ row: row2, table: table2 }) => {
|
|
581
|
+
var _a, _b;
|
|
582
|
+
const isCreatingRow2 = ((_a = table2.getState().creatingRow) == null ? void 0 : _a.id) === row2.id;
|
|
583
|
+
const isEditingRow2 = ((_b = table2.getState().editingRow) == null ? void 0 : _b.id) === row2.id;
|
|
584
|
+
return {
|
|
585
|
+
sx: {
|
|
586
|
+
"& .MuiBox-root": {
|
|
587
|
+
gap: 0
|
|
588
|
+
},
|
|
589
|
+
backgroundColor: "#fff",
|
|
590
|
+
whiteSpace: "pre-wrap",
|
|
591
|
+
// Hide save button only when editing existing row (not in create mode or non-editable mode)
|
|
592
|
+
...isEditingRow2 && !isCreatingRow2 && {
|
|
593
|
+
"& .MuiBox-root > .MuiIconButton-root:first-of-type": {
|
|
594
|
+
display: "none !important"
|
|
595
|
+
},
|
|
596
|
+
// Also hide any save icon buttons by aria-label or title
|
|
597
|
+
'& button[aria-label*="Save"]': {
|
|
598
|
+
display: "none !important"
|
|
599
|
+
},
|
|
600
|
+
'& button[title*="Save"]': {
|
|
601
|
+
display: "none !important"
|
|
602
|
+
},
|
|
603
|
+
// Hide save icon by class or data attributes
|
|
604
|
+
'& .MuiIconButton-root[class*="save"]': {
|
|
605
|
+
display: "none !important"
|
|
606
|
+
},
|
|
607
|
+
'& .MuiIconButton-root[data-testid*="save"]': {
|
|
608
|
+
display: "none !important"
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
},
|
|
612
|
+
onKeyUp: (e) => console.log(e)
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
},
|
|
616
|
+
"mrt-row-expand": {
|
|
617
|
+
size: 70
|
|
618
|
+
// Set the size of the expand-collapse arrow column here
|
|
619
|
+
},
|
|
620
|
+
"mrt-row-select": {
|
|
621
|
+
size: 50
|
|
622
|
+
// Set the width of the checkbox column here
|
|
623
|
+
}
|
|
624
|
+
},
|
|
625
|
+
renderRowActions: ({ row: row2, table: table2 }) => /* @__PURE__ */ jsx(Fragment, { children: (rest == null ? void 0 : rest.enableExpanding) ? /* @__PURE__ */ jsx(Fragment, { children: (row2 == null ? void 0 : row2.parentId) && /* @__PURE__ */ jsx(Box, { sx: { display: "flex", gap: 0 }, children: onDeleteRow && /* @__PURE__ */ jsx(Tooltip, { title: "Delete", children: /* @__PURE__ */ jsx(IconButton, { disabled: disableNextEdit, onClick: () => setRowToDelete(row2), size: "small", children: /* @__PURE__ */ jsx(Trash, { fontSize: "small", sx: { color: "theme.secondary.1000" } }) }) }) }) }) : /* @__PURE__ */ jsx(Box, { sx: { display: "flex", gap: 0 }, children: onDeleteRow && /* @__PURE__ */ jsx(Tooltip, { title: "Delete", children: /* @__PURE__ */ jsx(IconButton, { disabled: disableNextEdit, onClick: () => setRowToDelete(row2), children: /* @__PURE__ */ jsx(Trash, { fontSize: "small", sx: { color: "theme.secondary.1000" } }) }) }) }) }),
|
|
626
|
+
...Boolean(enableRowCreate) && {
|
|
627
|
+
renderBottomToolbarCustomActions: ({ table: table2 }) => /* @__PURE__ */ jsx(
|
|
628
|
+
Button,
|
|
629
|
+
{
|
|
630
|
+
variant: "outlined",
|
|
631
|
+
startIcon: /* @__PURE__ */ jsx(default_1$2, {}),
|
|
632
|
+
className: "add-row-btn",
|
|
633
|
+
disabled: disableNextEdit,
|
|
634
|
+
onClick: () => {
|
|
635
|
+
table2.setCreatingRow(true);
|
|
636
|
+
setDisableNextEdit(true);
|
|
637
|
+
},
|
|
638
|
+
children: t("common.add")
|
|
639
|
+
}
|
|
640
|
+
)
|
|
641
|
+
},
|
|
642
|
+
onRowSelectionChange: setRowSelection,
|
|
643
|
+
enableColumnOrdering: true,
|
|
644
|
+
enableRowSelection: enableRowSelection ?? true,
|
|
645
|
+
enableEditing: enableEditing instanceof Function ? enableEditing() : enableEditing ?? true,
|
|
646
|
+
editDisplayMode: editDisplayMode ?? "row",
|
|
647
|
+
createDisplayMode: "row",
|
|
648
|
+
enableColumnResizing,
|
|
649
|
+
enableRowDragging,
|
|
650
|
+
enableTopToolbar: false,
|
|
651
|
+
enableColumnActions: false,
|
|
652
|
+
enableSorting: true,
|
|
653
|
+
enableGrouping: true,
|
|
654
|
+
enableBottomToolbar: enableBottomToolbar ?? false,
|
|
655
|
+
enableColumnDragging: enableColumnDragging ?? true,
|
|
656
|
+
enableStickyHeader: true,
|
|
657
|
+
enableSortingRemoval: false,
|
|
658
|
+
// column ordering
|
|
659
|
+
state: {
|
|
660
|
+
// columnOrder: (!columnOrder || columnOrder.length <= 1)
|
|
661
|
+
// ? [...internalColumnOrder]
|
|
662
|
+
// : [...columnOrder],
|
|
663
|
+
columnOrder,
|
|
664
|
+
columnPinning: { left: ["actions", "mrt-row-actions"] },
|
|
665
|
+
isSaving: isCreatingRow || isEditingRow,
|
|
666
|
+
showProgressBars: false,
|
|
667
|
+
rowSelection,
|
|
668
|
+
...states,
|
|
669
|
+
sorting: Array.isArray(states == null ? void 0 : states.sorting) ? states == null ? void 0 : states.sorting : Array.isArray(sorting) ? sorting : [],
|
|
670
|
+
columnSizing
|
|
671
|
+
},
|
|
672
|
+
getRowId: (row2) => row2 == null ? void 0 : row2.id,
|
|
673
|
+
// table.getState().editingRow
|
|
674
|
+
muiTableBodyRowProps: ({ row: row2, table: table2 }) => {
|
|
675
|
+
var _a, _b, _c, _d, _e;
|
|
676
|
+
const editingRowId = ((_b = (_a = table2.getState()) == null ? void 0 : _a.editingRow) == null ? void 0 : _b.id) || ((_d = (_c = table2.getState()) == null ? void 0 : _c.creatingRow) == null ? void 0 : _d.id) || null;
|
|
677
|
+
const isErrorRow = Boolean((_e = row2 == null ? void 0 : row2.original) == null ? void 0 : _e.has_error);
|
|
678
|
+
const isCurrentlyEditing = editingRowId === row2.id;
|
|
679
|
+
return {
|
|
680
|
+
onClick: () => {
|
|
681
|
+
setSelectedRow(row2.id);
|
|
682
|
+
console.log("Row clicked:", row2.id, "editingRowId:", editingRowId, "isCurrentlyEditing:", isCurrentlyEditing, "disableNextEdit:", disableNextEdit);
|
|
683
|
+
if (editingRowId && editingRowId !== row2.id) {
|
|
684
|
+
table2.setEditingRow(null);
|
|
685
|
+
setTimeout(() => {
|
|
686
|
+
table2.setEditingRow(row2);
|
|
687
|
+
setDisableNextEdit(true);
|
|
688
|
+
}, 100);
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
if (!disableNextEdit && !isCurrentlyEditing && !editingRowId) {
|
|
692
|
+
console.log("Setting row as editable:", row2.id);
|
|
693
|
+
table2.setEditingRow(row2);
|
|
694
|
+
setDisableNextEdit(true);
|
|
695
|
+
} else {
|
|
696
|
+
console.log("Cannot edit row - conditions not met");
|
|
697
|
+
}
|
|
698
|
+
},
|
|
699
|
+
onKeyDown: (e) => {
|
|
700
|
+
if (isCurrentlyEditing) {
|
|
701
|
+
if (e.key === "Enter") {
|
|
702
|
+
e.preventDefault();
|
|
703
|
+
table2.setEditingRow(null);
|
|
704
|
+
} else if (e.key === "Escape") {
|
|
705
|
+
e.preventDefault();
|
|
706
|
+
console.log("Escape pressed, canceling edit for row:", row2.id);
|
|
707
|
+
table2.setEditingRow(null);
|
|
708
|
+
setDisableNextEdit(false);
|
|
709
|
+
handleSaveRow(row2, row2._valuesCache || row2.original, table2);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
},
|
|
713
|
+
sx: {
|
|
714
|
+
cursor: "pointer",
|
|
715
|
+
// backgroundColor: !editingRowId
|
|
716
|
+
// ? (selectedRow === row.id
|
|
717
|
+
// ? '#e8e8e8'
|
|
718
|
+
// : (isErrorRow ? 'theme.error.100' : 'inherit'))
|
|
719
|
+
// : 'inherit',
|
|
720
|
+
backgroundColor: !editingRowId ? isErrorRow ? "theme.error.100" : "inherit" : "inherit",
|
|
721
|
+
"&:hover": {
|
|
722
|
+
backgroundColor: editingRowId ? "transparent" : isErrorRow ? "theme.error.200" : "#e8e8e8"
|
|
723
|
+
// Removes hover effect globally
|
|
724
|
+
},
|
|
725
|
+
"&:hover td:after": {
|
|
726
|
+
backgroundColor: "transparent"
|
|
727
|
+
// Removes the grey background applied via :after
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
},
|
|
732
|
+
onColumnOrderChange: (colOrder) => {
|
|
733
|
+
if (handleColumnOrdering) handleColumnOrdering(colOrder);
|
|
734
|
+
},
|
|
735
|
+
onColumnSizingChange: setColumnSizing,
|
|
736
|
+
onColumnSizingInfoChange: setColumnSizingInfo,
|
|
737
|
+
renderEmptyRowsFallback: () => /* @__PURE__ */ jsxs(Box, { className: "no-data", children: [
|
|
738
|
+
/* @__PURE__ */ jsx("img", { src: images.common.tableNoData }),
|
|
739
|
+
/* @__PURE__ */ jsx(Typography, { type: "s3", weight: "medium", color: "theme.secondary.1000", children: t("common.noData") })
|
|
740
|
+
] }),
|
|
741
|
+
// pagination
|
|
742
|
+
enablePagination,
|
|
743
|
+
paginationDisplayMode: "pages",
|
|
744
|
+
muiPaginationProps: {
|
|
745
|
+
shape: "rounded",
|
|
746
|
+
page: pageNo,
|
|
747
|
+
// current page number
|
|
748
|
+
count: totalPages,
|
|
749
|
+
// total pages
|
|
750
|
+
showRowsPerPage: false,
|
|
751
|
+
// Hide rows per page options
|
|
752
|
+
boundaryCount: 3
|
|
753
|
+
},
|
|
754
|
+
muiEditTextFieldProps: ({ row: row2, column }) => ({
|
|
755
|
+
InputProps: {
|
|
756
|
+
disableUnderline: true
|
|
757
|
+
},
|
|
758
|
+
onBlur: (e) => {
|
|
759
|
+
updateData(e.target.value, column, row2.id);
|
|
760
|
+
},
|
|
761
|
+
// onChange: (e) => {
|
|
762
|
+
// updateData(e.target.value, column, row.id);
|
|
763
|
+
// },
|
|
764
|
+
variant: "outlined",
|
|
765
|
+
sx: ({ palette }) => {
|
|
766
|
+
var _a;
|
|
767
|
+
return {
|
|
768
|
+
"& .MuiOutlinedInput-root": {
|
|
769
|
+
"& fieldset": {
|
|
770
|
+
borderColor: `${(_a = palette.theme) == null ? void 0 : _a.primary[700]} !important`
|
|
771
|
+
// backgroundColor: palette.theme?.primary[700]
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
}),
|
|
777
|
+
/* Table loader style */
|
|
778
|
+
muiCircularProgressProps: {
|
|
779
|
+
sx: {
|
|
780
|
+
color: "#289B64"
|
|
781
|
+
}
|
|
782
|
+
},
|
|
783
|
+
// Table header cell default styles
|
|
784
|
+
muiTableHeadCellProps: {
|
|
785
|
+
sx: {
|
|
786
|
+
lineHeight: "140%",
|
|
787
|
+
letterSpacing: "-0.28px",
|
|
788
|
+
fontWeight: "500",
|
|
789
|
+
fontSize: "0.875rem",
|
|
790
|
+
"& .Mui-TableHeadCell-Content": {
|
|
791
|
+
height: "100%"
|
|
792
|
+
},
|
|
793
|
+
"& .Mui-TableHeadCell-Content-Labels": {
|
|
794
|
+
width: "100%",
|
|
795
|
+
justifyContent: "space-between"
|
|
796
|
+
},
|
|
797
|
+
"&.pinned-column": {
|
|
798
|
+
backgroundColor: "#fff"
|
|
799
|
+
},
|
|
800
|
+
"& .Mui-TableHeadCell-ResizeHandle-Wrapper": {
|
|
801
|
+
padding: 0,
|
|
802
|
+
margin: 0,
|
|
803
|
+
right: "-5px",
|
|
804
|
+
opacity: 0
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
},
|
|
808
|
+
// Table body cell default styles
|
|
809
|
+
muiTableBodyProps: {
|
|
810
|
+
sx: {
|
|
811
|
+
zIndex: 500
|
|
812
|
+
}
|
|
813
|
+
},
|
|
814
|
+
muiTableHeadProps: {
|
|
815
|
+
sx: {
|
|
816
|
+
zIndex: 600
|
|
817
|
+
}
|
|
818
|
+
},
|
|
819
|
+
muiTableBodyCellProps: () => ({
|
|
820
|
+
sx: {
|
|
821
|
+
lineHeight: "140%",
|
|
822
|
+
letterSpacing: "-0.26px",
|
|
823
|
+
fontWeight: "400",
|
|
824
|
+
fontSize: "0.8125rem",
|
|
825
|
+
"&.pinned-column": {
|
|
826
|
+
backgroundColor: "#fff"
|
|
827
|
+
},
|
|
828
|
+
"&:hover": {
|
|
829
|
+
backgroundColor: "transparent"
|
|
830
|
+
// Removes hover effect globally
|
|
831
|
+
},
|
|
832
|
+
whiteSpace: "pre-wrap"
|
|
833
|
+
}
|
|
834
|
+
// onClick: () => {
|
|
835
|
+
// table.setEditingCell(cell); //set editing cell
|
|
836
|
+
// queueMicrotask(() => {
|
|
837
|
+
// const textField = table.refs.editInputRefs.current[column.id];
|
|
838
|
+
// if (textField) {
|
|
839
|
+
// textField.focus();
|
|
840
|
+
// textField.select?.();
|
|
841
|
+
// }
|
|
842
|
+
// });
|
|
843
|
+
// }
|
|
844
|
+
// onKeyDown: (event) => {
|
|
845
|
+
// if (event.key === 'Tab') {
|
|
846
|
+
// try {
|
|
847
|
+
// // if (column.columnDef.editVariant === 'select') {
|
|
848
|
+
// // table.refs.editInputRefs.current[column.id]?.node?.blur();
|
|
849
|
+
// // } else {
|
|
850
|
+
// // table.refs.editInputRefs.current[column.id].blur();
|
|
851
|
+
// // }
|
|
852
|
+
// const rowIdx = row.index;
|
|
853
|
+
// const colIdx = columns.findIndex(
|
|
854
|
+
// (col) => col.accessorKey === column.id
|
|
855
|
+
// );
|
|
856
|
+
// const newColIdx = colIdx + 1;
|
|
857
|
+
// const clm = columns[newColIdx];
|
|
858
|
+
// const nextCell = row
|
|
859
|
+
// .getAllCells()
|
|
860
|
+
// .find((cl) => (cl.id = `${rowIdx}_${clm.accessorKey}`));
|
|
861
|
+
// if (nextCell) {
|
|
862
|
+
// // updateData(event.target.value, column, row.id);
|
|
863
|
+
// table.setEditingCell(nextCell);
|
|
864
|
+
// queueMicrotask(() => {
|
|
865
|
+
// const textField = table.refs.editInputRefs.current[column.id];
|
|
866
|
+
// if (textField) {
|
|
867
|
+
// textField.focus();
|
|
868
|
+
// textField.select?.();
|
|
869
|
+
// }
|
|
870
|
+
// });
|
|
871
|
+
// }
|
|
872
|
+
// } catch (error) {
|
|
873
|
+
// }
|
|
874
|
+
// }
|
|
875
|
+
// },
|
|
876
|
+
// onBlur: () => {
|
|
877
|
+
// table.setEditingCell(null);
|
|
878
|
+
// }
|
|
879
|
+
}),
|
|
880
|
+
// Checkbox styling
|
|
881
|
+
muiSelectCheckboxProps: {
|
|
882
|
+
sx: {
|
|
883
|
+
color: "theme.secondary.300",
|
|
884
|
+
"&.Mui-checked": {
|
|
885
|
+
color: "theme.primary.600",
|
|
886
|
+
"&:hover": {
|
|
887
|
+
color: "theme.primary.500"
|
|
888
|
+
}
|
|
889
|
+
},
|
|
890
|
+
"&.Mui-disabled": {
|
|
891
|
+
color: "theme.secondary.200"
|
|
892
|
+
}
|
|
893
|
+
},
|
|
894
|
+
icon: /* @__PURE__ */ jsx(RecgtangleIcon, { sx: { width: 20, height: 20 } }),
|
|
895
|
+
checkedIcon: /* @__PURE__ */ jsx(CheckBoxIcon, { sx: { width: 20, height: 20 } })
|
|
896
|
+
},
|
|
897
|
+
muiSelectAllCheckboxProps: {
|
|
898
|
+
sx: {
|
|
899
|
+
color: "theme.secondary.300",
|
|
900
|
+
"&.Mui-checked": {
|
|
901
|
+
color: "theme.primary.600",
|
|
902
|
+
"&:hover": {
|
|
903
|
+
color: "theme.primary.500"
|
|
904
|
+
}
|
|
905
|
+
},
|
|
906
|
+
"&.Mui-disabled": {
|
|
907
|
+
color: "theme.secondary.600"
|
|
908
|
+
}
|
|
909
|
+
},
|
|
910
|
+
icon: /* @__PURE__ */ jsx(RecgtangleIcon, { sx: { width: 20, height: 20 } }),
|
|
911
|
+
checkedIcon: /* @__PURE__ */ jsx(CheckBoxIcon, { sx: { width: 20, height: 20 } })
|
|
912
|
+
},
|
|
913
|
+
muiBottomToolbarProps: {
|
|
914
|
+
sx: {
|
|
915
|
+
boxShadow: "none",
|
|
916
|
+
"& .MuiBox-root": {
|
|
917
|
+
paddingLeft: 0
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
},
|
|
921
|
+
layoutMode: "grid",
|
|
922
|
+
icons: {
|
|
923
|
+
DragHandleIcon: () => /* @__PURE__ */ jsx(RecgtangleIcon, { fontSize: "medium" }),
|
|
924
|
+
SortIcon: () => /* @__PURE__ */ jsx(ArrowUpDown, { fontSize: "medium" }),
|
|
925
|
+
ArrowDownwardIcon: () => /* @__PURE__ */ jsx(ArrowUpDown, { fontSize: "medium" }),
|
|
926
|
+
ArrowUpwardIcon: () => /* @__PURE__ */ jsx(ArrowUpDown, { fontSize: "medium" }),
|
|
927
|
+
ExpandMoreIcon: () => /* @__PURE__ */ jsx(ArrowUpDown, { fontSize: "medium" }),
|
|
928
|
+
ExpandLessIcon: () => /* @__PURE__ */ jsx(ArrowUpDown, { fontSize: "medium" }),
|
|
929
|
+
SyncAltIcon: () => /* @__PURE__ */ jsx(ArrowUpDown, { fontSize: "medium" }),
|
|
930
|
+
CancelIcon: (props) => /* @__PURE__ */ jsx(Close, { fontSize: "small", ...props, color: "theme.secondary.1000" })
|
|
931
|
+
},
|
|
932
|
+
...rest
|
|
933
|
+
});
|
|
934
|
+
useEffect(() => {
|
|
935
|
+
var _a, _b;
|
|
936
|
+
if (enableRowSelection) {
|
|
937
|
+
if ((_a = table == null ? void 0 : table.getSelectedRowModel()) == null ? void 0 : _a.rows) {
|
|
938
|
+
SetSelectedRowId == null ? void 0 : SetSelectedRowId((_b = table == null ? void 0 : table.getSelectedRowModel()) == null ? void 0 : _b.rows);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}, [enableRowSelection]);
|
|
942
|
+
useEffect(() => {
|
|
943
|
+
if (onSelectRow) {
|
|
944
|
+
if (rest == null ? void 0 : rest.enableExpanding) {
|
|
945
|
+
const selectedRowModels = [];
|
|
946
|
+
const selection = table.getState().rowSelection;
|
|
947
|
+
const traverseRows = (rows2, parentKey = "") => {
|
|
948
|
+
rows2.forEach((row2, index) => {
|
|
949
|
+
var _a;
|
|
950
|
+
const rowKey = parentKey ? `${parentKey}.${index}` : `${row2.id}`;
|
|
951
|
+
if (selection[rowKey]) {
|
|
952
|
+
selectedRowModels.push(row2);
|
|
953
|
+
}
|
|
954
|
+
if ((_a = row2.subRows) == null ? void 0 : _a.length) {
|
|
955
|
+
traverseRows(row2.subRows, rowKey);
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
};
|
|
959
|
+
traverseRows(table.getRowModel().rows);
|
|
960
|
+
onSelectRow(selectedRowModels, rowSelection);
|
|
961
|
+
} else {
|
|
962
|
+
onSelectRow(table.getSelectedRowModel().rows, rowSelection);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
}, [rowSelection, table]);
|
|
966
|
+
useEffect(() => {
|
|
967
|
+
if (isResetRow) {
|
|
968
|
+
table == null ? void 0 : table.resetRowSelection();
|
|
969
|
+
}
|
|
970
|
+
}, [isResetRow, table]);
|
|
971
|
+
useEffect(() => {
|
|
972
|
+
if (!table) return;
|
|
973
|
+
let dropdownOpenTimer;
|
|
974
|
+
let saveTimer;
|
|
975
|
+
let lastDropdownClick = 0;
|
|
976
|
+
let isDropdownInteraction = false;
|
|
977
|
+
const handleMouseDown = (e) => {
|
|
978
|
+
const target = e.target;
|
|
979
|
+
const isDropdownElement = target.closest(
|
|
980
|
+
'.MuiSelect-root, .MuiMenuItem-root, .MuiPopover-root, .MuiList-root, .MuiMenu-list, .MuiModal-root, .MuiBackdrop-root, .MuiButtonBase-root, .MuiFormControl-root, .MuiInputBase-root, .MuiTextField-root, .MuiOutlinedInput-root, .MuiFilledInput-root, .MuiAutocomplete-popper, .MuiPickersPopper-root, [role="option"], [role="listbox"], [role="combobox"]'
|
|
981
|
+
);
|
|
982
|
+
if (isDropdownElement) {
|
|
983
|
+
isDropdownInteraction = true;
|
|
984
|
+
lastDropdownClick = Date.now();
|
|
985
|
+
if (saveTimer) {
|
|
986
|
+
clearTimeout(saveTimer);
|
|
987
|
+
}
|
|
988
|
+
if (dropdownOpenTimer) {
|
|
989
|
+
clearTimeout(dropdownOpenTimer);
|
|
990
|
+
}
|
|
991
|
+
dropdownOpenTimer = setTimeout(() => {
|
|
992
|
+
isDropdownInteraction = false;
|
|
993
|
+
}, 500);
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
const handleClick = (e) => {
|
|
997
|
+
var _a;
|
|
998
|
+
const editingRow = (_a = table.getState()) == null ? void 0 : _a.editingRow;
|
|
999
|
+
if (!editingRow) return;
|
|
1000
|
+
const target = e.target;
|
|
1001
|
+
const now = Date.now();
|
|
1002
|
+
if (isDropdownInteraction || now - lastDropdownClick < 300) {
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
const isInsideTable = target.closest(".MuiTableContainer-root, .MuiPaper-root, .MRT_Table");
|
|
1006
|
+
if (!isInsideTable) {
|
|
1007
|
+
if (saveTimer) {
|
|
1008
|
+
clearTimeout(saveTimer);
|
|
1009
|
+
}
|
|
1010
|
+
saveTimer = setTimeout(() => {
|
|
1011
|
+
var _a2;
|
|
1012
|
+
const currentEditingRow = (_a2 = table.getState()) == null ? void 0 : _a2.editingRow;
|
|
1013
|
+
if (currentEditingRow && !isDropdownInteraction) {
|
|
1014
|
+
handleSaveRow(currentEditingRow, currentEditingRow._valuesCache || currentEditingRow.original, table);
|
|
1015
|
+
}
|
|
1016
|
+
}, 200);
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
document.addEventListener("mousedown", handleMouseDown, true);
|
|
1020
|
+
document.addEventListener("click", handleClick, true);
|
|
1021
|
+
return () => {
|
|
1022
|
+
document.removeEventListener("mousedown", handleMouseDown, true);
|
|
1023
|
+
document.removeEventListener("click", handleClick, true);
|
|
1024
|
+
if (dropdownOpenTimer) {
|
|
1025
|
+
clearTimeout(dropdownOpenTimer);
|
|
1026
|
+
}
|
|
1027
|
+
if (saveTimer) {
|
|
1028
|
+
clearTimeout(saveTimer);
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
}, [table, handleSaveRow]);
|
|
1032
|
+
return /* @__PURE__ */ jsxs(TableWrapper, { className: "MRT-TableWrapper custom-table", children: [
|
|
1033
|
+
/* @__PURE__ */ jsx(MaterialReactTable, { table }),
|
|
1034
|
+
/* @__PURE__ */ jsx(
|
|
1035
|
+
Menu,
|
|
1036
|
+
{
|
|
1037
|
+
anchorEl,
|
|
1038
|
+
open: Boolean(anchorEl),
|
|
1039
|
+
onClose: handleHeaderClose,
|
|
1040
|
+
className: "add-role-drp",
|
|
1041
|
+
children: popUpShow ? /* @__PURE__ */ jsxs("div", { children: [
|
|
1042
|
+
/* @__PURE__ */ jsxs(
|
|
1043
|
+
MenuItem,
|
|
1044
|
+
{
|
|
1045
|
+
onClick: handleBackButtonClick,
|
|
1046
|
+
className: "role-drp-list add-column-title",
|
|
1047
|
+
children: [
|
|
1048
|
+
/* @__PURE__ */ jsx(ListItemIcon, { className: "add-icon", children: /* @__PURE__ */ jsx(default_1, {}) }),
|
|
1049
|
+
/* @__PURE__ */ jsx(ListItemText, { className: "title", children: t("common.addColumn_label") })
|
|
1050
|
+
]
|
|
1051
|
+
}
|
|
1052
|
+
),
|
|
1053
|
+
/* @__PURE__ */ jsx(Divider, { flexItem: true, sx: { mt: "0.25rem !important", mb: "0.25rem !important" } }),
|
|
1054
|
+
/* @__PURE__ */ jsx("div", { className: "searchbar-box-list", children: /* @__PURE__ */ jsx(
|
|
1055
|
+
SearchBar,
|
|
1056
|
+
{
|
|
1057
|
+
placeholder: "Search User",
|
|
1058
|
+
handleSearch: (e) => handleSearchEvent(e)
|
|
1059
|
+
}
|
|
1060
|
+
) }),
|
|
1061
|
+
/* @__PURE__ */ jsx("div", { className: "all-attribute-title", children: /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: t("common.allAttributes_label") }) }),
|
|
1062
|
+
filteredOptions.map((column) => /* @__PURE__ */ jsx(
|
|
1063
|
+
MenuItem,
|
|
1064
|
+
{
|
|
1065
|
+
onClick: () => handleAddColumn(column),
|
|
1066
|
+
children: /* @__PURE__ */ jsx(Typography, { color: "theme.secondary.1000", type: "s3", children: column.header })
|
|
1067
|
+
},
|
|
1068
|
+
column.accessorKey
|
|
1069
|
+
)),
|
|
1070
|
+
/* @__PURE__ */ jsx(Divider, { flexItem: true, sx: { mt: "0.25rem !important", mb: "0.25rem !important" } }),
|
|
1071
|
+
enableAddCustomField && /* @__PURE__ */ jsxs(MenuItem, { onClick: handleCustomAddColumn, className: "role-drp-list", children: [
|
|
1072
|
+
/* @__PURE__ */ jsx(ListItemIcon, { className: "add-icon", children: /* @__PURE__ */ jsx("img", { src: images.common.addIcon, alt: "Add Icon" }) }),
|
|
1073
|
+
/* @__PURE__ */ jsx(ListItemText, { className: "title", children: t("common.addCustomField_label") })
|
|
1074
|
+
] })
|
|
1075
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1076
|
+
visibleColumns.map((column) => /* @__PURE__ */ jsxs(
|
|
1077
|
+
MenuItem,
|
|
1078
|
+
{
|
|
1079
|
+
onClick: () => handleVisibleColumn(column),
|
|
1080
|
+
className: "role-drp-list",
|
|
1081
|
+
children: [
|
|
1082
|
+
/* @__PURE__ */ jsx(ListItemIcon, { className: "add-icon", children: /* @__PURE__ */ jsx("img", { src: images.common.dotsIcon, alt: "Add Icon" }) }),
|
|
1083
|
+
/* @__PURE__ */ jsx(ListItemText, { className: "title", children: column.header }),
|
|
1084
|
+
/* @__PURE__ */ jsx(ListItemIcon, { className: "eye-icon", children: /* @__PURE__ */ jsx("img", { src: images.common.eyeIcon, alt: "Eye Icon" }) })
|
|
1085
|
+
]
|
|
1086
|
+
},
|
|
1087
|
+
column.accessorKey
|
|
1088
|
+
)),
|
|
1089
|
+
/* @__PURE__ */ jsx(Divider, { flexItem: true, sx: { mt: "0.25rem !important", mb: "0.25rem !important" } }),
|
|
1090
|
+
/* @__PURE__ */ jsxs(MenuItem, { onClick: handleAddButtonClick, className: "role-drp-list", children: [
|
|
1091
|
+
/* @__PURE__ */ jsx(ListItemIcon, { className: "add-icon", children: /* @__PURE__ */ jsx("img", { src: images.common.addIcon, alt: "Add Icon" }) }),
|
|
1092
|
+
/* @__PURE__ */ jsx(ListItemText, { className: "title", children: t("common.addColumn_label") }),
|
|
1093
|
+
/* @__PURE__ */ jsx(
|
|
1094
|
+
Typography,
|
|
1095
|
+
{
|
|
1096
|
+
variant: "body2",
|
|
1097
|
+
color: "text.secondary",
|
|
1098
|
+
className: "eye-icon",
|
|
1099
|
+
children: /* @__PURE__ */ jsx(default_1$1, { sx: { fontSize: "1.25rem !important" } })
|
|
1100
|
+
}
|
|
1101
|
+
)
|
|
1102
|
+
] })
|
|
1103
|
+
] })
|
|
1104
|
+
}
|
|
1105
|
+
),
|
|
1106
|
+
/* @__PURE__ */ jsxs(
|
|
1107
|
+
Menu,
|
|
1108
|
+
{
|
|
1109
|
+
anchorEl: rowAnchorEl,
|
|
1110
|
+
open: Boolean(rowAnchorEl),
|
|
1111
|
+
onClose: handleActionsClose,
|
|
1112
|
+
children: [
|
|
1113
|
+
rowActionMenu == null ? void 0 : rowActionMenu.map((option) => {
|
|
1114
|
+
return /* @__PURE__ */ jsxs(
|
|
1115
|
+
MenuItem,
|
|
1116
|
+
{
|
|
1117
|
+
onClick: async () => {
|
|
1118
|
+
await option.handleAction(row);
|
|
1119
|
+
setRowAnchorEl(null);
|
|
1120
|
+
},
|
|
1121
|
+
disabled: typeof option.disabled === "function" ? option.disabled(row) : Boolean(option.disabled),
|
|
1122
|
+
sx: { alignItems: "center", gap: 0.5 },
|
|
1123
|
+
children: [
|
|
1124
|
+
option == null ? void 0 : option.icon,
|
|
1125
|
+
/* @__PURE__ */ jsx(Typography, { type: "s4", color: "inherit", children: typeof option.label === "function" ? option.label(row) : option.label })
|
|
1126
|
+
]
|
|
1127
|
+
}
|
|
1128
|
+
);
|
|
1129
|
+
}),
|
|
1130
|
+
(destructiveActionMenu == null ? void 0 : destructiveActionMenu.length) > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1131
|
+
/* @__PURE__ */ jsx(Divider, { flexItem: true, sx: { mt: "0.25rem !important", mb: "0.25rem !important" } }),
|
|
1132
|
+
/* @__PURE__ */ jsx("div", { className: "dropdown-inner--DestructiveHeader", children: destructiveActionMenu == null ? void 0 : destructiveActionMenu.map((option) => /* @__PURE__ */ jsx(
|
|
1133
|
+
MenuItem,
|
|
1134
|
+
{
|
|
1135
|
+
onClick: () => {
|
|
1136
|
+
option.handleAction(row);
|
|
1137
|
+
setRowAnchorEl(null);
|
|
1138
|
+
},
|
|
1139
|
+
className: "dropdown-inner--DestructiveActions",
|
|
1140
|
+
disabled: typeof option.disabled === "function" ? option.disabled(row) : Boolean(option.disabled),
|
|
1141
|
+
children: /* @__PURE__ */ jsx(Typography, { type: "s4", color: "inherit", children: typeof option.label === "function" ? option.label(row) : option.label })
|
|
1142
|
+
}
|
|
1143
|
+
)) })
|
|
1144
|
+
] })
|
|
1145
|
+
]
|
|
1146
|
+
}
|
|
1147
|
+
),
|
|
1148
|
+
/* @__PURE__ */ jsx(
|
|
1149
|
+
ConfirmPopUp,
|
|
1150
|
+
{
|
|
1151
|
+
open: Boolean(rowToDelete),
|
|
1152
|
+
onClose: () => setRowToDelete(null),
|
|
1153
|
+
onConfirm: () => handleRowDelete(),
|
|
1154
|
+
title: "Delete Item",
|
|
1155
|
+
description: `Are you sure you want to delete entry ?`,
|
|
1156
|
+
loading: isDeletingRow
|
|
1157
|
+
}
|
|
1158
|
+
)
|
|
1159
|
+
] });
|
|
1160
|
+
});
|
|
1161
|
+
export {
|
|
1162
|
+
MaterialEditableTable as default
|
|
1163
|
+
};
|
|
1164
|
+
//# sourceMappingURL=index.esm.js.map
|