@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
|
@@ -10,10 +10,7 @@ export const DEFAULT_SHORTCUTS = {
|
|
|
10
10
|
* with Ctrl, Alt or Meta so browser shortcuts keep working.
|
|
11
11
|
*/
|
|
12
12
|
export function matchShortcut(key, modifiers, shortcuts) {
|
|
13
|
-
if (shortcuts === false ||
|
|
14
|
-
modifiers.ctrl ||
|
|
15
|
-
modifiers.meta ||
|
|
16
|
-
modifiers.alt) {
|
|
13
|
+
if (shortcuts === false || modifiers.ctrl || modifiers.meta || modifiers.alt) {
|
|
17
14
|
return null;
|
|
18
15
|
}
|
|
19
16
|
const same = (a) => a.toLowerCase() === key.toLowerCase();
|
|
@@ -8,7 +8,7 @@ export type DragPointerHandlers = {
|
|
|
8
8
|
update(target: HitTarget): void;
|
|
9
9
|
drop(): void;
|
|
10
10
|
cancel(): void;
|
|
11
|
-
hitTest?: (point: HitPoint) => HitTarget | null;
|
|
11
|
+
hitTest?: ((point: HitPoint) => HitTarget | null) | undefined;
|
|
12
12
|
/** Scroll container for auto-scroll; `false` turns it off. */
|
|
13
13
|
scroll?: () => HTMLElement | null | false;
|
|
14
14
|
};
|
|
@@ -16,8 +16,9 @@ export type DragPointer = {
|
|
|
16
16
|
destroy(): void;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* Calendar wiring for the generic drag session (plan 08-2 Step 4): the session
|
|
20
|
+
* owns the mechanics (threshold, long press, claim, capture, Escape layer,
|
|
21
|
+
* frame loop, auto-scroll, interaction lock); this file only says what a drag
|
|
22
|
+
* means — which event/resize handle was pressed and which edit handlers run.
|
|
22
23
|
*/
|
|
23
24
|
export declare function createDragPointer(root: HTMLElement, handlers: DragPointerHandlers): DragPointer;
|
|
@@ -1,203 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createDragSession } from "../../dom/drag-session.js";
|
|
2
|
+
import { hasForeignGestureHandle } from "./gesture-handle.js";
|
|
3
3
|
import { elementHitTest } from "./hit-test.js";
|
|
4
|
-
const LONG_PRESS_MS = 400;
|
|
5
|
-
const THRESHOLD = 4;
|
|
6
|
-
const TOUCH_SLOP = 8;
|
|
7
|
-
const hasFrames = typeof requestAnimationFrame === "function";
|
|
8
|
-
const frame = (callback) => hasFrames
|
|
9
|
-
? requestAnimationFrame(callback)
|
|
10
|
-
: setTimeout(callback, 16);
|
|
11
|
-
const unframe = (handle) => hasFrames
|
|
12
|
-
? cancelAnimationFrame(handle)
|
|
13
|
-
: clearTimeout(handle);
|
|
14
|
-
/** One drag per page, even with two calendars or two copies of core (plan 09 M13). */
|
|
15
|
-
const lock = () => getGlobalState("calendar-drag", () => ({ owner: null }));
|
|
16
4
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
5
|
+
* Calendar wiring for the generic drag session (plan 08-2 Step 4): the session
|
|
6
|
+
* owns the mechanics (threshold, long press, claim, capture, Escape layer,
|
|
7
|
+
* frame loop, auto-scroll, interaction lock); this file only says what a drag
|
|
8
|
+
* means — which event/resize handle was pressed and which edit handlers run.
|
|
20
9
|
*/
|
|
21
10
|
export function createDragPointer(root, handlers) {
|
|
22
11
|
const hitTest = handlers.hitTest ?? elementHitTest;
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let swallowClick = false;
|
|
31
|
-
const onSelectStart = (event) => event.preventDefault();
|
|
32
|
-
const onTouchMove = (event) => {
|
|
33
|
-
if (event.cancelable)
|
|
34
|
-
event.preventDefault();
|
|
35
|
-
};
|
|
36
|
-
const finish = () => {
|
|
37
|
-
if (longPress !== undefined) {
|
|
38
|
-
clearTimeout(longPress);
|
|
39
|
-
longPress = undefined;
|
|
40
|
-
}
|
|
41
|
-
if (pendingFrame !== 0) {
|
|
42
|
-
unframe(pendingFrame);
|
|
43
|
-
pendingFrame = 0;
|
|
44
|
-
}
|
|
45
|
-
scroller?.stop();
|
|
46
|
-
scroller = undefined;
|
|
47
|
-
document.removeEventListener("selectstart", onSelectStart);
|
|
48
|
-
document.removeEventListener("touchmove", onTouchMove);
|
|
49
|
-
window.removeEventListener("blur", onBlur);
|
|
50
|
-
if (pressed) {
|
|
51
|
-
try {
|
|
52
|
-
pressed.element.releasePointerCapture?.(pressed.id);
|
|
12
|
+
const session = createDragSession({
|
|
13
|
+
root,
|
|
14
|
+
gestureKind: "chrono-calendar-drag",
|
|
15
|
+
press: (event) => {
|
|
16
|
+
// E25: another owner's marked handle on the way to our root wins.
|
|
17
|
+
if (hasForeignGestureHandle(event, root, "chrono")) {
|
|
18
|
+
return null;
|
|
53
19
|
}
|
|
54
|
-
|
|
55
|
-
|
|
20
|
+
const element = event.target?.closest?.("[data-chrono-event-key]");
|
|
21
|
+
if (!element || !root.contains(element)) {
|
|
22
|
+
return null;
|
|
56
23
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (lock().owner !== null)
|
|
68
|
-
return false;
|
|
69
|
-
const target = hitTest({ x: pressed.x, y: pressed.y });
|
|
70
|
-
if (!target || !handlers.begin(pressed.kind, pressed.key, target))
|
|
71
|
-
return false;
|
|
72
|
-
lock().owner = token;
|
|
73
|
-
dragging = true;
|
|
74
|
-
document.addEventListener("selectstart", onSelectStart);
|
|
75
|
-
if (pressed.touch)
|
|
76
|
-
document.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
77
|
-
window.addEventListener("blur", onBlur);
|
|
78
|
-
try {
|
|
79
|
-
pressed.element.setPointerCapture?.(pressed.id);
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
// setPointerCapture throws for inactive pointers.
|
|
83
|
-
}
|
|
84
|
-
const container = handlers.scroll?.();
|
|
85
|
-
if (container !== false) {
|
|
86
|
-
scroller = createAutoScroll(() => container ?? scrollParent(root));
|
|
87
|
-
}
|
|
88
|
-
return true;
|
|
89
|
-
};
|
|
90
|
-
function onBlur() {
|
|
91
|
-
if (dragging) {
|
|
92
|
-
handlers.cancel();
|
|
93
|
-
finish();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const onDown = (event) => {
|
|
97
|
-
if (event.button !== 0 || pressed)
|
|
98
|
-
return; // primary button; a second pointer is ignored
|
|
99
|
-
const element = event.target?.closest?.("[data-chrono-event-key]");
|
|
100
|
-
if (!element || !root.contains(element))
|
|
101
|
-
return;
|
|
102
|
-
const handle = event.target.closest?.("[data-chrono-resize]");
|
|
103
|
-
const edge = handle?.getAttribute("data-chrono-resize");
|
|
104
|
-
const kind = edge === "start"
|
|
105
|
-
? "resize-start"
|
|
106
|
-
: edge === "end"
|
|
107
|
-
? "resize-end"
|
|
108
|
-
: "move";
|
|
109
|
-
const key = element.getAttribute("data-chrono-event-key") ?? "";
|
|
110
|
-
if (!handlers.canStart(kind, key))
|
|
111
|
-
return;
|
|
112
|
-
pressed = {
|
|
113
|
-
kind,
|
|
114
|
-
key,
|
|
115
|
-
x: event.clientX,
|
|
116
|
-
y: event.clientY,
|
|
117
|
-
id: event.pointerId,
|
|
118
|
-
touch: event.pointerType === "touch",
|
|
119
|
-
element: event.target,
|
|
120
|
-
};
|
|
121
|
-
if (pressed.touch) {
|
|
122
|
-
longPress = setTimeout(() => {
|
|
123
|
-
longPress = undefined;
|
|
124
|
-
if (!begin())
|
|
125
|
-
finish();
|
|
126
|
-
}, LONG_PRESS_MS);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
const onMove = (event) => {
|
|
130
|
-
if (!pressed || event.pointerId !== pressed.id)
|
|
131
|
-
return;
|
|
132
|
-
if (!dragging) {
|
|
133
|
-
const slop = pressed.touch ? TOUCH_SLOP : THRESHOLD;
|
|
134
|
-
const far = Math.abs(event.clientX - pressed.x) > slop ||
|
|
135
|
-
Math.abs(event.clientY - pressed.y) > slop;
|
|
136
|
-
if (pressed.touch) {
|
|
137
|
-
if (far && longPress !== undefined)
|
|
138
|
-
finish(); // the finger scrolled: no drag
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
if (!far)
|
|
142
|
-
return;
|
|
143
|
-
if (!begin()) {
|
|
144
|
-
finish();
|
|
145
|
-
return;
|
|
24
|
+
const handle = event.target.closest?.("[data-chrono-resize]");
|
|
25
|
+
const edge = handle?.getAttribute("data-chrono-resize");
|
|
26
|
+
const kind = edge === "start" ? "resize-start" : edge === "end" ? "resize-end" : "move";
|
|
27
|
+
const key = element.getAttribute("data-chrono-event-key") ?? "";
|
|
28
|
+
return handlers.canStart(kind, key) ? { kind, key } : null;
|
|
29
|
+
},
|
|
30
|
+
hitTest,
|
|
31
|
+
begin: (pressed, hit) => {
|
|
32
|
+
if (!hit) {
|
|
33
|
+
return false;
|
|
146
34
|
}
|
|
147
|
-
|
|
148
|
-
last = event;
|
|
149
|
-
scroller?.update({ x: event.clientX, y: event.clientY });
|
|
150
|
-
if (pendingFrame !== 0)
|
|
151
|
-
return;
|
|
152
|
-
pendingFrame = frame(() => {
|
|
153
|
-
pendingFrame = 0;
|
|
154
|
-
const move = last;
|
|
155
|
-
if (!move || !dragging)
|
|
156
|
-
return;
|
|
157
|
-
const target = hitTest({ x: move.clientX, y: move.clientY });
|
|
158
|
-
if (target)
|
|
159
|
-
handlers.update(target);
|
|
160
|
-
});
|
|
161
|
-
};
|
|
162
|
-
const onUp = (event) => {
|
|
163
|
-
if (!pressed || event.pointerId !== pressed.id)
|
|
164
|
-
return;
|
|
165
|
-
if (dragging) {
|
|
166
|
-
swallowClick = true;
|
|
167
|
-
handlers.drop();
|
|
168
|
-
}
|
|
169
|
-
finish();
|
|
170
|
-
};
|
|
171
|
-
const onCancel = (event) => {
|
|
172
|
-
if (!pressed || event.pointerId !== pressed.id)
|
|
173
|
-
return;
|
|
174
|
-
if (dragging)
|
|
175
|
-
handlers.cancel();
|
|
176
|
-
finish();
|
|
177
|
-
};
|
|
178
|
-
/** The click after a real drag must not select or activate the event. */
|
|
179
|
-
const onClick = (event) => {
|
|
180
|
-
if (swallowClick) {
|
|
181
|
-
swallowClick = false;
|
|
182
|
-
event.stopPropagation();
|
|
183
|
-
event.preventDefault();
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
root.addEventListener("pointerdown", onDown);
|
|
187
|
-
root.addEventListener("pointermove", onMove);
|
|
188
|
-
root.addEventListener("pointerup", onUp);
|
|
189
|
-
root.addEventListener("pointercancel", onCancel);
|
|
190
|
-
root.addEventListener("click", onClick, true);
|
|
191
|
-
return {
|
|
192
|
-
destroy() {
|
|
193
|
-
if (dragging)
|
|
194
|
-
handlers.cancel();
|
|
195
|
-
finish();
|
|
196
|
-
root.removeEventListener("pointerdown", onDown);
|
|
197
|
-
root.removeEventListener("pointermove", onMove);
|
|
198
|
-
root.removeEventListener("pointerup", onUp);
|
|
199
|
-
root.removeEventListener("pointercancel", onCancel);
|
|
200
|
-
root.removeEventListener("click", onClick, true);
|
|
35
|
+
return handlers.begin(pressed.kind, pressed.key, hit);
|
|
201
36
|
},
|
|
202
|
-
|
|
37
|
+
update: (hit) => handlers.update(hit),
|
|
38
|
+
drop: handlers.drop,
|
|
39
|
+
cancel: handlers.cancel,
|
|
40
|
+
scroll: handlers.scroll,
|
|
41
|
+
});
|
|
42
|
+
return session;
|
|
203
43
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gesture-handle priority (E25, plan 08-2 NQ14).
|
|
3
|
+
*
|
|
4
|
+
* A component marks its own drag handle with
|
|
5
|
+
* `data-zealakit-gesture-handle="<owner>"`. A session skips a `pointerdown`
|
|
6
|
+
* whose composed path meets a handle of a **different** owner before the
|
|
7
|
+
* session's own root, so an outer title bar or pane separator wins over the
|
|
8
|
+
* content it contains.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Whether `event`'s path reaches another owner's marked handle before `root`.
|
|
12
|
+
*
|
|
13
|
+
* @param event The `pointerdown` event.
|
|
14
|
+
* @param root The session's own root element.
|
|
15
|
+
* @param owner This component's handle name (e.g. `"chrono"`).
|
|
16
|
+
*/
|
|
17
|
+
export declare function hasForeignGestureHandle(event: PointerEvent, root: Element, owner: string): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gesture-handle priority (E25, plan 08-2 NQ14).
|
|
3
|
+
*
|
|
4
|
+
* A component marks its own drag handle with
|
|
5
|
+
* `data-zealakit-gesture-handle="<owner>"`. A session skips a `pointerdown`
|
|
6
|
+
* whose composed path meets a handle of a **different** owner before the
|
|
7
|
+
* session's own root, so an outer title bar or pane separator wins over the
|
|
8
|
+
* content it contains.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Whether `event`'s path reaches another owner's marked handle before `root`.
|
|
12
|
+
*
|
|
13
|
+
* @param event The `pointerdown` event.
|
|
14
|
+
* @param root The session's own root element.
|
|
15
|
+
* @param owner This component's handle name (e.g. `"chrono"`).
|
|
16
|
+
*/
|
|
17
|
+
export function hasForeignGestureHandle(event, root, owner) {
|
|
18
|
+
for (const node of event.composedPath?.() ?? []) {
|
|
19
|
+
if (node === root)
|
|
20
|
+
break;
|
|
21
|
+
const declared = node.getAttribute?.("data-zealakit-gesture-handle");
|
|
22
|
+
if (declared && declared !== owner)
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
@@ -7,7 +7,7 @@ export type SelectionPointerHandlers = {
|
|
|
7
7
|
/** Skip a press (for example on an event that is being dragged instead). */
|
|
8
8
|
ignore?: (event: PointerEvent) => boolean;
|
|
9
9
|
/** Tests pass their own; the default uses `elementHitTest`. */
|
|
10
|
-
hitTest?: (point: HitPoint) => HitTarget | null;
|
|
10
|
+
hitTest?: ((point: HitPoint) => HitTarget | null) | undefined;
|
|
11
11
|
};
|
|
12
12
|
export type SelectionPointer = {
|
|
13
13
|
destroy(): void;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
+
import { claimGesture } from "@zealakit/ui-engine/internal";
|
|
2
|
+
import { cancelFrame, scheduleFrame } from "../../dom/auto-scroll.js";
|
|
3
|
+
import { hasForeignGestureHandle } from "./gesture-handle.js";
|
|
1
4
|
import { elementHitTest } from "./hit-test.js";
|
|
2
5
|
const LONG_PRESS_MS = 400;
|
|
3
6
|
const TOUCH_SLOP = 8;
|
|
4
|
-
const hasFrames = typeof requestAnimationFrame === "function";
|
|
5
|
-
const schedule = (callback) => hasFrames
|
|
6
|
-
? requestAnimationFrame(callback)
|
|
7
|
-
: setTimeout(callback, 16);
|
|
8
|
-
const cancel = (handle) => hasFrames
|
|
9
|
-
? cancelAnimationFrame(handle)
|
|
10
|
-
: clearTimeout(handle);
|
|
11
7
|
/**
|
|
12
8
|
* Pointer selection pipeline (plan 05 §13.2): drag-select on `[data-chrono-key]`
|
|
13
9
|
* cells. Touch arms a 400 ms long press (canceled by a move past 8 px); a
|
|
@@ -17,6 +13,7 @@ const cancel = (handle) => hasFrames
|
|
|
17
13
|
export function createSelectionPointer(root, handlers) {
|
|
18
14
|
const hitTest = handlers.hitTest ?? elementHitTest;
|
|
19
15
|
let selecting = false;
|
|
16
|
+
let claim = null;
|
|
20
17
|
let longPressTimer;
|
|
21
18
|
let frame = 0;
|
|
22
19
|
let startX = 0;
|
|
@@ -28,10 +25,55 @@ export function createSelectionPointer(root, handlers) {
|
|
|
28
25
|
longPressTimer = undefined;
|
|
29
26
|
}
|
|
30
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Start a selection through the engine gesture claim (08-2 Step 2). The
|
|
30
|
+
* selection has no movement threshold today, so it claims on the press
|
|
31
|
+
* itself.
|
|
32
|
+
*
|
|
33
|
+
* E25 as decided (Q10): only marks between the pressed element and `root`
|
|
34
|
+
* are read, so a marked element inside the calendar with another owner
|
|
35
|
+
* blocks the press, while a marked wrapper *around* the calendar is never
|
|
36
|
+
* consulted. Capture only happens after the claim is ours (E23).
|
|
37
|
+
*/
|
|
38
|
+
const beginSelection = (target, pointerId, element) => {
|
|
39
|
+
if (selecting || claim) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const held = claimGesture({
|
|
43
|
+
element: root,
|
|
44
|
+
kind: "chrono-calendar-selection",
|
|
45
|
+
pointerId,
|
|
46
|
+
cancel: () => {
|
|
47
|
+
claim = null; // the engine already dropped it
|
|
48
|
+
onPointerCancel();
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
if (!held) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
claim = held;
|
|
55
|
+
try {
|
|
56
|
+
element?.setPointerCapture?.(pointerId);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// setPointerCapture throws for inactive pointers.
|
|
60
|
+
}
|
|
61
|
+
selecting = true;
|
|
62
|
+
handlers.start(target);
|
|
63
|
+
return true;
|
|
64
|
+
};
|
|
65
|
+
const endSelection = () => {
|
|
66
|
+
claim?.release();
|
|
67
|
+
claim = null;
|
|
68
|
+
};
|
|
31
69
|
const onPointerDown = (event) => {
|
|
32
70
|
if (event.button !== 0 || handlers.ignore?.(event)) {
|
|
33
71
|
return; // primary button only: a context-menu click never selects
|
|
34
72
|
}
|
|
73
|
+
// E25: another owner's marked handle on the way to our root wins.
|
|
74
|
+
if (hasForeignGestureHandle(event, root, "chrono")) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
35
77
|
const target = hitTest({ x: event.clientX, y: event.clientY });
|
|
36
78
|
if (!target) {
|
|
37
79
|
return;
|
|
@@ -42,15 +84,11 @@ export function createSelectionPointer(root, handlers) {
|
|
|
42
84
|
clearLongPress();
|
|
43
85
|
longPressTimer = setTimeout(() => {
|
|
44
86
|
longPressTimer = undefined;
|
|
45
|
-
|
|
46
|
-
event.target?.setPointerCapture?.(event.pointerId);
|
|
47
|
-
handlers.start(target);
|
|
87
|
+
beginSelection(target, event.pointerId, event.target);
|
|
48
88
|
}, LONG_PRESS_MS);
|
|
49
89
|
return;
|
|
50
90
|
}
|
|
51
|
-
|
|
52
|
-
event.target?.setPointerCapture?.(event.pointerId);
|
|
53
|
-
handlers.start(target);
|
|
91
|
+
beginSelection(target, event.pointerId, event.target);
|
|
54
92
|
};
|
|
55
93
|
const onPointerMove = (event) => {
|
|
56
94
|
if (longPressTimer !== undefined) {
|
|
@@ -67,7 +105,7 @@ export function createSelectionPointer(root, handlers) {
|
|
|
67
105
|
if (frame !== 0) {
|
|
68
106
|
return;
|
|
69
107
|
}
|
|
70
|
-
frame =
|
|
108
|
+
frame = scheduleFrame(() => {
|
|
71
109
|
frame = 0;
|
|
72
110
|
const move = lastMove;
|
|
73
111
|
lastMove = undefined;
|
|
@@ -89,6 +127,7 @@ export function createSelectionPointer(root, handlers) {
|
|
|
89
127
|
return;
|
|
90
128
|
}
|
|
91
129
|
selecting = false;
|
|
130
|
+
endSelection();
|
|
92
131
|
handlers.confirm();
|
|
93
132
|
};
|
|
94
133
|
const onPointerCancel = () => {
|
|
@@ -97,21 +136,32 @@ export function createSelectionPointer(root, handlers) {
|
|
|
97
136
|
return;
|
|
98
137
|
}
|
|
99
138
|
selecting = false;
|
|
139
|
+
endSelection();
|
|
100
140
|
handlers.cancel();
|
|
101
141
|
};
|
|
142
|
+
/** E26: a native drag cannot run inside a pointer session. */
|
|
143
|
+
const onDragStart = (event) => {
|
|
144
|
+
if (selecting) {
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
onPointerCancel();
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
root.addEventListener("dragstart", onDragStart);
|
|
102
150
|
root.addEventListener("pointerdown", onPointerDown);
|
|
103
151
|
root.addEventListener("pointermove", onPointerMove);
|
|
104
152
|
root.addEventListener("pointerup", onPointerUp);
|
|
105
153
|
root.addEventListener("pointercancel", onPointerCancel);
|
|
106
154
|
return {
|
|
107
155
|
destroy() {
|
|
156
|
+
root.removeEventListener("dragstart", onDragStart);
|
|
108
157
|
root.removeEventListener("pointerdown", onPointerDown);
|
|
109
158
|
root.removeEventListener("pointermove", onPointerMove);
|
|
110
159
|
root.removeEventListener("pointerup", onPointerUp);
|
|
111
160
|
root.removeEventListener("pointercancel", onPointerCancel);
|
|
112
161
|
clearLongPress();
|
|
162
|
+
endSelection();
|
|
113
163
|
if (frame !== 0) {
|
|
114
|
-
|
|
164
|
+
cancelFrame(frame);
|
|
115
165
|
frame = 0;
|
|
116
166
|
}
|
|
117
167
|
},
|
|
@@ -10,7 +10,7 @@ export type SelectionOptions = {
|
|
|
10
10
|
/** Snap granularity for timed selection (plan 05 E14), default 30 minutes. */
|
|
11
11
|
slotDurationMinutes?: number;
|
|
12
12
|
/** Clamp the selection length (E14); clamping is not invalidation. */
|
|
13
|
-
maxDurationMinutes?: number;
|
|
13
|
+
maxDurationMinutes?: number | undefined;
|
|
14
14
|
};
|
|
15
15
|
/** The half-open `[start, end)` selection. All-day ends are exclusive midnights. */
|
|
16
16
|
export type SelectionRange = {
|
|
@@ -6,14 +6,14 @@ export type NavigationState = {
|
|
|
6
6
|
anchor: PlainDate;
|
|
7
7
|
focusedDate: PlainDate;
|
|
8
8
|
/** Ad-hoc definition made by `{ range }` navigation (`setRange`). */
|
|
9
|
-
custom?: ViewDefinition;
|
|
9
|
+
custom?: ViewDefinition | undefined;
|
|
10
10
|
};
|
|
11
11
|
export type NavigationContext = {
|
|
12
12
|
views: Record<string, ViewDefinition>;
|
|
13
13
|
weekStartsOn: DayOfWeek;
|
|
14
14
|
hiddenDays: readonly DayOfWeek[];
|
|
15
|
-
min?: PlainDate;
|
|
16
|
-
max?: PlainDate;
|
|
15
|
+
min?: PlainDate | undefined;
|
|
16
|
+
max?: PlainDate | undefined;
|
|
17
17
|
today: PlainDate;
|
|
18
18
|
};
|
|
19
19
|
export type NavigationAction = "prev" | "next" | "today" | {
|
|
@@ -26,9 +26,7 @@ export function firstVisibleDay(range, hidden) {
|
|
|
26
26
|
/** Keep the focus where it is when possible; otherwise pull it into the range onto a visible day. */
|
|
27
27
|
function settleFocus(focused, range, hidden, ctx) {
|
|
28
28
|
const inside = clampDate(focused, range);
|
|
29
|
-
return clampToBounds(hidden.includes(dayOfWeek(inside))
|
|
30
|
-
? firstVisibleDay(range, hidden)
|
|
31
|
-
: inside, ctx);
|
|
29
|
+
return clampToBounds(hidden.includes(dayOfWeek(inside)) ? firstVisibleDay(range, hidden) : inside, ctx);
|
|
32
30
|
}
|
|
33
31
|
/** Can the range move one step toward the past (`-1`) or future (`1`) within `min` / `max`? (C10) */
|
|
34
32
|
export function canNavigate(state, direction, ctx) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { addDays, addMonths, addWeeks, endOfWeek, getMonths, startOfMonth, startOfWeek, startOfYear, } from "../../foundation/index.js";
|
|
2
|
-
import { getMonthCount
|
|
2
|
+
import { getMonthCount } from "./view-definition.js";
|
|
3
3
|
function alignStart(definition, anchor, ctx) {
|
|
4
4
|
switch (definition.align) {
|
|
5
5
|
case "week":
|
|
@@ -17,7 +17,7 @@ export type ViewDefinition = {
|
|
|
17
17
|
align: "day" | "week" | "month" | "year";
|
|
18
18
|
hiddenDays?: DayOfWeek[];
|
|
19
19
|
/** Month layout only: how many month grids to show. */
|
|
20
|
-
months?: number;
|
|
20
|
+
months?: number | undefined;
|
|
21
21
|
/** Month layout only: always render 6 rows per month. */
|
|
22
22
|
fixedWeeks?: boolean;
|
|
23
23
|
/** Resource packs (plan 10 IG1): builds the layout; never serialized. */
|
|
@@ -41,7 +41,8 @@ export function resolveViews(custom, weekend) {
|
|
|
41
41
|
return views;
|
|
42
42
|
}
|
|
43
43
|
function isDevelopment() {
|
|
44
|
-
const env = globalThis.process
|
|
44
|
+
const env = globalThis.process
|
|
45
|
+
?.env;
|
|
45
46
|
return env?.NODE_ENV !== "production";
|
|
46
47
|
}
|
|
47
48
|
/** Look up a view. Unknown ids throw in development and fall back to `month` in production. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { addDays, compare, fromEpochDay, fromInstant, fromSecondOfDay, plainDate, plainDateTime, toEpochDay, toInstant, toPlainDateTime, toSecondOfDay, toZoned, } from "../../foundation/index.js";
|
|
2
2
|
import { parseRRule, stringifyRRule } from "./rrule.js";
|
|
3
3
|
import { expandRecurrence, recurrenceWall } from "./series.js";
|
|
4
|
+
import { withOptional } from "../../foundation/store/with-optional.js";
|
|
4
5
|
const SECONDS_PER_DAY = 86400;
|
|
5
6
|
const DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
6
7
|
const MIDNIGHT = { hour: 0, minute: 0, second: 0 };
|
|
@@ -57,8 +58,7 @@ function occurrenceIndex(series, occurrenceStart, timeZone) {
|
|
|
57
58
|
// EXDATE does not reduce COUNT and RDATE is not counted, so index the bare rule.
|
|
58
59
|
const bare = { ...series, exdates: undefined, rdates: undefined };
|
|
59
60
|
const occurrences = expandRecurrence(bare, range, { timeZone });
|
|
60
|
-
return occurrences.filter((item) => compare(item.start, occurrenceStart) < 0)
|
|
61
|
-
.length;
|
|
61
|
+
return occurrences.filter((item) => compare(item.start, occurrenceStart) < 0).length;
|
|
62
62
|
}
|
|
63
63
|
/** End the old series before `occurrenceStart` (COUNT split or UNTIL). */
|
|
64
64
|
function splitSeries(series, occurrenceStart, timeZone) {
|
|
@@ -117,8 +117,7 @@ export function applyRecurrenceChange(series, proposal, scope, options = {}) {
|
|
|
117
117
|
const shape = series;
|
|
118
118
|
const occurrenceStart = proposalOccurrence(proposal, timeZone);
|
|
119
119
|
const allDay = proposal.to.allDay;
|
|
120
|
-
const delta = wallSeconds(wall(proposal.to.start, allDay, timeZone)) -
|
|
121
|
-
wallSeconds(occurrenceStart);
|
|
120
|
+
const delta = wallSeconds(wall(proposal.to.start, allDay, timeZone)) - wallSeconds(occurrenceStart);
|
|
122
121
|
if (scope === "this") {
|
|
123
122
|
return {
|
|
124
123
|
override: {
|
|
@@ -174,11 +173,11 @@ export function applyRecurrenceChange(series, proposal, scope, options = {}) {
|
|
|
174
173
|
...(exdates ? { exdates } : {}),
|
|
175
174
|
...(rdates ? { rdates } : {}),
|
|
176
175
|
};
|
|
177
|
-
return {
|
|
176
|
+
return withOptional({
|
|
178
177
|
series: split.series,
|
|
179
178
|
newSeries,
|
|
180
179
|
removed: split.series === undefined,
|
|
181
|
-
};
|
|
180
|
+
});
|
|
182
181
|
}
|
|
183
182
|
/**
|
|
184
183
|
* Apply a delete to a series (plan 12 RR9): `"this"` adds an EXDATE,
|
|
@@ -191,10 +190,10 @@ export function applyRecurrenceDelete(series, occurrenceStart, scope, options =
|
|
|
191
190
|
}
|
|
192
191
|
if (scope === "following") {
|
|
193
192
|
const split = splitSeries(series, occurrenceStart, timeZone);
|
|
194
|
-
return {
|
|
193
|
+
return withOptional({
|
|
195
194
|
series: split.series,
|
|
196
195
|
removed: split.series === undefined,
|
|
197
|
-
};
|
|
196
|
+
});
|
|
198
197
|
}
|
|
199
198
|
const shape = series;
|
|
200
199
|
return {
|
|
@@ -17,7 +17,7 @@ export type ExpandRuleOptions = {
|
|
|
17
17
|
/** All-day series: length in days (end is exclusive). */
|
|
18
18
|
durationDays: number;
|
|
19
19
|
range: DateRange;
|
|
20
|
-
onError?: (error: RRuleError) => void;
|
|
20
|
+
onError?: ((error: RRuleError) => void) | undefined;
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
23
|
* Expand a parsed rule inside `range` (plan 12 RR4/RR5). DTSTART is always the
|