@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.mjs CHANGED
@@ -7382,7 +7382,7 @@ function formatDateTime(date) {
7382
7382
  minute: "2-digit"
7383
7383
  });
7384
7384
  }
7385
- function Histogram({ bins, maxCount, colorGroupedBins }) {
7385
+ function Histogram({ bins, maxCount, colorGroupedBins, selectedBins }) {
7386
7386
  const [hoveredBin, setHoveredBin] = useState(null);
7387
7387
  const containerRef = useRef(null);
7388
7388
  if (bins.length === 0 || maxCount === 0) return null;
@@ -7441,7 +7441,8 @@ function Histogram({ bins, maxCount, colorGroupedBins }) {
7441
7441
  /* @__PURE__ */ jsxs("div", { className: "text-muted-foreground", children: [
7442
7442
  bins[hoveredBin].count,
7443
7443
  " event",
7444
- bins[hoveredBin].count !== 1 ? "s" : ""
7444
+ bins[hoveredBin].count !== 1 ? "s" : "",
7445
+ !!(selectedBins == null ? void 0 : selectedBins[hoveredBin]) && ` (${selectedBins[hoveredBin]} selected)`
7445
7446
  ] })
7446
7447
  ]
7447
7448
  }
@@ -7512,7 +7513,9 @@ function Timebar({
7512
7513
  return { ...bin, count };
7513
7514
  });
7514
7515
  }, [hasSelection, selectionAsLine, storeHistogramBins, selectedTemporalFeatures]);
7515
- const colorGroupedBins = histogramBins.length > 0 && hasSelection && (selectionAsLine || selectedFeatureColors && selectedFeatureColors.size > 0) && globalMinDate && globalMaxDate ? (() => {
7516
+ const colorGroupedBins = useMemo(() => {
7517
+ if (histogramBins.length === 0 || !hasSelection || !globalMinDate || !globalMaxDate) return [];
7518
+ if (!selectionAsLine && !(selectedFeatureColors && selectedFeatureColors.size > 0)) return [];
7516
7519
  if (selectedTemporalFeatures.length === 0) return [];
7517
7520
  const colorGroups = /* @__PURE__ */ new Map();
7518
7521
  selectedTemporalFeatures.forEach((f) => {
@@ -7536,7 +7539,11 @@ function Timebar({
7536
7539
  result.push({ color, bins });
7537
7540
  });
7538
7541
  return result;
7539
- })() : [];
7542
+ }, [hasSelection, selectionAsLine, histogramBins, selectedTemporalFeatures, selectedFeatureColors, globalMinDate, globalMaxDate]);
7543
+ const selectedBins = useMemo(
7544
+ () => selectionAsLine ? histogramBins.map((_, i) => colorGroupedBins.reduce((sum, group) => sum + group.bins[i], 0)) : void 0,
7545
+ [selectionAsLine, histogramBins, colorGroupedBins]
7546
+ );
7540
7547
  const animationFrameRef = useRef(null);
7541
7548
  const lastFrameTimeRef = useRef(0);
7542
7549
  const playbackDuration = 1e4;
@@ -7654,7 +7661,8 @@ function Timebar({
7654
7661
  {
7655
7662
  bins: histogramBins,
7656
7663
  maxCount: maxBinCount,
7657
- colorGroupedBins
7664
+ colorGroupedBins,
7665
+ selectedBins
7658
7666
  }
7659
7667
  ),
7660
7668
  /* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
@@ -16816,6 +16824,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
16816
16824
  {
16817
16825
  selectedFeatureIds,
16818
16826
  selectedFeatureColors,
16827
+ selectionDisplay: "line",
16819
16828
  timebarExtra
16820
16829
  }
16821
16830
  ),