@rio-cloud/rio-uikit 2.3.0-beta.2 → 2.3.0

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 (160) hide show
  1. package/Marker.js +9 -5
  2. package/Table.js +10 -9
  3. package/TableNext.js +10 -9
  4. package/TableRowActionsDropdown.d.ts +2 -0
  5. package/TableRowActionsDropdown.js +5 -0
  6. package/TableRowActionsDropdown.js.map +1 -0
  7. package/components/analyticsAnalysisOverlay/AnalyticsAnalysisBanner.d.ts +38 -3
  8. package/components/analyticsAnalysisOverlay/AnalyticsAnalysisBanner.js +104 -109
  9. package/components/analyticsAnalysisOverlay/AnalyticsAnalysisBanner.js.map +1 -1
  10. package/components/analyticsAnalysisOverlay/AnalyticsAnalysisOverlay.d.ts +24 -5
  11. package/components/analyticsAnalysisOverlay/AnalyticsAnalysisOverlay.js +60 -56
  12. package/components/analyticsAnalysisOverlay/AnalyticsAnalysisOverlay.js.map +1 -1
  13. package/components/datepicker/DayPicker.js +72 -70
  14. package/components/datepicker/DayPicker.js.map +1 -1
  15. package/components/datepicker/DayPickerDropdown.d.ts +1 -0
  16. package/components/datepicker/DayPickerDropdown.js +61 -48
  17. package/components/datepicker/DayPickerDropdown.js.map +1 -1
  18. package/components/datepicker/useStackedDayPickerCalendars.js +26 -26
  19. package/components/datepicker/useStackedDayPickerCalendars.js.map +1 -1
  20. package/components/dropdown/ButtonDropdown.d.ts +4 -0
  21. package/components/dropdown/ButtonDropdown.js +82 -80
  22. package/components/dropdown/ButtonDropdown.js.map +1 -1
  23. package/components/listMenu/ListMenu.d.ts +8 -0
  24. package/components/listMenu/ListMenu.js +74 -66
  25. package/components/listMenu/ListMenu.js.map +1 -1
  26. package/components/map/components/Map.js +207 -156
  27. package/components/map/components/Map.js.map +1 -1
  28. package/components/map/components/MapContext.d.ts +3 -0
  29. package/components/map/components/MapContext.js +9 -6
  30. package/components/map/components/MapContext.js.map +1 -1
  31. package/components/map/components/features/MapZoom.js +19 -19
  32. package/components/map/components/features/MapZoom.js.map +1 -1
  33. package/components/map/components/features/Route.d.ts +65 -1
  34. package/components/map/components/features/Route.js +184 -98
  35. package/components/map/components/features/Route.js.map +1 -1
  36. package/components/map/components/features/basics/Marker.d.ts +21 -1
  37. package/components/map/components/features/basics/Marker.js +99 -40
  38. package/components/map/components/features/basics/Marker.js.map +1 -1
  39. package/components/map/components/features/basics/Polygon.d.ts +24 -1
  40. package/components/map/components/features/basics/Polygon.js +72 -19
  41. package/components/map/components/features/basics/Polygon.js.map +1 -1
  42. package/components/map/components/features/basics/Polyline.d.ts +29 -0
  43. package/components/map/components/features/basics/Polyline.js +69 -39
  44. package/components/map/components/features/basics/Polyline.js.map +1 -1
  45. package/components/map/components/features/layers/MarkerLayer.js +8 -8
  46. package/components/map/components/features/layers/MarkerLayer.js.map +1 -1
  47. package/components/map/components/features/layers/clustering/SimpleClusterLayer.js +13 -6
  48. package/components/map/components/features/layers/clustering/SimpleClusterLayer.js.map +1 -1
  49. package/components/map/utils/clustering.d.ts +1 -1
  50. package/components/map/utils/clustering.js +30 -30
  51. package/components/map/utils/clustering.js.map +1 -1
  52. package/components/map/utils/mapTypes.d.ts +141 -0
  53. package/components/map/utils/mapTypes.js.map +1 -1
  54. package/components/map/utils/mapUtils.d.ts +2 -0
  55. package/components/map/utils/mapUtils.js +4 -0
  56. package/components/map/utils/mapUtils.js.map +1 -1
  57. package/components/mapMarker/ClusterMapMarker.d.ts +2 -0
  58. package/components/mapMarker/ClusterMapMarker.js.map +1 -1
  59. package/components/mapMarker/SingleMapMarker.d.ts +2 -0
  60. package/components/mapMarker/SingleMapMarker.js.map +1 -1
  61. package/components/selects/ClearButton.js +9 -7
  62. package/components/selects/ClearButton.js.map +1 -1
  63. package/components/table/Table.d.ts +3 -1
  64. package/components/table/Table.js +239 -216
  65. package/components/table/Table.js.map +1 -1
  66. package/components/table/Table.types.d.ts +62 -4
  67. package/components/table/TableColumn.d.ts +8 -1
  68. package/components/table/TableColumn.js +66 -64
  69. package/components/table/TableColumn.js.map +1 -1
  70. package/components/table/TableExpandedRow.d.ts +4 -0
  71. package/components/table/TableExpandedRow.js +70 -67
  72. package/components/table/TableExpandedRow.js.map +1 -1
  73. package/components/table/TableGroupRow.d.ts +3 -1
  74. package/components/table/TableGroupRow.js +15 -14
  75. package/components/table/TableGroupRow.js.map +1 -1
  76. package/components/table/TableHeader.d.ts +9 -0
  77. package/components/table/TableHeader.js +110 -81
  78. package/components/table/TableHeader.js.map +1 -1
  79. package/components/table/TableHeaderColumn.d.ts +11 -1
  80. package/components/table/TableHeaderColumn.js +63 -58
  81. package/components/table/TableHeaderColumn.js.map +1 -1
  82. package/components/table/TableRow.d.ts +12 -0
  83. package/components/table/TableRow.js +78 -74
  84. package/components/table/TableRow.js.map +1 -1
  85. package/components/table/TableRowActionsDropdown.d.ts +11 -0
  86. package/components/table/TableRowActionsDropdown.js +22 -0
  87. package/components/table/TableRowActionsDropdown.js.map +1 -0
  88. package/components/table/TableStickyRowButton.d.ts +25 -0
  89. package/components/table/TableStickyRowButton.js +32 -0
  90. package/components/table/TableStickyRowButton.js.map +1 -0
  91. package/components/table/TableToolbar.d.ts +24 -3
  92. package/components/table/TableToolbar.js +78 -37
  93. package/components/table/TableToolbar.js.map +1 -1
  94. package/components/table/TableViewToggles.js +5 -5
  95. package/components/table/TableViewToggles.js.map +1 -1
  96. package/components/table/context/TableInteractionContext.d.ts +3 -0
  97. package/components/table/context/TableInteractionContext.js.map +1 -1
  98. package/components/table/context/TableLayoutContext.d.ts +1 -0
  99. package/components/table/context/TableLayoutContext.js.map +1 -1
  100. package/components/table/context/TableRenderContext.d.ts +1 -0
  101. package/components/table/context/TableRenderContext.js.map +1 -1
  102. package/components/table/layout/useHorizontalSectionSync.d.ts +2 -1
  103. package/components/table/layout/useHorizontalSectionSync.js +32 -31
  104. package/components/table/layout/useHorizontalSectionSync.js.map +1 -1
  105. package/components/table/layout/useMeasuredColumnMaxWidths.js +52 -54
  106. package/components/table/layout/useMeasuredColumnMaxWidths.js.map +1 -1
  107. package/components/table/layout/useTableLayout.d.ts +6 -2
  108. package/components/table/layout/useTableLayout.js +61 -48
  109. package/components/table/layout/useTableLayout.js.map +1 -1
  110. package/components/table/layout/useTableVirtualization.js +51 -56
  111. package/components/table/layout/useTableVirtualization.js.map +1 -1
  112. package/components/table/model/resolveResponsiveViewType.d.ts +2 -0
  113. package/components/table/model/resolveResponsiveViewType.js +27 -0
  114. package/components/table/model/resolveResponsiveViewType.js.map +1 -0
  115. package/components/table/render/header/TableDraggableHeaderCell.js +38 -36
  116. package/components/table/render/header/TableDraggableHeaderCell.js.map +1 -1
  117. package/components/table/render/header/TableHeader.types.d.ts +2 -0
  118. package/components/table/render/header/TableHeaderCellContent.js +16 -16
  119. package/components/table/render/header/TableHeaderCellContent.js.map +1 -1
  120. package/components/table/render/header/TableHeaderSelectionCell.d.ts +1 -0
  121. package/components/table/render/header/TableHeaderSelectionCell.js +13 -12
  122. package/components/table/render/header/TableHeaderSelectionCell.js.map +1 -1
  123. package/components/table/render/header/TableStaticHeaderCell.js +31 -29
  124. package/components/table/render/header/TableStaticHeaderCell.js.map +1 -1
  125. package/components/table/render/header/resolveHeaderCellClassName.d.ts +1 -0
  126. package/components/table/render/header/resolveHeaderCellClassName.js +10 -9
  127. package/components/table/render/header/resolveHeaderCellClassName.js.map +1 -1
  128. package/components/table/runtime/useResolvedRenderColumns.d.ts +4 -4
  129. package/components/table/runtime/useResolvedRenderColumns.js +13 -13
  130. package/components/table/runtime/useResolvedRenderColumns.js.map +1 -1
  131. package/components/table/runtime/useResolvedRenderHeader.d.ts +1 -1
  132. package/components/table/runtime/useResolvedRenderHeader.js.map +1 -1
  133. package/components/table/runtime/useResponsiveResolvedViewType.d.ts +23 -0
  134. package/components/table/runtime/useResponsiveResolvedViewType.js +22 -0
  135. package/components/table/runtime/useResponsiveResolvedViewType.js.map +1 -0
  136. package/components/table/selection/useInternalTableSelectionState.d.ts +2 -0
  137. package/components/table/selection/useInternalTableSelectionState.js +27 -17
  138. package/components/table/selection/useInternalTableSelectionState.js.map +1 -1
  139. package/components/table/selection/useTableSelection.d.ts +5 -1
  140. package/components/table/selection/useTableSelection.js +37 -26
  141. package/components/table/selection/useTableSelection.js.map +1 -1
  142. package/components/table/shared/parsePixelSize.d.ts +2 -0
  143. package/components/table/shared/parsePixelSize.js +13 -0
  144. package/components/table/shared/parsePixelSize.js.map +1 -0
  145. package/hooks/useDraggableElement.d.ts +27 -5
  146. package/hooks/useDraggableElement.js +100 -23
  147. package/hooks/useDraggableElement.js.map +1 -1
  148. package/hooks/usePopperDropdown.d.ts +1 -0
  149. package/hooks/usePopperDropdown.js +15 -12
  150. package/hooks/usePopperDropdown.js.map +1 -1
  151. package/hooks/useResizeObserver.d.ts +25 -6
  152. package/hooks/useResizeObserver.js +20 -18
  153. package/hooks/useResizeObserver.js.map +1 -1
  154. package/package.json +10 -10
  155. package/utils/analytics/createAnalyticsOverlayTooltip.js.map +1 -1
  156. package/utils/init/initConfig.js +5 -5
  157. package/utils/init/initConfig.js.map +1 -1
  158. package/version.d.ts +1 -1
  159. package/version.js +2 -2
  160. package/version.js.map +1 -1
