rift-ds 1.34.0 → 1.35.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 (69) hide show
  1. package/README.md +3 -3
  2. package/behaviors/locale.d.ts +9 -0
  3. package/behaviors/locale.js +2 -0
  4. package/bin/templates/blocks/app/dashboard/page.tsx +1 -1
  5. package/bin/templates/blocks/components/blocks/AppShell.module.css +10 -6
  6. package/chat/ChatTabs.js +1 -1
  7. package/chat/ChatWidget.d.ts +2 -2
  8. package/chat/ChatWidget.js +1 -1
  9. package/chat/DemoWelcome.js +2 -2
  10. package/chat/FollowupSuggestions.js +1 -1
  11. package/components/ActionBar/ActionBar.css +78 -0
  12. package/components/ActionBar/ActionBar.d.ts +40 -0
  13. package/components/ActionBar/ActionBar.js +29 -0
  14. package/components/AiButton/AiButton.js +1 -1
  15. package/components/Alert/Alert.css +16 -0
  16. package/components/Alert/Alert.d.ts +2 -2
  17. package/components/Alert/Alert.js +3 -1
  18. package/components/AppSidebar/AppSidebar.css +140 -4
  19. package/components/AppSidebar/AppSidebar.d.ts +12 -0
  20. package/components/AppSidebar/AppSidebar.js +7 -3
  21. package/components/ChatThread/ChatThread.d.ts +5 -1
  22. package/components/ChatThread/ChatThread.js +1 -1
  23. package/components/ContextMenu/ContextMenu.d.ts +5 -1
  24. package/components/ContextMenu/ContextMenu.js +2 -1
  25. package/components/ContributionGraph/ContributionGraph.d.ts +7 -1
  26. package/components/ContributionGraph/ContributionGraph.js +4 -18
  27. package/components/ContributionGraph/weeks.d.ts +8 -0
  28. package/components/ContributionGraph/weeks.js +25 -0
  29. package/components/DataTable/DataTable.js +1 -1
  30. package/components/DocumentChip/DocumentChip.js +1 -1
  31. package/components/EntitySwitcher/EntitySwitcher.css +11 -3
  32. package/components/EntitySwitcher/EntitySwitcher.js +1 -1
  33. package/components/EventCalendar/EventCalendar.css +152 -0
  34. package/components/EventCalendar/EventCalendar.d.ts +50 -4
  35. package/components/EventCalendar/EventCalendar.js +154 -23
  36. package/components/EventCalendar/eventTime.d.ts +31 -0
  37. package/components/EventCalendar/eventTime.js +42 -0
  38. package/components/FileInput/FileInput.d.ts +12 -4
  39. package/components/FileInput/FileInput.js +27 -4
  40. package/components/Input/Input.css +30 -0
  41. package/components/Input/Input.d.ts +8 -0
  42. package/components/Input/Input.js +3 -0
  43. package/components/Popover/Popover.d.ts +5 -1
  44. package/components/Popover/Popover.js +3 -1
  45. package/components/ProgressBar/ProgressBar.d.ts +5 -1
  46. package/components/ProgressBar/ProgressBar.js +1 -1
  47. package/components/PromptSuggestions/PromptSuggestions.d.ts +5 -1
  48. package/components/PromptSuggestions/PromptSuggestions.js +1 -1
  49. package/components/ResourceTimeline/ResourceTimeline.js +2 -2
  50. package/components/SegmentedControl/SegmentedControl.css +120 -3
  51. package/components/SegmentedControl/SegmentedControl.d.ts +9 -0
  52. package/components/SegmentedControl/SegmentedControl.js +11 -1
  53. package/components/ShaderScene/ShaderScene.d.ts +3 -3
  54. package/components/ShaderScene/scenes.d.ts +17 -0
  55. package/components/ShaderScene/scenes.js +175 -1
  56. package/components/Stat/Stat.css +12 -0
  57. package/components/Stat/Stat.d.ts +5 -0
  58. package/components/Stat/Stat.js +9 -3
  59. package/components/TableToolbar/TableToolbar.js +2 -2
  60. package/components/ThemeToggle/ThemeToggle.d.ts +1 -1
  61. package/components/ThreadTabs/ThreadTabs.d.ts +5 -1
  62. package/components/ThreadTabs/ThreadTabs.js +2 -1
  63. package/components/ToggleGroup/ToggleGroup.d.ts +5 -1
  64. package/components/registry.json +21 -4
  65. package/components/registry.json.d.ts +21 -4
  66. package/components/registry.json.js +1 -1
  67. package/index.d.ts +1 -0
  68. package/index.js +2 -0
  69. package/package.json +1 -1
@@ -1,12 +1,14 @@
1
1
  "use client";
2
2
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
3
- import React, { useMemo, useState } from "react";
3
+ import React, { useMemo, useState, useSyncExternalStore } from "react";
4
4
  import { Chip } from "../Chip/Chip.js";
5
5
  import "./EventCalendar.css";
6
6
  import "../../behaviors/visually-hidden.css";
7
7
  import "../../fonts/material-symbols.css";
8
8
  import { useLocale } from "../../behaviors/LocaleProvider.js";
