@underverse-ui/underverse 0.2.99 → 0.2.100

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
@@ -8759,6 +8759,7 @@ function CalendarTimeline({
8759
8759
  rowHeights,
8760
8760
  defaultRowHeights,
8761
8761
  onRowHeightsChange,
8762
+ autoRowHeight,
8762
8763
  enableLayoutResize,
8763
8764
  slotMinWidth,
8764
8765
  dayTimeStepMinutes = 60,
@@ -8811,6 +8812,10 @@ function CalendarTimeline({
8811
8812
  [isControlledEventSheetOpen, onEventSheetOpenChange, setSelectedEventId]
8812
8813
  );
8813
8814
  const sizeConfig = React28.useMemo(() => getSizeConfig(size), [size]);
8815
+ const densityClass = sizeConfig.densityClass;
8816
+ const eventHeight = sizeConfig.eventHeight;
8817
+ const laneGap = sizeConfig.laneGap;
8818
+ const lanePaddingY = sizeConfig.lanePaddingY;
8814
8819
  const canResizeColumn = React28.useMemo(() => {
8815
8820
  const cfg = enableLayoutResize;
8816
8821
  if (!cfg) return false;
@@ -8998,13 +9003,43 @@ function CalendarTimeline({
8998
9003
  setInternalRowHeights(defaultRowHeights);
8999
9004
  }, [defaultRowHeights, isControlledRowHeights]);
9000
9005
  const activeRowHeights = isControlledRowHeights ? rowHeights : internalRowHeights;
9006
+ const autoRowHeightCfg = React28.useMemo(() => {
9007
+ if (!autoRowHeight) return null;
9008
+ return autoRowHeight === true ? {} : autoRowHeight;
9009
+ }, [autoRowHeight]);
9010
+ const effectiveMaxLanesPerRow = React28.useMemo(() => {
9011
+ if (!autoRowHeightCfg) return maxLanesPerRow;
9012
+ const maxLanes = autoRowHeightCfg.maxLanesPerRow;
9013
+ if (typeof maxLanes === "number" && Number.isFinite(maxLanes) && maxLanes > 0) return Math.floor(maxLanes);
9014
+ return Number.POSITIVE_INFINITY;
9015
+ }, [autoRowHeightCfg, maxLanesPerRow]);
9016
+ const autoRowHeightsByResource = React28.useMemo(() => {
9017
+ if (!autoRowHeightCfg) return null;
9018
+ const maxRowHeight2 = autoRowHeightCfg.maxRowHeight;
9019
+ const out = /* @__PURE__ */ new Map();
9020
+ for (const [resourceId, list] of eventsByResource.entries()) {
9021
+ const mapped = list.map((ev) => {
9022
+ const startIdx = binarySearchLastLE(slotStarts, ev._start);
9023
+ const endIdx = clamp3(binarySearchFirstGE(slotStarts, ev._end), startIdx + 1, slots.length);
9024
+ return { startIdx, endIdx };
9025
+ });
9026
+ const { laneCount } = intervalPack(mapped);
9027
+ const lanesToFit = Number.isFinite(effectiveMaxLanesPerRow) ? Math.max(1, Math.min(laneCount, effectiveMaxLanesPerRow)) : Math.max(1, laneCount);
9028
+ const needed = lanePaddingY * 2 + lanesToFit * eventHeight + laneGap * Math.max(0, lanesToFit - 1);
9029
+ const next = typeof maxRowHeight2 === "number" && Number.isFinite(maxRowHeight2) && maxRowHeight2 > 0 ? Math.min(needed, maxRowHeight2) : needed;
9030
+ out.set(resourceId, next);
9031
+ }
9032
+ return out;
9033
+ }, [autoRowHeightCfg, eventHeight, eventsByResource, laneGap, lanePaddingY, slotStarts, slots.length, effectiveMaxLanesPerRow]);
9001
9034
  const getResourceRowHeight = React28.useCallback(
9002
9035
  (resourceId) => {
9003
9036
  const h = activeRowHeights[resourceId];
9004
- if (typeof h === "number" && Number.isFinite(h) && h > 0) return h;
9005
- return effectiveRowHeight;
9037
+ const base = typeof h === "number" && Number.isFinite(h) && h > 0 ? h : effectiveRowHeight;
9038
+ const auto = autoRowHeightsByResource?.get(resourceId);
9039
+ if (typeof auto === "number" && Number.isFinite(auto) && auto > 0) return Math.max(base, auto);
9040
+ return base;
9006
9041
  },
9007
- [activeRowHeights, effectiveRowHeight]
9042
+ [activeRowHeights, autoRowHeightsByResource, effectiveRowHeight]
9008
9043
  );
9009
9044
  const setRowHeightForResource = React28.useCallback(
9010
9045
  (resourceId, height) => {
@@ -9137,10 +9172,6 @@ function CalendarTimeline({
9137
9172
  const fmt = getDtf(resolvedLocale, resolvedTimeZone, { weekday: "long", year: "numeric", month: "long", day: "numeric" });
9138
9173
  return fmt.format(range.start);
9139
9174
  }, [activeDate, activeView, formatters, l.week, range.end, range.start, resolvedLocale, resolvedTimeZone]);
9140
- const densityClass = sizeConfig.densityClass;
9141
- const eventHeight = sizeConfig.eventHeight;
9142
- const laneGap = sizeConfig.laneGap;
9143
- const lanePaddingY = sizeConfig.lanePaddingY;
9144
9175
  const createMode = interactions?.createMode ?? "drag";
9145
9176
  const canCreate = !isViewOnly && (interactions?.creatable ?? false) && !!onCreateEvent;
9146
9177
  const [createOpen, setCreateOpen] = React28.useState(false);
@@ -9525,10 +9556,10 @@ function CalendarTimeline({
9525
9556
  return { ev: { ...ev, _start: s, _end: e }, startIdx, endIdx };
9526
9557
  });
9527
9558
  const { packed, laneCount } = intervalPack(mapped);
9528
- const visible = packed.filter((p) => p.lane < maxLanesPerRow);
9529
- const hidden = packed.filter((p) => p.lane >= maxLanesPerRow);
9559
+ const visible = packed.filter((p) => p.lane < effectiveMaxLanesPerRow);
9560
+ const hidden = packed.filter((p) => p.lane >= effectiveMaxLanesPerRow);
9530
9561
  const rowHeightPx = getResourceRowHeight(resourceId);
9531
- const visibleLaneCount = Math.max(1, Math.min(laneCount, maxLanesPerRow));
9562
+ const visibleLaneCount = Math.max(1, Math.min(laneCount, effectiveMaxLanesPerRow));
9532
9563
  const available = Math.max(0, rowHeightPx - lanePaddingY * 2 - laneGap * Math.max(0, visibleLaneCount - 1));
9533
9564
  const fitPerLane = visibleLaneCount > 0 ? Math.floor(available / visibleLaneCount) : eventHeight;
9534
9565
  const perLaneHeight = Math.max(9, Math.min(eventHeight, fitPerLane || eventHeight));
@@ -9546,7 +9577,7 @@ function CalendarTimeline({
9546
9577
  });
9547
9578
  }
9548
9579
  return map;
9549
- }, [eventsByResource, getResourceRowHeight, laneGap, lanePaddingY, slotStarts, slots.length, slotWidth, maxLanesPerRow, preview, eventHeight]);
9580
+ }, [eventsByResource, getResourceRowHeight, laneGap, lanePaddingY, slotStarts, slots.length, slotWidth, effectiveMaxLanesPerRow, preview, eventHeight]);
9550
9581
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
9551
9582
  "div",
9552
9583
  {