rift-ds 1.33.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 (95) hide show
  1. package/README.md +3 -3
  2. package/behaviors/chat-card.css +11 -6
  3. package/behaviors/locale.d.ts +9 -0
  4. package/behaviors/locale.js +2 -0
  5. package/bin/templates/blocks/app/dashboard/page.tsx +1 -1
  6. package/bin/templates/blocks/components/blocks/AppShell.module.css +10 -6
  7. package/chat/AssistantTurn.d.ts +2 -0
  8. package/chat/AssistantTurn.js +18 -7
  9. package/chat/ChatProvider.js +14 -0
  10. package/chat/ChatTabs.js +1 -1
  11. package/chat/ChatWidget.css +10 -0
  12. package/chat/ChatWidget.d.ts +9 -5
  13. package/chat/ChatWidget.js +7 -4
  14. package/chat/DemoWelcome.js +2 -2
  15. package/chat/FollowupSuggestions.js +1 -1
  16. package/chat/agentState.d.ts +2 -1
  17. package/chat/agentState.js +4 -1
  18. package/chat/awaiting.d.ts +19 -0
  19. package/chat/awaiting.js +21 -0
  20. package/chat/context.d.ts +4 -0
  21. package/chat/index.d.ts +1 -0
  22. package/chat/index.js +3 -1
  23. package/chat/server.d.ts +8 -3
  24. package/chat/server.js +1 -1
  25. package/components/ActionBar/ActionBar.css +78 -0
  26. package/components/ActionBar/ActionBar.d.ts +40 -0
  27. package/components/ActionBar/ActionBar.js +29 -0
  28. package/components/ActionCard/ActionCard.css +3 -3
  29. package/components/AgentStatus/AgentStatus.css +114 -22
  30. package/components/AgentStatus/AgentStatus.d.ts +10 -7
  31. package/components/AgentStatus/AgentStatus.js +10 -0
  32. package/components/AiButton/AiButton.d.ts +3 -3
  33. package/components/AiButton/AiButton.js +1 -1
  34. package/components/Alert/Alert.css +16 -0
  35. package/components/Alert/Alert.d.ts +2 -2
  36. package/components/Alert/Alert.js +3 -1
  37. package/components/AppSidebar/AppSidebar.css +140 -4
  38. package/components/AppSidebar/AppSidebar.d.ts +12 -0
  39. package/components/AppSidebar/AppSidebar.js +7 -3
  40. package/components/ChatThread/ChatThread.d.ts +5 -1
  41. package/components/ChatThread/ChatThread.js +1 -1
  42. package/components/Composer/Composer.css +14 -9
  43. package/components/Composer/Composer.d.ts +10 -8
  44. package/components/Composer/Composer.js +2 -1
  45. package/components/ContextMenu/ContextMenu.d.ts +5 -1
  46. package/components/ContextMenu/ContextMenu.js +2 -1
  47. package/components/ContributionGraph/ContributionGraph.d.ts +7 -1
  48. package/components/ContributionGraph/ContributionGraph.js +4 -18
  49. package/components/ContributionGraph/weeks.d.ts +8 -0
  50. package/components/ContributionGraph/weeks.js +25 -0
  51. package/components/DataTable/DataTable.js +1 -1
  52. package/components/DocumentChip/DocumentChip.js +1 -1
  53. package/components/EntitySwitcher/EntitySwitcher.css +11 -3
  54. package/components/EntitySwitcher/EntitySwitcher.js +1 -1
  55. package/components/EventCalendar/EventCalendar.css +152 -0
  56. package/components/EventCalendar/EventCalendar.d.ts +50 -4
  57. package/components/EventCalendar/EventCalendar.js +154 -23
  58. package/components/EventCalendar/eventTime.d.ts +31 -0
  59. package/components/EventCalendar/eventTime.js +42 -0
  60. package/components/FileInput/FileInput.d.ts +12 -4
  61. package/components/FileInput/FileInput.js +27 -4
  62. package/components/Input/Input.css +30 -0
  63. package/components/Input/Input.d.ts +8 -0
  64. package/components/Input/Input.js +3 -0
  65. package/components/MessageCard/MessageCard.css +1 -1
  66. package/components/Popover/Popover.d.ts +5 -1
  67. package/components/Popover/Popover.js +3 -1
  68. package/components/ProgressBar/ProgressBar.d.ts +5 -1
  69. package/components/ProgressBar/ProgressBar.js +1 -1
  70. package/components/PromptSuggestions/PromptSuggestions.d.ts +5 -1
  71. package/components/PromptSuggestions/PromptSuggestions.js +1 -1
  72. package/components/ResourceTimeline/ResourceTimeline.js +2 -2
  73. package/components/SegmentedControl/SegmentedControl.css +120 -3
  74. package/components/SegmentedControl/SegmentedControl.d.ts +9 -0
  75. package/components/SegmentedControl/SegmentedControl.js +11 -1
  76. package/components/ShaderScene/ShaderScene.d.ts +3 -3
  77. package/components/ShaderScene/scenes.d.ts +17 -0
  78. package/components/ShaderScene/scenes.js +175 -1
  79. package/components/SourceTrail/SourceTrail.css +1 -1
  80. package/components/Stat/Stat.css +12 -0
  81. package/components/Stat/Stat.d.ts +5 -0
  82. package/components/Stat/Stat.js +9 -3
  83. package/components/TableToolbar/TableToolbar.js +2 -2
  84. package/components/ThemeToggle/ThemeToggle.d.ts +1 -1
  85. package/components/ThreadTabs/ThreadTabs.d.ts +5 -1
  86. package/components/ThreadTabs/ThreadTabs.js +2 -1
  87. package/components/ToggleGroup/ToggleGroup.d.ts +5 -1
  88. package/components/ToolCall/ToolCall.css +2 -2
  89. package/components/UsageCard/UsageCard.css +4 -3
  90. package/components/registry.json +21 -4
  91. package/components/registry.json.d.ts +21 -4
  92. package/components/registry.json.js +1 -1
  93. package/index.d.ts +1 -0
  94. package/index.js +2 -0
  95. package/package.json +1 -1
