calendar-components-core 0.0.0-stage → 0.7.3
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/LICENSE +21 -0
- package/README.md +7 -2
- package/dist/index.d.ts +292 -0
- package/dist/index.js +312 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Brian Hung
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# calendar-components-core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Framework-neutral calendar state and layout: days, time grids, overlapping
|
|
4
|
+
events, keyboard movement and locale. Its one dependency is
|
|
5
|
+
`@internationalized/date`, React Aria's date library.
|
|
6
|
+
|
|
7
|
+
It is what [`calendar-components`](https://www.npmjs.com/package/calendar-components)
|
|
8
|
+
(React parts and hooks) is built on. Docs: https://calendar.brianhung.me
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
export { getLocalTimeZone } from '@internationalized/date';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Calendar days as "YYYY-MM-DD" strings at the edges, and
|
|
5
|
+
* `@internationalized/date` (React Aria's date library) for the arithmetic:
|
|
6
|
+
* a day is a name, not an instant, so no time zone can shift it, and a
|
|
7
|
+
* week starts where the reader's locale starts it.
|
|
8
|
+
*/
|
|
9
|
+
type DateString = string;
|
|
10
|
+
declare const addDays: (date: DateString, days: number) => DateString;
|
|
11
|
+
/** 0 is Sunday. */
|
|
12
|
+
declare const weekdayOf: (date: DateString) => number;
|
|
13
|
+
/** The first day of the week `date` is in, as `locale` counts weeks: Sunday in the US, Monday in Britain, Saturday in Egypt. */
|
|
14
|
+
declare const startOfWeek: (date: DateString, locale?: string) => DateString;
|
|
15
|
+
/** `count` days in a row from `from`. */
|
|
16
|
+
declare const daysFrom: (from: DateString, count: number) => DateString[];
|
|
17
|
+
/** A day as a Date at this device's midnight, for Intl to put into words. */
|
|
18
|
+
declare const toLocalDate: (date: DateString) => Date;
|
|
19
|
+
/**
|
|
20
|
+
* Today, and the minutes past midnight it is now, in a time zone (an IANA
|
|
21
|
+
* name; this device's when left out). A trip's calendar is in the trip's
|
|
22
|
+
* zone: "now" in Tokyo is Tokyo's, wherever it is read.
|
|
23
|
+
*/
|
|
24
|
+
declare function nowOf(timeZone?: string): {
|
|
25
|
+
date: DateString;
|
|
26
|
+
minutes: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Where events that overlap in time sit side by side, as a calendar's day
|
|
31
|
+
* column draws them: each event gets a lane, and a group of events that
|
|
32
|
+
* overlap one another share the column's width between their lanes.
|
|
33
|
+
*/
|
|
34
|
+
interface Span {
|
|
35
|
+
start: number;
|
|
36
|
+
end: number;
|
|
37
|
+
}
|
|
38
|
+
interface Placed<T> {
|
|
39
|
+
event: T;
|
|
40
|
+
/** 0 is leftmost. */
|
|
41
|
+
lane: number;
|
|
42
|
+
/** How many lanes its group has: its width is 1/lanes of the column. */
|
|
43
|
+
lanes: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The one order events are in, wherever they are ordered: by when they start, and of two that start
|
|
47
|
+
* together the longer first. It is the order they are drawn in, so it is the order the arrow keys go in.
|
|
48
|
+
*/
|
|
49
|
+
declare const compareEvents: (a: Span, b: Span) => number;
|
|
50
|
+
/**
|
|
51
|
+
* Where an event sits across its day, as fractions of the day's width: it starts at its lane, and is as
|
|
52
|
+
* wide as a lane and `overlap` of the next (Google Calendar's is 0.7, so each event runs under the one
|
|
53
|
+
* after it), never past the day's far edge. With no overlap the lanes share the width.
|
|
54
|
+
*/
|
|
55
|
+
declare function laneBox(lane: number, lanes: number, overlap?: number): {
|
|
56
|
+
start: number;
|
|
57
|
+
width: number;
|
|
58
|
+
};
|
|
59
|
+
declare function lanesOf<T extends Span>(events: readonly T[]): Placed<T>[];
|
|
60
|
+
|
|
61
|
+
/** An event in a day: when it starts and ends, in minutes past that day's midnight (`end` may pass 24 hours), and an id. */
|
|
62
|
+
interface CalendarEvent extends Span {
|
|
63
|
+
id: string;
|
|
64
|
+
}
|
|
65
|
+
/** A day and what happens in it. `allDay` are the day's own, at no set time. */
|
|
66
|
+
interface CalendarDay<E extends CalendarEvent = CalendarEvent, A extends {
|
|
67
|
+
id: string;
|
|
68
|
+
} = {
|
|
69
|
+
id: string;
|
|
70
|
+
}> {
|
|
71
|
+
date: DateString;
|
|
72
|
+
events: readonly E[];
|
|
73
|
+
allDay?: readonly A[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** What a calendar shows at a time. */
|
|
77
|
+
type CalendarView = "day" | "week" | "month";
|
|
78
|
+
/**
|
|
79
|
+
* A time as an app or its database keeps one: a `Date`, or an ISO 8601 string. A string that ends in "Z" or
|
|
80
|
+
* an offset ("2026-11-23T15:00:00Z") is an instant, read in the calendar's time zone; one with neither
|
|
81
|
+
* ("2026-11-23T07:00") is that time on the wall wherever it is read; a day alone ("2026-11-23") is a day.
|
|
82
|
+
*/
|
|
83
|
+
type EventTime = Date | string;
|
|
84
|
+
/**
|
|
85
|
+
* An event as an app keeps it: in a list, with when it starts and ends. It lasts the day (or days: `end` is
|
|
86
|
+
* the day after its last, as iCalendar and Google Calendar count) when `allDay` is set or `start` is a day
|
|
87
|
+
* alone.
|
|
88
|
+
*/
|
|
89
|
+
interface PlannedEvent {
|
|
90
|
+
id: string;
|
|
91
|
+
start: EventTime;
|
|
92
|
+
/** Left out, an event at a time lasts an hour and an all-day one a day. */
|
|
93
|
+
end?: EventTime;
|
|
94
|
+
allDay?: boolean;
|
|
95
|
+
}
|
|
96
|
+
/** The time zone a list's instants are read in. */
|
|
97
|
+
interface TimeZoneOptions {
|
|
98
|
+
/** An IANA name. @default this device's */
|
|
99
|
+
timeZone?: string;
|
|
100
|
+
}
|
|
101
|
+
/** The same day so many months on (or back), kept inside the month it lands in: a month on from January 31 is the last of February. */
|
|
102
|
+
declare const addMonths: (date: DateString, months: number) => DateString;
|
|
103
|
+
/** The day a view shows after one: a day, a week or a month on (or, with a negative `by`, back). */
|
|
104
|
+
declare const stepDate: (view: CalendarView, date: DateString, by: number) => DateString;
|
|
105
|
+
/**
|
|
106
|
+
* The days a view draws round a day: the day, its week as `locale` counts weeks, or its month with the
|
|
107
|
+
* weeks it begins and ends in drawn whole.
|
|
108
|
+
*/
|
|
109
|
+
declare function datesIn(view: CalendarView, date: DateString, locale?: string): DateString[];
|
|
110
|
+
/** The first and last day an event is on, in a time zone: for an all-day one, `end` is the day after its last. */
|
|
111
|
+
declare function eventSpan(event: PlannedEvent, { timeZone }?: TimeZoneOptions): {
|
|
112
|
+
first: DateString;
|
|
113
|
+
last: DateString;
|
|
114
|
+
};
|
|
115
|
+
/** An event of a list as a day holds it: all the app's own fields, and its times as minutes past the day's midnight. */
|
|
116
|
+
type PlacedEvent<E> = Omit<E, "start" | "end"> & CalendarEvent;
|
|
117
|
+
/**
|
|
118
|
+
* A list of events as the days a calendar draws: each of `dates` with its timed events and its all-day
|
|
119
|
+
* ones, in the order they were given. What `TimeGrid`, `Agenda` and a month take. An event at a time is
|
|
120
|
+
* on the day it starts (one that runs past midnight ends after 24 hours); an all-day one is on each day it
|
|
121
|
+
* lasts. Events outside `dates` are left out, so the list can be more than is shown.
|
|
122
|
+
*/
|
|
123
|
+
declare function groupByDay<E extends PlannedEvent>(events: readonly E[], dates: readonly DateString[], { timeZone }?: TimeZoneOptions): CalendarDay<PlacedEvent<E>, E>[];
|
|
124
|
+
/** Where a grid says an event now is: its day, and minutes past that day's midnight. What `onEventChange` gives. */
|
|
125
|
+
interface EventChange {
|
|
126
|
+
id: string;
|
|
127
|
+
date: DateString;
|
|
128
|
+
start: number;
|
|
129
|
+
end: number;
|
|
130
|
+
}
|
|
131
|
+
/** A change's times as instants, to send to a server: `updateEvent(change.id, eventTimes(change))`. */
|
|
132
|
+
declare function eventTimes(change: Omit<EventChange, "id">, { timeZone }?: TimeZoneOptions): {
|
|
133
|
+
start: Date;
|
|
134
|
+
end: Date;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* The list with an event put where a change says it now is: what a grid's `onEventChange` tells of a drag,
|
|
138
|
+
* a resize or a move by the keyboard. Its times stay as they were kept: `Date`s stay `Date`s, strings strings.
|
|
139
|
+
*/
|
|
140
|
+
declare const applyEventChange: <E extends PlannedEvent>(events: readonly E[], change: EventChange, { timeZone }?: TimeZoneOptions) => E[];
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* What comes with a change, as Base UI's change details: why it happened,
|
|
144
|
+
* the element it came from when there is one, and a way for the owner to
|
|
145
|
+
* refuse it. (React Aria hands its press and selection on without the
|
|
146
|
+
* browser's event, so there is none here.)
|
|
147
|
+
*/
|
|
148
|
+
interface ChangeDetails<Reason extends string = string> {
|
|
149
|
+
reason: Reason;
|
|
150
|
+
trigger: Element | undefined;
|
|
151
|
+
/** Keeps what was there: the change is not made. */
|
|
152
|
+
cancel(): void;
|
|
153
|
+
readonly isCanceled: boolean;
|
|
154
|
+
}
|
|
155
|
+
declare function createChangeDetails<Reason extends string>(reason: Reason, trigger?: Element): ChangeDetails<Reason>;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* An event dragged: moved whole, or its end pulled. Deltas are in minutes
|
|
159
|
+
* and days; the result keeps to the grid's step and to the day.
|
|
160
|
+
*/
|
|
161
|
+
interface Drag {
|
|
162
|
+
/** Minutes the start has moved. */
|
|
163
|
+
start: number;
|
|
164
|
+
/** Minutes the end has moved. */
|
|
165
|
+
end: number;
|
|
166
|
+
/** Days moved, towards later. */
|
|
167
|
+
days: number;
|
|
168
|
+
}
|
|
169
|
+
/** The minutes of the day a drag keeps an event within: the hours a grid draws, or the whole day. */
|
|
170
|
+
interface Bounds {
|
|
171
|
+
from: number;
|
|
172
|
+
to: number;
|
|
173
|
+
}
|
|
174
|
+
/** The event moved by `minutes`, to the step: as long as it was, and inside the bounds. */
|
|
175
|
+
declare function moved(event: Span, minutes: number, step: number, { from, to }?: Bounds): Span;
|
|
176
|
+
/** The event with its end pulled by `minutes`, to the step: never shorter than a step, never past the bounds. */
|
|
177
|
+
declare function resized(event: Span, minutes: number, step: number, { to }?: Bounds): Span;
|
|
178
|
+
/** The day `days` on from `index` among `count`, kept among them. */
|
|
179
|
+
declare const dayAt: (index: number, days: number, count: number) => number;
|
|
180
|
+
|
|
181
|
+
/** The hours a grid draws, as whole hours past midnight: `to` is exclusive and may pass 24. */
|
|
182
|
+
interface HourRange {
|
|
183
|
+
from: number;
|
|
184
|
+
to: number;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The hours to draw for some events: `pad` hours either side of them, never
|
|
188
|
+
* fewer than `least` when there are none or they are few.
|
|
189
|
+
*/
|
|
190
|
+
declare function hoursOf(spans: readonly Span[], { pad, least }?: {
|
|
191
|
+
pad?: number;
|
|
192
|
+
least?: HourRange;
|
|
193
|
+
}): HourRange;
|
|
194
|
+
/** How far down a grid a time is, in the grid's units, given what an hour is tall. */
|
|
195
|
+
declare const offsetOf: (minutes: number, range: HourRange, hourHeight: number) => number;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* What a locale says about a calendar: which day a week starts on, which days are its weekend, and its
|
|
199
|
+
* words for hours, times and days. All from the date library and Intl; nothing is bundled. Which way a
|
|
200
|
+
* locale reads is React Aria's to say (`useLocale().direction`, `isRTL`).
|
|
201
|
+
*/
|
|
202
|
+
interface LocaleInfo {
|
|
203
|
+
locale: string;
|
|
204
|
+
/** 0 is Sunday. */
|
|
205
|
+
firstDayOfWeek: number;
|
|
206
|
+
/** The days of the weekend there; 0 is Sunday. */
|
|
207
|
+
weekend: readonly number[];
|
|
208
|
+
}
|
|
209
|
+
/** What a locale says, worked out once for each: every day and cell asks. */
|
|
210
|
+
declare function localeInfo(locale: string): LocaleInfo;
|
|
211
|
+
/** An hour as a grid labels it: "9 AM", "09". */
|
|
212
|
+
declare const formatHour: (locale: string, hour: number) => string;
|
|
213
|
+
/** An hour in its parts, for a label that sets them apart: "7" and "AM"; `dayPeriod` is empty on a 24-hour clock. */
|
|
214
|
+
declare function formatHourParts(locale: string, hour: number): {
|
|
215
|
+
hour: string;
|
|
216
|
+
dayPeriod: string;
|
|
217
|
+
};
|
|
218
|
+
/** A time of day from minutes past midnight: "9:30 AM", "09:30". */
|
|
219
|
+
declare const formatTime: (locale: string, minutes: number) => string;
|
|
220
|
+
/**
|
|
221
|
+
* A time in its parts, for a label that sets the day period apart (iOS
|
|
222
|
+
* writes "7:00" and a small "AM"): `time` is the clock without it, and
|
|
223
|
+
* `dayPeriod` is empty on a 24-hour clock.
|
|
224
|
+
*/
|
|
225
|
+
declare function formatTimeParts(locale: string, minutes: number): {
|
|
226
|
+
time: string;
|
|
227
|
+
dayPeriod: string;
|
|
228
|
+
};
|
|
229
|
+
/** A day's parts for a column header ("Sun", "22"), and its whole name for a screen reader. */
|
|
230
|
+
declare function formatDay(locale: string, date: Date): {
|
|
231
|
+
weekday: string;
|
|
232
|
+
day: string;
|
|
233
|
+
full: string;
|
|
234
|
+
};
|
|
235
|
+
/** The words a grid says that are not dates or times. Pass your own to translate them. */
|
|
236
|
+
interface CalendarLabels {
|
|
237
|
+
allDay: string;
|
|
238
|
+
/** An event with its times, as a sentence: for an announcement. */
|
|
239
|
+
event: (name: string, from: string, to: string) => string;
|
|
240
|
+
/** When an event is, said after its name: "9:30 AM to 11:00 AM". */
|
|
241
|
+
timeRange: (from: string, to: string) => string;
|
|
242
|
+
/** A day's name when it is today: "Monday, November 23, today". */
|
|
243
|
+
dayToday: (day: string) => string;
|
|
244
|
+
/** The all-day part of a day: "all-day, Monday, November 23". */
|
|
245
|
+
allDayOf: (day: string) => string;
|
|
246
|
+
/** Said when an event has been moved or resized: its name, the day's full name, and its new times. */
|
|
247
|
+
changed: (name: string, day: string, from: string, to: string) => string;
|
|
248
|
+
/** Things said one after another, joined as the language joins them: "Thanksgiving, all-day". */
|
|
249
|
+
list: (parts: readonly string[]) => string;
|
|
250
|
+
/** The name of the handle that resizes an event. */
|
|
251
|
+
resize: string;
|
|
252
|
+
/** What 12 o'clock midday is called, where a calendar says so: "Noon". Left out, it is the hour like any other. */
|
|
253
|
+
noon?: string;
|
|
254
|
+
}
|
|
255
|
+
declare const LABELS: CalendarLabels;
|
|
256
|
+
/**
|
|
257
|
+
* The words a calendar says, for a locale. English has its own sentences.
|
|
258
|
+
* Every other language is put together from what Intl knows of it (its word
|
|
259
|
+
* for today, how it separates the parts of a list) round the dates and times
|
|
260
|
+
* it has already formatted, so nothing is said in English; pass `labels` for
|
|
261
|
+
* sentences of your own.
|
|
262
|
+
*/
|
|
263
|
+
declare function labelsFor(locale: string): CalendarLabels;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Where the keyboard goes from an event in a time grid. A day reads from the
|
|
267
|
+
* top: its all-day events in the order given, then its timed ones in time
|
|
268
|
+
* order, and up and down go through that. Sideways from a timed event is the
|
|
269
|
+
* event nearest in time on the next day that has any; from an all-day one,
|
|
270
|
+
* that day's first all-day event. First and last are of its own kind in its day.
|
|
271
|
+
*/
|
|
272
|
+
type Move = "previous" | "next" | "previous-day" | "next-day" | "first" | "last";
|
|
273
|
+
/** A day as the keyboard goes through it: a `CalendarDay` is one. */
|
|
274
|
+
interface NavigationDay {
|
|
275
|
+
events: readonly CalendarEvent[];
|
|
276
|
+
allDay?: readonly {
|
|
277
|
+
id: string;
|
|
278
|
+
}[];
|
|
279
|
+
}
|
|
280
|
+
declare function moveFrom(days: readonly NavigationDay[], id: string, move: Move): string | null;
|
|
281
|
+
|
|
282
|
+
type Listener = () => void;
|
|
283
|
+
/** A value that can be read, replaced and watched: what a framework binds to. */
|
|
284
|
+
interface Store<State> {
|
|
285
|
+
getSnapshot(): State;
|
|
286
|
+
subscribe(listener: Listener): () => void;
|
|
287
|
+
/** Merges the fields in; listeners hear only a real change. */
|
|
288
|
+
set(fields: Partial<State>): void;
|
|
289
|
+
}
|
|
290
|
+
declare function createStore<State extends object>(initial: State): Store<State>;
|
|
291
|
+
|
|
292
|
+
export { type Bounds, type CalendarDay, type CalendarEvent, type CalendarLabels, type CalendarView, type ChangeDetails, type DateString, type Drag, type EventChange, type EventTime, type HourRange, LABELS, type Listener, type LocaleInfo, type Move, type NavigationDay, type Placed, type PlacedEvent, type PlannedEvent, type Span, type Store, type TimeZoneOptions, addDays, addMonths, applyEventChange, compareEvents, createChangeDetails, createStore, datesIn, dayAt, daysFrom, eventSpan, eventTimes, formatDay, formatHour, formatHourParts, formatTime, formatTimeParts, groupByDay, hoursOf, labelsFor, laneBox, lanesOf, localeInfo, moveFrom, moved, nowOf, offsetOf, resized, startOfWeek, stepDate, toLocalDate, weekdayOf };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
// src/calendar.ts
|
|
2
|
+
import { endOfMonth, fromDate, getLocalTimeZone as getLocalTimeZone2, parseAbsolute, parseDate as parseDate2, parseDateTime, startOfMonth, toCalendarDate, toCalendarDateTime, toZoned } from "@internationalized/date";
|
|
3
|
+
|
|
4
|
+
// src/dates.ts
|
|
5
|
+
import { getDayOfWeek, getLocalTimeZone, now, parseDate, startOfWeek as startOfLocaleWeek } from "@internationalized/date";
|
|
6
|
+
var addDays = (date, days) => parseDate(date).add({ days }).toString();
|
|
7
|
+
var weekdayOf = (date) => getDayOfWeek(parseDate(date), "en-US");
|
|
8
|
+
var startOfWeek = (date, locale = "en-US") => startOfLocaleWeek(parseDate(date), locale).toString();
|
|
9
|
+
var daysFrom = (from, count) => Array.from({ length: count }, (_, i) => addDays(from, i));
|
|
10
|
+
var toLocalDate = (date) => {
|
|
11
|
+
const { year, month, day } = parseDate(date);
|
|
12
|
+
return new Date(year, month - 1, day);
|
|
13
|
+
};
|
|
14
|
+
function nowOf(timeZone = getLocalTimeZone()) {
|
|
15
|
+
const at = now(timeZone);
|
|
16
|
+
return { date: `${at.year}-${String(at.month).padStart(2, "0")}-${String(at.day).padStart(2, "0")}`, minutes: at.hour * 60 + at.minute };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/calendar.ts
|
|
20
|
+
var INSTANT = /(?:Z|[+-]\d{2}:?\d{2})$/i;
|
|
21
|
+
var isDay = (time) => typeof time === "string" && time.length === 10;
|
|
22
|
+
function onTheWall(time, zone) {
|
|
23
|
+
if (time instanceof Date) return toCalendarDateTime(fromDate(time, zone));
|
|
24
|
+
if (isDay(time)) return toCalendarDateTime(parseDate2(time));
|
|
25
|
+
return INSTANT.test(time) ? toCalendarDateTime(parseAbsolute(time, zone)) : parseDateTime(time);
|
|
26
|
+
}
|
|
27
|
+
var timeOn = (date, minutes) => toCalendarDateTime(parseDate2(date)).add({ minutes });
|
|
28
|
+
var minutesOf = (time) => time.hour * 60 + time.minute;
|
|
29
|
+
var addMonths = (date, months) => parseDate2(date).add({ months }).toString();
|
|
30
|
+
var stepDate = (view, date, by) => view === "month" ? addMonths(date, by) : addDays(date, by * (view === "day" ? 1 : 7));
|
|
31
|
+
function datesIn(view, date, locale = "en-US") {
|
|
32
|
+
if (view === "day") return [date];
|
|
33
|
+
if (view === "week") return daysFrom(startOfWeek(date, locale), 7);
|
|
34
|
+
const first = startOfWeek(startOfMonth(parseDate2(date)).toString(), locale);
|
|
35
|
+
const last = addDays(startOfWeek(endOfMonth(parseDate2(date)).toString(), locale), 6);
|
|
36
|
+
const dates = [];
|
|
37
|
+
for (let each = first; each <= last; each = addDays(each, 1)) dates.push(each);
|
|
38
|
+
return dates;
|
|
39
|
+
}
|
|
40
|
+
function eventSpan(event, { timeZone = getLocalTimeZone2() } = {}) {
|
|
41
|
+
const first = toCalendarDate(onTheWall(event.start, timeZone));
|
|
42
|
+
const end = event.end === void 0 ? first : toCalendarDate(onTheWall(event.end, timeZone));
|
|
43
|
+
const allDay = event.allDay ?? isDay(event.start);
|
|
44
|
+
const last = allDay && end.compare(first) > 0 ? end.subtract({ days: 1 }) : end.compare(first) > 0 ? end : first;
|
|
45
|
+
return { first: first.toString(), last: last.toString() };
|
|
46
|
+
}
|
|
47
|
+
function groupByDay(events, dates, { timeZone = getLocalTimeZone2() } = {}) {
|
|
48
|
+
const days = new Map(dates.map((date) => [date, { date, events: [], allDay: [] }]));
|
|
49
|
+
for (const event of events) {
|
|
50
|
+
const start = onTheWall(event.start, timeZone);
|
|
51
|
+
const first = toCalendarDate(start);
|
|
52
|
+
if (event.allDay ?? isDay(event.start)) {
|
|
53
|
+
const length = event.end === void 0 ? 1 : Math.max(1, toCalendarDate(onTheWall(event.end, timeZone)).compare(first));
|
|
54
|
+
for (let i = 0; i < length; i++) days.get(first.add({ days: i }).toString())?.allDay.push(event);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const day = days.get(first.toString());
|
|
58
|
+
if (!day) continue;
|
|
59
|
+
const from = minutesOf(start);
|
|
60
|
+
const end = event.end === void 0 ? void 0 : onTheWall(event.end, timeZone);
|
|
61
|
+
day.events.push({ ...event, start: from, end: end ? toCalendarDate(end).compare(first) * 1440 + minutesOf(end) : from + 60 });
|
|
62
|
+
}
|
|
63
|
+
return [...days.values()];
|
|
64
|
+
}
|
|
65
|
+
function eventTimes(change, { timeZone = getLocalTimeZone2() } = {}) {
|
|
66
|
+
return { start: toZoned(timeOn(change.date, change.start), timeZone).toDate(), end: toZoned(timeOn(change.date, change.end), timeZone).toDate() };
|
|
67
|
+
}
|
|
68
|
+
function written(time, like, zone) {
|
|
69
|
+
if (like instanceof Date) return toZoned(time, zone).toDate();
|
|
70
|
+
return INSTANT.test(like) ? toZoned(time, zone).toAbsoluteString() : time.toString();
|
|
71
|
+
}
|
|
72
|
+
var applyEventChange = (events, change, { timeZone = getLocalTimeZone2() } = {}) => events.map((event) => event.id === change.id ? { ...event, start: written(timeOn(change.date, change.start), event.start, timeZone), end: written(timeOn(change.date, change.end), event.end ?? event.start, timeZone) } : event);
|
|
73
|
+
|
|
74
|
+
// src/change.ts
|
|
75
|
+
function createChangeDetails(reason, trigger) {
|
|
76
|
+
let canceled = false;
|
|
77
|
+
return {
|
|
78
|
+
reason,
|
|
79
|
+
trigger,
|
|
80
|
+
cancel: () => void (canceled = true),
|
|
81
|
+
get isCanceled() {
|
|
82
|
+
return canceled;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/drag.ts
|
|
88
|
+
var DAY = 24 * 60;
|
|
89
|
+
var snap = (minutes, step) => Math.round(minutes / step) * step;
|
|
90
|
+
var WHOLE_DAY = { from: 0, to: DAY };
|
|
91
|
+
function moved(event, minutes, step, { from, to } = WHOLE_DAY) {
|
|
92
|
+
const length = event.end - event.start;
|
|
93
|
+
const start = Math.min(Math.max(from, snap(event.start + minutes, step)), Math.max(from, to - length));
|
|
94
|
+
return { start, end: start + length };
|
|
95
|
+
}
|
|
96
|
+
function resized(event, minutes, step, { to } = WHOLE_DAY) {
|
|
97
|
+
return { start: event.start, end: Math.min(Math.max(to, event.start + step), Math.max(event.start + step, snap(event.end + minutes, step))) };
|
|
98
|
+
}
|
|
99
|
+
var dayAt = (index, days, count) => Math.min(count - 1, Math.max(0, index + days));
|
|
100
|
+
|
|
101
|
+
// src/hours.ts
|
|
102
|
+
function hoursOf(spans, { pad = 1, least = { from: 8, to: 18 } } = {}) {
|
|
103
|
+
if (!spans.length) return least;
|
|
104
|
+
const first = Math.min(...spans.map((s) => s.start));
|
|
105
|
+
const last = Math.max(...spans.map((s) => s.end));
|
|
106
|
+
return { from: Math.max(0, Math.floor(first / 60) - pad), to: Math.min(30, Math.ceil(last / 60) + pad) };
|
|
107
|
+
}
|
|
108
|
+
var offsetOf = (minutes, range, hourHeight) => (minutes - range.from * 60) / 60 * hourHeight;
|
|
109
|
+
|
|
110
|
+
// src/layout.ts
|
|
111
|
+
var compareEvents = (a, b) => a.start - b.start || b.end - a.end;
|
|
112
|
+
function laneBox(lane, lanes, overlap = 0) {
|
|
113
|
+
const start = lane / lanes;
|
|
114
|
+
return { start, width: Math.min((1 + overlap) / lanes, 1 - start) };
|
|
115
|
+
}
|
|
116
|
+
function lanesOf(events) {
|
|
117
|
+
const sorted = [...events].sort(compareEvents);
|
|
118
|
+
const placed = [];
|
|
119
|
+
let group = [];
|
|
120
|
+
let groupEnd = -Infinity;
|
|
121
|
+
let free = [];
|
|
122
|
+
const close = () => {
|
|
123
|
+
for (const item of group) item.lanes = free.length;
|
|
124
|
+
group = [];
|
|
125
|
+
free = [];
|
|
126
|
+
};
|
|
127
|
+
for (const event of sorted) {
|
|
128
|
+
if (event.start >= groupEnd) close();
|
|
129
|
+
let lane = free.findIndex((end) => end <= event.start);
|
|
130
|
+
if (lane === -1) lane = free.length;
|
|
131
|
+
free[lane] = event.end;
|
|
132
|
+
groupEnd = Math.max(groupEnd, event.end);
|
|
133
|
+
const item = { event, lane, lanes: 1 };
|
|
134
|
+
group.push(item);
|
|
135
|
+
placed.push(item);
|
|
136
|
+
}
|
|
137
|
+
close();
|
|
138
|
+
return placed;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// src/locale.ts
|
|
142
|
+
import { CalendarDate, DateFormatter, getDayOfWeek as getDayOfWeek2, isWeekend, startOfWeek as startOfWeek2 } from "@internationalized/date";
|
|
143
|
+
var WEEK = Array.from({ length: 7 }, (_, i) => new CalendarDate(2023, 1, 1 + i));
|
|
144
|
+
var known = /* @__PURE__ */ new Map();
|
|
145
|
+
function localeInfo(locale) {
|
|
146
|
+
const had = known.get(locale);
|
|
147
|
+
if (had) return had;
|
|
148
|
+
const info = readLocale(locale);
|
|
149
|
+
known.set(locale, info);
|
|
150
|
+
return info;
|
|
151
|
+
}
|
|
152
|
+
function readLocale(locale) {
|
|
153
|
+
return {
|
|
154
|
+
locale,
|
|
155
|
+
// Which day a week starts on, and which days are the weekend, are the date library's to know.
|
|
156
|
+
firstDayOfWeek: getDayOfWeek2(startOfWeek2(WEEK[3], locale), "en-US"),
|
|
157
|
+
weekend: WEEK.flatMap((day, weekday) => isWeekend(day, locale) ? [weekday] : [])
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
var format = (locale, options) => new DateFormatter(locale, options);
|
|
161
|
+
var clock = (minutes) => new Date(2e3, 0, 1, 0, minutes);
|
|
162
|
+
var formatHour = (locale, hour) => format(locale, { hour: "numeric" }).format(clock(hour % 24 * 60));
|
|
163
|
+
function formatHourParts(locale, hour) {
|
|
164
|
+
const parts = format(locale, { hour: "numeric" }).formatToParts(clock(hour % 24 * 60));
|
|
165
|
+
return { hour: parts.find((part) => part.type === "hour")?.value ?? "", dayPeriod: parts.find((part) => part.type === "dayPeriod")?.value ?? "" };
|
|
166
|
+
}
|
|
167
|
+
var formatTime = (locale, minutes) => format(locale, { hour: "numeric", minute: "2-digit" }).format(clock(minutes % 1440));
|
|
168
|
+
function formatTimeParts(locale, minutes) {
|
|
169
|
+
const parts = format(locale, { hour: "numeric", minute: "2-digit" }).formatToParts(clock(minutes % 1440));
|
|
170
|
+
return {
|
|
171
|
+
time: parts.filter((part) => part.type !== "dayPeriod").map((part) => part.value).join("").trim(),
|
|
172
|
+
dayPeriod: parts.find((part) => part.type === "dayPeriod")?.value ?? ""
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function formatDay(locale, date) {
|
|
176
|
+
return { weekday: format(locale, { weekday: "short" }).format(date), day: format(locale, { day: "numeric" }).format(date), full: format(locale, { weekday: "long", month: "long", day: "numeric" }).format(date) };
|
|
177
|
+
}
|
|
178
|
+
var LABELS = {
|
|
179
|
+
allDay: "all-day",
|
|
180
|
+
event: (name, from, to) => `${name}, ${from} to ${to}`,
|
|
181
|
+
timeRange: (from, to) => `${from} to ${to}`,
|
|
182
|
+
dayToday: (day) => `${day}, today`,
|
|
183
|
+
allDayOf: (day) => `all-day, ${day}`,
|
|
184
|
+
changed: (name, day, from, to) => `${name} is now ${day}, ${from} to ${to}`,
|
|
185
|
+
list: (parts) => parts.join(", "),
|
|
186
|
+
resize: "Resize"
|
|
187
|
+
};
|
|
188
|
+
var ALL_DAY = {
|
|
189
|
+
en: "all-day",
|
|
190
|
+
es: "todo el d\xEDa",
|
|
191
|
+
fr: "toute la journ\xE9e",
|
|
192
|
+
de: "ganzt\xE4gig",
|
|
193
|
+
it: "tutto il giorno",
|
|
194
|
+
pt: "o dia todo",
|
|
195
|
+
nl: "hele dag",
|
|
196
|
+
ru: "\u0432\u0435\u0441\u044C \u0434\u0435\u043D\u044C",
|
|
197
|
+
ja: "\u7D42\u65E5",
|
|
198
|
+
ko: "\uC885\uC77C",
|
|
199
|
+
zh: "\u5168\u5929",
|
|
200
|
+
"zh-Hant": "\u6574\u5929",
|
|
201
|
+
ar: "\u0637\u0648\u0627\u0644 \u0627\u0644\u064A\u0648\u0645",
|
|
202
|
+
he: "\u05DB\u05DC \u05D4\u05D9\u05D5\u05DD",
|
|
203
|
+
hi: "\u092A\u0942\u0930\u0947 \u0926\u093F\u0928"
|
|
204
|
+
};
|
|
205
|
+
var built = /* @__PURE__ */ new Map();
|
|
206
|
+
function labelsFor(locale) {
|
|
207
|
+
const had = built.get(locale);
|
|
208
|
+
if (had) return had;
|
|
209
|
+
const tag = new Intl.Locale(locale).maximize();
|
|
210
|
+
const allDay = ALL_DAY[`${tag.language}-${tag.script}`] ?? ALL_DAY[tag.language] ?? LABELS.allDay;
|
|
211
|
+
let labels;
|
|
212
|
+
if (tag.language === "en") labels = LABELS;
|
|
213
|
+
else {
|
|
214
|
+
const list = new Intl.ListFormat(locale, { type: "unit", style: "short" });
|
|
215
|
+
const today = new Intl.RelativeTimeFormat(locale, { numeric: "auto" }).format(0, "day");
|
|
216
|
+
const range = (from, to) => `${from} \u2013 ${to}`;
|
|
217
|
+
labels = {
|
|
218
|
+
allDay,
|
|
219
|
+
event: (name, from, to) => list.format([name, range(from, to)]),
|
|
220
|
+
timeRange: range,
|
|
221
|
+
dayToday: (day) => list.format([day, today]),
|
|
222
|
+
allDayOf: (day) => list.format([allDay, day]),
|
|
223
|
+
changed: (name, day, from, to) => list.format([name, day, range(from, to)]),
|
|
224
|
+
list: (parts) => list.format(parts),
|
|
225
|
+
resize: ""
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
built.set(locale, labels);
|
|
229
|
+
return labels;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// src/navigate.ts
|
|
233
|
+
function moveFrom(days, id, move) {
|
|
234
|
+
const at = days.findIndex((day) => day.events.some((event) => event.id === id) || day.allDay?.some((event) => event.id === id));
|
|
235
|
+
if (at === -1) return null;
|
|
236
|
+
const over = (days[at].allDay ?? []).map((event) => event.id);
|
|
237
|
+
const timed = [...days[at].events].sort(compareEvents);
|
|
238
|
+
const column = [...over, ...timed.map((event) => event.id)];
|
|
239
|
+
const index = column.indexOf(id);
|
|
240
|
+
if (move === "previous") return column[index - 1] ?? null;
|
|
241
|
+
if (move === "next") return column[index + 1] ?? null;
|
|
242
|
+
const allDay = index < over.length;
|
|
243
|
+
const own = allDay ? over : column.slice(over.length);
|
|
244
|
+
if (move === "first") return own[0];
|
|
245
|
+
if (move === "last") return own[own.length - 1];
|
|
246
|
+
const step = move === "next-day" ? 1 : -1;
|
|
247
|
+
for (let i = at + step; i >= 0 && i < days.length; i += step) {
|
|
248
|
+
const there = days[i];
|
|
249
|
+
if (allDay) {
|
|
250
|
+
if (there.allDay?.length) return there.allDay[0].id;
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
if (!there.events.length) continue;
|
|
254
|
+
const from = timed[index - over.length].start;
|
|
255
|
+
return there.events.reduce((nearest, event) => Math.abs(event.start - from) < Math.abs(nearest.start - from) ? event : nearest).id;
|
|
256
|
+
}
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// src/reactive.ts
|
|
261
|
+
function createStore(initial) {
|
|
262
|
+
let state = initial;
|
|
263
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
264
|
+
return {
|
|
265
|
+
getSnapshot: () => state,
|
|
266
|
+
subscribe(listener) {
|
|
267
|
+
listeners.add(listener);
|
|
268
|
+
return () => void listeners.delete(listener);
|
|
269
|
+
},
|
|
270
|
+
set(fields) {
|
|
271
|
+
if (Object.keys(fields).every((key) => Object.is(state[key], fields[key]))) return;
|
|
272
|
+
state = { ...state, ...fields };
|
|
273
|
+
for (const listener of listeners) listener();
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
export {
|
|
278
|
+
LABELS,
|
|
279
|
+
addDays,
|
|
280
|
+
addMonths,
|
|
281
|
+
applyEventChange,
|
|
282
|
+
compareEvents,
|
|
283
|
+
createChangeDetails,
|
|
284
|
+
createStore,
|
|
285
|
+
datesIn,
|
|
286
|
+
dayAt,
|
|
287
|
+
daysFrom,
|
|
288
|
+
eventSpan,
|
|
289
|
+
eventTimes,
|
|
290
|
+
formatDay,
|
|
291
|
+
formatHour,
|
|
292
|
+
formatHourParts,
|
|
293
|
+
formatTime,
|
|
294
|
+
formatTimeParts,
|
|
295
|
+
getLocalTimeZone,
|
|
296
|
+
groupByDay,
|
|
297
|
+
hoursOf,
|
|
298
|
+
labelsFor,
|
|
299
|
+
laneBox,
|
|
300
|
+
lanesOf,
|
|
301
|
+
localeInfo,
|
|
302
|
+
moveFrom,
|
|
303
|
+
moved,
|
|
304
|
+
nowOf,
|
|
305
|
+
offsetOf,
|
|
306
|
+
resized,
|
|
307
|
+
startOfWeek,
|
|
308
|
+
stepDate,
|
|
309
|
+
toLocalDate,
|
|
310
|
+
weekdayOf
|
|
311
|
+
};
|
|
312
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/calendar.ts","../src/dates.ts","../src/change.ts","../src/drag.ts","../src/hours.ts","../src/layout.ts","../src/locale.ts","../src/navigate.ts","../src/reactive.ts"],"sourcesContent":["import { endOfMonth, fromDate, getLocalTimeZone, parseAbsolute, parseDate, parseDateTime, startOfMonth, toCalendarDate, toCalendarDateTime, toZoned, type CalendarDateTime } from \"@internationalized/date\";\nimport { addDays, daysFrom, startOfWeek, type DateString } from \"./dates\";\nimport type { CalendarDay, CalendarEvent } from \"./events\";\n\n/** What a calendar shows at a time. */\nexport type CalendarView = \"day\" | \"week\" | \"month\";\n\n/**\n * A time as an app or its database keeps one: a `Date`, or an ISO 8601 string. A string that ends in \"Z\" or\n * an offset (\"2026-11-23T15:00:00Z\") is an instant, read in the calendar's time zone; one with neither\n * (\"2026-11-23T07:00\") is that time on the wall wherever it is read; a day alone (\"2026-11-23\") is a day.\n */\nexport type EventTime = Date | string;\n\n/**\n * An event as an app keeps it: in a list, with when it starts and ends. It lasts the day (or days: `end` is\n * the day after its last, as iCalendar and Google Calendar count) when `allDay` is set or `start` is a day\n * alone.\n */\nexport interface PlannedEvent {\n id: string;\n start: EventTime;\n /** Left out, an event at a time lasts an hour and an all-day one a day. */\n end?: EventTime;\n allDay?: boolean;\n}\n\n/** The time zone a list's instants are read in. */\nexport interface TimeZoneOptions {\n /** An IANA name. @default this device's */\n timeZone?: string;\n}\n\n/** Whether a string names an instant: it ends in \"Z\" or an offset from UTC. */\nconst INSTANT = /(?:Z|[+-]\\d{2}:?\\d{2})$/i;\nconst isDay = (time: EventTime) => typeof time === \"string\" && time.length === 10;\n\n/** A time as a clock on the wall of a time zone shows it. */\nfunction onTheWall(time: EventTime, zone: string): CalendarDateTime {\n if (time instanceof Date) return toCalendarDateTime(fromDate(time, zone));\n if (isDay(time)) return toCalendarDateTime(parseDate(time));\n return INSTANT.test(time) ? toCalendarDateTime(parseAbsolute(time, zone)) : parseDateTime(time);\n}\n/** A day and the minutes past its midnight, as a time. */\nconst timeOn = (date: DateString, minutes: number) => toCalendarDateTime(parseDate(date)).add({ minutes });\nconst minutesOf = (time: CalendarDateTime) => time.hour * 60 + time.minute;\n\n/** The same day so many months on (or back), kept inside the month it lands in: a month on from January 31 is the last of February. */\nexport const addMonths = (date: DateString, months: number): DateString => parseDate(date).add({ months }).toString();\n\n/** The day a view shows after one: a day, a week or a month on (or, with a negative `by`, back). */\nexport const stepDate = (view: CalendarView, date: DateString, by: number): DateString => (view === \"month\" ? addMonths(date, by) : addDays(date, by * (view === \"day\" ? 1 : 7)));\n\n/**\n * The days a view draws round a day: the day, its week as `locale` counts weeks, or its month with the\n * weeks it begins and ends in drawn whole.\n */\nexport function datesIn(view: CalendarView, date: DateString, locale = \"en-US\"): DateString[] {\n if (view === \"day\") return [date];\n if (view === \"week\") return daysFrom(startOfWeek(date, locale), 7);\n const first = startOfWeek(startOfMonth(parseDate(date)).toString(), locale);\n const last = addDays(startOfWeek(endOfMonth(parseDate(date)).toString(), locale), 6);\n const dates: DateString[] = [];\n for (let each = first; each <= last; each = addDays(each, 1)) dates.push(each);\n return dates;\n}\n\n/** The first and last day an event is on, in a time zone: for an all-day one, `end` is the day after its last. */\nexport function eventSpan(event: PlannedEvent, { timeZone = getLocalTimeZone() }: TimeZoneOptions = {}): { first: DateString; last: DateString } {\n const first = toCalendarDate(onTheWall(event.start, timeZone));\n const end = event.end === undefined ? first : toCalendarDate(onTheWall(event.end, timeZone));\n const allDay = event.allDay ?? isDay(event.start);\n const last = allDay && end.compare(first) > 0 ? end.subtract({ days: 1 }) : end.compare(first) > 0 ? end : first;\n return { first: first.toString(), last: last.toString() };\n}\n\n/** An event of a list as a day holds it: all the app's own fields, and its times as minutes past the day's midnight. */\nexport type PlacedEvent<E> = Omit<E, \"start\" | \"end\"> & CalendarEvent;\n\n/**\n * A list of events as the days a calendar draws: each of `dates` with its timed events and its all-day\n * ones, in the order they were given. What `TimeGrid`, `Agenda` and a month take. An event at a time is\n * on the day it starts (one that runs past midnight ends after 24 hours); an all-day one is on each day it\n * lasts. Events outside `dates` are left out, so the list can be more than is shown.\n */\nexport function groupByDay<E extends PlannedEvent>(events: readonly E[], dates: readonly DateString[], { timeZone = getLocalTimeZone() }: TimeZoneOptions = {}): CalendarDay<PlacedEvent<E>, E>[] {\n const days = new Map(dates.map((date) => [date, { date, events: [] as PlacedEvent<E>[], allDay: [] as E[] }]));\n for (const event of events) {\n const start = onTheWall(event.start, timeZone);\n const first = toCalendarDate(start);\n if (event.allDay ?? isDay(event.start)) {\n const length = event.end === undefined ? 1 : Math.max(1, toCalendarDate(onTheWall(event.end, timeZone)).compare(first));\n for (let i = 0; i < length; i++) days.get(first.add({ days: i }).toString())?.allDay.push(event);\n continue;\n }\n const day = days.get(first.toString());\n if (!day) continue;\n const from = minutesOf(start);\n const end = event.end === undefined ? undefined : onTheWall(event.end, timeZone);\n day.events.push({ ...event, start: from, end: end ? toCalendarDate(end).compare(first) * 1440 + minutesOf(end) : from + 60 });\n }\n return [...days.values()];\n}\n\n/** Where a grid says an event now is: its day, and minutes past that day's midnight. What `onEventChange` gives. */\nexport interface EventChange {\n id: string;\n date: DateString;\n start: number;\n end: number;\n}\n\n/** A change's times as instants, to send to a server: `updateEvent(change.id, eventTimes(change))`. */\nexport function eventTimes(change: Omit<EventChange, \"id\">, { timeZone = getLocalTimeZone() }: TimeZoneOptions = {}): { start: Date; end: Date } {\n return { start: toZoned(timeOn(change.date, change.start), timeZone).toDate(), end: toZoned(timeOn(change.date, change.end), timeZone).toDate() };\n}\n\n/** A time written the way another was: a `Date` for a `Date`, an instant for an instant, a time on the wall for one of those. */\nfunction written(time: CalendarDateTime, like: EventTime, zone: string): EventTime {\n if (like instanceof Date) return toZoned(time, zone).toDate();\n return INSTANT.test(like) ? toZoned(time, zone).toAbsoluteString() : time.toString();\n}\n\n/**\n * The list with an event put where a change says it now is: what a grid's `onEventChange` tells of a drag,\n * a resize or a move by the keyboard. Its times stay as they were kept: `Date`s stay `Date`s, strings strings.\n */\nexport const applyEventChange = <E extends PlannedEvent>(events: readonly E[], change: EventChange, { timeZone = getLocalTimeZone() }: TimeZoneOptions = {}): E[] =>\n events.map((event) => (event.id === change.id ? { ...event, start: written(timeOn(change.date, change.start), event.start, timeZone), end: written(timeOn(change.date, change.end), event.end ?? event.start, timeZone) } : event));\n","import { getDayOfWeek, getLocalTimeZone, now, parseDate, startOfWeek as startOfLocaleWeek } from \"@internationalized/date\";\n\n/**\n * Calendar days as \"YYYY-MM-DD\" strings at the edges, and\n * `@internationalized/date` (React Aria's date library) for the arithmetic:\n * a day is a name, not an instant, so no time zone can shift it, and a\n * week starts where the reader's locale starts it.\n */\nexport type DateString = string;\n\nexport const addDays = (date: DateString, days: number): DateString => parseDate(date).add({ days }).toString();\n\n/** 0 is Sunday. */\nexport const weekdayOf = (date: DateString): number => getDayOfWeek(parseDate(date), \"en-US\");\n\n/** The first day of the week `date` is in, as `locale` counts weeks: Sunday in the US, Monday in Britain, Saturday in Egypt. */\nexport const startOfWeek = (date: DateString, locale = \"en-US\"): DateString => startOfLocaleWeek(parseDate(date), locale).toString();\n\n/** `count` days in a row from `from`. */\nexport const daysFrom = (from: DateString, count: number): DateString[] => Array.from({ length: count }, (_, i) => addDays(from, i));\n\n/** A day as a Date at this device's midnight, for Intl to put into words. */\nexport const toLocalDate = (date: DateString): Date => {\n const { year, month, day } = parseDate(date);\n return new Date(year, month - 1, day);\n};\n\n/**\n * Today, and the minutes past midnight it is now, in a time zone (an IANA\n * name; this device's when left out). A trip's calendar is in the trip's\n * zone: \"now\" in Tokyo is Tokyo's, wherever it is read.\n */\nexport function nowOf(timeZone: string = getLocalTimeZone()): { date: DateString; minutes: number } {\n const at = now(timeZone);\n return { date: `${at.year}-${String(at.month).padStart(2, \"0\")}-${String(at.day).padStart(2, \"0\")}`, minutes: at.hour * 60 + at.minute };\n}\n\nexport { getLocalTimeZone };\n","/**\n * What comes with a change, as Base UI's change details: why it happened,\n * the element it came from when there is one, and a way for the owner to\n * refuse it. (React Aria hands its press and selection on without the\n * browser's event, so there is none here.)\n */\nexport interface ChangeDetails<Reason extends string = string> {\n reason: Reason;\n trigger: Element | undefined;\n /** Keeps what was there: the change is not made. */\n cancel(): void;\n readonly isCanceled: boolean;\n}\n\nexport function createChangeDetails<Reason extends string>(reason: Reason, trigger?: Element): ChangeDetails<Reason> {\n let canceled = false;\n return {\n reason,\n trigger,\n cancel: () => void (canceled = true),\n get isCanceled() {\n return canceled;\n },\n };\n}\n","import type { Span } from \"./layout\";\n\n/**\n * An event dragged: moved whole, or its end pulled. Deltas are in minutes\n * and days; the result keeps to the grid's step and to the day.\n */\nexport interface Drag {\n /** Minutes the start has moved. */\n start: number;\n /** Minutes the end has moved. */\n end: number;\n /** Days moved, towards later. */\n days: number;\n}\n\nconst DAY = 24 * 60;\nconst snap = (minutes: number, step: number) => Math.round(minutes / step) * step;\n\n/** The minutes of the day a drag keeps an event within: the hours a grid draws, or the whole day. */\nexport interface Bounds {\n from: number;\n to: number;\n}\nconst WHOLE_DAY: Bounds = { from: 0, to: DAY };\n\n/** The event moved by `minutes`, to the step: as long as it was, and inside the bounds. */\nexport function moved(event: Span, minutes: number, step: number, { from, to }: Bounds = WHOLE_DAY): Span {\n const length = event.end - event.start;\n const start = Math.min(Math.max(from, snap(event.start + minutes, step)), Math.max(from, to - length));\n return { start, end: start + length };\n}\n\n/** The event with its end pulled by `minutes`, to the step: never shorter than a step, never past the bounds. */\nexport function resized(event: Span, minutes: number, step: number, { to }: Bounds = WHOLE_DAY): Span {\n return { start: event.start, end: Math.min(Math.max(to, event.start + step), Math.max(event.start + step, snap(event.end + minutes, step))) };\n}\n\n/** The day `days` on from `index` among `count`, kept among them. */\nexport const dayAt = (index: number, days: number, count: number): number => Math.min(count - 1, Math.max(0, index + days));\n","import type { Span } from \"./layout\";\n\n/** The hours a grid draws, as whole hours past midnight: `to` is exclusive and may pass 24. */\nexport interface HourRange {\n from: number;\n to: number;\n}\n\n/**\n * The hours to draw for some events: `pad` hours either side of them, never\n * fewer than `least` when there are none or they are few.\n */\nexport function hoursOf(spans: readonly Span[], { pad = 1, least = { from: 8, to: 18 } }: { pad?: number; least?: HourRange } = {}): HourRange {\n if (!spans.length) return least;\n const first = Math.min(...spans.map((s) => s.start));\n const last = Math.max(...spans.map((s) => s.end));\n return { from: Math.max(0, Math.floor(first / 60) - pad), to: Math.min(30, Math.ceil(last / 60) + pad) };\n}\n\n/** How far down a grid a time is, in the grid's units, given what an hour is tall. */\nexport const offsetOf = (minutes: number, range: HourRange, hourHeight: number): number => ((minutes - range.from * 60) / 60) * hourHeight;\n","/**\n * Where events that overlap in time sit side by side, as a calendar's day\n * column draws them: each event gets a lane, and a group of events that\n * overlap one another share the column's width between their lanes.\n */\n\nexport interface Span {\n start: number;\n end: number;\n}\n\nexport interface Placed<T> {\n event: T;\n /** 0 is leftmost. */\n lane: number;\n /** How many lanes its group has: its width is 1/lanes of the column. */\n lanes: number;\n}\n\n/**\n * The one order events are in, wherever they are ordered: by when they start, and of two that start\n * together the longer first. It is the order they are drawn in, so it is the order the arrow keys go in.\n */\nexport const compareEvents = (a: Span, b: Span): number => a.start - b.start || b.end - a.end;\n\n/**\n * Where an event sits across its day, as fractions of the day's width: it starts at its lane, and is as\n * wide as a lane and `overlap` of the next (Google Calendar's is 0.7, so each event runs under the one\n * after it), never past the day's far edge. With no overlap the lanes share the width.\n */\nexport function laneBox(lane: number, lanes: number, overlap = 0): { start: number; width: number } {\n const start = lane / lanes;\n return { start, width: Math.min((1 + overlap) / lanes, 1 - start) };\n}\n\nexport function lanesOf<T extends Span>(events: readonly T[]): Placed<T>[] {\n const sorted = [...events].sort(compareEvents);\n const placed: Placed<T>[] = [];\n let group: Placed<T>[] = [];\n let groupEnd = -Infinity;\n /** When each lane of the current group is next free. */\n let free: number[] = [];\n const close = () => {\n for (const item of group) item.lanes = free.length;\n group = [];\n free = [];\n };\n for (const event of sorted) {\n if (event.start >= groupEnd) close();\n let lane = free.findIndex((end) => end <= event.start);\n if (lane === -1) lane = free.length;\n free[lane] = event.end;\n groupEnd = Math.max(groupEnd, event.end);\n const item = { event, lane, lanes: 1 };\n group.push(item);\n placed.push(item);\n }\n close();\n return placed;\n}\n","import { CalendarDate, DateFormatter, getDayOfWeek, isWeekend, startOfWeek } from \"@internationalized/date\";\n\n/**\n * What a locale says about a calendar: which day a week starts on, which days are its weekend, and its\n * words for hours, times and days. All from the date library and Intl; nothing is bundled. Which way a\n * locale reads is React Aria's to say (`useLocale().direction`, `isRTL`).\n */\nexport interface LocaleInfo {\n locale: string;\n /** 0 is Sunday. */\n firstDayOfWeek: number;\n /** The days of the weekend there; 0 is Sunday. */\n weekend: readonly number[];\n}\n\n/** A week of days, to ask the date library about: 2023-01-01 was a Sunday. */\nconst WEEK = Array.from({ length: 7 }, (_, i) => new CalendarDate(2023, 1, 1 + i));\n\nconst known = new Map<string, LocaleInfo>();\n\n/** What a locale says, worked out once for each: every day and cell asks. */\nexport function localeInfo(locale: string): LocaleInfo {\n const had = known.get(locale);\n if (had) return had;\n const info = readLocale(locale);\n known.set(locale, info);\n return info;\n}\n\nfunction readLocale(locale: string): LocaleInfo {\n return {\n locale,\n // Which day a week starts on, and which days are the weekend, are the date library's to know.\n firstDayOfWeek: getDayOfWeek(startOfWeek(WEEK[3]!, locale), \"en-US\"),\n weekend: WEEK.flatMap((day, weekday) => (isWeekend(day, locale) ? [weekday] : [])),\n };\n}\n\n/** The date library's formatter: Intl's, cached, with its hour-cycle quirks smoothed over. */\nconst format = (locale: string, options: Intl.DateTimeFormatOptions) => new DateFormatter(locale, options);\n\nconst clock = (minutes: number) => new Date(2000, 0, 1, 0, minutes);\n\n/** An hour as a grid labels it: \"9 AM\", \"09\". */\nexport const formatHour = (locale: string, hour: number): string => format(locale, { hour: \"numeric\" }).format(clock((hour % 24) * 60));\n\n/** An hour in its parts, for a label that sets them apart: \"7\" and \"AM\"; `dayPeriod` is empty on a 24-hour clock. */\nexport function formatHourParts(locale: string, hour: number): { hour: string; dayPeriod: string } {\n const parts = format(locale, { hour: \"numeric\" }).formatToParts(clock((hour % 24) * 60));\n return { hour: parts.find((part) => part.type === \"hour\")?.value ?? \"\", dayPeriod: parts.find((part) => part.type === \"dayPeriod\")?.value ?? \"\" };\n}\n\n/** A time of day from minutes past midnight: \"9:30 AM\", \"09:30\". */\nexport const formatTime = (locale: string, minutes: number): string => format(locale, { hour: \"numeric\", minute: \"2-digit\" }).format(clock(minutes % 1440));\n\n/**\n * A time in its parts, for a label that sets the day period apart (iOS\n * writes \"7:00\" and a small \"AM\"): `time` is the clock without it, and\n * `dayPeriod` is empty on a 24-hour clock.\n */\nexport function formatTimeParts(locale: string, minutes: number): { time: string; dayPeriod: string } {\n const parts = format(locale, { hour: \"numeric\", minute: \"2-digit\" }).formatToParts(clock(minutes % 1440));\n return {\n time: parts\n .filter((part) => part.type !== \"dayPeriod\")\n .map((part) => part.value)\n .join(\"\")\n .trim(),\n dayPeriod: parts.find((part) => part.type === \"dayPeriod\")?.value ?? \"\",\n };\n}\n\n/** A day's parts for a column header (\"Sun\", \"22\"), and its whole name for a screen reader. */\nexport function formatDay(locale: string, date: Date): { weekday: string; day: string; full: string } {\n return { weekday: format(locale, { weekday: \"short\" }).format(date), day: format(locale, { day: \"numeric\" }).format(date), full: format(locale, { weekday: \"long\", month: \"long\", day: \"numeric\" }).format(date) };\n}\n\n/** The words a grid says that are not dates or times. Pass your own to translate them. */\nexport interface CalendarLabels {\n allDay: string;\n /** An event with its times, as a sentence: for an announcement. */\n event: (name: string, from: string, to: string) => string;\n /** When an event is, said after its name: \"9:30 AM to 11:00 AM\". */\n timeRange: (from: string, to: string) => string;\n /** A day's name when it is today: \"Monday, November 23, today\". */\n dayToday: (day: string) => string;\n /** The all-day part of a day: \"all-day, Monday, November 23\". */\n allDayOf: (day: string) => string;\n /** Said when an event has been moved or resized: its name, the day's full name, and its new times. */\n changed: (name: string, day: string, from: string, to: string) => string;\n /** Things said one after another, joined as the language joins them: \"Thanksgiving, all-day\". */\n list: (parts: readonly string[]) => string;\n /** The name of the handle that resizes an event. */\n resize: string;\n /** What 12 o'clock midday is called, where a calendar says so: \"Noon\". Left out, it is the hour like any other. */\n noon?: string;\n}\n\nexport const LABELS: CalendarLabels = {\n allDay: \"all-day\",\n event: (name, from, to) => `${name}, ${from} to ${to}`,\n timeRange: (from, to) => `${from} to ${to}`,\n dayToday: (day) => `${day}, today`,\n allDayOf: (day) => `all-day, ${day}`,\n changed: (name, day, from, to) => `${name} is now ${day}, ${from} to ${to}`,\n list: (parts) => parts.join(\", \"),\n resize: \"Resize\",\n};\n\n/** \"All-day\" as calendars write it, by language (and script, for Chinese). Elsewhere it is English until you give `labels`. */\nconst ALL_DAY: Record<string, string> = {\n en: \"all-day\",\n es: \"todo el día\",\n fr: \"toute la journée\",\n de: \"ganztägig\",\n it: \"tutto il giorno\",\n pt: \"o dia todo\",\n nl: \"hele dag\",\n ru: \"весь день\",\n ja: \"終日\",\n ko: \"종일\",\n zh: \"全天\",\n \"zh-Hant\": \"整天\",\n ar: \"طوال اليوم\",\n he: \"כל היום\",\n hi: \"पूरे दिन\",\n};\n\nconst built = new Map<string, CalendarLabels>();\n\n/**\n * The words a calendar says, for a locale. English has its own sentences.\n * Every other language is put together from what Intl knows of it (its word\n * for today, how it separates the parts of a list) round the dates and times\n * it has already formatted, so nothing is said in English; pass `labels` for\n * sentences of your own.\n */\nexport function labelsFor(locale: string): CalendarLabels {\n const had = built.get(locale);\n if (had) return had;\n const tag = new Intl.Locale(locale).maximize();\n const allDay = ALL_DAY[`${tag.language}-${tag.script}`] ?? ALL_DAY[tag.language] ?? LABELS.allDay;\n let labels: CalendarLabels;\n if (tag.language === \"en\") labels = LABELS;\n else {\n const list = new Intl.ListFormat(locale, { type: \"unit\", style: \"short\" });\n const today = new Intl.RelativeTimeFormat(locale, { numeric: \"auto\" }).format(0, \"day\");\n const range = (from: string, to: string) => `${from} – ${to}`;\n labels = {\n allDay,\n event: (name, from, to) => list.format([name, range(from, to)]),\n timeRange: range,\n dayToday: (day) => list.format([day, today]),\n allDayOf: (day) => list.format([allDay, day]),\n changed: (name, day, from, to) => list.format([name, day, range(from, to)]),\n list: (parts) => list.format(parts),\n resize: \"\",\n };\n }\n built.set(locale, labels);\n return labels;\n}\n","import type { CalendarEvent } from \"./events\";\nimport { compareEvents } from \"./layout\";\n\n/**\n * Where the keyboard goes from an event in a time grid. A day reads from the\n * top: its all-day events in the order given, then its timed ones in time\n * order, and up and down go through that. Sideways from a timed event is the\n * event nearest in time on the next day that has any; from an all-day one,\n * that day's first all-day event. First and last are of its own kind in its day.\n */\nexport type Move = \"previous\" | \"next\" | \"previous-day\" | \"next-day\" | \"first\" | \"last\";\n\n/** A day as the keyboard goes through it: a `CalendarDay` is one. */\nexport interface NavigationDay {\n events: readonly CalendarEvent[];\n allDay?: readonly { id: string }[];\n}\n\nexport function moveFrom(days: readonly NavigationDay[], id: string, move: Move): string | null {\n const at = days.findIndex((day) => day.events.some((event) => event.id === id) || day.allDay?.some((event) => event.id === id));\n if (at === -1) return null;\n const over = (days[at]!.allDay ?? []).map((event) => event.id);\n const timed = [...days[at]!.events].sort(compareEvents);\n const column = [...over, ...timed.map((event) => event.id)];\n const index = column.indexOf(id);\n if (move === \"previous\") return column[index - 1] ?? null;\n if (move === \"next\") return column[index + 1] ?? null;\n const allDay = index < over.length;\n const own = allDay ? over : column.slice(over.length);\n if (move === \"first\") return own[0]!;\n if (move === \"last\") return own[own.length - 1]!;\n const step = move === \"next-day\" ? 1 : -1;\n for (let i = at + step; i >= 0 && i < days.length; i += step) {\n const there = days[i]!;\n if (allDay) {\n if (there.allDay?.length) return there.allDay[0]!.id;\n continue;\n }\n if (!there.events.length) continue;\n const from = timed[index - over.length]!.start;\n return there.events.reduce((nearest, event) => (Math.abs(event.start - from) < Math.abs(nearest.start - from) ? event : nearest)).id;\n }\n return null;\n}\n","export type Listener = () => void;\n\n/** A value that can be read, replaced and watched: what a framework binds to. */\nexport interface Store<State> {\n getSnapshot(): State;\n subscribe(listener: Listener): () => void;\n /** Merges the fields in; listeners hear only a real change. */\n set(fields: Partial<State>): void;\n}\n\nexport function createStore<State extends object>(initial: State): Store<State> {\n let state = initial;\n const listeners = new Set<Listener>();\n return {\n getSnapshot: () => state,\n subscribe(listener) {\n listeners.add(listener);\n return () => void listeners.delete(listener);\n },\n set(fields) {\n if ((Object.keys(fields) as (keyof State)[]).every((key) => Object.is(state[key], fields[key]))) return;\n state = { ...state, ...fields };\n for (const listener of listeners) listener();\n },\n };\n}\n"],"mappings":";AAAA,SAAS,YAAY,UAAU,oBAAAA,mBAAkB,eAAe,aAAAC,YAAW,eAAe,cAAc,gBAAgB,oBAAoB,eAAsC;;;ACAlL,SAAS,cAAc,kBAAkB,KAAK,WAAW,eAAe,yBAAyB;AAU1F,IAAM,UAAU,CAAC,MAAkB,SAA6B,UAAU,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,SAAS;AAGvG,IAAM,YAAY,CAAC,SAA6B,aAAa,UAAU,IAAI,GAAG,OAAO;AAGrF,IAAM,cAAc,C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O,SAAS,aAAa,IAAI;AACvC,WAAS,IAAI,KAAK,MAAM,KAAK,KAAK,IAAI,KAAK,QAAQ,KAAK,MAAM;AAC5D,UAAM,QAAQ,KAAK,CAAC;AACpB,QAAI,QAAQ;AACV,UAAI,MAAM,QAAQ,OAAQ,QAAO,MAAM,OAAO,CAAC,EAAG;AAClD;AAAA,IACF;AACA,QAAI,CAAC,MAAM,OAAO,OAAQ;AAC1B,UAAM,OAAO,MAAM,QAAQ,KAAK,MAAM,EAAG;AACzC,WAAO,MAAM,OAAO,OAAO,CAAC,SAAS,UAAW,KAAK,IAAI,MAAM,QAAQ,IAAI,IAAI,KAAK,IAAI,QAAQ,QAAQ,IAAI,IAAI,QAAQ,OAAQ,EAAE;AAAA,EACpI;AACA,SAAO;AACT;;;ACjCO,SAAS,YAAkC,SAA8B;AAC9E,MAAI,QAAQ;AACZ,QAAM,YAAY,oBAAI,IAAc;AACpC,SAAO;AAAA,IACL,aAAa,MAAM;AAAA,IACnB,UAAU,UAAU;AAClB,gBAAU,IAAI,QAAQ;AACtB,aAAO,MAAM,KAAK,UAAU,OAAO,QAAQ;AAAA,IAC7C;AAAA,IACA,IAAI,QAAQ;AACV,UAAK,OAAO,KAAK,MAAM,EAAsB,MAAM,CAAC,QAAQ,OAAO,GAAG,MAAM,GAAG,GAAG,OAAO,GAAG,CAAC,CAAC,EAAG;AACjG,cAAQ,EAAE,GAAG,OAAO,GAAG,OAAO;AAC9B,iBAAW,YAAY,UAAW,UAAS;AAAA,IAC7C;AAAA,EACF;AACF;","names":["getLocalTimeZone","parseDate","parseDate","getLocalTimeZone","getDayOfWeek","startOfWeek"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "calendar-components-core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.7.3",
|
|
4
|
+
"description": "Framework-neutral calendar state and layout: days, time grids, overlapping events, keyboard movement, locale.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"calendar",
|
|
7
|
+
"time-grid",
|
|
8
|
+
"week-view",
|
|
9
|
+
"day-view",
|
|
10
|
+
"headless",
|
|
11
|
+
"schedule"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "Brian Hung",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=20"
|
|
18
|
+
},
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"calendar-components-source": "./src/index.ts",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsup",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
34
|
+
"prepack": "cp ../../LICENSE ."
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"tsup": "^8.5.0",
|
|
38
|
+
"typescript": "^5.9.3",
|
|
39
|
+
"vitest": "^3.2.4"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/BrianHung/calendar-components.git",
|
|
44
|
+
"directory": "packages/core"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public",
|
|
48
|
+
"registry": "https://registry.npmjs.org"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@internationalized/date": "^3.12.4"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://calendar.brianhung.me"
|
|
54
|
+
}
|