@tensor_1/react 2.62.0 → 2.64.0

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.
Files changed (44) hide show
  1. package/README.md +30 -1
  2. package/component-inventory.json +16 -0
  3. package/dist/{SchedulingCalendar-WWyFL3Eo.d.ts → SchedulingCalendar-CHOIb5cT.d.ts} +10 -2
  4. package/dist/components/Card.d.ts +1 -1
  5. package/dist/components/Card.js +2 -2
  6. package/dist/components/DataWorkspace.d.ts +8 -0
  7. package/dist/components/DataWorkspace.js +13 -4
  8. package/dist/components/DateTime.d.ts +33 -0
  9. package/dist/components/DateTime.js +53 -0
  10. package/dist/components/EditorialHome.d.ts +24 -7
  11. package/dist/components/EditorialHome.js +13 -9
  12. package/dist/components/Field.d.ts +18 -3
  13. package/dist/components/Field.js +6 -6
  14. package/dist/components/InfoTip.d.ts +9 -3
  15. package/dist/components/InfoTip.js +6 -2
  16. package/dist/components/Markdown.d.ts +12 -2
  17. package/dist/components/Markdown.js +3 -2
  18. package/dist/components/NumberInput.d.ts +28 -0
  19. package/dist/components/NumberInput.js +27 -0
  20. package/dist/components/OverflowRow.d.ts +34 -0
  21. package/dist/components/OverflowRow.js +77 -0
  22. package/dist/components/PageHeader.d.ts +1 -1
  23. package/dist/components/PageHeader.js +2 -2
  24. package/dist/components/RelativeTime.d.ts +5 -2
  25. package/dist/components/RelativeTime.js +4 -2
  26. package/dist/components/SchedulingAgenda.d.ts +1 -1
  27. package/dist/components/SchedulingCalendar.d.ts +1 -1
  28. package/dist/components/SchedulingCalendar.js +2 -0
  29. package/dist/components/SchedulingTimeGrid.d.ts +1 -1
  30. package/dist/components/SchedulingTimeGrid.js +164 -105
  31. package/dist/components/SchedulingTimeline.d.ts +1 -1
  32. package/dist/components/Timeline.d.ts +14 -2
  33. package/dist/components/Timeline.js +6 -1
  34. package/dist/index.cjs +3635 -3395
  35. package/dist/index.d.cts +180 -20
  36. package/dist/index.d.ts +4 -1
  37. package/dist/index.js +8 -0
  38. package/dist/info-tip-model.d.ts +12 -1
  39. package/dist/info-tip-model.js +10 -2
  40. package/dist/labels-context.d.ts +11 -1
  41. package/dist/markdown.cjs +3 -2
  42. package/dist/markdown.d.cts +12 -2
  43. package/dist/rich-text.cjs +3 -2
  44. package/package.json +1 -1
