@m4l/components 0.1.76 → 0.1.78
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/@types/export.d.ts +22 -3
- package/components/AccountPopover/{index.47cf6c43.js → index.7e76dbb7.js} +8 -7
- package/components/AppBar/{index.f04f5e45.js → index.06858422.js} +8 -7
- package/components/CommonActions/components/ActionCancel/{index.453c2d24.js → index.d536ccfa.js} +2 -2
- package/components/CommonActions/components/ActionFormCancel/{index.c2a2fd55.js → index.a915b105.js} +19 -19
- package/components/CommonActions/components/ActionFormIntro/{index.25d33912.js → index.14e65d6c.js} +2 -2
- package/components/CommonActions/components/ActionIntro/{index.c653a266.js → index.aa1648eb.js} +2 -2
- package/components/CommonActions/components/Actions/{index.e376a68e.js → index.52125041.js} +17 -18
- package/components/DataGrid/{index.ffaf000e.js → index.9fb3e6a1.js} +40 -31
- package/components/DataGrid/types.d.ts +5 -1
- package/components/DraggableWindow/{index.b08af1dc.js → index.c702d3f2.js} +1 -1
- package/components/DynamicFilter/constants.d.ts +1 -0
- package/components/DynamicFilter/contexts/DynamicFilterContext/store.d.ts +6 -1
- package/components/DynamicFilter/{index.d7c03a61.js → index.d1a2e2d1.js} +54 -47
- package/components/DynamicFilter/tests/contants.d.ts +2 -3
- package/components/DynamicFilter/types.d.ts +4 -0
- package/components/GridLayout/GridLayout.d.ts +6 -0
- package/components/GridLayout/Responsive/index.0905a698.js +353 -0
- package/components/GridLayout/WidthProvider/index.9a26dfe4.js +65 -0
- package/components/GridLayout/calculateUtils.d.ts +42 -0
- package/components/GridLayout/index.d.ts +6 -0
- package/components/GridLayout/index.da6fd387.js +1410 -0
- package/components/GridLayout/subcomponents/GridItem/index.d.ts +26 -0
- package/components/GridLayout/subcomponents/GridItem/types.d.ts +78 -0
- package/components/GridLayout/subcomponents/Responsive/index.d.ts +3 -0
- package/components/GridLayout/subcomponents/Responsive/responsiveUtils.d.ts +64 -0
- package/components/GridLayout/subcomponents/Responsive/types.d.ts +69 -0
- package/components/GridLayout/subcomponents/WidthProvider/index.d.ts +16 -0
- package/components/GridLayout/types.d.ts +355 -0
- package/components/GridLayout/utils.d.ts +123 -0
- package/components/HelperText/{index.9864f773.js → index.a019742c.js} +8 -7
- package/components/Icon/{index.9dae8337.js → index.9fcd1476.js} +1 -1
- package/components/LanguagePopover/{index.938c6675.js → index.98b63dcb.js} +8 -7
- package/components/LinearProgressIndeterminate/{index.d34d398f.js → index.60dabc06.js} +1 -1
- package/components/ModalDialog/{index.d9c5d400.js → index.d9937d46.js} +8 -56
- package/components/NavLink/{index.21c8fd90.js → index.a5dea6d3.js} +8 -7
- package/components/ObjectLogs/{index.a2709fc2.js → index.d9d20b9d.js} +27 -21
- package/components/ObjectLogs/types.d.ts +1 -0
- package/components/PaperForm/{index.5e1bc99f.js → index.ba38a0bd.js} +1 -1
- package/components/Period/{index.526791a3.js → index.7b94c418.js} +22 -23
- package/components/PropertyValue/constants.d.ts +3 -0
- package/components/PropertyValue/{index.8a1adf3e.js → index.45c73161.js} +17 -11
- package/components/PropertyValue/types.d.ts +2 -1
- package/components/Resizeable/{index.f6e48e56.js → index.9a9c79a4.js} +1 -1
- package/components/SideBar/{index.9e1a5b96.js → index.2f497e6c.js} +5 -5
- package/components/areas/components/AreasAdmin/classes/index.d.ts +1 -1
- package/components/areas/components/AreasAdmin/classes/types.d.ts +5 -0
- package/components/areas/components/AreasAdmin/{index.946eebb9.js → index.43ecd998.js} +167 -81
- package/components/areas/components/AreasAdmin/subcomponents/AreaChip/types.d.ts +0 -1
- package/components/areas/components/AreasAdmin/subcomponents/AreaChipMobile/subcomponents/PanelWindowPopUp/index.d.ts +3 -0
- package/components/areas/components/AreasAdmin/subcomponents/AreaChipMobile/subcomponents/PanelWindowPopUp/types.d.ts +3 -0
- package/components/areas/components/AreasViewer/classes/index.d.ts +1 -1
- package/components/areas/components/AreasViewer/classes/types.d.ts +3 -0
- package/components/areas/components/AreasViewer/{index.bf4191ea.js → index.14e62059.js} +326 -345
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/{GridLayout → AreaGridLayout}/index.d.ts +1 -1
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/index.d.ts +2 -2
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/Header/index.d.ts +1 -7
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/Header/subcomponents/WindowPopUpsList/index.d.ts +3 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/Header/subcomponents/WindowPopUpsList/types.d.ts +2 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/subcomponents/Header/types.d.ts +6 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/types.d.ts +1 -1
- package/components/areas/components/index.a87653a9.js +29 -0
- package/components/areas/contexts/AreasContext/helper.d.ts +8 -16
- package/components/areas/contexts/AreasContext/{index.f0397b7c.js → index.02c4e7be.js} +262 -336
- package/components/areas/contexts/AreasContext/types.d.ts +22 -20
- package/components/areas/contexts/{index.1809650a.js → index.1ff9b360.js} +1 -1
- package/components/areas/{dictionary.3fabae50.js → dictionary.afb7e3d9.js} +5 -2
- package/components/areas/dictionary.d.ts +4 -1
- package/components/areas/hooks/useAreas/{index.40917e99.js → index.85e4b2e2.js} +1 -1
- package/components/areas/{icons.19cde4b4.js → icons.8266ccc8.js} +5 -1
- package/components/areas/icons.d.ts +4 -0
- package/components/areas/{index.9bd48013.js → index.d1dcccf5.js} +12 -11
- package/components/areas/types.d.ts +29 -22
- package/components/formatters/BooleanFormatter/{index.431dc923.js → index.e8de8e4c.js} +1 -1
- package/components/formatters/{index.e1af75e6.js → index.67aeb049.js} +2 -2
- package/components/hook-form/RHFAutocomplete/{index.a063dc44.js → index.6aa51705.js} +25 -13
- package/components/hook-form/RHFAutocompleteAsync/{index.ddfd9cc9.js → index.1a3dfe5f.js} +1 -1
- package/components/hook-form/RHFCheckbox/{index.7e7f220b.js → index.a08a65b3.js} +1 -1
- package/components/hook-form/RHFDateTime/{index.d330709b.js → index.4d671108.js} +10 -9
- package/components/hook-form/RHFPeriod/{index.e2b1293b.js → index.39b4be49.js} +2 -2
- package/components/hook-form/RHFTextField/{index.e5336d09.js → index.9004e898.js} +5 -5
- package/components/hook-form/RHFUpload/{index.17e7f9eb.js → index.bed8573e.js} +9 -11
- package/components/index.d.ts +1 -0
- package/components/modal/{WindowBase.7acb9f1d.js → WindowBase.a0c0b322.js} +10 -9
- package/components/modal/{WindowConfirm.9b829837.js → WindowConfirm.6c063f2d.js} +19 -19
- package/components/modal/classes/index.d.ts +1 -0
- package/components/modal/classes/types.d.ts +1 -0
- package/components/modal/{index.1b25b61d.js → index.00efea85.js} +19 -17
- package/components/mui_extended/Accordion/constants.d.ts +1 -0
- package/components/mui_extended/Accordion/{index.3faafd8b.js → index.9877f7bf.js} +8 -9
- package/components/mui_extended/Accordion/types.d.ts +1 -0
- package/components/mui_extended/Badge/Badge.d.ts +3 -0
- package/components/mui_extended/Badge/classes/constants.d.ts +1 -0
- package/components/mui_extended/Badge/classes/index.d.ts +6 -0
- package/components/mui_extended/Badge/classes/types.d.ts +6 -0
- package/components/mui_extended/Badge/index.8c2b8b66.js +36 -0
- package/components/mui_extended/Badge/index.d.ts +2 -0
- package/components/mui_extended/Badge/tests/constants.d.ts +1 -0
- package/components/mui_extended/Badge/tests/utils.d.ts +2 -0
- package/components/mui_extended/Badge/types.d.ts +4 -0
- package/components/mui_extended/Button/{index.fdb5dcbd.js → index.4288f9fc.js} +8 -3
- package/components/mui_extended/IconButton/{index.1a9d4fa5.js → index.12f1a3c3.js} +4 -1
- package/components/mui_extended/MenuActions/{index.ba1da3b3.js → index.43a2e1ae.js} +41 -13
- package/components/mui_extended/MenuActions/index.d.ts +3 -2
- package/components/mui_extended/MenuActions/types.d.ts +9 -0
- package/components/mui_extended/Pager/{index.67bda2c5.js → index.2f6d6d7d.js} +1 -1
- package/components/mui_extended/Tab/constant.d.ts +1 -0
- package/components/mui_extended/Tab/{index.9e2f6e34.js → index.7c82e43d.js} +5 -6
- package/components/mui_extended/Tab/types.d.ts +1 -0
- package/components/mui_extended/{index.73e536de.js → index.0e2ff642.js} +8 -7
- package/components/mui_extended/index.d.ts +1 -0
- package/contexts/ModalContext/{index.699f95fa.js → index.e9a7ba4a.js} +1 -1
- package/hooks/useModal/{index.7b7d26ba.js → index.8e85f7ae.js} +1 -1
- package/index.js +228 -214
- package/node_modules.d73a220d.js +363 -0
- package/package.json +4 -3
- package/{react-draggable.6d7949a3.js → react-draggable.7abb5d0a.js} +3 -2
- package/{react-resizable.b6f8e04a.js → react-resizable.ba08699a.js} +13 -12
- package/test/getNameDataTestId.d.ts +1 -0
- package/utils/{index.008b4c2a.js → index.c43a95f4.js} +0 -15
- package/vendor.e353394b.js +124 -0
- package/components/DynamicFilter/tests/types.d.ts +0 -2
- package/components/DynamicFilter/tests/utils.d.ts +0 -2
- package/components/PropertyValue/tests/constants.d.ts +0 -1
- package/components/PropertyValue/tests/utils.d.ts +0 -2
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/WindowPopUp/index.d.ts +0 -4
- package/components/areas/components/index.2bb534cb.js +0 -28
- package/components/modal/ModalDialog/types.d.ts +0 -7
- package/components/mui_extended/Accordion/tests/constants.d.ts +0 -1
- package/components/mui_extended/Accordion/tests/utils.d.ts +0 -2
- package/components/mui_extended/Tab/tests/constants.d.ts +0 -1
- package/components/mui_extended/Tab/tests/utils.d.ts +0 -2
- /package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/{GridLayout → AreaGridLayout}/types.d.ts +0 -0
|
@@ -4,60 +4,62 @@ import { useContext, useMemo, useEffect, createContext, useRef, createElement, u
|
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { useModuleDictionary, useEnvironment, useModuleSkeleton, useFlagsPresent, CommonFlags } from "@m4l/core";
|
|
6
6
|
import { useResponsiveDesktop, useFirstRender, useFormatter } from "@m4l/graphics";
|
|
7
|
-
import { I as IconButton } from "../mui_extended/IconButton/index.
|
|
7
|
+
import { I as IconButton } from "../mui_extended/IconButton/index.12f1a3c3.js";
|
|
8
8
|
import { T as TEST_PROP_ID } from "../../test/constants_no_mock.86c553a9.js";
|
|
9
|
+
import { g as getNameDataTestId } from "../../vendor.e353394b.js";
|
|
9
10
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
10
11
|
import { generateUtilityClasses, alpha, styled as styled$1, Skeleton, MenuItem } from "@mui/material";
|
|
11
|
-
import { L as LabelMemuItem } from "../mui_extended/MenuActions/index.
|
|
12
|
+
import { L as LabelMemuItem } from "../mui_extended/MenuActions/index.43a2e1ae.js";
|
|
12
13
|
import { P as Popover } from "../mui_extended/Popover/index.9f35d0eb.js";
|
|
13
|
-
import { I as Icon } from "../Icon/index.
|
|
14
|
+
import { I as Icon } from "../Icon/index.9fcd1476.js";
|
|
14
15
|
import { styled, useTheme } from "@mui/material/styles";
|
|
15
16
|
import { R as RHFormProvider } from "../../contexts/RHFormContext/index.fe175bab.js";
|
|
16
|
-
import { g as getCommonActionsDictionary, A as Actions } from "../CommonActions/components/Actions/index.
|
|
17
|
-
import { A as ActionCancel } from "../CommonActions/components/ActionCancel/index.
|
|
18
|
-
import { A as ActionIntro } from "../CommonActions/components/ActionIntro/index.
|
|
17
|
+
import { g as getCommonActionsDictionary, A as Actions } from "../CommonActions/components/Actions/index.52125041.js";
|
|
18
|
+
import { A as ActionCancel } from "../CommonActions/components/ActionCancel/index.d536ccfa.js";
|
|
19
|
+
import { A as ActionIntro } from "../CommonActions/components/ActionIntro/index.aa1648eb.js";
|
|
19
20
|
import { useFormContext, useWatch } from "react-hook-form";
|
|
20
21
|
import "@mui/material/Button";
|
|
21
|
-
import "../mui_extended/Button/index.
|
|
22
|
-
import "../../contexts/ModalContext/index.
|
|
23
|
-
import "../../react-draggable.
|
|
24
|
-
import "../
|
|
25
|
-
import "../
|
|
26
|
-
import "../modal/index.1b25b61d.js";
|
|
22
|
+
import "../mui_extended/Button/index.4288f9fc.js";
|
|
23
|
+
import "../../contexts/ModalContext/index.e9a7ba4a.js";
|
|
24
|
+
import "../../react-draggable.7abb5d0a.js";
|
|
25
|
+
import "../Resizeable/index.9a9c79a4.js";
|
|
26
|
+
import "../modal/index.00efea85.js";
|
|
27
27
|
import "../Image/index.c18ebf5a.js";
|
|
28
|
-
import "../mui_extended/Accordion/index.
|
|
28
|
+
import "../mui_extended/Accordion/index.9877f7bf.js";
|
|
29
29
|
import { T as Typography } from "../mui_extended/Typography/index.443590d6.js";
|
|
30
30
|
import "../mui_extended/Avatar/index.75e6ed57.js";
|
|
31
31
|
import "react-router-dom";
|
|
32
|
+
import "../mui_extended/Badge/index.8c2b8b66.js";
|
|
32
33
|
import "@mui/lab";
|
|
33
|
-
import "../mui_extended/Pager/index.
|
|
34
|
-
import "../mui_extended/Tab/index.
|
|
34
|
+
import "../mui_extended/Pager/index.2f6d6d7d.js";
|
|
35
|
+
import "../mui_extended/Tab/index.7c82e43d.js";
|
|
35
36
|
import "../mui_extended/Tooltip/index.5a795dcd.js";
|
|
36
37
|
import { useStore, createStore } from "zustand";
|
|
37
|
-
import "../areas/contexts/AreasContext/index.
|
|
38
|
-
import "../areas/components/AreasAdmin/index.
|
|
39
|
-
import "../areas/components/AreasViewer/index.
|
|
40
|
-
import "../LinearProgressIndeterminate/index.
|
|
38
|
+
import "../areas/contexts/AreasContext/index.02c4e7be.js";
|
|
39
|
+
import "../areas/components/AreasAdmin/index.43ecd998.js";
|
|
40
|
+
import "../areas/components/AreasViewer/index.14e62059.js";
|
|
41
|
+
import "../LinearProgressIndeterminate/index.60dabc06.js";
|
|
41
42
|
import "../areas/contexts/WindowToolsMFContext/index.8f3e2a04.js";
|
|
42
43
|
import "../areas/contexts/DynamicMFParmsContext/index.1607c78e.js";
|
|
43
44
|
import { unstable_composeClasses } from "@mui/base";
|
|
44
|
-
import { g as getComponentUtilityClass, i as isValidDate } from "../../utils/index.
|
|
45
|
+
import { g as getComponentUtilityClass, i as isValidDate } from "../../utils/index.c43a95f4.js";
|
|
45
46
|
import { devtools } from "zustand/middleware";
|
|
46
47
|
import { immer } from "zustand/middleware/immer";
|
|
47
|
-
import { R as RHFAutocomplete } from "../hook-form/RHFAutocomplete/index.
|
|
48
|
+
import { R as RHFAutocomplete } from "../hook-form/RHFAutocomplete/index.6aa51705.js";
|
|
48
49
|
import "lodash/debounce";
|
|
49
|
-
import "../hook-form/RHFAutocompleteAsync/index.
|
|
50
|
-
import "../hook-form/RHFCheckbox/index.
|
|
51
|
-
import "../HelperText/index.
|
|
50
|
+
import "../hook-form/RHFAutocompleteAsync/index.1a3dfe5f.js";
|
|
51
|
+
import "../hook-form/RHFCheckbox/index.a08a65b3.js";
|
|
52
|
+
import "../HelperText/index.a019742c.js";
|
|
52
53
|
import "@mui/x-date-pickers";
|
|
53
|
-
import { R as RHFDateTime } from "../hook-form/RHFDateTime/index.
|
|
54
|
-
import { R as RHFTextField } from "../hook-form/RHFTextField/index.
|
|
55
|
-
import "../hook-form/RHFPeriod/index.
|
|
56
|
-
import "../Period/index.
|
|
54
|
+
import { R as RHFDateTime } from "../hook-form/RHFDateTime/index.4d671108.js";
|
|
55
|
+
import { R as RHFTextField } from "../hook-form/RHFTextField/index.9004e898.js";
|
|
56
|
+
import "../hook-form/RHFPeriod/index.39b4be49.js";
|
|
57
|
+
import "../Period/index.7b94c418.js";
|
|
57
58
|
import "lodash/isString";
|
|
58
59
|
import "react-dropzone";
|
|
59
|
-
import "../hook-form/RHFUpload/index.
|
|
60
|
+
import "../hook-form/RHFUpload/index.bed8573e.js";
|
|
60
61
|
import * as Yup from "yup";
|
|
62
|
+
const COMPONENT_PREFIX = "m4l-dynamic-filter";
|
|
61
63
|
const COMPONENT_CLASS_NAME = "M4LDynamicFilter";
|
|
62
64
|
const ASSETS_URL = "frontend/components/dynamic_filter/assets/icons";
|
|
63
65
|
const ASSETS = {
|
|
@@ -149,12 +151,6 @@ function useDynamicFilter(selector, equalityFn) {
|
|
|
149
151
|
throw new Error("useDynamicFilterStore context must be use inside DynamicFilterContext");
|
|
150
152
|
return useStore(store, selector, equalityFn);
|
|
151
153
|
}
|
|
152
|
-
const DYNAMICFILTER_TEST_ID = "m4ldynamicfilter";
|
|
153
|
-
const PREFIX_TEST_ATTRIBUTE = "data-test";
|
|
154
|
-
const TEST_PROP_FIELDS = `${PREFIX_TEST_ATTRIBUTE}-${DYNAMICFILTER_TEST_ID}-fields`;
|
|
155
|
-
function getTestIdByClass(key, detailId) {
|
|
156
|
-
return `${DYNAMICFILTER_TEST_ID}-${key}` + (detailId ? "-" + detailId : "");
|
|
157
|
-
}
|
|
158
154
|
const DYNAMICFILTER_DICTIONARY_ID = "dynamic_filter";
|
|
159
155
|
function getDynamicFilterComponentsDictionary() {
|
|
160
156
|
return [DYNAMICFILTER_DICTIONARY_ID].concat(getCommonActionsDictionary());
|
|
@@ -191,6 +187,7 @@ const getDynamicFilterDictionary = (key) => {
|
|
|
191
187
|
};
|
|
192
188
|
function BooleanFilter() {
|
|
193
189
|
const classesContainerBooleanFilter = useDynamicFilter((state) => state.classes.containerBooleanFilter);
|
|
190
|
+
const dataTestId = useDynamicFilter((state) => state.classes.containerBooleanFilter);
|
|
194
191
|
const {
|
|
195
192
|
getLabel
|
|
196
193
|
} = useModuleDictionary();
|
|
@@ -207,7 +204,7 @@ function BooleanFilter() {
|
|
|
207
204
|
}], [getLabel]);
|
|
208
205
|
return /* @__PURE__ */ jsxs("div", {
|
|
209
206
|
...process.env.NODE_ENV !== "production" ? {
|
|
210
|
-
[TEST_PROP_ID]:
|
|
207
|
+
[TEST_PROP_ID]: getNameDataTestId(COMPONENT_PREFIX, "containerBooleanFilter", dataTestId)
|
|
211
208
|
} : {},
|
|
212
209
|
className: classesContainerBooleanFilter,
|
|
213
210
|
children: [/* @__PURE__ */ jsx(RHFAutocomplete, {
|
|
@@ -1030,7 +1027,8 @@ function DynamicFilterProvider(props) {
|
|
|
1030
1027
|
fields,
|
|
1031
1028
|
initialApplyedFilters = [],
|
|
1032
1029
|
onChangeFilters,
|
|
1033
|
-
children
|
|
1030
|
+
children,
|
|
1031
|
+
dataTestId = ""
|
|
1034
1032
|
} = props;
|
|
1035
1033
|
const {
|
|
1036
1034
|
getLabel
|
|
@@ -1053,6 +1051,7 @@ function DynamicFilterProvider(props) {
|
|
|
1053
1051
|
fields,
|
|
1054
1052
|
automatic,
|
|
1055
1053
|
getLabel,
|
|
1054
|
+
dataTestId,
|
|
1056
1055
|
ownerState: {
|
|
1057
1056
|
isSkeleton,
|
|
1058
1057
|
isDirty: !automatic,
|
|
@@ -1216,6 +1215,7 @@ function ApplyedFilter(props) {
|
|
|
1216
1215
|
hidePopoverFilter: hidePopupEdit,
|
|
1217
1216
|
showPopoverFilterForEdit: showPopupForEdit
|
|
1218
1217
|
} = useDynamicFilter((state) => state.actions);
|
|
1218
|
+
const dataTestId = useDynamicFilter((state) => state.dataTestId);
|
|
1219
1219
|
const labels = useMemo(() => {
|
|
1220
1220
|
return getLabelsFilter(props, getLabel, formatters);
|
|
1221
1221
|
}, [props, getLabel]);
|
|
@@ -1234,7 +1234,7 @@ function ApplyedFilter(props) {
|
|
|
1234
1234
|
return /* @__PURE__ */ jsxs(WrapperApplyedFilter, {
|
|
1235
1235
|
className: clsx(classesApplyedFilter, !isSetted ? `${COMPONENT_CLASS_NAME}-noSetted` : null),
|
|
1236
1236
|
...process.env.NODE_ENV !== "production" ? {
|
|
1237
|
-
[TEST_PROP_ID]:
|
|
1237
|
+
[TEST_PROP_ID]: getNameDataTestId(COMPONENT_PREFIX, "applyedFilter", `${dataTestId}-${field.name}`)
|
|
1238
1238
|
} : {},
|
|
1239
1239
|
children: [urlIcon && /* @__PURE__ */ jsx(IconButton, {
|
|
1240
1240
|
src: urlIcon,
|
|
@@ -1276,6 +1276,7 @@ const ContainerApplyedFilters = styled("div")(({
|
|
|
1276
1276
|
}));
|
|
1277
1277
|
function ApplyedFilters() {
|
|
1278
1278
|
const classesWrapperApplyedFilters = useDynamicFilter((state) => state.classes.wrapperApplyedFilters, shallow);
|
|
1279
|
+
const dataTestId = useDynamicFilter((state) => state.dataTestId, shallow);
|
|
1279
1280
|
const classesContainerApplyedFilters = useDynamicFilter((state) => state.classes.containerApplyedFilters, shallow);
|
|
1280
1281
|
const applyedFilters = useDynamicFilter((state) => state.applyedFilters, shallow);
|
|
1281
1282
|
const isSkeleton = useDynamicFilter((state) => state.ownerState.isSkeleton, shallow);
|
|
@@ -1287,13 +1288,13 @@ function ApplyedFilters() {
|
|
|
1287
1288
|
return /* @__PURE__ */ jsx(WrapperApplyedFilters, {
|
|
1288
1289
|
className: classesWrapperApplyedFilters,
|
|
1289
1290
|
...process.env.NODE_ENV !== "production" ? {
|
|
1290
|
-
[TEST_PROP_ID]:
|
|
1291
|
+
[TEST_PROP_ID]: getNameDataTestId(COMPONENT_PREFIX, "wrapperApplyedFilters", dataTestId)
|
|
1291
1292
|
} : {},
|
|
1292
1293
|
children: /* @__PURE__ */ jsx(ScrollBar, {
|
|
1293
1294
|
children: /* @__PURE__ */ jsx(ContainerApplyedFilters, {
|
|
1294
1295
|
className: classesContainerApplyedFilters,
|
|
1295
1296
|
...process.env.NODE_ENV !== "production" ? {
|
|
1296
|
-
[TEST_PROP_ID]:
|
|
1297
|
+
[TEST_PROP_ID]: getNameDataTestId(COMPONENT_PREFIX, "containerApplyedFilters", dataTestId)
|
|
1297
1298
|
} : {},
|
|
1298
1299
|
children: [...applyedFilters].sort((a, b) => a.isSetted === b.isSetted ? 0 : a.isSetted ? -1 : 1).reverse().map((filter) => /* @__PURE__ */ jsx(ApplyedFilter, {
|
|
1299
1300
|
...filter
|
|
@@ -1362,6 +1363,7 @@ styled("div")(() => ({
|
|
|
1362
1363
|
display: "block"
|
|
1363
1364
|
}));
|
|
1364
1365
|
function FilterButton() {
|
|
1366
|
+
const dataTestId = useDynamicFilter((state) => state.dataTestId);
|
|
1365
1367
|
const automatic = useDynamicFilter((state) => state.automatic);
|
|
1366
1368
|
const isValid = useDynamicFilter((state) => state.ownerState.isValid);
|
|
1367
1369
|
const isDirty = useDynamicFilter((state) => state.ownerState.isDirty);
|
|
@@ -1387,7 +1389,7 @@ function FilterButton() {
|
|
|
1387
1389
|
return /* @__PURE__ */ jsx(IconButton, {
|
|
1388
1390
|
className: classesFilterButton,
|
|
1389
1391
|
...process.env.NODE_ENV !== "production" ? {
|
|
1390
|
-
[TEST_PROP_ID]:
|
|
1392
|
+
[TEST_PROP_ID]: getNameDataTestId(COMPONENT_PREFIX, "classesFilterButton", dataTestId)
|
|
1391
1393
|
} : {},
|
|
1392
1394
|
dictionaryTooltipId: getDynamicFilterDictionary(isValid ? isDirty ? DICCTIONARY.filter_tooltip_dirty : DICCTIONARY.filter_tooltip_refresh : DICCTIONARY.filter_tooltip_invalid),
|
|
1393
1395
|
onClick: fireOnChangeFilters,
|
|
@@ -1403,6 +1405,7 @@ function PopoverMenuFields(props) {
|
|
|
1403
1405
|
} = props;
|
|
1404
1406
|
const fnAnchorEl = useDynamicFilter((state) => state.fnAnchorEl, shallow);
|
|
1405
1407
|
const classesPopUpMenuFields = useDynamicFilter((state) => state.classes.popoverMenuFields, shallow);
|
|
1408
|
+
const dataTestId = useDynamicFilter((state) => state.dataTestId, shallow);
|
|
1406
1409
|
const classesPopUpMenuFieldsPaper = useDynamicFilter((state) => state.classes.popoverMenuFieldsPaper, shallow);
|
|
1407
1410
|
const classespopoverMenuFieldsItem = useDynamicFilter((state) => state.classes.popoverMenuFieldsItem, shallow);
|
|
1408
1411
|
const classespopoverLabelMemuItem = useDynamicFilter((state) => state.classes.classespopoverLabelMemuItem, shallow);
|
|
@@ -1444,12 +1447,12 @@ function PopoverMenuFields(props) {
|
|
|
1444
1447
|
PaperProps: {
|
|
1445
1448
|
className: classesPopUpMenuFieldsPaper,
|
|
1446
1449
|
...process.env.NODE_ENV !== "production" ? {
|
|
1447
|
-
[TEST_PROP_ID]:
|
|
1450
|
+
[TEST_PROP_ID]: getNameDataTestId(COMPONENT_PREFIX, "popoverMenuFieldsPaper", dataTestId)
|
|
1448
1451
|
} : {}
|
|
1449
1452
|
},
|
|
1450
1453
|
children: Boolean(fnAnchorEl) && fields.map((field, index) => /* @__PURE__ */ createElement(MenuItem, {
|
|
1451
1454
|
...process.env.NODE_ENV !== "production" ? {
|
|
1452
|
-
[TEST_PROP_ID]:
|
|
1455
|
+
[TEST_PROP_ID]: getNameDataTestId(COMPONENT_PREFIX, "popoverMenuFieldsItem", `${dataTestId}-${field.name}`)
|
|
1453
1456
|
} : {},
|
|
1454
1457
|
className: classespopoverMenuFieldsItem,
|
|
1455
1458
|
key: `menu_action_${field.label ?? getLabel(field.dictionaryId)}`,
|
|
@@ -1469,6 +1472,7 @@ function InputFilter() {
|
|
|
1469
1472
|
const withAllField = useDynamicFilter((state) => state.withAllField);
|
|
1470
1473
|
const inputData = useDynamicFilter((state) => state.inputData);
|
|
1471
1474
|
const availableFields = useDynamicFilter((state) => state.availableFields, shallow);
|
|
1475
|
+
const dataTestId = useDynamicFilter((state) => state.dataTestId, shallow);
|
|
1472
1476
|
const classesContainerInputFilter = useDynamicFilter((state) => state.classes.containerInputFilter, shallow);
|
|
1473
1477
|
const isSkeleton = useDynamicFilter((state) => state.ownerState.isSkeleton, shallow);
|
|
1474
1478
|
const {
|
|
@@ -1569,7 +1573,7 @@ function InputFilter() {
|
|
|
1569
1573
|
return /* @__PURE__ */ jsxs("div", {
|
|
1570
1574
|
className: classesContainerInputFilter,
|
|
1571
1575
|
...process.env.NODE_ENV !== "production" ? {
|
|
1572
|
-
[TEST_PROP_ID]:
|
|
1576
|
+
[TEST_PROP_ID]: getNameDataTestId(COMPONENT_PREFIX, "containerInputFilter", dataTestId)
|
|
1573
1577
|
} : {},
|
|
1574
1578
|
children: [!isSkeleton ? /* @__PURE__ */ jsxs(Fragment, {
|
|
1575
1579
|
children: [/* @__PURE__ */ jsx(Icon, {
|
|
@@ -1623,6 +1627,7 @@ const PopoverFilter = () => {
|
|
|
1623
1627
|
const refPreviousPopoverFilterData = useRef(popoverFilterData);
|
|
1624
1628
|
const classesPopoverFilter = useDynamicFilter((state) => state.classes.popoverFilter, shallow);
|
|
1625
1629
|
const classesPopoverFilterPapper = useDynamicFilter((state) => state.classes.popoverFilterPaper, shallow);
|
|
1630
|
+
const dataTestId = useDynamicFilter((state) => state.dataTestId, shallow);
|
|
1626
1631
|
const classesPopoverFilterHeader = useDynamicFilter((state) => state.classes.popoverFilterHeader, shallow);
|
|
1627
1632
|
const classesPopoverHeaderTitle = useDynamicFilter((state) => state.classes.popoverHeaderTitle, shallow);
|
|
1628
1633
|
const classesPopoverContainerFields = useDynamicFilter((state) => state.classes.popoverContainerFields, shallow);
|
|
@@ -1722,7 +1727,7 @@ const PopoverFilter = () => {
|
|
|
1722
1727
|
PaperProps: {
|
|
1723
1728
|
className: classesPopoverFilterPapper,
|
|
1724
1729
|
...process.env.NODE_ENV !== "production" ? {
|
|
1725
|
-
[TEST_PROP_ID]:
|
|
1730
|
+
[TEST_PROP_ID]: getNameDataTestId(COMPONENT_PREFIX, "popoverFilterPaper", dataTestId)
|
|
1726
1731
|
} : {}
|
|
1727
1732
|
},
|
|
1728
1733
|
children: /* @__PURE__ */ jsxs(RHFormProvider, {
|
|
@@ -1756,8 +1761,10 @@ const PopoverFilter = () => {
|
|
|
1756
1761
|
})
|
|
1757
1762
|
});
|
|
1758
1763
|
};
|
|
1764
|
+
const TEST_PROPS_DATA = `data-testing`;
|
|
1759
1765
|
const InnerForHooks = () => {
|
|
1760
1766
|
const isMobile = useDynamicFilter((state) => state.ownerState.isMobile, shallow);
|
|
1767
|
+
const dataTestId = useDynamicFilter((state) => state.dataTestId, shallow);
|
|
1761
1768
|
const classesRoot = useDynamicFilter((state) => state.classes.root, shallow);
|
|
1762
1769
|
const containerClearFilter = useDynamicFilter((state) => state.classes.containerClearFilter, shallow);
|
|
1763
1770
|
const classesContainerFistRow = useDynamicFilter((state) => state.classes.containerFistRow, shallow);
|
|
@@ -1765,8 +1772,8 @@ const InnerForHooks = () => {
|
|
|
1765
1772
|
return /* @__PURE__ */ jsx(DynamicFilterRoot, {
|
|
1766
1773
|
className: classesRoot,
|
|
1767
1774
|
...process.env.NODE_ENV !== "production" ? {
|
|
1768
|
-
[
|
|
1769
|
-
"
|
|
1775
|
+
[TEST_PROPS_DATA]: JSON.stringify(fields),
|
|
1776
|
+
[TEST_PROP_ID]: getNameDataTestId(COMPONENT_PREFIX, "root", dataTestId)
|
|
1770
1777
|
} : {},
|
|
1771
1778
|
children: !isMobile ? /* @__PURE__ */ jsxs(Fragment, {
|
|
1772
1779
|
children: [/* @__PURE__ */ jsx(InputFilter, {}), /* @__PURE__ */ jsx(ApplyedFilters, {}), /* @__PURE__ */ jsx(PopoverFilter, {}), /* @__PURE__ */ jsxs("div", {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Field } from '../types';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const TEST_PROP_FIELDS: string;
|
|
2
|
+
export declare const DYNAMICFILTER_PROP_DATA = "m4l-dynamic-filter";
|
|
3
|
+
export declare const TEST_PROPS_DATA = "data-testing";
|
|
5
4
|
export declare const TEST_FIELDS: Field[];
|
|
6
5
|
export declare const INITIAL_APPLYED_FILTERS_EMPTY: never[];
|
|
@@ -213,4 +213,8 @@ export interface DynamicFilterProps {
|
|
|
213
213
|
* "onChangeFilters" Handler que se dispara cuando el filtro cambia en automatico, o cuando es manual y se presion a el boton de filtrar
|
|
214
214
|
*/
|
|
215
215
|
onChangeFilters: OnChangeFilters;
|
|
216
|
+
/**
|
|
217
|
+
* "dataTestId" Propiedad única que permite crear un selector atributo necesario para las pruebas del componente.
|
|
218
|
+
*/
|
|
219
|
+
dataTestId?: string;
|
|
216
220
|
}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { c as cloneLayoutItem, a as cloneLayout, b as compact, d as correctBounds, G as GridLayout, n as noop } from "../index.da6fd387.js";
|
|
2
|
+
import { useState, useRef, useEffect, useCallback } from "react";
|
|
3
|
+
import { useFirstRender } from "@m4l/graphics";
|
|
4
|
+
import { d as deepEqual } from "../../../node_modules.d73a220d.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
function getBreakpointFromWidth(breakpoints, width) {
|
|
7
|
+
const sorted = sortBreakpoints(breakpoints);
|
|
8
|
+
let matching = sorted[0];
|
|
9
|
+
for (let i = 1, len = sorted.length; i < len; i++) {
|
|
10
|
+
const breakpointName = sorted[i];
|
|
11
|
+
if (width > breakpoints[breakpointName])
|
|
12
|
+
matching = breakpointName;
|
|
13
|
+
}
|
|
14
|
+
return matching;
|
|
15
|
+
}
|
|
16
|
+
function getColsFromBreakpoint(breakpoint, cols) {
|
|
17
|
+
if (!cols[breakpoint]) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
"ResponsiveReactGridLayout: `cols` entry for breakpoint " + breakpoint + " is missing!"
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
return cols[breakpoint];
|
|
23
|
+
}
|
|
24
|
+
function findOrGenerateResponsiveLayout(layouts, breakpoints, breakpoint, lastBreakpoint, cols, compactType, brekpointsCols, colapsedHeight) {
|
|
25
|
+
let layout = layouts[breakpoint];
|
|
26
|
+
const breakpointsSorted = sortBreakpoints(breakpoints);
|
|
27
|
+
const indexBreakointInit = breakpointsSorted.indexOf(breakpoint);
|
|
28
|
+
let compareBreakpoint;
|
|
29
|
+
if (!layout) {
|
|
30
|
+
if (lastBreakpoint !== breakpoint && layouts[lastBreakpoint]) {
|
|
31
|
+
compareBreakpoint = lastBreakpoint;
|
|
32
|
+
} else {
|
|
33
|
+
const rotatedBreakpoints = [
|
|
34
|
+
...breakpointsSorted.splice(indexBreakointInit),
|
|
35
|
+
...breakpointsSorted.reverse()
|
|
36
|
+
];
|
|
37
|
+
for (let i = 0, len = rotatedBreakpoints.length; i < len; i++) {
|
|
38
|
+
const b = rotatedBreakpoints[i];
|
|
39
|
+
if (layouts[b]) {
|
|
40
|
+
compareBreakpoint = b;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (compareBreakpoint) {
|
|
46
|
+
layout = [];
|
|
47
|
+
for (let i = 0, len = layouts[compareBreakpoint].length; i < len; i++) {
|
|
48
|
+
const li = cloneLayoutItem(layouts[compareBreakpoint][i]);
|
|
49
|
+
if (brekpointsCols[compareBreakpoint]) {
|
|
50
|
+
const newW = Math.round(li.w * cols / brekpointsCols[compareBreakpoint]);
|
|
51
|
+
li.w = newW;
|
|
52
|
+
}
|
|
53
|
+
layout.push(li);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (!layout) {
|
|
57
|
+
layout = [];
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
layout = cloneLayout(layout);
|
|
61
|
+
}
|
|
62
|
+
layout = cloneLayout(layout);
|
|
63
|
+
const ret = compact(
|
|
64
|
+
correctBounds(layout, { cols }, colapsedHeight),
|
|
65
|
+
compactType,
|
|
66
|
+
cols,
|
|
67
|
+
colapsedHeight
|
|
68
|
+
);
|
|
69
|
+
return ret;
|
|
70
|
+
}
|
|
71
|
+
function sortBreakpoints(breakpoints) {
|
|
72
|
+
const keys = Object.keys(breakpoints);
|
|
73
|
+
return keys.sort(function(a, b) {
|
|
74
|
+
return breakpoints[a] - breakpoints[b];
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function getIndentationValue(param, breakpoint) {
|
|
78
|
+
if (!param)
|
|
79
|
+
return [0, 0];
|
|
80
|
+
return Array.isArray(param) ? param : param[breakpoint];
|
|
81
|
+
}
|
|
82
|
+
function addLayoutItemToBreakPointIfNoExists(layouts, breakpoint, layoutItem, cols, margin, containerPadding, rowHeight, containerHeight, currentBreakpoint) {
|
|
83
|
+
if (!layouts[breakpoint])
|
|
84
|
+
return;
|
|
85
|
+
if (layouts[breakpoint].findIndex((l) => l.i === layoutItem.i) === -1) {
|
|
86
|
+
const l = cloneLayoutItem(layoutItem);
|
|
87
|
+
const heigthUnits = containerHeight !== void 0 ? (containerHeight + getIndentationValue(margin, breakpoint)[1] - 2 * getIndentationValue(containerPadding, breakpoint)[1]) / (rowHeight + getIndentationValue(margin, breakpoint)[1]) : l.h;
|
|
88
|
+
if (l.freeMove) {
|
|
89
|
+
l.x = Math.round(cols[breakpoint] / 4);
|
|
90
|
+
l.y = Math.round(heigthUnits / 4);
|
|
91
|
+
l.w = Math.round(cols[breakpoint] / 2);
|
|
92
|
+
l.h = heigthUnits / 2;
|
|
93
|
+
if (breakpoint === "xxs") {
|
|
94
|
+
l.visible = false;
|
|
95
|
+
for (let index = 0; index < layouts[breakpoint].length; index++) {
|
|
96
|
+
if (layouts[breakpoint][index].freeMove) {
|
|
97
|
+
layouts[breakpoint][index].visible = false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (currentBreakpoint === "xxs") {
|
|
101
|
+
l.visible = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
l.w = cols[breakpoint];
|
|
106
|
+
l.h = Math.round(heigthUnits * 0.8);
|
|
107
|
+
}
|
|
108
|
+
if (l.freeMove) {
|
|
109
|
+
layouts[breakpoint].push(l);
|
|
110
|
+
} else {
|
|
111
|
+
layouts[breakpoint].unshift(l);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function addLayoutItemToBreakPoints(layouts, layoutItem, cols, margin, containerPadding, rowHeight, containerHeight, currentBreakpoint) {
|
|
116
|
+
const newLayouts = {};
|
|
117
|
+
for (const key in layouts) {
|
|
118
|
+
const layoutBreakpoint = cloneLayout(layouts[key]);
|
|
119
|
+
newLayouts[key] = layoutBreakpoint;
|
|
120
|
+
addLayoutItemToBreakPointIfNoExists(
|
|
121
|
+
newLayouts,
|
|
122
|
+
key,
|
|
123
|
+
layoutItem,
|
|
124
|
+
cols,
|
|
125
|
+
margin,
|
|
126
|
+
containerPadding,
|
|
127
|
+
rowHeight,
|
|
128
|
+
containerHeight,
|
|
129
|
+
currentBreakpoint
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
return newLayouts;
|
|
133
|
+
}
|
|
134
|
+
function cloneLayouts(layouts, layoutItemReplaceProps) {
|
|
135
|
+
const newLayouts = {};
|
|
136
|
+
for (const breakPoint in layouts) {
|
|
137
|
+
newLayouts[breakPoint] = cloneLayout(layouts[breakPoint], layoutItemReplaceProps);
|
|
138
|
+
}
|
|
139
|
+
return newLayouts;
|
|
140
|
+
}
|
|
141
|
+
function isEqualLayoutItem(layoutA, layoutB) {
|
|
142
|
+
if (layoutA.i !== layoutB.i) {
|
|
143
|
+
return false;
|
|
144
|
+
} else if (layoutA.x !== layoutB.x || layoutA.y !== layoutB.y || layoutA.w !== layoutB.w || layoutA.h !== layoutB.h || layoutA.colapsed !== layoutB.colapsed || layoutA.visible !== layoutB.visible || layoutA.freeMove !== layoutB.freeMove) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
function isEqualLayout(layoutA, layoutB) {
|
|
150
|
+
if (layoutA.length !== layoutB.length) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
for (let index = 0; index < layoutA.length; index++) {
|
|
154
|
+
if (!isEqualLayoutItem(layoutA[index], layoutB[index])) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
function isEqualLayouts(layoutsA, layoutsB) {
|
|
161
|
+
if (Object.keys(layoutsA).length !== Object.keys(layoutsB).length) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
for (const breakPoint in layoutsA) {
|
|
165
|
+
if (layoutsB[breakPoint]) {
|
|
166
|
+
if (!isEqualLayout(layoutsA[breakPoint], layoutsB[breakPoint])) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
} else {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
function generateInitialState(props) {
|
|
176
|
+
const {
|
|
177
|
+
width,
|
|
178
|
+
breakpoint,
|
|
179
|
+
breakpoints,
|
|
180
|
+
containerPadding = [10, 10],
|
|
181
|
+
containerMargin = [10, 10],
|
|
182
|
+
layouts: defaultLayouts = {},
|
|
183
|
+
cols,
|
|
184
|
+
compactType = null,
|
|
185
|
+
colapsedHeight = 2
|
|
186
|
+
} = props;
|
|
187
|
+
const newBreakpoint = breakpoint || getBreakpointFromWidth(breakpoints, width);
|
|
188
|
+
const colNo = getColsFromBreakpoint(newBreakpoint, cols);
|
|
189
|
+
let fireOnLoadLayoutChange = true;
|
|
190
|
+
const initialLayout = findOrGenerateResponsiveLayout(defaultLayouts, breakpoints, newBreakpoint, newBreakpoint, colNo, compactType, {
|
|
191
|
+
[newBreakpoint]: colNo
|
|
192
|
+
}, colapsedHeight);
|
|
193
|
+
if (defaultLayouts[newBreakpoint]) {
|
|
194
|
+
if (deepEqual(defaultLayouts[newBreakpoint], initialLayout)) {
|
|
195
|
+
fireOnLoadLayoutChange = false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const ret = {
|
|
199
|
+
layout: initialLayout,
|
|
200
|
+
breakpoint: newBreakpoint,
|
|
201
|
+
cols: colNo,
|
|
202
|
+
contaierMargin: getIndentationValue(containerMargin, newBreakpoint),
|
|
203
|
+
contaierPadding: getIndentationValue(containerPadding, newBreakpoint),
|
|
204
|
+
fireOnLoadLayoutChange
|
|
205
|
+
};
|
|
206
|
+
return ret;
|
|
207
|
+
}
|
|
208
|
+
function Responsive(props) {
|
|
209
|
+
const {
|
|
210
|
+
width,
|
|
211
|
+
height,
|
|
212
|
+
breakpoint,
|
|
213
|
+
compactType = null,
|
|
214
|
+
breakpoints = {
|
|
215
|
+
lg: 1200,
|
|
216
|
+
md: 996,
|
|
217
|
+
sm: 768,
|
|
218
|
+
xs: 480,
|
|
219
|
+
xxs: 1
|
|
220
|
+
},
|
|
221
|
+
cols = {
|
|
222
|
+
lg: 12,
|
|
223
|
+
md: 10,
|
|
224
|
+
sm: 6,
|
|
225
|
+
xs: 4,
|
|
226
|
+
xxs: 2
|
|
227
|
+
},
|
|
228
|
+
containerPadding = [10, 10],
|
|
229
|
+
containerMargin = [10, 10],
|
|
230
|
+
layouts = {},
|
|
231
|
+
onBreakpointChange = noop,
|
|
232
|
+
onLayoutChange = noop,
|
|
233
|
+
onContainerChange = noop,
|
|
234
|
+
layoutItemRender,
|
|
235
|
+
colapsedHeight = 2,
|
|
236
|
+
...other
|
|
237
|
+
} = props;
|
|
238
|
+
const [currentState, setCurrentState] = useState(() => generateInitialState(props));
|
|
239
|
+
const refLayouts = useRef({
|
|
240
|
+
layouts: {
|
|
241
|
+
...layouts,
|
|
242
|
+
[currentState.breakpoint]: currentState.layout
|
|
243
|
+
},
|
|
244
|
+
breakpoint: currentState.breakpoint,
|
|
245
|
+
breakpoints,
|
|
246
|
+
width,
|
|
247
|
+
height
|
|
248
|
+
});
|
|
249
|
+
const isFirstRender = useFirstRender([width, height, layouts]);
|
|
250
|
+
useEffect(() => {
|
|
251
|
+
onContainerChange({
|
|
252
|
+
containerWidth: refLayouts.current.width,
|
|
253
|
+
containerHeight: refLayouts.current.height,
|
|
254
|
+
containerMargin: currentState.contaierMargin,
|
|
255
|
+
containerPadding: currentState.contaierPadding,
|
|
256
|
+
breakpoint: currentState.breakpoint,
|
|
257
|
+
cols: currentState.cols
|
|
258
|
+
});
|
|
259
|
+
if (currentState.fireOnLoadLayoutChange) {
|
|
260
|
+
onLayoutChange(currentState.layout, {
|
|
261
|
+
...layouts,
|
|
262
|
+
[currentState.breakpoint]: currentState.layout
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
return () => {
|
|
266
|
+
console.debug("destruccion del componente");
|
|
267
|
+
};
|
|
268
|
+
}, []);
|
|
269
|
+
useEffect(() => {
|
|
270
|
+
if (isFirstRender) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
const newBreakpoint = breakpoint || getBreakpointFromWidth(breakpoints, width);
|
|
274
|
+
const newCols = getColsFromBreakpoint(newBreakpoint, cols);
|
|
275
|
+
const lastBreakpoint = currentState.breakpoint;
|
|
276
|
+
const newLayouts = {
|
|
277
|
+
...layouts
|
|
278
|
+
};
|
|
279
|
+
let newContainerMargin = currentState.contaierMargin;
|
|
280
|
+
let newContainerPadding = currentState.contaierPadding;
|
|
281
|
+
if (newBreakpoint !== currentState.breakpoint || newCols !== currentState.cols || breakpoints !== refLayouts.current.breakpoints || !isEqualLayouts(layouts, refLayouts.current.layouts)) {
|
|
282
|
+
console.debug("useEffect responsive con cambio de algo", newBreakpoint, lastBreakpoint);
|
|
283
|
+
newContainerMargin = getIndentationValue(containerMargin, newBreakpoint);
|
|
284
|
+
newContainerPadding = getIndentationValue(containerPadding, newBreakpoint);
|
|
285
|
+
if (!(lastBreakpoint in newLayouts)) {
|
|
286
|
+
console.error("useEffect casi imposible", lastBreakpoint, newLayouts);
|
|
287
|
+
newLayouts[lastBreakpoint] = cloneLayout(currentState.layout);
|
|
288
|
+
}
|
|
289
|
+
const layout = findOrGenerateResponsiveLayout(newLayouts, breakpoints, newBreakpoint, lastBreakpoint, newCols, compactType, cols, colapsedHeight);
|
|
290
|
+
newLayouts[newBreakpoint] = layout;
|
|
291
|
+
if (newBreakpoint !== currentState.breakpoint) {
|
|
292
|
+
onBreakpointChange(newBreakpoint, newCols, width, height);
|
|
293
|
+
}
|
|
294
|
+
refLayouts.current.layouts = newLayouts;
|
|
295
|
+
refLayouts.current.breakpoint = newBreakpoint;
|
|
296
|
+
refLayouts.current.breakpoints = breakpoints;
|
|
297
|
+
console.debug("useEffect responsive****", layout);
|
|
298
|
+
setCurrentState({
|
|
299
|
+
breakpoint: newBreakpoint,
|
|
300
|
+
layout,
|
|
301
|
+
cols: newCols,
|
|
302
|
+
contaierMargin: newContainerMargin,
|
|
303
|
+
contaierPadding: newContainerPadding
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
onContainerChange({
|
|
307
|
+
containerWidth: width,
|
|
308
|
+
containerHeight: height,
|
|
309
|
+
containerMargin: newContainerMargin,
|
|
310
|
+
containerPadding: newContainerPadding,
|
|
311
|
+
breakpoint: newBreakpoint,
|
|
312
|
+
cols: newCols
|
|
313
|
+
});
|
|
314
|
+
}, [width, height, layouts, breakpoint, breakpoints]);
|
|
315
|
+
useEffect(() => {
|
|
316
|
+
onLayoutChange(currentState.layout, refLayouts.current.layouts);
|
|
317
|
+
}, [currentState.layout]);
|
|
318
|
+
const localOnLayoutChange = useCallback((newlayout) => {
|
|
319
|
+
try {
|
|
320
|
+
refLayouts.current.layouts[refLayouts.current.breakpoint] = cloneLayout(newlayout);
|
|
321
|
+
} catch (error) {
|
|
322
|
+
console.warn("localOnLayoutChange error");
|
|
323
|
+
}
|
|
324
|
+
setCurrentState((prev) => ({
|
|
325
|
+
...prev,
|
|
326
|
+
layout: cloneLayout(newlayout)
|
|
327
|
+
}));
|
|
328
|
+
onLayoutChange(newlayout, {
|
|
329
|
+
...refLayouts.current.layouts
|
|
330
|
+
});
|
|
331
|
+
}, [onLayoutChange]);
|
|
332
|
+
return /* @__PURE__ */ jsx(GridLayout, {
|
|
333
|
+
width,
|
|
334
|
+
height,
|
|
335
|
+
colapsedHeight,
|
|
336
|
+
layoutItemRender,
|
|
337
|
+
containerMargin: currentState.contaierMargin,
|
|
338
|
+
containerPadding: getIndentationValue(containerPadding, currentState.breakpoint),
|
|
339
|
+
onLayoutChange: localOnLayoutChange,
|
|
340
|
+
layout: currentState.layout,
|
|
341
|
+
cols: currentState.cols,
|
|
342
|
+
compactType,
|
|
343
|
+
...other
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
export {
|
|
347
|
+
Responsive as R,
|
|
348
|
+
addLayoutItemToBreakPointIfNoExists as a,
|
|
349
|
+
addLayoutItemToBreakPoints as b,
|
|
350
|
+
isEqualLayouts as c,
|
|
351
|
+
cloneLayouts as d,
|
|
352
|
+
isEqualLayout as i
|
|
353
|
+
};
|