@m4l/components 3.1.7 → 3.1.8
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/index.js +183 -340
- package/node_modules-CQtkw0uG.js +7350 -0
- package/package.json +1 -1
- package/vendor-AfIOyqRr.js +24636 -0
- package/components/AccountPopover/index-Dm2-k-Mv.js +0 -334
- package/components/AppBar/index-i0rhG3J1.js +0 -93
- package/components/BaseModule/index-CiNNlxzS.js +0 -30
- package/components/CommonActions/components/ActionCancel/index-CIdpDXkr.js +0 -12
- package/components/CommonActions/components/ActionFormCancel/index-CpyASN3q.js +0 -56
- package/components/CommonActions/components/ActionFormIntro/index-7KKtcUra.js +0 -33
- package/components/CommonActions/components/ActionIntro/index-CqqDZZcG.js +0 -25
- package/components/CommonActions/components/Actions/index-CuG1pnXW.js +0 -70
- package/components/DataGrid/constants-8L7QgBKi.js +0 -10
- package/components/DataGrid/formatters/ColumnBooleanFormatter/index-CveSCbq_.js +0 -26
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/index-CHqvieM2.js +0 -22
- package/components/DataGrid/formatters/ColumnDateFormatter/index-CKg8CJ6A.js +0 -19
- package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/index-DE6bwaKP.js +0 -23
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/index-BslXGK-A.js +0 -14
- package/components/DataGrid/formatters/ColumnPointsFormatter/index-BXGW2CsK.js +0 -10
- package/components/DataGrid/formatters/ColumnPriceFormatter/index-O11tBykn.js +0 -10
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/index-BaCawLr1.js +0 -36
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/index-Cq7a-jnE.js +0 -10
- package/components/DataGrid/formatters/index-CrZXPa0e.js +0 -13
- package/components/DataGrid/index-BZ-lbmuU.js +0 -908
- package/components/DataGrid/subcomponents/Actions/index-CHvPZ4Ru.js +0 -549
- package/components/DataGrid/subcomponents/editors/TextEditor/index-BIFm8akr.js +0 -80
- package/components/DragResizeWindow/index-D2jLYExo.js +0 -505
- package/components/DynamicFilter/constants-ByqmFATV.js +0 -31
- package/components/DynamicFilter/dictionary-PrbXU3VZ.js +0 -51
- package/components/DynamicFilter/index-DZiJc9h7.js +0 -116
- package/components/DynamicFilter/slots/SlotsEnum-cawFeNzx.js +0 -34
- package/components/DynamicFilter/slots/dynamicFilterSlots-DHxelhXP.js +0 -151
- package/components/DynamicFilter/slots/index-l0sNRNKZ.js +0 -1
- package/components/DynamicFilter/store/index-BT-eWVnJ.js +0 -254
- package/components/DynamicFilter/subcomponents/AppliedFilterChip/index-B32bAzi-.js +0 -60
- package/components/DynamicFilter/subcomponents/AppliedFilters/index-Bha19drV.js +0 -26
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/index-BmvzoHit.js +0 -40
- package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/index-BcO3SlP5.js +0 -129
- package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/index-BCJhpNS8.js +0 -171
- package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/index-DCNhz68u.js +0 -153
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/index-BdypjM1Y.js +0 -146
- package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/index-D-NFIVnK.js +0 -114
- package/components/DynamicFilter/subcomponents/FieldTypes/index-BwQHJqk9.js +0 -38
- package/components/DynamicFilter/subcomponents/FilterActions/index-B9UWmk07.js +0 -88
- package/components/DynamicFilter/subcomponents/InputFilter/index-CfGb1TfV.js +0 -188
- package/components/DynamicFilter/subcomponents/PopoverFilter/index-DkfRGrlO.js +0 -158
- package/components/DynamicFilter/subcomponents/PopoverMenuFields/index-DSegwAm2.js +0 -63
- package/components/FieldLabel/index-CI57EizR.js +0 -54
- package/components/GridLayout/index-C4HyxNYX.js +0 -1044
- package/components/GridLayout/subcomponents/Griditem/index-C7jT4s8t.js +0 -395
- package/components/GridLayout/subcomponents/Responsive/index-BKcU2OnF.js +0 -348
- package/components/GridLayout/subcomponents/SizeProvider/index-1aJ-e_54.js +0 -71
- package/components/HelperText/index-Crn_XIPF.js +0 -50
- package/components/Icon/index-C89MAkeH.js +0 -176
- package/components/Image/index-COp8vP0X.js +0 -175
- package/components/LanguagePopover/index-BA2Igs9L.js +0 -179
- package/components/LinearProgressIndeterminate/index-BwI756Mb.js +0 -55
- package/components/Loadable/index-BMbi9ISF.js +0 -9
- package/components/LoadingError/index-Cf0oGUrL.js +0 -89
- package/components/MFIsolationApp/index-V4R55hNU.js +0 -169
- package/components/MFLoader/index-BI8vQZSH.js +0 -299
- package/components/ModalDialog/index-CEVQBQ7W.js +0 -77
- package/components/NavLink/index-D1S_vtFO.js +0 -55
- package/components/NoItemSelected/index-B9oM26AX.js +0 -54
- package/components/ObjectLogs/index-CiXOJpS4.js +0 -233
- package/components/PDFViewer/index-GVN2rfd6.js +0 -51
- package/components/Page/index-DZMkYmr4.js +0 -117
- package/components/PaperForm/index-DwgAfjci.js +0 -59
- package/components/Period/index-2pJG3VmY.js +0 -238
- package/components/PrintingSystem/index-B2qcnfw0.js +0 -187
- package/components/PrintingSystem/subcomponents/BodyNode/index-Cv2aoy8S.js +0 -49
- package/components/PrintingSystem/subcomponents/ChartNode/index-BmJm8v_C.js +0 -105
- package/components/PrintingSystem/subcomponents/DividerNode/index-MpFhE-H0.js +0 -20
- package/components/PrintingSystem/subcomponents/FooterNode/index-ZEcWdMSM.js +0 -49
- package/components/PrintingSystem/subcomponents/GridNode/index-SsKax2xu.js +0 -74
- package/components/PrintingSystem/subcomponents/HeaderNode/index-Cs8TOOBL.js +0 -49
- package/components/PrintingSystem/subcomponents/PaperNode/index-DBb25Ecg.js +0 -30
- package/components/PrintingSystem/subcomponents/PropertyValueNode/index-CTVn7J9Q.js +0 -47
- package/components/PrintingSystem/subcomponents/SectionNode/index-iYPM3EaS.js +0 -49
- package/components/PrintingSystem/subcomponents/TextBoxNode/index-DGjXCFKJ.js +0 -24
- package/components/PropertyValue/index-Bh-Jnrte.js +0 -264
- package/components/Resizeable/index-DdP1xfE9.js +0 -20
- package/components/ScrollBar/index-f2URPPE2.js +0 -35
- package/components/ScrollToTop/index-TxORk5dB.js +0 -12
- package/components/SideBar/index-PUBBe0yH.js +0 -758
- package/components/SplitLayout/index-Bu1hcO6G.js +0 -89
- package/components/ToastContainer/index-DK1d8NNd.js +0 -191
- package/components/WrapperComponent/index-BHV-CsDU.js +0 -14
- package/components/animate/LoadingScreen/index-CkVLOrMz.js +0 -70
- package/components/animate/MotionContainer/index-eartnWyO.js +0 -34
- package/components/animate/MotionLazyContainer/index-Be8osTiG.js +0 -9
- package/components/animate/PropagateLoader/index-Bkq8V2SN.js +0 -23
- package/components/animate/features-BbnE33u3.js +0 -5
- package/components/animate/index-BsWiJfzp.js +0 -89
- package/components/animate/variants/bounce-DanQqHAX.js +0 -101
- package/components/animate/variants/container-Dmpr6tg5.js +0 -22
- package/components/animate/variants/fade-CAOJNn06.js +0 -65
- package/components/animate/variants/index-l0sNRNKZ.js +0 -1
- package/components/animate/variants/transition-B9W5SWTa.js +0 -20
- package/components/areas/components/AreasAdmin/index-OxQU3P8Y.js +0 -699
- package/components/areas/components/AreasViewer/index-DQ0aPioP.js +0 -805
- package/components/areas/components/index-l0sNRNKZ.js +0 -1
- package/components/areas/constants-rqODZNZe.js +0 -6
- package/components/areas/contexts/AreasContext/index-BqRlA7JA.js +0 -1110
- package/components/areas/contexts/DynamicMFParmsContext/index-22c6E7vK.js +0 -36
- package/components/areas/contexts/WindowToolsMFContext/index-DkE30fhm.js +0 -12
- package/components/areas/contexts/index-l0sNRNKZ.js +0 -1
- package/components/areas/dictionary-YUsP9beq.js +0 -36
- package/components/areas/hooks/index-l0sNRNKZ.js +0 -1
- package/components/areas/hooks/useAreas/index-BSbwbJLS.js +0 -11
- package/components/areas/hooks/useDynamicMFParameters/index-DhbcZPs9.js +0 -12
- package/components/areas/hooks/useSetWindowsTitle/useSetWindowsTitle-BzPD-miW.js +0 -31
- package/components/areas/hooks/useWindowToolsMF/index-BECQfhbC.js +0 -10
- package/components/areas/icons-CwFr-alN.js +0 -24
- package/components/areas/index-B_Odny9h.js +0 -22
- package/components/commercial/AppBarCommercial/index-CHq3P3GY.js +0 -28
- package/components/commercial/SectionCommercial/index-BeABGtdr.js +0 -56
- package/components/commercial/TopBar/index-F1repmti.js +0 -232
- package/components/commercial/index-CxDzs6Ax.js +0 -81
- package/components/formatters/BooleanFormatter/index-DktIidqW.js +0 -44
- package/components/formatters/DateFormatter/index-CGcRZ8BA.js +0 -43
- package/components/formatters/PointsFormatter/index-C7sR8iqk.js +0 -25
- package/components/formatters/PriceFormatter/index-CsvRawmc.js +0 -35
- package/components/formatters/UncertaintyFormatter/index-B9ESVEVp.js +0 -29
- package/components/formatters/index-pnJhDYKe.js +0 -109
- package/components/hook-form/HelperError/index-BVnmUazV.js +0 -19
- package/components/hook-form/RHFAutocomplete/index-BtPL16HR.js +0 -657
- package/components/hook-form/RHFAutocompleteAsync/index-BfzjLHG8.js +0 -226
- package/components/hook-form/RHFCheckbox/index-Vyttu8Vx.js +0 -132
- package/components/hook-form/RHFColorPicker/index-Cxxb5Wa_.js +0 -191
- package/components/hook-form/RHFDateTime/index-CW1Slb-f.js +0 -190
- package/components/hook-form/RHFMultiCheckbox/index-BARudV1A.js +0 -34
- package/components/hook-form/RHFPeriod/index-r-HeIOoZ.js +0 -98
- package/components/hook-form/RHFRadioGroup/index-CTD-0zKo.js +0 -52
- package/components/hook-form/RHFSelect/index-LdwRuFz-.js +0 -29
- package/components/hook-form/RHFTextField/index-B6ufruSB.js +0 -337
- package/components/hook-form/RHFUpload/index-CDPbm8NR.js +0 -253
- package/components/maps/components/GpsTools/index-5MXlhIEt.js +0 -1948
- package/components/maps/components/Map/index-2Lx5ARXa.js +0 -2546
- package/components/maps/index-Ci-7-FHg.js +0 -7
- package/components/modal/WindowBase-Gd27v5FU.js +0 -44
- package/components/modal/WindowConfirm-u6vAMFo7.js +0 -73
- package/components/modal/index-CydPIpKZ.js +0 -65
- package/components/mui_extended/Accordion/index-DMLYJL7o.js +0 -124
- package/components/mui_extended/Avatar/index-ClBa-6eF.js +0 -64
- package/components/mui_extended/Badge/index-zI-F_Qkq.js +0 -29
- package/components/mui_extended/BoxIcon/index-BUTJ2tKw.js +0 -22
- package/components/mui_extended/Breadcrumbs/index-DTS7rOZH.js +0 -86
- package/components/mui_extended/Button/index-CGfZbaea.js +0 -222
- package/components/mui_extended/CheckBox-BXUrbonB.js +0 -76
- package/components/mui_extended/CircularProgress/index-Bnnti_G6.js +0 -8
- package/components/mui_extended/IconButton/classes/constants-ChY2jKkp.js +0 -4
- package/components/mui_extended/IconButton/classes/index-BxjJGAqZ.js +0 -45
- package/components/mui_extended/IconButton/index-CusYFjie.js +0 -97
- package/components/mui_extended/IconButton/styledIconButton-fAsbGoFS.js +0 -7
- package/components/mui_extended/LinearProgress/index-CGgW8jq2.js +0 -9
- package/components/mui_extended/LinkWithRoute/index-BC2miUjR.js +0 -15
- package/components/mui_extended/MenuActions/MenuActions-C6CjSU6C.js +0 -149
- package/components/mui_extended/MenuActions/constants-BwsU9chA.js +0 -10
- package/components/mui_extended/MenuActions/dictionary-Dj_07puT.js +0 -11
- package/components/mui_extended/MenuActions/slots/MenuActionsEnum-Bu-L6eWU.js +0 -13
- package/components/mui_extended/MenuActions/slots/MenuActionsSlots-D65KZAKF.js +0 -46
- package/components/mui_extended/Pager/index-DCbxiTZA.js +0 -257
- package/components/mui_extended/Popover/index-DfrJAQkV.js +0 -153
- package/components/mui_extended/Stack/index-DzEeCYfp.js +0 -31
- package/components/mui_extended/Tab/index-Bu3dPidV.js +0 -129
- package/components/mui_extended/ToggleButton/index-C9cBkT1V.js +0 -18
- package/components/mui_extended/ToggleIconButton/index--0b3Td6C.js +0 -26
- package/components/mui_extended/Tooltip/index-B8QUytCK.js +0 -42
- package/components/mui_extended/Typography/index-Cf_4Zw8f.js +0 -54
- package/components/mui_extended/index-l0sNRNKZ.js +0 -1
- package/components/popups/PopupsProvider/index-DhSxmtfJ.js +0 -172
- package/components/popups/PopupsViewer/constants-DuyD7aCn.js +0 -4
- package/components/popups/PopupsViewer/icons-BUujqqbu.js +0 -7
- package/components/popups/PopupsViewer/index-BecevSns.js +0 -172
- package/components/popups/PopupsViewer/slots/index-B98CiRLa.js +0 -14
- package/components/popups/PopupsViewer/slots/popupsViewerSlots-BXH77nCF.js +0 -46
- package/components/popups/index-l0sNRNKZ.js +0 -1
- package/contexts/ModalContext/index-CPfNnfTL.js +0 -39
- package/contexts/RHFormContext/index-D_nK759o.js +0 -78
- package/hocs/withToggle/index-C1_DMZD3.js +0 -14
- package/hooks/useFormAddEdit/index-D9oSjUn1.js +0 -90
- package/hooks/useFormReadyForUpdate/index-B3HygFCM.js +0 -20
- package/hooks/useModal/index-BJSQOX3U.js +0 -10
- package/hooks/useSizeContainer/index-D4hDjM1P.js +0 -37
- package/hooks/useStateRef/index-C3P6ZK3m.js +0 -15
- package/hooks/useTab/index-B_GEQFOP.js +0 -12
- package/react-data-grid-BfYuZ6AK.js +0 -2606
- package/react-draggable-DsCPdgQP.js +0 -811
- package/react-json-view-bhqIAaNg.js +0 -2576
- package/react-resizable-eBbFl2dX.js +0 -618
- package/react-spinners-TpKN9lZg.js +0 -123
- package/react-splitter-layout-C-JTsNGs.js +0 -158
- package/styles/DynamicFilter-CJFsIegc.js +0 -319
- package/styles/MenuActions-lTi-ynPM.js +0 -42
- package/styles/index-DKj6m8SL.js +0 -1691
- package/test/constants_no_mock-CF-669v-.js +0 -4
- package/test/getNameDataTestId-BaBTWhBr.js +0 -10
- package/utils/index-DiMrtgIu.js +0 -502
- /package/components/GridLayout/subcomponents/{Griditem → GridItem}/index.d.ts +0 -0
- /package/components/GridLayout/subcomponents/{Griditem → GridItem}/types.d.ts +0 -0
|
@@ -1,908 +0,0 @@
|
|
|
1
|
-
import { g as getModalDialogComponentsDictionary } from "../ModalDialog/index-CEVQBQ7W.js";
|
|
2
|
-
import { g as getPagerComponentsDictionary } from "../mui_extended/Pager/index-DCbxiTZA.js";
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { a as WrapperSkeleton, D as DataGridRoot } from "../../styles/index-DKj6m8SL.js";
|
|
5
|
-
import { forwardRef, createContext, useState, useMemo, useEffect, useCallback, useContext, useRef, useLayoutEffect } from "react";
|
|
6
|
-
import { u as useRowSelection, S as SelectCellFormatter, H as HeaderRenderer, D as DataGrid$1 } from "../../react-data-grid-BfYuZ6AK.js";
|
|
7
|
-
import { useDrag, useDrop, DndProvider } from "react-dnd";
|
|
8
|
-
import { HTML5Backend } from "react-dnd-html5-backend";
|
|
9
|
-
import { SvgIcon, Checkbox, InputBase, Skeleton, generateUtilityClasses, generateUtilityClass } from "@mui/material";
|
|
10
|
-
import { D as DATAGRID_SELECT_COLUMN_KEY, c as componentName, a as DATAGRID_PREFIX_NAME } from "./constants-8L7QgBKi.js";
|
|
11
|
-
import { voidFunction, useModuleDictionary, useModuleSkeleton, getPropertyByString } from "@m4l/core";
|
|
12
|
-
import { A as ActionsColumn, a as Actions } from "./subcomponents/Actions/index-CHvPZ4Ru.js";
|
|
13
|
-
import { unstable_composeClasses } from "@mui/base";
|
|
14
|
-
import { T as TEST_PROP_ID } from "../../test/constants_no_mock-CF-669v-.js";
|
|
15
|
-
import { g as getNameDataTestId } from "../../test/getNameDataTestId-BaBTWhBr.js";
|
|
16
|
-
function CheckboxIcon(props) {
|
|
17
|
-
return /* @__PURE__ */ jsx(SvgIcon, { ...props, children: /* @__PURE__ */ jsx("path", { d: "M17 3a4 4 0 014 4v10a4 4 0 01-4 4H7a4 4 0 01-4-4V7a4 4 0 014-4h10zm0 2H7a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2z" }) });
|
|
18
|
-
}
|
|
19
|
-
function CheckboxCheckedIcon(props) {
|
|
20
|
-
return /* @__PURE__ */ jsx(SvgIcon, { ...props, children: /* @__PURE__ */ jsx("path", { d: "M17 3a4 4 0 014 4v10a4 4 0 01-4 4H7a4 4 0 01-4-4V7a4 4 0 014-4h10zm-1.372 4.972a1.006 1.006 0 00-.928.388l-3.78 5-1.63-2.08a1.001 1.001 0 00-1.58 1.23l2.44 3.11a1 1 0 001.58-.01l4.57-6v-.03a1.006 1.006 0 00-.672-1.608z" }) });
|
|
21
|
-
}
|
|
22
|
-
function CheckboxIndeterminateIcon(props) {
|
|
23
|
-
return /* @__PURE__ */ jsx(SvgIcon, { ...props, children: /* @__PURE__ */ jsx("path", { d: "M17 3a4 4 0 014 4v10a4 4 0 01-4 4H7a4 4 0 01-4-4V7a4 4 0 014-4h10zm-1.75 8h-6.5a.75.75 0 00-.75.75v.5c0 .414.336.75.75.75h6.5a.75.75 0 00.75-.75v-.5a.75.75 0 00-.75-.75z" }) });
|
|
24
|
-
}
|
|
25
|
-
const CheckboxFormatter = forwardRef(
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
27
|
-
function CheckboxFormatter2({ onChange, checked, ...props }, _ref) {
|
|
28
|
-
function handleChange(e) {
|
|
29
|
-
onChange(e.target.checked, e.nativeEvent.shiftKey);
|
|
30
|
-
}
|
|
31
|
-
return /* @__PURE__ */ jsx(
|
|
32
|
-
Checkbox,
|
|
33
|
-
{
|
|
34
|
-
checked,
|
|
35
|
-
size: "small",
|
|
36
|
-
icon: /* @__PURE__ */ jsx(CheckboxIcon, {}),
|
|
37
|
-
checkedIcon: /* @__PURE__ */ jsx(CheckboxCheckedIcon, {}),
|
|
38
|
-
indeterminateIcon: /* @__PURE__ */ jsx(CheckboxIndeterminateIcon, {}),
|
|
39
|
-
onChange: handleChange,
|
|
40
|
-
...props
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
);
|
|
45
|
-
const DataGridContext = createContext(null);
|
|
46
|
-
const getColumnConfigByKey = (key, storeColumnsConfig) => {
|
|
47
|
-
let indexFind = -1;
|
|
48
|
-
return [
|
|
49
|
-
storeColumnsConfig.find((column, index) => {
|
|
50
|
-
if (column.key === key) {
|
|
51
|
-
indexFind = index;
|
|
52
|
-
}
|
|
53
|
-
return column.key === key;
|
|
54
|
-
}),
|
|
55
|
-
indexFind
|
|
56
|
-
];
|
|
57
|
-
};
|
|
58
|
-
function getColumnsConfig(id, columns, remoteConfig = void 0) {
|
|
59
|
-
let columnsConfig;
|
|
60
|
-
if (remoteConfig) {
|
|
61
|
-
columnsConfig = remoteConfig.columnsConfig;
|
|
62
|
-
} else {
|
|
63
|
-
try {
|
|
64
|
-
const item = window.localStorage.getItem(`${id}_columns_config`);
|
|
65
|
-
columnsConfig = item !== null ? JSON.parse(item) : [];
|
|
66
|
-
} catch (e) {
|
|
67
|
-
columnsConfig = [];
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return columns.map((column, index) => {
|
|
71
|
-
const [columnConfig = { ...column }, columnConfigIndex] = getColumnConfigByKey(
|
|
72
|
-
column.key,
|
|
73
|
-
columnsConfig
|
|
74
|
-
);
|
|
75
|
-
return {
|
|
76
|
-
key: column.key,
|
|
77
|
-
name: column.name,
|
|
78
|
-
hidden: column.hidden === void 0 ? false : column.hidden,
|
|
79
|
-
index: columnConfigIndex > -1 ? columnConfigIndex : index,
|
|
80
|
-
visible: columnConfig.visible === void 0 ? true : columnConfig.visible,
|
|
81
|
-
frozen: columnConfig.frozen === void 0 ? false : columnConfig.frozen,
|
|
82
|
-
orginalIndex: index,
|
|
83
|
-
originalVisible: column.visible === void 0 ? true : column.visible,
|
|
84
|
-
originalFrozen: column.frozen === void 0 ? false : column.frozen
|
|
85
|
-
};
|
|
86
|
-
}).sort((a, b) => a.index - b.index);
|
|
87
|
-
}
|
|
88
|
-
function getColumnsWidth(id, columns, remoteConfig) {
|
|
89
|
-
const newMap = /* @__PURE__ */ new Map();
|
|
90
|
-
let storeColumnsWidth;
|
|
91
|
-
try {
|
|
92
|
-
const item = window.localStorage.getItem(`${id}_columns_width`);
|
|
93
|
-
storeColumnsWidth = item !== null ? new Map(JSON.parse(item)) : /* @__PURE__ */ new Map();
|
|
94
|
-
} catch (e) {
|
|
95
|
-
storeColumnsWidth = /* @__PURE__ */ new Map();
|
|
96
|
-
}
|
|
97
|
-
for (let i = 0; i < columns.length; i++) {
|
|
98
|
-
let width;
|
|
99
|
-
if (remoteConfig) {
|
|
100
|
-
try {
|
|
101
|
-
width = remoteConfig.columnsWidths.get(columns[i].key);
|
|
102
|
-
} catch (error) {
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (width === void 0) {
|
|
106
|
-
const storeWidth = storeColumnsWidth.get(columns[i].key);
|
|
107
|
-
if (typeof storeWidth === "number") {
|
|
108
|
-
width = storeWidth;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (width !== void 0) {
|
|
112
|
-
newMap.set(columns[i].key, width);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return newMap;
|
|
116
|
-
}
|
|
117
|
-
function saveColumnsWidth(id, storeColumnsWidth) {
|
|
118
|
-
localStorage.setItem(`${id}_columns_width`, JSON.stringify([...storeColumnsWidth]));
|
|
119
|
-
}
|
|
120
|
-
function saveColumnsConfig(id, columnsConfig) {
|
|
121
|
-
localStorage.setItem(`${id}_columns_config`, JSON.stringify(columnsConfig));
|
|
122
|
-
}
|
|
123
|
-
function getIndexRowHeightVariant(variant) {
|
|
124
|
-
if (variant === "compact") {
|
|
125
|
-
return 0;
|
|
126
|
-
}
|
|
127
|
-
if (variant === "standard") {
|
|
128
|
-
return 1;
|
|
129
|
-
}
|
|
130
|
-
return 2;
|
|
131
|
-
}
|
|
132
|
-
function DataGridProvider(props) {
|
|
133
|
-
const {
|
|
134
|
-
id,
|
|
135
|
-
children,
|
|
136
|
-
columns,
|
|
137
|
-
remoteConfig,
|
|
138
|
-
rows,
|
|
139
|
-
rowsCount,
|
|
140
|
-
rowActionsGetter,
|
|
141
|
-
rowHeights = [28, 32, 36],
|
|
142
|
-
rowHeaderHeights = [28, 32, 36],
|
|
143
|
-
initialRowHeightVariant = "compact",
|
|
144
|
-
checkedRows,
|
|
145
|
-
onCheckedRowsChange,
|
|
146
|
-
rowKeyGetter,
|
|
147
|
-
classes
|
|
148
|
-
} = props;
|
|
149
|
-
const [columnsWidths, setColumnsWidths] = useState(
|
|
150
|
-
/* @__PURE__ */ new Map()
|
|
151
|
-
);
|
|
152
|
-
const [columnsConfig, setColumnsConfigOptions] = useState(
|
|
153
|
-
() => (
|
|
154
|
-
//
|
|
155
|
-
[]
|
|
156
|
-
)
|
|
157
|
-
);
|
|
158
|
-
const [rowsFilterCount, setRowFilterCount] = useState(rowsCount);
|
|
159
|
-
const [currentRowHeightVariant, setCurrentRowHeightVariant] = useState(() => {
|
|
160
|
-
if (typeof rowHeights !== typeof rowHeaderHeights) {
|
|
161
|
-
throw new Error("Must be same type rowheights and rowHeaderTypes");
|
|
162
|
-
}
|
|
163
|
-
if (typeof rowHeights === "number" && typeof rowHeaderHeights === "number") {
|
|
164
|
-
return {
|
|
165
|
-
rowHVariant: "compact",
|
|
166
|
-
rowHeight: rowHeights,
|
|
167
|
-
rowHeaderHeight: rowHeaderHeights
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
if (typeof rowHeights !== "number" && rowHeights.length !== 3) {
|
|
171
|
-
throw new Error("Must be 3 heights");
|
|
172
|
-
}
|
|
173
|
-
if (typeof rowHeaderHeights !== "number" && rowHeaderHeights.length !== 3) {
|
|
174
|
-
throw new Error("Must be 3 HeaderHeights");
|
|
175
|
-
}
|
|
176
|
-
return {
|
|
177
|
-
rowHVariant: initialRowHeightVariant,
|
|
178
|
-
rowHeight: typeof rowHeights !== "number" ? rowHeights[getIndexRowHeightVariant(initialRowHeightVariant)] : rowHeights,
|
|
179
|
-
rowHeaderHeight: typeof rowHeaderHeights !== "number" ? rowHeaderHeights[getIndexRowHeightVariant(initialRowHeightVariant)] : rowHeaderHeights
|
|
180
|
-
};
|
|
181
|
-
});
|
|
182
|
-
const finalRowHeights = useMemo(() => rowHeights, [rowHeights]);
|
|
183
|
-
let timerSaveColumns;
|
|
184
|
-
useEffect(() => {
|
|
185
|
-
}, [columnsConfig]);
|
|
186
|
-
useEffect(() => {
|
|
187
|
-
setColumnsWidths(getColumnsWidth(id, columns, remoteConfig));
|
|
188
|
-
setColumnsConfigOptions(getColumnsConfig(id, columns, remoteConfig));
|
|
189
|
-
}, [columns, id, remoteConfig]);
|
|
190
|
-
const onChangeColumnsConfig = useCallback(
|
|
191
|
-
(newColumnsConfig) => {
|
|
192
|
-
saveColumnsConfig(id, newColumnsConfig);
|
|
193
|
-
setColumnsConfigOptions(newColumnsConfig);
|
|
194
|
-
},
|
|
195
|
-
[setColumnsConfigOptions, id]
|
|
196
|
-
);
|
|
197
|
-
const onChangeColumnsOrder = useCallback(
|
|
198
|
-
(sourceKey, targetKey) => {
|
|
199
|
-
if (sourceKey === targetKey) return;
|
|
200
|
-
const sourceColumnIndex = columnsConfig.findIndex((c) => c.key === sourceKey);
|
|
201
|
-
const targetColumnIndex = columnsConfig.findIndex((c) => c.key === targetKey);
|
|
202
|
-
const reorderedColumnsConfig = [...columnsConfig];
|
|
203
|
-
reorderedColumnsConfig.splice(
|
|
204
|
-
targetColumnIndex,
|
|
205
|
-
0,
|
|
206
|
-
reorderedColumnsConfig.splice(sourceColumnIndex, 1)[0]
|
|
207
|
-
);
|
|
208
|
-
onChangeColumnsConfig(reorderedColumnsConfig);
|
|
209
|
-
},
|
|
210
|
-
[columnsConfig, onChangeColumnsConfig]
|
|
211
|
-
);
|
|
212
|
-
const onChangeColumnWidth = (columnKey, width) => {
|
|
213
|
-
columnsWidths.set(columnKey, Math.round(width));
|
|
214
|
-
if (timerSaveColumns) {
|
|
215
|
-
clearTimeout(timerSaveColumns);
|
|
216
|
-
}
|
|
217
|
-
timerSaveColumns = setTimeout(() => {
|
|
218
|
-
saveColumnsWidth(id, columnsWidths);
|
|
219
|
-
}, 500);
|
|
220
|
-
};
|
|
221
|
-
useEffect(() => {
|
|
222
|
-
setColumnsConfigOptions(getColumnsConfig(id, columns));
|
|
223
|
-
}, [columns]);
|
|
224
|
-
const setRowFilterCountInternal = (newRowsCount) => {
|
|
225
|
-
setRowFilterCount(newRowsCount);
|
|
226
|
-
};
|
|
227
|
-
const setCurrentRowHeightInternal = useCallback(
|
|
228
|
-
(newVariant) => {
|
|
229
|
-
if (typeof rowHeights === "number" || typeof rowHeaderHeights === "number") {
|
|
230
|
-
throw new Error("Only use setCurrentRowHeight with vector rowHeights");
|
|
231
|
-
}
|
|
232
|
-
setCurrentRowHeightVariant({
|
|
233
|
-
rowHVariant: newVariant,
|
|
234
|
-
rowHeight: rowHeights[getIndexRowHeightVariant(newVariant)],
|
|
235
|
-
rowHeaderHeight: rowHeaderHeights[getIndexRowHeightVariant(newVariant)]
|
|
236
|
-
});
|
|
237
|
-
},
|
|
238
|
-
[setCurrentRowHeightVariant, rowHeights, rowHeaderHeights]
|
|
239
|
-
);
|
|
240
|
-
return /* @__PURE__ */ jsx(
|
|
241
|
-
DataGridContext.Provider,
|
|
242
|
-
{
|
|
243
|
-
value: {
|
|
244
|
-
columnsConfig,
|
|
245
|
-
columnsWidths,
|
|
246
|
-
rowsCount: rowsFilterCount,
|
|
247
|
-
currentRowHeightVariant: currentRowHeightVariant.rowHVariant,
|
|
248
|
-
currentRowHeight: currentRowHeightVariant.rowHeight,
|
|
249
|
-
currentRowHeaderHeight: currentRowHeightVariant.rowHeaderHeight,
|
|
250
|
-
rows,
|
|
251
|
-
rowHeights: finalRowHeights,
|
|
252
|
-
checkedRows,
|
|
253
|
-
onChangeColumnsConfig,
|
|
254
|
-
onChangeColumnsOrder,
|
|
255
|
-
onChangeColumnWidth,
|
|
256
|
-
setRowsCount: setRowFilterCountInternal,
|
|
257
|
-
rowActionsGetter,
|
|
258
|
-
classes,
|
|
259
|
-
setRowHeightVariant: setCurrentRowHeightInternal,
|
|
260
|
-
onCheckedRowsChange,
|
|
261
|
-
rowKeyGetter
|
|
262
|
-
},
|
|
263
|
-
children
|
|
264
|
-
}
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
function useDataGrid() {
|
|
268
|
-
const context = useContext(DataGridContext);
|
|
269
|
-
if (!context) throw new Error("useDataGrid context must be use inside DataGridContext");
|
|
270
|
-
return context;
|
|
271
|
-
}
|
|
272
|
-
const filterColumnClassName = "filter-cell";
|
|
273
|
-
const filterHeight = 35;
|
|
274
|
-
function SelectGroupFormatter(props) {
|
|
275
|
-
const [isRowSelected, onRowSelectionChange] = useRowSelection();
|
|
276
|
-
const onChange = (checked) => {
|
|
277
|
-
onRowSelectionChange({ row: props.row, checked, isShiftClick: false });
|
|
278
|
-
};
|
|
279
|
-
const cellFormater = SelectCellFormatter({
|
|
280
|
-
value: isRowSelected,
|
|
281
|
-
isCellSelected: props.isCellSelected,
|
|
282
|
-
onChange,
|
|
283
|
-
"aria-label": "Select Group"
|
|
284
|
-
});
|
|
285
|
-
return cellFormater;
|
|
286
|
-
}
|
|
287
|
-
function SelectFormatter(props) {
|
|
288
|
-
const { checkedRows, onCheckedRowsChange, rowKeyGetter } = useDataGrid();
|
|
289
|
-
const onChange = (checked, _isShiftClick) => {
|
|
290
|
-
const newCheckedRows = new Set(checkedRows);
|
|
291
|
-
if (checked) {
|
|
292
|
-
newCheckedRows.add(rowKeyGetter(props.row));
|
|
293
|
-
} else {
|
|
294
|
-
newCheckedRows.delete(rowKeyGetter(props.row));
|
|
295
|
-
}
|
|
296
|
-
onCheckedRowsChange && onCheckedRowsChange(newCheckedRows);
|
|
297
|
-
};
|
|
298
|
-
return /* @__PURE__ */ jsx(
|
|
299
|
-
SelectCellFormatter,
|
|
300
|
-
{
|
|
301
|
-
value: checkedRows?.has(rowKeyGetter(props.row)) || false,
|
|
302
|
-
isCellSelected: props.isCellSelected,
|
|
303
|
-
onChange,
|
|
304
|
-
"aria-label": "Select"
|
|
305
|
-
}
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
const SelectColumnHeaderRenderer = (props) => {
|
|
309
|
-
const { rows, rowKeyGetter, onCheckedRowsChange, checkedRows } = useDataGrid();
|
|
310
|
-
const onAllRowsCheckedChange = (checked) => {
|
|
311
|
-
if (!onCheckedRowsChange) return;
|
|
312
|
-
if (checked) {
|
|
313
|
-
onCheckedRowsChange(new Set(rows.map((r) => rowKeyGetter(r))));
|
|
314
|
-
} else {
|
|
315
|
-
onCheckedRowsChange(/* @__PURE__ */ new Set());
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
const allRowsChecked = rows.length === checkedRows?.size;
|
|
319
|
-
return SelectCellFormatter({
|
|
320
|
-
"aria-label": "Select All",
|
|
321
|
-
isCellSelected: props.isCellSelected,
|
|
322
|
-
value: allRowsChecked,
|
|
323
|
-
onChange: onAllRowsCheckedChange
|
|
324
|
-
});
|
|
325
|
-
};
|
|
326
|
-
const SelectColumn = {
|
|
327
|
-
key: DATAGRID_SELECT_COLUMN_KEY,
|
|
328
|
-
name: "",
|
|
329
|
-
width: 32,
|
|
330
|
-
minWidth: 32,
|
|
331
|
-
isDraggable: false,
|
|
332
|
-
resizable: false,
|
|
333
|
-
sortable: false,
|
|
334
|
-
frozen: true,
|
|
335
|
-
type: "boolean",
|
|
336
|
-
headerRenderer: SelectColumnHeaderRenderer,
|
|
337
|
-
formatter: SelectFormatter,
|
|
338
|
-
groupFormatter: SelectGroupFormatter
|
|
339
|
-
};
|
|
340
|
-
function useFocusRef(isSelected) {
|
|
341
|
-
const ref = useRef(null);
|
|
342
|
-
useLayoutEffect(() => {
|
|
343
|
-
if (!isSelected) return;
|
|
344
|
-
ref.current?.focus({ preventScroll: true });
|
|
345
|
-
}, [isSelected]);
|
|
346
|
-
return {
|
|
347
|
-
ref,
|
|
348
|
-
tabIndex: isSelected ? 0 : -1
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
const initialState = {
|
|
352
|
-
activeFilters: false,
|
|
353
|
-
setActiveFilters: voidFunction
|
|
354
|
-
};
|
|
355
|
-
const FilterContext = createContext(initialState);
|
|
356
|
-
function FilterProvider({ children, initialActiveFilters }) {
|
|
357
|
-
const [filterOptions, setFilterOptions] = useState({
|
|
358
|
-
activeFilters: initialActiveFilters
|
|
359
|
-
});
|
|
360
|
-
const onChangeFilter = (column, value) => {
|
|
361
|
-
const newMap = filterOptions.filters ? new Map(filterOptions.filters) : /* @__PURE__ */ new Map();
|
|
362
|
-
if (value !== "") {
|
|
363
|
-
newMap.set(column.key, { value, customFilter: column.customFilter });
|
|
364
|
-
} else {
|
|
365
|
-
newMap.delete(column.key);
|
|
366
|
-
}
|
|
367
|
-
setFilterOptions({
|
|
368
|
-
...filterOptions,
|
|
369
|
-
filters: newMap
|
|
370
|
-
});
|
|
371
|
-
};
|
|
372
|
-
const setActiveFilters = (active) => {
|
|
373
|
-
if (active) {
|
|
374
|
-
setFilterOptions({ activeFilters: true, filters: /* @__PURE__ */ new Map() });
|
|
375
|
-
} else {
|
|
376
|
-
setFilterOptions({ activeFilters: false });
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
return /* @__PURE__ */ jsx(
|
|
380
|
-
FilterContext.Provider,
|
|
381
|
-
{
|
|
382
|
-
value: {
|
|
383
|
-
...filterOptions,
|
|
384
|
-
onChangeFilter,
|
|
385
|
-
setActiveFilters
|
|
386
|
-
},
|
|
387
|
-
children
|
|
388
|
-
}
|
|
389
|
-
);
|
|
390
|
-
}
|
|
391
|
-
const useFilters = () => useContext(FilterContext);
|
|
392
|
-
function DraggableHeaderRenderer(props) {
|
|
393
|
-
const { onColumnsReorder, column, isCellSelected, ...others } = props;
|
|
394
|
-
const { ref, tabIndex } = useFocusRef(isCellSelected);
|
|
395
|
-
const { getLabel } = useModuleDictionary();
|
|
396
|
-
const { activeFilters, filters, onChangeFilter } = useFilters();
|
|
397
|
-
const [filter, setFilter] = useState(filters?.get(column.key) || "");
|
|
398
|
-
const [{ isDragging }, drag] = useDrag({
|
|
399
|
-
type: "COLUMN_DRAG",
|
|
400
|
-
item: { key: column.key },
|
|
401
|
-
collect: (monitor) => ({
|
|
402
|
-
isDragging: monitor.isDragging()
|
|
403
|
-
})
|
|
404
|
-
});
|
|
405
|
-
const [{ isOver }, drop] = useDrop({
|
|
406
|
-
accept: "COLUMN_DRAG",
|
|
407
|
-
drop({ key }) {
|
|
408
|
-
onColumnsReorder(key, column.key);
|
|
409
|
-
},
|
|
410
|
-
collect: (monitor) => ({
|
|
411
|
-
isOver: monitor.isOver(),
|
|
412
|
-
canDrop: monitor.canDrop()
|
|
413
|
-
})
|
|
414
|
-
});
|
|
415
|
-
const handleChange = (e) => {
|
|
416
|
-
if (activeFilters) {
|
|
417
|
-
if (onChangeFilter) onChangeFilter(column, e.target.value);
|
|
418
|
-
}
|
|
419
|
-
setFilter(e.target.value);
|
|
420
|
-
};
|
|
421
|
-
useEffect(() => {
|
|
422
|
-
if (!activeFilters) setFilter("");
|
|
423
|
-
}, [activeFilters]);
|
|
424
|
-
const newColumn = { ...column };
|
|
425
|
-
if (newColumn.withinHeaderRenderer) {
|
|
426
|
-
newColumn.name = newColumn.withinHeaderRenderer(props);
|
|
427
|
-
}
|
|
428
|
-
return /* @__PURE__ */ jsxs(
|
|
429
|
-
"div",
|
|
430
|
-
{
|
|
431
|
-
ref: (newRef) => {
|
|
432
|
-
drag(newRef);
|
|
433
|
-
drop(newRef);
|
|
434
|
-
},
|
|
435
|
-
style: {
|
|
436
|
-
opacity: isDragging ? 0.5 : 1,
|
|
437
|
-
backgroundColor: isOver ? "#ececec" : void 0,
|
|
438
|
-
cursor: "move",
|
|
439
|
-
display: "flex",
|
|
440
|
-
flexDirection: "column",
|
|
441
|
-
lineHeight: "1",
|
|
442
|
-
// activeFilters && column.withFilter ? '30px' : '60px',
|
|
443
|
-
height: "100%",
|
|
444
|
-
justifyContent: "center",
|
|
445
|
-
textAlign: "center"
|
|
446
|
-
// alignItems: 'center',
|
|
447
|
-
// justifyContent: 'space-evenly'
|
|
448
|
-
},
|
|
449
|
-
children: [
|
|
450
|
-
/* @__PURE__ */ jsx(HeaderRenderer, { column: newColumn, isCellSelected, ...others }),
|
|
451
|
-
activeFilters && (column?.withFilter === void 0 || column.withFilter === true) && /* @__PURE__ */ jsx(
|
|
452
|
-
"div",
|
|
453
|
-
{
|
|
454
|
-
className: "filter_cell_div",
|
|
455
|
-
style: {
|
|
456
|
-
borderTop: "1px solid var(--rdg-border-color)",
|
|
457
|
-
width: "100%",
|
|
458
|
-
display: "flex",
|
|
459
|
-
alignItems: "center",
|
|
460
|
-
// flexGrow: 1,
|
|
461
|
-
height: `${filterHeight}px`
|
|
462
|
-
// paddingLeft: '2px', paddingRight: '2px'
|
|
463
|
-
},
|
|
464
|
-
children: /* @__PURE__ */ jsx(
|
|
465
|
-
InputBase,
|
|
466
|
-
{
|
|
467
|
-
inputRef: ref,
|
|
468
|
-
placeholder: getLabel("data_grid.filter_holder"),
|
|
469
|
-
style: {
|
|
470
|
-
width: "100%",
|
|
471
|
-
paddingBottom: "2px",
|
|
472
|
-
border: "1px solid var(--rdg-border-color)"
|
|
473
|
-
},
|
|
474
|
-
tabIndex,
|
|
475
|
-
type: "text",
|
|
476
|
-
onChange: handleChange,
|
|
477
|
-
value: filter
|
|
478
|
-
}
|
|
479
|
-
)
|
|
480
|
-
}
|
|
481
|
-
)
|
|
482
|
-
]
|
|
483
|
-
}
|
|
484
|
-
);
|
|
485
|
-
}
|
|
486
|
-
const getDragHeaderRenderer = (handleColumnsReorder) => {
|
|
487
|
-
function HeaderRenderer2(props) {
|
|
488
|
-
return /* @__PURE__ */ jsx(DraggableHeaderRenderer, { ...props, onColumnsReorder: handleColumnsReorder });
|
|
489
|
-
}
|
|
490
|
-
return HeaderRenderer2;
|
|
491
|
-
};
|
|
492
|
-
function SkeletonFormatter() {
|
|
493
|
-
const { classes } = useDataGrid();
|
|
494
|
-
return /* @__PURE__ */ jsx(WrapperSkeleton, { className: classes.skeletonFormatter, children: /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "100%", height: "12px" }) });
|
|
495
|
-
}
|
|
496
|
-
function getComparator(columns, sortColumn) {
|
|
497
|
-
const column = columns.find((d) => d.key === sortColumn);
|
|
498
|
-
let typeOrder = "string";
|
|
499
|
-
if (column) {
|
|
500
|
-
typeOrder = column.type || "string";
|
|
501
|
-
}
|
|
502
|
-
switch (typeOrder) {
|
|
503
|
-
case "number":
|
|
504
|
-
return (a, b) => {
|
|
505
|
-
try {
|
|
506
|
-
return Number(a[sortColumn]) - Number(b[sortColumn]);
|
|
507
|
-
} catch (error) {
|
|
508
|
-
return -1;
|
|
509
|
-
}
|
|
510
|
-
};
|
|
511
|
-
default:
|
|
512
|
-
return (a, b) => {
|
|
513
|
-
try {
|
|
514
|
-
return a[sortColumn].toString().localeCompare(b[sortColumn].toString());
|
|
515
|
-
} catch (error) {
|
|
516
|
-
return -1;
|
|
517
|
-
}
|
|
518
|
-
};
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
const getColumIndex = (key, columnsConfig) => columnsConfig.findIndex((columnConfig) => columnConfig.key === key);
|
|
522
|
-
const getInOrderColumns = (columns, hasCheckedRows, columnsConfig, columnsWidths, rowActionsGetter) => {
|
|
523
|
-
let filteredSortedColumns = columns.filter((column) => {
|
|
524
|
-
const columnConfigIndex = getColumIndex(column.key, columnsConfig);
|
|
525
|
-
const visible = columnConfigIndex > -1 ? columnsConfig[columnConfigIndex].visible : true;
|
|
526
|
-
return !column.hidden && visible;
|
|
527
|
-
}).sort(
|
|
528
|
-
(a, b) => (
|
|
529
|
-
// Sort for index
|
|
530
|
-
getColumIndex(a.key, columnsConfig) - getColumIndex(b.key, columnsConfig)
|
|
531
|
-
)
|
|
532
|
-
).map((columnSorted) => {
|
|
533
|
-
const columnConfigIndex = getColumIndex(columnSorted.key, columnsConfig);
|
|
534
|
-
return {
|
|
535
|
-
...columnSorted,
|
|
536
|
-
frozen: columnConfigIndex > -1 ? columnsConfig[columnConfigIndex].frozen : true,
|
|
537
|
-
width: typeof columnsWidths.get(columnSorted.key) === "number" ? columnsWidths.get(columnSorted.key) : columnSorted.width
|
|
538
|
-
};
|
|
539
|
-
}).sort((a, b) => {
|
|
540
|
-
const order = (a.frozen === void 0 || a.frozen === false) === (b.frozen === void 0 || b.frozen === false) ? 0 : a.frozen ? -1 : 1;
|
|
541
|
-
return order;
|
|
542
|
-
});
|
|
543
|
-
if (rowActionsGetter) {
|
|
544
|
-
filteredSortedColumns = [ActionsColumn, ...filteredSortedColumns];
|
|
545
|
-
}
|
|
546
|
-
if (hasCheckedRows) {
|
|
547
|
-
filteredSortedColumns = [SelectColumn, ...filteredSortedColumns];
|
|
548
|
-
}
|
|
549
|
-
return filteredSortedColumns;
|
|
550
|
-
};
|
|
551
|
-
const getAligByType = (columnType) => {
|
|
552
|
-
switch (columnType) {
|
|
553
|
-
case "string":
|
|
554
|
-
return "left";
|
|
555
|
-
case "date":
|
|
556
|
-
case "boolean":
|
|
557
|
-
case "custom":
|
|
558
|
-
return "center";
|
|
559
|
-
case "number":
|
|
560
|
-
return "right";
|
|
561
|
-
}
|
|
562
|
-
return "left";
|
|
563
|
-
};
|
|
564
|
-
const useSortColumnsRows = (sourceColumns, sourceRows) => {
|
|
565
|
-
const {
|
|
566
|
-
columnsConfig,
|
|
567
|
-
columnsWidths,
|
|
568
|
-
onChangeColumnsOrder,
|
|
569
|
-
rowActionsGetter,
|
|
570
|
-
checkedRows,
|
|
571
|
-
onCheckedRowsChange
|
|
572
|
-
} = useDataGrid();
|
|
573
|
-
const [columns, setColumns] = useState(() => []);
|
|
574
|
-
const [sortColumns, setSortColumns] = useState([]);
|
|
575
|
-
const isSkeleton = useModuleSkeleton();
|
|
576
|
-
const { activeFilters, filters } = useFilters();
|
|
577
|
-
const findKeyInColumns = (key, cols) => {
|
|
578
|
-
const index = cols.findIndex((column) => key === column.key && column.hidden === false);
|
|
579
|
-
return index !== -1;
|
|
580
|
-
};
|
|
581
|
-
useEffect(() => {
|
|
582
|
-
setColumns(
|
|
583
|
-
getInOrderColumns(
|
|
584
|
-
sourceColumns,
|
|
585
|
-
!!checkedRows && !!onCheckedRowsChange,
|
|
586
|
-
//Si están seteados se habilita el múltipe
|
|
587
|
-
columnsConfig,
|
|
588
|
-
columnsWidths,
|
|
589
|
-
rowActionsGetter
|
|
590
|
-
)
|
|
591
|
-
);
|
|
592
|
-
const finalSortedColumns = sortColumns.filter(
|
|
593
|
-
(sortColumn) => findKeyInColumns(sortColumn.columnKey, sourceColumns)
|
|
594
|
-
);
|
|
595
|
-
if (JSON.stringify(finalSortedColumns) !== JSON.stringify(sortColumns)) {
|
|
596
|
-
setSortColumns(finalSortedColumns);
|
|
597
|
-
}
|
|
598
|
-
}, [sourceColumns, columnsConfig, rowActionsGetter]);
|
|
599
|
-
const finalColumns = useMemo(() => {
|
|
600
|
-
const DragAndDropHeaderRenderer = getDragHeaderRenderer(onChangeColumnsOrder);
|
|
601
|
-
return columns.map((c) => {
|
|
602
|
-
const newColumn = {
|
|
603
|
-
...c,
|
|
604
|
-
cellClass: c.align !== void 0 ? `rdg-cell-align-${c.align}` : `rdg-cell-align-${getAligByType(c.type)}`
|
|
605
|
-
};
|
|
606
|
-
if (newColumn.key === DATAGRID_SELECT_COLUMN_KEY || newColumn.isDraggable !== void 0 && newColumn.isDraggable === false) {
|
|
607
|
-
return newColumn;
|
|
608
|
-
}
|
|
609
|
-
if (isSkeleton) {
|
|
610
|
-
newColumn.headerRenderer = SkeletonFormatter;
|
|
611
|
-
newColumn.formatter = SkeletonFormatter;
|
|
612
|
-
}
|
|
613
|
-
if (newColumn.headerRenderer) {
|
|
614
|
-
newColumn.withinHeaderRenderer = newColumn.headerRenderer;
|
|
615
|
-
}
|
|
616
|
-
if ((newColumn?.withFilter === void 0 || newColumn.withFilter === true) && activeFilters) {
|
|
617
|
-
newColumn.headerCellClass = filterColumnClassName;
|
|
618
|
-
}
|
|
619
|
-
newColumn.headerRenderer = DragAndDropHeaderRenderer;
|
|
620
|
-
return newColumn;
|
|
621
|
-
});
|
|
622
|
-
}, [isSkeleton, columns, activeFilters, onChangeColumnsOrder]);
|
|
623
|
-
const finalRows = useMemo(() => {
|
|
624
|
-
const nextRows = sourceRows.filter((r) => {
|
|
625
|
-
if (!filters || filters.size === 0) return true;
|
|
626
|
-
const iterator = filters.entries();
|
|
627
|
-
let valReturn = true;
|
|
628
|
-
for (let i = 0; i < filters.size; i++) {
|
|
629
|
-
const entry = iterator.next().value;
|
|
630
|
-
const columnKey = entry[0];
|
|
631
|
-
const columnFilter = entry[1];
|
|
632
|
-
let valCell;
|
|
633
|
-
const valueMaybeString = getPropertyByString(r, columnKey);
|
|
634
|
-
let fixedValue;
|
|
635
|
-
if (typeof valueMaybeString === "string") {
|
|
636
|
-
fixedValue = valueMaybeString;
|
|
637
|
-
} else {
|
|
638
|
-
fixedValue = "";
|
|
639
|
-
}
|
|
640
|
-
try {
|
|
641
|
-
if (columnFilter.customFilter) {
|
|
642
|
-
valReturn = valReturn && columnFilter.customFilter(r, columnFilter.value);
|
|
643
|
-
} else {
|
|
644
|
-
valCell = fixedValue;
|
|
645
|
-
valReturn = valReturn && valCell.includes(columnFilter.value);
|
|
646
|
-
}
|
|
647
|
-
} catch (error) {
|
|
648
|
-
continue;
|
|
649
|
-
}
|
|
650
|
-
if (!valReturn) break;
|
|
651
|
-
}
|
|
652
|
-
return valReturn;
|
|
653
|
-
});
|
|
654
|
-
if (sortColumns.length === 0) {
|
|
655
|
-
return nextRows;
|
|
656
|
-
}
|
|
657
|
-
nextRows.sort((a, b) => {
|
|
658
|
-
for (const sort of sortColumns) {
|
|
659
|
-
const comparator = getComparator(columns, sort.columnKey);
|
|
660
|
-
const compResult = comparator(a, b);
|
|
661
|
-
if (compResult !== 0) {
|
|
662
|
-
return sort.direction === "ASC" ? compResult : -compResult;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
return 0;
|
|
666
|
-
});
|
|
667
|
-
return nextRows;
|
|
668
|
-
}, [sourceRows, sortColumns, filters]);
|
|
669
|
-
return { finalColumns, sortColumns, setSortColumns, finalRows };
|
|
670
|
-
};
|
|
671
|
-
function Table(props) {
|
|
672
|
-
const { columns, rows, onRowsChange, rowKeyGetter, selectedRows, onSelectedRowsChange } = props;
|
|
673
|
-
const { finalColumns, sortColumns, setSortColumns, finalRows } = useSortColumnsRows(
|
|
674
|
-
columns,
|
|
675
|
-
rows
|
|
676
|
-
);
|
|
677
|
-
const { activeFilters } = useFilters();
|
|
678
|
-
const { onChangeColumnWidth, setRowsCount, currentRowHeight, currentRowHeaderHeight, classes } = useDataGrid();
|
|
679
|
-
const ref_data_grid = useRef(null);
|
|
680
|
-
const onRowClick = (row) => {
|
|
681
|
-
if (selectedRows && onSelectedRowsChange) {
|
|
682
|
-
if (selectedRows.entries().next().value) {
|
|
683
|
-
if (selectedRows.entries().next().value[1] === rowKeyGetter(row)) {
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
const mySet = /* @__PURE__ */ new Set([rowKeyGetter(row)]);
|
|
688
|
-
onSelectedRowsChange(mySet);
|
|
689
|
-
}
|
|
690
|
-
};
|
|
691
|
-
useEffect(() => {
|
|
692
|
-
let columnIndice = 0;
|
|
693
|
-
for (const column of finalColumns) {
|
|
694
|
-
const index = sortColumns.findIndex((sortColumn) => column.key === sortColumn.columnKey);
|
|
695
|
-
if (index !== -1) {
|
|
696
|
-
ref_data_grid.current?.element?.querySelector(`[role="columnheader"][aria-colindex="${columnIndice + 1}"]`)?.setAttribute("aria-columnsort", `${sortColumns[index].direction}`);
|
|
697
|
-
} else {
|
|
698
|
-
ref_data_grid.current?.element?.querySelector(`[role="columnheader"][aria-colindex="${columnIndice + 1}"]`)?.removeAttribute("aria-columnsort");
|
|
699
|
-
}
|
|
700
|
-
columnIndice++;
|
|
701
|
-
}
|
|
702
|
-
}, [sortColumns, finalColumns]);
|
|
703
|
-
useEffect(() => {
|
|
704
|
-
setRowsCount(finalRows.length);
|
|
705
|
-
}, [finalRows]);
|
|
706
|
-
const onColumnResize = (idx, width) => {
|
|
707
|
-
onChangeColumnWidth(finalColumns[idx].key, width);
|
|
708
|
-
};
|
|
709
|
-
const onChangeSort = (newSortColumns) => {
|
|
710
|
-
setSortColumns(newSortColumns);
|
|
711
|
-
};
|
|
712
|
-
return /* @__PURE__ */ jsx("div", { className: classes.tableContaniner, id: "WrapperTable", children: /* @__PURE__ */ jsx("div", { className: classes.wrapperDataGridCss, children: /* @__PURE__ */ jsx(DndProvider, { backend: HTML5Backend, context: window, children: /* @__PURE__ */ jsx(
|
|
713
|
-
DataGrid$1,
|
|
714
|
-
{
|
|
715
|
-
className: "fill-grid rdg-light",
|
|
716
|
-
ref: ref_data_grid,
|
|
717
|
-
headerRowHeight: activeFilters ? currentRowHeaderHeight + filterHeight : currentRowHeaderHeight,
|
|
718
|
-
columns: finalColumns,
|
|
719
|
-
sortColumns,
|
|
720
|
-
onSortColumnsChange: onChangeSort,
|
|
721
|
-
onColumnResize,
|
|
722
|
-
rows: finalRows,
|
|
723
|
-
onRowsChange,
|
|
724
|
-
selectedRows,
|
|
725
|
-
onSelectedRowsChange,
|
|
726
|
-
onRowClick,
|
|
727
|
-
rowHeight: currentRowHeight,
|
|
728
|
-
rowKeyGetter,
|
|
729
|
-
cellNavigationMode: "LOOP_OVER_ROW",
|
|
730
|
-
components: { checkboxFormatter: CheckboxFormatter },
|
|
731
|
-
defaultColumnOptions: { resizable: true, sortable: true }
|
|
732
|
-
}
|
|
733
|
-
) }) }) });
|
|
734
|
-
}
|
|
735
|
-
const dataGridClasses = generateUtilityClasses(componentName, [
|
|
736
|
-
/* elements */
|
|
737
|
-
"root",
|
|
738
|
-
"actions",
|
|
739
|
-
"withPager",
|
|
740
|
-
"withNoPager",
|
|
741
|
-
"rowsCount",
|
|
742
|
-
"rowsCountLabel",
|
|
743
|
-
"rowsCountValue",
|
|
744
|
-
"densitySkeleton",
|
|
745
|
-
"actionDensityPopover",
|
|
746
|
-
"actionFilter",
|
|
747
|
-
"actionSettings",
|
|
748
|
-
"tableContaniner",
|
|
749
|
-
"wrapperDataGridCss",
|
|
750
|
-
"columnsConfigContainer",
|
|
751
|
-
"columnsLabelSetColumns",
|
|
752
|
-
"columnsConfigContent",
|
|
753
|
-
"columnsConfigGrid",
|
|
754
|
-
"columnsConfigActions",
|
|
755
|
-
"formatterColumn",
|
|
756
|
-
"skeletonFormatter",
|
|
757
|
-
"actionsFormatter",
|
|
758
|
-
"actionsConfigContainer",
|
|
759
|
-
"booleanFormatter",
|
|
760
|
-
"iconFormatter",
|
|
761
|
-
/* states or variants of elements */
|
|
762
|
-
"withActions"
|
|
763
|
-
]);
|
|
764
|
-
function getDataGridUtilityClass(slot) {
|
|
765
|
-
return generateUtilityClass(componentName, slot);
|
|
766
|
-
}
|
|
767
|
-
const dataGridUtilityClasses = (ownerState) => {
|
|
768
|
-
const slots = {
|
|
769
|
-
root: ["root"],
|
|
770
|
-
actions: ["actions", ownerState.actionsProps.withPager ? "withPager" : "withNoPager"],
|
|
771
|
-
rowsCount: ["rowsCount"],
|
|
772
|
-
rowsCountLabel: ["rowsCountLabel"],
|
|
773
|
-
rowsCountValue: ["rowsCountValue"],
|
|
774
|
-
densitySkeleton: ["densitySkeleton"],
|
|
775
|
-
densityRoot: ["densityRoot"],
|
|
776
|
-
densityPopover: ["densityPopover"],
|
|
777
|
-
actionFilter: ["actionFilter"],
|
|
778
|
-
actionSettings: ["actionSettingsRoot"],
|
|
779
|
-
actionDensityPopover: ["actionDensityPopover"],
|
|
780
|
-
tableContaniner: ["tableContaniner", ownerState.withActions && "withActions"],
|
|
781
|
-
wrapperDataGridCss: ["wrapperDataGridCss"],
|
|
782
|
-
columnsConfigContainer: ["columnsConfigContainer"],
|
|
783
|
-
columnsLabelSetColumns: ["columnsLabelSetColumns"],
|
|
784
|
-
columnsConfigContent: ["columnsConfigContent"],
|
|
785
|
-
columnsConfigGrid: ["columnsConfigGrid"],
|
|
786
|
-
columnsConfigActions: ["columnsConfigActions"],
|
|
787
|
-
formatterColumn: ["formatterColumn"],
|
|
788
|
-
skeletonFormatter: ["skeletonFormatter"],
|
|
789
|
-
actionsFormatter: ["actionsFormatter"],
|
|
790
|
-
actionsConfigContainer: ["actionsConfigContainer"],
|
|
791
|
-
booleanFormatter: ["booleanFormatter"],
|
|
792
|
-
iconFormatter: ["iconFormatter"]
|
|
793
|
-
};
|
|
794
|
-
const composedClasses = unstable_composeClasses(slots, getDataGridUtilityClass, {});
|
|
795
|
-
return {
|
|
796
|
-
...composedClasses
|
|
797
|
-
};
|
|
798
|
-
};
|
|
799
|
-
function getDataGridComponentsDictionary() {
|
|
800
|
-
return ["data_grid"].concat(getPagerComponentsDictionary()).concat(getModalDialogComponentsDictionary());
|
|
801
|
-
}
|
|
802
|
-
const dictionary = {
|
|
803
|
-
LABEL_ACTIONS: "actions",
|
|
804
|
-
LABEL_ROWS_PER_PAGE: "pager.rows_per_page",
|
|
805
|
-
LABEL_OF: "pager.of"
|
|
806
|
-
};
|
|
807
|
-
const DATAGRID_TEST_ID = "m4ldatagrid";
|
|
808
|
-
const PREFIX_TEST_ATTRIBUTE = "data-testid";
|
|
809
|
-
const TEST_PROP_COLUMNS = `${PREFIX_TEST_ATTRIBUTE}-${DATAGRID_TEST_ID}-columns`;
|
|
810
|
-
function DataGrid(props) {
|
|
811
|
-
const {
|
|
812
|
-
id,
|
|
813
|
-
withActions = true,
|
|
814
|
-
rows,
|
|
815
|
-
columns,
|
|
816
|
-
actionsProps,
|
|
817
|
-
selectedRows,
|
|
818
|
-
onSelectedRowsChange,
|
|
819
|
-
rowKeyGetter,
|
|
820
|
-
rowActionsGetter,
|
|
821
|
-
onRowsChange,
|
|
822
|
-
rowHeaderHeights,
|
|
823
|
-
rowHeights,
|
|
824
|
-
initialRowHeightVariant,
|
|
825
|
-
checkedRows,
|
|
826
|
-
onCheckedRowsChange,
|
|
827
|
-
dataTestId = ""
|
|
828
|
-
} = props;
|
|
829
|
-
const ownerState = {
|
|
830
|
-
actionsProps,
|
|
831
|
-
withActions
|
|
832
|
-
};
|
|
833
|
-
const classes = dataGridUtilityClasses(ownerState);
|
|
834
|
-
return /* @__PURE__ */ jsx(
|
|
835
|
-
DataGridRoot,
|
|
836
|
-
{
|
|
837
|
-
className: classes.root,
|
|
838
|
-
...process.env.NODE_ENV !== "production" ? {
|
|
839
|
-
[TEST_PROP_COLUMNS]: JSON.stringify(columns),
|
|
840
|
-
[TEST_PROP_ID]: getNameDataTestId(DATAGRID_PREFIX_NAME, "root", dataTestId)
|
|
841
|
-
} : {},
|
|
842
|
-
children: /* @__PURE__ */ jsx(
|
|
843
|
-
DataGridProvider,
|
|
844
|
-
{
|
|
845
|
-
id: props.id,
|
|
846
|
-
columns: props.columns,
|
|
847
|
-
rowHeights,
|
|
848
|
-
rowHeaderHeights,
|
|
849
|
-
initialRowHeightVariant,
|
|
850
|
-
rowsCount: rows.length,
|
|
851
|
-
checkedRows,
|
|
852
|
-
rowActionsGetter,
|
|
853
|
-
onCheckedRowsChange,
|
|
854
|
-
rowKeyGetter,
|
|
855
|
-
rows,
|
|
856
|
-
classes,
|
|
857
|
-
children: /* @__PURE__ */ jsxs(FilterProvider, { initialActiveFilters: false, children: [
|
|
858
|
-
withActions && actionsProps && /* @__PURE__ */ jsx(
|
|
859
|
-
Actions,
|
|
860
|
-
{
|
|
861
|
-
...actionsProps
|
|
862
|
-
}
|
|
863
|
-
),
|
|
864
|
-
/* @__PURE__ */ jsx(
|
|
865
|
-
Table,
|
|
866
|
-
{
|
|
867
|
-
id,
|
|
868
|
-
withActions,
|
|
869
|
-
columns,
|
|
870
|
-
rows,
|
|
871
|
-
selectedRows,
|
|
872
|
-
onSelectedRowsChange,
|
|
873
|
-
rowKeyGetter,
|
|
874
|
-
onRowsChange
|
|
875
|
-
}
|
|
876
|
-
)
|
|
877
|
-
] })
|
|
878
|
-
}
|
|
879
|
-
)
|
|
880
|
-
}
|
|
881
|
-
);
|
|
882
|
-
}
|
|
883
|
-
const getDataGridRowsFromSet = (set, rows, rowKeyGetter) => {
|
|
884
|
-
const rowsFinded = [];
|
|
885
|
-
if (set) {
|
|
886
|
-
if (set.size > 0) {
|
|
887
|
-
const iterator = set.entries();
|
|
888
|
-
for (let i = 0; i < set.size; i++) {
|
|
889
|
-
const entry = iterator.next().value;
|
|
890
|
-
const key = entry[1];
|
|
891
|
-
const row = rows.find((frow) => rowKeyGetter(frow) === key);
|
|
892
|
-
if (row) {
|
|
893
|
-
rowsFinded.push(row);
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
return rowsFinded;
|
|
899
|
-
};
|
|
900
|
-
export {
|
|
901
|
-
DataGrid as D,
|
|
902
|
-
useFilters as a,
|
|
903
|
-
dictionary as b,
|
|
904
|
-
getDataGridRowsFromSet as c,
|
|
905
|
-
dataGridClasses as d,
|
|
906
|
-
getDataGridComponentsDictionary as g,
|
|
907
|
-
useDataGrid as u
|
|
908
|
-
};
|