@m4l/gclick 0.3.7 → 0.3.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.
Files changed (89) hide show
  1. package/components/ReportsViewer/subcomponents/ReportSheetMapFitBounds/ReportSheetMapFitBounds.d.ts +3 -2
  2. package/components/ReportsViewer/subcomponents/ReportSheetMapFitBounds/ReportSheetMapFitBounds.d.ts.map +1 -1
  3. package/components/ReportsViewer/subcomponents/ReportSheetMapFitBounds/ReportSheetMapFitBounds.js +16 -20
  4. package/components/index.d.ts +1 -0
  5. package/components/index.d.ts.map +1 -1
  6. package/components/maps/components/GpsMap/constants.d.ts +1 -0
  7. package/components/maps/components/GpsMap/constants.d.ts.map +1 -1
  8. package/components/maps/components/GpsMap/constants.js +16 -14
  9. package/components/maps/components/GpsMap/contexts/MapContext/MapContext.d.ts +2 -1
  10. package/components/maps/components/GpsMap/contexts/MapContext/MapContext.d.ts.map +1 -1
  11. package/components/maps/components/GpsMap/contexts/MapContext/helpers/featureObservability.d.ts +28 -0
  12. package/components/maps/components/GpsMap/contexts/MapContext/helpers/featureObservability.d.ts.map +1 -0
  13. package/components/maps/components/GpsMap/contexts/MapContext/helpers/featureObservability.js +111 -0
  14. package/components/maps/components/GpsMap/contexts/MapContext/helpers/geoJsonBounds.d.ts +9 -0
  15. package/components/maps/components/GpsMap/contexts/MapContext/helpers/geoJsonBounds.d.ts.map +1 -0
  16. package/components/maps/components/GpsMap/contexts/MapContext/helpers/geoJsonBounds.js +183 -0
  17. package/components/maps/components/GpsMap/contexts/MapContext/helpers/helpers.d.ts +112 -0
  18. package/components/maps/components/GpsMap/contexts/MapContext/helpers/helpers.d.ts.map +1 -0
  19. package/components/maps/components/GpsMap/contexts/MapContext/helpers/helpers.js +87 -0
  20. package/components/maps/components/GpsMap/contexts/MapContext/helpers/layerDataBounds.d.ts +10 -0
  21. package/components/maps/components/GpsMap/contexts/MapContext/helpers/layerDataBounds.d.ts.map +1 -0
  22. package/components/maps/components/GpsMap/contexts/MapContext/helpers/layerDataBounds.js +12 -0
  23. package/components/maps/components/GpsMap/contexts/MapContext/index.d.ts +2 -1
  24. package/components/maps/components/GpsMap/contexts/MapContext/index.d.ts.map +1 -1
  25. package/components/maps/components/GpsMap/contexts/MapContext/store.d.ts +6 -2
  26. package/components/maps/components/GpsMap/contexts/MapContext/store.d.ts.map +1 -1
  27. package/components/maps/components/GpsMap/contexts/MapContext/store.js +301 -123
  28. package/components/maps/components/GpsMap/contexts/MapContext/types.d.ts +191 -20
  29. package/components/maps/components/GpsMap/contexts/MapContext/types.d.ts.map +1 -1
  30. package/components/maps/components/GpsMap/contexts/MapContext/types.js +8 -0
  31. package/components/maps/components/GpsMap/featureRenders/CommonFeatureRender/index.d.ts.map +1 -1
  32. package/components/maps/components/GpsMap/featureRenders/CommonFeatureRender/index.js +93 -124
  33. package/components/maps/components/GpsMap/hooks/index.d.ts +3 -0
  34. package/components/maps/components/GpsMap/hooks/index.d.ts.map +1 -1
  35. package/components/maps/components/GpsMap/hooks/useAutoFocus/helpers.d.ts +12 -0
  36. package/components/maps/components/GpsMap/hooks/useAutoFocus/helpers.d.ts.map +1 -0
  37. package/components/maps/components/GpsMap/hooks/useAutoFocus/helpers.js +29 -0
  38. package/components/maps/components/GpsMap/hooks/useAutoFocus/index.d.ts +1 -4
  39. package/components/maps/components/GpsMap/hooks/useAutoFocus/index.d.ts.map +1 -1
  40. package/components/maps/components/GpsMap/hooks/useAutoFocus/index.js +32 -59
  41. package/components/maps/components/GpsMap/hooks/useAutoFocus/types.d.ts +4 -13
  42. package/components/maps/components/GpsMap/hooks/useAutoFocus/types.d.ts.map +1 -1
  43. package/components/maps/components/GpsMap/hooks/useMapInteractionCapture.d.ts +7 -0
  44. package/components/maps/components/GpsMap/hooks/useMapInteractionCapture.d.ts.map +1 -0
  45. package/components/maps/components/GpsMap/hooks/useMapInteractionCapture.js +42 -0
  46. package/components/maps/components/GpsMap/hooks/useMapInteractionCapture.types.d.ts +19 -0
  47. package/components/maps/components/GpsMap/hooks/useMapInteractionCapture.types.d.ts.map +1 -0
  48. package/components/maps/components/GpsMap/hooks/useObservableFeatureEventHandlers.d.ts +12 -0
  49. package/components/maps/components/GpsMap/hooks/useObservableFeatureEventHandlers.d.ts.map +1 -0
  50. package/components/maps/components/GpsMap/hooks/useObservableFeatureEventHandlers.js +43 -0
  51. package/components/maps/components/GpsMap/index.d.ts +1 -0
  52. package/components/maps/components/GpsMap/index.d.ts.map +1 -1
  53. package/components/maps/components/GpsMap/subcomponents/Controls/subcomponents/ButtonsToolsList/subcomponents/MeasureTool/constants.d.ts +5 -0
  54. package/components/maps/components/GpsMap/subcomponents/Controls/subcomponents/ButtonsToolsList/subcomponents/MeasureTool/constants.d.ts.map +1 -1
  55. package/components/maps/components/GpsMap/subcomponents/Controls/subcomponents/ButtonsToolsList/subcomponents/MeasureTool/constants.js +20 -13
  56. package/components/maps/components/GpsMap/subcomponents/Controls/subcomponents/ButtonsToolsList/subcomponents/MeasureTool/hooks/useMeasure/index.d.ts +4 -3
  57. package/components/maps/components/GpsMap/subcomponents/Controls/subcomponents/ButtonsToolsList/subcomponents/MeasureTool/hooks/useMeasure/index.d.ts.map +1 -1
  58. package/components/maps/components/GpsMap/subcomponents/Controls/subcomponents/ButtonsToolsList/subcomponents/MeasureTool/hooks/useMeasure/index.js +175 -120
  59. package/components/maps/components/GpsMap/subcomponents/Controls/subcomponents/ButtonsToolsList/subcomponents/MeasureTool/hooks/useMeasure/types.d.ts +6 -0
  60. package/components/maps/components/GpsMap/subcomponents/Controls/subcomponents/ButtonsToolsList/subcomponents/MeasureTool/hooks/useMeasure/types.d.ts.map +1 -1
  61. package/components/maps/components/GpsMap/subcomponents/Controls/subcomponents/ButtonsToolsList/subcomponents/MeasureTool/subcomponents/MyActions/MyActions.d.ts.map +1 -1
  62. package/components/maps/components/GpsMap/subcomponents/Controls/subcomponents/ButtonsToolsList/subcomponents/MeasureTool/subcomponents/MyActions/MyActions.js +26 -12
  63. package/components/maps/components/GpsMap/subcomponents/LayersContainer/subcomponents/Layer/Layer.js +1 -1
  64. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/constants.d.ts +6 -0
  65. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/constants.d.ts.map +1 -1
  66. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/constants.js +38 -26
  67. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/hooks/useDatagridFiltered.js +26 -26
  68. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/hooks/useFilterAndSort/useFilterAndSort.js +27 -27
  69. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/hooks/useMaster.js +4 -4
  70. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/hooks/useModuleDynamicActions.d.ts +1 -1
  71. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/hooks/useModuleDynamicActions.d.ts.map +1 -1
  72. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/hooks/useModuleDynamicActions.js +34 -28
  73. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/hooks/useRowActionsGetter.d.ts.map +1 -1
  74. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/hooks/useRowActionsGetter.js +41 -36
  75. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/hooks/useTabFiltered.js +17 -17
  76. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/Form.d.ts.map +1 -1
  77. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/Form.js +16 -18
  78. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/hooks/useDrawing.d.ts +3 -2
  79. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/hooks/useDrawing.d.ts.map +1 -1
  80. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/hooks/useDrawing.js +136 -92
  81. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/GeneralData/GeneralData.d.ts.map +1 -1
  82. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/GeneralData/GeneralData.js +29 -23
  83. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/subcomponents/GeofenceFeatureRender/GeofenceFeatureRender.d.ts +1 -1
  84. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/subcomponents/GeofenceFeatureRender/GeofenceFeatureRender.d.ts.map +1 -1
  85. package/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/subcomponents/GeofenceFeatureRender/GeofenceFeatureRender.js +60 -95
  86. package/components/maps/index.d.ts +1 -0
  87. package/components/maps/index.d.ts.map +1 -1
  88. package/index.js +143 -136
  89. package/package.json +3 -4