9
- import { weekStartOf, weekdayOffset, rotateWeek, weekdayHeadersIn } from "../../behaviors/locale.js";
9
+ import { weekStartOf, weekdayOffset, plainSpaces, rotateWeek, weekdayHeadersIn } from "../../behaviors/locale.js";
10
+ import { MOTION_DEADLINE_TICK_MS } from "../../tokens/motion.js";
11
+ import { clockMinutes, compareTimes, nowMarkerIndex, minutesOf } from "./eventTime.js";
10
12
  function parseDay(str) {
11
13
  const match = str ? /^(\d{4})-(\d{2})-(\d{2})$/.exec(str) : null;
12
14
  return match ? new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3])) : null;
@@ -39,6 +41,61 @@ const monthLabelIn = (locale) => {
39
41
  const format = new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" });
40
42
  return (month) => format.format(month);
41
43
  };
44
+ const weekLabelIn = (locale) => {
45
+ const format = new Intl.DateTimeFormat(locale, { month: "long", day: "numeric", year: "numeric" });
46
+ return (start, end) => plainSpaces(format.formatRange(start, end));
47
+ };
48
+ const atMinutes = (minutes) => new Date(2e3, 0, 1, Math.floor(minutes / 60), minutes % 60);
49
+ const eventTimesIn = (locale) => {
50
+ const format = new Intl.DateTimeFormat(locale, { hour: "numeric", minute: "2-digit" });
51
+ const clock = (minutes) => plainSpaces(format.format(atMinutes(minutes)));
52
+ return (event) => {
53
+ if (event.time) return { range: event.time, start: event.time, end: null };
54
+ const start = clockMinutes(event.start);
55
+ if (start === null) return null;
56
+ const end = clockMinutes(event.end);
57
+ if (end === null || end <= start) return { range: clock(start), start: clock(start), end: null };
58
+ return {
59
+ range: plainSpaces(format.formatRange(atMinutes(start), atMinutes(end))),
60
+ start: clock(start),
61
+ end: clock(end)
62
+ };
63
+ };
64
+ };
65
+ const sortTimeOf = (event) => clockMinutes(event.start) !== null ? event.start : event.time;
66
+ const subscribeClock = (onChange) => {
67
+ let timer;
68
+ const start = () => {
69
+ window.clearInterval(timer);
70
+ onChange();
71
+ timer = window.setInterval(onChange, MOTION_DEADLINE_TICK_MS);
72
+ };
73
+ const onVisibility = () => {
74
+ if (document.hidden) window.clearInterval(timer);
75
+ else start();
76
+ };
77
+ start();
78
+ document.addEventListener("visibilitychange", onVisibility);
79
+ return () => {
80
+ window.clearInterval(timer);
81
+ document.removeEventListener("visibilitychange", onVisibility);
82
+ };
83
+ };
84
+ const subscribeNothing = () => () => {
85
+ };
86
+ const clockToDay = () => formatDate(/* @__PURE__ */ new Date());
87
+ const clockToMinute = () => {
88
+ const now = /* @__PURE__ */ new Date();
89
+ return `${formatDate(now)}T${String(now.getHours()).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}`;
90
+ };
91
+ const noClock = () => null;
92
+ function useDeviceClock(precision) {
93
+ return useSyncExternalStore(
94
+ precision === "off" ? subscribeNothing : subscribeClock,
95
+ precision === "minute" ? clockToMinute : precision === "day" ? clockToDay : noClock,
96
+ noClock
97
+ );
98
+ }
42
99
  const defaultMoreLabel = (count) => `+${count} more`;
43
100
  const overflowLabelIn = (formatDayLabel) => (count, date) => `${count} more event${count === 1 ? "" : "s"}, ${formatDayLabel(date)}`;
