@remit/ui 0.0.224 → 0.0.225
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/app-shell-slotted.js +1 -1
- package/dist/components/app-switcher.d.ts +15 -0
- package/dist/components/app-switcher.js +31 -0
- package/dist/components/calendar-event-popup.d.ts +43 -0
- package/dist/components/calendar-event-popup.js +18 -0
- package/dist/components/calendar-event-sidebar.d.ts +34 -0
- package/dist/components/calendar-event-sidebar.js +16 -0
- package/dist/components/calendar-grid.d.ts +8 -7
- package/dist/components/calendar-grid.js +39 -108
- package/dist/components/calendar-popover.d.ts +25 -0
- package/dist/components/calendar-popover.js +84 -0
- package/dist/components/calendar-quick-create.d.ts +35 -0
- package/dist/components/calendar-quick-create.js +26 -0
- package/dist/components/calendar-screen-toolbar.d.ts +30 -0
- package/dist/components/calendar-screen-toolbar.js +24 -0
- package/dist/components/calendar-sheet.d.ts +14 -0
- package/dist/components/calendar-sheet.js +34 -0
- package/dist/components/calendar-side-pane.d.ts +20 -0
- package/dist/components/calendar-side-pane.js +11 -0
- package/dist/components/calendar-time-grid.d.ts +64 -0
- package/dist/components/calendar-time-grid.js +666 -0
- package/dist/components/calendar-toolbar.d.ts +0 -31
- package/dist/components/calendar-toolbar.js +0 -27
- package/dist/components/calendar-year.d.ts +11 -0
- package/dist/components/calendar-year.js +9 -0
- package/dist/components/compose-fab.js +3 -1
- package/dist/components/mini-month.d.ts +19 -0
- package/dist/components/mini-month.js +34 -0
- package/dist/index.d.ts +19 -3
- package/dist/index.js +19 -3
- package/dist/lib/calendar-range.d.ts +10 -0
- package/dist/lib/calendar-range.js +39 -0
- package/dist/lib/calendar-slot-pick.d.ts +29 -0
- package/dist/lib/calendar-slot-pick.js +67 -0
- package/dist/lib/event-drag.d.ts +20 -0
- package/dist/lib/event-drag.js +50 -0
- package/dist/lib/grid-keyboard.d.ts +15 -0
- package/dist/lib/grid-keyboard.js +46 -0
- package/dist/lib/iso-week.d.ts +2 -0
- package/dist/lib/iso-week.js +13 -0
- package/dist/lib/long-press.d.ts +25 -0
- package/dist/lib/long-press.js +37 -0
- package/dist/lib/mini-month.d.ts +27 -0
- package/dist/lib/mini-month.js +33 -0
- package/dist/lib/popup-placement.d.ts +22 -0
- package/dist/lib/popup-placement.js +39 -0
- package/dist/lib/time-grid-layout.d.ts +38 -0
- package/dist/lib/time-grid-layout.js +94 -0
- package/package.json +1 -1
- package/dist/components/event-detail.d.ts +0 -38
- package/dist/components/event-detail.js +0 -21
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { clockAt, SNAP_MINUTES, slotRange } from "./calendar-slot-pick.js";
|
|
2
|
+
const LAST_SLOT = 1440 - SNAP_MINUTES;
|
|
3
|
+
/** The grid's tab stop: the current hour of today, or of the first day in view. */
|
|
4
|
+
export function initialFocus(days, today, nowMinute) {
|
|
5
|
+
return {
|
|
6
|
+
date: days.includes(today) ? today : days[0],
|
|
7
|
+
minute: Math.floor(nowMinute / 60) * 60,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/** Where an arrow key moves the focus: a quarter hour up or down, a day across. */
|
|
11
|
+
export function moveFocus(slot, key, days) {
|
|
12
|
+
const index = days.indexOf(slot.date);
|
|
13
|
+
switch (key) {
|
|
14
|
+
case "ArrowUp":
|
|
15
|
+
return { ...slot, minute: Math.max(0, slot.minute - SNAP_MINUTES) };
|
|
16
|
+
case "ArrowDown":
|
|
17
|
+
return {
|
|
18
|
+
...slot,
|
|
19
|
+
minute: Math.min(LAST_SLOT, slot.minute + SNAP_MINUTES),
|
|
20
|
+
};
|
|
21
|
+
case "ArrowLeft":
|
|
22
|
+
return { ...slot, date: days[Math.max(0, index - 1)] };
|
|
23
|
+
case "ArrowRight":
|
|
24
|
+
return { ...slot, date: days[Math.min(days.length - 1, index + 1)] };
|
|
25
|
+
default:
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const order = (a, b) => a.date === b.date ? a.minute - b.minute : a.date < b.date ? -1 : 1;
|
|
30
|
+
/**
|
|
31
|
+
* The range Shift and the arrows stretch out, from the slot the stretch began
|
|
32
|
+
* on to the focused slot, both included.
|
|
33
|
+
*/
|
|
34
|
+
export function stretchRange(anchor, focus) {
|
|
35
|
+
const [first, last] = order(anchor, focus) <= 0 ? [anchor, focus] : [focus, anchor];
|
|
36
|
+
if (first.date === last.date)
|
|
37
|
+
return slotRange(first.date, first.minute, last.minute + SNAP_MINUTES);
|
|
38
|
+
const end = slotRange(last.date, last.minute, last.minute + SNAP_MINUTES);
|
|
39
|
+
return {
|
|
40
|
+
date: first.date,
|
|
41
|
+
startTime: clockAt(first.minute),
|
|
42
|
+
endDate: end.endDate,
|
|
43
|
+
endTime: end.endTime,
|
|
44
|
+
allDay: false,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const MS_PER_DAY = 86_400_000;
|
|
2
|
+
const parse = (date) => {
|
|
3
|
+
const [year, month, day] = date.split("-").map(Number);
|
|
4
|
+
return new Date(Date.UTC(year, month - 1, day));
|
|
5
|
+
};
|
|
6
|
+
/** The ISO 8601 week a `YYYY-MM-DD` date falls in: weeks start on Monday, and week 1 holds the year's first Thursday. */
|
|
7
|
+
export function isoWeek(date) {
|
|
8
|
+
const day = parse(date);
|
|
9
|
+
const weekday = (day.getUTCDay() + 6) % 7;
|
|
10
|
+
const thursday = new Date(day.getTime() + (3 - weekday) * MS_PER_DAY);
|
|
11
|
+
const yearStart = Date.UTC(thursday.getUTCFullYear(), 0, 1);
|
|
12
|
+
return Math.floor((thursday.getTime() - yearStart) / MS_PER_DAY / 7) + 1;
|
|
13
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CalendarSlotPick } from "../components/calendar-types.js";
|
|
2
|
+
/** How long a finger holds still before a slot is selected, as in Google Calendar. */
|
|
3
|
+
export declare const HOLD_MS = 500;
|
|
4
|
+
/** How far a finger may drift during the hold before it counts as a scroll. */
|
|
5
|
+
export declare const SCROLL_SLOP_PX = 8;
|
|
6
|
+
export type Press = {
|
|
7
|
+
phase: "pending";
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
at: number;
|
|
11
|
+
} | {
|
|
12
|
+
phase: "held";
|
|
13
|
+
} | {
|
|
14
|
+
phase: "scrolled";
|
|
15
|
+
};
|
|
16
|
+
export declare function pressStart(x: number, y: number, at: number): Press;
|
|
17
|
+
/** A finger that moves during the hold is scrolling, and never selects. */
|
|
18
|
+
export declare function pressMove(press: Press, x: number, y: number): Press;
|
|
19
|
+
/** A hold that outlasted the delay without moving becomes a selection. */
|
|
20
|
+
export declare function pressTick(press: Press, now: number): Press;
|
|
21
|
+
/**
|
|
22
|
+
* A handle dragged by `deltaY` pixels, in quarter-hour steps. The other end
|
|
23
|
+
* stays put, and the block never gets shorter than a quarter hour.
|
|
24
|
+
*/
|
|
25
|
+
export declare function stepHandle(range: CalendarSlotPick, edge: "start" | "end", deltaY: number, hourHeight: number): CalendarSlotPick;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { rangeMinutes, SNAP_MINUTES, slotRange } from "./calendar-slot-pick.js";
|
|
2
|
+
/** How long a finger holds still before a slot is selected, as in Google Calendar. */
|
|
3
|
+
export const HOLD_MS = 500;
|
|
4
|
+
/** How far a finger may drift during the hold before it counts as a scroll. */
|
|
5
|
+
export const SCROLL_SLOP_PX = 8;
|
|
6
|
+
export function pressStart(x, y, at) {
|
|
7
|
+
return { phase: "pending", x, y, at };
|
|
8
|
+
}
|
|
9
|
+
/** A finger that moves during the hold is scrolling, and never selects. */
|
|
10
|
+
export function pressMove(press, x, y) {
|
|
11
|
+
if (press.phase !== "pending")
|
|
12
|
+
return press;
|
|
13
|
+
return Math.hypot(x - press.x, y - press.y) > SCROLL_SLOP_PX
|
|
14
|
+
? { phase: "scrolled" }
|
|
15
|
+
: press;
|
|
16
|
+
}
|
|
17
|
+
/** A hold that outlasted the delay without moving becomes a selection. */
|
|
18
|
+
export function pressTick(press, now) {
|
|
19
|
+
if (press.phase !== "pending")
|
|
20
|
+
return press;
|
|
21
|
+
return now - press.at >= HOLD_MS ? { phase: "held" } : press;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A handle dragged by `deltaY` pixels, in quarter-hour steps. The other end
|
|
25
|
+
* stays put, and the block never gets shorter than a quarter hour.
|
|
26
|
+
*/
|
|
27
|
+
export function stepHandle(range, edge, deltaY, hourHeight) {
|
|
28
|
+
const steps = Math.round((deltaY / hourHeight) * (60 / SNAP_MINUTES));
|
|
29
|
+
const { start, end } = rangeMinutes(range);
|
|
30
|
+
const moved = steps * SNAP_MINUTES;
|
|
31
|
+
if (edge === "start") {
|
|
32
|
+
const next = Math.min(Math.max(0, start + moved), end - SNAP_MINUTES);
|
|
33
|
+
return slotRange(range.date, next, end);
|
|
34
|
+
}
|
|
35
|
+
const next = Math.max(Math.min(1440, end + moved), start + SNAP_MINUTES);
|
|
36
|
+
return slotRange(range.date, start, next);
|
|
37
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface MiniMonthDay {
|
|
2
|
+
date: string;
|
|
3
|
+
day: number;
|
|
4
|
+
inMonth: boolean;
|
|
5
|
+
isToday: boolean;
|
|
6
|
+
inRange: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface MiniMonthWeek {
|
|
9
|
+
weekNumber: number;
|
|
10
|
+
days: MiniMonthDay[];
|
|
11
|
+
}
|
|
12
|
+
export interface MiniMonthInput {
|
|
13
|
+
/** Any `YYYY-MM-DD` in the month to draw. */
|
|
14
|
+
month: string;
|
|
15
|
+
today: string;
|
|
16
|
+
/** The range on the grid, inclusive; empty strings mark none. */
|
|
17
|
+
rangeStart: string;
|
|
18
|
+
rangeEnd: string;
|
|
19
|
+
}
|
|
20
|
+
/** The first of the month a date is in, moved by a number of months. */
|
|
21
|
+
export declare function shiftMonth(date: string, months: number): string;
|
|
22
|
+
/**
|
|
23
|
+
* The weeks a month spans, Monday first, each with its ISO week number. The
|
|
24
|
+
* days around the month fill its first and last week, the way a paper
|
|
25
|
+
* calendar prints them.
|
|
26
|
+
*/
|
|
27
|
+
export declare function miniMonthWeeks({ month, today, rangeStart, rangeEnd, }: MiniMonthInput): MiniMonthWeek[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { datesFrom, weekStart } from "./calendar-range.js";
|
|
2
|
+
import { isoWeek } from "./iso-week.js";
|
|
3
|
+
/** The first of the month a date is in, moved by a number of months. */
|
|
4
|
+
export function shiftMonth(date, months) {
|
|
5
|
+
const [year, month] = date.split("-").map(Number);
|
|
6
|
+
const index = year * 12 + (month - 1) + months;
|
|
7
|
+
const nextYear = Math.floor(index / 12);
|
|
8
|
+
const nextMonth = (index % 12) + 1;
|
|
9
|
+
return `${nextYear}-${String(nextMonth).padStart(2, "0")}-01`;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The weeks a month spans, Monday first, each with its ISO week number. The
|
|
13
|
+
* days around the month fill its first and last week, the way a paper
|
|
14
|
+
* calendar prints them.
|
|
15
|
+
*/
|
|
16
|
+
export function miniMonthWeeks({ month, today, rangeStart, rangeEnd, }) {
|
|
17
|
+
const first = `${month.slice(0, 7)}-01`;
|
|
18
|
+
const last = shiftMonth(first, 1);
|
|
19
|
+
const weeks = [];
|
|
20
|
+
let start = weekStart(first);
|
|
21
|
+
while (start < last) {
|
|
22
|
+
const days = datesFrom(start, 7).map((date) => ({
|
|
23
|
+
date,
|
|
24
|
+
day: Number(date.slice(8)),
|
|
25
|
+
inMonth: date.slice(0, 7) === first.slice(0, 7),
|
|
26
|
+
isToday: date === today,
|
|
27
|
+
inRange: rangeStart !== "" && date >= rangeStart && date <= rangeEnd,
|
|
28
|
+
}));
|
|
29
|
+
weeks.push({ weekNumber: isoWeek(start), days });
|
|
30
|
+
start = datesFrom(start, 8)[7];
|
|
31
|
+
}
|
|
32
|
+
return weeks;
|
|
33
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface Box {
|
|
2
|
+
left: number;
|
|
3
|
+
top: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
export interface Size {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
export interface Placement {
|
|
12
|
+
left: number;
|
|
13
|
+
top: number;
|
|
14
|
+
side: "right" | "left" | "below" | "above" | "center";
|
|
15
|
+
}
|
|
16
|
+
export declare function centred(popup: Size, viewport: Size): Placement;
|
|
17
|
+
/**
|
|
18
|
+
* Where a popup goes beside what it describes: to the right when there is
|
|
19
|
+
* room, else to the left, else below or above, and never over the anchor. An
|
|
20
|
+
* anchor that is missing or out of view centres the popup instead.
|
|
21
|
+
*/
|
|
22
|
+
export declare function placePopup(anchor: Box | null, popup: Size, viewport: Size): Placement;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const GAP = 8;
|
|
2
|
+
const clamp = (value, low, high) => Math.min(Math.max(value, low), Math.max(low, high));
|
|
3
|
+
const inView = (anchor, viewport) => anchor.width > 0 &&
|
|
4
|
+
anchor.height > 0 &&
|
|
5
|
+
anchor.left < viewport.width &&
|
|
6
|
+
anchor.left + anchor.width > 0 &&
|
|
7
|
+
anchor.top < viewport.height &&
|
|
8
|
+
anchor.top + anchor.height > 0;
|
|
9
|
+
export function centred(popup, viewport) {
|
|
10
|
+
return {
|
|
11
|
+
left: Math.max(GAP, (viewport.width - popup.width) / 2),
|
|
12
|
+
top: Math.max(GAP, (viewport.height - popup.height) / 2),
|
|
13
|
+
side: "center",
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Where a popup goes beside what it describes: to the right when there is
|
|
18
|
+
* room, else to the left, else below or above, and never over the anchor. An
|
|
19
|
+
* anchor that is missing or out of view centres the popup instead.
|
|
20
|
+
*/
|
|
21
|
+
export function placePopup(anchor, popup, viewport) {
|
|
22
|
+
if (!anchor || !inView(anchor, viewport))
|
|
23
|
+
return centred(popup, viewport);
|
|
24
|
+
const top = clamp(anchor.top, GAP, viewport.height - popup.height - GAP);
|
|
25
|
+
const right = anchor.left + anchor.width + GAP;
|
|
26
|
+
if (right + popup.width <= viewport.width - GAP)
|
|
27
|
+
return { left: right, top, side: "right" };
|
|
28
|
+
const left = anchor.left - GAP - popup.width;
|
|
29
|
+
if (left >= GAP)
|
|
30
|
+
return { left, top, side: "left" };
|
|
31
|
+
const across = clamp(anchor.left, GAP, viewport.width - popup.width - GAP);
|
|
32
|
+
const below = anchor.top + anchor.height + GAP;
|
|
33
|
+
if (below + popup.height <= viewport.height - GAP)
|
|
34
|
+
return { left: across, top: below, side: "below" };
|
|
35
|
+
const above = anchor.top - GAP - popup.height;
|
|
36
|
+
if (above >= GAP)
|
|
37
|
+
return { left: across, top: above, side: "above" };
|
|
38
|
+
return centred(popup, viewport);
|
|
39
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** A moment as a wall clock reads it in one zone: the day and minutes from midnight. */
|
|
2
|
+
export interface ZonedMoment {
|
|
3
|
+
date: string;
|
|
4
|
+
minute: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function zonedMoment(iso: string, timeZone: string): ZonedMoment;
|
|
7
|
+
export interface TimedSpan {
|
|
8
|
+
id: string;
|
|
9
|
+
start: ZonedMoment;
|
|
10
|
+
end: ZonedMoment;
|
|
11
|
+
}
|
|
12
|
+
export interface PlacedSpan {
|
|
13
|
+
id: string;
|
|
14
|
+
/** Minutes from midnight on this day, end exclusive. */
|
|
15
|
+
top: number;
|
|
16
|
+
bottom: number;
|
|
17
|
+
column: number;
|
|
18
|
+
columns: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The timed events on one day, clipped to it and laid out side by side where
|
|
22
|
+
* they overlap: each cluster of overlapping events shares its width evenly.
|
|
23
|
+
*/
|
|
24
|
+
export declare function layoutDay(date: string, spans: readonly TimedSpan[]): PlacedSpan[];
|
|
25
|
+
export interface DaySpan {
|
|
26
|
+
id: string;
|
|
27
|
+
/** First and last day, inclusive. */
|
|
28
|
+
first: string;
|
|
29
|
+
last: string;
|
|
30
|
+
}
|
|
31
|
+
export interface PlacedBar {
|
|
32
|
+
id: string;
|
|
33
|
+
startIndex: number;
|
|
34
|
+
span: number;
|
|
35
|
+
lane: number;
|
|
36
|
+
}
|
|
37
|
+
/** All-day events as bars across the days in view, stacked into lanes. */
|
|
38
|
+
export declare function layoutAllDay(days: readonly string[], spans: readonly DaySpan[]): PlacedBar[];
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const partsFormat = new Map();
|
|
2
|
+
function formatter(timeZone) {
|
|
3
|
+
let format = partsFormat.get(timeZone);
|
|
4
|
+
if (!format) {
|
|
5
|
+
format = new Intl.DateTimeFormat("en-CA", {
|
|
6
|
+
timeZone,
|
|
7
|
+
year: "numeric",
|
|
8
|
+
month: "2-digit",
|
|
9
|
+
day: "2-digit",
|
|
10
|
+
hour: "2-digit",
|
|
11
|
+
minute: "2-digit",
|
|
12
|
+
hourCycle: "h23",
|
|
13
|
+
});
|
|
14
|
+
partsFormat.set(timeZone, format);
|
|
15
|
+
}
|
|
16
|
+
return format;
|
|
17
|
+
}
|
|
18
|
+
export function zonedMoment(iso, timeZone) {
|
|
19
|
+
const parts = Object.fromEntries(formatter(timeZone)
|
|
20
|
+
.formatToParts(new Date(iso))
|
|
21
|
+
.map((part) => [part.type, part.value]));
|
|
22
|
+
return {
|
|
23
|
+
date: `${parts.year}-${parts.month}-${parts.day}`,
|
|
24
|
+
minute: Number(parts.hour) * 60 + Number(parts.minute),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The timed events on one day, clipped to it and laid out side by side where
|
|
29
|
+
* they overlap: each cluster of overlapping events shares its width evenly.
|
|
30
|
+
*/
|
|
31
|
+
export function layoutDay(date, spans) {
|
|
32
|
+
const onDay = spans
|
|
33
|
+
.filter((span) => span.start.date <= date && span.end.date >= date)
|
|
34
|
+
.map((span) => ({
|
|
35
|
+
id: span.id,
|
|
36
|
+
top: span.start.date < date ? 0 : span.start.minute,
|
|
37
|
+
bottom: span.end.date > date ? 1440 : span.end.minute,
|
|
38
|
+
}))
|
|
39
|
+
.filter((span) => span.bottom > span.top || span.top === span.bottom)
|
|
40
|
+
.map((span) => ({ ...span, bottom: Math.max(span.bottom, span.top + 15) }))
|
|
41
|
+
.sort((a, b) => a.top - b.top || b.bottom - a.bottom);
|
|
42
|
+
const placed = [];
|
|
43
|
+
let cluster = [];
|
|
44
|
+
let clusterEnd = -1;
|
|
45
|
+
const close = () => {
|
|
46
|
+
const columns = Math.max(0, ...cluster.map((span) => span.column)) + 1;
|
|
47
|
+
for (const span of cluster)
|
|
48
|
+
span.columns = columns;
|
|
49
|
+
placed.push(...cluster);
|
|
50
|
+
cluster = [];
|
|
51
|
+
};
|
|
52
|
+
for (const span of onDay) {
|
|
53
|
+
if (span.top >= clusterEnd && cluster.length > 0)
|
|
54
|
+
close();
|
|
55
|
+
const taken = new Set(cluster
|
|
56
|
+
.filter((other) => other.bottom > span.top)
|
|
57
|
+
.map((other) => other.column));
|
|
58
|
+
let column = 0;
|
|
59
|
+
while (taken.has(column))
|
|
60
|
+
column += 1;
|
|
61
|
+
cluster.push({ ...span, column, columns: 1 });
|
|
62
|
+
clusterEnd = Math.max(clusterEnd, span.bottom);
|
|
63
|
+
}
|
|
64
|
+
if (cluster.length > 0)
|
|
65
|
+
close();
|
|
66
|
+
return placed;
|
|
67
|
+
}
|
|
68
|
+
/** All-day events as bars across the days in view, stacked into lanes. */
|
|
69
|
+
export function layoutAllDay(days, spans) {
|
|
70
|
+
const lanes = [];
|
|
71
|
+
const bars = [];
|
|
72
|
+
const visible = spans
|
|
73
|
+
.filter((span) => span.last >= days[0] && span.first <= days[days.length - 1])
|
|
74
|
+
.sort((a, b) => a.first.localeCompare(b.first) || b.last.localeCompare(a.last));
|
|
75
|
+
for (const span of visible) {
|
|
76
|
+
const startIndex = Math.max(0, days.indexOf(span.first < days[0] ? days[0] : span.first));
|
|
77
|
+
const lastDay = span.last > days[days.length - 1] ? days[days.length - 1] : span.last;
|
|
78
|
+
const endIndex = days.indexOf(lastDay);
|
|
79
|
+
let lane = lanes.findIndex((taken) => taken.every((index) => index < startIndex || index > endIndex));
|
|
80
|
+
if (lane === -1) {
|
|
81
|
+
lane = lanes.length;
|
|
82
|
+
lanes.push([]);
|
|
83
|
+
}
|
|
84
|
+
for (let index = startIndex; index <= endIndex; index += 1)
|
|
85
|
+
lanes[lane].push(index);
|
|
86
|
+
bars.push({
|
|
87
|
+
id: span.id,
|
|
88
|
+
startIndex,
|
|
89
|
+
span: endIndex - startIndex + 1,
|
|
90
|
+
lane,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return bars;
|
|
94
|
+
}
|
package/package.json
CHANGED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { CalendarAttendee, CalendarDescriptor, CalendarEventData } from "./calendar-types.js";
|
|
2
|
-
export interface EventDetailProps {
|
|
3
|
-
event: CalendarEventData;
|
|
4
|
-
calendar: CalendarDescriptor;
|
|
5
|
-
/** Already formatted by the caller — the component owns no clock. */
|
|
6
|
-
whenText: string;
|
|
7
|
-
/**
|
|
8
|
-
* Absent where the surface cannot write yet. A control that leads nowhere is
|
|
9
|
-
* worse than no control, so the header renders each one only when it has
|
|
10
|
-
* somewhere to go.
|
|
11
|
-
*/
|
|
12
|
-
onEdit?: () => void;
|
|
13
|
-
onDelete?: () => void;
|
|
14
|
-
/** Absent when the event was never born from a mail. */
|
|
15
|
-
onOpenThread?: () => void;
|
|
16
|
-
/** Puts the pane back to whatever it shows with nothing selected. */
|
|
17
|
-
onClose?: () => void;
|
|
18
|
-
/** The guest whose context is open. Empty for none. */
|
|
19
|
-
activeAttendee?: string;
|
|
20
|
-
/** Called with a guest to open and with "" to close. Absent leaves the list inert. */
|
|
21
|
-
onActivateAttendee?: (email: string) => void;
|
|
22
|
-
/** Rendered under the open guest. The kit knows nothing about mail. */
|
|
23
|
-
renderAttendeeContext?: (attendee: CalendarAttendee) => React.ReactNode;
|
|
24
|
-
/** A thumb needs a bigger row than a pointer does. */
|
|
25
|
-
touch?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* `bare` drops the header and the scrolling frame, for a surface that already
|
|
28
|
-
* carries both — a full-screen flow whose footer holds the same actions.
|
|
29
|
-
*/
|
|
30
|
-
chrome?: "header" | "bare";
|
|
31
|
-
className?: string;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* One event, opened. The link back to the mail it came from is part of the
|
|
35
|
-
* event rather than a footnote: an event with a thread behind it is never a
|
|
36
|
-
* dead end, and the way back is one click from the detail you are reading.
|
|
37
|
-
*/
|
|
38
|
-
export declare function EventDetail({ event, calendar, whenText, onEdit, onDelete, onOpenThread, onClose, activeAttendee, onActivateAttendee, renderAttendeeContext, touch, chrome, className, }: EventDetailProps): import("react").JSX.Element;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Clock, Globe, Mail, MapPin, Pencil, Repeat, Trash2, X, } from "lucide-react";
|
|
3
|
-
import { calendarColorClasses } from "../lib/calendar-color.js";
|
|
4
|
-
import { cn } from "../lib/cn.js";
|
|
5
|
-
import { AttendeeList, RsvpBadge } from "./attendee-row.js";
|
|
6
|
-
import { Button } from "./button.js";
|
|
7
|
-
function Line({ icon, children, }) {
|
|
8
|
-
return (_jsxs("div", { className: "flex items-start gap-2.5 py-1", children: [_jsx("span", { className: "mt-0.5 shrink-0 text-fg-subtle", children: icon }), _jsx("div", { className: "min-w-0 flex-1 text-sm text-fg", children: children })] }));
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* One event, opened. The link back to the mail it came from is part of the
|
|
12
|
-
* event rather than a footnote: an event with a thread behind it is never a
|
|
13
|
-
* dead end, and the way back is one click from the detail you are reading.
|
|
14
|
-
*/
|
|
15
|
-
export function EventDetail({ event, calendar, whenText, onEdit, onDelete, onOpenThread, onClose, activeAttendee = "", onActivateAttendee, renderAttendeeContext, touch = false, chrome = "header", className, }) {
|
|
16
|
-
const hue = calendarColorClasses(calendar.color);
|
|
17
|
-
const facts = (_jsxs(_Fragment, { children: [_jsx("h1", { className: "text-xl font-semibold text-fg", children: event.title }), _jsxs("div", { className: "mt-3 flex flex-col border-b border-line pb-3", children: [_jsx(Line, { icon: _jsx(Clock, { className: "size-4" }), children: _jsxs("span", { className: "flex flex-wrap items-center gap-2", children: [whenText, event.attendees.length > 0 && _jsx(RsvpBadge, { rsvp: event.myRsvp })] }) }), event.zoneCertainty === "ambiguous" ? (_jsx(Line, { icon: _jsx(Globe, { className: "size-4 text-warning" }), children: _jsx("span", { className: "text-warning", children: "The mail said a time but never a zone. Shown in your own; confirm before you travel for it." }) })) : (event.timeZone !== "" && (_jsx(Line, { icon: _jsx(Globe, { className: "size-4" }), children: event.timeZone }))), event.recurrenceRule !== "" && (_jsx(Line, { icon: _jsx(Repeat, { className: "size-4" }), children: _jsxs("span", { className: "flex flex-wrap items-center gap-2", children: [event.recurrenceRule, event.seriesException && (_jsx("span", { className: "rounded-xs bg-warning-soft px-1.5 py-0.5 text-2xs text-warning", children: "Moved out of the series" }))] }) })), event.location !== "" && (_jsx(Line, { icon: _jsx(MapPin, { className: "size-4" }), children: event.location }))] }), event.threadId !== "" && onOpenThread && (_jsxs("button", { type: "button", onClick: onOpenThread, className: "mt-3 flex w-full items-center gap-2.5 rounded-md border border-line bg-surface-sunken px-3 py-2 text-left outline-none hover:border-line-strong focus-visible:ring-2 focus-visible:ring-ring", children: [_jsx(Mail, { className: "size-4 shrink-0 text-accent-2" }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "block text-2xs uppercase tracking-wider text-fg-subtle", children: "From this thread" }), _jsx("span", { className: "block truncate text-sm text-fg", children: event.threadSubject })] })] })), event.attendees.length > 0 && (_jsx(AttendeeList, { attendees: event.attendees, activeEmail: activeAttendee, onActivate: onActivateAttendee, renderContext: renderAttendeeContext, touch: touch, className: "mt-3" })), event.notes !== "" && (_jsx("p", { className: "mt-3 whitespace-pre-wrap text-sm text-fg-muted", children: event.notes }))] }));
|
|
18
|
-
if (chrome === "bare")
|
|
19
|
-
return _jsx("div", { className: cn("flex flex-col", className), children: facts });
|
|
20
|
-
return (_jsxs("article", { className: cn("flex h-full w-full flex-col bg-surface", className), children: [_jsxs("header", { className: "flex h-pane-header shrink-0 items-center gap-2 border-b border-line px-row-inset", children: [_jsx("span", { className: cn("size-2.5 shrink-0 rounded-full", hue.solid) }), _jsxs("span", { className: "min-w-0 flex-1 truncate text-xs text-fg-muted", children: [calendar.name, " \u00B7 ", calendar.accountLabel] }), onEdit && (_jsx(Button, { variant: "ghost", size: "sm", icon: _jsx(Pencil, { className: "size-3.5" }), onClick: onEdit, children: "Edit" })), onDelete && (_jsx(Button, { variant: "ghost", size: "sm", icon: _jsx(Trash2, { className: "size-3.5" }), onClick: onDelete, className: "text-danger", children: "Delete" })), onClose && (_jsx("button", { type: "button", "aria-label": "Close event", onClick: onClose, className: "flex size-7 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring", children: _jsx(X, { className: "size-4" }) }))] }), _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto px-row-inset py-3", children: facts })] }));
|
|
21
|
-
}
|