@@ -0,0 +1,28 @@
1
+ import * as react from 'react';
2
+ import { InputProps } from './Input.js';
3
+
4
+ interface NumberInputProps extends Omit<InputProps, 'type' | 'value' | 'defaultValue'> {
5
+ /**
6
+ * The number the field holds. `NaN`, `null` or `undefined` shows an empty field. Passing the prop
7
+ * at all makes the field controlled, so a form value that starts `undefined` and becomes a number
8
+ * never switches it; leave the prop out (or use `defaultValue`) for an uncontrolled field.
9
+ */
10
+ value?: number | null;
11
+ /** The starting number of an uncontrolled field. */
12
+ defaultValue?: number;
13
+ /**
14
+ * Called on every change with the field's `valueAsNumber` (HAR-3100, the rule of TENSOR
15
+ * HAR-1597): a number, or `NaN` when the field is empty or holds no number yet. Never the typed
16
+ * text, which a form library would store as a string (digits vanished as they were typed), and
17
+ * never `0` or `undefined` for an emptied field, which read as "zero" and "use the default".
18
+ */
19
+ onValueChange?: (value: number) => void;
20
+ }
21
+ /**
22
+ * A number field (`<input type="number">`, `inputMode="decimal"` and `step="any"` by default, so a
23
+ * decimal is never a step mismatch) whose value is a number. Feed `onValueChange` back into `value`:
24
+ * what was typed stays in the box, an emptied field is `NaN`, so a required number refuses it.
25
+ */
26
+ declare const NumberInput: react.ForwardRefExoticComponent<NumberInputProps & react.RefAttributes<HTMLInputElement>>;
27
+
28
+ export { NumberInput, type NumberInputProps };
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from "react";
4
+ import { Input } from "./Input.js";
5
+ const NumberInput = forwardRef((allProps, ref) => {
6
+ const { value, onValueChange, onChange, inputMode = "decimal", step = "any", ...props } = allProps;
7
+ const controlled = Object.prototype.hasOwnProperty.call(allProps, "value");
8
+ return /* @__PURE__ */ jsx(
9
+ Input,
10
+ {
11
+ ref,
12
+ inputMode,
13
+ step,
14
+ ...props,
15
+ ...controlled ? { value: value == null || Number.isNaN(value) ? "" : value } : {},
16
+ onChange: (event) => {
17
+ onChange?.(event);
18
+ onValueChange?.(event.currentTarget.valueAsNumber);
19
+ },
20
+ type: "number"
21
+ }
22
+ );
23
+ });
24
+ NumberInput.displayName = "NumberInput";
25
+ export {
26
+ NumberInput
27
+ };
@@ -0,0 +1,34 @@
1
+ import * as react from 'react';
2
+ import { HTMLAttributes, ReactNode } from 'react';
3
+
4
+ interface OverflowRowProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
5
+ /** The items, in order: each child is one item (a pill, a chip, a short label). */
6
+ children?: ReactNode;
7
+ /** The counter's text; `{count}` is the number of hidden items. Default "+{count}". */
8
+ more?: string;
9
+ /**
10
+ * What a screen reader hears for the counter. `{count}` is the number of hidden items and
11
+ * `{items}` their text, comma-separated. Default "{count} more: {items}". The counter's
12
+ * `title` lists the same items for a pointer.
13
+ */
14
+ moreLabel?: string;
15
+ }
16
+ /**
17
+ * How many items an `OverflowRow` shows (pure, so it can be tested without layout): all of
18
+ * them when they fit side by side, otherwise the most that fit whole together with the counter
19
+ * for the rest, and never fewer than one. `counterWidth(hidden)` is the counter's width when it
20
+ * stands for `hidden` items.
21
+ */
22
+ declare function overflowRowFit(widths: readonly number[], available: number, gap: number, counterWidth: (hidden: number) => number): number;
23
+ /**
24
+ * One line of items that never wraps (HAR-3072): it shows, in order, the items that fit whole
25
+ * and replaces the rest with one counter ("+3"), so a table row keeps one height and no badge is
26
+ * cut mid-word. The first item always shows; when it alone is wider than the row it is clipped at
27
+ * the row's edge (give it its own truncating text for an ellipsis). Re-measures when it is
28
+ * resized and on every render; before it can measure (server render, no ResizeObserver) every
29
+ * item shows and the row clips. The hidden items stay in the DOM for measuring but out of the
30
+ * layout and the accessibility tree; the counter's label names them, so each is heard once.
31
+ */
32
+ declare function OverflowRow({ children, more, moreLabel, className, ...props }: OverflowRowProps): react.JSX.Element;
33
+
34
+ export { OverflowRow, type OverflowRowProps, overflowRowFit };
@@ -0,0 +1,77 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { Children, isValidElement, useEffect, useLayoutEffect, useRef, useState } from "react";
4
+ import { cx } from "../cx.js";
5
+ function overflowRowFit(widths, available, gap, counterWidth) {
6
+ const n = widths.length;
7
+ if (n === 0) return 0;
8
+ const total = widths.reduce((sum, w, i) => sum + w + (i > 0 ? gap : 0), 0);
9
+ if (total <= available) return n;
10
+ let best = 1;
11
+ let used = 0;
12
+ for (let k = 1; k < n; k += 1) {
13
+ used += (widths[k - 1] ?? 0) + (k > 1 ? gap : 0);
14
+ if (used + gap + counterWidth(n - k) <= available) best = k;
15
+ }
16
+ return best;
17
+ }
18
+ const fill = (template, count, items) => template.replace("{count}", String(count)).replace("{items}", items);
19
+ function OverflowRow({
20
+ children,
21
+ more = "+{count}",
22
+ moreLabel = "{count} more: {items}",
23
+ className,
24
+ ...props
25
+ }) {
26
+ const items = Children.toArray(children);
27
+ const ref = useRef(null);
28
+ const [shown, setShown] = useState(items.length);
29
+ const [hidden, setHidden] = useState([]);
30
+ const measure = useRef(() => void 0);
31
+ measure.current = () => {
32
+ const row = ref.current;
33
+ if (!row) return;
34
+ const nodes = Array.from(row.children).filter((el) => el.classList.contains("uix-overflow-row__item"));
35
+ const probe = row.querySelector(".uix-overflow-row__probe");
36
+ const widths = nodes.map((el) => Math.max(el.scrollWidth, el.getBoundingClientRect().width));
37
+ const gap = Number.parseFloat(getComputedStyle(row).columnGap) || 0;
38
+ const counter = probe ? probe.getBoundingClientRect().width : 0;
39
+ const next = overflowRowFit(widths, row.clientWidth, gap, () => counter);
40
+ const text = nodes.slice(next).map((el) => (el.textContent ?? "").trim()).filter(Boolean);
41
+ setShown((current) => current === next ? current : next);
42
+ setHidden((current) => current.join("\0") === text.join("\0") ? current : text);
43
+ };
44
+ useLayoutEffect(() => {
45
+ if (typeof ResizeObserver !== "undefined") measure.current();
46
+ });
47
+ useEffect(() => {
48
+ const row = ref.current;
49
+ if (!row || typeof ResizeObserver === "undefined") return void 0;
50
+ const observer = new ResizeObserver(() => measure.current());
51
+ observer.observe(row);
52
+ return () => observer.disconnect();
53
+ }, []);
54
+ const visible = Math.min(shown, items.length);
55
+ const hiddenCount = items.length - visible;
56
+ const names = hidden.join(", ");
57
+ return /* @__PURE__ */ jsxs("div", { ref, className: cx("uix-overflow-row", className), ...props, children: [
58
+ items.map((child, i) => /* @__PURE__ */ jsx(
59
+ "span",
60
+ {
61
+ className: "uix-overflow-row__item",
62
+ ...i >= visible ? { "data-overflow-hidden": "", "aria-hidden": true } : {},
63
+ children: child
64
+ },
65
+ isValidElement(child) && child.key != null ? child.key : i
66
+ )),
67
+ hiddenCount > 0 && /* @__PURE__ */ jsxs("span", { className: "uix-overflow-row__more", title: names || void 0, children: [
68
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: fill(more, hiddenCount, names) }),
69
+ /* @__PURE__ */ jsx("span", { className: "uix-visually-hidden", children: fill(moreLabel, hiddenCount, names) })
70
+ ] }),
71
+ /* @__PURE__ */ jsx("span", { className: "uix-overflow-row__probe", "aria-hidden": "true", children: fill(more, items.length, "") })
72
+ ] });
73
+ }
74
+ export {
75
+ OverflowRow,
76
+ overflowRowFit
77
+ };
@@ -13,7 +13,7 @@ interface PageHeaderProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {
13
13
  * empty, whitespace-only or `null` renders no button.
14
14
  */
15
15
  help?: string | null;
16
- /** Accessible name of the ? button. Default `"About: <title>"` when title is text; pass a localised one. */
16
+ /** Accessible name of the ? button. Default: the `UixLabelsProvider` `infoTip` template with the title (`"About: <title>"` without a provider). */
17
17
  helpLabel?: string;
18
18
  /** Right-aligned action area (buttons, menus). */
19
19
  actions?: ReactNode;
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { cx } from "../cx.js";
3
3
  import { InfoTip } from "./InfoTip.js";
4
- import { hasHelp, helpLabelFor } from "../info-tip-model.js";
4
+ import { hasHelp, helpTopic } from "../info-tip-model.js";
5
5
  function PageHeader({ eyebrow, title, subtitle, help, helpLabel, actions, as: TitleTag = "h1", size = "default", className, ...props }) {
6
6
  const heading = /* @__PURE__ */ jsx(TitleTag, { className: "uix-page-header__title", children: title });
7
7
  return /* @__PURE__ */ jsxs("header", { className: cx("uix-page-header", size === "display" && "uix-page-header--display", className), ...props, children: [
@@ -9,7 +9,7 @@ function PageHeader({ eyebrow, title, subtitle, help, helpLabel, actions, as: Ti
9
9
  eyebrow != null && /* @__PURE__ */ jsx("div", { className: "uix-page-header__eyebrow", children: eyebrow }),
10
10
  hasHelp(help) ? /* @__PURE__ */ jsxs("div", { className: "uix-page-header__title-row", children: [
11
11
  heading,
12
- /* @__PURE__ */ jsx(InfoTip, { content: help, label: helpLabel ?? helpLabelFor(title) })
12
+ /* @__PURE__ */ jsx(InfoTip, { content: help, label: helpLabel, topic: helpTopic(title) })
13
13
  ] }) : heading,
14
14
  subtitle != null && /* @__PURE__ */ jsx("p", { className: "uix-page-header__subtitle", children: subtitle })
15
15
  ] }),
@@ -17,7 +17,10 @@ interface RelativeTimeProps extends Omit<HTMLAttributes<HTMLTimeElement>, 'child
17
17
  refreshInterval?: number | false;
18
18
  formatter?: (context: RelativeTimeFormatContext) => ReactNode;
19
19
  }
20
- /** Locale-aware relative time with deterministic `now` support for SSR and tests. */
21
- declare function RelativeTime({ value, now, locale, timeZone, numeric, invalidLabel, refreshInterval, formatter, title, ...props }: RelativeTimeProps): react.JSX.Element;
20
+ /**
21
+ * Locale-aware relative time with deterministic `now` support for SSR and tests. It carries `.uix-time`
22
+ * (HAR-3094): it never breaks inside itself ("vor 3 Minuten" is one unit) and its digits are tabular.
23
+ */
24
+ declare function RelativeTime({ value, now, locale, timeZone, numeric, invalidLabel, refreshInterval, formatter, title, className, ...props }: RelativeTimeProps): react.JSX.Element;
22
25
 
23
26
  export { RelativeTime, type RelativeTimeFormatContext, type RelativeTimeProps };
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { useCallback, useMemo, useSyncExternalStore } from "react";
4
+ import { cx } from "../cx.js";
4
5
  import { parseDateValue, relativeTimeValue } from "../relative-time-model.js";
5
6
  import { readRelativeClock, subscribeRelativeClock } from "../relative-time-clock.js";
6
7
  function RelativeTime({
@@ -13,6 +14,7 @@ function RelativeTime({
13
14
  refreshInterval = 3e4,
14
15
  formatter,
15
16
  title,
17
+ className,
16
18
  ...props
17
19
  }) {
18
20
  const interval = refreshInterval === false ? 0 : Math.max(0, refreshInterval);
@@ -23,7 +25,7 @@ function RelativeTime({
23
25
  const getServerSnapshot = useCallback(() => fixedNow ?? Date.now(), [fixedNow]);
24
26
  const clock = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
25
27
  const date = useMemo(() => parseDateValue(value), [value]);
26
- if (!date) return /* @__PURE__ */ jsx("time", { "data-invalid": "true", suppressHydrationWarning: true, ...props, children: invalidLabel });
28
+ if (!date) return /* @__PURE__ */ jsx("time", { className: cx("uix-time", className), "data-invalid": "true", suppressHydrationWarning: true, ...props, children: invalidLabel });
27
29
  const current = new Date(clock);
28
30
  const content = formatter ? formatter({ date, now: current, locale, timeZone }) : (() => {
29
31
  const relative = relativeTimeValue(date, current);
@@ -33,7 +35,7 @@ function RelativeTime({
33
35
  return new Intl.RelativeTimeFormat(locale, { numeric }).format(relative.value, relative.unit);
34
36
  })();
35
37
  const absolute = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short", timeZone }).format(date);
36
- return /* @__PURE__ */ jsx("time", { dateTime: date.toISOString(), title: title ?? absolute, suppressHydrationWarning: true, ...props, children: content });
38
+ return /* @__PURE__ */ jsx("time", { className: cx("uix-time", className), dateTime: date.toISOString(), title: title ?? absolute, suppressHydrationWarning: true, ...props, children: content });
37
39
  }
38
40
  export {
39
41
  RelativeTime
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { S as SchedulingAgendaGroup, e as SchedulingCalendarLabels, i as SchedulingDatePart, d as SchedulingCalendarEntry, l as SchedulingMarker, f as SchedulingCalendarOverlay } from '../SchedulingCalendar-WWyFL3Eo.js';
3
+ import { S as SchedulingAgendaGroup, e as SchedulingCalendarLabels, i as SchedulingDatePart, d as SchedulingCalendarEntry, l as SchedulingMarker, f as SchedulingCalendarOverlay } from '../SchedulingCalendar-CHOIb5cT.js';
4
4
  import '../calendar-model.js';
5
5
  import '../scheduling-calendar-model.js';
6
6
  import './SchedulingResourceDay.js';
@@ -3,4 +3,4 @@ import '../calendar-model.js';
3
3
  import '../scheduling-calendar-model.js';
4
4
  import './SchedulingResourceDay.js';
5
5
  import '../scheduling-resource-model.js';
6
- export { D as DEFAULT_SCHEDULING_CALENDAR_LABELS, S as SchedulingAgendaGroup, a as SchedulingBand, b as SchedulingCalendar, c as SchedulingCalendarDay, d as SchedulingCalendarEntry, e as SchedulingCalendarLabels, f as SchedulingCalendarOverlay, g as SchedulingCalendarProps, h as SchedulingCalendarView, i as SchedulingDatePart, j as SchedulingEntryState, k as SchedulingLegendItem, l as SchedulingMarker, m as SchedulingMarkerEmphasis, n as SchedulingOverlayKind, o as SchedulingOverlayPattern, p as SchedulingStatus } from '../SchedulingCalendar-WWyFL3Eo.js';
6
+ export { D as DEFAULT_SCHEDULING_CALENDAR_LABELS, S as SchedulingAgendaGroup, a as SchedulingBand, b as SchedulingCalendar, c as SchedulingCalendarDay, d as SchedulingCalendarEntry, e as SchedulingCalendarLabels, f as SchedulingCalendarOverlay, g as SchedulingCalendarProps, h as SchedulingCalendarView, i as SchedulingDatePart, j as SchedulingEntryState, k as SchedulingLegendItem, l as SchedulingMarker, m as SchedulingMarkerEmphasis, n as SchedulingOverlayKind, o as SchedulingOverlayPattern, p as SchedulingStatus } from '../SchedulingCalendar-CHOIb5cT.js';
@@ -134,6 +134,7 @@ function SchedulingCalendar({
134
134
  topLaneCrossMidnightMinutes = TOP_LANE_CROSS_MIDNIGHT_MINUTES,
135
135
  topLaneCap = 3,
136
136
  maxLanes = 4,
137
+ scrollToTime,
137
138
  resources,
138
139
  resourceSpans = EMPTY_SPANS,
139
140
  slotMinutes,
@@ -556,6 +557,7 @@ function SchedulingCalendar({
556
557
  topLaneCap,
557
558
  windowLaneCap: windowLaneCap ?? DEFAULT_LANE_CAP,
558
559
  maxLanes,
560
+ scrollToTime,
559
561
  emptyNote,
560
562
  nothingToShow
561
563
  }
@@ -1,6 +1,6 @@
1
1
  import 'react';
2
2
  import '../scheduling-calendar-model.js';
3
- export { q as SchedulingTimeGrid, r as SchedulingTimeGridProps, T as TimeGridEntryContext } from '../SchedulingCalendar-WWyFL3Eo.js';
3
+ export { q as SchedulingTimeGrid, r as SchedulingTimeGridProps, T as TimeGridEntryContext } from '../SchedulingCalendar-CHOIb5cT.js';
4
4
  import '../calendar-model.js';
5
5
  import './SchedulingResourceDay.js';
6
6
  import '../scheduling-resource-model.js';
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { memo, useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
3
+ import { memo, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
4
4
  import { zonedDateKey, zonedHourSlots, zonedTimeOfDay } from "../calendar-model.js";
5
5
  import { layoutDaySpans, layoutTimeGridDay, placesInTopLane, proposeMove } from "../scheduling-calendar-model.js";
6
6
  import { fillLabel } from "../fill-label.js";
@@ -9,6 +9,12 @@ const MINUTES_PER_HOUR = 60;
9
9
  const LINES_PER_HOUR = 3;
10
10
  const DRAG_THRESHOLD = 4;
11
11
  const DEFAULT_STEP = 15;
12
+ const DEFAULT_OPEN_HOUR = 8;
13
+ const useIsomorphicLayoutEffect = typeof document !== "undefined" ? useLayoutEffect : useEffect;
14
+ const hoursOf = (time) => {
15
+ const match = time === void 0 ? null : /^([01]\d|2[0-3]):([0-5]\d)$/.exec(time);
16
+ return match ? Number(match[1]) + Number(match[2]) / MINUTES_PER_HOUR : null;
17
+ };
12
18
  const vars = (values) => values;
13
19
  const linesFor = (segment) => Math.max(0, Math.floor(segment.lengthHours * LINES_PER_HOUR - 0.25));
14
20
  const slotSignature = (slots) => slots.map((slot) => `${slot.label}${slot.offsetLabel ?? ""}`).join(" ");
@@ -98,6 +104,7 @@ function SchedulingTimeGrid({
98
104
  topLaneCap,
99
105
  windowLaneCap,
100
106
  maxLanes,
107
+ scrollToTime,
101
108
  emptyNote,
102
109
  nothingToShow
103
110
  }) {
@@ -142,6 +149,10 @@ function SchedulingTimeGrid({
142
149
  const entryById = useMemo(() => new Map(entries.map((entry) => [entry.id, entry])), [entries]);
143
150
  const overlayById = useMemo(() => new Map(overlays.map((overlay) => [overlay.id, overlay])), [overlays]);
144
151
  const columns = useMemo(() => days.map((date) => layoutTimeGridDay(entries, date, timeZone, { ...laneOptions, maxLanes: lanes })), [days, entries, timeZone, laneOptions, lanes]);
152
+ const hiddenByWidth = useMemo(() => {
153
+ if (lanes >= maxLanes) return days.map(() => 0);
154
+ return days.map((date, index) => Math.max(0, columns[index].hidden.length - layoutTimeGridDay(entries, date, timeZone, { ...laneOptions, maxLanes }).hidden.length));
155
+ }, [days, entries, timeZone, laneOptions, lanes, maxLanes, columns]);
145
156
  const slots = useMemo(() => days.map((date) => zonedHourSlots(date, timeZone)), [days, timeZone]);
146
157
  const top = useMemo(() => layoutDaySpans(entries.filter((entry) => placesInTopLane(entry, timeZone, laneOptions)), days, { timeZone, laneCap: Math.max(0, topLaneCap) }), [entries, days, timeZone, laneOptions, topLaneCap]);
147
158
  const drawable = useMemo(() => overlays.filter((overlay) => new Date(overlay.end).getTime() >= new Date(overlay.start).getTime()), [overlays]);
@@ -416,6 +427,49 @@ function SchedulingTimeGrid({
416
427
  };
417
428
  const nowAt = now === void 0 ? null : new Date(now).getTime();
418
429
  const nowColumn = nowAt === null || Number.isNaN(nowAt) ? -1 : days.indexOf(zonedDateKey(new Date(nowAt), timeZone));
430
+ const openHour = useMemo(() => {
431
+ const given = hoursOf(scrollToTime);
432
+ if (given !== null) return Math.floor(given);
433
+ let first = DEFAULT_OPEN_HOUR;
434
+ for (const column of columns) for (const segment of column.segments) if (segment.part !== "continuation") first = Math.min(first, segment.offsetHours);
435
+ return Math.max(0, Math.floor(first));
436
+ }, [scrollToTime, columns]);
437
+ const scrollKey = `${view}|${days[0]}|${days.length}`;
438
+ const opened = useRef({ key: "", top: null, byUser: false });
439
+ useIsomorphicLayoutEffect(() => {
440
+ const root = rootRef.current;
441
+ if (!root) return;
442
+ const state = opened.current;
443
+ if (state.key !== scrollKey) {
444
+ state.key = scrollKey;
445
+ state.byUser = false;
446
+ }
447
+ if (state.byUser) return;
448
+ const height = root.querySelector("[data-tg-column]")?.getBoundingClientRect().height ?? 0;
449
+ const hours = columns[0]?.dayHours ?? 0;
450
+ if (!(height > 0) || !(hours > 0)) return;
451
+ root.scrollTop = Math.round(openHour * (height / hours));
452
+ state.top = root.scrollTop;
453
+ }, [scrollKey, openHour, columns]);
454
+ useEffect(() => {
455
+ const root = rootRef.current;
456
+ if (!root) return void 0;
457
+ const byUser = () => {
458
+ opened.current.byUser = true;
459
+ };
460
+ const onScroll = () => {
461
+ const { top: top2 } = opened.current;
462
+ if (top2 !== null && Math.abs(root.scrollTop - top2) > 2) byUser();
463
+ };
464
+ root.addEventListener("wheel", byUser, { passive: true });
465
+ root.addEventListener("touchmove", byUser, { passive: true });
466
+ root.addEventListener("scroll", onScroll, { passive: true });
467
+ return () => {
468
+ root.removeEventListener("wheel", byUser);
469
+ root.removeEventListener("touchmove", byUser);
470
+ root.removeEventListener("scroll", onScroll);
471
+ };
472
+ }, []);
419
473
  const topHiddenOn = (date) => top.hidden.filter((id) => {
420
474
  const entry = entryById.get(id);
421
475
  return entry ? layoutDaySpans([entry], [date], { timeZone }).placed.length > 0 : false;
@@ -448,115 +502,120 @@ function SchedulingTimeGrid({
448
502
  }
449
503
  },
450
504
  children: [
451
- /* @__PURE__ */ jsxs("div", { className: "uix-scheduling-calendar__tg-head", children: [
452
- /* @__PURE__ */ jsx("div", { className: "uix-scheduling-calendar__tg-zone", children: fillLabel(labels.timeZone, { timeZone }) }),
453
- days.map((date, index) => {
454
- const info = dayInfo?.[date];
455
- const hiddenIds = dayInfo ? [] : [...columns[index].hidden, ...topHiddenOn(date)];
456
- const more = info ? info.overflowCount : hiddenIds.length;
457
- const moreText = fillLabel(labels.moreSpans, { count: more });
458
- const moreName = fillLabel(labels.moreEntriesLabel, { count: more, date: dateText(date, "day") });
459
- const headName = !info ? dateText(date, "day") : info.label ? fillLabel(labels.dayName, { date: dateText(date, "day"), label: info.label }) : `${dateText(date, "day")}, ${fillLabel(labels.dayCount, { count: info.count })}`;
460
- return /* @__PURE__ */ jsxs("div", { className: "uix-scheduling-calendar__tg-dayhead", role: "group", "aria-label": headName, "data-date": date, children: [
461
- /* @__PURE__ */ jsx(
505
+ /* @__PURE__ */ jsxs("div", { className: "uix-scheduling-calendar__tg-sticky", children: [
506
+ /* @__PURE__ */ jsxs("div", { className: "uix-scheduling-calendar__tg-head", children: [
507
+ /* @__PURE__ */ jsx("div", { className: "uix-scheduling-calendar__tg-zone", children: fillLabel(labels.timeZone, { timeZone }) }),
508
+ days.map((date, index) => {
509
+ const info = dayInfo?.[date];
510
+ const hiddenIds = dayInfo ? [] : [...columns[index].hidden, ...topHiddenOn(date)];
511
+ const more = info ? info.overflowCount + hiddenByWidth[index] : hiddenIds.length;
512
+ const moreText = fillLabel(labels.moreEntries, { count: more });
513
+ const moreName = fillLabel(labels.moreEntriesLabel, { count: more, date: dateText(date, "day") });
514
+ const headName = !info ? dateText(date, "day") : info.label ? fillLabel(labels.dayName, { date: dateText(date, "day"), label: info.label }) : `${dateText(date, "day")}, ${fillLabel(labels.dayCount, { count: info.count })}`;
515
+ return /* @__PURE__ */ jsxs("div", { className: "uix-scheduling-calendar__tg-dayhead", role: "group", "aria-label": headName, "data-date": date, "data-today": index === nowColumn || void 0, children: [
516
+ /* @__PURE__ */ jsx(
517
+ "button",
518
+ {
519
+ type: "button",
520
+ className: "uix-scheduling-calendar__date",
521
+ "data-calendar-date": date,
522
+ tabIndex: tabStop === date ? 0 : -1,
523
+ "aria-label": info?.label ? fillLabel(labels.dayName, { date: dateText(date, "day"), label: info.label }) : dateText(date, "day"),
524
+ onFocus: () => setActiveDay(date),
525
+ onKeyDown: (event) => onHeadKeyDown(event, date),
526
+ onClick: onSelectDate ? () => onSelectDate(date) : void 0,
527
+ children: dateText(date, "column")
528
+ }
529
+ ),
530
+ info && /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__count", "aria-hidden": "true", children: fillLabel(labels.dayCount, { count: info.count }) }),
531
+ info?.markers && info.markers.length > 0 && /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__markers", children: info.markers.map((marker) => /* @__PURE__ */ jsx("span", { children: renderMarker(marker, true) }, marker.id)) }),
532
+ more > 0 && (onShowMore ? /* @__PURE__ */ jsx("button", { type: "button", tabIndex: -1, className: "uix-scheduling-calendar__more", "aria-label": moreName, onClick: () => onShowMore(date, hiddenIds.map((id) => entryById.get(id)).filter(Boolean)), children: moreText }) : /* @__PURE__ */ jsxs("span", { className: "uix-scheduling-calendar__more", children: [
533
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: moreText }),
534
+ /* @__PURE__ */ jsx("span", { className: "uix-visually-hidden", children: moreName })
535
+ ] }))
536
+ ] }, date);
537
+ })
538
+ ] }),
539
+ (windowLanes > 0 || moreWindows > 0) && /* @__PURE__ */ jsxs("div", { className: "uix-scheduling-calendar__tg-strip", role: "group", "aria-label": labels.windows, style: vars({ "--uix-scheduling-calendar-lanes": Math.max(windowLanes, 1) + (moreWindows > 0 ? 1 : 0) }), children: [
540
+ strip.placed.map((placed) => {
541
+ const overlay = overlayById.get(placed.id);
542
+ if (!overlay) return null;
543
+ return /* @__PURE__ */ jsx(
462
544
  "button",
463
545
  {
464
546
  type: "button",
465
- className: "uix-scheduling-calendar__date",
466
- "data-calendar-date": date,
467
- tabIndex: tabStop === date ? 0 : -1,
468
- "aria-label": info?.label ? fillLabel(labels.dayName, { date: dateText(date, "day"), label: info.label }) : dateText(date, "day"),
469
- onFocus: () => setActiveDay(date),
470
- onKeyDown: (event) => onHeadKeyDown(event, date),
471
- onClick: onSelectDate ? () => onSelectDate(date) : void 0,
472
- children: dateText(date, "column")
473
- }
474
- ),
475
- info && /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__count", "aria-hidden": "true", children: info.count }),
476
- info?.markers && info.markers.length > 0 && /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__markers", children: info.markers.map((marker) => /* @__PURE__ */ jsx("span", { children: renderMarker(marker, true) }, marker.id)) }),
477
- more > 0 && (onShowMore ? /* @__PURE__ */ jsx("button", { type: "button", tabIndex: -1, className: "uix-scheduling-calendar__more", "aria-label": moreName, onClick: () => onShowMore(date, hiddenIds.map((id) => entryById.get(id)).filter(Boolean)), children: moreText }) : /* @__PURE__ */ jsxs("span", { className: "uix-scheduling-calendar__more", children: [
478
- /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: moreText }),
479
- /* @__PURE__ */ jsx("span", { className: "uix-visually-hidden", children: moreName })
480
- ] }))
481
- ] }, date);
482
- })
483
- ] }),
484
- (windowLanes > 0 || moreWindows > 0) && /* @__PURE__ */ jsxs("div", { className: "uix-scheduling-calendar__tg-strip", role: "group", "aria-label": labels.windows, style: vars({ "--uix-scheduling-calendar-lanes": Math.max(windowLanes, 1) }), children: [
485
- strip.placed.map((placed) => {
486
- const overlay = overlayById.get(placed.id);
487
- if (!overlay) return null;
488
- return /* @__PURE__ */ jsx(
489
- "button",
490
- {
491
- type: "button",
492
- tabIndex: -1,
493
- className: "uix-scheduling-calendar__window",
494
- "data-overlay-id": overlay.id,
495
- "data-pattern": overlay.pattern ?? "solid",
496
- "data-global": overlay.global || void 0,
497
- "data-kind": overlay.kind,
498
- "data-continues-before": placed.continuesBefore || void 0,
499
- "data-continues-after": placed.continuesAfter || void 0,
500
- style: { gridColumn: gridColumns(placed), ...vars({ "--uix-scheduling-calendar-lane": placed.lane }) },
501
- onClick: () => onSelectOverlay?.(overlay),
502
- "aria-label": overlayName(overlay),
503
- children: /* @__PURE__ */ jsxs("span", { className: "uix-scheduling-calendar__window-text", children: [
504
- overlay.kindLabel && /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__window-kind", children: overlay.kindLabel }),
505
- /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__window-name", children: overlay.label }),
506
- overlay.scopeLabel && /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__window-scope", children: overlay.scopeLabel })
507
- ] })
508
- },
509
- placed.id
510
- );
511
- }),
512
- moreWindows > 0 && (onShowMore ? /* @__PURE__ */ jsx("button", { type: "button", tabIndex: -1, className: "uix-scheduling-calendar__rowmore", "data-more-date": firstHiddenWindowDay, "aria-label": fillLabel(labels.moreWindowsLabel, { count: moreWindows, date: dateText(firstHiddenWindowDay, "day") }), onClick: () => onShowMore(firstHiddenWindowDay, []), children: fillLabel(labels.moreWindows, { count: moreWindows }) }) : /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__rowmore", children: fillLabel(labels.moreWindows, { count: moreWindows }) }))
513
- ] }),
514
- (topLanes > 0 || ghostSpan) && /* @__PURE__ */ jsxs("div", { className: "uix-scheduling-calendar__tg-strip uix-scheduling-calendar__tg-top", role: "group", "aria-label": labels.topLane, style: vars({ "--uix-scheduling-calendar-lanes": Math.max(topLanes, 1) }), children: [
515
- top.placed.map((placed) => {
516
- const entry = entryById.get(placed.id);
517
- if (!entry) return null;
518
- const canDrag = movable(entry);
519
- const markers = entryMarkers(entry);
520
- return /* @__PURE__ */ jsxs(
521
- "button",
522
- {
523
- type: "button",
524
- tabIndex: -1,
525
- className: "uix-scheduling-calendar__entry uix-scheduling-calendar__tg-span",
526
- "data-item-id": entry.id,
527
- "data-highlight": entry.emphasis === "highlight" || void 0,
528
- "data-dim": entry.emphasis === "dim" || void 0,
529
- "data-band": entry.band ?? "none",
530
- "data-status": entryStatus(entry),
531
- "data-state": entry.state,
532
- "data-movable": canDrag || void 0,
533
- "data-continues-before": placed.continuesBefore || void 0,
534
- "data-continues-after": placed.continuesAfter || void 0,
535
- style: { gridColumn: gridColumns(placed), ...vars({ "--uix-scheduling-calendar-lane": placed.lane }) },
536
- "aria-label": entryName(entry),
537
- "aria-describedby": canDrag ? hintId : void 0,
538
- onClick: () => handlers.click(entry),
539
- onKeyDown: canDrag ? (event) => handlers.keyDown(event, entry) : void 0,
540
- onBlur: canDrag ? () => handlers.blur(entry) : void 0,
541
- onPointerDown: canDrag ? (event) => handlers.pointerDown(event, entry, placed.startCol, true) : void 0,
542
- children: [
543
- /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__entry-text", children: renderEntry?.(entry, { availableLines: 1 }) ?? /* @__PURE__ */ jsxs(Fragment, { children: [
544
- !placed.continuesBefore && !entry.allDay && /* @__PURE__ */ jsxs(Fragment, { children: [
545
- /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__time", children: zonedTimeOfDay(entry.start, timeZone) }),
546
- " "
547
- ] }),
548
- /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__title", children: entry.title })
549
- ] }) }),
550
- markers.length > 0 && /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__markers", children: markers.map((marker) => /* @__PURE__ */ jsx("span", { children: renderMarker(marker) }, marker.id)) })
551
- ]
552
- },
553
- placed.id
554
- );
555
- }),
556
- ghostSpan && /* @__PURE__ */ jsx("div", { className: "uix-scheduling-calendar__tg-ghost", "aria-hidden": "true", "data-sent": ghost?.source === "sent" || void 0, style: { gridColumn: gridColumns(ghostSpan), ...vars({ "--uix-scheduling-calendar-lane": ghostLane }) } })
547
+ tabIndex: -1,
548
+ className: "uix-scheduling-calendar__window",
549
+ "data-overlay-id": overlay.id,
550
+ "data-pattern": overlay.pattern ?? "solid",
551
+ "data-global": overlay.global || void 0,
552
+ "data-kind": overlay.kind,
553
+ "data-continues-before": placed.continuesBefore || void 0,
554
+ "data-continues-after": placed.continuesAfter || void 0,
555
+ style: { gridColumn: gridColumns(placed), ...vars({ "--uix-scheduling-calendar-lane": placed.lane }) },
556
+ onClick: () => onSelectOverlay?.(overlay),
557
+ "aria-label": overlayName(overlay),
558
+ children: /* @__PURE__ */ jsxs("span", { className: "uix-scheduling-calendar__window-text", children: [
559
+ overlay.kindLabel && /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__window-kind", children: overlay.kindLabel }),
560
+ /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__window-name", children: overlay.label }),
561
+ overlay.scopeLabel && /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__window-scope", children: overlay.scopeLabel })
562
+ ] })
563
+ },
564
+ placed.id
565
+ );
566
+ }),
567
+ moreWindows > 0 && (onShowMore ? /* @__PURE__ */ jsx("button", { type: "button", tabIndex: -1, className: "uix-scheduling-calendar__rowmore", "data-more-date": firstHiddenWindowDay, style: { gridColumn: days.indexOf(firstHiddenWindowDay) + 2 }, "aria-label": fillLabel(labels.moreWindowsLabel, { count: moreWindows, date: dateText(firstHiddenWindowDay, "day") }), onClick: () => onShowMore(firstHiddenWindowDay, []), children: fillLabel(labels.moreWindows, { count: moreWindows }) }) : /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__rowmore", style: { gridColumn: days.indexOf(firstHiddenWindowDay) + 2 }, children: fillLabel(labels.moreWindows, { count: moreWindows }) }))
568
+ ] }),
569
+ (topLanes > 0 || ghostSpan) && /* @__PURE__ */ jsxs("div", { className: "uix-scheduling-calendar__tg-strip uix-scheduling-calendar__tg-top", role: "group", "aria-label": labels.topLane, style: vars({ "--uix-scheduling-calendar-lanes": Math.max(topLanes, 1) }), children: [
570
+ top.placed.map((placed) => {
571
+ const entry = entryById.get(placed.id);
572
+ if (!entry) return null;
573
+ const canDrag = movable(entry);
574
+ const markers = entryMarkers(entry);
575
+ return /* @__PURE__ */ jsxs(
576
+ "button",
577
+ {
578
+ type: "button",
579
+ tabIndex: -1,
580
+ className: "uix-scheduling-calendar__entry uix-scheduling-calendar__tg-span",
581
+ "data-item-id": entry.id,
582
+ "data-highlight": entry.emphasis === "highlight" || void 0,
583
+ "data-dim": entry.emphasis === "dim" || void 0,
584
+ "data-band": entry.band ?? "none",
585
+ "data-status": entryStatus(entry),
586
+ "data-state": entry.state,
587
+ "data-movable": canDrag || void 0,
588
+ "data-continues-before": placed.continuesBefore || void 0,
589
+ "data-continues-after": placed.continuesAfter || void 0,
590
+ style: { gridColumn: gridColumns(placed), ...vars({ "--uix-scheduling-calendar-lane": placed.lane }) },
591
+ "aria-label": entryName(entry),
592
+ "aria-describedby": canDrag ? hintId : void 0,
593
+ onClick: () => handlers.click(entry),
594
+ onKeyDown: canDrag ? (event) => handlers.keyDown(event, entry) : void 0,
595
+ onBlur: canDrag ? () => handlers.blur(entry) : void 0,
596
+ onPointerDown: canDrag ? (event) => handlers.pointerDown(event, entry, placed.startCol, true) : void 0,
597
+ children: [
598
+ /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__entry-text", children: renderEntry?.(entry, { availableLines: 1 }) ?? /* @__PURE__ */ jsxs(Fragment, { children: [
599
+ !placed.continuesBefore && !entry.allDay && /* @__PURE__ */ jsxs(Fragment, { children: [
600
+ /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__time", children: zonedTimeOfDay(entry.start, timeZone) }),
601
+ " "
602
+ ] }),
603
+ /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__title", children: entry.title })
604
+ ] }) }),
605
+ markers.length > 0 && /* @__PURE__ */ jsx("span", { className: "uix-scheduling-calendar__markers", children: markers.map((marker) => /* @__PURE__ */ jsx("span", { children: renderMarker(marker) }, marker.id)) })
606
+ ]
607
+ },
608
+ placed.id
609
+ );
610
+ }),
611
+ ghostSpan && /* @__PURE__ */ jsx("div", { className: "uix-scheduling-calendar__tg-ghost", "aria-hidden": "true", "data-sent": ghost?.source === "sent" || void 0, style: { gridColumn: gridColumns(ghostSpan), ...vars({ "--uix-scheduling-calendar-lane": ghostLane }) } })
612
+ ] })
557
613
  ] }),
558
614
  /* @__PURE__ */ jsxs("div", { className: "uix-scheduling-calendar__tg-body", children: [
559
- /* @__PURE__ */ jsx("div", { className: "uix-scheduling-calendar__tg-gutter", "aria-hidden": "true", children: hourLabels(gutterIndex, false) }),
615
+ /* @__PURE__ */ jsxs("div", { className: "uix-scheduling-calendar__tg-gutter", "aria-hidden": "true", children: [
616
+ hourLabels(gutterIndex, false),
617
+ nowColumn >= 0 && now !== void 0 && /* @__PURE__ */ jsx("div", { className: "uix-scheduling-calendar__tg-nowtime", style: vars({ "--uix-scheduling-calendar-offset": (nowAt - columns[nowColumn].dayStart) / HOUR_MS }), children: zonedTimeOfDay(now, timeZone) })
618
+ ] }),
560
619
  shades.map((placed) => {
561
620
  const overlay = overlayById.get(placed.id);
562
621
  const first = columns[placed.startCol];