@@ -22,6 +22,15 @@
22
22
  padding: var(--padding-400);
23
23
  }
24
24
 
25
+ /* Bare — inside a Panel or Widget that already draws the surface, the
26
+ calendar drops its own, so the two never double their borders. */
27
+ .ds-event-calendar--bare {
28
+ background-color: transparent;
29
+ border: none;
30
+ border-radius: 0;
31
+ padding: 0;
32
+ }
33
+
25
34
  /* ============================================
26
35
  HEADER
27
36
  ============================================ */
@@ -453,6 +462,149 @@ button.ds-event-calendar__more:focus-visible {
453
462
  grid-template-columns: 1fr;
454
463
  }
455
464
 
465
+ /* ============================================
466
+ DAY VIEW SCHEDULE — the day as a list
467
+ Each event leads with its start over its end
468
+ in a column of its own, so the titles line up;
469
+ a bar in the event's accent sits between. The
470
+ rows take the pill's fill and hover.
471
+ ============================================ */
472
+
473
+ .ds-event-calendar__agenda {
474
+ display: flex;
475
+ flex-direction: column;
476
+ gap: var(--gap-050);
477
+ margin: 0;
478
+ padding: 0;
479
+ list-style: none;
480
+ }
481
+
482
+ .ds-event-calendar__agenda-item {
483
+ display: flex;
484
+ }
485
+
486
+ :where(.ds-event-calendar__agenda-event) {
487
+ --ds-event-accent: var(--color-status-neutral-border);
488
+ }
489
+
490
+ .ds-event-calendar__agenda-event {
491
+ display: flex;
492
+ align-items: stretch;
493
+ gap: var(--gap-200);
494
+ flex: 1 1 auto;
495
+ min-width: 0;
496
+ margin: 0;
497
+ padding: var(--padding-150) var(--padding-200);
498
+ background-color: var(--color-calendar-event-bg);
499
+ border: var(--border-025) solid transparent;
500
+ border-radius: var(--radius-200);
501
+ color: inherit;
502
+ font: inherit;
503
+ text-align: start;
504
+ }
505
+
506
+ button.ds-event-calendar__agenda-event {
507
+ cursor: pointer;
508
+ transition:
509
+ background-color var(--motion-duration-fast) var(--motion-ease-standard),
510
+ border-color var(--motion-duration-fast) var(--motion-ease-standard);
511
+ }
512
+
513
+ button.ds-event-calendar__agenda-event:hover {
514
+ background-color: var(--color-calendar-event-bg-hover);
515
+ border-color: var(--color-calendar-event-border);
516
+ }
517
+
518
+ button.ds-event-calendar__agenda-event:focus-visible {
519
+ outline: 2px solid var(--color-action-primary-bg);
520
+ outline-offset: -2px;
521
+ }
522
+
523
+ .ds-event-calendar__agenda-time {
524
+ display: flex;
525
+ flex: none;
526
+ flex-direction: column;
527
+ min-inline-size: calc(var(--control-height-default) * 2);
528
+ font-variant-numeric: tabular-nums;
529
+ }
530
+
531
+ .ds-event-calendar__agenda-start {
532
+ color: var(--color-text-primary);
533
+ font-family: var(--font-paragraph-sm-emphasis-family);
534
+ font-size: var(--font-paragraph-sm-emphasis-size);
535
+ font-weight: var(--font-paragraph-sm-emphasis-weight);
536
+ line-height: var(--font-paragraph-sm-emphasis-line-height);
537
+ letter-spacing: var(--font-paragraph-sm-emphasis-letter-spacing);
538
+ }
539
+
540
+ .ds-event-calendar__agenda-end {
541
+ color: var(--color-text-tertiary);
542
+ font-family: var(--font-paragraph-sm-family);
543
+ font-size: var(--font-paragraph-sm-size);
544
+ font-weight: var(--font-paragraph-sm-weight);
545
+ line-height: var(--font-paragraph-sm-line-height);
546
+ letter-spacing: var(--font-paragraph-sm-letter-spacing);
547
+ }
548
+
549
+ .ds-event-calendar__agenda-bar {
550
+ flex: none;
551
+ width: var(--gap-050);
552
+ border-radius: var(--radius-pill);
553
+ background-color: var(--ds-event-accent);
554
+ }
555
+
556
+ .ds-event-calendar__agenda-title {
557
+ flex: 1 1 auto;
558
+ min-width: 0;
559
+ align-self: center;
560
+ overflow-wrap: anywhere;
561
+ color: var(--color-text-primary);
562
+ font-family: var(--font-paragraph-emphasis-family);
563
+ font-size: var(--font-paragraph-emphasis-size);
564
+ font-weight: var(--font-paragraph-emphasis-weight);
565
+ line-height: var(--font-paragraph-emphasis-line-height);
566
+ letter-spacing: var(--font-paragraph-emphasis-letter-spacing);
567
+ }
568
+
569
+ .ds-event-calendar__agenda-empty {
570
+ margin: 0;
571
+ padding: var(--padding-300) var(--padding-200);
572
+ color: var(--color-text-tertiary);
573
+ font-family: var(--font-paragraph-sm-family);
574
+ font-size: var(--font-paragraph-sm-size);
575
+ font-weight: var(--font-paragraph-sm-weight);
576
+ line-height: var(--font-paragraph-sm-line-height);
577
+ letter-spacing: var(--font-paragraph-sm-letter-spacing);
578
+ }
579
+
580
+ /* Now — today's convention, the inverse chip, with a rule running on from
581
+ it across the schedule. Current, not selected, so never the action
582
+ colour. */
583
+ .ds-event-calendar__now {
584
+ display: flex;
585
+ align-items: center;
586
+ gap: var(--gap-100);
587
+ }
588
+
589
+ .ds-event-calendar__now::after {
590
+ content: '';
591
+ flex: 1 1 auto;
592
+ border-block-start: var(--border-050) solid var(--color-bg-page-inverse);
593
+ }
594
+
595
+ .ds-event-calendar__now-label {
596
+ flex: none;
597
+ padding: 0 var(--padding-100);
598
+ background-color: var(--color-bg-page-inverse);
599
+ border-radius: var(--radius-pill);
600
+ color: var(--color-text-on-inverse);
601
+ font-family: var(--font-paragraph-sm-emphasis-family);
602
+ font-size: var(--font-paragraph-sm-emphasis-size);
603
+ font-weight: var(--font-paragraph-sm-emphasis-weight);
604
+ line-height: var(--font-paragraph-sm-emphasis-line-height);
605
+ letter-spacing: var(--font-paragraph-sm-emphasis-letter-spacing);
606
+ }
607
+
456
608
  /* ============================================
457
609
  SELECTED DAY — the host's panel for the chosen day
458
610
  ============================================ */