@@ -1,46 +1,105 @@
1
- import v, { useRef as I, useEffect as u } from "react";
2
- import k from "react-dom/server";
3
- import { removeEventListenerMap as f, addEventListenerMap as d } from "../../../utils/eventHandling.js";
4
- import { useMapContext as g } from "../../MapContext.js";
5
- const M = (e) => e instanceof H.map.Icon, l = (e) => e ? !M(e) : !1, D = (e) => {
6
- if (M(e) || e instanceof H.map.DomIcon)
1
+ import w, { useRef as k, useEffect as l } from "react";
2
+ import O from "react-dom/server";
3
+ import { removeEventListenerMap as b, addEventListenerMap as g } from "../../../utils/eventHandling.js";
4
+ import { useMapContext as y } from "../../MapContext.js";
5
+ const v = (e) => e instanceof H.map.Icon, p = (e) => e ? !v(e) : !1, x = 500, u = /* @__PURE__ */ new Map();
6
+ let M = /* @__PURE__ */ new WeakMap(), C = !0;
7
+ const S = () => ({
8
+ cacheEnabled: C,
9
+ domIconCreations: 0,
10
+ markupCacheHits: 0,
11
+ markupCacheMisses: 0,
12
+ reactElementCacheHits: 0,
13
+ reactElementCacheMisses: 0,
14
+ uncachedDomIconCreations: 0,
15
+ markerSetups: 0,
16
+ markerDestroys: 0,
17
+ markerIconUpdates: 0,
18
+ markerIconRecreates: 0,
19
+ markerSetIconCalls: 0
20
+ }), r = S(), N = () => ({
21
+ ...r,
22
+ cacheEnabled: C
23
+ }), W = () => {
24
+ Object.assign(r, S());
25
+ }, z = (e) => {
26
+ C = e;
27
+ }, G = () => {
28
+ u.clear(), M = /* @__PURE__ */ new WeakMap();
29
+ }, j = (e) => {
30
+ const n = e ?? C;
31
+ return r.cacheEnabled = n, n;
32
+ }, f = (e) => {
33
+ const n = u.get(e);
34
+ if (n)
35
+ return r.markupCacheHits += 1, u.delete(e), u.set(e, n), n;
36
+ r.markupCacheMisses += 1, r.domIconCreations += 1;
37
+ const o = new H.map.DomIcon(e);
38
+ if (u.set(e, o), u.size > x) {
39
+ const c = u.keys().next().value;
40
+ c !== void 0 && u.delete(c);
41
+ }
42
+ return o;
43
+ }, R = (e, n = {}) => {
44
+ if (!e || v(e) || e instanceof H.map.DomIcon)
7
45
  return e || "";
8
- const t = v.isValidElement(e) ? k.renderToStaticMarkup(e) : e;
9
- return new H.map.DomIcon(t);
10
- }, i = (e, t) => {
11
- const { position: m, customData: n, icon: c, draggable: o, eventListenerMap: r } = e, a = l(c) ? H.map.DomMarker : H.map.Marker, s = new a(m, {
12
- icon: c && D(c)
13
- });
14
- return s.setData(n), s.draggable = !!o, t.map?.addObject(s), d(s, r, t.map), s;
15
- }, p = (e, t) => {
16
- f(e), t.map?.getObjects().includes(e) && t.map.removeObject(e), e.dispose();
17
- }, R = (e) => {
18
- const { position: t, customData: m, icon: n, eventListenerMap: c } = e, { api: o } = g(), r = I();
19
- return u(() => (r.current = i(e, o), () => {
20
- r.current && (p(r.current, o), r.current = void 0);
21
- }), []), u(() => {
22
- r.current && r.current.setGeometry(t);
23
- }, [t, r.current]), u(() => {
24
- r.current && r.current.setData(m);
25
- }, [m, r.current]), u(() => {
26
- if (r.current) {
27
- const a = f(r.current);
28
- d(r.current, c, a);
46
+ const o = j(n.cacheEnabled);
47
+ if (w.isValidElement(e)) {
48
+ const i = O.renderToStaticMarkup(e);
49
+ if (!o)
50
+ return r.reactElementCacheMisses += 1, r.domIconCreations += 1, r.uncachedDomIconCreations += 1, new H.map.DomIcon(i);
51
+ const a = M.get(e);
52
+ if (a)
53
+ return r.reactElementCacheHits += 1, a;
54
+ r.reactElementCacheMisses += 1;
55
+ const m = f(i);
56
+ return M.set(e, m), m;
57
+ }
58
+ const c = e;
59
+ return o ? f(c) : (r.domIconCreations += 1, r.uncachedDomIconCreations += 1, new H.map.DomIcon(c));
60
+ }, D = (e, n, o) => {
61
+ const { position: c, customData: i, icon: a, draggable: m, eventListenerMap: t } = e;
62
+ r.markerSetups += 1;
63
+ const d = p(a) ? H.map.DomMarker : H.map.Marker, s = new d(c, {
64
+ icon: a && R(a, { cacheEnabled: o })
65
+ }), I = n.map;
66
+ return s.setData(i), s.draggable = !!m, I?.addObject(s), I && g(s, t, I), s;
67
+ }, E = (e, n) => {
68
+ r.markerDestroys += 1, b(e), n.map?.getObjects().includes(e) && n.map.removeObject(e), e.dispose();
69
+ }, K = (e) => {
70
+ const { position: n, customData: o, icon: c, eventListenerMap: i } = e, { api: a, enableMarkerIconCache: m } = y(), t = k(), d = k(p(c));
71
+ return l(() => (t.current = D(e, a, m), d.current = p(c), () => {
72
+ t.current && (E(t.current, a), t.current = void 0);
73
+ }), []), l(() => {
74
+ t.current && t.current.setGeometry(n);
75
+ }, [n, t.current]), l(() => {
76
+ t.current && t.current.setData(o);
77
+ }, [o, t.current]), l(() => {
78
+ if (t.current) {
79
+ const s = b(t.current);
80
+ g(t.current, i, s);
29
81
  }
30
- }, [c, r.current]), u(() => {
31
- if (r.current && n)
32
- if (l(n))
33
- p(r.current, o), r.current = i(e, o);
34
- else {
35
- const a = D(n);
36
- a && r.current.setIcon(a);
37
- }
38
- }, [n, r.current]), null;
82
+ }, [i, t.current]), l(() => {
83
+ if (!(t.current && c))
84
+ return;
85
+ r.markerIconUpdates += 1;
86
+ const s = p(c);
87
+ if (d.current !== s)
88
+ r.markerIconRecreates += 1, E(t.current, a), t.current = D(e, a, m), d.current = s;
89
+ else {
90
+ const h = R(c, { cacheEnabled: m });
91
+ r.markerSetIconCalls += 1, h && t.current.setIcon(h);
92
+ }
93
+ }, [c, t.current, m]), null;
39
94
  };
40
95
  export {
41
- R as default,
42
- D as getOrCreateIcon,
43
- l as isDomMakerNeeded,
44
- M as isHMapIcon
96
+ G as clearMarkerIconCache,
97
+ K as default,
98
+ N as getMarkerDebugStats,
99
+ R as getOrCreateIcon,
100
+ p as isDomMakerNeeded,
101
+ v as isHMapIcon,
102
+ W as resetMarkerDebugStats,
103
+ z as setMarkerIconCacheEnabled
45
104
  };
46
105
  //# sourceMappingURL=Marker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Marker.js","sources":["../../../../../../src/components/map/components/features/basics/Marker.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport ReactDomServer from 'react-dom/server';\n\nimport { type EventListenerMap, addEventListenerMap, removeEventListenerMap } from '../../../utils/eventHandling';\nimport { useMapContext } from '../../MapContext';\nimport type { MapApi, Position } from '../../../utils/mapTypes';\n\nexport type MarkerIcon = string | React.ReactElement; // Element;\n\nexport const isHMapIcon = (icon: MarkerIcon | H.map.DomIcon | undefined) => icon instanceof H.map.Icon;\n\nexport const isDomMakerNeeded = (icon: MarkerIcon | H.map.DomIcon | undefined) => (!icon ? false : !isHMapIcon(icon));\n\n// Note:\n// H.map.Marker: A \"normal\" marker that uses a static image as an icon.\n// Large numbers of markers of this types can be added to the map very quickly and efficiently.\n// H.map.Dom: A marker which supports HTML (and SVG) content, which can be dynamic.\n// Markers of this type are best displayed individually or in small sets.\n// It is also important to note that Markers and DomMarkers are rendered in separate rendering steps.\n// Markers are rendered in the map scene and therefore appear behind any DomMarkers which are rendered\n// as an overlay on top of the map.\nexport const getOrCreateIcon = (icon: MarkerIcon | H.map.DomIcon | undefined) => {\n if (isHMapIcon(icon) || icon instanceof H.map.DomIcon) {\n return icon || '';\n }\n\n const renderedIcon = React.isValidElement(icon) ? ReactDomServer.renderToStaticMarkup(icon) : icon;\n\n return new H.map.DomIcon(renderedIcon as any);\n};\n\nconst setupMarker = (props: MarkerProps, api: MapApi) => {\n const { position, customData, icon, draggable, eventListenerMap } = props;\n\n const MarkerConstructor = isDomMakerNeeded(icon) ? H.map.DomMarker : H.map.Marker;\n\n const marker = new MarkerConstructor(position, {\n icon: icon && (getOrCreateIcon(icon) as any),\n });\n\n marker.setData(customData);\n marker.draggable = !!draggable;\n\n api.map?.addObject(marker);\n\n addEventListenerMap(marker, eventListenerMap, api.map!);\n\n return marker;\n};\n\nconst destroyMarker = (marker: H.map.DomMarker, api: MapApi) => {\n removeEventListenerMap(marker);\n if (api.map?.getObjects().includes(marker)) {\n api.map.removeObject(marker);\n }\n marker.dispose();\n};\n\nexport type MarkerProps = {\n position: Position;\n icon?: MarkerIcon;\n eventListenerMap?: EventListenerMap;\n customData?: object;\n draggable?: boolean;\n};\n\nconst Marker = (props: MarkerProps) => {\n const { position, customData, icon, eventListenerMap } = props;\n\n const { api } = useMapContext();\n\n const markerRef = useRef<H.map.DomMarker>();\n\n useEffect(() => {\n markerRef.current = setupMarker(props, api);\n\n return () => {\n if (markerRef.current) {\n destroyMarker(markerRef.current, api);\n markerRef.current = undefined;\n }\n };\n }, []);\n\n // Update marker position\n useEffect(() => {\n if (markerRef.current) {\n markerRef.current.setGeometry(position);\n }\n }, [position, markerRef.current]);\n\n // Update marker custom data\n useEffect(() => {\n if (markerRef.current) {\n markerRef.current.setData(customData);\n }\n }, [customData, markerRef.current]);\n\n // Update EventListenerMap\n useEffect(() => {\n if (markerRef.current) {\n // use exports to make methods accessible for stubbing\n const mapApi = removeEventListenerMap(markerRef.current);\n addEventListenerMap(markerRef.current, eventListenerMap, mapApi);\n }\n }, [eventListenerMap, markerRef.current]);\n\n // If icon type changed, we need to change the marker type\n useEffect(() => {\n if (!(markerRef.current && icon)) {\n return;\n }\n\n if (isDomMakerNeeded(icon)) {\n destroyMarker(markerRef.current, api);\n markerRef.current = setupMarker(props, api);\n } else {\n const domIcon = getOrCreateIcon(icon);\n domIcon && markerRef.current.setIcon(domIcon);\n }\n }, [icon, markerRef.current]);\n\n return null;\n};\n\nexport default Marker;\n"],"names":["isHMapIcon","icon","isDomMakerNeeded","getOrCreateIcon","renderedIcon","React","ReactDomServer","setupMarker","props","api","position","customData","draggable","eventListenerMap","MarkerConstructor","marker","addEventListenerMap","destroyMarker","removeEventListenerMap","Marker","useMapContext","markerRef","useRef","useEffect","mapApi","domIcon"],"mappings":";;;;AASO,MAAMA,IAAa,CAACC,MAAiDA,aAAgB,EAAE,IAAI,MAErFC,IAAmB,CAACD,MAAmDA,IAAe,CAACD,EAAWC,CAAI,IAAxB,IAU9EE,IAAkB,CAACF,MAAiD;AAC7E,MAAID,EAAWC,CAAI,KAAKA,aAAgB,EAAE,IAAI;AAC1C,WAAOA,KAAQ;AAGnB,QAAMG,IAAeC,EAAM,eAAeJ,CAAI,IAAIK,EAAe,qBAAqBL,CAAI,IAAIA;AAE9F,SAAO,IAAI,EAAE,IAAI,QAAQG,CAAmB;AAChD,GAEMG,IAAc,CAACC,GAAoBC,MAAgB;AACrD,QAAM,EAAE,UAAAC,GAAU,YAAAC,GAAY,MAAAV,GAAM,WAAAW,GAAW,kBAAAC,MAAqBL,GAE9DM,IAAoBZ,EAAiBD,CAAI,IAAI,EAAE,IAAI,YAAY,EAAE,IAAI,QAErEc,IAAS,IAAID,EAAkBJ,GAAU;AAAA,IAC3C,MAAMT,KAASE,EAAgBF,CAAI;AAAA,EAAA,CACtC;AAED,SAAAc,EAAO,QAAQJ,CAAU,GACzBI,EAAO,YAAY,CAAC,CAACH,GAErBH,E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;AACpC,QAAAwB,KAAWJ,EAAU,QAAQ,QAAQI,CAAO;AAAA,MAChD;AAAA,EACJ,GAAG,CAACxB,GAAMoB,EAAU,OAAO,CAAC,GAErB;AACX;"}
1
+ {"version":3,"file":"Marker.js","sources":["../../../../../../src/components/map/components/features/basics/Marker.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport ReactDomServer from 'react-dom/server';\n\nimport { type EventListenerMap, addEventListenerMap, removeEventListenerMap } from '../../../utils/eventHandling';\nimport { useMapContext } from '../../MapContext';\nimport type { MapApi, Position } from '../../../utils/mapTypes';\n\nexport type MarkerIcon = string | React.ReactElement; // Element;\ntype MapMarkerObject = H.map.Marker | H.map.DomMarker;\ntype GetOrCreateIconOptions = {\n cacheEnabled?: boolean;\n};\n\nexport const isHMapIcon = (icon: MarkerIcon | H.map.DomIcon | undefined) => icon instanceof H.map.Icon;\n\nexport const isDomMakerNeeded = (icon: MarkerIcon | H.map.DomIcon | undefined) => (!icon ? false : !isHMapIcon(icon));\n\nconst DOM_ICON_CACHE_MAX_SIZE = 500;\nconst domIconCache = new Map<string, H.map.DomIcon>();\n\nlet reactElementIconCache = new WeakMap<React.ReactElement, H.map.DomIcon>();\nlet markerIconCacheEnabled = true;\n\ntype MarkerDebugStats = {\n cacheEnabled: boolean;\n domIconCreations: number;\n markupCacheHits: number;\n markupCacheMisses: number;\n reactElementCacheHits: number;\n reactElementCacheMisses: number;\n uncachedDomIconCreations: number;\n markerSetups: number;\n markerDestroys: number;\n markerIconUpdates: number;\n markerIconRecreates: number;\n markerSetIconCalls: number;\n};\n\nconst createMarkerDebugStats = (): MarkerDebugStats => ({\n cacheEnabled: markerIconCacheEnabled,\n domIconCreations: 0,\n markupCacheHits: 0,\n markupCacheMisses: 0,\n reactElementCacheHits: 0,\n reactElementCacheMisses: 0,\n uncachedDomIconCreations: 0,\n markerSetups: 0,\n markerDestroys: 0,\n markerIconUpdates: 0,\n markerIconRecreates: 0,\n markerSetIconCalls: 0,\n});\n\nconst markerDebugStats = createMarkerDebugStats();\n\nexport const getMarkerDebugStats = () => ({\n ...markerDebugStats,\n cacheEnabled: markerIconCacheEnabled,\n});\n\nexport const resetMarkerDebugStats = () => {\n Object.assign(markerDebugStats, createMarkerDebugStats());\n};\n\nexport const setMarkerIconCacheEnabled = (enabled: boolean) => {\n markerIconCacheEnabled = enabled;\n};\n\nexport const clearMarkerIconCache = () => {\n domIconCache.clear();\n reactElementIconCache = new WeakMap<React.ReactElement, H.map.DomIcon>();\n};\n\nconst resolveCacheEnabled = (cacheEnabled?: boolean) => {\n const resolvedCacheEnabled = cacheEnabled ?? markerIconCacheEnabled;\n markerDebugStats.cacheEnabled = resolvedCacheEnabled;\n return resolvedCacheEnabled;\n};\n\nconst getCachedDomIcon = (markup: string) => {\n const cachedIcon = domIconCache.get(markup);\n\n if (cachedIcon) {\n markerDebugStats.markupCacheHits += 1;\n // Refresh insertion order so frequently used icons stay in the cache longer.\n domIconCache.delete(markup);\n domIconCache.set(markup, cachedIcon);\n return cachedIcon;\n }\n\n markerDebugStats.markupCacheMisses += 1;\n markerDebugStats.domIconCreations += 1;\n\n const nextIcon = new H.map.DomIcon(markup);\n domIconCache.set(markup, nextIcon);\n\n if (domIconCache.size > DOM_ICON_CACHE_MAX_SIZE) {\n const oldestKey = domIconCache.keys().next().value;\n\n if (oldestKey !== undefined) {\n domIconCache.delete(oldestKey);\n }\n }\n\n return nextIcon;\n};\n\n// Note:\n// H.map.Marker: A \"normal\" marker that uses a static image as an icon.\n// Large numbers of markers of this types can be added to the map very quickly and efficiently.\n// H.map.Dom: A marker which supports HTML (and SVG) content, which can be dynamic.\n// Markers of this type are best displayed individually or in small sets.\n// It is also important to note that Markers and DomMarkers are rendered in separate rendering steps.\n// Markers are rendered in the map scene and therefore appear behind any DomMarkers which are rendered\n// as an overlay on top of the map.\nexport const getOrCreateIcon = (icon: MarkerIcon | H.map.DomIcon | undefined, options: GetOrCreateIconOptions = {}) => {\n if (!icon || isHMapIcon(icon) || icon instanceof H.map.DomIcon) {\n return icon || '';\n }\n\n const cacheEnabled = resolveCacheEnabled(options.cacheEnabled);\n\n if (React.isValidElement(icon)) {\n const renderedIcon = ReactDomServer.renderToStaticMarkup(icon);\n\n if (!cacheEnabled) {\n markerDebugStats.reactElementCacheMisses += 1;\n markerDebugStats.domIconCreations += 1;\n markerDebugStats.uncachedDomIconCreations += 1;\n return new H.map.DomIcon(renderedIcon);\n }\n\n const cachedElementIcon = reactElementIconCache.get(icon);\n\n if (cachedElementIcon) {\n markerDebugStats.reactElementCacheHits += 1;\n return cachedElementIcon;\n }\n\n markerDebugStats.reactElementCacheMisses += 1;\n const cachedMarkupIcon = getCachedDomIcon(renderedIcon);\n reactElementIconCache.set(icon, cachedMarkupIcon);\n\n return cachedMarkupIcon;\n }\n\n const stringIcon = icon as string;\n\n if (!cacheEnabled) {\n markerDebugStats.domIconCreations += 1;\n markerDebugStats.uncachedDomIconCreations += 1;\n return new H.map.DomIcon(stringIcon);\n }\n\n return getCachedDomIcon(stringIcon);\n};\n\nconst setupMarker = (props: MarkerProps, api: MapApi, cacheEnabled?: boolean) => {\n const { position, customData, icon, draggable, eventListenerMap } = props;\n\n markerDebugStats.markerSetups += 1;\n\n const MarkerConstructor = isDomMakerNeeded(icon) ? H.map.DomMarker : H.map.Marker;\n\n const marker = new MarkerConstructor(position, {\n icon: icon && getOrCreateIcon(icon, { cacheEnabled }),\n });\n\n const map = api.map;\n\n marker.setData(customData);\n marker.draggable = !!draggable;\n\n map?.addObject(marker);\n\n if (map) {\n addEventListenerMap(marker, eventListenerMap, map);\n }\n\n return marker;\n};\n\nconst destroyMarker = (marker: MapMarkerObject, api: MapApi) => {\n markerDebugStats.markerDestroys += 1;\n removeEventListenerMap(marker);\n if (api.map?.getObjects().includes(marker)) {\n api.map.removeObject(marker);\n }\n marker.dispose();\n};\n\nexport type MarkerProps = {\n position: Position;\n icon?: MarkerIcon;\n eventListenerMap?: EventListenerMap;\n customData?: object;\n draggable?: boolean;\n};\n\nconst Marker = (props: MarkerProps) => {\n const { position, customData, icon, eventListenerMap } = props;\n\n const { api, enableMarkerIconCache } = useMapContext();\n\n const markerRef = useRef<MapMarkerObject>();\n const markerUsesDomIconRef = useRef<boolean>(isDomMakerNeeded(icon));\n\n useEffect(() => {\n markerRef.current = setupMarker(props, api, enableMarkerIconCache);\n markerUsesDomIconRef.current = isDomMakerNeeded(icon);\n\n return () => {\n if (markerRef.current) {\n destroyMarker(markerRef.current, api);\n markerRef.current = undefined;\n }\n };\n }, []);\n\n // Update marker position\n useEffect(() => {\n if (markerRef.current) {\n markerRef.current.setGeometry(position);\n }\n }, [position, markerRef.current]);\n\n // Update marker custom data\n useEffect(() => {\n if (markerRef.current) {\n markerRef.current.setData(customData);\n }\n }, [customData, markerRef.current]);\n\n // Update EventListenerMap\n useEffect(() => {\n if (markerRef.current) {\n // use exports to make methods accessible for stubbing\n const mapApi = removeEventListenerMap(markerRef.current);\n addEventListenerMap(markerRef.current, eventListenerMap, mapApi);\n }\n }, [eventListenerMap, markerRef.current]);\n\n // If icon type changed, we need to change the marker type\n useEffect(() => {\n if (!(markerRef.current && icon)) {\n return;\n }\n\n markerDebugStats.markerIconUpdates += 1;\n\n const nextUsesDomIcon = isDomMakerNeeded(icon);\n const shouldRecreateMarker = markerUsesDomIconRef.current !== nextUsesDomIcon;\n\n if (shouldRecreateMarker) {\n markerDebugStats.markerIconRecreates += 1;\n destroyMarker(markerRef.current, api);\n markerRef.current = setupMarker(props, api, enableMarkerIconCache);\n markerUsesDomIconRef.current = nextUsesDomIcon;\n } else {\n const domIcon = getOrCreateIcon(icon, { cacheEnabled: enableMarkerIconCache });\n markerDebugStats.markerSetIconCalls += 1;\n domIcon && markerRef.current.setIcon(domIcon);\n }\n }, [icon, markerRef.current, enableMarkerIconCache]);\n\n return null;\n};\n\nexport default Marker;\n"],"names":["isHMapIcon","icon","isDomMakerNeeded","DOM_ICON_CACHE_MAX_SIZE","domIconCache","reactElementIconCache","markerIconCacheEnabled","createMarkerDebugStats","markerDebugStats","getMarkerDebugStats","resetMarkerDebugStats","setMarkerIconCacheEnabled","enabled","clearMarkerIconCache","resolveCacheEnabled","cacheEnabled","resolvedCacheEnabled","getCachedDomIcon","markup","cachedIcon","nextIcon","oldestKey","getOrCreateIcon","options","React","renderedIcon","ReactDomServer","cachedElementIcon","cachedMarkupIcon","stringIcon","setupMarker","props","api","position","customData","draggable","eventListenerMap","MarkerConstructor","marker","map","addEventListenerMap","destroyMarker","removeEventListenerMap","Marker","enableMarkerIconCache","useMapContext","markerRef","useRef","markerUsesDomIconRef","useEffect","mapApi","nextUsesDomIcon","domIcon"],"mappings":";;;;AAaO,MAAMA,IAAa,CAACC,MAAiDA,aAAgB,EAAE,IAAI,MAErFC,IAAmB,CAACD,MAAmDA,IAAe,CAACD,EAAWC,CAAI,IAAxB,IAErFE,IAA0B,KAC1BC,wBAAmB,IAAA;AAEzB,IAAIC,wBAA4B,QAAA,GAC5BC,IAAyB;AAiB7B,MAAMC,IAAyB,OAAyB;AAAA,EACpD,cAAcD;AAAA,EACd,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,uBAAuB;AAAA,EACvB,yBAAyB;AAAA,EACzB,0BAA0B;AAAA,EAC1B,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,oBAAoB;AACxB,IAEME,IAAmBD,EAAA,GAEZE,IAAsB,OAAO;AAAA,EACtC,GAAGD;AAAA,EACH,cAAcF;AAClB,IAEaI,IAAwB,MAAM;AACvC,SAAO,OAAOF,GAAkBD,GAAwB;AAC5D,GAEaI,IAA4B,CAACC,MAAqB;AAC3D,EAAAN,IAAyBM;AAC7B,GAEaC,IAAuB,MAAM;AACtC,EAAAT,EAAa,MAAA,GACbC,wBAA4B,QAAA;AAChC,GAEMS,IAAsB,CAACC,MAA2B;AACpD,QAAMC,IAAuBD,KAAgBT;AAC7C,SAAAE,EAAiB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U,MAAM;AACZ,IAAIH,EAAU,WACVA,EAAU,QAAQ,YAAYb,CAAQ;AAAA,EAE9C,GAAG,CAACA,GAAUa,EAAU,OAAO,CAAC,GAGhCG,EAAU,MAAM;AACZ,IAAIH,EAAU,WACVA,EAAU,QAAQ,QAAQZ,CAAU;AAAA,EAE5C,GAAG,CAACA,GAAYY,EAAU,OAAO,CAAC,GAGlCG,EAAU,MAAM;AACZ,QAAIH,EAAU,SAAS;AAEnB,YAAMI,IAASR,EAAuBI,EAAU,OAAO;AACvD,MAAAN,EAAoBM,EAAU,SAASV,GAAkBc,CAAM;AAAA,IACnE;AAAA,EACJ,GAAG,CAACd,GAAkBU,EAAU,OAAO,CAAC,GAGxCG,EAAU,MAAM;AACZ,QAAI,EAAEH,EAAU,WAAW7C;AACvB;AAGJ,IAAAO,EAAiB,qBAAqB;AAEtC,UAAM2C,IAAkBjD,EAAiBD,CAAI;AAG7C,QAF6B+C,EAAqB,YAAYG;AAG1D,MAAA3C,EAAiB,uBAAuB,GACxCiC,EAAcK,EAAU,SAASd,CAAG,GACpCc,EAAU,UAAUhB,EAAYC,GAAOC,GAAKY,CAAqB,GACjEI,EAAqB,UAAUG;AAAA,SAC5B;AACH,YAAMC,IAAU9B,EAAgBrB,GAAM,EAAE,cAAc2C,GAAuB;AAC7E,MAAApC,EAAiB,sBAAsB,GACvC4C,KAAWN,EAAU,QAAQ,QAAQM,CAAO;AAAA,IAChD;AAAA,EACJ,GAAG,CAACnD,GAAM6C,EAAU,SAASF,CAAqB,CAAC,GAE5C;AACX;"}
@@ -1,11 +1,34 @@
1
+ import { CSSProperties } from 'react';
1
2
  import { Position } from '../../../utils/mapTypes';
2
3
  import { EventListenerMap } from '../../../utils/eventHandling';
3
4
  export { colorMapColdplay, colorMapWarmup, colorMapGray, colorMapBrand, colorMapStatus, colorMapMarker, colorMapRating, colorMapHighlight, } from './polygonColors';
4
5
  export type PolygonPoints = Position[] & Record<string, any>;
6
+ export type PolygonStyle = H.map.SpatialStyle | H.map.SpatialStyle.Options;
5
7
  export type PolygonProps = {
8
+ /**
9
+ * Ordered geographic positions that define the polygon geometry.
10
+ */
6
11
  points: PolygonPoints;
7
- style?: H.map.SpatialStyle;
12
+ /**
13
+ * Visual style applied to the polygon.
14
+ *
15
+ * @default H.map.SpatialStyle.DEFAULT_STYLE
16
+ *
17
+ */
18
+ style?: PolygonStyle;
19
+ /**
20
+ * Style overrides applied while the polygon is hovered.
21
+ */
22
+ hoverStyle?: PolygonStyle;
23
+ /**
24
+ * Event handlers attached to the polygon.
25
+ */
8
26
  eventListenerMap?: EventListenerMap;
27
+ /**
28
+ * Cursor shown while hovering the polygon.
29
+ * If omitted, clickable polygons automatically use `pointer`.
30
+ */
31
+ cursor?: CSSProperties['cursor'];
9
32
  };
10
33
  declare const Polygon: (props: PolygonProps) => null;
11
34
  export default Polygon;
@@ -1,24 +1,77 @@
1
- import { useState as g, useEffect as a } from "react";
2
- import { isNil as l } from "es-toolkit/predicate";
3
- import { useMapContext as u } from "../../MapContext.js";
4
- import { useUpdateProp as c, useUpdateEventListenerMap as f } from "../../../utils/hooks.js";
5
- const i = (s) => {
6
- const t = new H.geo.LineString();
7
- return s.forEach((e) => {
8
- l(e.lat) || l(e.lng) || Number.isNaN(e.lat) || Number.isNaN(e.lng) || t.pushLatLngAlt(e.lat, e.lng, 0);
9
- }), new H.geo.Polygon(t);
10
- }, S = (s) => {
11
- const { points: t, style: e = H.map.SpatialStyle.DEFAULT_STYLE, eventListenerMap: m } = s, { api: n } = u(), [r, p] = g();
12
- return a(() => {
13
- const o = new H.map.Polygon(i(t), { style: e });
14
- return n.map?.addObject(o), p(o), () => {
15
- n.map?.getObjects().includes(o) && n.map?.removeObject(o), o.dispose();
1
+ import { useState as v, useRef as y, useMemo as C, useEffect as E } from "react";
2
+ import { isNil as S } from "es-toolkit/predicate";
3
+ import { useMapContext as R } from "../../MapContext.js";
4
+ import { useUpdateEventListenerMap as h } from "../../../utils/hooks.js";
5
+ import { EventUtils as a } from "../../../utils/eventHandling.js";
6
+ const T = (e) => {
7
+ const p = new H.geo.LineString();
8
+ return e.forEach((r) => {
9
+ S(r.lat) || S(r.lng) || Number.isNaN(r.lat) || Number.isNaN(r.lng) || p.pushLatLngAlt(r.lat, r.lng, 0);
10
+ }), new H.geo.Polygon(p);
11
+ }, L = (e) => {
12
+ if (e)
13
+ return e instanceof H.map.SpatialStyle ? {
14
+ strokeColor: e.strokeColor,
15
+ fillColor: e.fillColor,
16
+ lineWidth: e.lineWidth,
17
+ lineCap: e.lineCap,
18
+ lineHeadCap: e.lineHeadCap,
19
+ lineTailCap: e.lineTailCap,
20
+ lineJoin: e.lineJoin,
21
+ miterLimit: e.miterLimit,
22
+ lineDash: e.lineDash,
23
+ lineDashOffset: e.lineDashOffset
24
+ } : e;
25
+ }, M = (e) => {
26
+ const { points: p, style: r = H.map.SpatialStyle.DEFAULT_STYLE, hoverStyle: f, eventListenerMap: o, cursor: g } = e, { api: i } = R(), [n, P] = v(), m = y(!1), l = C(() => {
27
+ if (g)
28
+ return g;
29
+ if (o?.[a.TAP] || o?.[a.DBL_TAP] || o?.[a.CONTEXTMENU])
30
+ return "pointer";
31
+ }, [g, o]), s = C(() => {
32
+ if (f)
33
+ return new H.map.SpatialStyle({
34
+ ...L(r),
35
+ ...L(f)
36
+ });
37
+ }, [f, r]), u = (t, N) => {
38
+ t.setStyle(N && s ? s : r);
39
+ }, c = (t) => {
40
+ if (!i.map)
41
+ return;
42
+ const N = i.map.getElement(), O = i.map.getViewPort().element;
43
+ N.style.cursor = t, O.style.cursor = t;
44
+ };
45
+ E(() => {
46
+ const t = new H.map.Polygon(T(p), { style: r });
47
+ return i.map?.addObject(t), P(t), () => {
48
+ i.map?.getObjects().includes(t) && i.map?.removeObject(t), t.dispose();
16
49
  };
17
- }, [n.map]), a(() => {
18
- r && r.setGeometry(i(t));
19
- }, [t]), c(r, "setStyle", e), f(r, m), null;
50
+ }, [i.map]), E(() => {
51
+ n && n.setGeometry(T(p));
52
+ }, [p]), E(() => {
53
+ n && u(n, m.current);
54
+ }, [n, r, s]), E(
55
+ () => () => {
56
+ l && c("");
57
+ },
58
+ [i.map, l]
59
+ );
60
+ const d = C(() => o || f || l ? {
61
+ ...o,
62
+ [a.POINTER_ENTER]: (...t) => {
63
+ n && s && (m.current = !0, u(n, !0)), l && c(l), o?.[a.POINTER_ENTER]?.(...t);
64
+ },
65
+ [a.POINTER_LEAVE]: (...t) => {
66
+ n && s && (m.current = !1, u(n, !1)), l && c(""), o?.[a.POINTER_LEAVE]?.(...t);
67
+ },
68
+ [a.POINTER_CANCEL]: (...t) => {
69
+ n && s && (m.current = !1, u(n, !1)), l && c(""), o?.[a.POINTER_CANCEL]?.(...t);
70
+ }
71
+ } : o, [i.map, o, n, s, l]);
72
+ return h(n, d), null;
20
73
  };
21
74
  export {
22
- S as default
75
+ M as default
23
76
  };
24
77
  //# sourceMappingURL=Polygon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Polygon.js","sources":["../../../../../../src/components/map/components/features/basics/Polygon.tsx"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { isNil } from 'es-toolkit/predicate';\n\nimport { useMapContext } from '../../MapContext';\nimport { useUpdateProp, useUpdateEventListenerMap } from '../../../utils/hooks';\nimport type { Position } from '../../../utils/mapTypes';\nimport type { EventListenerMap } from '../../../utils/eventHandling';\n\nexport {\n colorMapColdplay,\n colorMapWarmup,\n colorMapGray,\n colorMapBrand,\n colorMapStatus,\n colorMapMarker,\n colorMapRating,\n colorMapHighlight,\n} from './polygonColors';\n\nconst createGeometry = (points: Position[]) => {\n const lineString = new H.geo.LineString();\n\n points.forEach(p => {\n if (isNil(p.lat) || isNil(p.lng) || Number.isNaN(p.lat) || Number.isNaN(p.lng)) {\n return;\n }\n lineString.pushLatLngAlt(p.lat, p.lng, 0);\n });\n\n return new H.geo.Polygon(lineString);\n};\n\nexport type PolygonPoints = Position[] & Record<string, any>;\n\nexport type PolygonProps = {\n points: PolygonPoints;\n style?: H.map.SpatialStyle;\n eventListenerMap?: EventListenerMap;\n};\n\nconst Polygon = (props: PolygonProps) => {\n const { points, style = H.map.SpatialStyle.DEFAULT_STYLE, eventListenerMap } = props;\n\n const { api } = useMapContext();\n const [polygon, setPolygon] = useState<H.map.Polygon>();\n\n useEffect(() => {\n const newPolygon = new H.map.Polygon(createGeometry(points), { style });\n api.map?.addObject(newPolygon);\n\n setPolygon(newPolygon);\n\n return () => {\n if (api.map?.getObjects().includes(newPolygon)) {\n api.map?.removeObject(newPolygon);\n }\n newPolygon.dispose();\n };\n }, [api.map]);\n\n useEffect(() => {\n if (polygon) {\n polygon.setGeometry(createGeometry(points));\n }\n }, [points]);\n\n useUpdateProp(polygon, 'setStyle', style);\n useUpdateEventListenerMap(polygon, eventListenerMap);\n\n return null;\n};\n\nexport default Polygon;\n"],"names":["createGeometry","points","lineString","p","isNil","Polygon","props","style","eventListenerMap","api","useMapContext","polygon","setPolygon","useState","useEffect","newPolygon","useUpdateProp","useUpdateEventListenerMap"],"mappings":";;;;AAmBA,MAAMA,IAAiB,CAACC,MAAuB;AAC3C,QAAMC,IAAa,IAAI,EAAE,IAAI,WAAA;AAE7B,SAAAD,EAAO,QAAQ,CAAAE,MAAK;AAChB,IAAIC,EAAMD,EAAE,GAAG,KAAKC,EAAMD,EAAE,GAAG,KAAK,OAAO,MAAMA,EAAE,GAAG,KAAK,OAAO,MAAMA,EAAE,GAAG,KAG7ED,EAAW,cAAcC,EAAE,KAAKA,EAAE,KAAK,CAAC;AAAA,EAC5C,CAAC,GAEM,IAAI,EAAE,IAAI,QAAQD,CAAU;AACvC,GAUMG,IAAU,CAACC,MAAwB;AACrC,QAAM,EAAE,QAAAL,GAAQ,OAAAM,IAAQ,EAAE,IAAI,aAAa,eAAe,kBAAAC,MAAqBF,GAEzE,EAAE,KAAAG,EAAA,IAAQC,EAAA,GACV,CAACC,GAASC,CAAU,IAAIC,EAAA;AAE9B,SAAAC,EAAU,MAAM;AACZ,UAAMC,IAAa,IAAI,EAAE,IAAI,QAAQf,EAAeC,CAAM,GAAG,EAAE,OAAAM,GAAO;AACtE,WAAAE,EAAI,KAAK,UAAUM,CAAU,GAE7BH,EAAWG,CAAU,GAEd,MAAM;AACT,MAAIN,EAAI,KAAK,WAAA,EAAa,SAASM,CAAU,KACzCN,EAAI,KAAK,aAAaM,CAAU,GAEpCA,EAAW,QAAA;AAAA,IACf;AAAA,EACJ,GAAG,CAACN,EAAI,GAAG,CAAC,GAEZK,EAAU,MAAM;AACZ,IAAIH,KACAA,EAAQ,YAAYX,EAAeC,CAAM,CAAC;AAAA,EAElD,GAAG,CAACA,CAAM,CAAC,GAEXe,EAAcL,GAAS,YAAYJ,CAAK,GACxCU,EAA0BN,GAASH,CAAgB,GAE5C;AACX;"}
1
+ {"version":3,"file":"Polygon.js","sources":["../../../../../../src/components/map/components/features/basics/Polygon.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState, type CSSProperties } from 'react';\nimport { isNil } from 'es-toolkit/predicate';\n\nimport { useMapContext } from '../../MapContext';\nimport { useUpdateEventListenerMap } from '../../../utils/hooks';\nimport type { Position } from '../../../utils/mapTypes';\nimport { EventUtils, type EventListenerMap } from '../../../utils/eventHandling';\n\nexport {\n colorMapColdplay,\n colorMapWarmup,\n colorMapGray,\n colorMapBrand,\n colorMapStatus,\n colorMapMarker,\n colorMapRating,\n colorMapHighlight,\n} from './polygonColors';\n\nconst createGeometry = (points: Position[]) => {\n const lineString = new H.geo.LineString();\n\n points.forEach(p => {\n if (isNil(p.lat) || isNil(p.lng) || Number.isNaN(p.lat) || Number.isNaN(p.lng)) {\n return;\n }\n lineString.pushLatLngAlt(p.lat, p.lng, 0);\n });\n\n return new H.geo.Polygon(lineString);\n};\n\nexport type PolygonPoints = Position[] & Record<string, any>;\nexport type PolygonStyle = H.map.SpatialStyle | H.map.SpatialStyle.Options;\n\nconst toSpatialStyleOptions = (style?: PolygonStyle): H.map.SpatialStyle.Options | undefined => {\n if (!style) {\n return;\n }\n\n if (style instanceof H.map.SpatialStyle) {\n return {\n strokeColor: style.strokeColor,\n fillColor: style.fillColor,\n lineWidth: style.lineWidth,\n lineCap: style.lineCap,\n lineHeadCap: style.lineHeadCap,\n lineTailCap: style.lineTailCap,\n lineJoin: style.lineJoin,\n miterLimit: style.miterLimit,\n lineDash: style.lineDash,\n lineDashOffset: style.lineDashOffset,\n };\n }\n\n return style;\n};\n\nexport type PolygonProps = {\n /**\n * Ordered geographic positions that define the polygon geometry.\n */\n points: PolygonPoints;\n\n /**\n * Visual style applied to the polygon.\n *\n * @default H.map.SpatialStyle.DEFAULT_STYLE\n *\n */\n style?: PolygonStyle;\n\n /**\n * Style overrides applied while the polygon is hovered.\n */\n hoverStyle?: PolygonStyle;\n\n /**\n * Event handlers attached to the polygon.\n */\n eventListenerMap?: EventListenerMap;\n\n /**\n * Cursor shown while hovering the polygon.\n * If omitted, clickable polygons automatically use `pointer`.\n */\n cursor?: CSSProperties['cursor'];\n};\n\nconst Polygon = (props: PolygonProps) => {\n const { points, style = H.map.SpatialStyle.DEFAULT_STYLE, hoverStyle, eventListenerMap, cursor } = props;\n\n const { api } = useMapContext();\n const [polygon, setPolygon] = useState<H.map.Polygon>();\n const isHoveredRef = useRef(false);\n\n const resolvedCursor = useMemo(() => {\n if (cursor) {\n return cursor;\n }\n\n if (\n eventListenerMap?.[EventUtils.TAP] ||\n eventListenerMap?.[EventUtils.DBL_TAP] ||\n eventListenerMap?.[EventUtils.CONTEXTMENU]\n ) {\n return 'pointer';\n }\n }, [cursor, eventListenerMap]);\n\n const mergedHoverStyle = useMemo(() => {\n if (!hoverStyle) {\n return;\n }\n\n return new H.map.SpatialStyle({\n ...toSpatialStyleOptions(style),\n ...toSpatialStyleOptions(hoverStyle),\n });\n }, [hoverStyle, style]);\n\n const applyPolygonStyle = (nextPolygon: H.map.Polygon, hovered: boolean) => {\n nextPolygon.setStyle(hovered && mergedHoverStyle ? mergedHoverStyle : style);\n };\n\n const applyCursor = (nextCursor: string) => {\n if (!api.map) {\n return;\n }\n\n const mapElement = api.map.getElement() as HTMLElement;\n const viewportElement = api.map.getViewPort().element as HTMLElement;\n\n mapElement.style.cursor = nextCursor;\n viewportElement.style.cursor = nextCursor;\n };\n\n useEffect(() => {\n const newPolygon = new H.map.Polygon(createGeometry(points), { style });\n api.map?.addObject(newPolygon);\n\n setPolygon(newPolygon);\n\n return () => {\n if (api.map?.getObjects().includes(newPolygon)) {\n api.map?.removeObject(newPolygon);\n }\n newPolygon.dispose();\n };\n }, [api.map]);\n\n useEffect(() => {\n if (polygon) {\n polygon.setGeometry(createGeometry(points));\n }\n }, [points]);\n\n useEffect(() => {\n if (polygon) {\n applyPolygonStyle(polygon, isHoveredRef.current);\n }\n }, [polygon, style, mergedHoverStyle]);\n\n useEffect(\n () => () => {\n if (resolvedCursor) {\n applyCursor('');\n }\n },\n [api.map, resolvedCursor]\n );\n\n const resolvedEventListenerMap = useMemo(() => {\n if (!(eventListenerMap || hoverStyle || resolvedCursor)) {\n return eventListenerMap;\n }\n\n return {\n ...eventListenerMap,\n [EventUtils.POINTER_ENTER]: (...args: unknown[]) => {\n if (polygon && mergedHoverStyle) {\n isHoveredRef.current = true;\n applyPolygonStyle(polygon, true);\n }\n\n if (resolvedCursor) {\n applyCursor(resolvedCursor);\n }\n\n eventListenerMap?.[EventUtils.POINTER_ENTER]?.(...args);\n },\n [EventUtils.POINTER_LEAVE]: (...args: unknown[]) => {\n if (polygon && mergedHoverStyle) {\n isHoveredRef.current = false;\n applyPolygonStyle(polygon, false);\n }\n\n if (resolvedCursor) {\n applyCursor('');\n }\n\n eventListenerMap?.[EventUtils.POINTER_LEAVE]?.(...args);\n },\n [EventUtils.POINTER_CANCEL]: (...args: unknown[]) => {\n if (polygon && mergedHoverStyle) {\n isHoveredRef.current = false;\n applyPolygonStyle(polygon, false);\n }\n\n if (resolvedCursor) {\n applyCursor('');\n }\n\n eventListenerMap?.[EventUtils.POINTER_CANCEL]?.(...args);\n },\n } satisfies EventListenerMap;\n }, [api.map, eventListenerMap, polygon, mergedHoverStyle, resolvedCursor]);\n\n useUpdateEventListenerMap(polygon, resolvedEventListenerMap);\n\n return null;\n};\n\nexport default Polygon;\n"],"names":["createGeometry","points","lineString","p","isNil","toSpatialStyleOptions","style","Polygon","props","hoverStyle","eventListenerMap","cursor","api","useMapContext","polygon","setPolygon","useState","isHoveredRef","useRef","resolvedCursor","useMemo","EventUtils","mergedHoverStyle","applyPolygonStyle","nextPolygon","hovered","applyCursor","nextCursor","mapElement","viewportElement","useEffect","newPolygon","resolvedEventListenerMap","args","useUpdateEventListenerMap"],"mappings":";;;;;AAmBA,MAAMA,IAAiB,CAACC,MAAuB;AAC3C,QAAMC,IAAa,IAAI,EAAE,IAAI,WAAA;AAE7B,SAAAD,EAAO,QAAQ,CAAAE,MAAK;AAChB,IAAIC,EAAMD,EAAE,GAAG,KAAKC,EAAMD,EAAE,GAAG,KAAK,OAAO,MAAMA,EAAE,GAAG,KAAK,OAAO,MAAMA,EAAE,GAAG,KAG7ED,EAAW,cAAcC,EAAE,KAAKA,EAAE,KAAK,CAAC;AAAA,EAC5C,CAAC,GAEM,IAAI,EAAE,IAAI,QAAQD,CAAU;AACvC,GAKMG,IAAwB,CAACC,MAAiE;AAC5F,MAAKA;AAIL,WAAIA,aAAiB,EAAE,IAAI,eAChB;AAAA,MACH,aAAaA,EAAM;AAAA,MACnB,WAAWA,EAAM;AAAA,MACjB,WAAWA,EAAM;AAAA,MACjB,SAASA,EAAM;AAAA,MACf,aAAaA,EAAM;AAAA,MACnB,aAAaA,EAAM;AAAA,MACnB,UAAUA,EAAM;AAAA,MAChB,YAAYA,EAAM;AAAA,MAClB,UAAUA,EAAM;AAAA,MAChB,gBAAgBA,EAAM;AAAA,IAAA,IAIvBA;AACX,GAiCMC,IAAU,CAACC,MAAwB;AACrC,QAAM,EAAE,QAAAP,GAAQ,OAAAK,IAAQ,EAAE,IAAI,aAAa,eAAe,YAAAG,GAAY,kBAAAC,GAAkB,QAAAC,EAAA,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olylineObjects = {
9
+ group: H.map.Group;
10
+ line: H.map.Polyline;
11
+ routeArrows?: H.map.Polyline;
12
+ };
8
13
  export type PolylineProps = {
14
+ /**
15
+ * Controls whether directional arrows are rendered on the polyline.
16
+ */
9
17
  hasArrows?: boolean;
18
+ /**
19
+ * Defines the arrow appearance when arrows are rendered.
20
+ */
10
21
  arrowStyle?: ArrowStyle;
22
+ /**
23
+ * Geometry used to render the polyline.
24
+ */
11
25
  geometry: H.geo.LineString;
26
+ /**
27
+ * Visual style applied to the main polyline.
28
+ *
29
+ * @default H.map.SpatialStyle.DEFAULT_STYLE
30
+ */
12
31
  style?: H.map.SpatialStyle;
32
+ /**
33
+ * Custom payload forwarded to the rendered polyline objects and their events.
34
+ */
13
35
  customData?: object;
36
+ /**
37
+ * Event handlers attached to the polyline.
38
+ */
14
39
  eventListenerMap?: EventListenerMap;
40
+ /**
41
+ * Receives the created HERE polyline objects once they are mounted and `undefined` on cleanup.
42
+ */
43
+ onReady?: (objects?: PolylineObjects) => void;
15
44
  };
16
45
  declare const Polyline: (props: PolylineProps) => null;
17
46
  export default Polyline;
@@ -1,65 +1,95 @@
1
- import { useState as u, useEffect as b } from "react";
2
- import { useMapContext as O } from "../../MapContext.js";
3
- import s from "../../../exceptions/MapException.js";
4
- import { useUpdateEventListenerMap as P } from "../../../utils/hooks.js";
5
- import { removeEventListenerMap as g } from "../../../utils/eventHandling.js";
6
- import { isVectorBased as h } from "../../../utils/rendering.js";
7
- const M = "Error in Polyline: Polyline without geometry makes no sense", C = "Error in Polyline: property geometry must be of type H.geo.LineString", v = (p) => {
1
+ import { useState as M, useRef as h, useEffect as d, useMemo as S } from "react";
2
+ import { useMapContext as I } from "../../MapContext.js";
3
+ import b from "../../../exceptions/MapException.js";
4
+ import { EventUtils as i, removeEventListenerMap as p, addEventListenerMap as w } from "../../../utils/eventHandling.js";
5
+ import { isVectorBased as v } from "../../../utils/rendering.js";
6
+ const j = "Error in Polyline: Polyline without geometry makes no sense", A = "Error in Polyline: property geometry must be of type H.geo.LineString", V = (T) => {
8
7
  const {
9
- geometry: t,
10
- hasArrows: n,
11
- arrowStyle: a,
12
- style: l = H.map.SpatialStyle.DEFAULT_STYLE,
13
- customData: m,
14
- eventListenerMap: y
15
- } = p, { api: r, enableWebGL: c, baseLayer: d } = O(), [f, S] = u();
16
- if (!t)
17
- throw new s(M);
18
- if (!(t instanceof H.geo.LineString))
19
- throw new s(C);
20
- return b(() => {
21
- const e = new H.map.Group({ data: m }), i = new H.map.Polyline(t, { style: l });
22
- if (n) {
23
- let o;
24
- if (h(c, d))
25
- o = new H.map.Polyline(t, {
8
+ geometry: r,
9
+ hasArrows: y,
10
+ arrowStyle: E,
11
+ style: O = H.map.SpatialStyle.DEFAULT_STYLE,
12
+ customData: u,
13
+ eventListenerMap: n,
14
+ onReady: m
15
+ } = T, { api: o, enableWebGL: L, baseLayer: _ } = I(), [l, N] = M(), s = h([]), f = h(m);
16
+ d(() => {
17
+ f.current = m;
18
+ }, [m]);
19
+ const g = S(() => {
20
+ if (!n)
21
+ return;
22
+ const e = Object.entries(n).filter(
23
+ ([t]) => [i.POINTER_ENTER, i.POINTER_LEAVE, i.POINTER_CANCEL].includes(t)
24
+ );
25
+ if (e.length !== 0)
26
+ return Object.fromEntries(e);
27
+ }, [n]), P = S(() => {
28
+ if (!n)
29
+ return;
30
+ const e = Object.entries(n).filter(
31
+ ([t]) => ![i.POINTER_ENTER, i.POINTER_LEAVE, i.POINTER_CANCEL].includes(t)
32
+ );
33
+ if (e.length !== 0)
34
+ return Object.fromEntries(e);
35
+ }, [n]);
36
+ if (!r)
37
+ throw new b(j);
38
+ if (!(r instanceof H.geo.LineString))
39
+ throw new b(A);
40
+ return d(() => {
41
+ const e = new H.map.Group({ data: u }), t = new H.map.Polyline(r, { style: O });
42
+ let a;
43
+ t.setData(u);
44
+ const R = [t];
45
+ if (y) {
46
+ if (v(L, _))
47
+ a = new H.map.Polyline(r, {
26
48
  style: {
27
49
  strokeColor: "rgba(42, 55, 64, 1)",
28
50
  lineWidth: 5,
29
51
  lineDash: [1.8, 4],
30
52
  // @ts-expect-error-next-line - the types are outdated here
31
53
  lineDashImage: H.map.SpatialStyle.DashImage.ARROW,
32
- ...a
54
+ ...E
33
55
  }
34
56
  });
35
57
  else {
36
- const w = {
58
+ const c = {
37
59
  lineWidth: 2,
38
60
  fillColor: "rgba(42, 55, 64, 1)",
39
61
  strokeColor: "rgba(0, 0, 0, 0.8)",
40
62
  lineDash: [0, 4],
41
63
  lineTailCap: "arrow-tail",
42
64
  lineHeadCap: "arrow-head",
43
- ...a
44
- }, E = new H.map.SpatialStyle({
65
+ ...E
66
+ }, C = new H.map.SpatialStyle({
45
67
  lineWidth: 10,
46
68
  strokeColor: "rgba(255, 255, 255, 0)"
47
69
  });
48
- o = new H.map.Polyline(t, { style: E, arrows: w });
70
+ a = new H.map.Polyline(r, { style: C, arrows: c });
49
71
  }
50
- e.addObjects([i, o]);
72
+ a.setData(u), R.push(a), e.addObjects([t, a]);
51
73
  } else
52
- e.addObjects([i]);
53
- return r.map?.addObject(e), S(e), () => {
54
- g(e), e.forEach((o) => {
55
- e.removeObject(o), o.dispose();
56
- }), r.map?.getObjects().includes(e) && r.map.removeObject(e), e.dispose();
74
+ e.addObjects([t]);
75
+ return o.map?.addObject(e), s.current = R, N(e), f.current?.({ group: e, line: t, routeArrows: a }), () => {
76
+ f.current?.(), p(e), s.current.forEach(p), s.current = [], e.forEach((c) => {
77
+ e.removeObject(c), c.dispose();
78
+ }), o.map?.getObjects().includes(e) && o.map.removeObject(e), e.dispose();
57
79
  };
58
- }, [r.map, t, l, n, a]), P(f, y), null;
80
+ }, [o.map, r, O, y, E]), d(() => {
81
+ const e = o.map;
82
+ if (l && e)
83
+ return w(l, P, e), s.current.forEach((t) => {
84
+ w(t, g, e);
85
+ }), () => {
86
+ p(l), s.current.forEach(p);
87
+ };
88
+ }, [o.map, l, P, g]), null;
59
89
  };
60
90
  export {
61
- M as MISSING_GEOMETRY_PROPS_EXCEPTION_MSG,
62
- C as WRONG_GEOMETRY_PROPS_EXCEPTION_MSG,
63
- v as default
91
+ j as MISSING_GEOMETRY_PROPS_EXCEPTION_MSG,
92
+ A as WRONG_GEOMETRY_PROPS_EXCEPTION_MSG,
93
+ V as default
64
94
  };
65
95
  //# sourceMappingURL=Polyline.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Polyline.js","sources":["../../../../../../src/components/map/components/features/basics/Polyline.tsx"],"sourcesContent":["import { useState, useEffect } from 'react';\n\nimport { useMapContext } from '../../MapContext';\nimport MapException from '../../../exceptions/MapException';\n\nimport { useUpdateEventListenerMap } from '../../../utils/hooks';\nimport { removeEventListenerMap, type EventListenerMap } from '../../../utils/eventHandling';\nimport { isVectorBased } from '../../../utils/rendering';\n\nexport const MISSING_GEOMETRY_PROPS_EXCEPTION_MSG = 'Error in Polyline: Polyline without geometry makes no sense';\nexport const WRONG_GEOMETRY_PROPS_EXCEPTION_MSG =\n 'Error in Polyline: property geometry must be of type H.geo.LineString';\n\nexport type ArrowStyle = {\n fillColor?: string;\n strokeColor?: string;\n};\n\nexport type PolylineProps = {\n hasArrows?: boolean;\n arrowStyle?: ArrowStyle;\n geometry: H.geo.LineString;\n style?: H.map.SpatialStyle;\n customData?: object;\n eventListenerMap?: EventListenerMap;\n};\n\nconst Polyline = (props: PolylineProps) => {\n const {\n geometry,\n hasArrows,\n arrowStyle,\n style = H.map.SpatialStyle.DEFAULT_STYLE,\n customData,\n eventListenerMap,\n } = props;\n\n const { api, enableWebGL, baseLayer } = useMapContext();\n\n const [polyline, setPolyline] = useState<H.map.Group>();\n\n if (!geometry) {\n throw new MapException(MISSING_GEOMETRY_PROPS_EXCEPTION_MSG);\n }\n\n if (!(geometry instanceof H.geo.LineString)) {\n throw new MapException(WRONG_GEOMETRY_PROPS_EXCEPTION_MSG);\n }\n\n useEffect(() => {\n const lineGroup = new H.map.Group({ data: customData });\n const line = new H.map.Polyline(geometry, { style });\n\n if (hasArrows) {\n let routeArrows: H.map.Polyline;\n\n if (isVectorBased(enableWebGL, baseLayer)) {\n // WebGL way - Create a patterned polyline\n routeArrows = new H.map.Polyline(geometry, {\n style: {\n strokeColor: 'rgba(42, 55, 64, 1)',\n lineWidth: 5,\n lineDash: [1.8, 4],\n // @ts-expect-error-next-line - the types are outdated here\n lineDashImage: H.map.SpatialStyle.DashImage.ARROW,\n ...arrowStyle,\n },\n });\n } else {\n // Pixel map way - Create a patterned polyline\n const defaultArrowStyle = {\n lineWidth: 2,\n fillColor: 'rgba(42, 55, 64, 1)',\n strokeColor: 'rgba(0, 0, 0, 0.8)',\n lineDash: [0, 4],\n lineTailCap: 'arrow-tail',\n lineHeadCap: 'arrow-head',\n ...arrowStyle,\n };\n\n const arrowLineStyle = new H.map.SpatialStyle({\n lineWidth: 10,\n strokeColor: 'rgba(255, 255, 255, 0)',\n });\n\n routeArrows = new H.map.Polyline(geometry, { style: arrowLineStyle, arrows: defaultArrowStyle });\n }\n\n // create a group that represents the route line and contains\n // outline and the pattern\n lineGroup.addObjects([line, routeArrows]);\n } else {\n lineGroup.addObjects([line]);\n }\n\n api.map?.addObject(lineGroup);\n setPolyline(lineGroup);\n\n return () => {\n removeEventListenerMap(lineGroup);\n\n lineGroup.forEach(singleLine => {\n lineGroup.removeObject(singleLine);\n singleLine.dispose();\n });\n\n if (api.map?.getObjects().includes(lineGroup)) {\n api.map.removeObject(lineGroup);\n }\n lineGroup.dispose();\n };\n }, [api.map, geometry, style, hasArrows, arrowStyle]);\n\n useUpdateEventListenerMap(polyline, eventListenerMap);\n\n return null;\n};\n\nexport default Polyline;\n"],"names":["MISSING_GEOMETRY_PROPS_EXCEPTION_MSG","WRONG_GEOMETRY_PROPS_EXCEPTION_MSG","Polyline","props","geometry","hasArrows","arrowStyle","style","customData","eventListenerMap","api","enableWebGL","baseLayer","useMapContext","polyline","setPolyline","useState","MapException","useEffect","lineGroup","line","routeArrows","isVectorBased","defaultArrowStyle","arrowLineStyle","removeEventListenerMap","singleLine","useUp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H,IAAc,IAAI,EAAE,IAAI,SAASjB,GAAU,EAAE,OAAOoB,GAAgB,QAAQD,GAAmB;AAAA,MACnG;AAIA,MAAAJ,EAAU,WAAW,CAACC,GAAMC,CAAW,CAAC;AAAA,IAC5C;AACI,MAAAF,EAAU,WAAW,CAACC,CAAI,CAAC;AAG/B,WAAAV,EAAI,KAAK,UAAUS,CAAS,GAC5BJ,EAAYI,CAAS,GAEd,MAAM;AACT,MAAAM,EAAuBN,CAAS,GAEhCA,EAAU,QAAQ,CAAAO,MAAc;AAC5B,QAAAP,EAAU,aAAaO,CAAU,GACjCA,EAAW,QAAA;AAAA,MACf,CAAC,GAEGhB,EAAI,KAAK,WAAA,EAAa,SAASS,CAAS,KACxCT,EAAI,IAAI,aAAaS,CAAS,GAElCA,EAAU,QAAA;AAAA,IACd;AAAA,EACJ,GAAG,CAACT,EAAI,KAAKN,GAAUG,GAAOF,GAAWC,CAAU,CAAC,GAEpDqB,EAA0Bb,GAAUL,CAAgB,GAE7C;AACX;"}
1
+ {"version":3,"file":"Polyline.js","sources":["../../../../../../src/components/map/components/features/basics/Polyline.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\n\nimport { useMapContext } from '../../MapContext';\nimport MapException from '../../../exceptions/MapException';\n\nimport {\n EventUtils,\n addEventListenerMap,\n removeEventListenerMap,\n type EventListenerMap,\n} from '../../../utils/eventHandling';\nimport { isVectorBased } from '../../../utils/rendering';\n\nexport const MISSING_GEOMETRY_PROPS_EXCEPTION_MSG = 'Error in Polyline: Polyline without geometry makes no sense';\nexport const WRONG_GEOMETRY_PROPS_EXCEPTION_MSG =\n 'Error in Polyline: property geometry must be of type H.geo.LineString';\n\nexport type ArrowStyle = {\n fillColor?: string;\n strokeColor?: string;\n};\n\nexport type PolylineObjects = {\n group: H.map.Group;\n line: H.map.Polyline;\n routeArrows?: H.map.Polyline;\n};\n\nexport type PolylineProps = {\n /**\n * Controls whether directional arrows are rendered on the polyline.\n */\n hasArrows?: boolean;\n\n /**\n * Defines the arrow appearance when arrows are rendered.\n */\n arrowStyle?: ArrowStyle;\n\n /**\n * Geometry used to render the polyline.\n */\n geometry: H.geo.LineString;\n\n /**\n * Visual style applied to the main polyline.\n *\n * @default H.map.SpatialStyle.DEFAULT_STYLE\n */\n style?: H.map.SpatialStyle;\n\n /**\n * Custom payload forwarded to the rendered polyline objects and their events.\n */\n customData?: object;\n\n /**\n * Event handlers attached to the polyline.\n */\n eventListenerMap?: EventListenerMap;\n\n /**\n * Receives the created HERE polyline objects once they are mounted and `undefined` on cleanup.\n */\n onReady?: (objects?: PolylineObjects) => void;\n};\n\nconst Polyline = (props: PolylineProps) => {\n const {\n geometry,\n hasArrows,\n arrowStyle,\n style = H.map.SpatialStyle.DEFAULT_STYLE,\n customData,\n eventListenerMap,\n onReady,\n } = props;\n\n const { api, enableWebGL, baseLayer } = useMapContext();\n\n const [polyline, setPolyline] = useState<H.map.Group>();\n const directEventTargetsRef = useRef<H.map.Polyline[]>([]);\n const onReadyRef = useRef(onReady);\n\n useEffect(() => {\n onReadyRef.current = onReady;\n }, [onReady]);\n\n const directEventListenerMap = useMemo(() => {\n if (!eventListenerMap) {\n return;\n }\n\n const directEntries = Object.entries(eventListenerMap).filter(([key]) =>\n [EventUtils.POINTER_ENTER, EventUtils.POINTER_LEAVE, EventUtils.POINTER_CANCEL].includes(key)\n );\n\n if (directEntries.length === 0) {\n return;\n }\n\n return Object.fromEntries(directEntries) satisfies EventListenerMap;\n }, [eventListenerMap]);\n\n const groupEventListenerMap = useMemo(() => {\n if (!eventListenerMap) {\n return;\n }\n\n const groupEntries = Object.entries(eventListenerMap).filter(\n ([key]) => ![EventUtils.POINTER_ENTER, EventUtils.POINTER_LEAVE, EventUtils.POINTER_CANCEL].includes(key)\n );\n\n if (groupEntries.length === 0) {\n return;\n }\n\n return Object.fromEntries(groupEntries) satisfies EventListenerMap;\n }, [eventListenerMap]);\n\n if (!geometry) {\n throw new MapException(MISSING_GEOMETRY_PROPS_EXCEPTION_MSG);\n }\n\n if (!(geometry instanceof H.geo.LineString)) {\n throw new MapException(WRONG_GEOMETRY_PROPS_EXCEPTION_MSG);\n }\n\n useEffect(() => {\n const lineGroup = new H.map.Group({ data: customData });\n const line = new H.map.Polyline(geometry, { style });\n\n let routeArrows: H.map.Polyline | undefined;\n line.setData(customData);\n\n const directEventTargets = [line];\n\n if (hasArrows) {\n if (isVectorBased(enableWebGL, baseLayer)) {\n // WebGL way - Create a patterned polyline\n routeArrows = new H.map.Polyline(geometry, {\n style: {\n strokeColor: 'rgba(42, 55, 64, 1)',\n lineWidth: 5,\n lineDash: [1.8, 4],\n // @ts-expect-error-next-line - the types are outdated here\n lineDashImage: H.map.SpatialStyle.DashImage.ARROW,\n ...arrowStyle,\n },\n });\n } else {\n // Pixel map way - Create a patterned polyline\n const defaultArrowStyle = {\n lineWidth: 2,\n fillColor: 'rgba(42, 55, 64, 1)',\n strokeColor: 'rgba(0, 0, 0, 0.8)',\n lineDash: [0, 4],\n lineTailCap: 'arrow-tail',\n lineHeadCap: 'arrow-head',\n ...arrowStyle,\n };\n\n const arrowLineStyle = new H.map.SpatialStyle({\n lineWidth: 10,\n strokeColor: 'rgba(255, 255, 255, 0)',\n });\n\n routeArrows = new H.map.Polyline(geometry, { style: arrowLineStyle, arrows: defaultArrowStyle });\n }\n\n routeArrows.setData(customData);\n directEventTargets.push(routeArrows);\n\n // create a group that represents the route line and contains\n // outline and the pattern\n lineGroup.addObjects([line, routeArrows]);\n } else {\n lineGroup.addObjects([line]);\n }\n\n api.map?.addObject(lineGroup);\n directEventTargetsRef.current = directEventTargets;\n setPolyline(lineGroup);\n onReadyRef.current?.({ group: lineGroup, line, routeArrows });\n\n return () => {\n onReadyRef.current?.();\n removeEventListenerMap(lineGroup);\n directEventTargetsRef.current.forEach(removeEventListenerMap);\n directEventTargetsRef.current = [];\n\n lineGroup.forEach(singleLine => {\n lineGroup.removeObject(singleLine);\n singleLine.dispose();\n });\n\n if (api.map?.getObjects().includes(lineGroup)) {\n api.map.removeObject(lineGroup);\n }\n lineGroup.dispose();\n };\n }, [api.map, geometry, style, hasArrows, arrowStyle]);\n\n useEffect(() => {\n const map = api.map;\n\n if (!(polyline && map)) {\n return;\n }\n\n addEventListenerMap(polyline, groupEventListenerMap, map);\n directEventTargetsRef.current.forEach(target => {\n addEventListenerMap(target, directEventListenerMap, map);\n });\n\n return () => {\n removeEventListenerMap(polyline);\n directEventTargetsRef.current.forEach(removeEventListenerMap);\n };\n }, [api.map, polyline, groupEventListenerMap, directEventListenerMap]);\n\n return null;\n};\n\nexport default Polyline;\n"],"names":["MISSING_GEOMETRY_PROPS_EXCEPTION_MSG","WRONG_GEOMETRY_PROPS_EXCEPTION_MSG","Polyline","props","geometry","hasArrows","arrowStyle","style","customData","eventListenerMap","onReady","api","enableWebGL","baseLayer","useMapContext","polyline","setPolyline","useState","directEventTargetsRef","useRef","onReadyRef","useEffect","directEventListenerMap","useMemo","directEntries","key","EventUtils","groupEventListenerMap","groupEntries","MapException","lineGroup","line","routeArrows","directEventTargets","isVectorBased","defaultArrowStyle","arrowLineStyle","removeEventListenerMap","singleLine","map","addEventListenerMap","target"],"mappings":";;;;;AAaO,MAAMA,IAAuC,+DACvCC,IACT,yEAoDEC,IAAW,CAACC,MAAyB;AACvC,QAAM;AAAA,IACF,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,YAAAC;AAAA,IACA,OAAAC,IAAQ,EAAE,IAAI,aAAa;AAAA,IAC3B,YAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,SAAAC;AAAA,EAAA,IACAP,GAEE,EAAE,KAAAQ,GAAK,aAAAC,GAAa,WAAAC,EAAA,IAAcC,EAAA,GAElC,CAACC,GAAUC,CAAW,IAAIC,EAAA,GAC1BC,IAAwBC,EAAyB,EAAE,GACnDC,IAAaD,EAAOT,CAAO;AAEjC,EAAAW,EAAU,MAAM;AACZ,IAAAD,EAAW,UAAUV;AAAA,EACzB,GAAG,CAACA,CAAO,CAAC;AAEZ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MI,KAAYwB;AAIlB,aAAAC,EAAoBzB,GAAUY,GAAuBY,CAAG,GACxDrB,EAAsB,QAAQ,QAAQ,CAAAuB,MAAU;AAC5C,QAAAD,EAAoBC,GAAQnB,GAAwBiB,CAAG;AAAA,MAC3D,CAAC,GAEM,MAAM;AACT,QAAAF,EAAuBtB,CAAQ,GAC/BG,EAAsB,QAAQ,QAAQmB,CAAsB;AAAA,MAChE;AAAA,EACJ,GAAG,CAAC1B,EAAI,KAAKI,GAAUY,GAAuBL,CAAsB,CAAC,GAE9D;AACX;"}
@@ -1,15 +1,15 @@
1
- import { jsx as i } from "react/jsx-runtime";
1
+ import { jsx as n } from "react/jsx-runtime";
2
2
  import l from "./clustering/ClusterLayer.js";
3
- import { wrapSimpleTheme as n } from "../../../utils/clustering.js";
4
- import { useMapContext as a } from "../../MapContext.js";
5
- const C = (r) => {
6
- const t = a(), { simpleTheme: e, clusterDissolvable: o = !0, ...s } = r, m = !o || t.showCluster, p = {
7
- clusterTheme: e && n(e),
3
+ import { wrapSimpleTheme as p } from "../../../utils/clustering.js";
4
+ import { useMapContext as i } from "../../MapContext.js";
5
+ const f = (t) => {
6
+ const e = i(), { simpleTheme: r, clusterDissolvable: o = !0, ...s } = t, m = !o || e.showCluster, a = {
7
+ clusterTheme: r && p(r, e.enableMarkerIconCache),
8
8
  ...s
9
9
  };
10
- return /* @__PURE__ */ i(l, { ...p, minWeight: m ? void 0 : 1e9 });
10
+ return /* @__PURE__ */ n(l, { ...a, minWeight: m ? void 0 : 1e9 });
11
11
  };
12
12
  export {
13
- C as default
13
+ f as default
14
14
  };
15
15
  //# sourceMappingURL=MarkerLayer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkerLayer.js","sources":["../../../../../../src/components/map/components/features/layers/MarkerLayer.tsx"],"sourcesContent":["import type React from 'react';\n\nimport ClusterLayer, { type ClusterTheme } from './clustering/ClusterLayer';\nimport { wrapSimpleTheme, type SimpleClusterTheme } from '../../../utils/clustering';\nimport { useMapContext } from '../../MapContext';\n\nexport type { ClusterTheme, SimpleClusterTheme };\n\nexport type MarkerLayerProps = React.ComponentProps<typeof ClusterLayer> & {\n simpleTheme?: SimpleClusterTheme;\n clusterDissolvable?: boolean;\n clusterStrategy?: 'FASTGRID' | 'GRID' | 'DYNAMICGRID';\n eps?: number;\n};\n\n/*\n * Not very different to the SimpleClusterLayer, but with a different intention.\n */\nconst MarkerLayer = (props: MarkerLayerProps) => {\n const mapContext = useMapContext();\n\n const { simpleTheme, clusterDissolvable = true, ...rest } = props;\n\n // Norbert: Not an ideal solution\n const showCluster = !clusterDissolvable || mapContext.showCluster;\n const newProps = {\n clusterTheme: simpleTheme && wrapSimpleTheme(simpleTheme),\n ...rest,\n };\n return <ClusterLayer {...newProps} minWeight={showCluster ? undefined : 1000000000} />;\n};\n\nexport default MarkerLayer;\n"],"names":["MarkerLayer","props","mapContext","useMapContext","simpleTheme","clusterDissolvable","rest","showCluster","newProps","wrapSimpleTheme","ClusterLayer"],"mappings":";;;;AAkBA,MAAMA,IAAc,CAACC,MAA4B;AAC7C,QAAMC,IAAaC,EAAA,GAEb,EAAE,aAAAC,GAAa,oBAAAC,IAAqB,IAAM,GAAGC,MAASL,GAGtDM,IAAc,CAACF,KAAsBH,EAAW,aAChDM,IAAW;AAAA,IACb,cAAcJ,KAAeK,EAAgBL,CAAW;AAAA,IACxD,GAAGE;AAAA,EAAA;AAEP,2BAAQI,GAAA,EAAc,GAAGF,GAAU,WAAWD,IAAc,SAAY,KAAY;AACxF;"}
1
+ {"version":3,"file":"MarkerLayer.js","sources":["../../../../../../src/components/map/components/features/layers/MarkerLayer.tsx"],"sourcesContent":["import type React from 'react';\n\nimport ClusterLayer, { type ClusterTheme } from './clustering/ClusterLayer';\nimport { wrapSimpleTheme, type SimpleClusterTheme } from '../../../utils/clustering';\nimport { useMapContext } from '../../MapContext';\n\nexport type { ClusterTheme, SimpleClusterTheme };\n\nexport type MarkerLayerProps = React.ComponentProps<typeof ClusterLayer> & {\n simpleTheme?: SimpleClusterTheme;\n clusterDissolvable?: boolean;\n clusterStrategy?: 'FASTGRID' | 'GRID' | 'DYNAMICGRID';\n eps?: number;\n};\n\n/*\n * Not very different to the SimpleClusterLayer, but with a different intention.\n */\nconst MarkerLayer = (props: MarkerLayerProps) => {\n const mapContext = useMapContext();\n\n const { simpleTheme, clusterDissolvable = true, ...rest } = props;\n\n // Norbert: Not an ideal solution\n const showCluster = !clusterDissolvable || mapContext.showCluster;\n const newProps = {\n clusterTheme: simpleTheme && wrapSimpleTheme(simpleTheme, mapContext.enableMarkerIconCache),\n ...rest,\n };\n return <ClusterLayer {...newProps} minWeight={showCluster ? undefined : 1000000000} />;\n};\n\nexport default MarkerLayer;\n"],"names":["MarkerLayer","props","mapContext","useMapContext","simpleTheme","clusterDissolvable","rest","showCluster","newProps","wrapSimpleTheme","ClusterLayer"],"mappings":";;;;AAkBA,MAAMA,IAAc,CAACC,MAA4B;AAC7C,QAAMC,IAAaC,EAAA,GAEb,EAAE,aAAAC,GAAa,oBAAAC,IAAqB,IAAM,GAAGC,MAASL,GAGtDM,IAAc,CAACF,KAAsBH,EAAW,aAChDM,IAAW;AAAA,IACb,cAAcJ,KAAeK,EAAgBL,GAAaF,EAAW,qBAAqB;AAAA,IAC1F,GAAGI;AAAA,EAAA;AAEP,2BAAQI,GAAA,EAAc,GAAGF,GAAU,WAAWD,IAAc,SAAY,KAAY;AACxF;"}