@octostar/map-component 0.1.11 → 0.1.13
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.cjs +22 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +28 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -38,14 +38,25 @@ const toGeoJSON__namespace = /* @__PURE__ */ _interopNamespaceDefault(toGeoJSON)
|
|
|
38
38
|
function cn(...inputs) {
|
|
39
39
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
40
40
|
}
|
|
41
|
+
const ToastContext = react.createContext(null);
|
|
41
42
|
function useToast() {
|
|
42
|
-
const
|
|
43
|
+
const externalToast = react.useContext(ToastContext);
|
|
44
|
+
if (externalToast) {
|
|
45
|
+
return { toast: externalToast };
|
|
46
|
+
}
|
|
47
|
+
let message = null;
|
|
48
|
+
try {
|
|
49
|
+
const app = antd.App.useApp();
|
|
50
|
+
message = app.message;
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
43
53
|
const toast = ({ title, description, variant }) => {
|
|
44
54
|
const content = description ? `${title ? title + ": " : ""}${description}` : title;
|
|
55
|
+
const msg = message ?? antd.message;
|
|
45
56
|
if (variant === "destructive") {
|
|
46
|
-
|
|
57
|
+
msg.error(content);
|
|
47
58
|
} else {
|
|
48
|
-
|
|
59
|
+
msg.success(content);
|
|
49
60
|
}
|
|
50
61
|
};
|
|
51
62
|
return { toast };
|
|
@@ -4615,7 +4626,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
4615
4626
|
hideBasemapSwitcher = false,
|
|
4616
4627
|
externalPersistence = false,
|
|
4617
4628
|
enableKeyboardShortcuts = true,
|
|
4618
|
-
enableProperties = true
|
|
4629
|
+
enableProperties = true,
|
|
4630
|
+
toastProvider
|
|
4619
4631
|
}, ref) {
|
|
4620
4632
|
const mapContainer = react.useRef(null);
|
|
4621
4633
|
const map = react.useRef(null);
|
|
@@ -4688,7 +4700,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
4688
4700
|
const [labelsSuppressed, setLabelsSuppressed] = react.useState(true);
|
|
4689
4701
|
const [contextMenu, setContextMenu] = react.useState(null);
|
|
4690
4702
|
const timelineStore = useTimelineStore();
|
|
4691
|
-
const { toast } = useToast();
|
|
4703
|
+
const { toast: internalToast } = useToast();
|
|
4704
|
+
const toast = toastProvider ?? internalToast;
|
|
4692
4705
|
react.useEffect(() => {
|
|
4693
4706
|
const handleError = (event) => {
|
|
4694
4707
|
const msg = event.message || "";
|
|
@@ -9854,7 +9867,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9854
9867
|
] })
|
|
9855
9868
|
] }) });
|
|
9856
9869
|
}
|
|
9857
|
-
|
|
9870
|
+
const toastContextValue = toastProvider ?? null;
|
|
9871
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ToastContext.Provider, { value: toastContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(MapDropZone, { onDrop: handleDropGeoJSON, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `map-container w-full h-full min-w-0 relative ${className || ""}`, "data-testid": "map-editor-canvas", children: [
|
|
9858
9872
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9859
9873
|
"div",
|
|
9860
9874
|
{
|
|
@@ -10102,7 +10116,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10102
10116
|
onGoTo: (coords, zoom) => {
|
|
10103
10117
|
if (map.current) {
|
|
10104
10118
|
const currentZoom = map.current.getZoom();
|
|
10105
|
-
map.current.flyTo({ center: coords, zoom: zoom ?? Math.max(currentZoom,
|
|
10119
|
+
map.current.flyTo({ center: coords, zoom: zoom ?? Math.max(currentZoom, 14), duration: 2e3 });
|
|
10106
10120
|
}
|
|
10107
10121
|
},
|
|
10108
10122
|
showClearFilter,
|
|
@@ -10376,7 +10390,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10376
10390
|
"data-testid": "input-file-geojson"
|
|
10377
10391
|
}
|
|
10378
10392
|
)
|
|
10379
|
-
] }) });
|
|
10393
|
+
] }) }) });
|
|
10380
10394
|
});
|
|
10381
10395
|
function ActionPanel({ onSave, onLoad, disabled }) {
|
|
10382
10396
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|