datastake-daf 0.6.766 → 0.6.768

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 (51) hide show
  1. package/dist/components/index.js +269 -140
  2. package/dist/pages/index.js +4736 -5657
  3. package/dist/utils/index.js +16 -1
  4. package/package.json +4 -1
  5. package/src/@daf/core/components/Dashboard/Map/ChainIcon/Markers/StakeholderMarker.js +5 -2
  6. package/src/@daf/core/components/Dashboard/Map/ChainIcon/index.js +67 -28
  7. package/src/@daf/core/components/Dashboard/Map/StakeholderIcon/index.js +3 -0
  8. package/src/@daf/core/components/Dashboard/Map/hook.js +57 -33
  9. package/src/@daf/core/components/Graphs/TradeRelationship/index.jsx +49 -11
  10. package/src/@daf/core/components/Graphs/components/BaseGraph.jsx +8 -4
  11. package/src/@daf/core/components/Screens/BaseScreen/index.jsx +1 -1
  12. package/src/@daf/core/components/Screens/TableScreen/TablePageWithTabs/index.jsx +1 -1
  13. package/src/@daf/core/components/UI/MissingTagButton/index.jsx +36 -0
  14. package/src/@daf/hooks/useMapHelper.js +5 -0
  15. package/src/@daf/pages/Dashboards/SupplyChain/components/SupplyChainMap/index.js +3 -2
  16. package/src/@daf/pages/Documents/config.js +0 -10
  17. package/src/@daf/pages/Documents/index.jsx +51 -108
  18. package/src/@daf/pages/Events/Activities/config.js +1 -11
  19. package/src/@daf/pages/Events/Activities/index.jsx +47 -105
  20. package/src/@daf/pages/Events/Incidents/config.js +1 -11
  21. package/src/@daf/pages/Events/Incidents/index.jsx +47 -105
  22. package/src/@daf/pages/Events/config.js +18 -34
  23. package/src/@daf/pages/Events/helper.js +0 -1
  24. package/src/@daf/pages/Events/index.jsx +49 -111
  25. package/src/@daf/pages/Locations/MineSite/columns.js +1 -1
  26. package/src/@daf/pages/Locations/MineSite/config.js +0 -10
  27. package/src/@daf/pages/Locations/MineSite/index.jsx +47 -105
  28. package/src/@daf/pages/Locations/config.js +4 -16
  29. package/src/@daf/pages/Locations/index.jsx +53 -110
  30. package/src/@daf/pages/Stakeholders/Operators/config.js +0 -10
  31. package/src/@daf/pages/Stakeholders/Operators/index.jsx +47 -105
  32. package/src/@daf/pages/Stakeholders/Workers/config.js +0 -10
  33. package/src/@daf/pages/Stakeholders/Workers/index.jsx +47 -105
  34. package/src/@daf/pages/Stakeholders/config.js +3 -15
  35. package/src/@daf/pages/Stakeholders/index.jsx +53 -109
  36. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/index.js +5 -1
  37. package/src/@daf/pages/TablePage/config.js +78 -0
  38. package/src/@daf/pages/{Events → TablePage}/create.jsx +11 -8
  39. package/src/@daf/pages/TablePage/hook.js +123 -0
  40. package/src/@daf/pages/TablePage/index.jsx +142 -0
  41. package/src/constants/locales/en/translation.js +5 -0
  42. package/src/constants/locales/fr/translation.js +5 -0
  43. package/src/index.js +1 -0
  44. package/src/@daf/pages/Documents/create.jsx +0 -105
  45. package/src/@daf/pages/Events/Activities/create.jsx +0 -104
  46. package/src/@daf/pages/Events/Incidents/create.jsx +0 -104
  47. package/src/@daf/pages/Locations/MineSite/create.jsx +0 -104
  48. package/src/@daf/pages/Locations/create.jsx +0 -104
  49. package/src/@daf/pages/Stakeholders/Operators/create.jsx +0 -104
  50. package/src/@daf/pages/Stakeholders/Workers/create.jsx +0 -104
  51. package/src/@daf/pages/Stakeholders/create.jsx +0 -105
