@octostar/map-component 0.2.6 → 0.2.7

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.
package/dist/index.mjs CHANGED
@@ -6,10 +6,9 @@ import * as turf from "@turf/turf";
6
6
  import proj4 from "proj4";
7
7
  import * as THREE from "three";
8
8
  import { Button, Modal, Input, App, message, Tooltip, Dropdown, Divider, Popover, Switch, Slider, Tag, Select, Collapse, ColorPicker, Tabs, Card, Table, DatePicker } from "antd";
9
- import { saveAs } from "file-saver";
10
- import { MousePointer2, Square, Hexagon, Circle, MoreVertical, ChevronDown, Filter, X, Move, Ruler, Search, Scan, Pencil, Database, MapPin, Minus, Pentagon, Type, MoveRight, Undo2, Redo2, Trash2, Navigation, Loader2, Map as Map$1, Satellite, FolderOpen, Upload, Download, MoreHorizontal, Focus, Box, Layers, Plus, ChevronRight, Eye, EyeOff, Lock, Smile, Package, Copy, FolderInput, Save, Calendar, Palette, Blend, RefreshCw, ExternalLink, Info, SkipBack, Pause, Play, Clock, AlertTriangle, TestTube, Users, GripVertical, Plane, FileJson, Check, Phone, Car, AlertCircle } from "lucide-react";
11
9
  import { clsx } from "clsx";
12
10
  import { twMerge } from "tailwind-merge";
11
+ import { MousePointer2, Square, Hexagon, Circle, MoreVertical, ChevronDown, Filter, X, Move, Ruler, Search, Scan, Pencil, Database, MapPin, Minus, Pentagon, Type, MoveRight, Undo2, Redo2, Trash2, Navigation, Loader2, Map as Map$1, Satellite, FolderOpen, Upload, Download, MoreHorizontal, Focus, Box, Layers, Plus, ChevronRight, Eye, EyeOff, Lock, Smile, Package, Copy, FolderInput, Save, Calendar, Palette, Blend, RefreshCw, ExternalLink, Info, SkipBack, Pause, Play, Clock, AlertTriangle, TestTube, Users, GripVertical, Plane, FileJson, Check, Phone, Car, AlertCircle } from "lucide-react";
13
12
  import { createPortal } from "react-dom";
14
13
  import { format } from "date-fns";
15
14
  import { useStore, createStore } from "zustand";
@@ -367,6 +366,17 @@ function isValidIconValue(value) {
367
366
  function cn(...inputs) {
368
367
  return twMerge(clsx(inputs));
369
368
  }
369
+ function downloadBlob(blob, filename) {
370
+ const url = URL.createObjectURL(blob);
371
+ const anchor = document.createElement("a");
372
+ anchor.href = url;
373
+ anchor.download = filename;
374
+ anchor.rel = "noopener";
375
+ document.body.appendChild(anchor);
376
+ anchor.click();
377
+ anchor.remove();
378
+ setTimeout(() => URL.revokeObjectURL(url), 0);
379
+ }
370
380
  const ToastContext = createContext(null);
371
381
  function useToast() {
372
382
  const externalToast = useContext(ToastContext);
@@ -11646,7 +11656,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
11646
11656
  }
11647
11657
  };
11648
11658
  const blob = new Blob([JSON.stringify(geojson, null, 2)], { type: "application/json" });
11649
- saveAs(blob, `${layer.name.replace(/[^a-z0-9]/gi, "_")}.geojson`);
11659
+ downloadBlob(blob, `${layer.name.replace(/[^a-z0-9]/gi, "_")}.geojson`);
11650
11660
  }, [layers]);
11651
11661
  const handleLoadLayerGeoJSON = useCallback((layerId) => {
11652
11662
  const input = fileInputRef.current;
@@ -11723,7 +11733,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
11723
11733
  if (!draw.current) return;
11724
11734
  const geojson = buildEnrichedGeoJSON();
11725
11735
  const blob = new Blob([JSON.stringify(geojson, null, 2)], { type: "application/geo+json" });
11726
- saveAs(blob, "map_export.geojson");
11736
+ downloadBlob(blob, "map_export.geojson");
11727
11737
  }, [buildEnrichedGeoJSON]);
11728
11738
  const handleSearchAndAddToNewLayer = useCallback(async () => {
11729
11739
  if (!onSearchEngineRequest || !map.current || !draw.current) return;