@zealakit/chrono-react 1.0.0-beta.1 → 1.0.0-beta.2
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 +1 -0
- package/dist/calendar/components.d.ts +2 -2
- package/dist/calendar/components.js +10 -12
- package/dist/calendar/mini-calendar.js +6 -5
- package/dist/calendar/use-calendar.js +1 -3
- package/dist/calendar/use-mini-calendar.js +1 -1
- package/dist/date/bind-panel.js +1 -1
- package/dist/date/components.js +20 -29
- package/dist/date/utilities.d.ts +1 -1
- package/dist/date/utilities.js +1 -1
- package/dist/datetime/components.js +16 -21
- package/dist/datetime/use-datetime-panel.js +1 -1
- package/dist/shared/defined-options.d.ts +18 -0
- package/dist/shared/defined-options.js +9 -0
- package/dist/shared/merge-props.js +1 -3
- package/dist/shared/part.d.ts +1 -1
- package/dist/shared/slot.js +1 -4
- package/dist/shared/style-properties.js +1 -1
- package/dist/time/bind-panel.js +2 -2
- package/dist/time/components.d.ts +2 -2
- package/dist/time/components.js +16 -21
- package/dist/time/utilities.d.ts +1 -1
- package/dist/time/utilities.js +1 -1
- package/dist/vendor/core/calendar/availability.d.ts +2 -2
- package/dist/vendor/core/calendar/availability.js +4 -5
- package/dist/vendor/core/calendar/controllers/calendar-controller.js +93 -145
- package/dist/vendor/core/calendar/controllers/drag-engine.js +15 -34
- package/dist/vendor/core/calendar/controllers/mini-calendar-controller.js +3 -2
- package/dist/vendor/core/calendar/controllers/shared.d.ts +9 -5
- package/dist/vendor/core/calendar/controllers/shared.js +8 -8
- package/dist/vendor/core/calendar/events/agenda-layout.js +4 -3
- package/dist/vendor/core/calendar/events/all-day-row.d.ts +1 -1
- package/dist/vendor/core/calendar/events/all-day-row.js +5 -5
- package/dist/vendor/core/calendar/events/background-layout.d.ts +1 -1
- package/dist/vendor/core/calendar/events/background-layout.js +6 -7
- package/dist/vendor/core/calendar/events/month-layout.js +6 -5
- package/dist/vendor/core/calendar/events/normalize.d.ts +2 -2
- package/dist/vendor/core/calendar/events/normalize.js +6 -9
- package/dist/vendor/core/calendar/events/now-indicator.d.ts +2 -2
- package/dist/vendor/core/calendar/events/time-grid-layout.d.ts +4 -4
- package/dist/vendor/core/calendar/events/time-grid-layout.js +8 -15
- package/dist/vendor/core/calendar/events/types.d.ts +2 -2
- package/dist/vendor/core/calendar/index.d.ts +11 -11
- package/dist/vendor/core/calendar/index.js +5 -5
- package/dist/vendor/core/calendar/interaction/auto-scroll.d.ts +1 -9
- package/dist/vendor/core/calendar/interaction/auto-scroll.js +12 -39
- package/dist/vendor/core/calendar/interaction/drag-geometry.js +2 -5
- package/dist/vendor/core/calendar/interaction/drag-keyboard.js +1 -4
- package/dist/vendor/core/calendar/interaction/drag-pointer.d.ts +5 -4
- package/dist/vendor/core/calendar/interaction/drag-pointer.js +33 -193
- package/dist/vendor/core/calendar/interaction/gesture-handle.d.ts +17 -0
- package/dist/vendor/core/calendar/interaction/gesture-handle.js +26 -0
- package/dist/vendor/core/calendar/interaction/pointer.d.ts +1 -1
- package/dist/vendor/core/calendar/interaction/pointer.js +65 -15
- package/dist/vendor/core/calendar/interaction/selection.d.ts +1 -1
- package/dist/vendor/core/calendar/navigation/navigate.d.ts +3 -3
- package/dist/vendor/core/calendar/navigation/navigate.js +1 -3
- package/dist/vendor/core/calendar/navigation/range.js +1 -1
- package/dist/vendor/core/calendar/navigation/view-definition.d.ts +1 -1
- package/dist/vendor/core/calendar/navigation/view-definition.js +2 -1
- package/dist/vendor/core/calendar/recurrence/apply.js +7 -8
- package/dist/vendor/core/calendar/recurrence/expand.d.ts +1 -1
- package/dist/vendor/core/calendar/recurrence/expand.js +14 -18
- package/dist/vendor/core/calendar/recurrence/pack.js +4 -7
- package/dist/vendor/core/calendar/recurrence/rrule.js +6 -16
- package/dist/vendor/core/calendar/recurrence/series.js +1 -3
- package/dist/vendor/core/calendar/recurrence/types.d.ts +1 -1
- package/dist/vendor/core/calendar/resources/resource-time-grid.js +1 -2
- package/dist/vendor/core/calendar/resources/timeline-layout.js +4 -6
- package/dist/vendor/core/calendar/resources/types.d.ts +7 -7
- package/dist/vendor/core/calendar/views/day.d.ts +5 -5
- package/dist/vendor/core/calendar/views/day.js +2 -5
- package/dist/vendor/core/calendar/views/mini-calendar.d.ts +8 -8
- package/dist/vendor/core/calendar/views/mini-calendar.js +1 -1
- package/dist/vendor/core/calendar/views/month-layout.d.ts +1 -1
- package/dist/vendor/core/calendar/views/month-layout.js +1 -1
- package/dist/vendor/core/calendar/views/time-grid-layout.js +1 -4
- package/dist/vendor/core/date/input/date-input-controller.d.ts +15 -15
- package/dist/vendor/core/date/input/date-input-controller.js +9 -21
- package/dist/vendor/core/date/input/date-range-input-controller.js +2 -5
- package/dist/vendor/core/date/input/parse.d.ts +2 -2
- package/dist/vendor/core/date/input/parse.js +3 -9
- package/dist/vendor/core/date/input/validity.js +1 -1
- package/dist/vendor/core/date/panel/panel-controller.d.ts +11 -11
- package/dist/vendor/core/date/panel/panel-controller.js +18 -40
- package/dist/vendor/core/date/presets.js +1 -2
- package/dist/vendor/core/date/selection/multiple.js +2 -5
- package/dist/vendor/core/date/selection/range.d.ts +2 -2
- package/dist/vendor/core/date/selection/range.js +2 -6
- package/dist/vendor/core/datetime/compose.d.ts +3 -3
- package/dist/vendor/core/datetime/constraints.d.ts +9 -9
- package/dist/vendor/core/datetime/input/datetime-input-controller.d.ts +2 -2
- package/dist/vendor/core/datetime/input/datetime-input-controller.js +12 -27
- package/dist/vendor/core/datetime/input/datetime-range-input-controller.js +5 -16
- package/dist/vendor/core/datetime/input/parse.d.ts +2 -2
- package/dist/vendor/core/datetime/input/parse.js +2 -5
- package/dist/vendor/core/datetime/panel/controller.js +4 -10
- package/dist/vendor/core/datetime/panel/range-controller.js +4 -16
- package/dist/vendor/core/datetime/zone/day-instants.js +1 -3
- package/dist/vendor/core/datetime/zone/resolve.js +2 -4
- package/dist/vendor/core/dom/auto-scroll.d.ts +37 -0
- package/dist/vendor/core/dom/auto-scroll.js +57 -0
- package/dist/vendor/core/dom/drag-session.d.ts +25 -0
- package/dist/vendor/core/dom/drag-session.js +257 -0
- package/dist/vendor/core/foundation/a11y/announcer.d.ts +9 -4
- package/dist/vendor/core/foundation/a11y/announcer.js +15 -27
- package/dist/vendor/core/foundation/a11y/grid-navigation.d.ts +2 -2
- package/dist/vendor/core/foundation/a11y/grid-navigation.js +2 -12
- package/dist/vendor/core/foundation/a11y/roving-focus.js +23 -2
- package/dist/vendor/core/foundation/constraints/availability-rules.js +2 -4
- package/dist/vendor/core/foundation/constraints/availability.d.ts +6 -6
- package/dist/vendor/core/foundation/constraints/availability.js +6 -16
- package/dist/vendor/core/foundation/constraints/date.d.ts +3 -3
- package/dist/vendor/core/foundation/constraints/index.d.ts +1 -1
- package/dist/vendor/core/foundation/constraints/range.d.ts +4 -4
- package/dist/vendor/core/foundation/constraints/range.js +1 -1
- package/dist/vendor/core/foundation/constraints/time.d.ts +5 -5
- package/dist/vendor/core/foundation/constraints/time.js +1 -1
- package/dist/vendor/core/foundation/grid/index.d.ts +2 -2
- package/dist/vendor/core/foundation/grid/month-grid.d.ts +2 -2
- package/dist/vendor/core/foundation/grid/time-axis.d.ts +3 -3
- package/dist/vendor/core/foundation/grid/time-axis.js +1 -1
- package/dist/vendor/core/foundation/input/index.d.ts +1 -1
- package/dist/vendor/core/foundation/input/index.js +1 -1
- package/dist/vendor/core/foundation/input/segment-engine.js +2 -6
- package/dist/vendor/core/foundation/locale/direction.js +1 -13
- package/dist/vendor/core/foundation/locale/format.js +1 -3
- package/dist/vendor/core/foundation/locale/hour-cycle.js +2 -6
- package/dist/vendor/core/foundation/locale/index.d.ts +1 -1
- package/dist/vendor/core/foundation/locale/index.js +1 -1
- package/dist/vendor/core/foundation/locale/resolve.js +12 -2
- package/dist/vendor/core/foundation/locale/week-info.js +1 -2
- package/dist/vendor/core/foundation/ranges/index.d.ts +1 -1
- package/dist/vendor/core/foundation/ranges/index.js +1 -1
- package/dist/vendor/core/foundation/ranges/interval.js +1 -3
- package/dist/vendor/core/foundation/store/controllable.d.ts +1 -1
- package/dist/vendor/core/foundation/store/ids.d.ts +8 -1
- package/dist/vendor/core/foundation/store/ids.js +10 -5
- package/dist/vendor/core/foundation/store/index.d.ts +2 -2
- package/dist/vendor/core/foundation/store/index.js +2 -2
- package/dist/vendor/core/foundation/store/with-optional.d.ts +15 -0
- package/dist/vendor/core/foundation/store/with-optional.js +3 -0
- package/dist/vendor/core/foundation/values/convert.js +3 -7
- package/dist/vendor/core/foundation/values/epoch-day.js +1 -5
- package/dist/vendor/core/foundation/values/index.d.ts +1 -1
- package/dist/vendor/core/foundation/values/index.js +1 -1
- package/dist/vendor/core/foundation/values/iso.js +2 -4
- package/dist/vendor/core/foundation/values/plain-time.js +1 -3
- package/dist/vendor/core/foundation/values/zoned.js +2 -5
- package/dist/vendor/core/time/input/parse.d.ts +1 -1
- package/dist/vendor/core/time/input/parse.js +1 -3
- package/dist/vendor/core/time/input/time-input-controller.d.ts +18 -18
- package/dist/vendor/core/time/input/time-input-controller.js +12 -27
- package/dist/vendor/core/time/input/time-range-input-controller.js +3 -10
- package/dist/vendor/core/time/input/validity.js +1 -1
- package/dist/vendor/core/time/panel/time-panel-controller.d.ts +12 -12
- package/dist/vendor/core/time/panel/time-panel-controller.js +19 -49
- package/dist/vendor/core/time/selection/range.d.ts +3 -3
- package/dist/vendor/core/time/selection/slots.d.ts +9 -9
- package/dist/vendor/core/time/selection/slots.js +1 -3
- package/package.json +21 -28
- package/dist/vendor/core/foundation/store/global-state.d.ts +0 -1
- package/dist/vendor/core/foundation/store/global-state.js +0 -21
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type Attributes, type DateInput, type DayOfWeek, type GridNavContext, type GridNavKey, type Messages, type PlainDate, type WeekdayHeader } from "../../foundation/index.js";
|
|
2
2
|
import type { CalendarDay } from "../views/day.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Ids for calendar and mini-calendar roots without an app id (08-1 Step 2, X11).
|
|
5
|
+
* The engine owns the page-wide counter so two calendars or two Core copies never
|
|
6
|
+
* collide; adapters pass framework ids for SSR.
|
|
7
|
+
*/
|
|
4
8
|
export declare function nextId(prefix: string): string;
|
|
5
9
|
export type Modifiers = {
|
|
6
10
|
shift: boolean;
|
|
@@ -12,14 +16,14 @@ export declare const isNavKey: (key: string) => key is GridNavKey;
|
|
|
12
16
|
export declare function moveInMonthGrid(current: PlainDate, key: GridNavKey, shift: boolean, ctx: GridNavContext, hidden: readonly DayOfWeek[]): PlainDate;
|
|
13
17
|
/** Attributes every day element shares (cells, time-grid headers, agenda days). */
|
|
14
18
|
export declare function dayAttributes(day: CalendarDay, role: string, options: {
|
|
15
|
-
locale?: string;
|
|
19
|
+
locale?: string | undefined;
|
|
16
20
|
messages: Messages;
|
|
17
|
-
extraLabel?: string;
|
|
21
|
+
extraLabel?: string | undefined;
|
|
18
22
|
}): Attributes;
|
|
19
23
|
export declare function cellAttributes(day: CalendarDay, options: {
|
|
20
|
-
locale?: string;
|
|
24
|
+
locale?: string | undefined;
|
|
21
25
|
messages: Messages;
|
|
22
|
-
extraLabel?: string;
|
|
26
|
+
extraLabel?: string | undefined;
|
|
23
27
|
}): Attributes;
|
|
24
28
|
export declare function columnHeaderAttributes(header: WeekdayHeader): Attributes;
|
|
25
29
|
export declare function weekNumberAttributes(weekNumber: number, messages: Messages): Attributes;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { dayOfWeek, formatMessage, getDateLabel,
|
|
2
|
-
/**
|
|
1
|
+
import { dayOfWeek, formatMessage, getDateLabel, createId, nextFocusedDate, toIsoString, toPlainDate, } from "../../foundation/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Ids for calendar and mini-calendar roots without an app id (08-1 Step 2, X11).
|
|
4
|
+
* The engine owns the page-wide counter so two calendars or two Core copies never
|
|
5
|
+
* collide; adapters pass framework ids for SSR.
|
|
6
|
+
*/
|
|
3
7
|
export function nextId(prefix) {
|
|
4
|
-
|
|
5
|
-
state.count += 1;
|
|
6
|
-
return `${prefix}-${state.count}`;
|
|
8
|
+
return createId(prefix);
|
|
7
9
|
}
|
|
8
10
|
const NAV_KEYS = new Set([
|
|
9
11
|
"ArrowLeft",
|
|
@@ -29,9 +31,7 @@ export function dayAttributes(day, role, options) {
|
|
|
29
31
|
const label = getDateLabel(day.date, options.locale, { today: day.today, selected: day.selected, disabled: day.disabled }, options.messages);
|
|
30
32
|
return {
|
|
31
33
|
role,
|
|
32
|
-
"aria-label": options.extraLabel
|
|
33
|
-
? `${label}, ${options.extraLabel}`
|
|
34
|
-
: label,
|
|
34
|
+
"aria-label": options.extraLabel ? `${label}, ${options.extraLabel}` : label,
|
|
35
35
|
"aria-current": day.today ? "date" : undefined,
|
|
36
36
|
"aria-disabled": day.disabled ? "true" : undefined,
|
|
37
37
|
tabindex: day.focused ? 0 : -1,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { compare, toEpochDay
|
|
1
|
+
import { compare, toEpochDay } from "../../foundation/index.js";
|
|
2
2
|
import { coveredDays, wallSecondsOf } from "./normalize.js";
|
|
3
3
|
import { compareEventIds } from "./sort.js";
|
|
4
|
+
import { withOptional } from "../../foundation/store/with-optional.js";
|
|
4
5
|
function compareAgenda(a, b) {
|
|
5
6
|
if (a.allDay !== b.allDay) {
|
|
6
7
|
return a.allDay ? -1 : 1;
|
|
@@ -37,7 +38,7 @@ export function layoutAgenda(events, days, options = {}) {
|
|
|
37
38
|
continue;
|
|
38
39
|
}
|
|
39
40
|
const dayKey = days[index].key;
|
|
40
|
-
const item = {
|
|
41
|
+
const item = withOptional({
|
|
41
42
|
key: `${event.key}:${dayKey}`,
|
|
42
43
|
event: event.event,
|
|
43
44
|
start: event.start,
|
|
@@ -48,7 +49,7 @@ export function layoutAgenda(events, days, options = {}) {
|
|
|
48
49
|
past: now !== undefined && compare(event.end, now) <= 0,
|
|
49
50
|
recurrence: event.recurrence,
|
|
50
51
|
dayKey,
|
|
51
|
-
};
|
|
52
|
+
});
|
|
52
53
|
const list = byDay.get(index);
|
|
53
54
|
if (list) {
|
|
54
55
|
list.push(item);
|
|
@@ -5,7 +5,7 @@ export type AllDayRowOptions = {
|
|
|
5
5
|
/** `allDayEventLimit`, default 3 (plan 05 §2.6). */
|
|
6
6
|
eventLimit?: number;
|
|
7
7
|
/** Timed events of 24h or more move here (plan 05 E5), default `true`. */
|
|
8
|
-
longEventsInAllDayRow?: boolean;
|
|
8
|
+
longEventsInAllDayRow?: boolean | undefined;
|
|
9
9
|
now?: PlainDateTime;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { compare, toEpochDay
|
|
1
|
+
import { compare, toEpochDay } from "../../foundation/index.js";
|
|
2
2
|
import { coveredDays, wallSecondsOf } from "./normalize.js";
|
|
3
3
|
import { applyPieceLimit } from "./overflow.js";
|
|
4
4
|
import { compareMonthSegments } from "./sort.js";
|
|
5
|
+
import { withOptional } from "../../foundation/store/with-optional.js";
|
|
5
6
|
const SECONDS_PER_DAY = 86400;
|
|
6
7
|
function laneOverlaps(occupied, start, days) {
|
|
7
8
|
if (!occupied) {
|
|
@@ -27,8 +28,7 @@ export function layoutAllDayRow(events, days, options = {}) {
|
|
|
27
28
|
}
|
|
28
29
|
const pieces = [];
|
|
29
30
|
for (const event of events) {
|
|
30
|
-
const isLong = longEvents &&
|
|
31
|
-
wallSecondsOf(event.end) - wallSecondsOf(event.start) >= SECONDS_PER_DAY;
|
|
31
|
+
const isLong = longEvents && wallSecondsOf(event.end) - wallSecondsOf(event.start) >= SECONDS_PER_DAY;
|
|
32
32
|
if (!event.allDay && !isLong) {
|
|
33
33
|
continue;
|
|
34
34
|
}
|
|
@@ -55,7 +55,7 @@ export function layoutAllDayRow(events, days, options = {}) {
|
|
|
55
55
|
continue; // no visible day
|
|
56
56
|
}
|
|
57
57
|
const firstKey = days[startColumn]?.key;
|
|
58
|
-
pieces.push({
|
|
58
|
+
pieces.push(withOptional({
|
|
59
59
|
key: `${event.key}:${firstKey}`,
|
|
60
60
|
event: event.event,
|
|
61
61
|
start: event.start,
|
|
@@ -70,7 +70,7 @@ export function layoutAllDayRow(events, days, options = {}) {
|
|
|
70
70
|
days: endColumn - startColumn + 1,
|
|
71
71
|
lane: 0,
|
|
72
72
|
hidden: false,
|
|
73
|
-
});
|
|
73
|
+
}));
|
|
74
74
|
}
|
|
75
75
|
pieces.sort(compareMonthSegments);
|
|
76
76
|
const lanes = [];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { addDays, fromInstant, fromSecondOfDay, plainDateTime, toSecondOfDay, } from "../../foundation/index.js";
|
|
2
2
|
import { wallSecondsOf } from "./normalize.js";
|
|
3
|
+
import { withOptional } from "../../foundation/store/with-optional.js";
|
|
3
4
|
const SECONDS_PER_DAY = 86400;
|
|
4
5
|
const wants = (mode, status) => mode === "both" || mode === status;
|
|
5
6
|
/**
|
|
@@ -12,9 +13,7 @@ export function layoutBackgrounds(options) {
|
|
|
12
13
|
return [];
|
|
13
14
|
}
|
|
14
15
|
const axisStart = options.dayStart ? toSecondOfDay(options.dayStart) : 0;
|
|
15
|
-
const rawEnd = options.dayEnd
|
|
16
|
-
? toSecondOfDay(options.dayEnd)
|
|
17
|
-
: SECONDS_PER_DAY;
|
|
16
|
+
const rawEnd = options.dayEnd ? toSecondOfDay(options.dayEnd) : SECONDS_PER_DAY;
|
|
18
17
|
const axisEnd = rawEnd <= axisStart ? SECONDS_PER_DAY : rawEnd;
|
|
19
18
|
const axisLength = axisEnd - axisStart;
|
|
20
19
|
const pieces = [];
|
|
@@ -31,7 +30,7 @@ export function layoutBackgrounds(options) {
|
|
|
31
30
|
const top = (toSecondOfDay(wallStart) - axisStart) / axisLength;
|
|
32
31
|
const height = (wallSecondsOf(wallEnd) - wallSecondsOf(wallStart)) / axisLength;
|
|
33
32
|
const clampedTop = Math.max(0, Math.min(1, top));
|
|
34
|
-
pieces.push({
|
|
33
|
+
pieces.push(withOptional({
|
|
35
34
|
key: `${day.resourceKey ?? ""}:${day.key}:${interval.start}`,
|
|
36
35
|
dayKey: day.key,
|
|
37
36
|
resourceKey: day.resourceKey,
|
|
@@ -39,7 +38,7 @@ export function layoutBackgrounds(options) {
|
|
|
39
38
|
height: Math.max(0, Math.min(1 - clampedTop, height)),
|
|
40
39
|
status: interval.status,
|
|
41
40
|
rules: interval.rules,
|
|
42
|
-
});
|
|
41
|
+
}));
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
return pieces;
|
|
@@ -67,7 +66,7 @@ export function layoutTimelineBackgrounds(options) {
|
|
|
67
66
|
const left = (wallSecondsOf(wallStart) - startSeconds) / length;
|
|
68
67
|
const width = (wallSecondsOf(wallEnd) - wallSecondsOf(wallStart)) / length;
|
|
69
68
|
const clampedLeft = Math.max(0, Math.min(1, left));
|
|
70
|
-
pieces.push({
|
|
69
|
+
pieces.push(withOptional({
|
|
71
70
|
key: `${row.resourceKey ?? row.key}:${interval.start}`,
|
|
72
71
|
rowKey: row.key,
|
|
73
72
|
resourceKey: row.resourceKey,
|
|
@@ -75,7 +74,7 @@ export function layoutTimelineBackgrounds(options) {
|
|
|
75
74
|
width: Math.max(0, Math.min(1 - clampedLeft, width)),
|
|
76
75
|
status: interval.status,
|
|
77
76
|
rules: interval.rules,
|
|
78
|
-
});
|
|
77
|
+
}));
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
80
|
return pieces;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { compare, toEpochDay
|
|
1
|
+
import { compare, toEpochDay } from "../../foundation/index.js";
|
|
2
2
|
import { coveredDays } from "./normalize.js";
|
|
3
3
|
import { compareMonthSegments } from "./sort.js";
|
|
4
|
+
import { withOptional } from "../../foundation/store/with-optional.js";
|
|
4
5
|
/**
|
|
5
6
|
* The month grid that owns each visible day. A day that exists twice in a
|
|
6
7
|
* multi-month layout (once in-month, once as an adjacent day) is hosted by its
|
|
@@ -76,7 +77,7 @@ export function layoutMonthEvents(events, layout, options = {}) {
|
|
|
76
77
|
pieces.push({
|
|
77
78
|
month: row.month,
|
|
78
79
|
week: row.week,
|
|
79
|
-
segment: {
|
|
80
|
+
segment: withOptional({
|
|
80
81
|
...base,
|
|
81
82
|
key: `${event.key}:${first.key}`,
|
|
82
83
|
allDay: true,
|
|
@@ -88,7 +89,7 @@ export function layoutMonthEvents(events, layout, options = {}) {
|
|
|
88
89
|
days: row.cells.length,
|
|
89
90
|
lane: 0,
|
|
90
91
|
hidden: false,
|
|
91
|
-
},
|
|
92
|
+
}),
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
95
|
else {
|
|
@@ -96,7 +97,7 @@ export function layoutMonthEvents(events, layout, options = {}) {
|
|
|
96
97
|
pieces.push({
|
|
97
98
|
month: row.month,
|
|
98
99
|
week: row.week,
|
|
99
|
-
segment: {
|
|
100
|
+
segment: withOptional({
|
|
100
101
|
...base,
|
|
101
102
|
key: `${event.key}:${cell.key}`,
|
|
102
103
|
allDay: false,
|
|
@@ -108,7 +109,7 @@ export function layoutMonthEvents(events, layout, options = {}) {
|
|
|
108
109
|
days: 1,
|
|
109
110
|
lane: 0,
|
|
110
111
|
hidden: false,
|
|
111
|
-
},
|
|
112
|
+
}),
|
|
112
113
|
});
|
|
113
114
|
}
|
|
114
115
|
}
|
|
@@ -7,8 +7,8 @@ export type NormalizeOptions = {
|
|
|
7
7
|
/** Display zone. Defaults to `"UTC"`, never the host zone. */
|
|
8
8
|
timeZone?: string;
|
|
9
9
|
/** The opt-in recurrence pack (plan 12 RR2). */
|
|
10
|
-
recurrence?: RecurrencePack;
|
|
11
|
-
onRecurrenceError?: (event: CalendarEventInput, error: RRuleError) => void;
|
|
10
|
+
recurrence?: RecurrencePack | undefined;
|
|
11
|
+
onRecurrenceError?: ((event: CalendarEventInput, error: RRuleError) => void) | undefined;
|
|
12
12
|
};
|
|
13
13
|
/** One development warning per cause per process (plan 13). */
|
|
14
14
|
export declare function warnOnce(message: string): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { addDays, compare, plainDateTime, toEpochDay, toPlainDate, toPlainDateTime, toSecondOfDay, } from "../../foundation/index.js";
|
|
2
|
+
import { withOptional } from "../../foundation/store/with-optional.js";
|
|
2
3
|
const MIDNIGHT = { hour: 0, minute: 0, second: 0 };
|
|
3
4
|
const warned = new Set();
|
|
4
5
|
/** One development warning per cause per process (plan 13). */
|
|
@@ -35,9 +36,7 @@ function resourceIdsOf(value) {
|
|
|
35
36
|
if (value === undefined) {
|
|
36
37
|
return undefined;
|
|
37
38
|
}
|
|
38
|
-
const list = Array.isArray(value)
|
|
39
|
-
? value
|
|
40
|
-
: [value];
|
|
39
|
+
const list = Array.isArray(value) ? value : [value];
|
|
41
40
|
const seen = new Set();
|
|
42
41
|
return list.filter((id) => {
|
|
43
42
|
const key = String(id);
|
|
@@ -52,9 +51,7 @@ function resourceIdsOf(value) {
|
|
|
52
51
|
export function coveredDays(start, end, allDay) {
|
|
53
52
|
const firstDay = toEpochDay(start);
|
|
54
53
|
const endsAtMidnight = end.hour === 0 && end.minute === 0 && end.second === 0;
|
|
55
|
-
const lastDay = allDay
|
|
56
|
-
? toEpochDay(end) - 1
|
|
57
|
-
: toEpochDay(end) - (endsAtMidnight ? 1 : 0);
|
|
54
|
+
const lastDay = allDay ? toEpochDay(end) - 1 : toEpochDay(end) - (endsAtMidnight ? 1 : 0);
|
|
58
55
|
return { firstDay, lastDay };
|
|
59
56
|
}
|
|
60
57
|
/** Wall-clock seconds since epoch as if the value were UTC (no host zone). */
|
|
@@ -98,7 +95,7 @@ export function normalizeEventInput(event, timeZone = "UTC") {
|
|
|
98
95
|
end = tmp;
|
|
99
96
|
warnOnce(`[chrono] Event "${String(event.id)}" has end before start; swapped.`);
|
|
100
97
|
}
|
|
101
|
-
return {
|
|
98
|
+
return withOptional({
|
|
102
99
|
id: event.id,
|
|
103
100
|
key: String(event.id),
|
|
104
101
|
event,
|
|
@@ -108,7 +105,7 @@ export function normalizeEventInput(event, timeZone = "UTC") {
|
|
|
108
105
|
recurringId: event.recurringId,
|
|
109
106
|
calendarId: event.calendarId,
|
|
110
107
|
resourceIds: resourceIdsOf(event.resourceId),
|
|
111
|
-
};
|
|
108
|
+
});
|
|
112
109
|
}
|
|
113
110
|
/**
|
|
114
111
|
* Parse events into display-zone wall time, resolve all-day, swap reversed
|
|
@@ -124,7 +121,7 @@ export function normalizeEvents(events, options) {
|
|
|
124
121
|
timeZone,
|
|
125
122
|
onRecurrenceError: options.onRecurrenceError,
|
|
126
123
|
});
|
|
127
|
-
return occurrences.map((occurrence) => ({
|
|
124
|
+
return occurrences.map((occurrence) => withOptional({
|
|
128
125
|
id: occurrence.event.id,
|
|
129
126
|
key: occurrence.key,
|
|
130
127
|
event: occurrence.event,
|
|
@@ -13,6 +13,6 @@ export type NowIndicatorDay = {
|
|
|
13
13
|
* `top` is a fraction 0–1 of the axis `[dayStart, dayEnd)`.
|
|
14
14
|
*/
|
|
15
15
|
export declare function getNowIndicator(now: PlainDateTime, days: readonly NowIndicatorDay[], options?: {
|
|
16
|
-
dayStart?: PlainTime;
|
|
17
|
-
dayEnd?: PlainTime;
|
|
16
|
+
dayStart?: PlainTime | undefined;
|
|
17
|
+
dayEnd?: PlainTime | undefined;
|
|
18
18
|
}): NowIndicator | null;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { type PlainDate, type PlainDateTime, type PlainTime } from "../../foundation/index.js";
|
|
2
2
|
import type { CalendarEventInput, NormalizedEvent, TimeGridSegment } from "./types.js";
|
|
3
3
|
export type TimeGridEventsOptions = {
|
|
4
|
-
dayStart?: PlainTime;
|
|
4
|
+
dayStart?: PlainTime | undefined;
|
|
5
5
|
/** Exclusive; omit for 24:00. */
|
|
6
|
-
dayEnd?: PlainTime;
|
|
6
|
+
dayEnd?: PlainTime | undefined;
|
|
7
7
|
/** Minimum drawn height in minutes (plan 05 E4), default 15. */
|
|
8
|
-
minEventDuration?: number;
|
|
8
|
+
minEventDuration?: number | undefined;
|
|
9
9
|
/** Timed events of 24h or more move to the all-day row (E5), default `true`. */
|
|
10
|
-
longEventsInAllDayRow?: boolean;
|
|
10
|
+
longEventsInAllDayRow?: boolean | undefined;
|
|
11
11
|
now?: PlainDateTime;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { compare, splitIntervalByDay, toEpochDay, toSecondOfDay, } from "../../foundation/index.js";
|
|
2
2
|
import { wallSecondsOf } from "./normalize.js";
|
|
3
3
|
import { compareEventIds } from "./sort.js";
|
|
4
|
+
import { withOptional } from "../../foundation/store/with-optional.js";
|
|
4
5
|
const SECONDS_PER_DAY = 86400;
|
|
5
6
|
function secondsInDay(value, date) {
|
|
6
7
|
return wallSecondsOf(value) - toEpochDay(date) * SECONDS_PER_DAY;
|
|
@@ -24,8 +25,7 @@ function assignColumns(members) {
|
|
|
24
25
|
const columnEnds = [];
|
|
25
26
|
for (const item of members) {
|
|
26
27
|
let column = 0;
|
|
27
|
-
while (column < columnEnds.length &&
|
|
28
|
-
columnEnds[column] > item.startSec) {
|
|
28
|
+
while (column < columnEnds.length && columnEnds[column] > item.startSec) {
|
|
29
29
|
column += 1;
|
|
30
30
|
}
|
|
31
31
|
if (column === columnEnds.length) {
|
|
@@ -42,9 +42,7 @@ function assignColumns(members) {
|
|
|
42
42
|
let span = 1;
|
|
43
43
|
while (item.column + span < columns) {
|
|
44
44
|
const column = item.column + span;
|
|
45
|
-
const overlap = members.some((other) => other.column === column &&
|
|
46
|
-
other.startSec < item.endSec &&
|
|
47
|
-
item.startSec < other.endSec);
|
|
45
|
+
const overlap = members.some((other) => other.column === column && other.startSec < item.endSec && item.startSec < other.endSec);
|
|
48
46
|
if (overlap) {
|
|
49
47
|
break;
|
|
50
48
|
}
|
|
@@ -61,9 +59,7 @@ function assignColumns(members) {
|
|
|
61
59
|
*/
|
|
62
60
|
export function layoutTimeGridEvents(events, days, options = {}) {
|
|
63
61
|
const axisStart = options.dayStart ? toSecondOfDay(options.dayStart) : 0;
|
|
64
|
-
const axisEnd = options.dayEnd
|
|
65
|
-
? toSecondOfDay(options.dayEnd)
|
|
66
|
-
: SECONDS_PER_DAY;
|
|
62
|
+
const axisEnd = options.dayEnd ? toSecondOfDay(options.dayEnd) : SECONDS_PER_DAY;
|
|
67
63
|
const axisLength = axisEnd - axisStart;
|
|
68
64
|
const minDuration = (options.minEventDuration ?? 15) * 60;
|
|
69
65
|
const longEvents = options.longEventsInAllDayRow ?? true;
|
|
@@ -77,8 +73,7 @@ export function layoutTimeGridEvents(events, days, options = {}) {
|
|
|
77
73
|
if (event.allDay) {
|
|
78
74
|
continue;
|
|
79
75
|
}
|
|
80
|
-
if (longEvents &&
|
|
81
|
-
wallSecondsOf(event.end) - wallSecondsOf(event.start) >= SECONDS_PER_DAY) {
|
|
76
|
+
if (longEvents && wallSecondsOf(event.end) - wallSecondsOf(event.start) >= SECONDS_PER_DAY) {
|
|
82
77
|
continue;
|
|
83
78
|
}
|
|
84
79
|
// `splitIntervalByDay` returns nothing for an empty interval, so a
|
|
@@ -107,9 +102,7 @@ export function layoutTimeGridEvents(events, days, options = {}) {
|
|
|
107
102
|
// A zero-length event (no `end`) is kept when it starts inside the axis
|
|
108
103
|
// and drawn at the minimum height; anything else must overlap the axis.
|
|
109
104
|
const zeroLength = startSec === endSec;
|
|
110
|
-
if (zeroLength
|
|
111
|
-
? startSec < axisStart || startSec >= axisEnd
|
|
112
|
-
: clippedEnd <= clippedStart) {
|
|
105
|
+
if (zeroLength ? startSec < axisStart || startSec >= axisEnd : clippedEnd <= clippedStart) {
|
|
113
106
|
continue;
|
|
114
107
|
}
|
|
115
108
|
const realHeight = (clippedEnd - clippedStart) / axisLength;
|
|
@@ -161,7 +154,7 @@ export function layoutTimeGridEvents(events, days, options = {}) {
|
|
|
161
154
|
assignColumns(cluster.members);
|
|
162
155
|
}
|
|
163
156
|
for (const item of group) {
|
|
164
|
-
result.push({
|
|
157
|
+
result.push(withOptional({
|
|
165
158
|
key: item.key,
|
|
166
159
|
event: item.event,
|
|
167
160
|
start: item.start,
|
|
@@ -177,7 +170,7 @@ export function layoutTimeGridEvents(events, days, options = {}) {
|
|
|
177
170
|
column: item.column,
|
|
178
171
|
columns: item.columns,
|
|
179
172
|
span: item.span,
|
|
180
|
-
});
|
|
173
|
+
}));
|
|
181
174
|
}
|
|
182
175
|
}
|
|
183
176
|
return result;
|
|
@@ -35,9 +35,9 @@ export type CalendarEventInput = {
|
|
|
35
35
|
/** RFC 5545 rule or parsed rule: the event is a series (plan 12 RR1). */
|
|
36
36
|
rrule?: string | RRule;
|
|
37
37
|
/** Occurrence starts removed from the rule (RR1). */
|
|
38
|
-
exdates?: readonly (DateTimeInput | DateInput)[];
|
|
38
|
+
exdates?: readonly (DateTimeInput | DateInput)[] | undefined;
|
|
39
39
|
/** Extra occurrence starts (RR1). */
|
|
40
|
-
rdates?: readonly (DateTimeInput | DateInput)[];
|
|
40
|
+
rdates?: readonly (DateTimeInput | DateInput)[] | undefined;
|
|
41
41
|
/** With `recurringId`: the original occurrence this event replaces (RR6). */
|
|
42
42
|
recurrenceId?: DateTimeInput | DateInput;
|
|
43
43
|
/** Resource(s) the event belongs to, for resource views (plan 10 R2). */
|
|
@@ -9,7 +9,7 @@ export type { CalendarDay, DayContext } from "./views/day.js";
|
|
|
9
9
|
export { getMonthLayout } from "./views/month-layout.js";
|
|
10
10
|
export type { CalendarWeek, LayoutContext, MonthGridModel, MonthLayout, } from "./views/month-layout.js";
|
|
11
11
|
export { getTimeGridLayout } from "./views/time-grid-layout.js";
|
|
12
|
-
export type { TimeGridLayout, TimeGridOptions
|
|
12
|
+
export type { TimeGridLayout, TimeGridOptions } from "./views/time-grid-layout.js";
|
|
13
13
|
export { getListLayout } from "./views/list-layout.js";
|
|
14
14
|
export type { ListLayout } from "./views/list-layout.js";
|
|
15
15
|
export { getMiniCalendarLayout } from "./views/mini-calendar.js";
|
|
@@ -19,7 +19,7 @@ export type { CalendarController, CalendarLayout, CalendarMessages, CalendarOpti
|
|
|
19
19
|
export { createMiniCalendarController } from "./controllers/mini-calendar-controller.js";
|
|
20
20
|
export type { MiniCalendarController, MiniCalendarOptions, MiniCalendarState, MonthValue, } from "./controllers/mini-calendar-controller.js";
|
|
21
21
|
export type { Modifiers } from "./controllers/shared.js";
|
|
22
|
-
export { normalizeEvents, coveredDays, wallSecondsOf
|
|
22
|
+
export { normalizeEvents, coveredDays, wallSecondsOf } from "./events/normalize.js";
|
|
23
23
|
export type { NormalizeOptions } from "./events/normalize.js";
|
|
24
24
|
export { compareEventIds, compareMonthSegments } from "./events/sort.js";
|
|
25
25
|
export type { SortableSegment } from "./events/sort.js";
|
|
@@ -34,20 +34,20 @@ export type { NowIndicator, NowIndicatorDay } from "./events/now-indicator.js";
|
|
|
34
34
|
export { layoutAgenda } from "./events/agenda-layout.js";
|
|
35
35
|
export type { AgendaDay, AgendaOptions } from "./events/agenda-layout.js";
|
|
36
36
|
export { enterCell, isExitKey, stepFocus } from "./interaction/event-focus.js";
|
|
37
|
-
export type { FocusItems, FocusMode, FocusState
|
|
37
|
+
export type { FocusItems, FocusMode, FocusState } from "./interaction/event-focus.js";
|
|
38
38
|
export { computeSelection, selectionPieces } from "./interaction/selection.js";
|
|
39
|
-
export type { SelectionCell, SelectionOptions, SelectionRange
|
|
39
|
+
export type { SelectionCell, SelectionOptions, SelectionRange } from "./interaction/selection.js";
|
|
40
40
|
export { applyEventLimit, applyPieceLimit } from "./events/overflow.js";
|
|
41
41
|
export type { DayOverflow, OverflowResult } from "./events/overflow.js";
|
|
42
42
|
export type { AgendaItem, AllDayRowSegment, CalendarEventInput, CalendarEvents, EventId, EventSegmentBase, MonthEventLayout, MonthSegment, NormalizedEvent, SelectionProposal, TimeGridSegment, } from "./events/types.js";
|
|
43
|
-
export { autoScrollSpeed, createAutoScroll
|
|
43
|
+
export { autoScrollSpeed, createAutoScroll } from "./interaction/auto-scroll.js";
|
|
44
44
|
export type { AutoScroll } from "./interaction/auto-scroll.js";
|
|
45
|
-
export { moveEvent, nudgeEvent, resizeEvent, snapTo
|
|
46
|
-
export type { DragTarget, EditValue, GeometryOptions, Grab
|
|
45
|
+
export { moveEvent, nudgeEvent, resizeEvent, snapTo } from "./interaction/drag-geometry.js";
|
|
46
|
+
export type { DragTarget, EditValue, GeometryOptions, Grab } from "./interaction/drag-geometry.js";
|
|
47
47
|
export { editStep, matchShortcut } from "./interaction/drag-keyboard.js";
|
|
48
|
-
export type { EditKind, KeyStep, Shortcuts
|
|
48
|
+
export type { EditKind, KeyStep, Shortcuts } from "./interaction/drag-keyboard.js";
|
|
49
49
|
export type { PendingChange } from "./interaction/pending.js";
|
|
50
|
-
export type { ChangeValue, DragState, EventChangeProposal
|
|
50
|
+
export type { ChangeValue, DragState, EventChangeProposal } from "./controllers/drag-engine.js";
|
|
51
51
|
export { resourceViews } from "./resources/views.js";
|
|
52
52
|
export { resourceCellKey } from "./resources/keys.js";
|
|
53
53
|
export { buildResourceTree } from "./resources/tree.js";
|
|
@@ -58,13 +58,13 @@ export { clampWindow } from "./resources/windowing.js";
|
|
|
58
58
|
export { zoomTarget } from "./navigation/zoom.js";
|
|
59
59
|
export type { ResourceAllDayPiece, ResourceBuildContext, ResourceColumn, ResourceGrouping, ResourceGroupHeader, ResourceId, ResourceInput, ResourceLayout, ResourceRow, ResourceTimeGridLayout, ResourceTimeGridPiece, ResourceWindowInfo, TimelineAxis, TimelineHeaderCell, TimelineLayout, TimelinePiece, TimelineRow, TimelineSlot, TimelineSlotDuration, TimelineUnit, WindowRange, } from "./resources/types.js";
|
|
60
60
|
export type { ResourcePieceLike } from "./controllers/calendar-controller.js";
|
|
61
|
-
export { availabilityFromEvents, resolveCalendarAvailability, wallIso
|
|
61
|
+
export { availabilityFromEvents, resolveCalendarAvailability, wallIso } from "./availability.js";
|
|
62
62
|
export type { AvailabilityContext, AvailabilityFromEventsOptions, CalendarAvailabilityInput, } from "./availability.js";
|
|
63
63
|
export { backgroundAttributes, layoutBackgrounds, layoutTimelineBackgrounds, } from "./events/background-layout.js";
|
|
64
64
|
export type { BackgroundDay, BackgroundLayoutOptions, BackgroundMode, BackgroundPiece, BackgroundStatus, TimelineBackgroundOptions, TimelineBackgroundPiece, } from "./events/background-layout.js";
|
|
65
65
|
export { parseRRule, stringifyRRule } from "./recurrence/rrule.js";
|
|
66
66
|
export { expandRecurrence } from "./recurrence/series.js";
|
|
67
67
|
export { recurrence } from "./recurrence/pack.js";
|
|
68
|
-
export { applyRecurrenceChange, applyRecurrenceDelete
|
|
68
|
+
export { applyRecurrenceChange, applyRecurrenceDelete } from "./recurrence/apply.js";
|
|
69
69
|
export type { ApplyRecurrenceOptions, RecurrenceChangeResult, RecurrenceDeleteResult, RecurrenceOverride, RecurrenceScope, } from "./recurrence/apply.js";
|
|
70
70
|
export type { RRule, RRuleByDay, RRuleError, RRuleErrorCode, RRuleFreq, RRuleUntil, RecurrenceErrorHandler, RecurrenceExpandOptions, RecurrenceInfo, RecurrenceOccurrence, RecurrencePack, } from "./recurrence/types.js";
|
|
@@ -8,7 +8,7 @@ export { getListLayout } from "./views/list-layout.js";
|
|
|
8
8
|
export { getMiniCalendarLayout } from "./views/mini-calendar.js";
|
|
9
9
|
export { createCalendarController } from "./controllers/calendar-controller.js";
|
|
10
10
|
export { createMiniCalendarController } from "./controllers/mini-calendar-controller.js";
|
|
11
|
-
export { normalizeEvents, coveredDays, wallSecondsOf
|
|
11
|
+
export { normalizeEvents, coveredDays, wallSecondsOf } from "./events/normalize.js";
|
|
12
12
|
export { compareEventIds, compareMonthSegments } from "./events/sort.js";
|
|
13
13
|
export { layoutMonthEvents } from "./events/month-layout.js";
|
|
14
14
|
export { layoutAllDayRow } from "./events/all-day-row.js";
|
|
@@ -18,8 +18,8 @@ export { layoutAgenda } from "./events/agenda-layout.js";
|
|
|
18
18
|
export { enterCell, isExitKey, stepFocus } from "./interaction/event-focus.js";
|
|
19
19
|
export { computeSelection, selectionPieces } from "./interaction/selection.js";
|
|
20
20
|
export { applyEventLimit, applyPieceLimit } from "./events/overflow.js";
|
|
21
|
-
export { autoScrollSpeed, createAutoScroll
|
|
22
|
-
export { moveEvent, nudgeEvent, resizeEvent, snapTo
|
|
21
|
+
export { autoScrollSpeed, createAutoScroll } from "./interaction/auto-scroll.js";
|
|
22
|
+
export { moveEvent, nudgeEvent, resizeEvent, snapTo } from "./interaction/drag-geometry.js";
|
|
23
23
|
export { editStep, matchShortcut } from "./interaction/drag-keyboard.js";
|
|
24
24
|
export { resourceViews } from "./resources/views.js";
|
|
25
25
|
export { resourceCellKey } from "./resources/keys.js";
|
|
@@ -29,9 +29,9 @@ export { layoutTimeline } from "./resources/timeline-layout.js";
|
|
|
29
29
|
export { buildTimelineAxis, slotKeyOf } from "./resources/timeline-axis.js";
|
|
30
30
|
export { clampWindow } from "./resources/windowing.js";
|
|
31
31
|
export { zoomTarget } from "./navigation/zoom.js";
|
|
32
|
-
export { availabilityFromEvents, resolveCalendarAvailability, wallIso
|
|
32
|
+
export { availabilityFromEvents, resolveCalendarAvailability, wallIso } from "./availability.js";
|
|
33
33
|
export { backgroundAttributes, layoutBackgrounds, layoutTimelineBackgrounds, } from "./events/background-layout.js";
|
|
34
34
|
export { parseRRule, stringifyRRule } from "./recurrence/rrule.js";
|
|
35
35
|
export { expandRecurrence } from "./recurrence/series.js";
|
|
36
36
|
export { recurrence } from "./recurrence/pack.js";
|
|
37
|
-
export { applyRecurrenceChange, applyRecurrenceDelete
|
|
37
|
+
export { applyRecurrenceChange, applyRecurrenceDelete } from "./recurrence/apply.js";
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Auto-scroll while a drag is near an edge of the scroll container (plan 09 M12).
|
|
3
|
-
* `speed(d) = d >= 40 ? 0 : round(20 · (1 − d / 40))` pixels per frame.
|
|
4
|
-
*/
|
|
5
|
-
export declare const EDGE = 40;
|
|
6
|
-
export declare const MAX_SPEED = 20;
|
|
7
|
-
export declare function autoScrollSpeed(distance: number): number;
|
|
1
|
+
export { autoScrollSpeed } from "../../dom/auto-scroll.js";
|
|
8
2
|
export type AutoScroll = {
|
|
9
3
|
/** Start the loop for the pointer position; call again to move the point. */
|
|
10
4
|
update(point: {
|
|
@@ -13,7 +7,5 @@ export type AutoScroll = {
|
|
|
13
7
|
}): void;
|
|
14
8
|
stop(): void;
|
|
15
9
|
};
|
|
16
|
-
/** The nearest scrollable ancestor of `element`, or `null`. */
|
|
17
|
-
export declare function scrollParent(element: Element | null): HTMLElement | null;
|
|
18
10
|
/** A rAF loop that scrolls `getContainer()` toward the pointer; stops when asked. */
|
|
19
11
|
export declare function createAutoScroll(getContainer: () => HTMLElement | null): AutoScroll;
|
|
@@ -1,32 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Public edge auto-scroll helper (calendar API). The generic maths and the
|
|
3
|
+
* scrollable-ancestor lookup live in the private `src/dom/auto-scroll.ts`
|
|
4
|
+
* (plan 08-2 Step 4); this module keeps the published `createAutoScroll`
|
|
5
|
+
* behaviour and its own loop for backwards compatibility. The calendar's own
|
|
6
|
+
* drag uses the drag session's single frame loop instead (NP9).
|
|
4
7
|
*/
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
export function autoScrollSpeed(distance) {
|
|
8
|
-
const d = Math.max(0, distance);
|
|
9
|
-
return d >= EDGE ? 0 : Math.round(MAX_SPEED * (1 - d / EDGE));
|
|
10
|
-
}
|
|
11
|
-
const hasFrames = typeof requestAnimationFrame === "function";
|
|
12
|
-
const frame = (callback) => hasFrames
|
|
13
|
-
? requestAnimationFrame(callback)
|
|
14
|
-
: setTimeout(callback, 16);
|
|
15
|
-
const unframe = (handle) => hasFrames
|
|
16
|
-
? cancelAnimationFrame(handle)
|
|
17
|
-
: clearTimeout(handle);
|
|
18
|
-
/** The nearest scrollable ancestor of `element`, or `null`. */
|
|
19
|
-
export function scrollParent(element) {
|
|
20
|
-
let node = element?.parentElement ?? null;
|
|
21
|
-
while (node) {
|
|
22
|
-
const style = getComputedStyle(node);
|
|
23
|
-
if (/(auto|scroll)/.test(`${style.overflowY} ${style.overflowX}`)) {
|
|
24
|
-
return node;
|
|
25
|
-
}
|
|
26
|
-
node = node.parentElement;
|
|
27
|
-
}
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
8
|
+
import { applyAutoScroll, cancelFrame, scheduleFrame } from "../../dom/auto-scroll.js";
|
|
9
|
+
export { autoScrollSpeed } from "../../dom/auto-scroll.js";
|
|
30
10
|
/** A rAF loop that scrolls `getContainer()` toward the pointer; stops when asked. */
|
|
31
11
|
export function createAutoScroll(getContainer) {
|
|
32
12
|
let point = null;
|
|
@@ -34,29 +14,22 @@ export function createAutoScroll(getContainer) {
|
|
|
34
14
|
const tick = () => {
|
|
35
15
|
handle = 0;
|
|
36
16
|
const container = getContainer();
|
|
37
|
-
if (!point || !container)
|
|
17
|
+
if (!point || !container) {
|
|
38
18
|
return;
|
|
39
|
-
const rect = container.getBoundingClientRect();
|
|
40
|
-
const dy = autoScrollSpeed(point.y - rect.top) * -1 +
|
|
41
|
-
autoScrollSpeed(rect.bottom - point.y);
|
|
42
|
-
const dx = autoScrollSpeed(point.x - rect.left) * -1 +
|
|
43
|
-
autoScrollSpeed(rect.right - point.x);
|
|
44
|
-
if (dx !== 0 || dy !== 0) {
|
|
45
|
-
container.scrollLeft += dx;
|
|
46
|
-
container.scrollTop += dy;
|
|
47
19
|
}
|
|
48
|
-
|
|
20
|
+
applyAutoScroll(container, point);
|
|
21
|
+
handle = scheduleFrame(tick);
|
|
49
22
|
};
|
|
50
23
|
return {
|
|
51
24
|
update(next) {
|
|
52
25
|
point = next;
|
|
53
26
|
if (handle === 0)
|
|
54
|
-
handle =
|
|
27
|
+
handle = scheduleFrame(tick);
|
|
55
28
|
},
|
|
56
29
|
stop() {
|
|
57
30
|
point = null;
|
|
58
31
|
if (handle !== 0) {
|
|
59
|
-
|
|
32
|
+
cancelFrame(handle);
|
|
60
33
|
handle = 0;
|
|
61
34
|
}
|
|
62
35
|
},
|
|
@@ -13,11 +13,8 @@ const shiftDays = (value, days) => fromSeconds(toSeconds(value) + days * DAY);
|
|
|
13
13
|
const dayDiff = (a, b) => toEpochDay(a) - toEpochDay(b);
|
|
14
14
|
/** How far into the event (in days / minutes) the press happened. */
|
|
15
15
|
export function grabOf(value, target) {
|
|
16
|
-
const press = target.time
|
|
17
|
-
|
|
18
|
-
: midnight(target.date);
|
|
19
|
-
const spanDays = Math.max(1, dayDiff(value.end, value.start) +
|
|
20
|
-
(toSecondOfDay(value.end) > 0 && !value.allDay ? 1 : 0));
|
|
16
|
+
const press = target.time ? plainDateTime(target.date, target.time) : midnight(target.date);
|
|
17
|
+
const spanDays = Math.max(1, dayDiff(value.end, value.start) + (toSecondOfDay(value.end) > 0 && !value.allDay ? 1 : 0));
|
|
21
18
|
return {
|
|
22
19
|
dayOffset: Math.min(Math.max(0, dayDiff(target.date, value.start)), spanDays - 1),
|
|
23
20
|
minuteOffset: Math.max(0, Math.round((toSeconds(press) - toSeconds(value.start)) / 60)),
|