@@ -1,26 +1,29 @@
1
- import { useState as S, useRef as D, useEffect as d, useCallback as F, useMemo as w } from "react";
2
- import { useFormContext as x } from "react-hook-form";
3
- import { useModuleDictionary as B } from "@m4l/core";
4
- import { useMap as V } from "react-leaflet";
5
- import * as v from "leaflet";
6
- import { getLayerFromGeometry as H } from "../helpers.js";
7
- import { useFormReadyForUpdate as J, useWatchTyped as U } from "@m4l/components";
8
- import { MAP_GPSTOOLS_DICCTIONARY as u } from "../../../../../dictionary.js";
9
- import { getStyleFromProperties as T } from "../../../helpers.js";
10
- function Z() {
11
- const { getLabel: i } = B(), y = J(), r = V(), { control: G, setValue: t } = x(), [
12
- a,
13
- A,
14
- m,
15
- g,
1
+ import { useState as G, useRef as b, useEffect as g, useCallback as k, useMemo as U } from "react";
2
+ import { useFormContext as J } from "react-hook-form";
3
+ import { useModuleDictionary as q } from "@m4l/core";
4
+ import { useMap as Q } from "react-leaflet";
5
+ import * as Y from "leaflet";
6
+ import { getLayerFromGeometry as Z } from "../helpers.js";
7
+ import { useFormReadyForUpdate as K, useWatchTyped as X } from "@m4l/components";
8
+ import { MAP_GPSTOOLS_DICCTIONARY as l } from "../../../../../dictionary.js";
9
+ import { getStyleFromProperties as x } from "../../../helpers.js";
10
+ import { useMapInteractionCapture as B } from "../../../../../../GpsMap/hooks/useMapInteractionCapture.js";
11
+ import { useMapStore as j } from "../../../../../../GpsMap/hooks/useMapStore/index.js";
12
+ import { GEOFENCES_DRAW_INTERACTION_OWNER_ID as v, GEOFENCES_DRAW_REQUIRED_INTERACTION_CHANNELS as z, GEOFENCES_ADD_EDIT_VISUAL_REQUIRED_INTERACTION_CHANNELS as $ } from "../../../constants.js";
13
+ function pe() {
14
+ const { getLabel: i } = q(), d = K(), t = Q(), { control: V, setValue: r } = J(), A = j((o) => o.mapActions.moveToBounds), [
15
+ u,
16
+ O,
16
17
  f,
18
+ E,
19
+ _,
17
20
  L,
18
21
  h,
19
- E,
20
- I,
21
- b
22
- ] = U({
23
- control: G,
22
+ N,
23
+ R,
24
+ W
25
+ ] = X({
26
+ control: V,
24
27
  name: [
25
28
  "geofenceTypeId",
26
29
  "inEdition",
@@ -33,112 +36,153 @@ function Z() {
33
36
  "geometry",
34
37
  "properties.radius"
35
38
  ]
36
- }), [O, N] = S(!1), e = D(null), p = D(T({
37
- strokeColor: m,
38
- strokeOpacity: g,
39
- strokeWeight: f,
39
+ }), [D, y] = G(!1), e = b(null), {
40
+ isAvailable: S,
41
+ releaseCapture: c,
42
+ requestCapture: T
43
+ } = B({
44
+ ownerId: v,
45
+ channels: z
46
+ }), { requestCapture: M } = B({
47
+ ownerId: v,
48
+ channels: $
49
+ }), m = b(x({
50
+ strokeColor: f,
51
+ strokeOpacity: E,
52
+ strokeWeight: _,
40
53
  strokeDashArray: L,
41
54
  fillColor: h,
42
- fillOpacity: E
55
+ fillOpacity: N
43
56
  }));
44
- p.current = T({
45
- strokeColor: m,
46
- strokeOpacity: g,
47
- strokeWeight: f,
57
+ m.current = x({
58
+ strokeColor: f,
59
+ strokeOpacity: E,
60
+ strokeWeight: _,
48
61
  strokeDashArray: L,
49
62
  fillColor: h,
50
- fillOpacity: E
63
+ fillOpacity: N
51
64
  });
52
- const k = b ?? null, [l, M] = S(a);
53
- d(() => {
54
- if (y)
55
- return I && (e.current = H(I, a, k, {
56
- ...p.current
57
- }), e.current && (r.addLayer(e.current), r.fitBounds(e.current.getBounds()))), () => {
65
+ const H = W ?? null, [a, F] = G(u);
66
+ g(() => {
67
+ d && M();
68
+ }, [d, M]), g(() => {
69
+ if (d) {
70
+ if (R && (e.current = Z(R, u, H, {
71
+ ...m.current
72
+ }), e.current)) {
73
+ t.addLayer(e.current);
74
+ const o = e.current.getBounds();
75
+ A({
76
+ southWest: {
77
+ lat: o.getSouth(),
78
+ lng: o.getWest()
79
+ },
80
+ northEast: {
81
+ lat: o.getNorth(),
82
+ lng: o.getEast()
83
+ }
84
+ }, {
85
+ animate: !1,
86
+ padding: [0, 0],
87
+ maxZoom: t.getMaxZoom()
88
+ });
89
+ }
90
+ return () => {
58
91
  e.current && e.current.remove();
59
92
  };
60
- }, [r, y]), d(() => {
61
- if (!y) {
62
- l !== a && M(a);
93
+ }
94
+ }, [t, A, d]), g(() => {
95
+ if (!d) {
96
+ a !== u && F(u);
63
97
  return;
64
98
  }
65
- a !== l && (M(a), l !== "gt_circle" && (t("properties.radius", null, { shouldDirty: !0 }), t("lat", null, { shouldDirty: !0 }), t("lng", null, { shouldDirty: !0 })), t("geometry", null, { shouldDirty: !0 }), e.current && (e.current.remove(), e.current = null));
66
- }, [y, a]), d(() => {
67
- e.current && e.current.setStyle(p.current);
68
- }, [m, g, f, L, h, E]), d(() => {
69
- r.pm.setLang("en", {
99
+ u !== a && (F(u), a !== "gt_circle" && (r("properties.radius", null, { shouldDirty: !0 }), r("lat", null, { shouldDirty: !0 }), r("lng", null, { shouldDirty: !0 })), r("geometry", null, { shouldDirty: !0 }), e.current && (e.current.remove(), e.current = null), c(["draw_geometry"]), y(!1), r("inEdition", !1, { shouldDirty: !0 }));
100
+ }, [u, a, d, c, r]), g(() => {
101
+ e.current && e.current.setStyle(m.current);
102
+ }, [f, E, _, L, h, N]), g(() => {
103
+ t.pm.setLang("en", {
70
104
  tooltips: {
71
105
  placeMarker: void 0,
72
- firstVertex: i(u.LABEL_GEOMAN_FIRST_VERTEX),
73
- continueLine: i(u.LABEL_GEOMAN_CONTINUE_LINE),
74
- finishLine: i(u.LABEL_GEOMAN_FINISH_LINE),
75
- finishPoly: i(u.LABEL_GEOMAN_FINISH_POLYLINE),
76
- finishRect: i(u.LABEL_GEOMAN_FINISH_RECT),
77
- startCircle: i(u.LABEL_GEOMAN_START_CIRCLE),
78
- finishCircle: i(u.LABEL_GEOMAN_FINISH_CIRCLE),
79
- placeCircleMarker: i(u.LABEL_GEOMAN_PLACE_CIRCLE_MARKER)
106
+ firstVertex: i(l.LABEL_GEOMAN_FIRST_VERTEX),
107
+ continueLine: i(l.LABEL_GEOMAN_CONTINUE_LINE),
108
+ finishLine: i(l.LABEL_GEOMAN_FINISH_LINE),
109
+ finishPoly: i(l.LABEL_GEOMAN_FINISH_POLYLINE),
110
+ finishRect: i(l.LABEL_GEOMAN_FINISH_RECT),
111
+ startCircle: i(l.LABEL_GEOMAN_START_CIRCLE),
112
+ finishCircle: i(l.LABEL_GEOMAN_FINISH_CIRCLE),
113
+ placeCircleMarker: i(l.LABEL_GEOMAN_PLACE_CIRCLE_MARKER)
80
114
  }
81
115
  });
82
- }, [r, i]), d(() => {
83
- if (r) {
84
- let s = "Circle", _ = "Circle";
85
- l === "gt_polygon" ? (s = "Polygon", _ = "Polygon") : l === "gt_multipolygon" ? (s = "MultiPolygon", _ = "Polygon") : l === "gt_rectangle" && (s = "Rectangle", _ = "Rectangle"), O ? e.current ? (e.current.pm.enable(), t("inEdition", !0), e.current.on("pm:disable", (n) => {
86
- e.current = n.layer, t("geometry", e.current.toGeoJSON()?.geometry, {
116
+ }, [t, i]), g(() => {
117
+ if (t) {
118
+ let o = "Circle", C = "Circle";
119
+ a === "gt_polygon" ? (o = "Polygon", C = "Polygon") : a === "gt_multipolygon" ? (o = "MultiPolygon", C = "Polygon") : a === "gt_rectangle" && (o = "Rectangle", C = "Rectangle"), D ? e.current ? (e.current.pm.enable(), r("inEdition", !0), e.current.on("pm:disable", (s) => {
120
+ e.current = s.layer, r("geometry", e.current.toGeoJSON()?.geometry, {
87
121
  shouldTouch: !0,
88
122
  shouldValidate: !0,
89
123
  shouldDirty: !0
90
- }), t("inEdition", !1), N(!1);
91
- }), s === "Circle" && e.current.on("pm:change", (n) => {
92
- e.current = n.layer, t("lat", Number(e.current.getLatLng().lat.toFixed(8))), t("lng", Number(e.current.getLatLng().lng.toFixed(8))), t("properties.radius", e.current.getRadius()), t("properties.radius", Number(e.current.getRadius().toFixed(1)));
93
- })) : (t("inEdition", !0), s === "Circle" ? r.on("pm:drawstart", ({ workingLayer: n }) => {
94
- n.on("pm:centerplaced", (c) => {
95
- const o = c.workingLayer;
96
- o.setStyle({
97
- color: m,
98
- opacity: g,
99
- weight: f,
124
+ }), r("inEdition", !1), y(!1), c(["draw_geometry"]);
125
+ }), o === "Circle" && e.current.on("pm:change", (s) => {
126
+ e.current = s.layer, r("lat", Number(e.current.getLatLng().lat.toFixed(8))), r("lng", Number(e.current.getLatLng().lng.toFixed(8))), r("properties.radius", e.current.getRadius()), r("properties.radius", Number(e.current.getRadius().toFixed(1)));
127
+ })) : (r("inEdition", !0), o === "Circle" ? t.on("pm:drawstart", ({ workingLayer: s }) => {
128
+ s.on("pm:centerplaced", (p) => {
129
+ const n = p.workingLayer;
130
+ n.setStyle({
131
+ color: f,
132
+ opacity: E,
133
+ weight: _,
100
134
  dashArray: L,
101
135
  fillColor: h,
102
- fillOpacity: E
103
- }), t("lat", Number(o.getLatLng().lat.toFixed(8))), t("lng", Number(o.getLatLng().lng.toFixed(8))), o.on("pm:change", (C) => {
104
- t("properties.radius", Number(o.getRadius().toFixed(1)));
136
+ fillOpacity: N
137
+ }), r("lat", Number(n.getLatLng().lat.toFixed(8))), r("lng", Number(n.getLatLng().lng.toFixed(8))), n.on("pm:change", (I) => {
138
+ r("properties.radius", Number(n.getRadius().toFixed(1)));
105
139
  });
106
140
  });
107
- }) : (s === "Polygon" || s === "MultiPolygon") && r.on("pm:drawstart", ({ workingLayer: n }) => {
108
- n.on("pm:vertexadded", (c) => {
109
- c.workingLayer.setStyle(p.current);
141
+ }) : (o === "Polygon" || o === "MultiPolygon") && t.on("pm:drawstart", ({ workingLayer: s }) => {
142
+ s.on("pm:vertexadded", (p) => {
143
+ p.workingLayer.setStyle(m.current);
110
144
  });
111
- }), r.pm.enableDraw(_), r.pm.setPathOptions(p.current), r.on("pm:create", (n) => {
112
- const c = n.layer, o = c.toGeoJSON()?.geometry;
113
- if (s === "MultiPolygon" && o?.type === "Polygon") {
114
- const C = {
145
+ }), t.pm.enableDraw(C), t.pm.setPathOptions(m.current), t.on("pm:create", (s) => {
146
+ const p = s.layer, n = p.toGeoJSON()?.geometry;
147
+ if (o === "MultiPolygon" && n?.type === "Polygon") {
148
+ const I = {
115
149
  type: "MultiPolygon",
116
- coordinates: [o.coordinates]
150
+ coordinates: [n.coordinates]
117
151
  };
118
- r.removeLayer(c), e.current = v.geoJSON(C, {
119
- style: p.current
120
- }), r.addLayer(e.current), t("geometry", C, {
152
+ t.removeLayer(p), e.current = Y.geoJSON(I, {
153
+ style: m.current
154
+ }), t.addLayer(e.current), r("geometry", I, {
121
155
  shouldTouch: !0,
122
156
  shouldValidate: !0,
123
157
  shouldDirty: !0
124
158
  });
125
159
  } else
126
- e.current = c, t("geometry", o, {
160
+ e.current = p, r("geometry", n, {
127
161
  shouldTouch: !0,
128
162
  shouldValidate: !0,
129
163
  shouldDirty: !0
130
164
  });
131
- t("inEdition", !1), N(!1);
132
- })) : (r.pm.disableDraw("Polygon"), r.off("pm:create"), r.off("pm:edit"), r.off("pm:drawstart"));
165
+ r("inEdition", !1), y(!1), c(["draw_geometry"]);
166
+ })) : (t.pm.disableDraw("Polygon"), t.off("pm:create"), t.off("pm:edit"), t.off("pm:drawstart"));
167
+ }
168
+ }, [D, t, c]);
169
+ const P = k(() => {
170
+ T() && y(!0);
171
+ }, [T]), w = k(() => {
172
+ if (c(["draw_geometry"]), e.current) {
173
+ e.current.pm.disable();
174
+ return;
133
175
  }
134
- }, [r, O]);
135
- const P = F(() => {
136
- N(!0);
137
- }, []), R = F(() => {
138
- e.current && e.current.pm.disable();
139
- }, []);
140
- return w(() => ({ inEdition: A, handleDraw: P, handleFinish: R, geometrTypeIdCached: l }), [A, P, R, l]);
176
+ y(!1), r("inEdition", !1, { shouldDirty: !0 });
177
+ }, [c, r]);
178
+ return U(() => ({
179
+ inEdition: O,
180
+ handleDraw: P,
181
+ handleFinish: w,
182
+ geometrTypeIdCached: a,
183
+ isInteractionAvailable: S
184
+ }), [a, P, w, O, S]);
141
185
  }
142
186
  export {
143
- Z as useDrawing
187
+ pe as useDrawing
144
188
  };
@@ -1 +1 @@
1
- {"version":3,"file":"GeneralData.d.ts","sourceRoot":"","sources":["../../../../../../../../../../../../../../packages/gclick/src/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/GeneralData/GeneralData.tsx"],"names":[],"mappings":"AAoBA;;GAEG;AACH,wBAAgB,WAAW,qDA8D1B"}
1
+ {"version":3,"file":"GeneralData.d.ts","sourceRoot":"","sources":["../../../../../../../../../../../../../../packages/gclick/src/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/subcomponents/GeofenceAddEdit/subcomponents/GeneralData/GeneralData.tsx"],"names":[],"mappings":"AAoBA;;GAEG;AACH,wBAAgB,WAAW,qDAoE1B"}
@@ -1,44 +1,50 @@
1
- import { jsxs as r, jsx as e } from "@emotion/react/jsx-runtime";
2
- import { useModuleDictionary as u } from "@m4l/core";
3
- import { PaperForm as L, RHFTextField as n, Stack as a, RHFSelect as f, Button as g, RHFHelperError as m } from "@m4l/components";
4
- import { useDrawing as A } from "../../hooks/useDrawing.js";
1
+ import { jsxs as n, jsx as e } from "@emotion/react/jsx-runtime";
2
+ import { useModuleDictionary as L } from "@m4l/core";
3
+ import { PaperForm as f, RHFTextField as r, Stack as l, RHFSelect as g, Button as A, RHFHelperError as m } from "@m4l/components";
4
+ import { useDrawing as E } from "../../hooks/useDrawing.js";
5
5
  import { MAP_GPSTOOLS_DICCTIONARY as i } from "../../../../../../dictionary.js";
6
- import { useGeneral as E } from "./hooks/useGeneral.js";
7
- function x() {
8
- const { getLabel: t } = u(), { inEdition: l, handleDraw: s, handleFinish: c, geometrTypeIdCached: o } = A(), { urlIcon: d, geofencesTypes: p } = E();
9
- return /* @__PURE__ */ r(L, { urlIcon: d, title: t(i.PAPER_GENERAL), variant: "text", isForm: !0, children: [
6
+ import { useGeneral as I } from "./hooks/useGeneral.js";
7
+ function y() {
8
+ const { getLabel: t } = L(), {
9
+ inEdition: o,
10
+ handleDraw: s,
11
+ handleFinish: c,
12
+ geometrTypeIdCached: a,
13
+ isInteractionAvailable: d
14
+ } = E(), { urlIcon: p, geofencesTypes: u } = I();
15
+ return /* @__PURE__ */ n(f, { urlIcon: p, title: t(i.PAPER_GENERAL), variant: "text", isForm: !0, children: [
10
16
  /* @__PURE__ */ e(
11
- n,
17
+ r,
12
18
  {
13
19
  name: "name",
14
20
  type: "text",
15
21
  label: t(`${i.LABEL_NAME}`)
16
22
  }
17
23
  ),
18
- /* @__PURE__ */ r(a, { direction: "column", spacing: 1, alignItems: "flex-start", children: [
19
- /* @__PURE__ */ r(a, { direction: "row", spacing: 1, alignItems: "center", children: [
24
+ /* @__PURE__ */ n(l, { direction: "column", spacing: 1, alignItems: "flex-start", children: [
25
+ /* @__PURE__ */ n(l, { direction: "row", spacing: 1, alignItems: "center", children: [
20
26
  /* @__PURE__ */ e(
21
- f,
27
+ g,
22
28
  {
23
29
  name: "geofenceTypeId",
24
- options: p
30
+ options: u
25
31
  }
26
32
  ),
27
33
  /* @__PURE__ */ e(
28
- g,
34
+ A,
29
35
  {
30
- onClick: l ? c : s,
31
- disabled: !o,
32
- label: t(l ? i.LABEL_FINISH : i.LABEL_DRAW)
36
+ onClick: o ? c : s,
37
+ disabled: !a || !o && !d,
38
+ label: t(o ? i.LABEL_FINISH : i.LABEL_DRAW)
33
39
  }
34
40
  )
35
41
  ] }),
36
42
  /* @__PURE__ */ e(m, { name: "geometry" }, "geometry"),
37
43
  /* @__PURE__ */ e(m, { name: "inEdition" }, "inEdition"),
38
- o && o === "gt_circle" && // <HelperText variant='info' message={'undefined'} />
39
- /* @__PURE__ */ r(a, { direction: "row", spacing: 1, alignItems: "center", children: [
44
+ a && a === "gt_circle" && // <HelperText variant='info' message={'undefined'} />
45
+ /* @__PURE__ */ n(l, { direction: "row", spacing: 1, alignItems: "center", children: [
40
46
  /* @__PURE__ */ e(
41
- n,
47
+ r,
42
48
  {
43
49
  name: "properties.radius",
44
50
  label: t(i.LABEL_RADIUS),
@@ -48,7 +54,7 @@ function x() {
48
54
  }
49
55
  ),
50
56
  /* @__PURE__ */ e(
51
- n,
57
+ r,
52
58
  {
53
59
  name: "lat",
54
60
  label: t(i.LABEL_LAT),
@@ -58,7 +64,7 @@ function x() {
58
64
  }
59
65
  ),
60
66
  /* @__PURE__ */ e(
61
- n,
67
+ r,
62
68
  {
63
69
  name: "lng",
64
70
  label: t(i.LABEL_LON),
@@ -72,5 +78,5 @@ function x() {
72
78
  ] });
73
79
  }
74
80
  export {
75
- x as GeneralData
81
+ y as GeneralData
76
82
  };
@@ -1,6 +1,6 @@
1
1
  import { ComponentRenderPropFeature } from '../../../../../GpsMap/contexts/MapContext';
2
2
  /**
3
- * "GeofenceFeatureRender" es la función encargada de renderizada las geocercas
3
+ * `GeofenceFeatureRender` renders geofences on the map.
4
4
  */
5
5
  export declare const GeofenceFeatureRender: ComponentRenderPropFeature;
6
6
  //# sourceMappingURL=GeofenceFeatureRender.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GeofenceFeatureRender.d.ts","sourceRoot":"","sources":["../../../../../../../../../../../../packages/gclick/src/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/subcomponents/GeofenceFeatureRender/GeofenceFeatureRender.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAcvF;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,0BAwLnC,CAAC"}
1
+ {"version":3,"file":"GeofenceFeatureRender.d.ts","sourceRoot":"","sources":["../../../../../../../../../../../../packages/gclick/src/components/maps/components/GpsMapTools/subcomponents/GeofencesTool/subcomponents/GeofenceFeatureRender/GeofenceFeatureRender.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAcvF;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,0BAgJnC,CAAC"}
@@ -1,67 +1,52 @@
1
- import { jsxs as d, jsx as i } from "@emotion/react/jsx-runtime";
2
- import { Circle as I, Polyline as S, Polygon as j, GeoJSON as M } from "react-leaflet";
3
- import { shallow as P } from "zustand/shallow";
4
- import { useMapStore as b } from "../../../../../GpsMap/hooks/useMapStore/index.js";
5
- import p, { useCallback as v } from "react";
6
- import { MarkerIconLabel as g } from "../../../../../GpsMap/featureRenders/MarkerIconLabel/index.js";
7
- import { getLabelPositionForCircle as C, getLabelPositionForLineString as H, getLabelPositionForPolygon as h } from "./helpers.js";
8
- import { getStyleFromProperties as u } from "../../helpers.js";
9
- const A = (F) => {
10
- const { id: L, layerId: y } = F, e = b((t) => {
11
- const r = t.hashLayers[y].geoJsonObject;
1
+ import { jsxs as g, jsx as s } from "@emotion/react/jsx-runtime";
2
+ import { Circle as F, Polyline as L, Polygon as v, GeoJSON as I } from "react-leaflet";
3
+ import { shallow as j } from "zustand/shallow";
4
+ import { useMapStore as k } from "../../../../../GpsMap/hooks/useMapStore/index.js";
5
+ import p from "react";
6
+ import { MarkerIconLabel as u } from "../../../../../GpsMap/featureRenders/MarkerIconLabel/index.js";
7
+ import { getLabelPositionForCircle as H, getLabelPositionForLineString as M, getLabelPositionForPolygon as P } from "./helpers.js";
8
+ import { getStyleFromProperties as d } from "../../helpers.js";
9
+ import { useObservableFeatureEventHandlers as S } from "../../../../../GpsMap/hooks/useObservableFeatureEventHandlers.js";
10
+ const N = (b) => {
11
+ const { id: y, layerId: f } = b, m = S(f, y), e = k((o) => {
12
+ const r = o.hashLayers[f].geoJsonObject;
12
13
  if (!r)
13
14
  return null;
14
15
  if (r.object.type === "FeatureCollection") {
15
- const o = r.object.features.find((n) => n.id === L);
16
- if (o)
16
+ const t = r.object.features.find((n) => n.id === y);
17
+ if (t)
17
18
  return {
18
- id: o.id,
19
- geometry: o.geometry,
20
- properties: o.properties
19
+ id: t.id,
20
+ geometry: t.geometry,
21
+ properties: t.properties
21
22
  };
22
23
  } else
23
- throw new Error("GeofenceFeatureRender no se puede usar con un feature de tipo Feature");
24
+ throw new Error("GeofenceFeatureRender cannot be used with a single Feature payload");
24
25
  return null;
25
- }, P), { addLayerDataToFeature: f } = b((t) => t.mapActions, P), c = v((t) => {
26
- if (!e)
27
- return;
28
- const r = {
29
- // visible: true,
30
- boundsNW: t.target.getBounds().getNorthWest(),
31
- boundsSE: t.target.getBounds().getSouthEast(),
32
- getTarget: () => t.target
33
- // target: e.target,
34
- };
35
- f(y, e.id, r);
36
- }, [e, f, y]);
26
+ }, j);
37
27
  if (!e)
38
28
  return null;
39
- const m = {
29
+ const c = {
40
30
  featureId: e.id
41
31
  };
42
32
  if (e.geometry?.type === "Point") {
43
- const [t, r] = e.geometry.coordinates;
33
+ const [o, r] = e.geometry.coordinates;
44
34
  if (e.properties?.radius) {
45
- const { radius: o, markerIconLabel: n, ...s } = e.properties, a = u(s), l = C(r, t, o);
46
- return /* @__PURE__ */ d(p.Fragment, { children: [
47
- /* @__PURE__ */ i(
48
- I,
35
+ const { radius: t, markerIconLabel: n, ...i } = e.properties, a = d(i), l = H(r, o, t);
36
+ return /* @__PURE__ */ g(p.Fragment, { children: [
37
+ /* @__PURE__ */ s(
38
+ F,
49
39
  {
50
- center: { lat: r, lng: t },
40
+ center: { lat: r, lng: o },
51
41
  radius: e.properties?.radius,
52
- eventHandlers: {
53
- add: c
54
- // remove: () => {
55
- // removeLefletLayerToFeature(layerId, feature.id)
56
- // },
57
- },
42
+ eventHandlers: m,
58
43
  ...a,
59
- ...m
44
+ ...c
60
45
  },
61
46
  Math.random()
62
47
  ),
63
- n && /* @__PURE__ */ i(
64
- g,
48
+ n && /* @__PURE__ */ s(
49
+ u,
65
50
  {
66
51
  position: l,
67
52
  ...n
@@ -70,78 +55,58 @@ const A = (F) => {
70
55
  ] });
71
56
  }
72
57
  } else if (e.geometry?.type === "LineString") {
73
- const t = e.geometry.coordinates.map(
74
- (s) => [s[1], s[0]]
75
- ), { markerIconLabel: r, ...o } = e.properties, n = u(o);
76
- return /* @__PURE__ */ d(p.Fragment, { children: [
77
- /* @__PURE__ */ i(
78
- S,
58
+ const o = e.geometry.coordinates.map(
59
+ (i) => [i[1], i[0]]
60
+ ), { markerIconLabel: r, ...t } = e.properties, n = d(t);
61
+ return /* @__PURE__ */ g(p.Fragment, { children: [
62
+ /* @__PURE__ */ s(
63
+ L,
79
64
  {
80
- positions: t,
65
+ positions: o,
81
66
  stroke: !0,
82
- eventHandlers: {
83
- add: c
84
- // remove: () => {
85
- // removeLefletLayerToFeature(layerId, feature.id)
86
- // },
87
- },
67
+ eventHandlers: m,
88
68
  ...n,
89
- ...m
69
+ ...c
90
70
  },
91
71
  Math.random()
92
72
  ),
93
- r && /* @__PURE__ */ i(
94
- g,
73
+ r && /* @__PURE__ */ s(
74
+ u,
95
75
  {
96
- position: H(t),
76
+ position: M(o),
97
77
  ...r
98
78
  }
99
79
  )
100
80
  ] });
101
81
  } else if (e.geometry?.type === "Polygon") {
102
- const t = e.geometry.coordinates.map(
103
- (s) => s.map(([a, l]) => [l, a])
104
- ), { markerIconLabel: r, ...o } = e.properties, n = u(o);
105
- return /* @__PURE__ */ d(p.Fragment, { children: [
106
- /* @__PURE__ */ i(
107
- j,
82
+ const o = e.geometry.coordinates.map(
83
+ (i) => i.map(([a, l]) => [l, a])
84
+ ), { markerIconLabel: r, ...t } = e.properties, n = d(t);
85
+ return /* @__PURE__ */ g(p.Fragment, { children: [
86
+ /* @__PURE__ */ s(
87
+ v,
108
88
  {
109
- positions: t,
110
- eventHandlers: {
111
- add: c
112
- // remove: () => {
113
- // removeLefletLayerToFeature(layerId, feature.id)
114
- // },
115
- },
89
+ positions: o,
90
+ eventHandlers: m,
116
91
  ...n,
117
- ...m
92
+ ...c
118
93
  }
119
94
  ),
120
- r && /* @__PURE__ */ i(g, { position: h(t), ...r })
95
+ r && /* @__PURE__ */ s(u, { position: P(o), ...r })
121
96
  ] });
122
97
  } else if (e.geometry?.type === "MultiPolygon") {
123
- const t = e.geometry.coordinates.map(
124
- (s) => s.map(
125
- (a) => a.map(([l, k]) => [k, l])
98
+ const o = e.geometry.coordinates.map(
99
+ (i) => i.map(
100
+ (a) => a.map(([l, h]) => [h, l])
126
101
  )
127
- ), { markerIconLabel: r, ...o } = e.properties, n = u(o);
128
- return /* @__PURE__ */ d(p.Fragment, { children: [
129
- /* @__PURE__ */ i(
130
- M,
131
- {
132
- data: e.geometry,
133
- ...n,
134
- ...m,
135
- eventHandlers: {
136
- add: c
137
- }
138
- }
139
- ),
140
- r && /* @__PURE__ */ i(p.Fragment, { children: t.map((s, a) => /* @__PURE__ */ i(g, { position: h(s), ...r, label: `${r.label} (${a + 1}/${t.length})` }, a)) })
102
+ ), { markerIconLabel: r, ...t } = e.properties, n = d(t);
103
+ return /* @__PURE__ */ g(p.Fragment, { children: [
104
+ /* @__PURE__ */ s(I, { data: e.geometry, eventHandlers: m, ...n, ...c }),
105
+ r && /* @__PURE__ */ s(p.Fragment, { children: o.map((i, a) => /* @__PURE__ */ s(u, { position: P(i), ...r, label: `${r.label} (${a + 1}/${o.length})` }, a)) })
141
106
  ] });
142
107
  }
143
108
  return null;
144
109
  };
145
110
  export {
146
- A as GeofenceFeatureRender
111
+ N as GeofenceFeatureRender
147
112
  };
@@ -1,4 +1,5 @@
1
1
  export * from './components/GpsMap';
2
+ export { isObservableFeatureEventCaptured } from './components/GpsMap';
2
3
  export * from './utils';
3
4
  export type { MapProps, RendePropFeatureArgs, ComponentRenderPropFeature, FeatureId, FeatureCollection, Feature, Geometry, } from './components/GpsMap';
4
5
  export * from './components/GpsMapTools';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick/src/components/maps/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAC;AAEpC,cAAc,SAAS,CAAC;AACxB,YAAY,EACV,QAAQ,EACR,oBAAoB,EACpB,0BAA0B,EAC1B,SAAS,EACT,iBAAiB,EACjB,OAAO,EACP,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAE7B,cAAc,0BAA0B,CAAC;AAGzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick/src/components/maps/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAEvE,cAAc,SAAS,CAAC;AACxB,YAAY,EACV,QAAQ,EACR,oBAAoB,EACpB,0BAA0B,EAC1B,SAAS,EACT,iBAAiB,EACjB,OAAO,EACP,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAE7B,cAAc,0BAA0B,CAAC;AAGzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC"}