@@ -9941,44 +9941,44 @@ function useAjaxModal$2({
9941
9941
  }
9942
9942
 
9943
9943
  const mergeObject = obj => {
9944
- return Object.entries(obj || {}).reduce((acc, _ref) => {
9945
- let [key, value] = _ref;
9944
+ return Object.entries(obj || {}).reduce((acc, [key, value]) => {
9946
9945
  if (typeof value === "object" && !Array.isArray(value) && value !== null) {
9947
- return _objectSpread2(_objectSpread2({}, acc), value);
9946
+ return {
9947
+ ...acc,
9948
+ ...value
9949
+ };
9948
9950
  }
9949
- return _objectSpread2(_objectSpread2({}, acc), {}, {
9951
+ return {
9952
+ ...acc,
9950
9953
  [key]: value
9951
- });
9954
+ };
9952
9955
  }, {});
9953
9956
  };
9954
- const handleDataLinkGroupWithTableKeys = _ref2 => {
9955
- var _inputConfig$meta, _config$meta2, _inputConfig$meta3, _inputConfig$meta4, _inputConfig$meta5;
9956
- let {
9957
- config,
9958
- inputConfig,
9959
- inputKey,
9960
- value,
9961
- level,
9962
- t,
9963
- rootForm,
9964
- allData,
9965
- user,
9966
- getApiBaseUrl = () => {},
9967
- getAppHeader = () => {},
9968
- app,
9969
- TreeNodeComponent
9970
- } = _ref2;
9957
+ const handleDataLinkGroupWithTableKeys = ({
9958
+ config,
9959
+ inputConfig,
9960
+ inputKey,
9961
+ value,
9962
+ level,
9963
+ t,
9964
+ rootForm,
9965
+ allData,
9966
+ user,
9967
+ getApiBaseUrl = () => {},
9968
+ getAppHeader = () => {},
9969
+ app,
9970
+ TreeNodeComponent
9971
+ }) => {
9971
9972
  if (!(config.type === 'dataLinkGroup' || config.type === 'dataLink')) {
9972
9973
  return null;
9973
9974
  }
9974
- if ((inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type) !== 'dataLink' || !(inputConfig !== null && inputConfig !== void 0 && (_inputConfig$meta = inputConfig.meta) !== null && _inputConfig$meta !== void 0 && _inputConfig$meta.tableKeys)) {
9975
+ if (inputConfig?.type !== 'dataLink' || !inputConfig?.meta?.tableKeys) {
9975
9976
  const parentInputKeys = Object.keys(config.inputs || {});
9976
9977
  const isHandledBySiblingDataLink = parentInputKeys.some(otherInputKey => {
9977
9978
  const otherConfig = config.inputs[otherInputKey];
9978
- if ((otherConfig === null || otherConfig === void 0 ? void 0 : otherConfig.type) === 'dataLink') {
9979
- var _otherConfig$meta, _config$meta;
9980
- const siblingTableKeys = (otherConfig === null || otherConfig === void 0 || (_otherConfig$meta = otherConfig.meta) === null || _otherConfig$meta === void 0 ? void 0 : _otherConfig$meta.tableKeys) || [];
9981
- const additionalTableKeys = ((_config$meta = config.meta) === null || _config$meta === void 0 ? void 0 : _config$meta.additionalTableKeys) || [];
9979
+ if (otherConfig?.type === 'dataLink') {
9980
+ const siblingTableKeys = otherConfig?.meta?.tableKeys || [];
9981
+ const additionalTableKeys = config.meta?.additionalTableKeys || [];
9982
9982
  const allSiblingKeys = [...siblingTableKeys, ...additionalTableKeys];
9983
9983
  return allSiblingKeys.includes(inputKey) && otherInputKey !== inputKey;
9984
9984
  }
@@ -9992,26 +9992,23 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
9992
9992
  return null;
9993
9993
  }
9994
9994
  const tableKeys = inputConfig.meta.tableKeys;
9995
- const additionalTableKeys = ((_config$meta2 = config.meta) === null || _config$meta2 === void 0 ? void 0 : _config$meta2.additionalTableKeys) || [];
9995
+ const additionalTableKeys = config.meta?.additionalTableKeys || [];
9996
9996
  const parentInputKeys = Object.keys(config.inputs || {});
9997
9997
  const siblingInputsMatchingTableKeys = parentInputKeys.filter(siblingKey => siblingKey !== inputKey).filter(siblingKey => tableKeys.includes(siblingKey) || additionalTableKeys.includes(siblingKey));
9998
9998
  [...new Set([...tableKeys, ...siblingInputsMatchingTableKeys])];
9999
- const isAjaxModal = React.useMemo(() => {
10000
- var _inputConfig$meta2;
10001
- return !!(inputConfig !== null && inputConfig !== void 0 && (_inputConfig$meta2 = inputConfig.meta) !== null && _inputConfig$meta2 !== void 0 && _inputConfig$meta2.namespace);
10002
- }, [inputConfig]);
9999
+ const isAjaxModal = React.useMemo(() => !!inputConfig?.meta?.namespace, [inputConfig]);
10003
10000
  const ajaxModalValues = useAjaxModal$2({
10004
10001
  name: inputKey,
10005
10002
  user,
10006
- namespace: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta3 = inputConfig.meta) === null || _inputConfig$meta3 === void 0 ? void 0 : _inputConfig$meta3.namespace,
10007
- skipFetch: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta4 = inputConfig.meta) === null || _inputConfig$meta4 === void 0 ? void 0 : _inputConfig$meta4.skipFetch,
10003
+ namespace: inputConfig?.meta?.namespace,
10004
+ skipFetch: inputConfig?.meta?.skipFetch,
10008
10005
  isAjaxModal,
10009
- formScope: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta5 = inputConfig.meta) === null || _inputConfig$meta5 === void 0 ? void 0 : _inputConfig$meta5.formScope,
10006
+ formScope: inputConfig?.meta?.formScope,
10010
10007
  APP: app,
10011
10008
  apiBaseUrl: getApiBaseUrl(),
10012
10009
  _getAppHeader: getAppHeader
10013
10010
  });
10014
- const dataLinkForm = ajaxModalValues === null || ajaxModalValues === void 0 ? void 0 : ajaxModalValues.form;
10011
+ const dataLinkForm = ajaxModalValues?.form;
10015
10012
  const createInputsAndValues = item => {
10016
10013
  const inputs = {};
10017
10014
  const values = {};
@@ -10023,12 +10020,12 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10023
10020
  'videos': 'Video'
10024
10021
  };
10025
10022
  tableKeys.filter(tableKey => tableKey !== 'datastakeId').forEach(tableKey => {
10026
- var _dataLinkForm$identif;
10027
- const formInputConfig = (dataLinkForm === null || dataLinkForm === void 0 ? void 0 : dataLinkForm[tableKey]) || (dataLinkForm === null || dataLinkForm === void 0 || (_dataLinkForm$identif = dataLinkForm['identification']) === null || _dataLinkForm$identif === void 0 ? void 0 : _dataLinkForm$identif[tableKey]);
10023
+ const formInputConfig = dataLinkForm?.[tableKey] || dataLinkForm?.['identification']?.[tableKey];
10028
10024
  if (formInputConfig) {
10029
- inputs[tableKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10025
+ inputs[tableKey] = {
10026
+ ...formInputConfig,
10030
10027
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : formInputConfig.label || formInputConfig.tableLabel || tableKey
10031
- });
10028
+ };
10032
10029
  if (formInputConfig.label && typeof formInputConfig.label === 'object') {
10033
10030
  const dynamicLabelKeys = Object.keys(formInputConfig.label);
10034
10031
  let resolvedLabel = null;
@@ -10036,7 +10033,7 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10036
10033
  const parts = labelKey.split(' is ');
10037
10034
  if (parts.length === 2) {
10038
10035
  const [conditionKey, conditionValue] = parts;
10039
- if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
10036
+ if (item?.[conditionKey] === conditionValue) {
10040
10037
  resolvedLabel = formInputConfig.label[labelKey];
10041
10038
  break;
10042
10039
  }
@@ -10044,37 +10041,37 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10044
10041
  }
10045
10042
  inputs[tableKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey);
10046
10043
  }
10047
- values[tableKey] = item === null || item === void 0 ? void 0 : item[tableKey];
10044
+ values[tableKey] = item?.[tableKey];
10048
10045
  } else {
10049
- var _item$linking;
10050
10046
  inputs[tableKey] = {
10051
10047
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey,
10052
- type: inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type
10048
+ type: inputConfig?.type
10053
10049
  };
10054
- values[tableKey] = (item === null || item === void 0 || (_item$linking = item.linking) === null || _item$linking === void 0 || (_item$linking = _item$linking.SCL) === null || _item$linking === void 0 || (_item$linking = _item$linking[item === null || item === void 0 ? void 0 : item[tableKey]]) === null || _item$linking === void 0 ? void 0 : _item$linking.name) || (item === null || item === void 0 ? void 0 : item[tableKey]);
10050
+ values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item?.[tableKey];
10055
10051
  }
10056
10052
  });
10057
10053
  siblingInputsMatchingTableKeys.forEach(siblingKey => {
10058
10054
  const siblingConfig = config.inputs[siblingKey];
10059
10055
  if (siblingConfig) {
10060
- inputs[siblingKey] = _objectSpread2(_objectSpread2({}, siblingConfig), {}, {
10056
+ inputs[siblingKey] = {
10057
+ ...siblingConfig,
10061
10058
  label: siblingConfig.label || siblingKey
10062
- });
10063
- values[siblingKey] = item === null || item === void 0 ? void 0 : item[siblingKey];
10059
+ };
10060
+ values[siblingKey] = item?.[siblingKey];
10064
10061
  }
10065
10062
  });
10066
- if (dataLinkForm !== null && dataLinkForm !== void 0 && dataLinkForm.identification && typeof dataLinkForm.identification === 'object') {
10063
+ if (dataLinkForm?.identification && typeof dataLinkForm.identification === 'object') {
10067
10064
  Object.keys(dataLinkForm.identification).filter(fieldKey => fieldKey !== 'datastakeId' && !tableKeys.includes(fieldKey)).filter(fieldKey => {
10068
10065
  const formInputConfig = dataLinkForm.identification[fieldKey];
10069
10066
  return formInputConfig && typeof formInputConfig === 'object' && !Array.isArray(formInputConfig);
10070
10067
  }).forEach(fieldKey => {
10071
- var _item$linking2;
10072
10068
  const formInputConfig = dataLinkForm.identification[fieldKey];
10073
- inputs[fieldKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10069
+ inputs[fieldKey] = {
10070
+ ...formInputConfig,
10074
10071
  label: uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : formInputConfig.label || formInputConfig.tableLabel || fieldKey
10075
- });
10076
- if (formInputConfig !== null && formInputConfig !== void 0 && formInputConfig.label && typeof (formInputConfig === null || formInputConfig === void 0 ? void 0 : formInputConfig.label) === 'object') {
10077
- const dynamicLabelKeys = Object.keys(formInputConfig === null || formInputConfig === void 0 ? void 0 : formInputConfig.label);
10072
+ };
10073
+ if (formInputConfig?.label && typeof formInputConfig?.label === 'object') {
10074
+ const dynamicLabelKeys = Object.keys(formInputConfig?.label);
10078
10075
  let resolvedLabel = null;
10079
10076
  for (const labelKey of dynamicLabelKeys) {
10080
10077
  const parts = labelKey.split(' is ');
@@ -10083,7 +10080,7 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10083
10080
  const flattenedItem = Object.assign({}, item.location, {
10084
10081
  address: item.address
10085
10082
  });
10086
- if ((flattenedItem === null || flattenedItem === void 0 ? void 0 : flattenedItem[conditionKey]) === conditionValue) {
10083
+ if (flattenedItem?.[conditionKey] === conditionValue) {
10087
10084
  resolvedLabel = formInputConfig.label[labelKey];
10088
10085
  break;
10089
10086
  }
@@ -10091,7 +10088,7 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10091
10088
  }
10092
10089
  inputs[fieldKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : fieldKey);
10093
10090
  }
10094
- values[fieldKey] = (item === null || item === void 0 || (_item$linking2 = item.linking) === null || _item$linking2 === void 0 || (_item$linking2 = _item$linking2.SCL) === null || _item$linking2 === void 0 || (_item$linking2 = _item$linking2[item === null || item === void 0 ? void 0 : item[fieldKey]]) === null || _item$linking2 === void 0 ? void 0 : _item$linking2.name) || (item === null || item === void 0 ? void 0 : item[fieldKey]);
10091
+ values[fieldKey] = item?.linking?.SCL?.[item?.[fieldKey]]?.name || item?.[fieldKey];
10095
10092
  });
10096
10093
  }
10097
10094
  return {
@@ -10101,17 +10098,16 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10101
10098
  };
10102
10099
  if (Array.isArray(value)) {
10103
10100
  return value.map((item, itemIndex) => {
10104
- var _merged$inputKey;
10105
10101
  const merged = mergeObject(item);
10106
- const datastakeIdValue = (merged === null || merged === void 0 || (_merged$inputKey = merged[inputKey]) === null || _merged$inputKey === void 0 ? void 0 : _merged$inputKey.datastakeId) || (merged === null || merged === void 0 ? void 0 : merged.datastakeId);
10102
+ const datastakeIdValue = merged?.[inputKey]?.datastakeId || merged?.datastakeId;
10107
10103
  const {
10108
10104
  inputs,
10109
10105
  values
10110
10106
  } = createInputsAndValues(merged);
10111
10107
  return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
10112
- nodeKey: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10108
+ nodeKey: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10113
10109
  config: {
10114
- label: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10110
+ label: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10115
10111
  type: 'custom-datalink-group',
10116
10112
  inputs: inputs
10117
10113
  },
@@ -10125,12 +10121,11 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10125
10121
  getApiBaseUrl: getApiBaseUrl,
10126
10122
  getAppHeader: getAppHeader,
10127
10123
  app: app
10128
- }, "".concat(inputKey, "-").concat(itemIndex));
10124
+ }, `${inputKey}-${itemIndex}`);
10129
10125
  });
10130
10126
  } else {
10131
- var _merged$inputKey2;
10132
10127
  const merged = mergeObject(value);
10133
- const datastakeIdValue = (merged === null || merged === void 0 || (_merged$inputKey2 = merged[inputKey]) === null || _merged$inputKey2 === void 0 ? void 0 : _merged$inputKey2.datastakeId) || (merged === null || merged === void 0 ? void 0 : merged.datastakeId);
10128
+ const datastakeIdValue = merged?.[inputKey]?.datastakeId || merged?.datastakeId;
10134
10129
  const {
10135
10130
  inputs,
10136
10131
  values
@@ -10152,7 +10147,7 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10152
10147
  getApiBaseUrl: getApiBaseUrl,
10153
10148
  getAppHeader: getAppHeader,
10154
10149
  app: app
10155
- }, "".concat(inputKey, "-group"));
10150
+ }, `${inputKey}-group`);
10156
10151
  }
