@reactloom/scheduler 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -2
- package/dist/LICENSE +21 -0
- package/dist/_internal/primitives/visually-hidden.js +29 -0
- package/dist/_internal/primitives/visually-hidden.js.map +1 -0
- package/dist/_internal/utils/cx.js +10 -0
- package/dist/_internal/utils/cx.js.map +1 -0
- package/dist/_internal/utils/data-attr.js +8 -0
- package/dist/_internal/utils/data-attr.js.map +1 -0
- package/dist/dates.d.ts +37 -0
- package/dist/dates.d.ts.map +1 -0
- package/dist/dates.js +79 -0
- package/dist/dates.js.map +1 -0
- package/dist/event-calendar.d.ts +9 -0
- package/dist/event-calendar.d.ts.map +1 -0
- package/dist/event-calendar.js +944 -0
- package/dist/event-calendar.js.map +1 -0
- package/dist/gantt.d.ts +67 -0
- package/dist/gantt.d.ts.map +1 -0
- package/dist/gantt.js +512 -0
- package/dist/gantt.js.map +1 -0
- package/dist/gantt.module.js +44 -0
- package/dist/gantt.module.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/recurrence.d.ts +27 -0
- package/dist/recurrence.d.ts.map +1 -0
- package/dist/recurrence.js +130 -0
- package/dist/recurrence.js.map +1 -0
- package/dist/scheduler.module.js +86 -0
- package/dist/scheduler.module.js.map +1 -0
- package/dist/styles.css +3 -0
- package/dist/types.d.ts +130 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +75 -3
package/README.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @reactloom/scheduler
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Accessible scheduling for ReactLoom: an `EventCalendar` (month, week, day, agenda and resource
|
|
4
|
+
timeline views) and a `Gantt` chart. Both are keyboard-first WAI-ARIA grids with explicit time
|
|
5
|
+
zones.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @reactloom/scheduler @reactloom/ui @reactloom/theme
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import '@reactloom/scheduler/styles.css';
|
|
13
|
+
import { EventCalendar, type CalendarEvent } from '@reactloom/scheduler';
|
|
14
|
+
|
|
15
|
+
const [events, setEvents] = useState<CalendarEvent[]>(initialEvents);
|
|
16
|
+
|
|
17
|
+
<EventCalendar
|
|
18
|
+
aria-label="Team calendar"
|
|
19
|
+
events={events}
|
|
20
|
+
defaultView="week"
|
|
21
|
+
timeZone="Europe/London"
|
|
22
|
+
onCreate={(range) => setEvents((all) => [...all, { id: crypto.randomUUID(), title: 'New event', ...range }])}
|
|
23
|
+
onEventChange={({ event, start, end }) =>
|
|
24
|
+
setEvents((all) => all.map((e) => (e.id === event.id ? { ...e, start, end } : e)))
|
|
25
|
+
}
|
|
26
|
+
/>;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- **Keyboard:** arrows move between days and time slots; Enter on an empty slot creates an event;
|
|
30
|
+
Alt + arrows move an event and Alt + Shift + arrows resize it. Pointer drag and resize handles
|
|
31
|
+
call the same `onEventChange`.
|
|
32
|
+
- **Repeating events:** give an event a `recurrence` rule (daily, weekly, monthly or yearly, with
|
|
33
|
+
`interval`, `weekdays`, `count`, `until` and exceptions). `parseRRule` and `formatRRule`
|
|
34
|
+
convert to and from iCalendar `RRULE` text; `expandEvents` lists occurrences in a range.
|
|
35
|
+
- **Resources:** pass `resources` for a column per person or room in the day view, and a row each
|
|
36
|
+
in the `timeline` view.
|
|
37
|
+
- **Gantt:** `<Gantt aria-label="Plan" tasks={tasks} timeZone="UTC" />` shows tasks, milestones,
|
|
38
|
+
progress and dependency arrows as a navigable tree grid. Add `onTaskChange` to make it editable.
|
|
39
|
+
|
|
40
|
+
The component never changes your data: it reports requested changes and you apply them.
|
|
41
|
+
|
|
42
|
+
Documentation and live examples: <https://reactloom.dev/components/event-calendar> ·
|
|
43
|
+
<https://reactloom.dev/components/gantt>
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ReactLoom UI contributors
|
|
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.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
// ../primitives/src/visually-hidden.tsx
|
|
4
|
+
var hidden = {
|
|
5
|
+
position: "absolute",
|
|
6
|
+
width: 1,
|
|
7
|
+
height: 1,
|
|
8
|
+
padding: 0,
|
|
9
|
+
margin: -1,
|
|
10
|
+
overflow: "hidden",
|
|
11
|
+
clip: "rect(0 0 0 0)",
|
|
12
|
+
clipPath: "inset(50%)",
|
|
13
|
+
whiteSpace: "nowrap",
|
|
14
|
+
border: 0
|
|
15
|
+
};
|
|
16
|
+
/** Content available to assistive technology but not rendered visually. */
|
|
17
|
+
var VisuallyHidden = /*#__PURE__*/ forwardRef(function VisuallyHidden({ style, ...props }, ref) {
|
|
18
|
+
return /* @__PURE__ */ jsx("span", {
|
|
19
|
+
ref,
|
|
20
|
+
...props,
|
|
21
|
+
style: {
|
|
22
|
+
...hidden,
|
|
23
|
+
...style
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
export { VisuallyHidden };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=visually-hidden.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visually-hidden.js","names":[],"sources":["../../../../primitives/src/visually-hidden.tsx"],"sourcesContent":["import { forwardRef, type CSSProperties, type HTMLAttributes } from 'react';\n\nconst hidden: CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n padding: 0,\n margin: -1,\n overflow: 'hidden',\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(50%)',\n whiteSpace: 'nowrap',\n border: 0,\n};\n\nexport type VisuallyHiddenProps = HTMLAttributes<HTMLSpanElement>;\n\n/** Content available to assistive technology but not rendered visually. */\nexport const VisuallyHidden = /*#__PURE__*/ forwardRef<HTMLSpanElement, VisuallyHiddenProps>(function VisuallyHidden(\n { style, ...props },\n ref,\n) {\n return <span ref={ref} {...props} style={{ ...hidden, ...style }} />;\n});\n"],"mappings":";;;AAEA,IAAM,SAAwB;CAC5B,UAAU;CACV,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,UAAU;CACV,MAAM;CACN,UAAU;CACV,YAAY;CACZ,QAAQ;AACV;;AAKA,IAAa,iBAA+B,yBAAiD,SAAS,eACpG,EAAE,OAAO,GAAG,SACZ,KACA;CACA,OAAO,oBAAC,QAAD;EAAW;EAAK,GAAI;EAAO,OAAO;GAAE,GAAG;GAAQ,GAAG;EAAM;CAAI,CAAA;AACrE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// ../utils/src/cx.ts
|
|
2
|
+
/** Joins truthy class names with a single space. */
|
|
3
|
+
function cx(...values) {
|
|
4
|
+
let out = "";
|
|
5
|
+
for (const v of values) if (v) out = out ? `${out} ${v}` : v;
|
|
6
|
+
return out || void 0;
|
|
7
|
+
}
|
|
8
|
+
export { cx };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=cx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cx.js","names":[],"sources":["../../../../utils/src/cx.ts"],"sourcesContent":["type ClassValue = string | false | null | undefined;\n\n/** Joins truthy class names with a single space. */\nexport function cx(...values: ClassValue[]): string | undefined {\n let out = '';\n for (const v of values) if (v) out = out ? `${out} ${v}` : v;\n return out || undefined;\n}\n"],"mappings":";;AAGA,SAAgB,GAAG,GAAG,QAA0C;CAC9D,IAAI,MAAM;CACV,KAAK,MAAM,KAAK,QAAQ,IAAI,GAAG,MAAM,MAAM,GAAG,IAAI,GAAG,MAAM;CAC3D,OAAO,OAAO,KAAA;AAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-attr.js","names":[],"sources":["../../../../utils/src/data-attr.ts"],"sourcesContent":["/** `true` → `\"\"` (attribute present), falsy → `undefined` (attribute absent). */\nexport function dataAttr(condition: boolean | undefined): '' | undefined {\n return condition ? '' : undefined;\n}\n"],"mappings":";;AACA,SAAgB,SAAS,WAAgD;CACvE,OAAO,YAAY,KAAK,KAAA;AAC1B"}
|
package/dist/dates.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type CalendarDate } from '@internationalized/date';
|
|
2
|
+
import type { CalendarEvent } from './types.js';
|
|
3
|
+
/** The calendar day of an instant in a time zone. */
|
|
4
|
+
export declare const dayOf: (date: Date, timeZone: string) => CalendarDate;
|
|
5
|
+
/** Midnight of a calendar day in a time zone, as an instant (DST-aware). */
|
|
6
|
+
export declare const startOfDay: (day: CalendarDate, timeZone: string) => Date;
|
|
7
|
+
/** The instant at `minutes` after midnight on a day in a time zone (wall-clock time, DST-aware). */
|
|
8
|
+
export declare function atMinutes(day: CalendarDate, minutes: number, timeZone: string): Date;
|
|
9
|
+
/** Minutes since local midnight of an instant in a time zone. */
|
|
10
|
+
export declare function minutesOf(date: Date, timeZone: string): number;
|
|
11
|
+
/** ISO day key, e.g. `2026-11-24`. */
|
|
12
|
+
export declare const keyOf: (day: CalendarDate) => string;
|
|
13
|
+
/** Six weeks starting on the locale's first day of the week, covering the month of `day`. */
|
|
14
|
+
export declare function monthGrid(day: CalendarDate, locale: string): CalendarDate[][];
|
|
15
|
+
/** The seven days of the locale's week containing `day`. */
|
|
16
|
+
export declare const weekDays: (day: CalendarDate, locale: string) => CalendarDate[];
|
|
17
|
+
/** Weekday index (0 = locale's first day). */
|
|
18
|
+
export declare const weekdayIndex: (day: CalendarDate, locale: string) => number;
|
|
19
|
+
/** Does an event touch this calendar day (in the time zone)? End is exclusive. */
|
|
20
|
+
export declare function onDay(event: CalendarEvent, day: CalendarDate, timeZone: string): boolean;
|
|
21
|
+
/** Shift an instant by whole days keeping its wall-clock time (across DST), in a time zone. */
|
|
22
|
+
export declare function addDays(date: Date, days: number, timeZone: string): Date;
|
|
23
|
+
/** Shift an instant by minutes. */
|
|
24
|
+
export declare const addMinutes: (date: Date, minutes: number) => Date;
|
|
25
|
+
export interface PositionedEvent<E extends CalendarEvent> {
|
|
26
|
+
event: E;
|
|
27
|
+
/** Overlap column and how many columns the cluster has. */
|
|
28
|
+
column: number;
|
|
29
|
+
columns: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Side-by-side layout for overlapping timed events in one day column: events are sorted by
|
|
33
|
+
* start, placed in the first free column of their cluster, and every event in a cluster gets the
|
|
34
|
+
* cluster's column count.
|
|
35
|
+
*/
|
|
36
|
+
export declare function layoutDay<E extends CalendarEvent>(events: readonly E[]): Array<PositionedEvent<E>>;
|
|
37
|
+
//# sourceMappingURL=dates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dates.d.ts","sourceRoot":"","sources":["../src/dates.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAQlB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,qDAAqD;AACrD,eAAO,MAAM,KAAK,GAAI,MAAM,IAAI,EAAE,UAAU,MAAM,KAAG,YAAwD,CAAC;AAE9G,4EAA4E;AAC5E,eAAO,MAAM,UAAU,GAAI,KAAK,YAAY,EAAE,UAAU,MAAM,KAAG,IAAuC,CAAC;AAEzG,oGAAoG;AACpG,wBAAgB,SAAS,CAAC,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAGpF;AAED,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG9D;AAED,sCAAsC;AACtC,eAAO,MAAM,KAAK,GAAI,KAAK,YAAY,WAAmB,CAAC;AAE3D,6FAA6F;AAC7F,wBAAgB,SAAS,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE,EAAE,CAG7E;AAED,4DAA4D;AAC5D,eAAO,MAAM,QAAQ,GAAI,KAAK,YAAY,EAAE,QAAQ,MAAM,KAAG,YAAY,EAGxE,CAAC;AAEF,8CAA8C;AAC9C,eAAO,MAAM,YAAY,GAAI,KAAK,YAAY,EAAE,QAAQ,MAAM,WAA8B,CAAC;AAE7F,kFAAkF;AAClF,wBAAgB,KAAK,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAIxF;AAED,+FAA+F;AAC/F,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAExE;AAED,mCAAmC;AACnC,eAAO,MAAM,UAAU,GAAI,MAAM,IAAI,EAAE,SAAS,MAAM,KAAG,IAAmD,CAAC;AAE7G,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,aAAa;IACtD,KAAK,EAAE,CAAC,CAAC;IACT,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,aAAa,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAwBlG"}
|
package/dist/dates.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { fromDate, startOfMonth, startOfWeek, toCalendarDate, toZoned } from "@internationalized/date";
|
|
2
|
+
// src/dates.ts
|
|
3
|
+
/** The calendar day of an instant in a time zone. */
|
|
4
|
+
var dayOf = (date, timeZone) => toCalendarDate(fromDate(date, timeZone));
|
|
5
|
+
/** Midnight of a calendar day in a time zone, as an instant (DST-aware). */
|
|
6
|
+
var startOfDay = (day, timeZone) => toZoned(day, timeZone).toDate();
|
|
7
|
+
/** The instant at `minutes` after midnight on a day in a time zone (wall-clock time, DST-aware). */
|
|
8
|
+
function atMinutes(day, minutes, timeZone) {
|
|
9
|
+
return toZoned(day, timeZone).set({
|
|
10
|
+
hour: Math.floor(minutes / 60),
|
|
11
|
+
minute: minutes % 60
|
|
12
|
+
}).toDate();
|
|
13
|
+
}
|
|
14
|
+
/** Minutes since local midnight of an instant in a time zone. */
|
|
15
|
+
function minutesOf(date, timeZone) {
|
|
16
|
+
const z = fromDate(date, timeZone);
|
|
17
|
+
return z.hour * 60 + z.minute;
|
|
18
|
+
}
|
|
19
|
+
/** ISO day key, e.g. `2026-11-24`. */
|
|
20
|
+
var keyOf = (day) => day.toString();
|
|
21
|
+
/** Six weeks starting on the locale's first day of the week, covering the month of `day`. */
|
|
22
|
+
function monthGrid(day, locale) {
|
|
23
|
+
const first = startOfWeek(startOfMonth(day), locale);
|
|
24
|
+
return Array.from({ length: 6 }, (_, w) => Array.from({ length: 7 }, (_, d) => first.add({ days: w * 7 + d })));
|
|
25
|
+
}
|
|
26
|
+
/** The seven days of the locale's week containing `day`. */
|
|
27
|
+
var weekDays = (day, locale) => {
|
|
28
|
+
const first = startOfWeek(day, locale);
|
|
29
|
+
return Array.from({ length: 7 }, (_, d) => first.add({ days: d }));
|
|
30
|
+
};
|
|
31
|
+
/** Does an event touch this calendar day (in the time zone)? End is exclusive. */
|
|
32
|
+
function onDay(event, day, timeZone) {
|
|
33
|
+
const start = startOfDay(day, timeZone).getTime();
|
|
34
|
+
const end = startOfDay(day.add({ days: 1 }), timeZone).getTime();
|
|
35
|
+
return event.start.getTime() < end && event.end.getTime() > start;
|
|
36
|
+
}
|
|
37
|
+
/** Shift an instant by whole days keeping its wall-clock time (across DST), in a time zone. */
|
|
38
|
+
function addDays(date, days, timeZone) {
|
|
39
|
+
return fromDate(date, timeZone).add({ days }).toDate();
|
|
40
|
+
}
|
|
41
|
+
/** Shift an instant by minutes. */
|
|
42
|
+
var addMinutes = (date, minutes) => new Date(date.getTime() + minutes * 6e4);
|
|
43
|
+
/**
|
|
44
|
+
* Side-by-side layout for overlapping timed events in one day column: events are sorted by
|
|
45
|
+
* start, placed in the first free column of their cluster, and every event in a cluster gets the
|
|
46
|
+
* cluster's column count.
|
|
47
|
+
*/
|
|
48
|
+
function layoutDay(events) {
|
|
49
|
+
const sorted = [...events].sort((a, b) => a.start.getTime() - b.start.getTime() || b.end.getTime() - a.end.getTime());
|
|
50
|
+
const result = [];
|
|
51
|
+
let cluster = [];
|
|
52
|
+
let columnsEnd = [];
|
|
53
|
+
let clusterEnd = -Infinity;
|
|
54
|
+
const close = () => {
|
|
55
|
+
const columns = Math.max(1, columnsEnd.length);
|
|
56
|
+
for (const item of cluster) item.columns = columns;
|
|
57
|
+
result.push(...cluster);
|
|
58
|
+
cluster = [];
|
|
59
|
+
columnsEnd = [];
|
|
60
|
+
};
|
|
61
|
+
for (const event of sorted) {
|
|
62
|
+
const start = event.start.getTime();
|
|
63
|
+
if (start >= clusterEnd) close();
|
|
64
|
+
let column = columnsEnd.findIndex((end) => end <= start);
|
|
65
|
+
if (column === -1) column = columnsEnd.length;
|
|
66
|
+
columnsEnd[column] = event.end.getTime();
|
|
67
|
+
clusterEnd = Math.max(clusterEnd === -Infinity ? 0 : clusterEnd, event.end.getTime());
|
|
68
|
+
cluster.push({
|
|
69
|
+
event,
|
|
70
|
+
column,
|
|
71
|
+
columns: 1
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
close();
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
export { addDays, addMinutes, atMinutes, dayOf, keyOf, layoutDay, minutesOf, monthGrid, onDay, startOfDay, weekDays };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=dates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dates.js","names":[],"sources":["../src/dates.ts"],"sourcesContent":["import {\n type CalendarDate,\n fromDate,\n getDayOfWeek,\n startOfMonth,\n startOfWeek,\n toCalendarDate,\n toZoned,\n type ZonedDateTime,\n} from '@internationalized/date';\nimport type { CalendarEvent } from './types.js';\n\n/** The calendar day of an instant in a time zone. */\nexport const dayOf = (date: Date, timeZone: string): CalendarDate => toCalendarDate(fromDate(date, timeZone));\n\n/** Midnight of a calendar day in a time zone, as an instant (DST-aware). */\nexport const startOfDay = (day: CalendarDate, timeZone: string): Date => toZoned(day, timeZone).toDate();\n\n/** The instant at `minutes` after midnight on a day in a time zone (wall-clock time, DST-aware). */\nexport function atMinutes(day: CalendarDate, minutes: number, timeZone: string): Date {\n const midnight: ZonedDateTime = toZoned(day, timeZone);\n return midnight.set({ hour: Math.floor(minutes / 60), minute: minutes % 60 }).toDate();\n}\n\n/** Minutes since local midnight of an instant in a time zone. */\nexport function minutesOf(date: Date, timeZone: string): number {\n const z = fromDate(date, timeZone);\n return z.hour * 60 + z.minute;\n}\n\n/** ISO day key, e.g. `2026-11-24`. */\nexport const keyOf = (day: CalendarDate) => day.toString();\n\n/** Six weeks starting on the locale's first day of the week, covering the month of `day`. */\nexport function monthGrid(day: CalendarDate, locale: string): CalendarDate[][] {\n const first = startOfWeek(startOfMonth(day), locale);\n return Array.from({ length: 6 }, (_, w) => Array.from({ length: 7 }, (_, d) => first.add({ days: w * 7 + d })));\n}\n\n/** The seven days of the locale's week containing `day`. */\nexport const weekDays = (day: CalendarDate, locale: string): CalendarDate[] => {\n const first = startOfWeek(day, locale);\n return Array.from({ length: 7 }, (_, d) => first.add({ days: d }));\n};\n\n/** Weekday index (0 = locale's first day). */\nexport const weekdayIndex = (day: CalendarDate, locale: string) => getDayOfWeek(day, locale);\n\n/** Does an event touch this calendar day (in the time zone)? End is exclusive. */\nexport function onDay(event: CalendarEvent, day: CalendarDate, timeZone: string): boolean {\n const start = startOfDay(day, timeZone).getTime();\n const end = startOfDay(day.add({ days: 1 }), timeZone).getTime();\n return event.start.getTime() < end && event.end.getTime() > start;\n}\n\n/** Shift an instant by whole days keeping its wall-clock time (across DST), in a time zone. */\nexport function addDays(date: Date, days: number, timeZone: string): Date {\n return fromDate(date, timeZone).add({ days }).toDate();\n}\n\n/** Shift an instant by minutes. */\nexport const addMinutes = (date: Date, minutes: number): Date => new Date(date.getTime() + minutes * 60_000);\n\nexport interface PositionedEvent<E extends CalendarEvent> {\n event: E;\n /** Overlap column and how many columns the cluster has. */\n column: number;\n columns: number;\n}\n\n/**\n * Side-by-side layout for overlapping timed events in one day column: events are sorted by\n * start, placed in the first free column of their cluster, and every event in a cluster gets the\n * cluster's column count.\n */\nexport function layoutDay<E extends CalendarEvent>(events: readonly E[]): Array<PositionedEvent<E>> {\n const sorted = [...events].sort((a, b) => a.start.getTime() - b.start.getTime() || b.end.getTime() - a.end.getTime());\n const result: Array<PositionedEvent<E>> = [];\n let cluster: Array<PositionedEvent<E>> = [];\n let columnsEnd: number[] = [];\n let clusterEnd = -Infinity;\n const close = () => {\n const columns = Math.max(1, columnsEnd.length);\n for (const item of cluster) item.columns = columns;\n result.push(...cluster);\n cluster = [];\n columnsEnd = [];\n };\n for (const event of sorted) {\n const start = event.start.getTime();\n if (start >= clusterEnd) close();\n let column = columnsEnd.findIndex((end) => end <= start);\n if (column === -1) column = columnsEnd.length;\n columnsEnd[column] = event.end.getTime();\n clusterEnd = Math.max(clusterEnd === -Infinity ? 0 : clusterEnd, event.end.getTime());\n cluster.push({ event, column, columns: 1 });\n }\n close();\n return result;\n}\n"],"mappings":";;;AAaA,IAAa,SAAS,MAAY,aAAmC,eAAe,SAAS,MAAM,QAAQ,CAAC;;AAG5G,IAAa,cAAc,KAAmB,aAA2B,QAAQ,KAAK,QAAQ,CAAC,CAAC,OAAO;;AAGvG,SAAgB,UAAU,KAAmB,SAAiB,UAAwB;CAEpF,OADgC,QAAQ,KAAK,QACtC,CAAA,CAAS,IAAI;EAAE,MAAM,KAAK,MAAM,UAAU,EAAE;EAAG,QAAQ,UAAU;CAAG,CAAC,CAAC,CAAC,OAAO;AACvF;;AAGA,SAAgB,UAAU,MAAY,UAA0B;CAC9D,MAAM,IAAI,SAAS,MAAM,QAAQ;CACjC,OAAO,EAAE,OAAO,KAAK,EAAE;AACzB;;AAGA,IAAa,SAAS,QAAsB,IAAI,SAAS;;AAGzD,SAAgB,UAAU,KAAmB,QAAkC;CAC7E,MAAM,QAAQ,YAAY,aAAa,GAAG,GAAG,MAAM;CACnD,OAAO,MAAM,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAG,MAAM,MAAM,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAG,MAAM,MAAM,IAAI,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;AAChH;;AAGA,IAAa,YAAY,KAAmB,WAAmC;CAC7E,MAAM,QAAQ,YAAY,KAAK,MAAM;CACrC,OAAO,MAAM,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAG,MAAM,MAAM,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AACnE;;AAMA,SAAgB,MAAM,OAAsB,KAAmB,UAA2B;CACxF,MAAM,QAAQ,WAAW,KAAK,QAAQ,CAAC,CAAC,QAAQ;CAChD,MAAM,MAAM,WAAW,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,QAAQ;CAC/D,OAAO,MAAM,MAAM,QAAQ,IAAI,OAAO,MAAM,IAAI,QAAQ,IAAI;AAC9D;;AAGA,SAAgB,QAAQ,MAAY,MAAc,UAAwB;CACxE,OAAO,SAAS,MAAM,QAAQ,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO;AACvD;;AAGA,IAAa,cAAc,MAAY,YAA0B,IAAI,KAAK,KAAK,QAAQ,IAAI,UAAU,GAAM;;;;;;AAc3G,SAAgB,UAAmC,QAAiD;CAClG,MAAM,SAAS,CAAC,GAAG,MAAM,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,QAAQ,IAAI,EAAE,MAAM,QAAQ,KAAK,EAAE,IAAI,QAAQ,IAAI,EAAE,IAAI,QAAQ,CAAC;CACpH,MAAM,SAAoC,CAAC;CAC3C,IAAI,UAAqC,CAAC;CAC1C,IAAI,aAAuB,CAAC;CAC5B,IAAI,aAAa;CACjB,MAAM,cAAc;EAClB,MAAM,UAAU,KAAK,IAAI,GAAG,WAAW,MAAM;EAC7C,KAAK,MAAM,QAAQ,SAAS,KAAK,UAAU;EAC3C,OAAO,KAAK,GAAG,OAAO;EACtB,UAAU,CAAC;EACX,aAAa,CAAC;CAChB;CACA,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,QAAQ,MAAM,MAAM,QAAQ;EAClC,IAAI,SAAS,YAAY,MAAM;EAC/B,IAAI,SAAS,WAAW,WAAW,QAAQ,OAAO,KAAK;EACvD,IAAI,WAAW,IAAI,SAAS,WAAW;EACvC,WAAW,UAAU,MAAM,IAAI,QAAQ;EACvC,aAAa,KAAK,IAAI,eAAe,YAAY,IAAI,YAAY,MAAM,IAAI,QAAQ,CAAC;EACpF,QAAQ,KAAK;GAAE;GAAO;GAAQ,SAAS;EAAE,CAAC;CAC5C;CACA,MAAM;CACN,OAAO;AACT"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CalendarEvent, EventCalendarProps, SchedulerMessages } from './types.js';
|
|
2
|
+
export declare const defaultSchedulerMessages: SchedulerMessages;
|
|
3
|
+
/**
|
|
4
|
+
* An accessible event calendar (ADR-0012): month, week, day and agenda views; keyboard creation
|
|
5
|
+
* (Enter on an empty day or slot) and moving (Alt + arrows on an event); drag and drop; explicit
|
|
6
|
+
* time zones. Events are the app's data: the calendar reports `onCreate` and `onEventChange`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function EventCalendar<E extends CalendarEvent>(props: EventCalendarProps<E>): import("react").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=event-calendar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-calendar.d.ts","sourceRoot":"","sources":["../src/event-calendar.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAkC,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGvH,eAAO,MAAM,wBAAwB,EAAE,iBAkBtC,CAAC;AAeF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,aAAa,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,+BAm2BlF"}
|