datastake-daf 0.6.814 → 0.6.815

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.
@@ -16,6 +16,7 @@ var L$1 = require('leaflet');
16
16
  var reactCollapsed = require('react-collapsed');
17
17
  var countryCityLocation = require('country-city-location');
18
18
  var client = require('react-dom/client');
19
+ var reactDom = require('react-dom');
19
20
  require('@elfalem/leaflet-curve');
20
21
  var dot = require('dot-object');
21
22
  var ReactHtmlParser = require('react-html-parser');
@@ -6054,7 +6055,12 @@ function DAFTable(_ref) {
6054
6055
  doEmptyRows
6055
6056
  } = _ref,
6056
6057
  rest = _objectWithoutProperties(_ref, _excluded$F);
6057
- const [source, setSource] = React.useState([]);
6058
+ const source = React.useMemo(() => {
6059
+ if (data && Array.isArray(data)) {
6060
+ return data;
6061
+ }
6062
+ return [];
6063
+ }, [data]);
6058
6064
  const projectData = (projects || []).find(p => p.id === selectedProject);
6059
6065
  const [filtersInit, setFiltersInit] = React.useState(!loading);
6060
6066
  React.useEffect(() => {
@@ -6098,11 +6104,13 @@ function DAFTable(_ref) {
6098
6104
  }
6099
6105
  }) : filtersConfig;
6100
6106
  }, [sourcesKey, sources, filtersConfig, t]);
6101
- React.useEffect(() => {
6102
- if (data && Array.isArray(data)) {
6103
- setSource(data);
6104
- }
6105
- }, [data, data.length]);
6107
+
6108
+ // useEffect(() => {
6109
+ // if (data && Array.isArray(data)) {
6110
+ // setSource(data);
6111
+ // }
6112
+ // }, [data, data.length]);
6113
+
6106
6114
  const paginationPageSize = pagination === null || pagination === void 0 ? void 0 : pagination.pageSize;
