@remit/ui 0.0.219 → 0.0.221

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/ui",
3
- "version": "0.0.219",
3
+ "version": "0.0.221",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -88,6 +88,8 @@ const base: CalendarGridProps = {
88
88
  onSelectEvent: () => undefined,
89
89
  onPickSlot: () => undefined,
90
90
  onRangeChange: () => undefined,
91
+ dayHref: (day) => `/day/${day}`,
92
+ onZoomDay: () => undefined,
91
93
  };
92
94
 
93
95
  interface Chip {
@@ -182,6 +184,129 @@ describe("CalendarGrid placement", () => {
182
184
  });
183
185
  });
184
186
 
187
+ const monthDays = (root: HTMLElement): string[] =>
188
+ Array.from(
189
+ new Set(
190
+ Array.from(root.querySelectorAll<HTMLElement>("[data-date]")).map(
191
+ (cell) => cell.dataset.date ?? "",
192
+ ),
193
+ ),
194
+ ).sort();
195
+
196
+ const nextWeek = "2026-06-17";
197
+ const lastOfMonth = anEvent({
198
+ id: "close",
199
+ title: "Month close",
200
+ start: "2026-06-30T15:00:00+02:00",
201
+ end: "2026-06-30T16:00:00+02:00",
202
+ });
203
+ const spill = anEvent({
204
+ id: "spill",
205
+ title: "Kickoff",
206
+ start: "2026-07-02T09:00:00+02:00",
207
+ end: "2026-07-02T10:00:00+02:00",
208
+ });
209
+ const later = anEvent({
210
+ id: "later",
211
+ title: "Planning",
212
+ start: `${nextWeek}T13:00:00+02:00`,
213
+ end: `${nextWeek}T14:00:00+02:00`,
214
+ });
215
+
216
+ describe("CalendarGrid month", () => {
217
+ it("draws whole weeks from the Monday on or before the 1st to the Sunday on or after the last", () => {
218
+ const days = monthDays(grid({ view: "month", date: "2026-07-10" }));
219
+ assert.equal(days.length, 35);
220
+ assert.equal(days[0], "2026-06-29");
221
+ assert.equal(days[34], "2026-08-02");
222
+ });
223
+
224
+ it("draws exactly the month's days when it fills its weeks", () => {
225
+ const days = monthDays(grid({ view: "month", date: "2027-02-14" }));
226
+ assert.equal(days.length, 28);
227
+ assert.equal(days[0], "2027-02-01");
228
+ assert.equal(days[27], "2027-02-28");
229
+ });
230
+
231
+ it("puts each event on its own day, including the neighbouring month's edge days", () => {
232
+ const root = grid({
233
+ view: "month",
234
+ date: TODAY,
235
+ events: [roadmap, handover, later, lastOfMonth, spill],
236
+ });
237
+ assert.equal(chip(root, "Roadmap review").date, TODAY);
238
+ assert.equal(chip(root, "Handover").date, TOMORROW);
239
+ assert.equal(chip(root, "Planning").date, nextWeek);
240
+ assert.equal(chip(root, "Month close").date, "2026-06-30");
241
+ assert.equal(chip(root, "Kickoff").date, "2026-07-02");
242
+ });
243
+
244
+ it("draws every event as a row, never a column block", () => {
245
+ const drawn = chips(
246
+ grid({ view: "month", date: TODAY, events: [roadmap, handover] }),
247
+ );
248
+ assert.equal(drawn.length, 2);
249
+ assert.ok(drawn.every((one) => one.timed === false));
250
+ });
251
+
252
+ it("marks today in the month", () => {
253
+ assert.ok(
254
+ grid({ view: "month", date: TODAY }).querySelector(
255
+ `[data-date="${TODAY}"][aria-current="date"]`,
256
+ ),
257
+ );
258
+ });
259
+
260
+ it("makes each day's number a real link to that day", () => {
261
+ const root = grid({ view: "month", date: TODAY });
262
+ const link = root.querySelector<HTMLAnchorElement>(
263
+ "a[aria-label='Open Wednesday, 10 June 2026']",
264
+ );
265
+ assert.ok(link);
266
+ assert.equal(link.getAttribute("href"), "/day/2026-06-10");
267
+ assert.equal(link.textContent, "10");
268
+ assert.equal(root.querySelectorAll("a[href^='/day/']").length, 35);
269
+ });
270
+
271
+ it("draws an event that crosses Sunday into Monday on both days", () => {
272
+ const drawn = chips(
273
+ grid({
274
+ view: "month",
275
+ date: TODAY,
276
+ events: [
277
+ anEvent({
278
+ id: "overnight",
279
+ title: "Overnight deploy",
280
+ start: "2026-06-28T22:00:00+02:00",
281
+ end: "2026-06-29T02:00:00+02:00",
282
+ }),
283
+ ],
284
+ }),
285
+ ).filter((one) => one.title === "Overnight deploy");
286
+ assert.deepEqual(
287
+ drawn.map((one) => one.date),
288
+ ["2026-06-28", "2026-06-29"],
289
+ );
290
+ });
291
+
292
+ it("places an event on the day it falls on in the grid's zone, not its own", () => {
293
+ const root = grid({
294
+ view: "month",
295
+ date: TODAY,
296
+ events: [
297
+ anEvent({
298
+ id: "newyork",
299
+ title: "Late call",
300
+ timeZone: "America/New_York",
301
+ start: "2026-06-30T23:30:00-04:00",
302
+ end: "2026-07-01T00:30:00-04:00",
303
+ }),
304
+ ],
305
+ });
306
+ assert.equal(chip(root, "Late call").date, "2026-07-01");
307
+ });
308
+ });
309
+
185
310
  describe("CalendarGrid all-day band", () => {
186
311
  it("gives the week a band of its own, named", () => {
187
312
  assert.match(grid().innerHTML, /All day/);
@@ -126,6 +126,8 @@ const meta: Meta<typeof CalendarGrid> = {
126
126
  onSelectEvent: () => undefined,
127
127
  onPickSlot: () => undefined,
128
128
  onRangeChange: () => undefined,
129
+ dayHref: (day) => `#${day}`,
130
+ onZoomDay: () => undefined,
129
131
  },
130
132
  };
131
133
  export default meta;
@@ -10,7 +10,7 @@ import interactionPlugin from "@fullcalendar/react/interaction";
10
10
  import listPlugin from "@fullcalendar/react/list";
11
11
  import multiMonthPlugin from "@fullcalendar/react/multimonth";
12
12
  import timeGridPlugin from "@fullcalendar/react/timegrid";
13
- import { useEffect, useMemo, useRef } from "react";
13
+ import { type MouseEvent, useEffect, useMemo, useRef } from "react";
14
14
  import { calendarEventBodyClasses } from "../lib/calendar-event-shell.js";
15
15
  import {
16
16
  isDraggedSelection,
@@ -104,6 +104,8 @@ export interface CalendarGridProps {
104
104
  onPickSlot: (pick: CalendarSlotPick) => void;
105
105
  /** The range title the grid computed, e.g. "8 – 14 Jun 2026". */
106
106
  onRangeChange: (title: string) => void;
107
+ dayHref: (date: string) => string;
108
+ onZoomDay: (date: string) => void;
107
109
  className?: string;
108
110
  }
109
111
 
@@ -141,6 +143,21 @@ function toInput(event: CalendarEventData): EventInput {
141
143
  };
142
144
  }
143
145
 
146
+ const isoDayInZone = (instant: Date, timeZone: string): string =>
147
+ new Intl.DateTimeFormat("en-CA", {
148
+ timeZone,
149
+ year: "numeric",
150
+ month: "2-digit",
151
+ day: "2-digit",
152
+ }).format(instant);
153
+
154
+ const isModifiedClick = (click: MouseEvent<HTMLElement>): boolean =>
155
+ click.button !== 0 ||
156
+ click.metaKey ||
157
+ click.ctrlKey ||
158
+ click.shiftKey ||
159
+ click.altKey;
160
+
144
161
  export function CalendarGrid({
145
162
  view,
146
163
  date,
@@ -153,6 +170,8 @@ export function CalendarGrid({
153
170
  onSelectEvent,
154
171
  onPickSlot,
155
172
  onRangeChange,
173
+ dayHref,
174
+ onZoomDay,
156
175
  className,
157
176
  }: CalendarGridProps) {
158
177
  const calendarRef = useRef<CalendarRef>(null);
@@ -241,6 +260,7 @@ export function CalendarGrid({
241
260
  height="100%"
242
261
  headerToolbar={false}
243
262
  firstDay={1}
263
+ fixedWeekCount={false}
244
264
  nowIndicator
245
265
  selectable
246
266
  selectMirror
@@ -252,6 +272,39 @@ export function CalendarGrid({
252
272
  allDayText="All day"
253
273
  dayMaxEvents={isTight ? 2 : 3}
254
274
  eventMaxStack={3}
275
+ dayCellTopContent={(info) => {
276
+ if (view !== "month") return;
277
+ const day = isoDayInZone(info.date, timeZone);
278
+ return (
279
+ <a
280
+ href={dayHref(day)}
281
+ aria-label={`Open ${info.date.toLocaleDateString("en-GB", { dateStyle: "full", timeZone })}`}
282
+ className="hover:underline"
283
+ onClick={(click) => {
284
+ if (isModifiedClick(click)) return;
285
+ click.preventDefault();
286
+ onZoomDay(day);
287
+ }}
288
+ >
289
+ {Number(day.slice(8))}
290
+ </a>
291
+ );
292
+ }}
293
+ dayCellDidMount={(info) => {
294
+ if (view !== "month") return;
295
+ /* The engine hides a day number from assistive tech unless it is its
296
+ own nav link, and a link inside a hidden wrapper is unreachable. */
297
+ info.el
298
+ .querySelector(":scope [aria-hidden='true']:has(> a)")
299
+ ?.removeAttribute("aria-hidden");
300
+ /* A press on the link must not start the engine's cell click: it
301
+ finishes a task after the pointer is up, by which time the link
302
+ has already moved the view and the cell it wants is gone. */
303
+ const link = info.el.querySelector("a");
304
+ for (const type of ["mousedown", "touchstart", "pointerdown"]) {
305
+ link?.addEventListener(type, (press) => press.stopPropagation());
306
+ }
307
+ }}
255
308
  moreLinkClick="popover"
256
309
  moreLinkText={(num) => `+${num}`}
257
310
  scrollTime="08:30:00"
@@ -113,4 +113,15 @@ describe("MobileReadingPane", () => {
113
113
  assert.match(html, /title="Reply"/);
114
114
  assert.doesNotMatch(html, /title="Reply \(r\)"/);
115
115
  });
116
+
117
+ it("keeps pinch-zoom enabled on the scroll area when swipe handlers are set", () => {
118
+ const html = renderToString(
119
+ createElement(MobileReadingPane, {
120
+ thread,
121
+ onBack: () => undefined,
122
+ touchHandlers: { onTouchStart: () => undefined },
123
+ }),
124
+ );
125
+ assert.match(html, /touch-action:\s*pan-y pinch-zoom/);
126
+ });
116
127
  });
@@ -131,7 +131,7 @@ export function MobileReadingPane({
131
131
 
132
132
  <div
133
133
  className="flex-1 overflow-y-auto"
134
- style={touchHandlers ? { touchAction: "pan-y" } : undefined}
134
+ style={touchHandlers ? { touchAction: "pan-y pinch-zoom" } : undefined}
135
135
  {...touchHandlers}
136
136
  >
137
137
  {/* Newest first, as on the wide pane. */}