@octostar/map-component 0.2.1 → 0.2.2
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 +30 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +31 -13
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/dist/types/components/timebar.d.ts.map +1 -1
- package/dist/types/lib/timeline-store.d.ts +34 -1
- package/dist/types/lib/timeline-store.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4547,7 +4547,7 @@ function computeHistogramBins(features, minDate, maxDate, binCount = 50) {
|
|
|
4547
4547
|
});
|
|
4548
4548
|
return bins;
|
|
4549
4549
|
}
|
|
4550
|
-
const
|
|
4550
|
+
const timelineStoreInitializer = (set, get) => ({
|
|
4551
4551
|
isEnabled: false,
|
|
4552
4552
|
hasTemporalData: false,
|
|
4553
4553
|
temporalFeatures: [],
|
|
@@ -4652,7 +4652,24 @@ const useTimelineStore = zustand.create((set, get) => ({
|
|
|
4652
4652
|
isPlaying: false,
|
|
4653
4653
|
histogramBins: []
|
|
4654
4654
|
})
|
|
4655
|
-
})
|
|
4655
|
+
});
|
|
4656
|
+
function createTimelineStore() {
|
|
4657
|
+
return zustand.createStore(timelineStoreInitializer);
|
|
4658
|
+
}
|
|
4659
|
+
const TimelineStoreContext = react.createContext(null);
|
|
4660
|
+
function useTimelineStoreApi() {
|
|
4661
|
+
const store = react.useContext(TimelineStoreContext);
|
|
4662
|
+
if (!store) {
|
|
4663
|
+
throw new Error("useTimelineStoreApi must be used within a MapEditorCanvas (TimelineStoreContext.Provider)");
|
|
4664
|
+
}
|
|
4665
|
+
return store;
|
|
4666
|
+
}
|
|
4667
|
+
const identityTimelineSelector = (state) => state;
|
|
4668
|
+
function useTimelineStore(selector) {
|
|
4669
|
+
const store = useTimelineStoreApi();
|
|
4670
|
+
const select = selector ?? identityTimelineSelector;
|
|
4671
|
+
return zustand.useStore(store, select);
|
|
4672
|
+
}
|
|
4656
4673
|
const TIMEBAR_HEIGHT = 158;
|
|
4657
4674
|
const TIMEBAR_BOTTOM_OFFSET = 12;
|
|
4658
4675
|
const MINUTE_MS = 6e4;
|
|
@@ -4893,6 +4910,7 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
|
|
|
4893
4910
|
setRange,
|
|
4894
4911
|
setPlaying
|
|
4895
4912
|
} = useTimelineStore();
|
|
4913
|
+
const timelineStoreApi = useTimelineStoreApi();
|
|
4896
4914
|
const hasSelection = selectedFeatureIds.length > 0;
|
|
4897
4915
|
const selectedTemporalFeatures = react.useMemo(() => {
|
|
4898
4916
|
if (!hasSelection) return temporalFeatures;
|
|
@@ -4976,7 +4994,7 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
|
|
|
4976
4994
|
const elapsed = timestamp - lastFrameTimeRef.current;
|
|
4977
4995
|
if (elapsed >= frameInterval) {
|
|
4978
4996
|
lastFrameTimeRef.current = timestamp;
|
|
4979
|
-
const state =
|
|
4997
|
+
const state = timelineStoreApi.getState();
|
|
4980
4998
|
if (!state.rangeStart || !state.globalMaxDate || !state.globalMinDate) {
|
|
4981
4999
|
setPlaying(false);
|
|
4982
5000
|
return;
|
|
@@ -6076,8 +6094,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6076
6094
|
const [labelsSuppressed, setLabelsSuppressed] = react.useState(true);
|
|
6077
6095
|
const [cursorCoords, setCursorCoords] = react.useState(null);
|
|
6078
6096
|
const [contextMenu, setContextMenu] = react.useState(null);
|
|
6079
|
-
const
|
|
6080
|
-
|
|
6097
|
+
const [timelineStoreApi] = react.useState(createTimelineStore);
|
|
6098
|
+
const timelineStore = zustand.useStore(timelineStoreApi);
|
|
6081
6099
|
const { toast: internalToast } = useToast();
|
|
6082
6100
|
const toast = toastProvider ?? internalToast;
|
|
6083
6101
|
react.useEffect(() => {
|
|
@@ -6950,8 +6968,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6950
6968
|
}
|
|
6951
6969
|
layerTemporalCacheRef.current.set(layerId, { featureCount: features.length, hasTemporal: layerHasTemporal });
|
|
6952
6970
|
});
|
|
6953
|
-
|
|
6954
|
-
}, []);
|
|
6971
|
+
timelineStoreApi.getState().setTemporalFeatures(temporalFeatures, untimedIds);
|
|
6972
|
+
}, [timelineStoreApi]);
|
|
6955
6973
|
const scheduleTimelineUpdate = react.useCallback(() => {
|
|
6956
6974
|
if (timelineUpdateTimerRef.current) clearTimeout(timelineUpdateTimerRef.current);
|
|
6957
6975
|
timelineUpdateTimerRef.current = setTimeout(() => {
|
|
@@ -8955,10 +8973,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8955
8973
|
},
|
|
8956
8974
|
isEditModeEnabled: () => isEditMode,
|
|
8957
8975
|
setTimelineEnabled: (enabled) => {
|
|
8958
|
-
|
|
8976
|
+
timelineStoreApi.getState().setEnabled(enabled);
|
|
8959
8977
|
},
|
|
8960
8978
|
setTimelineRange: (start, end) => {
|
|
8961
|
-
|
|
8979
|
+
timelineStoreApi.getState().setRange(start, end);
|
|
8962
8980
|
onTimelineChange == null ? void 0 : onTimelineChange(start, end);
|
|
8963
8981
|
},
|
|
8964
8982
|
exportGeoJSON: (layerIds) => {
|
|
@@ -9277,7 +9295,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9277
9295
|
return features;
|
|
9278
9296
|
},
|
|
9279
9297
|
getTimelineRange: () => {
|
|
9280
|
-
const ts =
|
|
9298
|
+
const ts = timelineStoreApi.getState();
|
|
9281
9299
|
return {
|
|
9282
9300
|
start: ts.rangeStart,
|
|
9283
9301
|
end: ts.rangeEnd
|
|
@@ -12605,7 +12623,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12605
12623
|
] }) });
|
|
12606
12624
|
}
|
|
12607
12625
|
const toastContextValue = toastProvider ?? null;
|
|
12608
|
-
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 overflow-hidden isolate ${className || ""}`, "data-testid": "map-editor-canvas", children: [
|
|
12626
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TimelineStoreContext.Provider, { value: timelineStoreApi, children: /* @__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 overflow-hidden isolate ${className || ""}`, "data-testid": "map-editor-canvas", children: [
|
|
12609
12627
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12610
12628
|
"div",
|
|
12611
12629
|
{
|
|
@@ -13106,7 +13124,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13106
13124
|
"data-testid": "input-file-geojson"
|
|
13107
13125
|
}
|
|
13108
13126
|
)
|
|
13109
|
-
] }) }) });
|
|
13127
|
+
] }) }) }) });
|
|
13110
13128
|
});
|
|
13111
13129
|
function ActionPanel({ onSave, onLoad, disabled }) {
|
|
13112
13130
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|