@m4l/components 0.2.4 → 0.2.6
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/components/DataGrid/{index.8fbcf147.js → index.d14640ca.js} +5 -5
- package/components/DataGrid/subcomponents/Actions/{index.bad681dc.js → index.3afb1664.js} +1 -1
- package/components/DynamicFilter/{index.cd7691e0.js → index.118c9d62.js} +1 -1
- package/components/ObjectLogs/{index.9c353020.js → index.070914d9.js} +2 -2
- package/components/PropertyValue/{index.37d91d0c.js → index.3b5c9ac7.js} +1 -1
- package/components/areas/components/AreasAdmin/{index.a14ba797.js → index.27c6d03e.js} +1 -1
- package/components/areas/components/AreasViewer/{index.c4545f2d.js → index.374d105d.js} +3 -3
- package/components/areas/contexts/AreasContext/{index.54893ef7.js → index.287ec96e.js} +2 -2
- package/components/areas/hooks/useAreas/{index.a15b3d9c.js → index.66c6cf2f.js} +1 -1
- package/components/hook-form/RHFRadioGroup/{index.7deb4e48.js → index.3b17819b.js} +1 -1
- package/components/index.d.ts +0 -1
- package/components/mui_extended/Accordion/{index.b9b427d7.js → index.22b4a776.js} +1 -1
- package/components/mui_extended/Tab/{index.724d5948.js → index.32349e95.js} +5 -5
- package/hooks/useTab/{index.991b13a7.js → index.f24a704c.js} +1 -1
- package/index.js +35 -52
- package/package.json +1 -1
- package/{vendor.8f8b0ac9.js → vendor.632361a1.js} +11 -13
- package/components/hook-form/HelperError/index.66bbcac3.js +0 -30
- package/components/hook-form/RHFHelperError/index.d.ts +0 -4
- package/components/maps/components/GpsTools/GpsTools.d.ts +0 -1
- package/components/maps/components/GpsTools/classes/index.d.ts +0 -4
- package/components/maps/components/GpsTools/classes/types.d.ts +0 -20
- package/components/maps/components/GpsTools/constants.d.ts +0 -8
- package/components/maps/components/GpsTools/contexts/GpsToolsContext/index.d.ts +0 -19
- package/components/maps/components/GpsTools/contexts/GpsToolsContext/store.d.ts +0 -16
- package/components/maps/components/GpsTools/contexts/GpsToolsContext/types.d.ts +0 -173
- package/components/maps/components/GpsTools/dictionary.d.ts +0 -64
- package/components/maps/components/GpsTools/hooks/useLayers/index.d.ts +0 -1
- package/components/maps/components/GpsTools/hooks/useMapTools/index.d.ts +0 -2
- package/components/maps/components/GpsTools/icons.d.ts +0 -15
- package/components/maps/components/GpsTools/index.889b0c39.js +0 -2313
- package/components/maps/components/GpsTools/index.d.ts +0 -2
- package/components/maps/components/GpsTools/subcomponents/TabTools/index.d.ts +0 -9
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/constants.d.ts +0 -7
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/hooks/useCheckedFeatures.d.ts +0 -9
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/hooks/useCheckedGeofences.d.ts +0 -4
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/hooks/useColumns.d.ts +0 -9
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/hooks/useMaster.d.ts +0 -20
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/hooks/useRowActionsGetter.d.ts +0 -9
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/index.d.ts +0 -1
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/model.d.ts +0 -122
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/ColumnSetCheckFormatter/index.d.ts +0 -8
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/ColumnSetCheckFormatter/types.d.ts +0 -5
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/constants.d.ts +0 -20
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/helpers.d.ts +0 -7
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/hooks/useDrawing.d.ts +0 -11
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/hooks/useSubmit.d.ts +0 -8
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/hooks/useSumbitErrorsFocus.d.ts +0 -5
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/hooks/useValidation.d.ts +0 -22
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/index.d.ts +0 -1
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/ConfigData/index.d.ts +0 -1
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/ConfigData/types.d.ts +0 -6
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/ConfigData/validations.d.ts +0 -5
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/GeneralData/index.d.ts +0 -1
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/GeneralData/types.d.ts +0 -7
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/GeneralData/validations.d.ts +0 -6
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/MyActions/index.d.ts +0 -1
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/MyTabs/index.d.ts +0 -1
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/StyleData/index.d.ts +0 -1
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/StyleData/subcomponents/FillData/index.d.ts +0 -1
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/StyleData/subcomponents/StrokeData/index.d.ts +0 -1
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/StyleData/types.d.ts +0 -10
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/types.d.ts +0 -25
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofencesList/index.d.ts +0 -1
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/GeofencesList/subcomponents/Filter/index.d.ts +0 -7
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/GeofencesTool/subcomponents/PolylineWithArrows/index.d.ts +0 -9
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/MeasureTool/constants.d.ts +0 -30
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/MeasureTool/hooks/useMeasure.d.ts +0 -31
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/MeasureTool/hooks/useValidation.d.ts +0 -10
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/MeasureTool/index.d.ts +0 -1
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/MeasureTool/subcomponents/MeasureData/index.d.ts +0 -1
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/MeasureTool/subcomponents/MeasureData/types.d.ts +0 -6
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/MeasureTool/subcomponents/MeasureData/validations.d.ts +0 -2
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/MeasureTool/subcomponents/MyActions/index.d.ts +0 -1
- package/components/maps/components/GpsTools/subcomponents/TabTools/subcomponents/MeasureTool/types.d.ts +0 -9
- package/components/maps/components/GpsTools/types.d.ts +0 -34
- package/components/maps/components/Map/Map.d.ts +0 -2
- package/components/maps/components/Map/classes/index.d.ts +0 -5
- package/components/maps/components/Map/classes/types.d.ts +0 -19
- package/components/maps/components/Map/constants.d.ts +0 -10
- package/components/maps/components/Map/contexts/MapContext/MapContext.d.ts +0 -19
- package/components/maps/components/Map/contexts/MapContext/helper.d.ts +0 -8
- package/components/maps/components/Map/contexts/MapContext/index.d.ts +0 -2
- package/components/maps/components/Map/contexts/MapContext/store.d.ts +0 -16
- package/components/maps/components/Map/contexts/MapContext/types.d.ts +0 -354
- package/components/maps/components/Map/hooks/useMapStore/index.d.ts +0 -3
- package/components/maps/components/Map/index.665e5c5d.js +0 -474
- package/components/maps/components/Map/index.d.ts +0 -5
- package/components/maps/components/Map/subcomponents/LayersContainer/index.d.ts +0 -2
- package/components/maps/components/Map/subcomponents/LeafletLayer/index.d.ts +0 -3
- package/components/maps/components/Map/subcomponents/LeafletLayer/types.d.ts +0 -2
- package/components/maps/components/Map/subcomponents/MainTools/index.d.ts +0 -2
- package/components/maps/components/Map/subcomponents/MainTools/types.d.ts +0 -5
- package/components/maps/components/Map/types.d.ts +0 -28
- package/components/maps/index.d.ts +0 -3
- package/hooks/useFormReadyForUpdate/index.d.ts +0 -6
- package/hooks/useFormReadyForUpdate/index.f60f500e.js +0 -20
|
@@ -1,474 +0,0 @@
|
|
|
1
|
-
import "leaflet/dist/leaflet.css";
|
|
2
|
-
import { MapContainer, LayerGroup, useMap, TileLayer } from "react-leaflet";
|
|
3
|
-
import { styled } from "@mui/material/styles";
|
|
4
|
-
import { shallow } from "zustand/shallow";
|
|
5
|
-
import React__default, { useEffect, useState, useCallback, createContext, useRef, useContext } from "react";
|
|
6
|
-
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { createStore, useStore } from "zustand";
|
|
8
|
-
import L__default from "leaflet";
|
|
9
|
-
import { T as ToggleButton } from "../../../mui_extended/ToggleButton/index.21a1f8e5.js";
|
|
10
|
-
import { T as ToggleIconButton } from "../../../mui_extended/ToggleIconButton/index.00f13c40.js";
|
|
11
|
-
import { useResponsiveDesktop, useFirstRender } from "@m4l/graphics";
|
|
12
|
-
import { useModuleDictionary, useModuleSkeleton } from "@m4l/core";
|
|
13
|
-
import { devtools } from "zustand/middleware";
|
|
14
|
-
import { immer } from "zustand/middleware/immer";
|
|
15
|
-
import { generateUtilityClasses } from "@mui/material";
|
|
16
|
-
import { unstable_composeClasses } from "@mui/base";
|
|
17
|
-
import { g as getComponentUtilityClass } from "../../../../utils/index.de903261.js";
|
|
18
|
-
import { cloneDeep } from "lodash";
|
|
19
|
-
import { G as GpsToolsContext } from "../GpsTools/index.889b0c39.js";
|
|
20
|
-
const COMPONENT_CLASS_NAME = "M4LMap";
|
|
21
|
-
const MAP_ZINDEX_DEFAULT = 0;
|
|
22
|
-
const MAP_ZINDEX_OVER_MAP = 1100;
|
|
23
|
-
const mapClasses = generateUtilityClasses(COMPONENT_CLASS_NAME, [
|
|
24
|
-
"root",
|
|
25
|
-
"mapContainer",
|
|
26
|
-
"svgLayersContainer",
|
|
27
|
-
"svgLayer",
|
|
28
|
-
"svgLayerMultiPoints",
|
|
29
|
-
"layerMarker",
|
|
30
|
-
"mainToolsRoot",
|
|
31
|
-
"measureMarkerRoot",
|
|
32
|
-
"measureMarkerContainer",
|
|
33
|
-
"measureMarkerContainerRhomb",
|
|
34
|
-
"measureMarkerContainerSlot",
|
|
35
|
-
"measureMarkerContainerSlotNumber",
|
|
36
|
-
"measureLabelMarkerRoot",
|
|
37
|
-
"measureLabelMarkerContainer",
|
|
38
|
-
"measureLabelMarkerDistance",
|
|
39
|
-
"measureLabelMarkerRemove"
|
|
40
|
-
]);
|
|
41
|
-
const useMapUtilityClasses = (ownerState) => {
|
|
42
|
-
const slots = {
|
|
43
|
-
root: ["root"],
|
|
44
|
-
mapContainer: ["mapContainer"],
|
|
45
|
-
svgLayersContainer: ["svgLayersContainer"],
|
|
46
|
-
svgLayer: ["svgLayer"],
|
|
47
|
-
svgLayerMultiPoints: ["svgLayerMultiPoints"],
|
|
48
|
-
layerMarker: ["layerMarker"],
|
|
49
|
-
mainToolsRoot: ["mainToolsRoot"],
|
|
50
|
-
measureMarkerRoot: ["measureMarkerRoot"],
|
|
51
|
-
measureMarkerContainer: ["measureMarkerContainer"],
|
|
52
|
-
measureMarkerContainerRhomb: ["measureMarkerContainerRhomb"],
|
|
53
|
-
measureMarkerContainerSlot: ["measureMarkerContainerSlot"],
|
|
54
|
-
measureMarkerContainerSlotNumber: ["measureMarkerContainerSlotNumber"],
|
|
55
|
-
measureLabelMarkerRoot: ["measureLabelMarkerRoot"],
|
|
56
|
-
measureLabelMarkerContainer: ["measureLabelMarkerContainer"],
|
|
57
|
-
measureLabelMarkerDistance: ["measureLabelMarkerDistance"],
|
|
58
|
-
measureLabelMarkerRemove: ["measureLabelMarkerRemove"]
|
|
59
|
-
};
|
|
60
|
-
return unstable_composeClasses(slots, getComponentUtilityClass(COMPONENT_CLASS_NAME), {});
|
|
61
|
-
};
|
|
62
|
-
const MapRootContainer = styled(MapContainer)`
|
|
63
|
-
width: 100%;
|
|
64
|
-
height: 100%;
|
|
65
|
-
flex-grow: 1;
|
|
66
|
-
overflow: auto;
|
|
67
|
-
position: relative;
|
|
68
|
-
|
|
69
|
-
.leaflet-control-scale-line{
|
|
70
|
-
color: red; //Ejemplo de como estilar el control de scala
|
|
71
|
-
}
|
|
72
|
-
.${mapClasses.mainToolsRoot} {
|
|
73
|
-
display: flex;
|
|
74
|
-
top: 20px;
|
|
75
|
-
left: 80px;
|
|
76
|
-
position: absolute;
|
|
77
|
-
background-color: gray;
|
|
78
|
-
z-index: ${MAP_ZINDEX_OVER_MAP};
|
|
79
|
-
}
|
|
80
|
-
.${mapClasses.svgLayersContainer} {
|
|
81
|
-
width: 100%;
|
|
82
|
-
height: 100%;
|
|
83
|
-
position: absolute;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.${mapClasses.svgLayer} {
|
|
87
|
-
z-index: 1;
|
|
88
|
-
width: 100%;
|
|
89
|
-
height: 100%;
|
|
90
|
-
overflow: hidden;
|
|
91
|
-
user-select: none;
|
|
92
|
-
pointer-events: none;
|
|
93
|
-
position: absolute !important;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.${mapClasses.layerMarker} {
|
|
97
|
-
z-index: 2;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
.${mapClasses.measureMarkerRoot} {
|
|
103
|
-
--color: red;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.${mapClasses.measureMarkerContainer} {
|
|
107
|
-
position: relative;
|
|
108
|
-
cursor: pointer;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.${mapClasses.measureMarkerContainerRhomb} {
|
|
112
|
-
position: absolute;
|
|
113
|
-
filter: drop-shadow(0px 0px 3px rgba(0,0,0,.4));
|
|
114
|
-
width: 31px;
|
|
115
|
-
height: 31px;
|
|
116
|
-
border-radius: 50% 50% 50% 0;
|
|
117
|
-
border: 4px solid var(--color);
|
|
118
|
-
background-color: var(--color);
|
|
119
|
-
transform: rotate(-45deg);
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
.${mapClasses.measureMarkerContainerSlot} {
|
|
123
|
-
position: absolute;
|
|
124
|
-
background: #fff;
|
|
125
|
-
border-radius: 50%;
|
|
126
|
-
overflow: hidden;
|
|
127
|
-
top: 3px;
|
|
128
|
-
left: 3px;
|
|
129
|
-
width: 25px;
|
|
130
|
-
height: 24px;
|
|
131
|
-
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
.${mapClasses.measureMarkerContainerSlotNumber} {
|
|
135
|
-
font-size: 14px;
|
|
136
|
-
font-weight: 600;
|
|
137
|
-
text-align: center;
|
|
138
|
-
margin-top: 1px;
|
|
139
|
-
color: black;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.${mapClasses.measureLabelMarkerContainer} {
|
|
143
|
-
background-color:white;
|
|
144
|
-
border:1px solid gray;
|
|
145
|
-
color:#fff;
|
|
146
|
-
width:80px;
|
|
147
|
-
margin-left:15px;
|
|
148
|
-
margin-top:15px;
|
|
149
|
-
}
|
|
150
|
-
.${mapClasses.measureLabelMarkerDistance} {
|
|
151
|
-
color:gray;
|
|
152
|
-
}
|
|
153
|
-
.${mapClasses.measureLabelMarkerRemove} {
|
|
154
|
-
color:blue;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
`;
|
|
158
|
-
const RenderByEachFeatureComponent = ({
|
|
159
|
-
renderFeature,
|
|
160
|
-
...props
|
|
161
|
-
}) => {
|
|
162
|
-
const feature = renderFeature(props);
|
|
163
|
-
return feature ? /* @__PURE__ */ jsx(Fragment, {
|
|
164
|
-
children: feature
|
|
165
|
-
}) : null;
|
|
166
|
-
};
|
|
167
|
-
const MemonizedRenderByEachFeatureComponent = React__default.memo(RenderByEachFeatureComponent);
|
|
168
|
-
const LeafletLayer = (props) => {
|
|
169
|
-
const {
|
|
170
|
-
layerId
|
|
171
|
-
} = props;
|
|
172
|
-
const featureIdOrCollection = useMapStore((state) => {
|
|
173
|
-
const geoJsonObject = state.hashLayers[layerId]?.geoJsonObject;
|
|
174
|
-
if (geoJsonObject && geoJsonObject.object.type === "Feature") {
|
|
175
|
-
return geoJsonObject.object.id;
|
|
176
|
-
} else if (geoJsonObject && geoJsonObject.object.type === "FeatureCollection") {
|
|
177
|
-
return geoJsonObject && geoJsonObject.object.features.map((feature) => feature.id);
|
|
178
|
-
}
|
|
179
|
-
}, shallow);
|
|
180
|
-
const renderFeature = useMapStore((state) => state.hashLayers[layerId]?.renderFeature, shallow);
|
|
181
|
-
if (!featureIdOrCollection || !renderFeature) {
|
|
182
|
-
return null;
|
|
183
|
-
}
|
|
184
|
-
if (!Array.isArray(featureIdOrCollection)) {
|
|
185
|
-
return /* @__PURE__ */ jsx(RenderByEachFeatureComponent, {
|
|
186
|
-
renderFeature,
|
|
187
|
-
id: featureIdOrCollection,
|
|
188
|
-
layerId
|
|
189
|
-
});
|
|
190
|
-
} else {
|
|
191
|
-
return /* @__PURE__ */ jsx(LayerGroup, {
|
|
192
|
-
children: featureIdOrCollection.map((featureId) => {
|
|
193
|
-
return /* @__PURE__ */ jsx(MemonizedRenderByEachFeatureComponent, {
|
|
194
|
-
renderFeature,
|
|
195
|
-
id: featureId,
|
|
196
|
-
layerId
|
|
197
|
-
}, `k_${featureId}`);
|
|
198
|
-
})
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
const LayersContainer = () => {
|
|
203
|
-
const layersId = useMapStore((state) => state.layersIds, shallow);
|
|
204
|
-
const isSkeleton = useMapStore((state) => state.ownerState.isSkeleton, shallow);
|
|
205
|
-
const map = useMap();
|
|
206
|
-
useEffect(() => {
|
|
207
|
-
console.log("LayersContainer useEffect", map);
|
|
208
|
-
if (!map) {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
L__default.control.scale().addTo(map);
|
|
212
|
-
}, [map]);
|
|
213
|
-
if (isSkeleton) {
|
|
214
|
-
return null;
|
|
215
|
-
}
|
|
216
|
-
console.log("LayersContainer Render", layersId);
|
|
217
|
-
return /* @__PURE__ */ jsx(React__default.Fragment, {
|
|
218
|
-
children: layersId.map((l) => /* @__PURE__ */ jsx(LeafletLayer, {
|
|
219
|
-
layerId: l
|
|
220
|
-
}, l))
|
|
221
|
-
});
|
|
222
|
-
};
|
|
223
|
-
function MainTools(props) {
|
|
224
|
-
const {
|
|
225
|
-
gpsTools,
|
|
226
|
-
aditionalMainTools
|
|
227
|
-
} = props;
|
|
228
|
-
const [isPressed, setIsPressed] = useState(true);
|
|
229
|
-
const onClick = useCallback((e, isPressed2) => {
|
|
230
|
-
setIsPressed(!!isPressed2);
|
|
231
|
-
e.stopPropagation();
|
|
232
|
-
console.log("ButtonisPressed", isPressed2);
|
|
233
|
-
}, []);
|
|
234
|
-
console.log("Render MainTools", gpsTools);
|
|
235
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
236
|
-
className: mapClasses.mainToolsRoot,
|
|
237
|
-
children: [/* @__PURE__ */ jsx(ToggleButton, {
|
|
238
|
-
defaultIsPressed: true,
|
|
239
|
-
onClick,
|
|
240
|
-
children: "Hola"
|
|
241
|
-
}), /* @__PURE__ */ jsx(ToggleIconButton, {
|
|
242
|
-
src: "",
|
|
243
|
-
onClick
|
|
244
|
-
}), isPressed && gpsTools, aditionalMainTools]
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
function Map(props) {
|
|
248
|
-
const {
|
|
249
|
-
children,
|
|
250
|
-
gpsTools,
|
|
251
|
-
aditionalMainTools
|
|
252
|
-
} = props;
|
|
253
|
-
return /* @__PURE__ */ jsxs(MapRootContainer, {
|
|
254
|
-
className: mapClasses.root,
|
|
255
|
-
center: [6.215749485905093, -75.58622905191254],
|
|
256
|
-
zoom: 16,
|
|
257
|
-
maxZoom: 22,
|
|
258
|
-
preferCanvas: true,
|
|
259
|
-
children: [/* @__PURE__ */ jsx(TileLayer, {
|
|
260
|
-
url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
261
|
-
attribution: '\xA9 <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
|
262
|
-
}), /* @__PURE__ */ jsx(LayersContainer, {}), children, /* @__PURE__ */ jsx(MainTools, {
|
|
263
|
-
aditionalMainTools,
|
|
264
|
-
gpsTools
|
|
265
|
-
})]
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
const updateOwnerStateClasses = (state) => {
|
|
269
|
-
state.classes = useMapUtilityClasses(state.ownerState);
|
|
270
|
-
};
|
|
271
|
-
const createMapStore = (initProps) => {
|
|
272
|
-
const startProps = {
|
|
273
|
-
classes: useMapUtilityClasses(initProps.ownerState),
|
|
274
|
-
layersIds: [],
|
|
275
|
-
hashLayers: {},
|
|
276
|
-
...initProps
|
|
277
|
-
};
|
|
278
|
-
return createStore(
|
|
279
|
-
devtools(
|
|
280
|
-
immer((set, get) => ({
|
|
281
|
-
...startProps,
|
|
282
|
-
mapActions: {
|
|
283
|
-
init: (layersStore) => {
|
|
284
|
-
set((state) => {
|
|
285
|
-
for (let index = 0; index < layersStore.length; index++) {
|
|
286
|
-
state.hashLayers[layersStore[index].layerId] = cloneDeep(
|
|
287
|
-
layersStore[index]
|
|
288
|
-
);
|
|
289
|
-
state.layersIds.push(layersStore[index].layerId);
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
},
|
|
293
|
-
setMapState: (status) => {
|
|
294
|
-
set((state) => {
|
|
295
|
-
state.ownerState.status = status;
|
|
296
|
-
});
|
|
297
|
-
},
|
|
298
|
-
setDataLayer: (layerId, geoJson) => {
|
|
299
|
-
if (!get().hashLayers[layerId]) {
|
|
300
|
-
throw new Error(`Layer with id ${layerId} not found`);
|
|
301
|
-
}
|
|
302
|
-
set((state) => {
|
|
303
|
-
const layer = state.hashLayers[layerId];
|
|
304
|
-
layer.geoJsonObject = geoJson;
|
|
305
|
-
});
|
|
306
|
-
},
|
|
307
|
-
getFeatureIds: (layerId) => {
|
|
308
|
-
if (!get().hashLayers[layerId]) {
|
|
309
|
-
throw new Error(`Layer with id ${layerId} not found`);
|
|
310
|
-
}
|
|
311
|
-
const geoJsonObject = get().hashLayers[layerId]?.geoJsonObject;
|
|
312
|
-
if (geoJsonObject && geoJsonObject.object.type === "Feature") {
|
|
313
|
-
return [geoJsonObject.object.id];
|
|
314
|
-
} else if (geoJsonObject && geoJsonObject.object.type === "FeatureCollection") {
|
|
315
|
-
return geoJsonObject.object.features.map((feature) => feature.id);
|
|
316
|
-
}
|
|
317
|
-
return [];
|
|
318
|
-
},
|
|
319
|
-
setFeatureData: (layerId, featureId, geometry, properties) => {
|
|
320
|
-
if (!get().hashLayers[layerId]) {
|
|
321
|
-
throw new Error(`Layer with id ${layerId} not found`);
|
|
322
|
-
}
|
|
323
|
-
set((state) => {
|
|
324
|
-
if (state.hashLayers[layerId].geoJsonObject?.object.type === "FeatureCollection") {
|
|
325
|
-
const layer = state.hashLayers[layerId].geoJsonObject?.object;
|
|
326
|
-
let feature = layer.features.find((f) => f.id === featureId);
|
|
327
|
-
if (feature) {
|
|
328
|
-
feature.geometry = cloneDeep(geometry);
|
|
329
|
-
feature.properties = cloneDeep(properties);
|
|
330
|
-
} else {
|
|
331
|
-
feature = {
|
|
332
|
-
type: "Feature",
|
|
333
|
-
geometry,
|
|
334
|
-
id: featureId,
|
|
335
|
-
properties
|
|
336
|
-
};
|
|
337
|
-
layer.features.push(feature);
|
|
338
|
-
}
|
|
339
|
-
} else if (state.hashLayers[layerId].geoJsonObject?.object.type === "Feature") {
|
|
340
|
-
const layer = state.hashLayers[layerId].geoJsonObject?.object;
|
|
341
|
-
layer.id = featureId;
|
|
342
|
-
layer.geometry = cloneDeep(geometry);
|
|
343
|
-
layer.properties = cloneDeep(properties);
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
},
|
|
347
|
-
removeFeature: (layerId, featureId) => {
|
|
348
|
-
if (!get().hashLayers[layerId]) {
|
|
349
|
-
throw new Error(`Layer with id ${layerId} not found`);
|
|
350
|
-
}
|
|
351
|
-
set((state) => {
|
|
352
|
-
if (state.hashLayers[layerId].geoJsonObject?.object.type === "FeatureCollection") {
|
|
353
|
-
const layer = state.hashLayers[layerId].geoJsonObject?.object;
|
|
354
|
-
const index = layer.features.findIndex((f) => f.id === featureId);
|
|
355
|
-
if (index !== -1) {
|
|
356
|
-
layer.features.splice(index, 1);
|
|
357
|
-
}
|
|
358
|
-
} else if (state.hashLayers[layerId].geoJsonObject?.object.type === "Feature") {
|
|
359
|
-
const layer = state.hashLayers[layerId].geoJsonObject?.object;
|
|
360
|
-
layer.geometry = { type: "Point", coordinates: [0, 0] };
|
|
361
|
-
layer.properties = {};
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
},
|
|
365
|
-
setLayerRenderProp: (layerId, renderProp) => {
|
|
366
|
-
set((state) => {
|
|
367
|
-
state.hashLayers[layerId].renderFeature = renderProp;
|
|
368
|
-
});
|
|
369
|
-
},
|
|
370
|
-
addLayer: (layer) => {
|
|
371
|
-
if (get().hashLayers[layer.layerId]) {
|
|
372
|
-
throw new Error(`Layer with id ${layer.layerId} already exists`);
|
|
373
|
-
}
|
|
374
|
-
set((state) => {
|
|
375
|
-
state.hashLayers[layer.layerId] = layer;
|
|
376
|
-
state.layersIds.push(layer.layerId);
|
|
377
|
-
});
|
|
378
|
-
},
|
|
379
|
-
removeLayer: (layerId) => {
|
|
380
|
-
if (!get().hashLayers[layerId]) {
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
set((state) => {
|
|
384
|
-
state.layersIds.splice(state.layersIds.indexOf(layerId), 1);
|
|
385
|
-
delete state.hashLayers[layerId];
|
|
386
|
-
});
|
|
387
|
-
},
|
|
388
|
-
setHandlerGetLabel: (newHandler) => {
|
|
389
|
-
set((state) => {
|
|
390
|
-
state.getLabel = newHandler;
|
|
391
|
-
});
|
|
392
|
-
},
|
|
393
|
-
setExternalState: (newExternalState) => {
|
|
394
|
-
set((state) => {
|
|
395
|
-
state.ownerState = { ...state.ownerState, ...newExternalState };
|
|
396
|
-
updateOwnerStateClasses(state);
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
})),
|
|
401
|
-
{ name: `Map store` }
|
|
402
|
-
)
|
|
403
|
-
);
|
|
404
|
-
};
|
|
405
|
-
const MapContext = createContext(null);
|
|
406
|
-
function MapProvider(props) {
|
|
407
|
-
const {
|
|
408
|
-
children,
|
|
409
|
-
initialLayers
|
|
410
|
-
} = props;
|
|
411
|
-
const {
|
|
412
|
-
getLabel
|
|
413
|
-
} = useModuleDictionary();
|
|
414
|
-
const isDesktop = useResponsiveDesktop();
|
|
415
|
-
const isSkeleton = useModuleSkeleton();
|
|
416
|
-
const isFirstRender = useFirstRender([getLabel]);
|
|
417
|
-
const mapStoreRef = useRef();
|
|
418
|
-
if (!mapStoreRef.current) {
|
|
419
|
-
mapStoreRef.current = createMapStore({
|
|
420
|
-
getLabel,
|
|
421
|
-
ownerState: {
|
|
422
|
-
status: "init",
|
|
423
|
-
isMobile: !isDesktop,
|
|
424
|
-
isSkeleton,
|
|
425
|
-
focus: false
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
mapStoreRef.current?.getState().mapActions.init(initialLayers || []);
|
|
429
|
-
}
|
|
430
|
-
const {
|
|
431
|
-
setHandlerGetLabel,
|
|
432
|
-
setExternalState
|
|
433
|
-
} = useStore(mapStoreRef.current, (state) => state.mapActions, shallow);
|
|
434
|
-
useEffect(() => {
|
|
435
|
-
if (!isFirstRender) {
|
|
436
|
-
setHandlerGetLabel(getLabel);
|
|
437
|
-
}
|
|
438
|
-
}, [getLabel]);
|
|
439
|
-
useEffect(() => {
|
|
440
|
-
if (isFirstRender) {
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
setExternalState({
|
|
444
|
-
isMobile: !isDesktop,
|
|
445
|
-
isSkeleton
|
|
446
|
-
});
|
|
447
|
-
}, [isDesktop, isSkeleton]);
|
|
448
|
-
return /* @__PURE__ */ jsx(MapContext.Provider, {
|
|
449
|
-
value: mapStoreRef.current,
|
|
450
|
-
children
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
function useMapStore(selector, equalityFn) {
|
|
454
|
-
const context = useContext(MapContext);
|
|
455
|
-
if (!context)
|
|
456
|
-
throw new Error("useMapStore context must be use inside MapContext");
|
|
457
|
-
return useStore(context, selector, equalityFn);
|
|
458
|
-
}
|
|
459
|
-
function useMapToolsStore(selector, equalityFn) {
|
|
460
|
-
const context = useContext(GpsToolsContext);
|
|
461
|
-
if (!context)
|
|
462
|
-
throw new Error("useMapToolsStore context must be use inside GpsToolsContext");
|
|
463
|
-
return useStore(context, selector, equalityFn);
|
|
464
|
-
}
|
|
465
|
-
export {
|
|
466
|
-
MAP_ZINDEX_DEFAULT as M,
|
|
467
|
-
useMapStore as a,
|
|
468
|
-
MAP_ZINDEX_OVER_MAP as b,
|
|
469
|
-
Map as c,
|
|
470
|
-
MapProvider as d,
|
|
471
|
-
MapContext as e,
|
|
472
|
-
mapClasses as m,
|
|
473
|
-
useMapToolsStore as u
|
|
474
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { Map } from './Map';
|
|
2
|
-
export type { MapProps } from './types';
|
|
3
|
-
export { MapProvider, MapContext } from './contexts/MapContext/MapContext';
|
|
4
|
-
export { useMapStore } from './hooks/useMapStore';
|
|
5
|
-
export type { RendePropFeatureArgs, ComponentRenderPropFeature, FeatureId, FeatureCollection, Feature, Geometry } from './contexts/MapContext';
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
export declare type Localization = {
|
|
3
|
-
/**
|
|
4
|
-
* "lat" Posición en del eje "Y" en grados.
|
|
5
|
-
*/
|
|
6
|
-
lat: number;
|
|
7
|
-
/**
|
|
8
|
-
* "lng" Posición en del eje "X" en grados.
|
|
9
|
-
*/
|
|
10
|
-
lng: number;
|
|
11
|
-
};
|
|
12
|
-
export declare type Point = {
|
|
13
|
-
/**
|
|
14
|
-
* "x" Posición en del eje "X" en pixeles.
|
|
15
|
-
*/
|
|
16
|
-
x: number;
|
|
17
|
-
/**
|
|
18
|
-
* "y" Posición en del eje "Y" en pixeles.
|
|
19
|
-
*/
|
|
20
|
-
y: number;
|
|
21
|
-
};
|
|
22
|
-
export interface MapProps {
|
|
23
|
-
children: ReactNode;
|
|
24
|
-
startLat?: number;
|
|
25
|
-
startLon?: number;
|
|
26
|
-
gpsTools?: ReactNode;
|
|
27
|
-
aditionalMainTools?: ReactNode;
|
|
28
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { Map, MapProvider, MapContext, useMapStore } from './components/Map';
|
|
2
|
-
export type { MapProps, RendePropFeatureArgs, ComponentRenderPropFeature, FeatureId, FeatureCollection, Feature, Geometry } from './components/Map';
|
|
3
|
-
export { GpsTools, useMapToolsStore } from './components/GpsTools';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from "react";
|
|
2
|
-
import { useFormContext, useWatch } from "react-hook-form";
|
|
3
|
-
function useFormReadyForUpdate() {
|
|
4
|
-
const [readyToUpdate, setReadyToUpdate] = useState(false);
|
|
5
|
-
const { control } = useFormContext();
|
|
6
|
-
const statusLoad = useWatch({
|
|
7
|
-
control,
|
|
8
|
-
name: "statusLoad"
|
|
9
|
-
});
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (statusLoad !== "ready") {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
setReadyToUpdate(true);
|
|
15
|
-
}, [statusLoad]);
|
|
16
|
-
return readyToUpdate;
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
useFormReadyForUpdate as u
|
|
20
|
-
};
|