@underverse-ui/underverse 1.0.11 → 1.0.12

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.d.cts CHANGED
@@ -1192,7 +1192,13 @@ interface CalendarTimelineProps<TResourceMeta = unknown, TEventMeta = unknown> e
1192
1192
  * When set, `view`/`defaultView` are ignored.
1193
1193
  */
1194
1194
  onlyView?: CalendarTimelineView;
1195
- view?: CalendarTimelineView;
1195
+ /**
1196
+ * Active view (controlled) or allowed views list.
1197
+ * - string: controls the current view
1198
+ * - array: restricts which views are shown; the active view falls back to
1199
+ * `defaultView` (if included) or the first entry.
1200
+ */
1201
+ view?: CalendarTimelineView | CalendarTimelineView[];
1196
1202
  defaultView?: CalendarTimelineView;
1197
1203
  onViewChange?: (view: CalendarTimelineView) => void;
1198
1204
  /**
package/dist/index.d.ts CHANGED
@@ -1192,7 +1192,13 @@ interface CalendarTimelineProps<TResourceMeta = unknown, TEventMeta = unknown> e
1192
1192
  * When set, `view`/`defaultView` are ignored.
1193
1193
  */
1194
1194
  onlyView?: CalendarTimelineView;
1195
- view?: CalendarTimelineView;
1195
+ /**
1196
+ * Active view (controlled) or allowed views list.
1197
+ * - string: controls the current view
1198
+ * - array: restricts which views are shown; the active view falls back to
1199
+ * `defaultView` (if included) or the first entry.
1200
+ */
1201
+ view?: CalendarTimelineView | CalendarTimelineView[];
1196
1202
  defaultView?: CalendarTimelineView;
1197
1203
  onViewChange?: (view: CalendarTimelineView) => void;
1198
1204
  /**
package/dist/index.js CHANGED
@@ -10770,13 +10770,28 @@ function CalendarTimeline({
10770
10770
  const colMax = maxResourceColumnWidth ?? 520;
10771
10771
  const rowMin = minRowHeight ?? 36;
10772
10772
  const rowMax = maxRowHeight ?? 120;
10773
- const availableViews = React33.useMemo(
10774
- () => onlyView ? [onlyView] : ["month", "week", "day", "sprint"],
10775
- [onlyView]
10776
- );
10777
- const isControlledView = view !== void 0;
10778
- const [internalView, setInternalView] = React33.useState(() => onlyView ?? defaultView);
10773
+ const viewList = React33.useMemo(() => Array.isArray(view) ? view : void 0, [view]);
10774
+ const availableViews = React33.useMemo(() => {
10775
+ if (onlyView) return [onlyView];
10776
+ if (viewList?.length) return viewList;
10777
+ return ["month", "week", "day", "sprint"];
10778
+ }, [onlyView, viewList]);
10779
+ const isControlledView = view !== void 0 && !Array.isArray(view);
10780
+ const [internalView, setInternalView] = React33.useState(() => {
10781
+ if (onlyView) return onlyView;
10782
+ if (viewList?.length) {
10783
+ if (defaultView && viewList.includes(defaultView)) return defaultView;
10784
+ return viewList[0] ?? defaultView ?? "month";
10785
+ }
10786
+ return defaultView ?? "month";
10787
+ });
10779
10788
  const activeView = onlyView ? onlyView : isControlledView ? view : internalView;
10789
+ React33.useEffect(() => {
10790
+ if (onlyView || isControlledView) return;
10791
+ if (!availableViews.includes(internalView)) {
10792
+ setInternalView(availableViews[0] ?? "month");
10793
+ }
10794
+ }, [availableViews, internalView, isControlledView, onlyView]);
10780
10795
  const effectiveSlotMinWidth = React33.useMemo(() => {
10781
10796
  if (slotMinWidth == null) {
10782
10797
  if (activeView === "month" && monthEventStyle === "compact") {
@@ -10818,10 +10833,11 @@ function CalendarTimeline({
10818
10833
  const setView = React33.useCallback(
10819
10834
  (next) => {
10820
10835
  if (onlyView) return;
10836
+ if (!availableViews.includes(next)) return;
10821
10837
  if (!isControlledView) setInternalView(next);
10822
10838
  onViewChange?.(next);
10823
10839
  },
10824
- [isControlledView, onViewChange, onlyView]
10840
+ [availableViews, isControlledView, onViewChange, onlyView]
10825
10841
  );
10826
10842
  const setDate = React33.useCallback(
10827
10843
  (next) => {