datastake-daf 0.6.266 → 0.6.268

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.
@@ -20903,7 +20903,9 @@ const SimpleGlobe = _ref => {
20903
20903
  projects = [],
20904
20904
  mapConfig = {},
20905
20905
  showSider = false,
20906
- onProjectClick = () => {}
20906
+ onProjectClick = () => {},
20907
+ type = "default",
20908
+ color = "var(--color-primary-60)"
20907
20909
  } = _ref;
20908
20910
  const mapContainer = React.useRef(null);
20909
20911
  const map = React.useRef(null);
@@ -20959,27 +20961,41 @@ const SimpleGlobe = _ref => {
20959
20961
  console.log('⚠️ [SIMPLE GLOBE] Could not set any fog configuration');
20960
20962
  }
20961
20963
  }
20964
+
20965
+ // Calculate bounds to fit all markers
20966
+ const bounds = new mapboxgl.LngLatBounds();
20967
+ let hasValidCoordinates = false;
20962
20968
  projects.forEach((project, index) => {
20963
20969
  var _project$author;
20964
20970
  console.log("\uD83D\uDCCD [SIMPLE GLOBE] Adding marker ".concat(index, ":"), project);
20965
20971
 
20966
- // Create marker element
20972
+ // Create marker element based on type
20967
20973
  const el = document.createElement('div');
20968
- el.className = 'mapboxgl-marker';
20969
- el.style.width = '25px';
20970
- el.style.height = '25px';
20971
- el.style.backgroundColor = '#00809E';
20972
- el.style.borderRadius = '50%';
20973
- el.style.border = '2px solid white';
20974
+ el.className = 'mapboxgl-marker map-marker';
20974
20975
  el.style.cursor = 'pointer';
20975
20976
  el.style.boxShadow = '0px 3.45px 3.45px 0px #00000029';
20976
20977
  el.style.display = 'flex';
20977
20978
  el.style.alignItems = 'center';
20978
20979
  el.style.justifyContent = 'center';
20979
- el.style.color = 'white';
20980
- el.style.fontWeight = 'bold';
20981
- el.style.fontSize = '12px';
20982
- el.innerHTML = "<span>".concat(project.percentageCompletion || 0, "</span>");
20980
+ if (type === "location") {
20981
+ // Location marker - SVG map pin style
20982
+ el.style.width = '28px';
20983
+ el.style.height = '33px';
20984
+ 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 ");
20985
+ } else {
20986
+ // Default circular marker style
20987
+ el.style.width = '30px';
20988
+ el.style.height = '30px';
20989
+ el.style.backgroundColor = color;
20990
+ el.style.borderRadius = '50%';
20991
+ el.style.border = '2px solid white';
20992
+ el.style.color = 'white';
20993
+ el.style.fontWeight = 'bold';
20994
+ el.style.fontSize = '14px';
20995
+ el.style.textAlign = 'center';
20996
+ el.style.lineHeight = '1';
20997
+ el.innerHTML = "<span style=\"display: block; line-height: 1;\">".concat(project.percentageCompletion || 0, "</span>");
20998
+ }
20983
20999
 
20984
21000
  // Create popup content using the same structure as minesitemap
20985
21001
  const popupContent = "\n <div class=\"daf-tooltip-cont\">\n <div class=\"daf-tooltip-head\">\n <div class=\"daf-tooltip-title\">\n <div>\n <h4>".concat(project.name, "</h4>\n <h5>").concat(project.sectoralScope || 'Project', "</h5>\n </div>\n </div>\n </div>\n <div class=\"daf-tooltip-list\">\n <div class=\"daf-tooltip-list-item\">\n <span class=\"daf-tooltip-name\">Country</span>\n <span class=\"daf-tooltip-value\">").concat(project.country || 'N/A', "</span>\n </div>\n <div class=\"daf-tooltip-list-item\">\n <span class=\"daf-tooltip-name\">Completion</span>\n <span class=\"daf-tooltip-value\">").concat(project.percentageCompletion || 0, "%</span>\n </div>\n <div class=\"daf-tooltip-list-item\">\n <span class=\"daf-tooltip-name\">Author</span>\n <span class=\"daf-tooltip-value\">").concat(((_project$author = project.author) === null || _project$author === void 0 ? void 0 : _project$author.name) || 'N/A', "</span>\n </div>\n <div class=\"daf-tooltip-list-item\">\n <span class=\"daf-tooltip-name\">ID</span>\n <span class=\"daf-tooltip-value\">").concat(project.datastakeId || 'N/A', "</span>\n </div>\n </div>\n </div>\n ");
@@ -20991,16 +21007,46 @@ const SimpleGlobe = _ref => {
20991
21007
  closeOnClick: false
20992
21008
  }).setHTML(popupContent);
20993
21009
 
20994
- // Add marker to map
20995
- new mapboxgl.Marker(el).setLngLat([project.longitude, project.latitude]).setPopup(popup).addTo(map.current);
21010
+ // Ensure coordinates are valid numbers
21011
+ const lng = Number(project.longitude);
21012
+ const lat = Number(project.latitude);
21013
+ console.log("\uD83D\uDCCD [SIMPLE GLOBE] Marker ".concat(index, " coordinates:"), {
21014
+ lng,
21015
+ lat
21016
+ });
21017
+
21018
+ // Validate coordinates
21019
+ if (isNaN(lng) || isNaN(lat) || lng < -180 || lng > 180 || lat < -90 || lat > 90) {
21020
+ console.error("\u274C [SIMPLE GLOBE] Invalid coordinates for project ".concat(index, ":"), {
21021
+ lng,
21022
+ lat
21023
+ });
21024
+ return;
21025
+ }
21026
+
21027
+ // Add coordinates to bounds
21028
+ bounds.extend([lng, lat]);
21029
+ hasValidCoordinates = true;
21030
+
21031
+ // Add marker to map with proper coordinate order [lng, lat]
21032
+ new mapboxgl.Marker(el).setLngLat([lng, lat]).setPopup(popup).addTo(map.current);
20996
21033
 
20997
21034
  // Add click handler
20998
21035
  el.addEventListener('click', () => {
20999
21036
  console.log('📍 [SIMPLE GLOBE] Marker clicked:', project);
21000
21037
  onProjectClick(project);
21001
21038
  });
21002
- console.log("\u2705 [SIMPLE GLOBE] Marker ".concat(index, " added at:"), [project.longitude, project.latitude]);
21039
+ console.log("\u2705 [SIMPLE GLOBE] Marker ".concat(index, " added at:"), [lng, lat]);
21003
21040
  });
