@octostar/map-component 0.3.4 → 0.3.5

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 CHANGED
@@ -7402,7 +7402,7 @@ function formatDateTime(date) {
7402
7402
  minute: "2-digit"
7403
7403
  });
7404
7404
  }
7405
- function Histogram({ bins, maxCount, colorGroupedBins }) {
7405
+ function Histogram({ bins, maxCount, colorGroupedBins, selectedBins }) {
7406
7406
  const [hoveredBin, setHoveredBin] = react.useState(null);
7407
7407
  const containerRef = react.useRef(null);
7408
7408
  if (bins.length === 0 || maxCount === 0) return null;
@@ -7461,7 +7461,8 @@ function Histogram({ bins, maxCount, colorGroupedBins }) {
7461
7461
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-muted-foreground", children: [
7462
7462
  bins[hoveredBin].count,
7463
7463
  " event",
7464
- bins[hoveredBin].count !== 1 ? "s" : ""
7464
+ bins[hoveredBin].count !== 1 ? "s" : "",
7465
+ !!(selectedBins == null ? void 0 : selectedBins[hoveredBin]) && ` (${selectedBins[hoveredBin]} selected)`
7465
7466
  ] })
7466
7467
  ]
7467
7468
  }
@@ -7532,7 +7533,9 @@ function Timebar({
7532
7533
  return { ...bin, count };
7533
7534
  });
7534
7535
  }, [hasSelection, selectionAsLine, storeHistogramBins, selectedTemporalFeatures]);
7535
- const colorGroupedBins = histogramBins.length > 0 && hasSelection && (selectionAsLine || selectedFeatureColors && selectedFeatureColors.size > 0) && globalMinDate && globalMaxDate ? (() => {
7536
+ const colorGroupedBins = react.useMemo(() => {
7537
+ if (histogramBins.length === 0 || !hasSelection || !globalMinDate || !globalMaxDate) return [];
7538
+ if (!selectionAsLine && !(selectedFeatureColors && selectedFeatureColors.size > 0)) return [];
7536
7539
  if (selectedTemporalFeatures.length === 0) return [];
7537
7540
  const colorGroups = /* @__PURE__ */ new Map();
7538
7541
  selectedTemporalFeatures.forEach((f) => {
@@ -7556,7 +7559,11 @@ function Timebar({
7556
7559
  result.push({ color, bins });
7557
7560
  });
7558
7561
  return result;
7559
- })() : [];
7562
+ }, [hasSelection, selectionAsLine, histogramBins, selectedTemporalFeatures, selectedFeatureColors, globalMinDate, globalMaxDate]);
7563
+ const selectedBins = react.useMemo(
7564
+ () => selectionAsLine ? histogramBins.map((_, i) => colorGroupedBins.reduce((sum, group) => sum + group.bins[i], 0)) : void 0,
7565
+ [selectionAsLine, histogramBins, colorGroupedBins]
7566
+ );
7560
7567
  const animationFrameRef = react.useRef(null);
7561
7568
  const lastFrameTimeRef = react.useRef(0);
7562
7569
  const playbackDuration = 1e4;
@@ -7674,7 +7681,8 @@ function Timebar({
7674
7681
  {
7675
7682
  bins: histogramBins,
7676
7683
  maxCount: maxBinCount,
7677
- colorGroupedBins
7684
+ colorGroupedBins,
7685
+ selectedBins
7678
7686
  }
7679
7687
  ),
7680
7688
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -16836,6 +16844,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
16836
16844
  {
16837
16845
  selectedFeatureIds,
16838
16846
  selectedFeatureColors,
16847
+ selectionDisplay: "line",
16839
16848
  timebarExtra
16840
16849
  }
16841
16850
  ),