@savvycal/calendar 0.13.0 → 0.15.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 +112 -40
- package/dist/components/day-grid-view/AllDaySection.d.ts +2 -0
- package/dist/components/day-grid-view/AllDaySection.d.ts.map +1 -1
- package/dist/components/day-grid-view/AllDaySection.js +113 -75
- package/dist/components/day-grid-view/DayColumn.d.ts +2 -24
- package/dist/components/day-grid-view/DayColumn.d.ts.map +1 -1
- package/dist/components/day-grid-view/DayGridView.d.ts +1 -1
- package/dist/components/day-grid-view/DayGridView.d.ts.map +1 -1
- package/dist/components/day-grid-view/DayGridView.js +347 -289
- package/dist/components/day-grid-view/defaults.d.ts.map +1 -1
- package/dist/components/day-grid-view/defaults.js +1 -0
- package/dist/components/month-view/MonthView.d.ts.map +1 -1
- package/dist/components/month-view/MonthView.js +184 -165
- package/dist/components/month-view/MonthWeekRow.d.ts +1 -0
- package/dist/components/month-view/MonthWeekRow.d.ts.map +1 -1
- package/dist/components/month-view/MonthWeekRow.js +95 -89
- package/dist/components/resource-grid-view/ResourceColumn.d.ts +3 -21
- package/dist/components/resource-grid-view/ResourceColumn.d.ts.map +1 -1
- package/dist/components/resource-grid-view/ResourceColumn.js +13 -6
- package/dist/components/resource-grid-view/ResourceGridView.d.ts +1 -1
- package/dist/components/resource-grid-view/ResourceGridView.d.ts.map +1 -1
- package/dist/components/resource-grid-view/ResourceGridView.js +348 -300
- package/dist/components/resource-grid-view/defaults.d.ts.map +1 -1
- package/dist/components/resource-grid-view/defaults.js +1 -0
- package/dist/components/shared/AllDayRow.d.ts.map +1 -1
- package/dist/components/shared/AllDayRow.js +21 -22
- package/dist/components/shared/EventChip.d.ts +4 -0
- package/dist/components/shared/EventChip.d.ts.map +1 -1
- package/dist/components/shared/EventChip.js +77 -69
- package/dist/components/shared/SelectionOverlay.d.ts +4 -0
- package/dist/components/shared/SelectionOverlay.d.ts.map +1 -1
- package/dist/components/shared/SelectionOverlay.js +38 -33
- package/dist/components/shared/SlotInteractionLayer.d.ts +5 -0
- package/dist/components/shared/SlotInteractionLayer.d.ts.map +1 -1
- package/dist/components/shared/SlotInteractionLayer.js +201 -176
- package/dist/components/shared/TimedEventLayer.d.ts +5 -2
- package/dist/components/shared/TimedEventLayer.d.ts.map +1 -1
- package/dist/components/shared/TimedEventLayer.js +57 -51
- package/dist/components/shared/useEventDrag.d.ts +36 -0
- package/dist/components/shared/useEventDrag.d.ts.map +1 -0
- package/dist/components/shared/useEventDrag.js +156 -0
- package/dist/components/shared/useLingeringValue.d.ts +7 -0
- package/dist/components/shared/useLingeringValue.d.ts.map +1 -0
- package/dist/components/shared/useLingeringValue.js +17 -0
- package/dist/components/shared/useTouchDrag.d.ts +38 -0
- package/dist/components/shared/useTouchDrag.d.ts.map +1 -0
- package/dist/components/shared/useTouchDrag.js +51 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/autoScroll.d.ts +30 -9
- package/dist/lib/autoScroll.d.ts.map +1 -1
- package/dist/lib/autoScroll.js +57 -51
- package/dist/lib/lanes.d.ts +2 -2
- package/dist/lib/lanes.d.ts.map +1 -1
- package/dist/lib/lanes.js +18 -18
- package/dist/types/calendar.d.ts +56 -0
- package/dist/types/calendar.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { Temporal } from 'temporal-polyfill';
|
|
3
|
+
import { EventDrop, TimedCalendarEvent } from '../../types/calendar';
|
|
4
|
+
interface UseEventDragOptions {
|
|
5
|
+
/** Called with the new placement when the user drops an event somewhere new. */
|
|
6
|
+
onDrop?: (drop: EventDrop) => void;
|
|
7
|
+
gridRef: RefObject<HTMLElement | null>;
|
|
8
|
+
rootRef: RefObject<HTMLElement | null>;
|
|
9
|
+
/** The sticky gutter, so a drag past the left edge picks the first visible column. */
|
|
10
|
+
gutterRef: RefObject<HTMLElement | null>;
|
|
11
|
+
timeZone: string;
|
|
12
|
+
startHour: number;
|
|
13
|
+
endHour: number;
|
|
14
|
+
hourHeight: number;
|
|
15
|
+
snapDuration: number;
|
|
16
|
+
/** Maps a `data-event-column` id to the day it shows and, for resource columns, its resource. */
|
|
17
|
+
resolveTarget: (columnId: string) => {
|
|
18
|
+
date: Temporal.PlainDate;
|
|
19
|
+
resourceId?: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Drag-to-move for timed events. A mouse press on an event becomes a drag once
|
|
24
|
+
* the pointer moves a few pixels; a touch becomes one after a long press, so a
|
|
25
|
+
* swipe across events still scrolls the grid. The event then follows the
|
|
26
|
+
* pointer, snapped to `snapDuration`, across columns. Releasing it somewhere
|
|
27
|
+
* new calls `onDrop` and does nothing else: the caller decides whether to
|
|
28
|
+
* apply the move, ask for confirmation, or ignore it. Escape cancels a drag
|
|
29
|
+
* in progress.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useEventDrag(options: UseEventDragOptions): {
|
|
32
|
+
dragPreview: EventDrop | null;
|
|
33
|
+
startEventDrag: (event: TimedCalendarEvent, e: React.PointerEvent<HTMLElement>) => void;
|
|
34
|
+
};
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=useEventDrag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEventDrag.d.ts","sourceRoot":"","sources":["../../../src/components/shared/useEventDrag.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAiBtE,UAAU,mBAAmB;IAC3B,gFAAgF;IAChF,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACnC,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACvC,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACvC,sFAAsF;IACtF,SAAS,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,iGAAiG;IACjG,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK;QACnC,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC;QACzB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAkED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB;;4BAyK7C,kBAAkB,KAAK,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC;EAuEjE"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { useState as H, useRef as D, useLayoutEffect as y, useCallback as f, useEffect as C } from "react";
|
|
2
|
+
import { findVerticalScrollParent as A, createAutoScroller as N } from "../../lib/autoScroll.js";
|
|
3
|
+
import { minutesToZonedDateTime as Z } from "../../lib/time.js";
|
|
4
|
+
const U = 4, q = 400, G = 10;
|
|
5
|
+
function V(s, c, l) {
|
|
6
|
+
return c.toPlainDateTime().until(s.withTimeZone(l).toPlainDateTime(), {
|
|
7
|
+
largestUnit: "minutes"
|
|
8
|
+
}).total("minutes");
|
|
9
|
+
}
|
|
10
|
+
function k(s, c, { startHour: l, hourHeight: o }) {
|
|
11
|
+
const i = s.getBoundingClientRect();
|
|
12
|
+
return l * 60 + (c - i.top) * 60 / o;
|
|
13
|
+
}
|
|
14
|
+
function z() {
|
|
15
|
+
const s = (o) => {
|
|
16
|
+
o.detail !== 0 && (o.stopPropagation(), o.preventDefault(), c());
|
|
17
|
+
}, c = () => {
|
|
18
|
+
clearTimeout(l), document.removeEventListener("click", s, !0), document.removeEventListener("pointerdown", c, !0);
|
|
19
|
+
}, l = setTimeout(c, 1e3);
|
|
20
|
+
document.addEventListener("click", s, !0), document.addEventListener("pointerdown", c, !0);
|
|
21
|
+
}
|
|
22
|
+
function J(s) {
|
|
23
|
+
const [c, l] = H(null), o = D(null), i = D(s);
|
|
24
|
+
y(() => {
|
|
25
|
+
i.current = s;
|
|
26
|
+
});
|
|
27
|
+
const M = f((t) => {
|
|
28
|
+
const { gridRef: e, rootRef: n, gutterRef: a } = i.current, d = e.current?.querySelectorAll(
|
|
29
|
+
"[data-event-column]"
|
|
30
|
+
);
|
|
31
|
+
if (!d || d.length === 0) return null;
|
|
32
|
+
let m = t;
|
|
33
|
+
const v = a.current, u = n.current;
|
|
34
|
+
v && (m = Math.max(m, v.getBoundingClientRect().right)), u && (m = Math.min(m, u.getBoundingClientRect().right - 1));
|
|
35
|
+
let r = d[0];
|
|
36
|
+
for (const h of d) {
|
|
37
|
+
if (m < h.getBoundingClientRect().left) break;
|
|
38
|
+
r = h;
|
|
39
|
+
}
|
|
40
|
+
return r;
|
|
41
|
+
}, []), p = f(
|
|
42
|
+
(t, e) => {
|
|
43
|
+
const n = o.current;
|
|
44
|
+
if (!n?.started || n.cancelled) return;
|
|
45
|
+
const a = M(t), d = a?.dataset.eventColumn;
|
|
46
|
+
if (!a || d == null) return;
|
|
47
|
+
const { startHour: m, endHour: v, snapDuration: u, timeZone: r, resolveTarget: h } = i.current, x = k(a, e, i.current) - n.grabOffsetMin, O = Math.round(x / u) * u, S = Math.min(n.durationMin, u), _ = Math.min(
|
|
48
|
+
Math.max(O, m * 60 + S - n.durationMin),
|
|
49
|
+
v * 60 - S
|
|
50
|
+
), { date: B, resourceId: Y } = h(d), w = Z(B, _, r), R = n.preview;
|
|
51
|
+
R && R.resourceId === (Y ?? n.event.resourceId) && R.startTime.equals(w) || (n.preview = {
|
|
52
|
+
event: n.event,
|
|
53
|
+
resourceId: Y ?? n.event.resourceId,
|
|
54
|
+
startTime: w,
|
|
55
|
+
endTime: w.add({ minutes: n.durationMin })
|
|
56
|
+
}, l(n.preview));
|
|
57
|
+
},
|
|
58
|
+
[M]
|
|
59
|
+
), g = D(() => {
|
|
60
|
+
}), P = f(
|
|
61
|
+
(t) => {
|
|
62
|
+
const e = o.current;
|
|
63
|
+
if (!(!e || t.pointerId !== e.pointerId)) {
|
|
64
|
+
if (e.lastX = t.clientX, e.lastY = t.clientY, !e.started) {
|
|
65
|
+
const n = Math.hypot(
|
|
66
|
+
t.clientX - e.originX,
|
|
67
|
+
t.clientY - e.originY
|
|
68
|
+
);
|
|
69
|
+
if (e.isTouch) {
|
|
70
|
+
n > G && g.current();
|
|
71
|
+
return;
|
|
72
|
+
} else {
|
|
73
|
+
if (n < U) return;
|
|
74
|
+
e.started = !0;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
p(t.clientX, t.clientY), e.cancelled || e.scroller?.ensure();
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
[p]
|
|
81
|
+
), T = f((t) => {
|
|
82
|
+
const e = o.current;
|
|
83
|
+
if (!e || t.pointerId !== e.pointerId || (g.current(), !e.started) || (z(), t.type === "pointercancel")) return;
|
|
84
|
+
const n = e.preview;
|
|
85
|
+
if (e.cancelled || !n) return;
|
|
86
|
+
(n.resourceId !== e.event.resourceId || n.startTime.epochNanoseconds !== e.event.startTime.epochNanoseconds) && i.current.onDrop?.(n);
|
|
87
|
+
}, []), L = f((t) => {
|
|
88
|
+
const e = o.current;
|
|
89
|
+
t.key !== "Escape" || !e?.started || e.cancelled || (e.cancelled = !0, e.scroller?.stop(), l(null));
|
|
90
|
+
}, []), E = f((t) => t.preventDefault(), []);
|
|
91
|
+
y(() => {
|
|
92
|
+
g.current = () => {
|
|
93
|
+
const t = o.current;
|
|
94
|
+
t?.longPressTimer != null && clearTimeout(t.longPressTimer), t?.scroller?.stop(), o.current = null, l(null), document.removeEventListener("pointermove", P), document.removeEventListener("pointerup", T), document.removeEventListener("pointercancel", T), document.removeEventListener("keydown", L), document.removeEventListener("selectstart", E), document.removeEventListener("contextmenu", E);
|
|
95
|
+
};
|
|
96
|
+
}), C(() => () => g.current(), []);
|
|
97
|
+
const I = s.onDrop != null, { rootRef: X } = s;
|
|
98
|
+
C(() => {
|
|
99
|
+
const t = X.current;
|
|
100
|
+
if (!I || !t) return;
|
|
101
|
+
const e = (n) => {
|
|
102
|
+
o.current?.started && n.preventDefault();
|
|
103
|
+
};
|
|
104
|
+
return t.addEventListener("touchmove", e, { passive: !1 }), () => t.removeEventListener("touchmove", e);
|
|
105
|
+
}, [I, X]);
|
|
106
|
+
const b = f(
|
|
107
|
+
(t, e) => {
|
|
108
|
+
if (!e.isPrimary || e.button !== 0 || !i.current.onDrop) return;
|
|
109
|
+
const n = e.currentTarget.closest(
|
|
110
|
+
"[data-event-column]"
|
|
111
|
+
), a = n?.dataset.eventColumn;
|
|
112
|
+
if (!n || a == null) return;
|
|
113
|
+
g.current();
|
|
114
|
+
const { timeZone: d, resolveTarget: m } = i.current, { date: v } = m(a), u = e.pointerType !== "mouse", r = {
|
|
115
|
+
event: t,
|
|
116
|
+
pointerId: e.pointerId,
|
|
117
|
+
isTouch: u,
|
|
118
|
+
longPressTimer: null,
|
|
119
|
+
originX: e.clientX,
|
|
120
|
+
originY: e.clientY,
|
|
121
|
+
grabOffsetMin: k(n, e.clientY, i.current) - V(t.startTime, v, d),
|
|
122
|
+
durationMin: t.startTime.until(t.endTime).total("minutes"),
|
|
123
|
+
started: !1,
|
|
124
|
+
cancelled: !1,
|
|
125
|
+
preview: null,
|
|
126
|
+
lastX: e.clientX,
|
|
127
|
+
lastY: e.clientY,
|
|
128
|
+
scroller: null,
|
|
129
|
+
scrollParent: A(n)
|
|
130
|
+
};
|
|
131
|
+
r.scroller = N({
|
|
132
|
+
getPointerY: () => r.lastY,
|
|
133
|
+
getScrollParent: () => r.scrollParent,
|
|
134
|
+
horizontal: {
|
|
135
|
+
getPointerX: () => r.lastX,
|
|
136
|
+
// The sticky gutter covers the first column while scrolled
|
|
137
|
+
getViewportLeft: () => i.current.gutterRef.current?.getBoundingClientRect().right
|
|
138
|
+
},
|
|
139
|
+
onScroll: () => p(r.lastX, r.lastY)
|
|
140
|
+
}), u && (r.longPressTimer = setTimeout(() => {
|
|
141
|
+
r.longPressTimer = null, r.started = !0, window.getSelection()?.removeAllRanges(), p(r.lastX, r.lastY);
|
|
142
|
+
}, q)), o.current = r, document.addEventListener("pointermove", P), document.addEventListener("pointerup", T), document.addEventListener("pointercancel", T), document.addEventListener("keydown", L), document.addEventListener("selectstart", E), u && document.addEventListener("contextmenu", E);
|
|
143
|
+
},
|
|
144
|
+
[
|
|
145
|
+
P,
|
|
146
|
+
T,
|
|
147
|
+
L,
|
|
148
|
+
E,
|
|
149
|
+
p
|
|
150
|
+
]
|
|
151
|
+
);
|
|
152
|
+
return { dragPreview: c, startEventDrag: b };
|
|
153
|
+
}
|
|
154
|
+
export {
|
|
155
|
+
J as useEventDrag
|
|
156
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `value`, or for `lingerMs` after it is cleared, its last non-null
|
|
3
|
+
* value. Keeps an overlay mounted briefly after clearing so a popover's close
|
|
4
|
+
* transition doesn't lose its reference element.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useLingeringValue<T>(value: T | null | undefined, lingerMs: number): T | null;
|
|
7
|
+
//# sourceMappingURL=useLingeringValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLingeringValue.d.ts","sourceRoot":"","sources":["../../../src/components/shared/useLingeringValue.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,EAC3B,QAAQ,EAAE,MAAM,GACf,CAAC,GAAG,IAAI,CAyBV"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useRef as l, useState as f, useEffect as o } from "react";
|
|
2
|
+
function m(e, r) {
|
|
3
|
+
const n = l(null), t = l(null), [c, u] = f(null);
|
|
4
|
+
return o(() => {
|
|
5
|
+
if (e)
|
|
6
|
+
t.current !== null && (clearTimeout(t.current), t.current = null), n.current = e;
|
|
7
|
+
else if (n.current && r > 0) {
|
|
8
|
+
const s = n.current;
|
|
9
|
+
n.current = null, u(s), t.current = setTimeout(() => {
|
|
10
|
+
t.current = null, u(null);
|
|
11
|
+
}, r);
|
|
12
|
+
}
|
|
13
|
+
}, [e, r]), e ?? c;
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
m as useLingeringValue
|
|
17
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/** How long (ms) a touch must rest before it can drag. */
|
|
3
|
+
export declare const LONG_PRESS_MS = 400;
|
|
4
|
+
/** How far (px) a touch can wander during the long press before it counts as a scroll. */
|
|
5
|
+
export declare const TOUCH_SLOP_PX = 10;
|
|
6
|
+
/**
|
|
7
|
+
* Style for an element a long press drags: keeps the press from selecting
|
|
8
|
+
* text or opening the iOS callout. Safari ignores `user-select` without its
|
|
9
|
+
* `-webkit-` prefix.
|
|
10
|
+
*/
|
|
11
|
+
export declare const TOUCH_DRAG_STYLE: {
|
|
12
|
+
readonly WebkitTouchCallout: "none";
|
|
13
|
+
readonly WebkitUserSelect: "none";
|
|
14
|
+
readonly userSelect: "none";
|
|
15
|
+
};
|
|
16
|
+
export interface TouchDragHandlers {
|
|
17
|
+
/** The long press completed. Return `false` to not drag after all. */
|
|
18
|
+
start: (clientX: number, clientY: number) => boolean | void;
|
|
19
|
+
move: (clientX: number, clientY: number) => void;
|
|
20
|
+
end: (clientX: number, clientY: number) => void;
|
|
21
|
+
/** The browser took the touch back, for example to scroll. */
|
|
22
|
+
cancel: () => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Long-press drags for touch and pen. Call the returned `startTouchDrag` from
|
|
26
|
+
* a pointerdown: it ignores the mouse and returns false. For a touch it
|
|
27
|
+
* returns true and waits `LONG_PRESS_MS` before calling `start`. Moving more
|
|
28
|
+
* than `TOUCH_SLOP_PX` before then leaves the touch to scroll, and lifting it
|
|
29
|
+
* is a tap, which the browser reports as emulated mouse events and a click,
|
|
30
|
+
* as it did before. Once a drag starts, the finger no longer scrolls, and no
|
|
31
|
+
* emulated mouse events or click follow the touch.
|
|
32
|
+
*
|
|
33
|
+
* `containerRef` must contain every element whose pointerdown can start a
|
|
34
|
+
* drag: it holds the touch listeners, which have to be in place before a
|
|
35
|
+
* touch begins to be able to stop it scrolling.
|
|
36
|
+
*/
|
|
37
|
+
export declare function useTouchDrag(containerRef: RefObject<HTMLElement | null>, enabled: boolean): (e: React.PointerEvent, handlers: TouchDragHandlers) => boolean;
|
|
38
|
+
//# sourceMappingURL=useTouchDrag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTouchDrag.d.ts","sourceRoot":"","sources":["../../../src/components/shared/useTouchDrag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvE,0DAA0D;AAC1D,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC,0FAA0F;AAC1F,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;;CAInB,CAAC;AAEX,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAC;IAC5D,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,8DAA8D;IAC9D,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,YAAY,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAC3C,OAAO,EAAE,OAAO,OA6BV,KAAK,CAAC,YAAY,YAAY,iBAAiB,KAAG,OAAO,CAmEhE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useRef as L, useEffect as S, useCallback as T } from "react";
|
|
2
|
+
const h = 400, D = 10, k = {
|
|
3
|
+
WebkitTouchCallout: "none",
|
|
4
|
+
WebkitUserSelect: "none",
|
|
5
|
+
userSelect: "none"
|
|
6
|
+
};
|
|
7
|
+
function y(d, f) {
|
|
8
|
+
const o = L(!1), i = L(() => {
|
|
9
|
+
});
|
|
10
|
+
return S(() => {
|
|
11
|
+
const e = d.current;
|
|
12
|
+
if (!f || !e) return;
|
|
13
|
+
const n = (r) => {
|
|
14
|
+
o.current && r.preventDefault();
|
|
15
|
+
}, c = (r) => {
|
|
16
|
+
o.current && (o.current = !1, r.preventDefault());
|
|
17
|
+
};
|
|
18
|
+
return e.addEventListener("touchmove", n, { passive: !1 }), e.addEventListener("touchend", c, { passive: !1 }), () => {
|
|
19
|
+
e.removeEventListener("touchmove", n), e.removeEventListener("touchend", c);
|
|
20
|
+
};
|
|
21
|
+
}, [d, f]), S(() => () => i.current(), []), T(
|
|
22
|
+
(e, n) => {
|
|
23
|
+
if (e.pointerType === "mouse" || !e.isPrimary) return !1;
|
|
24
|
+
i.current();
|
|
25
|
+
const { pointerId: c } = e, r = e.clientX, p = e.clientY;
|
|
26
|
+
let s = r, u = p, m = !1;
|
|
27
|
+
const E = (t) => {
|
|
28
|
+
t.pointerId === c && (s = t.clientX, u = t.clientY, m ? n.move(s, u) : Math.hypot(s - r, u - p) > D && v());
|
|
29
|
+
}, l = (t) => {
|
|
30
|
+
t.pointerId === c && (v(), m && (t.type === "pointercancel" ? (o.current = !1, n.cancel()) : n.end(s, u)));
|
|
31
|
+
}, a = (t) => t.preventDefault(), g = setTimeout(() => {
|
|
32
|
+
if (n.start(s, u) === !1) {
|
|
33
|
+
v();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
m = !0, o.current = !0, window.getSelection()?.removeAllRanges();
|
|
37
|
+
}, h), v = () => {
|
|
38
|
+
clearTimeout(g), document.removeEventListener("pointermove", E), document.removeEventListener("pointerup", l), document.removeEventListener("pointercancel", l), document.removeEventListener("contextmenu", a), document.removeEventListener("selectstart", a), i.current = () => {
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
return i.current = v, document.addEventListener("pointermove", E), document.addEventListener("pointerup", l), document.addEventListener("pointercancel", l), document.addEventListener("contextmenu", a), document.addEventListener("selectstart", a), !0;
|
|
42
|
+
},
|
|
43
|
+
[]
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
h as LONG_PRESS_MS,
|
|
48
|
+
k as TOUCH_DRAG_STYLE,
|
|
49
|
+
D as TOUCH_SLOP_PX,
|
|
50
|
+
y as useTouchDrag
|
|
51
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { MonthView } from './components/month-view';
|
|
|
5
5
|
export { resourceGridViewDefaults } from './components/resource-grid-view';
|
|
6
6
|
export { dayGridViewDefaults } from './components/day-grid-view';
|
|
7
7
|
export { monthViewDefaults } from './components/month-view';
|
|
8
|
-
export type { CalendarResource, CalendarEvent, TimedCalendarEvent, AllDayCalendarEvent, TimeSlot, AvailabilityRange, BackgroundEvent, TimeAxisConfig, ResourceGridViewProps, ResourceGridViewClassNames, GridViewClassNames, DayGridViewProps, DayGridViewClassNames, DayGridSelectedRange, PositionedEvent, OverflowClickInfo, OverflowPopoverRenderProps, SelectedRange, SelectionAppearance, SelectionEventData, EventLayout, MonthViewProps, MonthViewClassNames, MonthSelectedRange, MonthOverflowClickInfo, MonthOverflowPopoverRenderProps, } from './types/calendar';
|
|
8
|
+
export type { CalendarResource, CalendarEvent, TimedCalendarEvent, AllDayCalendarEvent, TimeSlot, AvailabilityRange, BackgroundEvent, TimeAxisConfig, ResourceGridViewProps, ResourceGridViewClassNames, GridViewClassNames, DayGridViewProps, DayGridViewClassNames, DayGridSelectedRange, PositionedEvent, OverflowClickInfo, OverflowPopoverRenderProps, SelectedRange, EventDrop, SelectionAppearance, SelectionEventData, EventLayout, MonthViewProps, MonthViewClassNames, MonthSelectedRange, MonthOverflowClickInfo, MonthOverflowPopoverRenderProps, } from './types/calendar';
|
|
9
9
|
export { cn } from './lib/utils';
|
|
10
10
|
export { timedEvent, allDayEvent } from './lib/events';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,0BAA0B,EAC1B,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,+BAA+B,GAChC,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,0BAA0B,EAC1B,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,+BAA+B,GAChC,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/lib/autoScroll.d.ts
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
export declare const AUTO_SCROLL_EDGE_PX = 48;
|
|
3
3
|
/** Peak auto-scroll speed while the pointer is at or past an edge. */
|
|
4
4
|
export declare const AUTO_SCROLL_MAX_PX_PER_SECOND = 400;
|
|
5
|
+
/**
|
|
6
|
+
* Sideways edge zone, in px. Narrower than the vertical one, which would
|
|
7
|
+
* take a quarter of a phone's width.
|
|
8
|
+
*/
|
|
9
|
+
export declare const AUTO_SCROLL_HORIZONTAL_EDGE_PX = 32;
|
|
10
|
+
/**
|
|
11
|
+
* Peak sideways speed. Slower than vertical, since one column can be most of
|
|
12
|
+
* the viewport and is easy to overshoot.
|
|
13
|
+
*/
|
|
14
|
+
export declare const AUTO_SCROLL_HORIZONTAL_MAX_PX_PER_SECOND = 250;
|
|
5
15
|
/**
|
|
6
16
|
* Nearest ancestor that scrolls vertically (overflow-y auto/scroll/overlay).
|
|
7
17
|
* The calendar root is `overflow-auto`, so this is the grid's own scroller.
|
|
@@ -16,19 +26,30 @@ export declare function findVerticalScrollParent(el: HTMLElement): HTMLElement |
|
|
|
16
26
|
*/
|
|
17
27
|
export declare function computeAutoScrollIntensity(pointerY: number, viewportTop: number, viewportBottom: number, edgePx?: number): number;
|
|
18
28
|
/**
|
|
19
|
-
* Scroll `scrollParent`
|
|
20
|
-
*
|
|
29
|
+
* Scroll `scrollParent` along `axis` by
|
|
30
|
+
* `intensity * maxPxPerSecond * deltaSeconds`. Returns the actual delta
|
|
31
|
+
* applied after clamping to the scroll range.
|
|
21
32
|
*/
|
|
22
|
-
export declare function
|
|
23
|
-
export interface
|
|
33
|
+
export declare function applyAutoScroll(scrollParent: HTMLElement, axis: 'x' | 'y', intensity: number, deltaSeconds: number, maxPxPerSecond?: number): number;
|
|
34
|
+
export interface AutoScroller {
|
|
24
35
|
/** Start the rAF loop if it isn't already running. */
|
|
25
36
|
ensure: () => void;
|
|
26
37
|
/** Cancel the rAF loop. Safe to call more than once. */
|
|
27
38
|
stop: () => void;
|
|
28
39
|
}
|
|
29
|
-
interface
|
|
30
|
-
|
|
40
|
+
interface CreateAutoScrollerOptions {
|
|
41
|
+
/** Omit to scroll sideways only. */
|
|
42
|
+
getPointerY?: () => number;
|
|
31
43
|
getScrollParent: () => HTMLElement | null;
|
|
44
|
+
/** Also scroll sideways when the pointer nears the left or right edge. */
|
|
45
|
+
horizontal?: {
|
|
46
|
+
getPointerX: () => number;
|
|
47
|
+
/**
|
|
48
|
+
* Left edge of the visible area, such as the right edge of a sticky
|
|
49
|
+
* gutter that covers the first column. Default: the scroller's left edge.
|
|
50
|
+
*/
|
|
51
|
+
getViewportLeft?: () => number | undefined;
|
|
52
|
+
};
|
|
32
53
|
/** Called after the scroller actually moves, so the caller can remap the pointer. */
|
|
33
54
|
onScroll: () => void;
|
|
34
55
|
raf?: typeof requestAnimationFrame;
|
|
@@ -36,9 +57,9 @@ interface CreateVerticalAutoScrollerOptions {
|
|
|
36
57
|
}
|
|
37
58
|
/**
|
|
38
59
|
* rAF loop that auto-scrolls while the pointer sits in an edge zone. The
|
|
39
|
-
* loop stops on its own when
|
|
40
|
-
* further; call `ensure()` again to resume.
|
|
60
|
+
* loop stops on its own when the pointer leaves the edge zones or the
|
|
61
|
+
* scroller can't move further; call `ensure()` again to resume.
|
|
41
62
|
*/
|
|
42
|
-
export declare function
|
|
63
|
+
export declare function createAutoScroller({ getPointerY, getScrollParent, horizontal, onScroll, raf, cancelRaf, }: CreateAutoScrollerOptions): AutoScroller;
|
|
43
64
|
export {};
|
|
44
65
|
//# sourceMappingURL=autoScroll.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoScroll.d.ts","sourceRoot":"","sources":["../../src/lib/autoScroll.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,sEAAsE;AACtE,eAAO,MAAM,6BAA6B,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"autoScroll.d.ts","sourceRoot":"","sources":["../../src/lib/autoScroll.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,sEAAsE;AACtE,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,wCAAwC,MAAM,CAAC;AAM5D;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,WAAW,GAAG,WAAW,GAAG,IAAI,CAS5E;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,MAAM,GAAE,MAA4B,GACnC,MAAM,CAiBR;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,WAAW,EACzB,IAAI,EAAE,GAAG,GAAG,GAAG,EACf,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,cAAc,GAAE,MAE4B,GAC3C,MAAM,CAeR;AAED,MAAM,WAAW,YAAY;IAC3B,sDAAsD;IACtD,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,wDAAwD;IACxD,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,UAAU,yBAAyB;IACjC,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IAC1C,0EAA0E;IAC1E,UAAU,CAAC,EAAE;QACX,WAAW,EAAE,MAAM,MAAM,CAAC;QAC1B;;;WAGG;QACH,eAAe,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;KAC5C,CAAC;IACF,qFAAqF;IACrF,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,qBAAqB,CAAC;IACnC,SAAS,CAAC,EAAE,OAAO,oBAAoB,CAAC;CACzC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,WAAW,EACX,eAAe,EACf,UAAU,EACV,QAAQ,EACR,GAA2B,EAC3B,SAAgC,GACjC,EAAE,yBAAyB,GAAG,YAAY,CA4D1C"}
|
package/dist/lib/autoScroll.js
CHANGED
|
@@ -1,78 +1,84 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
3
|
-
return
|
|
1
|
+
const C = 48, T = 400, d = 32, h = 250;
|
|
2
|
+
function a(t) {
|
|
3
|
+
return t === "auto" || t === "scroll" || t === "overlay";
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
let
|
|
7
|
-
for (;
|
|
8
|
-
if (
|
|
9
|
-
return
|
|
10
|
-
|
|
5
|
+
function p(t) {
|
|
6
|
+
let n = t.parentElement;
|
|
7
|
+
for (; n; ) {
|
|
8
|
+
if (a(getComputedStyle(n).overflowY))
|
|
9
|
+
return n;
|
|
10
|
+
n = n.parentElement;
|
|
11
11
|
}
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
|
-
function S(
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
const l = o -
|
|
20
|
-
return l <
|
|
14
|
+
function S(t, n, o, u = 48) {
|
|
15
|
+
const c = o - n;
|
|
16
|
+
if (c <= 0) return 0;
|
|
17
|
+
const r = Math.min(u, c / 2);
|
|
18
|
+
if (r <= 0) return 0;
|
|
19
|
+
const l = o - t, e = t - n;
|
|
20
|
+
return l < r && l <= e ? Math.min(1, (r - l) / r) : e < r ? -Math.min(1, (r - e) / r) : 0;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
if (
|
|
24
|
-
const
|
|
22
|
+
function m(t, n, o, u, c = n === "y" ? 400 : 250) {
|
|
23
|
+
if (o === 0 || u <= 0) return 0;
|
|
24
|
+
const r = o * c * u, l = Math.max(
|
|
25
25
|
0,
|
|
26
|
-
n.scrollHeight -
|
|
27
|
-
),
|
|
28
|
-
return
|
|
26
|
+
n === "y" ? t.scrollHeight - t.clientHeight : t.scrollWidth - t.clientWidth
|
|
27
|
+
), e = n === "y" ? "scrollTop" : "scrollLeft", i = t[e], _ = Math.min(l, Math.max(0, i + r));
|
|
28
|
+
return t[e] = _, _ - i;
|
|
29
29
|
}
|
|
30
30
|
function M({
|
|
31
|
-
getPointerY:
|
|
32
|
-
getScrollParent:
|
|
33
|
-
|
|
31
|
+
getPointerY: t,
|
|
32
|
+
getScrollParent: n,
|
|
33
|
+
horizontal: o,
|
|
34
|
+
onScroll: u,
|
|
34
35
|
raf: c = requestAnimationFrame,
|
|
35
|
-
cancelRaf:
|
|
36
|
+
cancelRaf: r = cancelAnimationFrame
|
|
36
37
|
}) {
|
|
37
|
-
let
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
43
|
-
|
|
38
|
+
let l = null, e = null, i = !1;
|
|
39
|
+
const _ = (f) => {
|
|
40
|
+
if (i) return;
|
|
41
|
+
l = null;
|
|
42
|
+
const s = n();
|
|
43
|
+
if (!s) {
|
|
44
|
+
e = null;
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
const O = s.getBoundingClientRect(), L = t ? S(t(), O.top, O.bottom) : 0, A = o ? S(
|
|
48
|
+
o.getPointerX(),
|
|
49
|
+
o.getViewportLeft?.() ?? O.left,
|
|
50
|
+
O.right,
|
|
51
|
+
32
|
|
52
|
+
) : 0;
|
|
53
|
+
if (A === 0 && L === 0) {
|
|
54
|
+
e = null;
|
|
53
55
|
return;
|
|
54
56
|
}
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
const E = e == null ? 1 / 60 : Math.min(0.05, (f - e) / 1e3);
|
|
58
|
+
e = f;
|
|
59
|
+
const R = m(s, "y", L, E);
|
|
60
|
+
if (m(s, "x", A, E) === 0 && R === 0) {
|
|
61
|
+
e = null;
|
|
58
62
|
return;
|
|
59
63
|
}
|
|
60
|
-
|
|
64
|
+
u(), l = c(_);
|
|
61
65
|
};
|
|
62
66
|
return {
|
|
63
67
|
ensure: () => {
|
|
64
|
-
|
|
68
|
+
i || l != null || (l = c(_));
|
|
65
69
|
},
|
|
66
70
|
stop: () => {
|
|
67
|
-
|
|
71
|
+
i = !0, l != null && (r(l), l = null), e = null;
|
|
68
72
|
}
|
|
69
73
|
};
|
|
70
74
|
}
|
|
71
75
|
export {
|
|
72
|
-
|
|
73
|
-
d as
|
|
74
|
-
|
|
76
|
+
C as AUTO_SCROLL_EDGE_PX,
|
|
77
|
+
d as AUTO_SCROLL_HORIZONTAL_EDGE_PX,
|
|
78
|
+
h as AUTO_SCROLL_HORIZONTAL_MAX_PX_PER_SECOND,
|
|
79
|
+
T as AUTO_SCROLL_MAX_PX_PER_SECOND,
|
|
80
|
+
m as applyAutoScroll,
|
|
75
81
|
S as computeAutoScrollIntensity,
|
|
76
|
-
M as
|
|
77
|
-
|
|
82
|
+
M as createAutoScroller,
|
|
83
|
+
p as findVerticalScrollParent
|
|
78
84
|
};
|
package/dist/lib/lanes.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ export interface ClippedSpan {
|
|
|
10
10
|
continuesAfter: boolean;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
* Clips an inclusive date range to
|
|
14
|
-
* null when it
|
|
13
|
+
* Clips an inclusive date range to ascending dates, which may skip days, or
|
|
14
|
+
* returns null when it covers none of them.
|
|
15
15
|
*/
|
|
16
16
|
export declare function clipDateSpan(startDate: Temporal.PlainDate, endDate: Temporal.PlainDate, dates: Temporal.PlainDate[]): ClippedSpan | null;
|
|
17
17
|
/**
|
package/dist/lib/lanes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lanes.d.ts","sourceRoot":"","sources":["../../src/lib/lanes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,eAAe,EAAE,OAAO,CAAC;IACzB,+BAA+B;IAC/B,cAAc,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,QAAQ,CAAC,SAAS,EAC7B,OAAO,EAAE,QAAQ,CAAC,SAAS,EAC3B,KAAK,EAAE,QAAQ,CAAC,SAAS,EAAE,GAC1B,WAAW,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"lanes.d.ts","sourceRoot":"","sources":["../../src/lib/lanes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,eAAe,EAAE,OAAO,CAAC;IACzB,+BAA+B;IAC/B,cAAc,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,QAAQ,CAAC,SAAS,EAC7B,OAAO,EAAE,QAAQ,CAAC,SAAS,EAC3B,KAAK,EAAE,QAAQ,CAAC,SAAS,EAAE,GAC1B,WAAW,GAAG,IAAI,CAkBpB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,EAC3C,WAAW,EAAE,MAAM,GAClB,MAAM,EAAE,CAiBV"}
|
package/dist/lib/lanes.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { Temporal as
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
1
|
+
import { Temporal as a } from "temporal-polyfill";
|
|
2
|
+
function p(l, o, n) {
|
|
3
|
+
const r = n.findIndex(
|
|
4
|
+
(e) => a.PlainDate.compare(e, l) >= 0
|
|
5
|
+
), i = n.filter((e) => a.PlainDate.compare(e, o) <= 0).length - 1;
|
|
6
|
+
if (r === -1 || r > i) return null;
|
|
7
|
+
const c = a.PlainDate.compare(l, n[0]) < 0, t = a.PlainDate.compare(o, n[n.length - 1]) > 0;
|
|
8
8
|
return {
|
|
9
9
|
startCol: r,
|
|
10
|
-
span:
|
|
11
|
-
continuesBefore:
|
|
10
|
+
span: i - r + 1,
|
|
11
|
+
continuesBefore: c,
|
|
12
12
|
continuesAfter: t
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function s(l, o) {
|
|
16
16
|
const n = [];
|
|
17
|
-
return l.map(({ startCol:
|
|
18
|
-
const
|
|
19
|
-
let t = n.findIndex((
|
|
20
|
-
for (let
|
|
21
|
-
if (
|
|
17
|
+
return l.map(({ startCol: r, span: i }) => {
|
|
18
|
+
const c = r + i - 1;
|
|
19
|
+
let t = n.findIndex((e) => {
|
|
20
|
+
for (let f = r; f <= c; f++)
|
|
21
|
+
if (e[f]) return !1;
|
|
22
22
|
return !0;
|
|
23
23
|
});
|
|
24
24
|
t === -1 && (t = n.length, n.push(new Array(o).fill(!1)));
|
|
25
|
-
for (let
|
|
25
|
+
for (let e = r; e <= c; e++) n[t][e] = !0;
|
|
26
26
|
return t;
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
s as assignLanes,
|
|
31
|
+
p as clipDateSpan
|
|
32
32
|
};
|