21041
+
21042
+ // Fit map to show all markers if we have valid coordinates
21043
+ if (hasValidCoordinates && !bounds.isEmpty()) {
21044
+ console.log('🗺️ [SIMPLE GLOBE] Fitting map to bounds:', bounds);
21045
+ map.current.fitBounds(bounds, {
21046
+ padding: 50,
21047
+ maxZoom: 8
21048
+ });
21049
+ }
21004
21050
  });
21005
21051
  return () => {
21006
21052
  if (map.current) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.266",
3
+ "version": "0.6.268",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -21,12 +21,16 @@ import Style from './style';
21
21
  * @param {Object} mapConfig - Map configuration options (optional)
22
22
  * @param {boolean} showSider - Whether to show the sidebar (default: false)
23
23
  * @param {Function} onProjectClick - Callback when a project pin is clicked
24
+ * @param {string} type - Marker type: "default" for circular markers, "location" for map pin markers
25
+ * @param {string} color - Marker color (default: "var(--color-primary-60)")
24
26
  */
25
27
  const SimpleGlobe = ({
26
28
  projects = [],
27
29
  mapConfig = {},
28
30
  showSider = false,
29
- onProjectClick = () => {}
31
+ onProjectClick = () => {},
32
+ type = "default",
33
+ color = "var(--color-primary-60)"
30
34
  }) => {
31
35
  const mapContainer = useRef(null);
32
36
  const map = useRef(null);
@@ -91,26 +95,55 @@ const SimpleGlobe = ({
91
95
  }
92
96
  }
93
97
 
98
+ // Calculate bounds to fit all markers
99
+ const bounds = new mapboxgl.LngLatBounds();
100
+ let hasValidCoordinates = false;
101
+
94
102
  projects.forEach((project, index) => {
95
103
  console.log(`📍 [SIMPLE GLOBE] Adding marker ${index}:`, project);
96
104
 
97
- // Create marker element
105
+ // Create marker element based on type
98
106
  const el = document.createElement('div');
99
- el.className = 'mapboxgl-marker';
100
- el.style.width = '25px';
101
- el.style.height = '25px';
102
- el.style.backgroundColor = '#00809E';
103
- el.style.borderRadius = '50%';
104
- el.style.border = '2px solid white';
107
+ el.className = 'mapboxgl-marker map-marker';
105
108
  el.style.cursor = 'pointer';
106
109
  el.style.boxShadow = '0px 3.45px 3.45px 0px #00000029';
107
110
  el.style.display = 'flex';
108
111
  el.style.alignItems = 'center';
109
112
  el.style.justifyContent = 'center';
110
- el.style.color = 'white';
111
- el.style.fontWeight = 'bold';
112
- el.style.fontSize = '12px';
113
- el.innerHTML = `<span>${project.percentageCompletion || 0}</span>`;
113
+
114
+ if (type === "location") {
115
+ // Location marker - SVG map pin style
116
+ el.style.width = '28px';
117
+ el.style.height = '33px';
118
+ el.innerHTML = `
119
+ <svg
120
+ width="28"
121
+ height="33"
122
+ viewBox="0 0 28 33"
123
+ fill="none"
124
+ xmlns="http://www.w3.org/2000/svg"
125
+ >
126
+ <path
127
+ 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"
128
+ fill="${color}"
129
+ stroke="white"
130
+ />
131
+ </svg>
132
+ `;
133
+ } else {
134
+ // Default circular marker style
135
+ el.style.width = '30px';
136
+ el.style.height = '30px';
137
+ el.style.backgroundColor = color;
138
+ el.style.borderRadius = '50%';
139
+ el.style.border = '2px solid white';
140
+ el.style.color = 'white';
141
+ el.style.fontWeight = 'bold';
142
+ el.style.fontSize = '14px';
143
+ el.style.textAlign = 'center';
144
+ el.style.lineHeight = '1';
145
+ el.innerHTML = `<span style="display: block; line-height: 1;">${project.percentageCompletion || 0}</span>`;
146
+ }
114
147
 
115
148
  // Create popup content using the same structure as minesitemap
116
149
  const popupContent = `
@@ -151,9 +184,25 @@ const SimpleGlobe = ({
151
184
  closeOnClick: false
152
185
  }).setHTML(popupContent);
153
186
 
154
- // Add marker to map
187
+ // Ensure coordinates are valid numbers
188
+ const lng = Number(project.longitude);
189
+ const lat = Number(project.latitude);
190
+
191
+ console.log(`📍 [SIMPLE GLOBE] Marker ${index} coordinates:`, { lng, lat });
192
+
193
+ // Validate coordinates
194
+ if (isNaN(lng) || isNaN(lat) || lng < -180 || lng > 180 || lat < -90 || lat > 90) {
195
+ console.error(`❌ [SIMPLE GLOBE] Invalid coordinates for project ${index}:`, { lng, lat });
196
+ return;
197
+ }
198
+
199
+ // Add coordinates to bounds
200
+ bounds.extend([lng, lat]);
201
+ hasValidCoordinates = true;
202
+
203
+ // Add marker to map with proper coordinate order [lng, lat]
155
204
  const marker = new mapboxgl.Marker(el)
156
- .setLngLat([project.longitude, project.latitude])
205
+ .setLngLat([lng, lat])
157
206
  .setPopup(popup)
158
207
  .addTo(map.current);
159
208
 
@@ -163,8 +212,17 @@ const SimpleGlobe = ({
163
212
  onProjectClick(project);
164
213
  });
165
214
 
166
- console.log(`✅ [SIMPLE GLOBE] Marker ${index} added at:`, [project.longitude, project.latitude]);
215
+ console.log(`✅ [SIMPLE GLOBE] Marker ${index} added at:`, [lng, lat]);
167
216
  });
217
+
218
+ // Fit map to show all markers if we have valid coordinates
219
+ if (hasValidCoordinates && !bounds.isEmpty()) {
220
+ console.log('🗺️ [SIMPLE GLOBE] Fitting map to bounds:', bounds);
221
+ map.current.fitBounds(bounds, {
222
+ padding: 50,
223
+ maxZoom: 8
224
+ });
225
+ }
168
226
  });
169
227
 
170
228
  return () => {
@@ -78,15 +78,15 @@ export default {
78
78
  },
79
79
  decorators: [
80
80
  (Story) => (
81
- <div style={{ margin: "3em" }}>
81
+
82
82
  <ThemeLayout>
83
83
  <Widget title="Simple Globe with Project Pins" className="no-px no-pb-body">
84
- <div style={{ width: '100%', height: '600px' }}>
84
+ {/* <div style={{ width: '100%', height: '600px' }}> */}
85
85
  <Story />
86
- </div>
86
+ {/* </div> */}
87
87
  </Widget>
88
88
  </ThemeLayout>
89
- </div>
89
+
90
90
  ),
91
91
  ],
92
92
  };
@@ -158,6 +158,34 @@ export const EmptyState = {
158
158
  }
159
159
  };
160
160
 
161
+ export const LocationMarkers = {
162
+ name: "Location Markers (Map Pin Style)",
163
+ args: {
164
+ projects: SAMPLE_PROJECTS,
165
+ showSider: true,
166
+ type: "location"
167
+ }
168
+ };
169
+
170
+ export const CustomColorMarkers = {
171
+ name: "Custom Color Markers",
172
+ args: {
173
+ projects: SAMPLE_PROJECTS,
174
+ showSider: true,
175
+ color: "#FF6B6B"
176
+ }
177
+ };
178
+
179
+ export const LocationCustomColor = {
180
+ name: "Location Markers with Custom Color",
181
+ args: {
182
+ projects: SAMPLE_PROJECTS,
183
+ showSider: true,
184
+ type: "location",
185
+ color: "#4ECDC4"
186
+ }
187
+ };
188
+
161
189
  export const DebugVersion = {
162
190
  name: "Debug Version (Direct Mapbox)",
163
191
  render: () => (