@moltenship/calendar-dnd 1.0.0-rc.1 → 1.0.0-rc.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/dist/index.d.mts +8 -0
- package/dist/index.mjs +16 -10
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -53,6 +53,14 @@ interface CalendarPointerOptions<TEvent, TEventId extends EventId, TResourceId e
|
|
|
53
53
|
readonly scrollContainer?: {
|
|
54
54
|
readonly current: Element | null;
|
|
55
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* A ref to an element inside `scrollContainer` that scrolls sideways in its place while dragging
|
|
58
|
+
* near its left and right edges: in a view that scrolls each axis in an element of its own, so a
|
|
59
|
+
* swipe moves one axis at a time. Defaults to `scrollContainer`.
|
|
60
|
+
*/
|
|
61
|
+
readonly sidewaysScrollContainer?: {
|
|
62
|
+
readonly current: Element | null;
|
|
63
|
+
};
|
|
56
64
|
/** Wall-clock grid for time columns. Defaults to 15 minutes. */
|
|
57
65
|
readonly snap?: WallTimeSnapOptions;
|
|
58
66
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -72,15 +72,17 @@ var EdgeArming = class {
|
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
74
|
/**
|
|
75
|
-
* Scrolls `container` when a viewport point sits near its edges
|
|
76
|
-
*
|
|
75
|
+
* Scrolls `container` when a viewport point sits near its edges, and `sideways` in its place at
|
|
76
|
+
* the left and right edges: a scroller nested in it that scrolls sideways. Returns whether either
|
|
77
|
+
* moved, so the caller re-reads geometry only after a scroll.
|
|
77
78
|
*/
|
|
78
|
-
function autoScroll(container, x, y) {
|
|
79
|
+
function autoScroll(container, x, y, sideways = container) {
|
|
79
80
|
const rect = bounds(container);
|
|
80
|
-
const {
|
|
81
|
+
const { scrollTop } = container;
|
|
82
|
+
const { scrollLeft } = sideways;
|
|
81
83
|
container.scrollTop += step(y, rect.top, rect.bottom);
|
|
82
|
-
|
|
83
|
-
return container.scrollTop !== scrollTop ||
|
|
84
|
+
sideways.scrollLeft += step(x, rect.left, rect.right);
|
|
85
|
+
return container.scrollTop !== scrollTop || sideways.scrollLeft !== scrollLeft;
|
|
84
86
|
}
|
|
85
87
|
//#endregion
|
|
86
88
|
//#region src/drags.ts
|
|
@@ -944,7 +946,7 @@ function attachCalendarPointer(region, getOptions) {
|
|
|
944
946
|
const current = session;
|
|
945
947
|
if (current === null) return;
|
|
946
948
|
trackEdges(current);
|
|
947
|
-
if (!(current.claimed || !current.edges.armed) && autoScroll(current.scrollContainer, current.point.x, current.point.y) && preview(current, true)) announce(current, { phase: "step" });
|
|
949
|
+
if (!(current.claimed || !current.edges.armed) && autoScroll(current.scrollContainer, current.point.x, current.point.y, current.sideways) && preview(current, true)) announce(current, { phase: "step" });
|
|
948
950
|
current.frame = requestAnimationFrame(scrollFrame);
|
|
949
951
|
}
|
|
950
952
|
function activate(current) {
|
|
@@ -1113,6 +1115,7 @@ function attachCalendarPointer(region, getOptions) {
|
|
|
1113
1115
|
const target = targetAt(surface, event.clientX, event.clientY);
|
|
1114
1116
|
const gesture = target === null ? null : gestureFor(event.target, target, options.events);
|
|
1115
1117
|
if (gesture === null) return;
|
|
1118
|
+
const scrollContainer = options.scrollContainer?.current ?? scrollableAncestor(event.target);
|
|
1116
1119
|
const current = {
|
|
1117
1120
|
active: false,
|
|
1118
1121
|
announcer: options.announcer,
|
|
@@ -1137,8 +1140,9 @@ function attachCalendarPointer(region, getOptions) {
|
|
|
1137
1140
|
},
|
|
1138
1141
|
pointerId: event.pointerId,
|
|
1139
1142
|
pointerType: event.pointerType,
|
|
1140
|
-
scrollContainer
|
|
1143
|
+
scrollContainer,
|
|
1141
1144
|
shown: null,
|
|
1145
|
+
sideways: options.sidewaysScrollContainer?.current ?? scrollContainer,
|
|
1142
1146
|
surface,
|
|
1143
1147
|
surfaceColumns: options.columns,
|
|
1144
1148
|
touchTarget: event.pointerType === "touch" && event.target !== region ? event.target : null,
|
|
@@ -1191,6 +1195,7 @@ const DEFAULT_SNAP = {
|
|
|
1191
1195
|
function regionOver(region, hit, eventId) {
|
|
1192
1196
|
const options = region.getOptions();
|
|
1193
1197
|
const event = eventId === void 0 ? void 0 : options.events.get(eventId);
|
|
1198
|
+
const scrollContainer = options.scrollContainer?.current ?? scrollableAncestor(hit);
|
|
1194
1199
|
return {
|
|
1195
1200
|
edges: new EdgeArming(false),
|
|
1196
1201
|
ghost: new GhostLayer(region.element, options.ghostClassName),
|
|
@@ -1203,7 +1208,8 @@ function regionOver(region, hit, eventId) {
|
|
|
1203
1208
|
timeZone: options.timeZone
|
|
1204
1209
|
},
|
|
1205
1210
|
region,
|
|
1206
|
-
scrollContainer
|
|
1211
|
+
scrollContainer,
|
|
1212
|
+
sideways: options.sidewaysScrollContainer?.current ?? scrollContainer,
|
|
1207
1213
|
surface: {
|
|
1208
1214
|
clippers: /* @__PURE__ */ new Map(),
|
|
1209
1215
|
columns: columnsByDate(options.columns),
|
|
@@ -1356,7 +1362,7 @@ function startCalendarDrop(source, { input = "pointer" } = {}) {
|
|
|
1356
1362
|
if (ended) return;
|
|
1357
1363
|
if (over !== null && !takesDrops(over.region)) update();
|
|
1358
1364
|
if (arm() && over !== null && point !== null) {
|
|
1359
|
-
if (autoScroll(over.scrollContainer, point.x, point.y)) update(true);
|
|
1365
|
+
if (autoScroll(over.scrollContainer, point.x, point.y, over.sideways)) update(true);
|
|
1360
1366
|
}
|
|
1361
1367
|
frame = requestAnimationFrame(scrollFrame);
|
|
1362
1368
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moltenship/calendar-dnd",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
4
|
"description": "Pointer drag, resize, and create interactions for Moltenship Time views.",
|
|
5
5
|
"homepage": "https://time.molten.sh/docs/interactions",
|
|
6
6
|
"bugs": {
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@moltenship/calendar-core": "1.0.0-rc.
|
|
32
|
-
"@moltenship/calendar-temporal": "1.0.0-rc.
|
|
31
|
+
"@moltenship/calendar-core": "1.0.0-rc.2",
|
|
32
|
+
"@moltenship/calendar-temporal": "1.0.0-rc.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/react": "19.3.0",
|