10157
10152
  };
10158
10153
 
@@ -12731,7 +12726,12 @@ const defaultMapConfig = {
12731
12726
  maxZoom: 18,
12732
12727
  preferCanvas: true,
12733
12728
  zoomControl: false,
12734
- maxBounds: maxBounds
12729
+ maxBounds: maxBounds,
12730
+ zoomSnap: 0.5,
12731
+ zoomDelta: 0.5,
12732
+ wheelPxPerZoomLevel: 150,
12733
+ zoomAnimation: true,
12734
+ zoomAnimationThreshold: 10
12735
12735
  };
12736
12736
  const filterValidGPS$1 = data => {
12737
12737
  const latCheck = lat => lat > -90 || lat < 90;
@@ -13513,7 +13513,7 @@ function StakeholderIcon$1({
13513
13513
  React.useEffect(() => {
13514
13514
  linkNodesData.map(node => {
13515
13515
  const isConnectingToStakeholder = node.isStakeholder;
13516
- const id = `${data.datastakeId}-${node.stakeholderId}`;
13516
+ const id = `${data.datastakeId}-${node.stakeholderId || node.datastakeId}`;
13517
13517
  const targetsParentId = node.parentId;
13518
13518
  const targetMarkerIndex = node.stakeholdersIndex;
13519
13519
  const isSibling = targetsParentId === parentId;
@@ -13632,7 +13632,10 @@ function StakeholderIcon$1({
13632
13632
  onClickLink(data);
13633
13633
  }
13634
13634
  }),
13635
- getPopupContainer: () => document.getElementById(data.datastakeId),
13635
+ getPopupContainer: triggerNode => {
13636
+ const mapElement = document.getElementById("map");
13637
+ return mapElement || triggerNode.parentElement || document.body;
13638
+ },
13636
13639
  children: /*#__PURE__*/jsxRuntime.jsx(StakeholderMarker, {
13637
13640
  className: `${data.type} ${isSelected ? "selected" : selectedMarkersId.length > 0 ? "unselected" : ""}
13638
13641
  ${isSmall ? "small" : isMedium ? "medium" : "large"}
@@ -13669,7 +13672,8 @@ function LocationIcon({
13669
13672
  activeMarker,
13670
13673
  setActiveMarker
13671
13674
  }) {
13672
- const root = React.useRef(null);
13675
+ const rootsMapRef = React.useRef(new Map());
13676
+ const markersRef = React.useRef([]);
13673
13677
  const isSelected = selectedMarkersId.includes(data.datastakeId);
13674
13678
  const Marker = React.useMemo(() => {
13675
13679
  if (isMineSite(data.type)) {
@@ -13706,7 +13710,21 @@ function LocationIcon({
13706
13710
  return data?.stakeholders || [];
13707
13711
  }, [data.stakeholders, zoom]);
13708
13712
  React.useEffect(() => {
13709
- stakeholdersOfLocation.map((stakeholder, index) => {
13713
+ const currentRoots = rootsMapRef.current;
13714
+ const currentMarkers = markersRef.current;
13715
+ currentMarkers.forEach(marker => {
13716
+ if (mapRef.hasLayer(marker)) {
13717
+ mapRef.removeLayer(marker);
13718
+ }
13719
+ });
13720
+ currentRoots.forEach(root => {
13721
+ root.unmount();
13722
+ });
13723
+ currentRoots.clear();
13724
+ markersRef.current = [];
13725
+
13726
+ // Create new markers
13727
+ stakeholdersOfLocation.forEach((stakeholder, index) => {
13710
13728
  const markerId = `${stakeholder.datastakeId}`;
13711
13729
  const {
13712
13730
  x,
@@ -13737,28 +13755,34 @@ function LocationIcon({
13737
13755
  iconSize: iconSize
13738
13756
  })
13739
13757
  }).addTo(mapRef);
13740
- const div = document.getElementById(markerId);
13741
- root.current = client.createRoot(div);
13742
- root.current.render( /*#__PURE__*/jsxRuntime.jsx(StakeholderIcon$1, {
13743
- data: stakeholder,
13744
- zoom: zoom,
13745
- allData: allData,
13746
- link: link,
13747
- parentId: data.datastakeId,
13748
- renderTooltip: renderTooltip,
13749
- onClickLink: onClickLink,
13750
- selectedMarkersId: selectedMarkersId,
13751
- handleSelectMarker: handleSelectMarker,
13752
- mapRef: mapRef,
13753
- radius: radius,
13754
- index: index,
13755
- x: x,
13756
- y: y,
13757
- openPopupIdRef: openPopupIdRef,
13758
- polylinesRef: polylinesRef,
13759
- isForceOpen: isForceOpen,
13760
- activeMarker: activeMarker
13761
- }));
13758
+ markersRef.current.push(marker);
13759
+ setTimeout(() => {
13760
+ const div = document.getElementById(markerId);
13761
+ if (div && !rootsMapRef.current.has(markerId)) {
13762
+ const root = client.createRoot(div);
13763
+ rootsMapRef.current.set(markerId, root);
13764
+ root.render( /*#__PURE__*/jsxRuntime.jsx(StakeholderIcon$1, {
13765
+ data: stakeholder,
13766
+ zoom: zoom,
13767
+ allData: allData,
13768
+ link: link,
13769
+ parentId: data.datastakeId,
13770
+ renderTooltip: renderTooltip,
13771
+ onClickLink: onClickLink,
13772
+ selectedMarkersId: selectedMarkersId,
13773
+ handleSelectMarker: handleSelectMarker,
13774
+ mapRef: mapRef,
13775
+ radius: radius,
13776
+ index: index,
13777
+ x: x,
13778
+ y: y,
13779
+ openPopupIdRef: openPopupIdRef,
13780
+ polylinesRef: polylinesRef,
13781
+ isForceOpen: isForceOpen,
13782
+ activeMarker: activeMarker
13783
+ }));
13784
+ }
13785
+ }, 0);
13762
13786
  setMapMarkers(prev => {
13763
13787
  const array = [...prev, {
13764
13788
  id: marker._leaflet_id,
@@ -13788,6 +13812,18 @@ function LocationIcon({
13788
13812
  listOfPolylines: polylinesRef.current
13789
13813
  });
13790
13814
  });
13815
+ return () => {
13816
+ markersRef.current.forEach(marker => {
13817
+ if (mapRef.hasLayer(marker)) {
13818
+ mapRef.removeLayer(marker);
13819
+ }
13820
+ });
13821
+ rootsMapRef.current.forEach(root => {
13822
+ root.unmount();
13823
+ });
13824
+ rootsMapRef.current.clear();
13825
+ markersRef.current = [];
13826
+ };
13791
13827
  }, [stakeholdersOfLocation, selectedMarkersId, activeMarker]);
13792
13828
  linkedNodesData.map(node => {
13793
13829
  const id = `${data.datastakeId}-${node.datastakeId}`;
@@ -13835,8 +13871,10 @@ function LocationIcon({
13835
13871
  // isHovering
13836
13872
  // }
13837
13873
  ,
13838
-
13839
- getPopupContainer: () => document.getElementById(i),
13874
+ getPopupContainer: triggerNode => {
13875
+ const mapElement = document.getElementById("map");
13876
+ return mapElement || triggerNode.parentElement || document.body;
13877
+ },
13840
13878
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
13841
13879
  style: {
13842
13880
  position: "relative",
@@ -13937,6 +13975,7 @@ function StakeholderIcon({
13937
13975
  link,
13938
13976
  onClickLink: () => onClickLink(marker)
13939
13977
  }),
13978
+ getPopupContainer: () => document.getElementById("map"),
13940
13979
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
13941
13980
  style: {
13942
13981
  position: "absolute",
@@ -13978,6 +14017,7 @@ function StakeholderIcon({
13978
14017
  link,
13979
14018
  onClickLink: () => onClickLink(marker)
13980
14019
  }),
14020
+ getPopupContainer: () => document.getElementById("map"),
13981
14021
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
13982
14022
  style: {
13983
14023
  position: "absolute",
@@ -14013,6 +14053,7 @@ function StakeholderIcon({
14013
14053
  link,
14014
14054
  onClickLink: () => onClickLink(marker)
14015
14055
  }),
14056
+ getPopupContainer: () => document.getElementById("map"),
14016
14057
  children: /*#__PURE__*/jsxRuntime.jsx(Style$K
14017
14058
  // onClick={toggleOpen}
14018
14059
  , {
@@ -14576,34 +14617,28 @@ const useMap$1 = ({
14576
14617
  }
14577
14618
  const highlightTable = {};
14578
14619
  for (const [node] of graph) {
14579
- const visited = new Set();
14580
- const queue = [node];
14581
- while (queue.length) {
14582
- const current = queue.shift();
14583
- if (visited.has(current)) continue;
14584
- const currentType = nodeTypes.get(current);
14585
- if (current !== node && isLocation(currentType)) continue;
14586
- visited.add(current);
14587
- for (const neighbor of graph.get(current)) {
14588
- if (!visited.has(neighbor)) queue.push(neighbor);
14589
- }
14590
- }
14591
- if (!isLocation(nodeTypes.get(node)) && stakeToLoc.has(node)) {
14592
- visited.add(stakeToLoc.get(node));
14593
- }
14594
- visited.add(node);
14595
- const extraLocs = new Set();
14596
- for (const n of visited) {
14597
- for (const neighbor of graph.get(n) || []) {
14598
- if (isLocation(nodeTypes.get(neighbor))) {
14599
- extraLocs.add(neighbor);
14620
+ const highlighted = new Set();
14621
+ highlighted.add(node);
14622
+ const nodeIsStakeholder = !isLocation(nodeTypes.get(node));
14623
+ if (nodeIsStakeholder && stakeToLoc.has(node)) {
14624
+ const parentLoc = stakeToLoc.get(node);
14625
+ highlighted.add(parentLoc);
14626
+ }
14627
+ for (const neighbor of graph.get(node) || []) {
14628
+ const neighborIsStakeholder = !isLocation(nodeTypes.get(neighbor));
14629
+ if (neighborIsStakeholder && stakeToLoc.has(neighbor)) {
14630
+ const neighborParent = stakeToLoc.get(neighbor);
14631
+ if (isLocation(nodeTypes.get(node)) && neighborParent === node || nodeIsStakeholder && stakeToLoc.get(node) === neighborParent) {
14632
+ highlighted.add(neighbor);
14633
+ } else {
14634
+ highlighted.add(neighbor);
14635
+ highlighted.add(neighborParent);
14600
14636
  }
14637
+ } else {
14638
+ highlighted.add(neighbor);
14601
14639
  }
14602
14640
  }
14603
- for (const loc of extraLocs) {
14604
- visited.add(loc);
14605
- }
14606
- highlightTable[node] = [...visited];
14641
+ highlightTable[node] = [...highlighted];
14607
14642
  }
14608
14643
  return highlightTable;
14609
14644
  }, [data, type]);
@@ -14736,7 +14771,13 @@ const useMap$1 = ({
14736
14771
  if (mapRef) {
14737
14772
  L__namespace.control.scale().addTo(mapRef);
14738
14773
  L__namespace.tileLayer(TILE_LAYER_URL, {
14739
- access_token: MAP_TOKEN
14774
+ access_token: MAP_TOKEN,
14775
+ keepBuffer: 4,
14776
+ updateWhenZooming: false,
14777
+ updateInterval: 200,
14778
+ maxNativeZoom: 18,
14779
+ tileSize: 256,
14780
+ fadeAnimation: true
14740
14781
  }).addTo(mapRef);
14741
14782
  }
14742
14783
  }, [mapRef]);
@@ -14800,6 +14841,23 @@ const useMap$1 = ({
14800
14841
  mapRef.setView([marker.coordinates[0], marker.coordinates[1]], getZoom(mapRef));
14801
14842
  }
14802
14843
  }, [activeMarker, mapRef]);
14844
+ React.useEffect(() => {
14845
+ if (mapRef && type === "chain") {
14846
+ const handleMapClick = e => {
14847
+ const clickedElement = e.originalEvent.target;
14848
+ const isMarkerClick = clickedElement.closest('.marker-chain') || clickedElement.closest('.leaflet-marker-icon');
14849
+ if (!isMarkerClick && selectedMarkersId.length > 0) {
14850
+ setSelectedMarkersId([]);
14851
+ openPopupIdRef.current = null;
14852
+ setMarkerWithPopup(null);
14853
+ }
14854
+ };
14855
+ mapRef.on('click', handleMapClick);
14856
+ return () => {
14857
+ mapRef.off('click', handleMapClick);
14858
+ };
14859
+ }
14860
+ }, [mapRef, type, selectedMarkersId]);
14803
14861
  return {
14804
14862
  container,
14805
14863
  activeMarker,
@@ -49175,17 +49233,23 @@ const BaseGraph = /*#__PURE__*/React.forwardRef(function BaseGraph({
49175
49233
  }
49176
49234
  return result;
49177
49235
  }, [nodes.length, mandatoryNodesToFit?.length, mandatoryNodesToFit]);
49236
+
49237
+ // In BaseGraph.jsx, replace the useEffect with:
49178
49238
  React.useEffect(() => {
49179
49239
  if (nodesToFit.length === 0) return;
49180
- requestAnimationFrame(() => {
49240
+
49241
+ // Use setTimeout instead of requestAnimationFrame to ensure nodes are rendered
49242
+ const timer = setTimeout(() => {
49181
49243
  fitView({
49182
49244
  padding: 0.4,
49183
49245
  nodes: [...nodesToFit],
49184
49246
  // duration: withDuration ? 300 : undefined,
49185
49247
  maxZoom: 0.9
49186
49248
  });
49187
- });
49188
- }, [JSON.stringify(nodesToFit), withDuration]);
49249
+ }, 100); // Small delay to ensure nodes are rendered
49250
+
49251
+ return () => clearTimeout(timer);
49252
+ }, [nodesToFit.length, nodesToFit.map(n => `${n.id}-${n.width}-${n.height}`).join(','), withDuration]);
49189
49253
  return /*#__PURE__*/jsxRuntime.jsx(ComponentWithFocus, {
49190
49254
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
49191
49255
  style: {
@@ -49214,8 +49278,9 @@ const BaseGraph = /*#__PURE__*/React.forwardRef(function BaseGraph({
49214
49278
  fitView: true // zoom out on default
49215
49279
  ,
49216
49280
  fitViewOptions: {
49217
- padding: 0.2 //zoom out on default
49218
- // ...(zoomOutTransition ? { duration: withDuration ? 300 : undefined } : {}),
49281
+ padding: 0.2,
49282
+ //zoom out on default
49283
+ duration: withDuration ? 300 : undefined
49219
49284
  },
49220
49285
  ...props,
49221
49286
  children: !isPdf && /*#__PURE__*/jsxRuntime.jsxs(react.Controls, {
@@ -49418,7 +49483,8 @@ function TradeRelationship(_ref) {
49418
49483
  filtersConfig,
49419
49484
  onFilterChange = () => {},
49420
49485
  renderTooltipItems = () => [],
49421
- getTotal = () => 0
49486
+ getTotal = () => 0,
49487
+ onRenderComplete = () => {}
49422
49488
  } = _ref;
49423
49489
  const reactFlowWrapper = React.useRef(null);
49424
49490
  const [nodes, setNodes] = react.useNodesState([]);
@@ -49431,6 +49497,23 @@ function TradeRelationship(_ref) {
49431
49497
  const [activeNode, setActiveNode] = React.useState(null);
49432
49498
  // const [initCenter, setInitCenter] = useState(true);
49433
49499
  const [associatedNodes, setAssociatedNodes] = React.useState(null);
49500
+ const isFullyRenderedRef = React.useRef(false);
49501
+ const [isFullyRendered, setIsFullyRendered] = React.useState(false);
49502
+ React.useEffect(() => {
49503
+ isFullyRenderedRef.current = false;
49504
+ setIsFullyRendered(false);
49505
+ setActiveNode(null);
49506
+ }, [data]);
49507
+ React.useEffect(() => {
49508
+ if (nodes.length > 0 && edges.length > 0 && !isFullyRenderedRef.current) {
49509
+ const timeoutId = setTimeout(() => {
49510
+ isFullyRenderedRef.current = true;
49511
+ setIsFullyRendered(true);
49512
+ onRenderComplete(true);
49513
+ }, 200);
49514
+ return () => clearTimeout(timeoutId);
49515
+ }
49516
+ }, [nodes.length, edges.length, associatedNodes]);
49434
49517
  React.useEffect(() => {
49435
49518
  setActiveNode(null);
49436
49519
  }, [data]);
@@ -49455,7 +49538,7 @@ function TradeRelationship(_ref) {
49455
49538
  })
49456
49539
  })), [edges, activeNode, associatedNodes]);
49457
49540
  React.useEffect(() => {
49458
- var _data$sources;
49541
+ var _data$sources, _data$id;
49459
49542
  let yInit = 0;
49460
49543
  let xInit = 0;
49461
49544
  const isBilateral = (data === null || data === void 0 || (_data$sources = data.sources) === null || _data$sources === void 0 ? void 0 : _data$sources.length) >= 1;
@@ -49467,7 +49550,7 @@ function TradeRelationship(_ref) {
49467
49550
  return;
49468
49551
  }
49469
49552
  const _nodes = [{
49470
- id: data.id,
49553
+ id: (_data$id = data.id) === null || _data$id === void 0 ? void 0 : _data$id.toString(),
49471
49554
  type: "expandedNode",
49472
49555
  position: {
49473
49556
  x: xInit,
@@ -49478,13 +49561,13 @@ function TradeRelationship(_ref) {
49478
49561
  const _edges = [];
49479
49562
  if (isBilateral) {
49480
49563
  (data.sources || []).forEach(source => {
49481
- var _data$id;
49564
+ var _data$id2;
49482
49565
  const hasPrev = false;
49483
- _edges.push({
49566
+ const edge = {
49484
49567
  id: "e-".concat(data.id, "-").concat(source),
49485
- source: source,
49486
- type: "default",
49487
- target: data === null || data === void 0 || (_data$id = data.id) === null || _data$id === void 0 ? void 0 : _data$id.toString(),
49568
+ source: source === null || source === void 0 ? void 0 : source.toString(),
49569
+ type: "defaultEdge",
49570
+ target: data === null || data === void 0 || (_data$id2 = data.id) === null || _data$id2 === void 0 ? void 0 : _data$id2.toString(),
49488
49571
  sourceHandle: "left",
49489
49572
  targetHandle: "right",
49490
49573
  data: _objectSpread2(_objectSpread2({
@@ -49497,7 +49580,8 @@ function TradeRelationship(_ref) {
49497
49580
  tooltipTitle,
49498
49581
  moreLeft: false
49499
49582
  })
49500
- });
49583
+ };
49584
+ _edges.push(edge);
49501
49585
  });
49502
49586
  }
49503
49587
  const mapChildren = _ref2 => {
@@ -49541,7 +49625,7 @@ function TradeRelationship(_ref) {
49541
49625
  var _ch$id2, _ch$id3;
49542
49626
  const hasPrev = _prevNodes.find(p => p.id === source);
49543
49627
  const isCustom = !hasPrev ? true : prevChildren.includes(source) ? false : true;
49544
- _edges.push({
49628
+ const edge = {
49545
49629
  id: "e-".concat(ch.id, "-").concat(source),
49546
49630
  source: hasPrev ? source : ch === null || ch === void 0 || (_ch$id2 = ch.id) === null || _ch$id2 === void 0 ? void 0 : _ch$id2.toString(),
49547
49631
  type: isCustom ? "verticalPath" : "defaultEdge",
@@ -49559,7 +49643,8 @@ function TradeRelationship(_ref) {
49559
49643
  tooltipTitle,
49560
49644
  moreLeft: prevChildren.length > children.length
49561
49645
  })
49562
- });
49646
+ };
49647
+ _edges.push(edge);
49563
49648
  if (isCustom) {
49564
49649
  customIndex += 1;
49565
49650
  }
@@ -49598,11 +49683,24 @@ function TradeRelationship(_ref) {
49598
49683
  prevChildren: !isBilateral ? [data.id] : [],
49599
49684
  maxHeight: 0
49600
49685
  });
49686
+
49687
+ // Check for potential ID mismatches
49688
+ const nodeIds = _nodes.map(n => n.id);
49689
+ _edges.filter(e => {
49690
+ const sourceExists = nodeIds.includes(e.source);
49691
+ const targetExists = nodeIds.includes(e.target);
49692
+ return !sourceExists || !targetExists;
49693
+ });
49694
+
49695
+ // Set nodes first
49601
49696
  setNodes(_nodes);
49602
- setEdges(_edges);
49603
- }, [data, activeNode]);
49697
+ const timeoutId = setTimeout(() => {
49698
+ setEdges(_edges);
49699
+ }, 100); // 100ms is imperceptible to users but ensures React Flow is ready
49604
49700
 
49605
- // Used to find associated nodes, when a node is selected
49701
+ // Cleanup to prevent memory leaks if component unmounts quickly
49702
+ return () => clearTimeout(timeoutId);
49703
+ }, [data, activeNode]);
49606
49704
  React.useEffect(() => {
49607
49705
  if (activeNode) {
49608
49706
  let _associatedNodesRight = [activeNode];
@@ -49669,7 +49767,7 @@ function TradeRelationship(_ref) {
49669
49767
  });
49670
49768
  },
49671
49769
  ref: reactFlowWrapper
49672
- });
49770
+ }, JSON.stringify(nodes) + JSON.stringify(edges));
49673
49771
  }
49674
49772
  var index$1 = withProvider(TradeRelationship);
49675
49773
 
@@ -50100,6 +50198,7 @@ var index = withProvider(StakeholderMappings);
50100
50198
 
50101
50199
  const _excluded$1 = ["t", "checkboxConfig", "defaultTableFilters", "columns", "children", "data", "loading", "APP", "getApiBaseUrl", "selectOptions", "selectFilters", "showCreate", "location", "goTo", "getRedirectLink", "defaultUrlParams", "view", "module", "filtersConfig", "isMobile"];
50102
50200
  const BaseScreen = _ref => {
50201
+ var _data$data;
50103
50202
  let {
50104
50203
  t,
50105
50204
  // newFiltersConfig,
@@ -50199,7 +50298,7 @@ const BaseScreen = _ref => {
50199
50298
  className: "daf-table-wrapper pagination-w-padding",
50200
50299
  children: [/*#__PURE__*/jsxRuntime.jsx(DAFTable, _objectSpread2({
50201
50300
  columns: columns,
50202
- data: data === null || data === void 0 ? void 0 : data.data,
50301
+ data: Array.isArray(data === null || data === void 0 ? void 0 : data.data) ? data === null || data === void 0 ? void 0 : data.data : data === null || data === void 0 || (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.data,
50203
50302
  loading: loading,
50204
50303
  hideOnLoading: false,
50205
50304
  pagination: pagination,
@@ -60461,6 +60560,35 @@ function KeyIndicatorNavigateLabel(_ref) {
60461
60560
  });
60462
60561
  }
60463
60562
 
60563
+ function MissingTagButton(_ref) {
60564
+ let {
60565
+ hasMissing,
60566
+ setHighlightMandatory,
60567
+ highlightMandatory,
60568
+ t
60569
+ } = _ref;
60570
+ return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
60571
+ children: hasMissing ? /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
60572
+ onClick: () => setHighlightMandatory(!highlightMandatory),
60573
+ className: formatClassname(['ml-2 highlight-tag', highlightMandatory && 'highlighted']),
60574
+ style: {
60575
+ textAlign: "center"
60576
+ },
60577
+ children: t('missing-inputs')
60578
+ }) : /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
60579
+ title: t('all-inputs-fullfilled'),
60580
+ children: /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
60581
+ onClick: () => setHighlightMandatory(!highlightMandatory),
60582
+ className: formatClassname(['ml-2 highlight-tag disabled']),
60583
+ style: {
60584
+ textAlign: "center"
60585
+ },
60586
+ children: t('missing-inputs')
60587
+ })
60588
+ })
60589
+ });
60590
+ }
60591
+
60464
60592
  var Style$5 = styled__default["default"].div`
60465
60593
  display: flex;
60466
60594
  flex-direction: column;
@@ -61811,6 +61939,7 @@ exports.LineChart = LineChart;
61811
61939
  exports.Loading = Loading;
61812
61940
  exports.LocationTable = LocationTable;
61813
61941
  exports.MineSiteMap = Map$3;
61942
+ exports.MissingTagButton = MissingTagButton;
61814
61943
  exports.Modal = Modal;
61815
61944
  exports.ModalHeader = ModalHeader;
61816
61945
  exports.MoreMenu = MoreMenu;