44
101
  const EventCalendar = React.forwardRef(
@@ -52,6 +109,11 @@ const EventCalendar = React.forwardRef(
52
109
  onDateClick,
53
110
  selectedDate,
54
111
  today: todayProp,
112
+ now: nowProp,
113
+ nowLabel = "Now",
114
+ allDayLabel = "All day",
115
+ emptyDayLabel = "No events",
116
+ bare = false,
55
117
  legend,
56
118
  legendToggles = false,
57
119
  hiddenColors: hiddenColorsProp,
@@ -69,6 +131,8 @@ const EventCalendar = React.forwardRef(
69
131
  nextDayLabel = "Next day",
70
132
  showLessLabel = "Show less",
71
133
  monthLabel: monthLabelProp,
134
+ weekLabel: weekLabelProp,
135
+ dayLabel: dayLabelProp,
72
136
  overflowLabel: overflowLabelProp,
73
137
  moreLabel = defaultMoreLabel,
74
138
  weekdayLabels,
@@ -78,11 +142,22 @@ const EventCalendar = React.forwardRef(
78
142
  ...rest
79
143
  }, ref) => {
80
144
  const baseClass = "ds-event-calendar";
81
- const today = useMemo(() => parseDay(todayProp) ?? /* @__PURE__ */ new Date(), [todayProp]);
145
+ const isDay = view === "day";
146
+ const isWeek = view === "week" || isDay;
147
+ const pinnedToday = useMemo(() => parseDay(todayProp), [todayProp]);
148
+ const pinnedNow = clockMinutes(nowProp);
149
+ const clock = useDeviceClock(isDay && pinnedNow === null ? "minute" : pinnedToday ? "off" : "day");
150
+ const clockDay = clock?.split("T")[0];
151
+ const clockTime = clock?.split("T")[1];
152
+ const deviceToday = useMemo(() => parseDay(clockDay), [clockDay]);
153
+ const today = pinnedToday ?? deviceToday;
154
+ const nowMinutes = pinnedNow ?? clockMinutes(clockTime);
155
+ const startingDay = today ?? /* @__PURE__ */ new Date();
82
156
  const locale = useLocale(localeProp);
83
157
  const weekStart = weekStartsOn ?? weekStartOf(locale);
84
158
  const dayNumber = useMemo(() => new Intl.NumberFormat(locale), [locale]);
85
- const formatDayLabel = useMemo(() => dayLabelIn(locale), [locale]);
159
+ const formatDayLabel = useMemo(() => dayLabelProp ?? dayLabelIn(locale), [dayLabelProp, locale]);
160
+ const eventTimes = useMemo(() => eventTimesIn(locale), [locale]);
86
161
  const monthLabel = useMemo(() => monthLabelProp ?? monthLabelIn(locale), [monthLabelProp, locale]);
87
162
  const overflowLabel = useMemo(
88
163
  () => overflowLabelProp ?? overflowLabelIn(formatDayLabel),
@@ -90,7 +165,7 @@ const EventCalendar = React.forwardRef(
90
165
  );
91
166
  const isControlled = month !== void 0;
92
167
  const [uncontrolledMonth, setUncontrolledMonth] = useState(
93
- defaultMonth ?? formatMonth(today.getFullYear(), today.getMonth())
168
+ defaultMonth ?? formatMonth(startingDay.getFullYear(), startingDay.getMonth())
94
169
  );
95
170
  const currentMonth = isControlled ? month : uncontrolledMonth;
96
171
  const [viewYear, viewMonth] = parseMonth(currentMonth);
@@ -100,9 +175,7 @@ const EventCalendar = React.forwardRef(
100
175
  if (!isControlled) setUncontrolledMonth(value);
101
176
  onMonthChange?.(value);
102
177
  };
103
- const isDay = view === "day";
104
- const isWeek = view === "week" || isDay;
105
- const [weekAnchor, setWeekAnchor] = useState(() => parseDay(selectedDate) ?? today);
178
+ const [weekAnchor, setWeekAnchor] = useState(() => parseDay(selectedDate) ?? startingDay);
106
179
  const weekStartDate = isDay ? weekAnchor : new Date(
107
180
  weekAnchor.getFullYear(),
108
181
  weekAnchor.getMonth(),
@@ -119,10 +192,8 @@ const EventCalendar = React.forwardRef(
119
192
  };
120
193
  const [expandedDays, setExpandedDays] = useState([]);
121
194
  const toggleDay = (day) => setExpandedDays((current) => current.includes(day) ? current.filter((d) => d !== day) : [...current, day]);
122
- const weekRangeLabel = useMemo(() => {
123
- const format = new Intl.DateTimeFormat(locale, { month: "long", day: "numeric", year: "numeric" });
124
- return (start) => format.formatRange(start, new Date(start.getFullYear(), start.getMonth(), start.getDate() + 6));
125
- }, [locale]);
195
+ const weekLabel = useMemo(() => weekLabelProp ?? weekLabelIn(locale), [weekLabelProp, locale]);
196
+ const weekRangeLabel = (start) => weekLabel(start, new Date(start.getFullYear(), start.getMonth(), start.getDate() + 6));
126
197
  const [ownHidden, setOwnHidden] = useState(defaultHiddenColors);
127
198
  const hiddenColors = hiddenColorsProp ?? ownHidden;
128
199
  const toggleColor = (color) => {
@@ -155,10 +226,12 @@ const EventCalendar = React.forwardRef(
155
226
  for (const list of map.values()) {
156
227
  list.sort((a, b) => {
157
228
  if (spans(a) !== spans(b)) return spans(a) ? -1 : 1;
158
- if (!a.time && !b.time) return 0;
159
- if (!a.time) return -1;
160
- if (!b.time) return 1;
161
- return a.time.localeCompare(b.time, locale);
229
+ const ta = sortTimeOf(a);
230
+ const tb = sortTimeOf(b);
231
+ if (!ta && !tb) return 0;
232
+ if (!ta) return -1;
233
+ if (!tb) return 1;
234
+ return compareTimes(ta, tb, locale);
162
235
  });
163
236
  }
164
237
  return map;
@@ -168,7 +241,7 @@ const EventCalendar = React.forwardRef(
168
241
  return (event) => {
169
242
  const start = parseDay(event.date);
170
243
  const end = parseDay(event.endDate);
171
- return start && end && end > start ? format.formatRange(start, end) : null;
244
+ return start && end && end > start ? plainSpaces(format.formatRange(start, end)) : null;
172
245
  };
173
246
  }, [locale]);
174
247
  const firstDay = weekdayOffset(new Date(viewYear, viewMonth, 1).getDay(), weekStart);
@@ -188,10 +261,67 @@ const EventCalendar = React.forwardRef(
188
261
  cells.push({ date, inMonth: date.getMonth() === viewMonth });
189
262
  }
190
263
  }
191
- const classes = [baseClass, isWeek ? `${baseClass}--week` : "", isDay ? `${baseClass}--day` : "", className].filter(Boolean).join(" ");
264
+ const classes = [
265
+ baseClass,
266
+ isWeek ? `${baseClass}--week` : "",
267
+ isDay ? `${baseClass}--day` : "",
268
+ bare ? `${baseClass}--bare` : "",
269
+ className
270
+ ].filter(Boolean).join(" ");
192
271
  const monthTitle = isDay ? formatDayLabel(weekStartDate) : isWeek ? weekRangeLabel(weekStartDate) : monthLabel(new Date(viewYear, viewMonth, 1));
193
272
  const previousName = isDay ? previousDayLabel : isWeek ? previousWeekLabel : previousLabel;
194
273
  const nextName = isDay ? nextDayLabel : isWeek ? nextWeekLabel : nextLabel;
274
+ const isTodayDate = (date) => today !== null && date.getFullYear() === today.getFullYear() && date.getMonth() === today.getMonth() && date.getDate() === today.getDate();
275
+ const eventName = (event, dayLabel) => {
276
+ const span = formatSpan(event);
277
+ const times = eventTimes(event);
278
+ return span ? `${event.title}, ${span}` : `${event.title}${times ? `, ${times.range}` : ""}, ${dayLabel}`;
279
+ };
280
+ const renderAgenda = (date) => {
281
+ const dateStr = formatDate(date);
282
+ const dayEvents = eventsByDate.get(dateStr) ?? [];
283
+ const dayLabel = formatDayLabel(date);
284
+ const markerAt = isTodayDate(date) && nowMinutes !== null ? nowMarkerIndex(
285
+ dayEvents.map((event) => {
286
+ const time = sortTimeOf(event);
287
+ return time ? minutesOf(time) : null;
288
+ }),
289
+ nowMinutes
290
+ ) : null;
291
+ if (dayEvents.length === 0) {
292
+ return /* @__PURE__ */ jsx("p", { className: `${baseClass}__agenda-empty`, children: emptyDayLabel });
293
+ }
294
+ const marker = /* @__PURE__ */ jsx("li", { className: `${baseClass}__now`, children: /* @__PURE__ */ jsx("span", { className: `${baseClass}__now-label`, children: nowLabel }) }, "now");
295
+ return /* @__PURE__ */ jsxs("ul", { className: `${baseClass}__agenda`, children: [
296
+ dayEvents.map((event, index) => {
297
+ const times = eventTimes(event);
298
+ const itemClasses = `${baseClass}__agenda-event ${baseClass}__event--${event.color ?? "neutral"}`;
299
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [
300
+ /* @__PURE__ */ jsxs("span", { className: `${baseClass}__agenda-time`, "aria-hidden": "true", children: [
301
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__agenda-start`, children: times ? times.start : allDayLabel }),
302
+ times?.end && /* @__PURE__ */ jsx("span", { className: `${baseClass}__agenda-end`, children: times.end })
303
+ ] }),
304
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__agenda-bar`, "aria-hidden": "true" }),
305
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__agenda-title`, "aria-hidden": "true", children: event.title }),
306
+ !onEventClick && /* @__PURE__ */ jsx("span", { className: "ds-visually-hidden", children: times ? `${event.title}, ${times.range}` : `${event.title}, ${allDayLabel}` })
307
+ ] });
308
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
309
+ markerAt === index && marker,
310
+ /* @__PURE__ */ jsx("li", { className: `${baseClass}__agenda-item`, children: onEventClick ? /* @__PURE__ */ jsx(
311
+ "button",
312
+ {
313
+ type: "button",
314
+ className: itemClasses,
315
+ onClick: () => onEventClick(event),
316
+ "aria-label": eventName(event, dayLabel),
317
+ children: content
318
+ }
319
+ ) : /* @__PURE__ */ jsx("span", { className: itemClasses, children: content }) })
320
+ ] }, event.id);
321
+ }),
322
+ markerAt === dayEvents.length && marker
323
+ ] });
324
+ };
195
325
  return /* @__PURE__ */ jsxs("div", { ...rest, ref, className: classes, children: [
196
326
  /* @__PURE__ */ jsxs("div", { className: `${baseClass}__header`, children: [
197
327
  /* @__PURE__ */ jsx("span", { className: `${baseClass}__month`, children: monthTitle }),
@@ -226,13 +356,13 @@ const EventCalendar = React.forwardRef(
226
356
  className: `${baseClass}__grid`,
227
357
  role: "group",
228
358
  "aria-label": monthTitle,
229
- children: cells.map(({ date, inMonth }) => {
359
+ children: isDay ? renderAgenda(weekStartDate) : cells.map(({ date, inMonth }) => {
230
360
  const dateStr = formatDate(date);
231
361
  const dayEvents = eventsByDate.get(dateStr) ?? [];
232
362
  const expanded = isWeek || expandedDays.includes(dateStr);
233
363
  const visible = expanded ? dayEvents : dayEvents.slice(0, maxEventsPerDay);
234
364
  const overflow = dayEvents.length - visible.length;
235
- const isToday = date.getFullYear() === today.getFullYear() && date.getMonth() === today.getMonth() && date.getDate() === today.getDate();
365
+ const isToday = isTodayDate(date);
236
366
  const dayLabel = formatDayLabel(date);
237
367
  const isSelected = dateStr === selectedDate;
238
368
  const cellClasses = [
@@ -274,6 +404,7 @@ const EventCalendar = React.forwardRef(
274
404
  /* @__PURE__ */ jsxs("div", { className: `${baseClass}__events`, children: [
275
405
  visible.map((event) => {
276
406
  const span = formatSpan(event);
407
+ const timeText = eventTimes(event)?.range;
277
408
  const pillClasses = [
278
409
  `${baseClass}__event`,
279
410
  `${baseClass}__event--${event.color ?? "neutral"}`,
@@ -284,8 +415,8 @@ const EventCalendar = React.forwardRef(
284
415
  const pillContent = /* @__PURE__ */ jsxs(Fragment, { children: [
285
416
  /* @__PURE__ */ jsx("span", { className: `${baseClass}__event-dot`, "aria-hidden": "true" }),
286
417
  /* @__PURE__ */ jsx("span", { className: `${baseClass}__event-title`, "aria-hidden": "true", children: event.title }),
287
- event.time && /* @__PURE__ */ jsx("span", { className: `${baseClass}__event-time`, "aria-hidden": "true", children: event.time }),
288
- !onEventClick && /* @__PURE__ */ jsx("span", { className: "ds-visually-hidden", children: event.time ? `${event.title}, ${event.time}` : event.title })
418
+ timeText && /* @__PURE__ */ jsx("span", { className: `${baseClass}__event-time`, "aria-hidden": "true", children: timeText }),
419
+ !onEventClick && /* @__PURE__ */ jsx("span", { className: "ds-visually-hidden", children: timeText ? `${event.title}, ${timeText}` : event.title })
289
420
  ] });
290
421
  return onEventClick ? /* @__PURE__ */ jsx(
291
422
  "button",
@@ -293,7 +424,7 @@ const EventCalendar = React.forwardRef(
293
424
  type: "button",
294
425
  className: pillClasses,
295
426
  onClick: () => onEventClick(event),
296
- "aria-label": span ? `${event.title}, ${span}` : `${event.title}${event.time ? `, ${event.time}` : ""}, ${dayLabel}`,
427
+ "aria-label": eventName(event, dayLabel),
297
428
  children: pillContent
298
429
  },
299
430
  event.id
@@ -0,0 +1,31 @@
1
+ /**
2
+ * EventCalendar's reading of an event's `time`, which is text the consumer
3
+ * has already formatted ("08:50", "1:40 PM", "13 h 40"). Sorting that text
4
+ * as text puts "12:50" before "8:50", so the calendar reads it as a clock
5
+ * time where it can and sorts by minutes after midnight.
6
+ */
7
+ /**
8
+ * `time` as minutes after midnight, or null when it does not read as a
9
+ * clock time. Takes 24-hour and 12-hour forms, with `:`, `.` or `h` between
10
+ * hour and minutes and an English day period in any case or spacing
11
+ * ("pm", "P.M.").
12
+ */
13
+ export declare function minutesOf(time: string): number | null;
14
+ /**
15
+ * Orders two events' `time`s: clock times by the clock, ahead of any time
16
+ * that does not read as one, and those by their text in `locale`.
17
+ */
18
+ export declare function compareTimes(a: string, b: string, locale: string): number;
19
+ /**
20
+ * An event's `start` or `end`, a 24-hour `HH:mm` string ("08:50", "13:40"),
21
+ * as minutes after midnight, or null when it is not one. Stricter than
22
+ * `minutesOf`: these are data, not display text.
23
+ */
24
+ export declare function clockMinutes(value: string | undefined): number | null;
25
+ /**
26
+ * Where the day view's now marker sits in a day's sorted schedule, given each
27
+ * event's start in minutes (null for an untimed event) and the time now:
28
+ * before the first event that starts later, else after the last timed one.
29
+ * Null when the day has no timed event to place it against.
30
+ */
31
+ export declare function nowMarkerIndex(starts: (number | null)[], now: number): number | null;
@@ -0,0 +1,42 @@
1
+ function minutesOf(time) {
2
+ const match = /^\s*(\d{1,2})(?:\s*[:.h]\s*(\d{2}))?\s*(?:([ap])\.?\s*m\.?)?\s*$/i.exec(time.normalize("NFKC"));
3
+ if (!match) return null;
4
+ let hour = Number(match[1]);
5
+ const minute = match[2] === void 0 ? 0 : Number(match[2]);
6
+ const period = match[3]?.toLowerCase();
7
+ if (minute > 59) return null;
8
+ if (period) {
9
+ if (hour < 1 || hour > 12) return null;
10
+ hour = hour % 12 + (period === "p" ? 12 : 0);
11
+ } else if (hour > 23) {
12
+ return null;
13
+ }
14
+ return hour * 60 + minute;
15
+ }
16
+ function compareTimes(a, b, locale) {
17
+ const ma = minutesOf(a);
18
+ const mb = minutesOf(b);
19
+ if (ma !== null && mb !== null && ma !== mb) return ma - mb;
20
+ if (ma === null !== (mb === null)) return ma === null ? 1 : -1;
21
+ return a.localeCompare(b, locale);
22
+ }
23
+ function clockMinutes(value) {
24
+ const match = value ? /^([01]\d|2[0-3]):([0-5]\d)$/.exec(value) : null;
25
+ return match ? Number(match[1]) * 60 + Number(match[2]) : null;
26
+ }
27
+ function nowMarkerIndex(starts, now) {
28
+ let lastTimed = -1;
29
+ for (let i = 0; i < starts.length; i++) {
30
+ const start = starts[i];
31
+ if (start === null) continue;
32
+ if (start > now) return i;
33
+ lastTimed = i;
34
+ }
35
+ return lastTimed === -1 ? null : lastTimed + 1;
36
+ }
37
+ export {
38
+ clockMinutes,
39
+ compareTimes,
40
+ minutesOf,
41
+ nowMarkerIndex
42
+ };
@@ -10,6 +10,8 @@ export interface FileInputFile {
10
10
  progress?: number;
11
11
  /** Per-file error message — replaces the size line */
12
12
  error?: string;
13
+ /** The picked file itself. Set on the entries FileInput makes from a selection, so an uncontrolled list still hands the host its files. */
14
+ file?: File;
13
15
  }
14
16
  /** Props owned by FileInput itself — everything else falls through to the native <input type="file">. */
15
17
  type FileInputOwnProps = {
@@ -17,8 +19,12 @@ type FileInputOwnProps = {
17
19
  label?: string;
18
20
  /** Instructional copy inside the dropzone */
19
21
  placeholder?: string;
20
- /** Files to list under the dropzone */
22
+ /** Files to list under the dropzone (controlled). Leave it out and FileInput keeps its own list, starting from `defaultFiles`. */
21
23
  files?: FileInputFile[];
24
+ /** The list FileInput starts with when `files` is left out (uncontrolled). A selection adds to it, or replaces it unless `multiple` is set, and a remove button takes an entry out. */
25
+ defaultFiles?: FileInputFile[];
26
+ /** Called with the whole list after a selection or a removal, in both modes. A controlled host can set `files` to it. */
27
+ onFilesChange?: (files: FileInputFile[]) => void;
22
28
  /** Component size (not the native character-width `size` attribute) */
23
29
  size?: 'default' | 'compact';
24
30
  /** Error state — shows error styling and message */
@@ -50,9 +56,11 @@ export interface FileInputProps extends FileInputOwnProps, Omit<React.ComponentP
50
56
  }
51
57
  /**
52
58
  * FileInput component — a click-or-drop zone paired with a list of the
53
- * chosen files. The list is fully controlled: pass `files` and handle
54
- * `onFilesSelected` / `onFileRemove` so upload progress and per-file
55
- * errors stay owned by the host app.
59
+ * chosen files. The list is a controlled/uncontrolled pair: pass `files` and
60
+ * handle `onFilesSelected` / `onFileRemove` (or `onFilesChange`) so upload
61
+ * progress and per-file errors stay owned by the host app, or leave `files`
62
+ * out and FileInput keeps the list itself, from `defaultFiles`, adding each
63
+ * selection and showing a remove button on every entry.
56
64
  *
57
65
  * Forwards a ref to the underlying `<input type="file">` — useful for
58
66
  * programmatically opening the picker or clearing the selection — and spreads
@@ -12,7 +12,9 @@ const FileInput = React.forwardRef(
12
12
  placeholder = "Drag and drop, or click to browse",
13
13
  accept,
14
14
  multiple = false,
15
- files = [],
15
+ files: controlledFiles,
16
+ defaultFiles,
17
+ onFilesChange,
16
18
  size = "default",
17
19
  disabled = false,
18
20
  required = false,
@@ -33,6 +35,10 @@ const FileInput = React.forwardRef(
33
35
  }, ref) => {
34
36
  const locale = useLocale(localeProp);
35
37
  const [isDragging, setIsDragging] = useState(false);
38
+ const isControlled = controlledFiles !== void 0;
39
+ const [internalFiles, setInternalFiles] = useState(defaultFiles ?? []);
40
+ const files = isControlled ? controlledFiles : internalFiles;
41
+ const nextEntryId = useRef(0);
36
42
  const inputRef = useRef(null);
37
43
  const generatedId = useId();
38
44
  const inputId = id || name || generatedId;
@@ -42,10 +48,27 @@ const FileInput = React.forwardRef(
42
48
  if (typeof ref === "function") ref(node);
43
49
  else if (ref) ref.current = node;
44
50
  };
51
+ const commitFiles = (next) => {
52
+ if (!isControlled) setInternalFiles(next);
53
+ onFilesChange?.(next);
54
+ };
45
55
  const emitFiles = (fileList) => {
46
56
  if (!fileList || fileList.length === 0) return;
47
- onFilesSelected?.(Array.from(fileList));
57
+ const picked = Array.from(fileList);
58
+ onFilesSelected?.(picked);
59
+ const entries = picked.map((file) => ({
60
+ id: `${generatedId}-file-${nextEntryId.current += 1}`,
61
+ name: file.name,
62
+ size: file.size,
63
+ file
64
+ }));
65
+ commitFiles(multiple ? [...files, ...entries] : entries);
66
+ };
67
+ const removeFile = (fileId) => {
68
+ onFileRemove?.(fileId);
69
+ commitFiles(files.filter((entry) => entry.id !== fileId));
48
70
  };
71
+ const canRemove = Boolean(onFileRemove || onFilesChange || !isControlled);
49
72
  const handleChange = (e) => {
50
73
  onChange?.(e);
51
74
  emitFiles(e.target.files);
@@ -176,12 +199,12 @@ const FileInput = React.forwardRef(
176
199
  }
177
200
  )
178
201
  ] }),
179
- onFileRemove && /* @__PURE__ */ jsx(
202
+ canRemove && /* @__PURE__ */ jsx(
180
203
  "button",
181
204
  {
182
205
  type: "button",
183
206
  className: `${baseClass}__file-remove`,
184
- onClick: () => onFileRemove(file.id),
207
+ onClick: () => removeFile(file.id),
185
208
  disabled,
186
209
  "aria-label": removeLabel(file.name),
187
210
  children: /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded", "aria-hidden": "true", children: "close" })
@@ -327,3 +327,33 @@
327
327
  .ds-input--affixed.ds-input--compact.ds-input--has-icon-right .ds-input__field-wrapper {
328
328
  padding-inline-end: var(--padding-200);
329
329
  }
330
+
331
+ /* ============================================
332
+ QUIET
333
+ At rest the field draws no border and no fill,
334
+ only its leading icon and placeholder. The
335
+ border stays, transparent, so revealing it
336
+ moves nothing. The rest rule names every
337
+ condition that reveals the field, so a
338
+ revealed field is simply the default one,
339
+ with its own hover, focus and error states:
340
+ the field hovered or focused, a value in it,
341
+ an error, disabled, or the nearest
342
+ [data-quiet-host] ancestor (a list row)
343
+ hovered.
344
+ ============================================ */
345
+
346
+ .ds-input--quiet:not(.ds-input--filled, .ds-input--error, .ds-input--disabled):not(:where([data-quiet-host]:hover) *):not(.ds-input--affixed) .ds-input__field:not(:hover, :focus),
347
+ .ds-input--quiet.ds-input--affixed:not(.ds-input--filled, .ds-input--error, .ds-input--disabled):not(:where([data-quiet-host]:hover) *) .ds-input__field-wrapper:not(:hover, :focus-within) {
348
+ border-color: transparent;
349
+ background-color: transparent;
350
+ }
351
+
352
+ /* Forced colors flatten every fill, so the border is all that marks the
353
+ field out: keep it at rest. */
354
+ @media (forced-colors: active) {
355
+ .ds-input--quiet:not(.ds-input--filled, .ds-input--error, .ds-input--disabled):not(:where([data-quiet-host]:hover) *):not(.ds-input--affixed) .ds-input__field:not(:hover, :focus),
356
+ .ds-input--quiet.ds-input--affixed:not(.ds-input--filled, .ds-input--error, .ds-input--disabled):not(:where([data-quiet-host]:hover) *) .ds-input__field-wrapper:not(:hover, :focus-within) {
357
+ border-color: var(--color-input-border-primary);
358
+ }
359
+ }
@@ -9,6 +9,14 @@ type InputOwnProps = {
9
9
  type?: 'text' | 'email' | 'password' | 'number' | 'search' | 'tel' | 'url';
10
10
  /** Component size (not the native character-width `size` attribute) */
11
11
  size?: 'default' | 'compact';
12
+ /**
13
+ * The field's form. `quiet` draws no border or fill at rest, only the
14
+ * leading icon and the placeholder, and reveals the full field while it is
15
+ * hovered, focused or holds a value, or while the nearest ancestor marked
16
+ * `data-quiet-host` (a list row) is hovered. For a list where every row can
17
+ * take an optional entry. An error always shows the full field.
18
+ */
19
+ variant?: 'default' | 'quiet';
12
20
  /** Error state — shows error styling and message */
13
21
  error?: boolean;
14
22
  /** Helper text displayed below the input. With the older `error` flag and no `errorText`, it doubles as the error message. */
@@ -13,6 +13,7 @@ const Input = React.forwardRef(
13
13
  value,
14
14
  type = "text",
15
15
  size = "default",
16
+ variant = "default",
16
17
  disabled = false,
17
18
  required = false,
18
19
  error = false,
@@ -57,6 +58,8 @@ const Input = React.forwardRef(
57
58
  const classes = [
58
59
  baseClass,
59
60
  size === "compact" ? `${baseClass}--compact` : "",
61
+ variant === "quiet" ? `${baseClass}--quiet` : "",
62
+ variant === "quiet" && filled ? `${baseClass}--filled` : "",
60
63
  invalid ? `${baseClass}--error` : "",
61
64
  affixed ? `${baseClass}--affixed` : "",
62
65
  disabled ? `${baseClass}--disabled` : "",
@@ -29,7 +29,11 @@ type PopoverOwnProps = {
29
29
  defaultOpen?: boolean;
30
30
  /** Callback when open state changes */
31
31
  onOpenChange?: (open: boolean) => void;
32
- /** Accessible label for the trigger and the panel; the panel is named "Popover" when it is omitted */
32
+ /**
33
+ * Legacy accessible-name prop for the trigger and the panel. A native `aria-label` wins when both are passed, and names those two rather than the wrapper; with neither, the panel is named "Popover".
34
+ *
35
+ * @deprecated Pass the native `aria-label` attribute instead.
36
+ */
33
37
  ariaLabel?: string;
34
38
  /** Additional CSS classes for the popover's root wrapper, which holds the trigger and the panel */
35
39
  className?: string;
@@ -19,12 +19,14 @@ const Popover = React.forwardRef(
19
19
  open: controlledOpen,
20
20
  defaultOpen = false,
21
21
  onOpenChange,
22
- ariaLabel,
22
+ ariaLabel: legacyAriaLabel,
23
+ "aria-label": nativeAriaLabel,
23
24
  className = "",
24
25
  onMouseEnter,
25
26
  onMouseLeave,
26
27
  ...rest
27
28
  }, ref) => {
29
+ const ariaLabel = nativeAriaLabel ?? legacyAriaLabel;
28
30
  const [internalOpen, setInternalOpen] = useState(defaultOpen);
29
31
  const containerRef = useRef(null);
30
32
  const triggerRef = useRef(null);
@@ -7,7 +7,11 @@ type ProgressBarOwnProps = {
7
7
  size?: 'default' | 'compact';
8
8
  /** Show percentage label */
9
9
  showLabel?: boolean;
10
- /** Accessible label describing what is loading. Defaults to "Progress"; a passed native `aria-label` works too. */
10
+ /**
11
+ * Legacy accessible-name prop for the bar, saying what is loading. A native `aria-label` wins when both are passed; with neither, the bar is named "Progress".
12
+ *
13
+ * @deprecated Pass the native `aria-label` attribute instead.
14
+ */
11
15
  ariaLabel?: string;
12
16
  /** The BCP 47 locale the percentage label is written in, such as `ar-EG`. Defaults to `en-US`. This component can render from a Server Component, so it takes the prop alone and reads no LocaleProvider. */
13
17
  locale?: string;
@@ -22,7 +22,7 @@ const ProgressBar = React.forwardRef(
22
22
  "aria-valuenow": clamped,
23
23
  "aria-valuemin": 0,
24
24
  "aria-valuemax": 100,
25
- "aria-label": ariaLabel || restAriaLabel || "Progress",
25
+ "aria-label": restAriaLabel ?? ariaLabel ?? "Progress",
26
26
  children: [
27
27
  /* @__PURE__ */ jsx("div", { className: `${baseClass}__track`, children: /* @__PURE__ */ jsx("div", { className: `${baseClass}__fill`, style: { width: `${clamped}%` } }) }),
28
28
  showLabel && /* @__PURE__ */ jsx("span", { className: `${baseClass}__label`, children: formatPercent(clamped, locale) })
@@ -67,7 +67,11 @@ type PromptSuggestionsOwnProps = {
67
67
  value?: string;
68
68
  /** Visually hidden text read after the taken suggestion once `value` is set. Defaults to "(chosen)". */
69
69
  chosenLabel?: string;
70
- /** Accessible name for the list. */
70
+ /**
71
+ * Legacy accessible-name prop for the list. Defaults to "Suggested prompts"; a native `aria-label` wins when both are passed.
72
+ *
73
+ * @deprecated Pass the native `aria-label` attribute instead.
74
+ */
71
75
  ariaLabel?: string;
72
76
  /** Additional CSS classes */
73
77
  className?: string;
@@ -62,7 +62,7 @@ const PromptSuggestions = React.forwardRef(
62
62
  ref,
63
63
  className: classes,
64
64
  role: "list",
65
- "aria-label": ariaLabel,
65
+ "aria-label": rest["aria-label"] ?? ariaLabel,
66
66
  "aria-busy": pending || void 0,
67
67
  "data-pending": pending || void 0,
68
68
  children: pending ? Array.from({ length: pendingCount }, (_, index) => /* @__PURE__ */ jsx("div", { "aria-hidden": "true", className: `${baseClass}__item`, children: block ? (
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import "react";
3
- import { DEFAULT_LOCALE } from "../../behaviors/locale.js";
3
+ import { DEFAULT_LOCALE, plainSpaces } from "../../behaviors/locale.js";
4
4
  import { ScrollRegion } from "../../behaviors/ScrollRegion.js";
5
5
  import "../../behaviors/visually-hidden.css";
6
6
  import "../../behaviors/direction.css";
@@ -34,7 +34,7 @@ function ResourceTimeline({
34
34
  minute: "2-digit"
35
35
  });
36
36
  const asDate = (minutes) => new Date(2e3, 0, 1, Math.floor(minutes / 60), minutes % 60);
37
- const range = (start, end) => timeFormat.formatRange(asDate(start), asDate(end));
37
+ const range = (start, end) => plainSpaces(timeFormat.formatRange(asDate(start), asDate(end)));
38
38
  const hours = [];
39
39
  for (let h = from / 60; h <= to / 60; h++) hours.push(h);
40
40
  const nowMinutes = now ? minutesOf(now) : null;