datastake-daf 0.6.287 → 0.6.288

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.
@@ -20938,6 +20938,331 @@ Globe.propTypes = {
20938
20938
  nameAsSiderTitle: PropTypes__default["default"].bool
20939
20939
  };
20940
20940
 
20941
+ const SimpleGlobe = _ref => {
20942
+ let {
20943
+ projects = [],
20944
+ mapConfig = {},
20945
+ showSider = false,
20946
+ onProjectClick = () => {},
20947
+ type = "default",
20948
+ color = "var(--color-primary-60)",
20949
+ renderTooltip: renderTooltip$1 = null
20950
+ } = _ref;
20951
+ const mapContainer = React.useRef(null);
20952
+ const map = React.useRef(null);
20953
+ const boundsRef = React.useRef(null);
20954
+ React.useEffect(() => {
20955
+ if (map.current) return; // Initialize map only once
20956
+
20957
+ console.log('🗺️ [SIMPLE GLOBE] Creating map...');
20958
+
20959
+ // Set Mapbox access token
20960
+ mapboxgl.accessToken = 'pk.eyJ1IjoicmVkaXM5OTkiLCJhIjoiY2x4YWV5MzA5MmtuZzJpcXM5Y201Z2E2YiJ9.m5bwPg-Tj4Akesl1yQUa3w';
20961
+
20962
+ // Create map with custom Straatos style - 3D globe configuration
20963
+ map.current = new mapboxgl.Map({
20964
+ container: mapContainer.current,
20965
+ style: 'mapbox://styles/pietragottardo/cm9tt9zfi00d101pg1vdx26si',
20966
+ center: [0, 0],
20967
+ zoom: mapConfig.maxZoom || 3,
20968
+ projection: 'globe',
20969
+ // 3D globe settings for proper rendering
20970
+ pitch: 0,
20971
+ bearing: 0,
20972
+ antialias: true,
20973
+ fadeDuration: 0,
20974
+ attributionControl: false
20975
+ });
20976
+
20977
+ // Configure 3D globe when style loads
20978
+ map.current.on('style.load', () => {
20979
+ console.log('🎨 [SIMPLE GLOBE] Style loaded, configuring 3D globe...');
20980
+
20981
+ // Set fog for the space background effect with stars
20982
+ try {
20983
+ map.current.setFog({
20984
+ 'color': 'rgb(0, 0, 0)',
20985
+ 'high-color': 'rgb(0, 0, 0)',
20986
+ 'horizon-blend': 0.1,
20987
+ 'space-color': 'rgb(0, 0, 0)',
20988
+ 'star-intensity': 0.6
20989
+ });
20990
+ console.log('✨ [SIMPLE GLOBE] Space background with stars set');
20991
+ } catch (e) {
20992
+ console.log('⚠️ [SIMPLE GLOBE] Could not set fog, trying alternative...');
20993
+ // Fallback: try simpler fog configuration
20994
+ try {
20995
+ map.current.setFog({
20996
+ 'color': 'rgb(0, 0, 0)',
20997
+ 'high-color': 'rgb(0, 0, 0)',
20998
+ 'horizon-blend': 0.1
20999
+ });
21000
+ console.log('✨ [SIMPLE GLOBE] Alternative space background set');
21001
+ } catch (e2) {
21002
+ console.log('⚠️ [SIMPLE GLOBE] Could not set any fog configuration');
21003
+ }
21004
+ }
21005
+
21006
+ // Set lighting for better 3D globe visibility
21007
+ try {
21008
+ map.current.setLight({
21009
+ 'anchor': 'viewport',
21010
+ 'color': 'white',
21011
+ 'intensity': 0.4
21012
+ });
21013
+ console.log('💡 [SIMPLE GLOBE] Lighting configured for 3D globe');
21014
+ } catch (e) {
21015
+ console.log('⚠️ [SIMPLE GLOBE] Could not set lighting');
21016
+ }
21017
+ });
21018
+
21019
+ // Add markers when map loads
21020
+ map.current.on('load', () => {
21021
+ console.log('🗺️ [SIMPLE GLOBE] Map loaded, adding markers...');
21022
+
21023
+ // Hide Mapbox logo and attribution completely
21024
+ map.current.getContainer();
21025
+ const style = document.createElement('style');
21026
+ style.textContent = "\n .mapboxgl-ctrl-logo,\n .mapboxgl-ctrl-attrib,\n .mapboxgl-ctrl-bottom-left,\n .mapboxgl-ctrl-bottom-right {\n display: none !important;\n }\n .mapboxgl-canvas-container {\n overflow: hidden !important;\n }\n .mapboxgl-canvas {\n overflow: hidden !important;\n }\n /* CRITICAL: Override Leaflet CSS interference with Mapbox */\n .daf-simple-globe-container .mapboxgl-canvas-container {\n position: relative !important;\n left: auto !important;\n top: auto !important;\n }\n .daf-simple-globe-container .mapboxgl-canvas-container canvas {\n position: relative !important;\n left: auto !important;\n top: auto !important;\n transform: none !important;\n }\n /* Prevent Leaflet styles from affecting Mapbox markers */\n .daf-simple-globe-container .daf-globe-marker {\n position: relative !important;\n left: auto !important;\n top: auto !important;\n }\n ";
21027
+ document.head.appendChild(style);
21028
+
21029
+ // Calculate bounds to fit all markers
21030
+ const bounds = new mapboxgl.LngLatBounds();
21031
+ let hasValidCoordinates = false;
21032
+ projects.forEach((project, index) => {
21033
+ console.log("\uD83D\uDCCD [SIMPLE GLOBE] Adding marker ".concat(index, ":"), project);
21034
+
21035
+ // Create marker element based on type
21036
+ const el = document.createElement('div');
21037
+ // Use a scoped class to avoid picking up broad styles like `.map-marker { width:100% }`
21038
+ el.className = 'daf-globe-marker';
21039
+ el.style.cursor = 'pointer';
21040
+ el.style.boxShadow = '0px 3.45px 3.45px 0px #00000029';
21041
+ el.style.display = 'flex';
21042
+ el.style.alignItems = 'center';
21043
+ el.style.justifyContent = 'center';
21044
+ if (type === "location") {
21045
+ // Location marker - SVG map pin style
21046
+ el.style.width = '28px';
21047
+ el.style.height = '33px';
21048
+ el.innerHTML = "\n <svg\n width=\"28\"\n height=\"33\"\n viewBox=\"0 0 28 33\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M5.14346 4.87419C10.0688 -0.15896 18.0528 -0.162058 22.9757 4.86861C27.6563 9.65161 27.8841 17.2616 23.6622 22.3255H23.6608C23.427 22.6141 23.1808 22.894 22.9211 23.1623L14.0671 32.2101L5.44057 23.3948L5.13868 23.096C0.215857 18.0655 0.218422 9.90737 5.14346 4.87419Z\"\n fill=\"".concat(color, "\"\n stroke=\"white\"\n />\n </svg>\n ");
21049
+ } else {
21050
+ // Default circular marker style
21051
+ el.style.width = '30px';
21052
+ el.style.height = '30px';
21053
+ el.style.backgroundColor = color;
21054
+ el.style.borderRadius = '50%';
21055
+ el.style.border = '2px solid white';
21056
+ el.style.color = 'white';
21057
+ el.style.fontWeight = 'bold';
21058
+ el.style.fontSize = '14px';
21059
+ el.style.textAlign = 'center';
21060
+ el.style.lineHeight = '1';
21061
+ el.innerHTML = "<span style=\"display: block; line-height: 1;\">".concat(project.percentageCompletion || 0, "</span>");
21062
+ }
21063
+
21064
+ // Create popup content using custom renderTooltip or default
21065
+ let popupContent;
21066
+ if (renderTooltip$1 && typeof renderTooltip$1 === 'function') {
21067
+ // Use custom renderTooltip function (same as MineSiteMap)
21068
+ const tooltipData = renderTooltip$1(project);
21069
+ popupContent = renderTooltip({
21070
+ title: project.name,
21071
+ subTitle: project.sectoralScope || 'Project',
21072
+ items: tooltipData,
21073
+ link: false
21074
+ });
21075
+ } else {
21076
+ // Use default tooltip structure
21077
+ const tooltipData = [{
21078
+ label: "Country",
21079
+ value: project.country || 'N/A'
21080
+ }, {
21081
+ label: "Sectoral Scope",
21082
+ value: project.sectoralScope || 'Project'
21083
+ }];
21084
+ popupContent = renderTooltip({
21085
+ title: project.name,
21086
+ subTitle: project.sectoralScope || 'Project',
21087
+ items: tooltipData,
21088
+ link: false
21089
+ });
21090
+ }
21091
+
21092
+ // Create popup
21093
+ const popup = new mapboxgl.Popup({
21094
+ offset: 25,
21095
+ closeButton: true,
21096
+ closeOnClick: false
21097
+ }).setHTML(popupContent);
21098
+
21099
+ // Ensure coordinates are valid numbers
21100
+ const lng = Number(project.longitude);
21101
+ const lat = Number(project.latitude);
21102
+ console.log("\uD83D\uDCCD [SIMPLE GLOBE] Marker ".concat(index, " coordinates:"), {
21103
+ lng,
21104
+ lat,
21105
+ project: project.name
21106
+ });
21107
+
21108
+ // Validate coordinates
21109
+ if (isNaN(lng) || isNaN(lat) || lng < -180 || lng > 180 || lat < -90 || lat > 90) {
21110
+ console.error("\u274C [SIMPLE GLOBE] Invalid coordinates for project ".concat(index, ":"), {
21111
+ lng,
21112
+ lat,
21113
+ project: project.name
21114
+ });
21115
+ return;
21116
+ }
21117
+
21118
+ // Add coordinates to bounds
21119
+ bounds.extend([lng, lat]);
21120
+ hasValidCoordinates = true;
21121
+
21122
+ // Create marker with explicit positioning and anchor for 3D globe
21123
+ const marker = new mapboxgl.Marker({
21124
+ element: el,
21125
+ anchor: 'center'
21126
+ }).setLngLat([lng, lat]).setPopup(popup).addTo(map.current);
21127
+
21128
+ // Add click handler
21129
+ el.addEventListener('click', () => {
21130
+ console.log('📍 [SIMPLE GLOBE] Marker clicked:', project);
21131
+ onProjectClick(project);
21132
+ });
21133
+
21134
+ // Verify marker position after a short delay (like other Globe components)
21135
+ setTimeout(() => {
21136
+ const markerLngLat = marker.getLngLat();
21137
+ console.log("\uD83D\uDD0D [SIMPLE GLOBE] Marker ".concat(index, " position verification:"), {
21138
+ expected: [lng, lat],
21139
+ actual: [markerLngLat.lng, markerLngLat.lat],
21140
+ project: project.name,
21141
+ match: Math.abs(markerLngLat.lng - lng) < 0.0001 && Math.abs(markerLngLat.lat - lat) < 0.0001
21142
+ });
21143
+ }, 100);
21144
+ console.log("\u2705 [SIMPLE GLOBE] Marker ".concat(index, " added at:"), [lng, lat]);
21145
+ });
21146
+
21147
+ // Fit map to show all markers if we have valid coordinates
21148
+ if (hasValidCoordinates && !bounds.isEmpty()) {
21149
+ console.log('🗺️ [SIMPLE GLOBE] Fitting map to bounds:', bounds);
21150
+ map.current.fitBounds(bounds, {
21151
+ padding: {
21152
+ top: 20,
21153
+ bottom: 20,
21154
+ left: 20,
21155
+ right: 20
21156
+ },
21157
+ maxZoom: 6,
21158
+ duration: 1000
21159
+ });
21160
+ boundsRef.current = bounds;
21161
+ } else {
21162
+ boundsRef.current = null;
21163
+ }
21164
+
21165
+ // Force resize for 3D globe rendering
21166
+ setTimeout(() => {
21167
+ if (map.current && map.current.resize) {
21168
+ map.current.resize();
21169
+ console.log('🔄 [SIMPLE GLOBE] Map resized for 3D globe rendering');
21170
+ }
21171
+ }, 100);
21172
+ });
21173
+ return () => {
21174
+ if (map.current) {
21175
+ map.current.remove();
21176
+ map.current = null;
21177
+ }
21178
+ };
21179
+ }, [projects, onProjectClick, mapConfig]);
21180
+ const zoomIn = () => map.current && map.current.zoomIn();
21181
+ const zoomOut = () => map.current && map.current.zoomOut();
21182
+ const recenter = () => {
21183
+ if (!map.current) return;
21184
+ if (boundsRef.current && !boundsRef.current.isEmpty()) {
21185
+ map.current.fitBounds(boundsRef.current, {
21186
+ padding: {
21187
+ top: 20,
21188
+ bottom: 20,
21189
+ left: 20,
21190
+ right: 20
21191
+ },
21192
+ maxZoom: 6,
21193
+ duration: 800
21194
+ });
21195
+ return;
21196
+ }
21197
+ map.current.easeTo({
21198
+ center: [0, 0],
21199
+ zoom: 3,
21200
+ duration: 800
21201
+ });
21202
+ };
21203
+ const pitchUp = () => {
21204
+ var _map$current$getPitch, _map$current;
21205
+ if (!map.current) return;
21206
+ const next = Math.min((((_map$current$getPitch = (_map$current = map.current).getPitch) === null || _map$current$getPitch === void 0 ? void 0 : _map$current$getPitch.call(_map$current)) || 0) + 10, 85);
21207
+ map.current.setPitch(next);
21208
+ };
21209
+ const pitchDown = () => {
21210
+ var _map$current$getPitch2, _map$current2;
21211
+ if (!map.current) return;
21212
+ const next = Math.max((((_map$current$getPitch2 = (_map$current2 = map.current).getPitch) === null || _map$current$getPitch2 === void 0 ? void 0 : _map$current$getPitch2.call(_map$current2)) || 0) - 10, 0);
21213
+ map.current.setPitch(next);
21214
+ };
21215
+ return /*#__PURE__*/jsxRuntime.jsx(Style$A, {
21216
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
21217
+ className: "daf-simple-globe-container",
21218
+ style: {
21219
+ width: '100%',
21220
+ height: '100%',
21221
+ overflow: 'hidden',
21222
+ position: 'relative'
21223
+ },
21224
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
21225
+ ref: mapContainer,
21226
+ className: "daf-globe-map-container",
21227
+ style: {
21228
+ width: '100%',
21229
+ height: '100%',
21230
+ overflow: 'hidden',
21231
+ position: 'relative'
21232
+ }
21233
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
21234
+ className: "map-control-buttons",
21235
+ children: [/*#__PURE__*/jsxRuntime.jsx("button", {
21236
+ type: "button",
21237
+ "aria-label": "Zoom in",
21238
+ onClick: zoomIn,
21239
+ children: "+"
21240
+ }), /*#__PURE__*/jsxRuntime.jsx("button", {
21241
+ type: "button",
21242
+ "aria-label": "Zoom out",
21243
+ onClick: zoomOut,
21244
+ children: "\u2212"
21245
+ }), /*#__PURE__*/jsxRuntime.jsx("button", {
21246
+ type: "button",
21247
+ "aria-label": "Recenter",
21248
+ onClick: recenter,
21249
+ children: "\u25CE"
21250
+ }), /*#__PURE__*/jsxRuntime.jsx("button", {
21251
+ type: "button",
21252
+ "aria-label": "Pitch up",
21253
+ onClick: pitchUp,
21254
+ children: "^"
21255
+ }), /*#__PURE__*/jsxRuntime.jsx("button", {
21256
+ type: "button",
21257
+ "aria-label": "Pitch down",
21258
+ onClick: pitchDown,
21259
+ children: "\u02C5"
21260
+ })]
21261
+ })]
21262
+ })
21263
+ });
21264
+ };
21265
+
20941
21266
  const IsolatedGlobe = _ref => {
20942
21267
  let {
20943
21268
  projects = [],
@@ -62148,6 +62473,7 @@ exports.SelectFiltersTimeFrame = Timeframe;
62148
62473
  exports.SettingsPopover = SettingsPopover;
62149
62474
  exports.Sidenav = Sidenav;
62150
62475
  exports.SidenavMenu = SidenavMenu;
62476
+ exports.SimpleGlobe = SimpleGlobe;
62151
62477
  exports.StackChart = StackChart;
62152
62478
  exports.StakeholderMappings = index$1;
62153
62479
  exports.Steps = DAFSteps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.287",
3
+ "version": "0.6.288",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
package/src/index.js CHANGED
@@ -62,6 +62,7 @@ export { default as TooltipIcon } from "./@daf/core/components/Icon/TooltipIcon.
62
62
  export { default as MineSiteMap } from "./@daf/core/components/Dashboard/Map/index.jsx";
63
63
  export { default as InExpandableWidgetMap } from "./@daf/core/components/Dashboard/Map/InExpandableWidgetMap/index.jsx";
64
64
  export { default as Globe } from "./@daf/core/components/Dashboard/Globe/index.jsx";
65
+ export { default as SimpleGlobe } from "./@daf/core/components/Dashboard/Globe/SimpleGlobe.jsx";
65
66
  export { default as IsolatedGlobe } from "./@daf/core/components/Dashboard/Globe/IsolatedGlobe.jsx";
66
67
  export { default as NoConflictGlobe } from "./@daf/core/components/Dashboard/Globe/NoConflictGlobe.jsx";
67
68
  export { default as WidgetPlaceholder } from "./@daf/core/components/Dashboard/Widget/WidgetPlaceholder/index.jsx";