@@ -10,7 +10,17 @@ export interface EventCalendarEvent {
10
10
  endDate?: string;
11
11
  /** Short label shown in the event pill. */
12
12
  title: string;
13
- /** Start time as already-formatted text like "09:30". Untimed events sort first. */
13
+ /** When the event starts, as a 24-hour `HH:mm` string ("08:50", "13:40"). The calendar writes it in the resolved locale and sorts each day by it: untimed events first, then by the clock. */
14
+ start?: string;
15
+ /** When the event ends, as a 24-hour `HH:mm` string, later than `start`. With it, the event shows and is named with its range ("8:50 – 9:50 AM" in `en-US`). */
16
+ end?: string;
17
+ /**
18
+ * Start time as already-formatted text like "09:30" or "1:40 PM", shown
19
+ * as written in place of `start` and `end` when it is set. Without `start`
20
+ * it sorts by the clock where it reads as a clock time, after untimed
21
+ * events and ahead of any other text.
22
+ * @deprecated Use `start` (and `end`), which the calendar formats in the resolved locale.
23
+ */
14
24
  time?: string;
15
25
  /** Accent for the pill's dot, from the core accent roles. Defaults to `neutral`. */
16
26
  color?: EventCalendarColor;
@@ -49,8 +59,32 @@ type EventCalendarOwnProps = {
49
59
  * consumer; pair with `onDateClick` to move it.
50
60
  */
51
61
  selectedDate?: string;
52
- /** The date the calendar treats as today (`YYYY-MM-DD`): it carries the today chip and picks the month shown first. Defaults to the device's date; pin it for a demo, a test or a time zone the device is not in. */
62
+ /**
63
+ * The date the calendar treats as today (`YYYY-MM-DD`): it carries the
64
+ * today chip and picks the month shown first. Defaults to the device's
65
+ * date, read in the browser only: a server render draws no today chip and
66
+ * the browser adds it once it hydrates, so a server in another time zone
67
+ * can never put it on the wrong day, and it moves on at midnight. The month
68
+ * shown first still falls back to the render-time clock, so a server-rendered
69
+ * host passes `today` (or `defaultMonth`) when the first month must match.
70
+ * Pin it for a demo, a test or a time zone the device is not in.
71
+ */
53
72
  today?: string;
73
+ /**
74
+ * The time (24-hour `HH:mm`) the day view's now marker sits at, when the
75
+ * day shown is `today`. Defaults to the device's clock, read in the browser
76
+ * only and moved on every minute, so a server render draws no marker; pin
77
+ * it for a demo, a test or a screenshot.
78
+ */
79
+ now?: string;
80
+ /** The text of the day view's now marker. */
81
+ nowLabel?: string;
82
+ /** What the day view's schedule shows in place of a time for an event with none. */
83
+ allDayLabel?: string;
84
+ /** What the day view's schedule says on a day with no events. */
85
+ emptyDayLabel?: string;
86
+ /** Strips the calendar's own fill, border, radius and padding, for a Panel or Widget that already draws the surface. */
87
+ bare?: boolean;
54
88
  /** What each event colour means, shown as a row of dots and labels under the grid. With `legendToggles`, each entry also shows and hides its colour's events. */
55
89
  legend?: EventCalendarLegendItem[];
56
90
  /** Makes each legend entry a selectable Chip that shows or hides the events of its colour, so a reader can narrow a busy calendar by kind. */
@@ -72,7 +106,7 @@ type EventCalendarOwnProps = {
72
106
  renderSelectedDay?: (date: string, events: EventCalendarEvent[]) => React.ReactNode;
73
107
  /** Trailing header slot, e.g. a "New event" Button. */
74
108
  actions?: React.ReactNode;
75
- /** `month` shows the whole month, a day's overflow folded behind "+N more"; `week` shows one week in tall cells with every event, stepping a week at a time from the selected day's week (else today's), which it keeps as its own state after mount; `day` shows that one day the same way, stepping a day at a time. */
109
+ /** `month` shows the whole month, a day's overflow folded behind "+N more"; `week` shows one week in tall cells with every event, stepping a week at a time from the selected day's week (else today's), which it keeps as its own state after mount; `day` shows that one day as a schedule, each event's start and end time first, with a now marker on today, stepping a day at a time. */
76
110
  view?: 'month' | 'week' | 'day';
77
111
  /** Accessible name of the previous-month button. */
78
112
  previousLabel?: string;
@@ -92,9 +126,21 @@ type EventCalendarOwnProps = {
92
126
  * The month heading, given the first day of the month in view: the visible
93
127
  * title and the name of the day grid. Defaults to the month name and the
94
128
  * year in `locale` ("January 2026" in `en-US`). Month view only; the week
95
- * view's heading is the week's range in `locale`.
129
+ * view's heading is `weekLabel`, the day view's `dayLabel`.
96
130
  */
97
131
  monthLabel?: (month: Date) => string;
132
+ /**
133
+ * The week view's heading, given the first and last day of the week in
134
+ * view: the visible title and the name of the week's cells. Defaults to
135
+ * the range in `locale` ("August 16 – 22, 2026" in `en-US`).
136
+ */
137
+ weekLabel?: (start: Date, end: Date) => string;
138
+ /**
139
+ * The full name of a day, given the day: the day view's heading and every
140
+ * day's spoken name. Defaults to the weekday and the date in `locale`
141
+ * ("Thursday, August 20, 2026" in `en-US`).
142
+ */
143
+ dayLabel?: (date: Date) => string;
98
144
  /**
99
145
  * Accessible name of a day's "+N more" overflow button, given the number of
100
146
  * hidden events and the day. Defaults to "N more events" followed by the
@@ -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