6107
6115
  const dataSource = React.useMemo(() => {
6108
6116
  const pageSize = paginationPageSize ? paginationPageSize : source.length > 10 ? source.length : 10;
@@ -13924,8 +13932,8 @@ function LocationIcon({
13924
13932
  activeMarker,
13925
13933
  setActiveMarker
13926
13934
  }) {
13927
- const rootsMapRef = React.useRef(new Map());
13928
13935
  const markersRef = React.useRef([]);
13936
+ const [portalContainers, setPortalContainers] = React.useState([]);
13929
13937
  const isSelected = selectedMarkersId.includes(data.datastakeId);
13930
13938
  const Marker = React.useMemo(() => {
13931
13939
  if (isMineSite(data.type)) {
@@ -13933,7 +13941,7 @@ function LocationIcon({
13933
13941
  }
13934
13942
  return VillageMarker;
13935
13943
  }, [data.type]);
13936
- const [isHovering, setIsHovering] = React.useState(false);
13944
+ React.useState(false);
13937
13945
  const linkedNodesData = React.useMemo(() => {
13938
13946
  const nodes = [];
13939
13947
  const links = data.links || [];
@@ -13998,31 +14006,32 @@ function LocationIcon({
13998
14006
  return nodes;
13999
14007
  }, [JSON.stringify(allData), JSON.stringify(data.links), JSON.stringify(data.stakeholders), zoom]);
14000
14008
  const stakeholdersOfLocation = React.useMemo(() => {
14001
- return data?.stakeholders || [];
14002
- }, [data.stakeholders, zoom]);
14009
+ return (data?.stakeholders || []).filter(stakeholder => {
14010
+ if (!stakeholder.links || stakeholder.links.length === 0) {
14011
+ return true;
14012
+ }
14013
+ const locationsWithThisStakeholder = allData.filter(loc => loc.stakeholders?.some(s => s.datastakeId === stakeholder.datastakeId)).map(loc => loc.datastakeId);
14014
+ const primaryLocation = locationsWithThisStakeholder.sort()[0];
14015
+ return data.datastakeId === primaryLocation;
14016
+ });
14017
+ }, [data.stakeholders, data.datastakeId, allData, zoom]);
14003
14018
  React.useEffect(() => {
14004
- const currentRoots = rootsMapRef.current;
14005
- const currentMarkers = markersRef.current;
14006
- currentMarkers.forEach(marker => {
14007
- if (mapRef.hasLayer(marker)) {
14019
+ markersRef.current.forEach(marker => {
14020
+ if (mapRef && mapRef.hasLayer(marker)) {
14008
14021
  mapRef.removeLayer(marker);
14009
14022
  }
14010
14023
  });
14011
- currentRoots.forEach(root => {
14012
- root.unmount();
14013
- });
14014
- currentRoots.clear();
14015
14024
  markersRef.current = [];
14016
-
14017
- // Only create stakeholder markers if this location or any of its stakeholders are selected
14025
+ setPortalContainers([]);
14018
14026
  const shouldShowStakeholders = isSelected || stakeholdersOfLocation.some(stk => selectedMarkersId.includes(stk.datastakeId));
14019
14027
  if (!shouldShowStakeholders || selectedMarkersId.length === 0) {
14020
14028
  return;
14021
14029
  }
14022
14030
 
14023
- // Create new markers only when selected
14031
+ // Create markers and store their container references
14032
+ const containers = [];
14024
14033
  stakeholdersOfLocation.forEach((stakeholder, index) => {
14025
- const markerId = `${stakeholder.datastakeId}`;
14034
+ const markerId = `${data.datastakeId}-${stakeholder.datastakeId}`;
14026
14035
  const {
14027
14036
  x,
14028
14037
  y,
@@ -14045,41 +14054,29 @@ function LocationIcon({
14045
14054
  const pathLocLatLng = mapRef.layerPointToLatLng(pathLocPoint);
14046
14055
  const isForceOpen = activeMarker?.datastakeId === data.datastakeId;
14047
14056
  const iconSize = isSmallMarker(zoom) || isExtraSmallMarker(zoom) ? [11, 11] : [25, 25];
14057
+
14058
+ // Create container div
14059
+ const containerDiv = document.createElement('div');
14060
+ containerDiv.id = markerId;
14048
14061
  const marker = L__namespace.marker(stakeholderLatLng, {
14049
14062
  icon: L__namespace.divIcon({
14050
- html: `<div id="${markerId}"></div>`,
14063
+ html: containerDiv.outerHTML,
14051
14064
  className: "marker-chain",
14052
14065
  iconSize: iconSize
14053
14066
  })
14054
14067
  }).addTo(mapRef);
14055
14068
  markersRef.current.push(marker);
14056
- setTimeout(() => {
14057
- const div = document.getElementById(markerId);
14058
- if (div && !rootsMapRef.current.has(markerId)) {
14059
- const root = client.createRoot(div);
14060
- rootsMapRef.current.set(markerId, root);
14061
- root.render( /*#__PURE__*/jsxRuntime.jsx(StakeholderIcon$1, {
14062
- data: stakeholder,
14063
- zoom: zoom,
14064
- allData: allData,
14065
- link: link,
14066
- parentId: data.datastakeId,
14067
- renderTooltip: renderTooltip,
14068
- onClickLink: onClickLink,
14069
- selectedMarkersId: selectedMarkersId,
14070
- handleSelectMarker: handleSelectMarker,
14071
- mapRef: mapRef,
14072
- radius: radius,
14073
- index: index,
14074
- x: x,
14075
- y: y,
14076
- openPopupIdRef: openPopupIdRef,
14077
- polylinesRef: polylinesRef,
14078
- isForceOpen: isForceOpen,
14079
- activeMarker: activeMarker
14080
- }));
14081
- }
14082
- }, 0);
14069
+
14070
+ // Store container info for portal rendering
14071
+ containers.push({
14072
+ markerId,
14073
+ stakeholder,
14074
+ x,
14075
+ y,
14076
+ radius,
14077
+ index,
14078
+ isForceOpen
14079
+ });
14083
14080
  setMapMarkers(prev => {
14084
14081
  const array = [...prev, {
14085
14082
  id: marker._leaflet_id,
@@ -14111,17 +14108,19 @@ function LocationIcon({
14111
14108
  animated: true
14112
14109
  });
14113
14110
  });
14111
+
14112
+ // Update portal containers after markers are created
14113
+ setTimeout(() => {
14114
+ setPortalContainers(containers);
14115
+ }, 0);
14114
14116
  return () => {
14115
14117
  markersRef.current.forEach(marker => {
14116
- if (mapRef.hasLayer(marker)) {
14118
+ if (mapRef && mapRef.hasLayer(marker)) {
14117
14119
  mapRef.removeLayer(marker);
14118
14120
  }
14119
14121
  });
14120
- rootsMapRef.current.forEach(root => {
14121
- root.unmount();
14122
- });
14123
- rootsMapRef.current.clear();
14124
14122
  markersRef.current = [];
14123
+ setPortalContainers([]);
14125
14124
  };
14126
14125
  }, [stakeholdersOfLocation, selectedMarkersId, activeMarker, zoom]);
14127
14126
 
@@ -14205,57 +14204,81 @@ function LocationIcon({
14205
14204
  });
14206
14205
  });
14207
14206
  }, [linkedNodesData, selectedMarkersId, zoom, stakeholdersOfLocation, isSelected]);
14208
- return /*#__PURE__*/jsxRuntime.jsx(antd.Popover, {
14209
- content: renderTooltipJsx({
14210
- title: data.name,
14211
- subTitle: data.subTitle,
14212
- total: data.sources,
14213
- className: "pt-0 pb-0",
14214
- items: renderTooltip(data),
14215
- link,
14216
- onClickLink: () => onClickLink(data),
14217
- isNewTab: true
14218
- })
14219
- // open={
14220
- // (!openPopupIdRef.current || openPopupIdRef.current === data.datastakeId) &&
14221
- // isHovering
14222
- // }
14223
- ,
14224
- getPopupContainer: triggerNode => {
14225
- const mapElement = document.getElementById("map");
14226
- return mapElement || triggerNode.parentElement || document.body;
14227
- },
14228
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
14229
- style: {
14230
- position: "relative",
14231
- display: "inline-block"
14207
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
14208
+ children: [/*#__PURE__*/jsxRuntime.jsx(antd.Popover, {
14209
+ content: renderTooltipJsx({
14210
+ title: data.name,
14211
+ subTitle: data.subTitle,
14212
+ total: data.sources,
14213
+ className: "pt-0 pb-0",
14214
+ items: renderTooltip(data),
14215
+ link,
14216
+ onClickLink: () => onClickLink(data),
14217
+ isNewTab: true
14218
+ }),
14219
+ getPopupContainer: triggerNode => {
14220
+ const mapElement = document.getElementById("map");
14221
+ return mapElement || triggerNode.parentElement || document.body;
14232
14222
  },
14233
- children: [(isSelected || selectedMarkersId.length === 0) && /*#__PURE__*/jsxRuntime.jsx("div", {
14223
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
14234
14224
  style: {
14235
- position: "absolute",
14236
- bottom: "0",
14237
- left: "50%",
14238
- transform: "translateX(-50%)",
14239
- width: "12px",
14240
- height: "6px",
14241
- background: "rgba(0,0,0,0.15)",
14242
- borderRadius: "50%",
14243
- filter: "blur(3px)"
14244
- }
14245
- }), /*#__PURE__*/jsxRuntime.jsx(Marker, {
14246
- isSelected: isSelected,
14247
- onClick: () => {
14248
- handleSelectMarker(data);
14249
- setActiveMarker(isSelected ? null : data);
14225
+ position: "relative",
14226
+ display: "inline-block"
14250
14227
  },
14228
+ children: [(isSelected || selectedMarkersId.length === 0) && /*#__PURE__*/jsxRuntime.jsx("div", {
14229
+ style: {
14230
+ position: "absolute",
14231
+ bottom: "0",
14232
+ left: "50%",
14233
+ transform: "translateX(-50%)",
14234
+ width: "12px",
14235
+ height: "6px",
14236
+ background: "rgba(0,0,0,0.15)",
14237
+ borderRadius: "50%",
14238
+ filter: "blur(3px)"
14239
+ }
14240
+ }), /*#__PURE__*/jsxRuntime.jsx(Marker, {
14241
+ isSelected: isSelected,
14242
+ onClick: () => {
14243
+ handleSelectMarker(data);
14244
+ setActiveMarker(isSelected ? null : data);
14245
+ },
14246
+ zoom: zoom,
14247
+ selectedMarkersId: selectedMarkersId
14248
+ })]
14249
+ })
14250
+ }), portalContainers.map(({
14251
+ markerId,
14252
+ stakeholder,
14253
+ x,
14254
+ y,
14255
+ radius,
14256
+ index,
14257
+ isForceOpen
14258
+ }) => {
14259
+ const container = document.getElementById(markerId);
14260
+ if (!container) return null;
14261
+ return /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/jsxRuntime.jsx(StakeholderIcon$1, {
14262
+ data: stakeholder,
14251
14263
  zoom: zoom,
14252
- onMouseEnter: () => setIsHovering(true),
14253
- onMouseLeave: () => {
14254
- setIsHovering(false);
14255
- },
14256
- selectedMarkersId: selectedMarkersId
14257
- })]
14258
- })
14264
+ allData: allData,
14265
+ link: link,
14266
+ parentId: data.datastakeId,
14267
+ renderTooltip: renderTooltip,
14268
+ onClickLink: onClickLink,
14269
+ selectedMarkersId: selectedMarkersId,
14270
+ handleSelectMarker: handleSelectMarker,
14271
+ mapRef: mapRef,
14272
+ radius: radius,
14273
+ index: index,
14274
+ x: x,
14275
+ y: y,
14276
+ openPopupIdRef: openPopupIdRef,
14277
+ polylinesRef: polylinesRef,
14278
+ isForceOpen: isForceOpen,
14279
+ activeMarker: activeMarker
14280
+ }, markerId), container);
14281
+ })]
14259
14282
  });
14260
14283
  }
14261
14284