@mintplayer/web-components 1.0.0 → 1.1.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/a11y/index.mjs +2 -56
- package/calendar/index.mjs +2 -363
- package/checkbox/index.mjs +4 -0
- package/checkbox/src/components/index.d.ts +2 -0
- package/checkbox/src/components/mp-checkbox.d.ts +69 -0
- package/checkbox/src/index.d.ts +2 -0
- package/chunks/color-C4VT0EL7.mjs +847 -0
- package/chunks/form-check.styles-jBlHetYX.mjs +151 -0
- package/chunks/live-announcer-CZDTKulf.mjs +58 -0
- package/chunks/mp-calendar.element-UC68iDbi.mjs +365 -0
- package/chunks/mp-checkbox-BokLL7BS.mjs +211 -0
- package/chunks/mp-datatable-CpAu8JJD.mjs +750 -0
- package/chunks/mp-pagination-BGxsawFL.mjs +326 -0
- package/chunks/mp-select-BDS1-YGn.mjs +254 -0
- package/chunks/mp-splitter-C8cGCmac.mjs +633 -0
- package/chunks/mp-tab-page-D1b4x-y2.mjs +414 -0
- package/chunks/mp-timepicker.element-BwEiwX92.mjs +428 -0
- package/chunks/mp-toggle-button-dLZNDUVz.mjs +534 -0
- package/chunks/mp-treeview-Bfq4_IVW.mjs +474 -0
- package/code-snippet/index.mjs +16 -13
- package/datatable/index.mjs +7 -0
- package/datatable/src/components/index.d.ts +2 -0
- package/datatable/src/components/mp-datatable.d.ts +156 -0
- package/datatable/src/index.d.ts +6 -0
- package/datatable/src/sort/compute-next-sort.d.ts +18 -0
- package/datatable/src/sort/index.d.ts +3 -0
- package/datatable/src/sort/sort-rows.d.ts +6 -0
- package/datatable/src/styles/datatable.styles.d.ts +2 -0
- package/datatable/src/styles/index.d.ts +1 -0
- package/datatable/src/types/column-def.d.ts +30 -0
- package/datatable/src/types/index.d.ts +1 -0
- package/datepicker/index.mjs +240 -0
- package/datepicker/src/index.d.ts +1 -0
- package/datepicker/src/mp-datepicker.element.d.ts +94 -0
- package/datepicker/src/mp-datepicker.element.template.d.ts +2 -0
- package/datetime-picker/index.mjs +427 -0
- package/datetime-picker/src/index.d.ts +1 -0
- package/datetime-picker/src/mp-datetime-picker.element.d.ts +174 -0
- package/datetime-picker/src/mp-datetime-picker.element.template.d.ts +2 -0
- package/dock/index.mjs +2402 -0
- package/dock/src/components/index.d.ts +1 -0
- package/dock/src/components/mint-dock-manager.element.d.ts +313 -0
- package/dock/src/components/mint-dock-manager.element.template.d.ts +2 -0
- package/dock/src/index.d.ts +2 -0
- package/dock/src/types/dock-layout.d.ts +65 -0
- package/dock/src/types/index.d.ts +1 -0
- package/file-manager/index.mjs +1263 -0
- package/file-manager/src/components/index.d.ts +2 -0
- package/file-manager/src/components/mp-file-manager.d.ts +320 -0
- package/file-manager/src/index.d.ts +5 -0
- package/file-manager/src/styles/file-manager.styles.d.ts +2 -0
- package/file-manager/src/styles/index.d.ts +1 -0
- package/file-manager/src/types/file-system-node.d.ts +24 -0
- package/file-manager/src/types/index.d.ts +3 -0
- package/file-manager/src/types/messages.d.ts +43 -0
- package/multi-range/index.mjs +407 -0
- package/multi-range/src/index.d.ts +2 -0
- package/multi-range/src/mint-multi-range.element.d.ts +124 -0
- package/multi-range/src/mint-multi-range.element.template.d.ts +2 -0
- package/multi-range/src/types/multi-range-orientation.d.ts +1 -0
- package/otp-input/index.mjs +362 -0
- package/otp-input/src/index.d.ts +4 -0
- package/otp-input/src/mint-otp-input.element.d.ts +134 -0
- package/otp-input/src/mint-otp-input.element.template.d.ts +2 -0
- package/otp-input/src/types/otp-input-case.d.ts +1 -0
- package/otp-input/src/types/otp-input-size.d.ts +1 -0
- package/otp-input/src/types/otp-input-type.d.ts +1 -0
- package/overlay/index.mjs +260 -0
- package/overlay/src/index.d.ts +2 -0
- package/overlay/src/overlay-controller.d.ts +205 -0
- package/package.json +1 -1
- package/pagination/index.mjs +5 -0
- package/pagination/src/components/index.d.ts +2 -0
- package/pagination/src/components/mp-pagination.d.ts +95 -0
- package/pagination/src/index.d.ts +2 -0
- package/pagination/src/styles/index.d.ts +1 -0
- package/pagination/src/styles/pagination.styles.d.ts +2 -0
- package/query-builder/index.mjs +3720 -0
- package/query-builder/src/context.d.ts +14 -0
- package/query-builder/src/dnd/drag-controller.d.ts +69 -0
- package/query-builder/src/index.d.ts +23 -0
- package/query-builder/src/model/default-tree.d.ts +7 -0
- package/query-builder/src/model/editor.d.ts +15 -0
- package/query-builder/src/model/errors.d.ts +6 -0
- package/query-builder/src/model/expression.d.ts +22 -0
- package/query-builder/src/model/field-def.d.ts +17 -0
- package/query-builder/src/model/messages.d.ts +17 -0
- package/query-builder/src/model/operator-overrides.d.ts +21 -0
- package/query-builder/src/model/operators.d.ts +8 -0
- package/query-builder/src/model/saved-query.d.ts +6 -0
- package/query-builder/src/model/sort.d.ts +9 -0
- package/query-builder/src/model/tree-ops.d.ts +56 -0
- package/query-builder/src/mp-query-builder.element.d.ts +158 -0
- package/query-builder/src/mp-query-builder.element.template.d.ts +2 -0
- package/query-builder/src/mp-query-condition.element.d.ts +44 -0
- package/query-builder/src/mp-query-condition.element.template.d.ts +2 -0
- package/query-builder/src/mp-query-group.element.d.ts +52 -0
- package/query-builder/src/mp-query-group.element.template.d.ts +2 -0
- package/query-builder/src/mp-query-subquery.element.d.ts +37 -0
- package/query-builder/src/mp-query-subquery.element.template.d.ts +2 -0
- package/query-builder/src/preview/render-expression.d.ts +23 -0
- package/query-builder/src/value-editors/builtin-editors.d.ts +6 -0
- package/query-builder/src/visitor/visit-tree.d.ts +29 -0
- package/query-builder/src/visitor/visitor-types.d.ts +15 -0
- package/radio/index.mjs +162 -0
- package/radio/src/components/index.d.ts +2 -0
- package/radio/src/components/mp-radio.d.ts +63 -0
- package/radio/src/index.d.ts +2 -0
- package/ribbon/index.mjs +3151 -0
- package/ribbon/src/index.d.ts +10 -0
- package/ribbon/src/items/index.d.ts +15 -0
- package/ribbon/src/items/mp-ribbon-button.element.d.ts +10 -0
- package/ribbon/src/items/mp-ribbon-checkbox.element.d.ts +11 -0
- package/ribbon/src/items/mp-ribbon-color-picker.element.d.ts +12 -0
- package/ribbon/src/items/mp-ribbon-combobox.element.d.ts +19 -0
- package/ribbon/src/items/mp-ribbon-dropdown-button.element.d.ts +16 -0
- package/ribbon/src/items/mp-ribbon-gallery-item.element.d.ts +15 -0
- package/ribbon/src/items/mp-ribbon-gallery.element.d.ts +11 -0
- package/ribbon/src/items/mp-ribbon-group-button.element.d.ts +18 -0
- package/ribbon/src/items/mp-ribbon-item-base.d.ts +68 -0
- package/ribbon/src/items/mp-ribbon-menu-item.element.d.ts +13 -0
- package/ribbon/src/items/mp-ribbon-menu-separator.element.d.ts +6 -0
- package/ribbon/src/items/mp-ribbon-split-button.element.d.ts +23 -0
- package/ribbon/src/items/mp-ribbon-template-item.element.d.ts +12 -0
- package/ribbon/src/items/mp-ribbon-toggle-button.element.d.ts +12 -0
- package/ribbon/src/mp-quick-access-toolbar.element.d.ts +35 -0
- package/ribbon/src/mp-ribbon-contextual-tab-set.element.d.ts +18 -0
- package/ribbon/src/mp-ribbon-group.element.d.ts +59 -0
- package/ribbon/src/mp-ribbon-tab.element.d.ts +72 -0
- package/ribbon/src/mp-ribbon.element.d.ts +211 -0
- package/ribbon/src/types/ribbon.types.d.ts +4 -0
- package/scheduler/index.mjs +3567 -0
- package/scheduler/src/components/mp-scheduler.d.ts +238 -0
- package/scheduler/src/drag/drag-manager.d.ts +90 -0
- package/scheduler/src/drag/drag-preview.d.ts +42 -0
- package/scheduler/src/drag/drag-state-machine.d.ts +102 -0
- package/scheduler/src/drag/drag-types.d.ts +104 -0
- package/scheduler/src/drag/index.d.ts +4 -0
- package/scheduler/src/events/event-types.d.ts +58 -0
- package/scheduler/src/events/index.d.ts +2 -0
- package/scheduler/src/events/scheduler-event-emitter.d.ts +52 -0
- package/scheduler/src/index.d.ts +6 -0
- package/scheduler/src/input/index.d.ts +2 -0
- package/scheduler/src/input/input-handler.d.ts +105 -0
- package/scheduler/src/input/pointer-event.d.ts +39 -0
- package/scheduler/src/state/scheduler-state.d.ts +189 -0
- package/scheduler/src/styles/scheduler.styles.d.ts +2 -0
- package/scheduler/src/views/base-view.d.ts +87 -0
- package/scheduler/src/views/day-view.d.ts +25 -0
- package/scheduler/src/views/index.d.ts +6 -0
- package/scheduler/src/views/month-view.d.ts +27 -0
- package/scheduler/src/views/timeline-view.d.ts +23 -0
- package/scheduler/src/views/week-view.d.ts +28 -0
- package/scheduler/src/views/year-view.d.ts +25 -0
- package/scheduler-core/index.mjs +174 -0
- package/scheduler-core/src/index.d.ts +3 -0
- package/scheduler-core/src/models/drag-state.d.ts +43 -0
- package/scheduler-core/src/models/event.d.ts +111 -0
- package/scheduler-core/src/models/events.d.ts +108 -0
- package/scheduler-core/src/models/index.d.ts +7 -0
- package/scheduler-core/src/models/options.d.ts +88 -0
- package/scheduler-core/src/models/resource.d.ts +58 -0
- package/scheduler-core/src/models/time-slot.d.ts +31 -0
- package/scheduler-core/src/models/types.d.ts +20 -0
- package/scheduler-core/src/services/date.service.d.ts +140 -0
- package/scheduler-core/src/services/index.d.ts +4 -0
- package/scheduler-core/src/services/position.service.d.ts +35 -0
- package/scheduler-core/src/services/resource.service.d.ts +83 -0
- package/scheduler-core/src/services/timeline.service.d.ts +103 -0
- package/scheduler-core/src/utils/color.d.ts +24 -0
- package/scheduler-core/src/utils/dom.d.ts +54 -0
- package/scheduler-core/src/utils/id.d.ts +16 -0
- package/scheduler-core/src/utils/index.d.ts +3 -0
- package/select/index.mjs +4 -0
- package/select/src/components/index.d.ts +2 -0
- package/select/src/components/mp-select.d.ts +82 -0
- package/select/src/index.d.ts +2 -0
- package/splitter/index.mjs +10 -0
- package/splitter/src/components/index.d.ts +2 -0
- package/splitter/src/components/mp-splitter.d.ts +109 -0
- package/splitter/src/index.d.ts +11 -0
- package/splitter/src/input/index.d.ts +4 -0
- package/splitter/src/input/input-handler.d.ts +36 -0
- package/splitter/src/input/pointer-event.d.ts +9 -0
- package/splitter/src/managers/index.d.ts +2 -0
- package/splitter/src/managers/resize-manager.d.ts +13 -0
- package/splitter/src/state/index.d.ts +2 -0
- package/splitter/src/state/splitter-state.d.ts +24 -0
- package/splitter/src/styles/index.d.ts +1 -0
- package/splitter/src/styles/splitter.styles.d.ts +2 -0
- package/splitter/src/types/direction.d.ts +1 -0
- package/splitter/src/types/index.d.ts +5 -0
- package/splitter/src/types/panel-info.d.ts +6 -0
- package/splitter/src/types/point.d.ts +4 -0
- package/splitter/src/types/resize-operation.d.ts +13 -0
- package/tab-control/index.mjs +6 -0
- package/tab-control/src/components/index.d.ts +3 -0
- package/tab-control/src/components/mp-tab-control.d.ts +50 -0
- package/tab-control/src/components/mp-tab-page.d.ts +35 -0
- package/tab-control/src/index.d.ts +4 -0
- package/tab-control/src/styles/index.d.ts +1 -0
- package/tab-control/src/styles/tab-control.styles.d.ts +2 -0
- package/tab-control/src/types/index.d.ts +1 -0
- package/tab-control/src/types/tabs-position.d.ts +1 -0
- package/tile-manager/index.mjs +867 -0
- package/tile-manager/src/components/index.d.ts +2 -0
- package/tile-manager/src/components/mint-tile-manager.element.d.ts +204 -0
- package/tile-manager/src/components/mint-tile-manager.element.template.d.ts +2 -0
- package/tile-manager/src/index.d.ts +4 -0
- package/tile-manager/src/types/grid-rect.d.ts +12 -0
- package/tile-manager/src/types/index.d.ts +3 -0
- package/tile-manager/src/types/tile-layout-snapshot.d.ts +15 -0
- package/tile-manager/src/types/tile-position.d.ts +10 -0
- package/tile-manager/src/utils/index.d.ts +1 -0
- package/tile-manager/src/utils/pack.d.ts +24 -0
- package/timepicker/index.mjs +5 -0
- package/timepicker/src/index.d.ts +2 -0
- package/timepicker/src/mp-time-list.element.d.ts +76 -0
- package/timepicker/src/mp-time-list.element.template.d.ts +2 -0
- package/timepicker/src/mp-timepicker.element.d.ts +87 -0
- package/timepicker/src/mp-timepicker.element.template.d.ts +2 -0
- package/toggle-button/index.mjs +5 -0
- package/toggle-button/src/components/index.d.ts +2 -0
- package/toggle-button/src/components/mp-toggle-button.d.ts +50 -0
- package/toggle-button/src/index.d.ts +3 -0
- package/toggle-button/src/styles/index.d.ts +1 -0
- package/toggle-button/src/styles/toggle-button.styles.d.ts +2 -0
- package/treeview/index.mjs +5 -0
- package/treeview/src/components/index.d.ts +2 -0
- package/treeview/src/components/mp-treeview.d.ts +113 -0
- package/treeview/src/index.d.ts +4 -0
- package/treeview/src/styles/index.d.ts +1 -0
- package/treeview/src/styles/treeview.styles.d.ts +2 -0
- package/treeview/src/types/index.d.ts +1 -0
- package/treeview/src/types/tree-node.d.ts +14 -0
- package/custom-elements.json +0 -1774
|
@@ -0,0 +1,3567 @@
|
|
|
1
|
+
import { unsafeCSS as W, LitElement as B, html as U } from "lit";
|
|
2
|
+
import { L as O } from "../chunks/live-announcer-CZDTKulf.mjs";
|
|
3
|
+
import { a as N, e as h, t as M, k as I, r as S, m as $, l as F, g as V } from "../chunks/color-C4VT0EL7.mjs";
|
|
4
|
+
function q(g = {}) {
|
|
5
|
+
const e = { ...N, ...g };
|
|
6
|
+
return {
|
|
7
|
+
view: e.initialView,
|
|
8
|
+
date: e.initialDate,
|
|
9
|
+
events: [],
|
|
10
|
+
resources: [],
|
|
11
|
+
options: e,
|
|
12
|
+
selectedEvent: null,
|
|
13
|
+
hoveredEvent: null,
|
|
14
|
+
hoveredSlot: null,
|
|
15
|
+
dragState: null,
|
|
16
|
+
previewEvent: null,
|
|
17
|
+
collapsedGroups: /* @__PURE__ */ new Set(),
|
|
18
|
+
isMouseDown: !1,
|
|
19
|
+
isLoading: !1,
|
|
20
|
+
focusedCell: null,
|
|
21
|
+
focusedResourceId: null,
|
|
22
|
+
selectionAnchor: null,
|
|
23
|
+
selectionExtent: null,
|
|
24
|
+
selectionResourceId: null,
|
|
25
|
+
keyboardMoveEventId: null,
|
|
26
|
+
focusedDate: null
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
class Y {
|
|
30
|
+
constructor(e = {}) {
|
|
31
|
+
this.listeners = /* @__PURE__ */ new Set(), this.state = q(e);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get current state
|
|
35
|
+
*/
|
|
36
|
+
getState() {
|
|
37
|
+
return this.state;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Update state with partial update or updater function
|
|
41
|
+
*/
|
|
42
|
+
setState(e) {
|
|
43
|
+
const t = typeof e == "function" ? e(this.state) : e;
|
|
44
|
+
this.state = { ...this.state, ...t }, this.notifyListeners();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Subscribe to state changes
|
|
48
|
+
*/
|
|
49
|
+
subscribe(e) {
|
|
50
|
+
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Notify all listeners of state change
|
|
54
|
+
*/
|
|
55
|
+
notifyListeners() {
|
|
56
|
+
for (const e of this.listeners)
|
|
57
|
+
e(this.state);
|
|
58
|
+
}
|
|
59
|
+
// Convenience methods for common state updates
|
|
60
|
+
/**
|
|
61
|
+
* Set the current view
|
|
62
|
+
*/
|
|
63
|
+
setView(e) {
|
|
64
|
+
this.setState({ view: e });
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Set the current date
|
|
68
|
+
*/
|
|
69
|
+
setDate(e) {
|
|
70
|
+
this.setState({ date: e });
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Set events
|
|
74
|
+
*/
|
|
75
|
+
setEvents(e) {
|
|
76
|
+
this.setState({ events: e });
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Add an event
|
|
80
|
+
*/
|
|
81
|
+
addEvent(e) {
|
|
82
|
+
this.setState((t) => ({
|
|
83
|
+
events: [...t.events, e]
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Update an event
|
|
88
|
+
*/
|
|
89
|
+
updateEvent(e) {
|
|
90
|
+
this.setState((t) => ({
|
|
91
|
+
events: t.events.map((s) => s.id === e.id ? e : s)
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Remove an event
|
|
96
|
+
*/
|
|
97
|
+
removeEvent(e) {
|
|
98
|
+
this.setState((t) => ({
|
|
99
|
+
events: t.events.filter((s) => s.id !== e)
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Set resources
|
|
104
|
+
*/
|
|
105
|
+
setResources(e) {
|
|
106
|
+
this.setState({ resources: e });
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Toggle resource group collapse
|
|
110
|
+
*/
|
|
111
|
+
toggleGroupCollapse(e) {
|
|
112
|
+
this.setState((t) => {
|
|
113
|
+
const s = new Set(t.collapsedGroups);
|
|
114
|
+
return s.has(e) ? s.delete(e) : s.add(e), { collapsedGroups: s };
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Set selected event
|
|
119
|
+
*/
|
|
120
|
+
setSelectedEvent(e) {
|
|
121
|
+
this.setState({ selectedEvent: e });
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Set hovered event
|
|
125
|
+
*/
|
|
126
|
+
setHoveredEvent(e) {
|
|
127
|
+
this.setState({ hoveredEvent: e });
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Set hovered slot
|
|
131
|
+
*/
|
|
132
|
+
setHoveredSlot(e) {
|
|
133
|
+
this.setState({ hoveredSlot: e });
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Start a drag operation
|
|
137
|
+
*/
|
|
138
|
+
startDrag(e) {
|
|
139
|
+
this.setState({
|
|
140
|
+
dragState: e,
|
|
141
|
+
previewEvent: e.preview,
|
|
142
|
+
isMouseDown: !0
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Update drag operation
|
|
147
|
+
*/
|
|
148
|
+
updateDrag(e, t) {
|
|
149
|
+
this.setState((s) => ({
|
|
150
|
+
dragState: s.dragState ? { ...s.dragState, currentSlot: e, preview: t } : null,
|
|
151
|
+
previewEvent: t
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* End drag operation
|
|
156
|
+
*/
|
|
157
|
+
endDrag() {
|
|
158
|
+
this.setState({
|
|
159
|
+
dragState: null,
|
|
160
|
+
previewEvent: null,
|
|
161
|
+
isMouseDown: !1
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Set mouse down state
|
|
166
|
+
*/
|
|
167
|
+
setMouseDown(e) {
|
|
168
|
+
this.setState({ isMouseDown: e });
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Set loading state
|
|
172
|
+
*/
|
|
173
|
+
setLoading(e) {
|
|
174
|
+
this.setState({ isLoading: e });
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Update options
|
|
178
|
+
*/
|
|
179
|
+
setOptions(e) {
|
|
180
|
+
this.setState((t) => ({
|
|
181
|
+
options: { ...t.options, ...e }
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Navigate to next period
|
|
186
|
+
*/
|
|
187
|
+
next() {
|
|
188
|
+
this.setState((e) => {
|
|
189
|
+
const t = new Date(e.date);
|
|
190
|
+
switch (e.view) {
|
|
191
|
+
case "year":
|
|
192
|
+
t.setFullYear(t.getFullYear() + 1);
|
|
193
|
+
break;
|
|
194
|
+
case "month":
|
|
195
|
+
t.setMonth(t.getMonth() + 1);
|
|
196
|
+
break;
|
|
197
|
+
case "week":
|
|
198
|
+
case "timeline":
|
|
199
|
+
t.setDate(t.getDate() + 7);
|
|
200
|
+
break;
|
|
201
|
+
case "day":
|
|
202
|
+
t.setDate(t.getDate() + 1);
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
return { date: t };
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Navigate to previous period
|
|
210
|
+
*/
|
|
211
|
+
prev() {
|
|
212
|
+
this.setState((e) => {
|
|
213
|
+
const t = new Date(e.date);
|
|
214
|
+
switch (e.view) {
|
|
215
|
+
case "year":
|
|
216
|
+
t.setFullYear(t.getFullYear() - 1);
|
|
217
|
+
break;
|
|
218
|
+
case "month":
|
|
219
|
+
t.setMonth(t.getMonth() - 1);
|
|
220
|
+
break;
|
|
221
|
+
case "week":
|
|
222
|
+
case "timeline":
|
|
223
|
+
t.setDate(t.getDate() - 7);
|
|
224
|
+
break;
|
|
225
|
+
case "day":
|
|
226
|
+
t.setDate(t.getDate() - 1);
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
return { date: t };
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Navigate to today
|
|
234
|
+
*/
|
|
235
|
+
today() {
|
|
236
|
+
this.setState({ date: /* @__PURE__ */ new Date() });
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Navigate to a specific date
|
|
240
|
+
*/
|
|
241
|
+
gotoDate(e) {
|
|
242
|
+
this.setState({ date: e });
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Move the keyboard focus to a cell. Setting `clearSelection` (default)
|
|
246
|
+
* also drops any active range selection — used for plain Arrow nav, where
|
|
247
|
+
* Shift would have stayed held to keep the range alive.
|
|
248
|
+
*/
|
|
249
|
+
setFocusedCell(e, t = null, s = !0) {
|
|
250
|
+
s ? this.setState({
|
|
251
|
+
focusedCell: e,
|
|
252
|
+
focusedResourceId: t,
|
|
253
|
+
selectionAnchor: null,
|
|
254
|
+
selectionExtent: null,
|
|
255
|
+
selectionResourceId: null
|
|
256
|
+
}) : this.setState({
|
|
257
|
+
focusedCell: e,
|
|
258
|
+
focusedResourceId: t
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Begin or extend a range selection. Anchor is set on first call (when
|
|
263
|
+
* Shift is first held), pinned at the *previously-focused* cell. Extent
|
|
264
|
+
* moves with each subsequent Shift+Arrow.
|
|
265
|
+
*/
|
|
266
|
+
extendSelection(e, t = null) {
|
|
267
|
+
this.setState((s) => {
|
|
268
|
+
const n = s.selectionAnchor ?? s.focusedCell ?? e, i = s.selectionResourceId ?? s.focusedResourceId ?? t;
|
|
269
|
+
return {
|
|
270
|
+
selectionAnchor: n,
|
|
271
|
+
selectionExtent: e,
|
|
272
|
+
selectionResourceId: i
|
|
273
|
+
};
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Clear any active range selection without touching the focused cell.
|
|
278
|
+
*/
|
|
279
|
+
clearSelection() {
|
|
280
|
+
this.setState({
|
|
281
|
+
selectionAnchor: null,
|
|
282
|
+
selectionExtent: null,
|
|
283
|
+
selectionResourceId: null
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Move the keyboard focus to a calendar date — used by month and year views
|
|
288
|
+
* (PRD scheduler-controlled-selection §5). Pass `null` to clear.
|
|
289
|
+
*/
|
|
290
|
+
setFocusedDate(e) {
|
|
291
|
+
this.setState({ focusedDate: e });
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function H(g, e, t = "24h") {
|
|
295
|
+
const s = h.formatTime(g.start, t), n = h.formatTime(g.end, t), i = g.start.toLocaleDateString(void 0, { weekday: "long", month: "short", day: "numeric" }), o = [`${g.title}, ${s}–${n}`, i];
|
|
296
|
+
return e && o.push(`on ${e}`), o.join(", ");
|
|
297
|
+
}
|
|
298
|
+
function k(g) {
|
|
299
|
+
const { selectionAnchor: e, selectionExtent: t, selectionResourceId: s } = g;
|
|
300
|
+
if (!e || !t) return null;
|
|
301
|
+
const n = Math.min(e.start.getTime(), t.start.getTime()), i = Math.max(e.end.getTime(), t.end.getTime());
|
|
302
|
+
return {
|
|
303
|
+
start: new Date(n),
|
|
304
|
+
end: new Date(i),
|
|
305
|
+
resourceId: s
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function R(g, e, t = null) {
|
|
309
|
+
const s = k(e);
|
|
310
|
+
return !s || s.resourceId && t && s.resourceId !== t ? !1 : g.start.getTime() < s.end.getTime() && g.end.getTime() > s.start.getTime();
|
|
311
|
+
}
|
|
312
|
+
function G(g, e = "24h", t = null) {
|
|
313
|
+
const s = g.start.toLocaleDateString(void 0, {
|
|
314
|
+
weekday: "long",
|
|
315
|
+
month: "short",
|
|
316
|
+
day: "numeric"
|
|
317
|
+
}), n = h.formatTime(g.start, e), i = [`${s}, ${n}`];
|
|
318
|
+
return t && i.push(t), i.join(", ");
|
|
319
|
+
}
|
|
320
|
+
function _(g, e, t = "24h") {
|
|
321
|
+
const s = k(g);
|
|
322
|
+
if (!s) return "";
|
|
323
|
+
const n = `${h.formatTime(s.start, t)} ${s.start.toLocaleDateString(void 0, { weekday: "short", month: "short", day: "numeric" })}`, i = `${h.formatTime(s.end, t)} ${s.end.toLocaleDateString(void 0, { weekday: "short", month: "short", day: "numeric" })}`, o = e * 1e3, r = Math.max(1, Math.round((s.end.getTime() - s.start.getTime()) / o));
|
|
324
|
+
return `Selection: ${n} to ${i}, ${r} slot${r === 1 ? "" : "s"}`;
|
|
325
|
+
}
|
|
326
|
+
function X(g, e, t = "24h") {
|
|
327
|
+
const s = g.toLocaleDateString(void 0, { weekday: "short", month: "short", day: "numeric" });
|
|
328
|
+
return `Moved to ${h.formatTime(g, t)}–${h.formatTime(e, t)}, ${s}`;
|
|
329
|
+
}
|
|
330
|
+
function j(g, e, t, s = "24h") {
|
|
331
|
+
return `Resized ${t} edge to ${h.formatTime(g, s)}–${h.formatTime(e, s)}`;
|
|
332
|
+
}
|
|
333
|
+
class x {
|
|
334
|
+
constructor(e, t) {
|
|
335
|
+
this.container = e, this.state = t;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Update the now indicator position (called every minute)
|
|
339
|
+
* Default implementation does nothing - override in views that have a now indicator
|
|
340
|
+
*/
|
|
341
|
+
updateNowIndicator() {
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Get the view's root element
|
|
345
|
+
*/
|
|
346
|
+
getElement() {
|
|
347
|
+
return this.container;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Helper to create an element with classes
|
|
351
|
+
*/
|
|
352
|
+
createElement(e, ...t) {
|
|
353
|
+
const s = document.createElement(e);
|
|
354
|
+
return t.length > 0 && s.classList.add(...t), s;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Helper to set data attributes
|
|
358
|
+
*/
|
|
359
|
+
setData(e, t) {
|
|
360
|
+
for (const [s, n] of Object.entries(t))
|
|
361
|
+
e.dataset[s] = String(n);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Helper to clear container
|
|
365
|
+
*/
|
|
366
|
+
clearContainer() {
|
|
367
|
+
this.container.innerHTML = "";
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
class A extends x {
|
|
371
|
+
constructor() {
|
|
372
|
+
super(...arguments), this.monthCards = /* @__PURE__ */ new Map();
|
|
373
|
+
}
|
|
374
|
+
render() {
|
|
375
|
+
this.clearContainer(), this.container.classList.add("scheduler-year-view");
|
|
376
|
+
const { date: e, options: t } = this.state, s = h.getYearMonths(e), n = this.createElement("div", "scheduler-year-grid");
|
|
377
|
+
this.monthCards.clear();
|
|
378
|
+
for (const i of s) {
|
|
379
|
+
const o = this.createMonthCard(i);
|
|
380
|
+
n.appendChild(o);
|
|
381
|
+
}
|
|
382
|
+
this.container.appendChild(n), this.updateMonthCardFocus();
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Build a `YYYY-MM` key from a Date, which is the unit of focus on year
|
|
386
|
+
* view (PRD scheduler-controlled-selection §5.2 — year cells are months,
|
|
387
|
+
* not days).
|
|
388
|
+
*/
|
|
389
|
+
static monthKey(e) {
|
|
390
|
+
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}`;
|
|
391
|
+
}
|
|
392
|
+
createMonthCard(e) {
|
|
393
|
+
const { events: t, options: s } = this.state, n = this.createElement("div", "scheduler-year-month"), i = A.monthKey(e);
|
|
394
|
+
n.setAttribute("role", "gridcell"), n.setAttribute("tabindex", "-1"), n.setAttribute("aria-selected", "false"), n.id = `scheduler-cell-y-${i}`, this.setData(n, { month: e.toISOString() }), this.monthCards.set(i, n);
|
|
395
|
+
const o = this.createElement("div", "scheduler-year-month-header");
|
|
396
|
+
o.textContent = h.getMonthName(e, s.locale), this.setData(o, { month: e.toISOString() }), n.appendChild(o);
|
|
397
|
+
const r = this.createElement("div", "scheduler-mini-month"), a = h.getMonthWeeks(e, s.firstDayOfWeek), l = a[0];
|
|
398
|
+
for (const m of l) {
|
|
399
|
+
const p = this.createElement("div", "scheduler-mini-day", "header");
|
|
400
|
+
p.textContent = h.getDayName(m, s.locale, "narrow"), p.style.fontWeight = "600", p.style.color = "#666", r.appendChild(p);
|
|
401
|
+
}
|
|
402
|
+
const d = h.getMonthStart(e), c = h.getMonthEnd(e), u = M.filterByRange(t, d, c), v = /* @__PURE__ */ new Set();
|
|
403
|
+
for (const m of u) {
|
|
404
|
+
const p = new Date(m.start);
|
|
405
|
+
for (p.setHours(0, 0, 0, 0); p <= m.end; )
|
|
406
|
+
v.add(p.toISOString().split("T")[0]), p.setDate(p.getDate() + 1);
|
|
407
|
+
}
|
|
408
|
+
for (const m of a)
|
|
409
|
+
for (const p of m) {
|
|
410
|
+
const f = this.createElement("div", "scheduler-mini-day");
|
|
411
|
+
f.textContent = String(p.getDate()), this.setData(f, { date: p.toISOString() }), h.isSameMonth(p, e) || f.classList.add("other-month"), h.isToday(p) && f.classList.add("today");
|
|
412
|
+
const b = p.toISOString().split("T")[0];
|
|
413
|
+
v.has(b) && f.classList.add("has-events"), r.appendChild(f);
|
|
414
|
+
}
|
|
415
|
+
return n.appendChild(r), n;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Apply roving tabindex based on `state.focusedDate`'s month. Year-view's
|
|
419
|
+
* focus unit is a month, so we strip down `focusedDate` to its `YYYY-MM`
|
|
420
|
+
* key. Falls back to the displayed year's first month if no focus yet.
|
|
421
|
+
*/
|
|
422
|
+
updateMonthCardFocus() {
|
|
423
|
+
const e = this.state.focusedDate;
|
|
424
|
+
let t = !1;
|
|
425
|
+
const s = e ? A.monthKey(e) : null;
|
|
426
|
+
for (const [n, i] of this.monthCards) {
|
|
427
|
+
const o = n === s;
|
|
428
|
+
i.setAttribute("tabindex", o ? "0" : "-1"), i.setAttribute("aria-selected", o ? "true" : "false"), o && (t = !0);
|
|
429
|
+
}
|
|
430
|
+
t || this.monthCards.values().next().value?.setAttribute("tabindex", "0");
|
|
431
|
+
}
|
|
432
|
+
update(e) {
|
|
433
|
+
const t = this.state.date.getFullYear() !== e.date.getFullYear();
|
|
434
|
+
if (this.state = e, t) {
|
|
435
|
+
this.render();
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
this.updateMonthCardFocus();
|
|
439
|
+
}
|
|
440
|
+
destroy() {
|
|
441
|
+
this.monthCards.clear(), this.clearContainer();
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
class T extends x {
|
|
445
|
+
constructor() {
|
|
446
|
+
super(...arguments), this.dayCells = /* @__PURE__ */ new Map();
|
|
447
|
+
}
|
|
448
|
+
render() {
|
|
449
|
+
this.clearContainer(), this.container.classList.add("scheduler-month-view");
|
|
450
|
+
const { date: e, options: t } = this.state, s = h.getMonthWeeks(e, t.firstDayOfWeek), n = this.createElement("div", "scheduler-day-headers"), i = s[0];
|
|
451
|
+
for (const r of i) {
|
|
452
|
+
const a = this.createElement("div", "scheduler-day-header");
|
|
453
|
+
a.textContent = h.getDayName(r, t.locale), n.appendChild(a);
|
|
454
|
+
}
|
|
455
|
+
this.container.appendChild(n);
|
|
456
|
+
const o = this.createElement("div", "scheduler-month-grid");
|
|
457
|
+
for (const r of s)
|
|
458
|
+
for (const a of r) {
|
|
459
|
+
const l = this.createDayCell(a);
|
|
460
|
+
o.appendChild(l);
|
|
461
|
+
}
|
|
462
|
+
this.container.appendChild(o), this.renderEvents(), this.updateDayCellFocus();
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Build a `YYYY-MM-DD` key from a Date using *local* components. Using
|
|
466
|
+
* `toISOString()` here would shift the key in any non-UTC timezone (a
|
|
467
|
+
* local midnight on May 12 in CEST is May 11 22:00 UTC), and the resulting
|
|
468
|
+
* cell IDs would not match the visible day numbers.
|
|
469
|
+
*/
|
|
470
|
+
static dayKey(e) {
|
|
471
|
+
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
472
|
+
}
|
|
473
|
+
createDayCell(e) {
|
|
474
|
+
const { date: t } = this.state, s = this.createElement("div", "scheduler-month-day");
|
|
475
|
+
h.isSameMonth(e, t) || s.classList.add("other-month"), h.isToday(e) && s.classList.add("today");
|
|
476
|
+
const n = T.dayKey(e);
|
|
477
|
+
s.setAttribute("role", "gridcell"), s.setAttribute("tabindex", "-1"), s.setAttribute("aria-selected", "false"), s.id = `scheduler-cell-m-${n}`;
|
|
478
|
+
const i = this.createElement("div", "day-number");
|
|
479
|
+
i.textContent = String(e.getDate()), s.appendChild(i);
|
|
480
|
+
const o = this.createElement("div", "month-events");
|
|
481
|
+
return s.appendChild(o), this.dayCells.set(n, s), this.setData(s, { date: n }), s;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Apply roving tabindex based on `state.focusedDate`. The grid must always
|
|
485
|
+
* have exactly one tab-reachable cell, so when no date is focused yet we
|
|
486
|
+
* fall back to today (if visible) or the first day of the displayed month.
|
|
487
|
+
*/
|
|
488
|
+
updateDayCellFocus() {
|
|
489
|
+
const e = this.state.focusedDate;
|
|
490
|
+
let t = !1;
|
|
491
|
+
const s = e ? T.dayKey(e) : null;
|
|
492
|
+
for (const [n, i] of this.dayCells) {
|
|
493
|
+
const o = n === s;
|
|
494
|
+
i.setAttribute("tabindex", o ? "0" : "-1"), i.setAttribute("aria-selected", o ? "true" : "false"), o && (t = !0);
|
|
495
|
+
}
|
|
496
|
+
t || (Array.from(this.dayCells.values()).find((i) => i.classList.contains("today") && !i.classList.contains("other-month")) || Array.from(this.dayCells.values()).find((i) => !i.classList.contains("other-month")) || this.dayCells.values().next().value)?.setAttribute("tabindex", "0");
|
|
497
|
+
}
|
|
498
|
+
renderEvents() {
|
|
499
|
+
const { date: e, events: t, options: s } = this.state;
|
|
500
|
+
h.getMonthStart(e), h.getMonthEnd(e);
|
|
501
|
+
const n = h.getMonthWeeks(e, s.firstDayOfWeek), i = n[0][0], o = n[n.length - 1][6];
|
|
502
|
+
o.setHours(23, 59, 59, 999);
|
|
503
|
+
const r = M.filterByRange(t, i, o), a = /* @__PURE__ */ new Map();
|
|
504
|
+
for (const d of r) {
|
|
505
|
+
const c = new Date(d.start), u = new Date(d.end), v = new Date(c);
|
|
506
|
+
for (v.setHours(0, 0, 0, 0); v <= u; ) {
|
|
507
|
+
const m = T.dayKey(v);
|
|
508
|
+
a.has(m) || a.set(m, []), a.get(m).push(d), v.setDate(v.getDate() + 1);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
const l = typeof s.dayMaxEvents == "number" ? s.dayMaxEvents : 3;
|
|
512
|
+
for (const [d, c] of a) {
|
|
513
|
+
const u = this.dayCells.get(d);
|
|
514
|
+
if (!u) continue;
|
|
515
|
+
const v = u.querySelector(".month-events");
|
|
516
|
+
if (!v) continue;
|
|
517
|
+
v.innerHTML = "";
|
|
518
|
+
const m = c.slice(0, l), p = c.length - m.length;
|
|
519
|
+
for (const f of m) {
|
|
520
|
+
const b = this.createElement("div", "scheduler-month-event");
|
|
521
|
+
b.textContent = f.title, b.style.backgroundColor = f.color ?? "#3788d8", b.style.color = f.textColor ?? I(f.color ?? "#3788d8"), this.setData(b, { eventId: f.id }), v.appendChild(b);
|
|
522
|
+
}
|
|
523
|
+
if (p > 0) {
|
|
524
|
+
const f = this.createElement("div", "scheduler-more-link");
|
|
525
|
+
f.textContent = `+${p} more`, this.setData(f, { date: d }), v.appendChild(f);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
update(e) {
|
|
530
|
+
const t = this.state.date.getMonth() !== e.date.getMonth() || this.state.date.getFullYear() !== e.date.getFullYear(), s = this.optionsRequireRerender(this.state.options, e.options);
|
|
531
|
+
if (this.state = e, t || s) {
|
|
532
|
+
this.render();
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
this.renderEvents(), this.updateDayCellFocus();
|
|
536
|
+
}
|
|
537
|
+
optionsRequireRerender(e, t) {
|
|
538
|
+
return e.firstDayOfWeek !== t.firstDayOfWeek || e.dayMaxEvents !== t.dayMaxEvents || e.locale !== t.locale;
|
|
539
|
+
}
|
|
540
|
+
destroy() {
|
|
541
|
+
this.dayCells.clear(), this.clearContainer();
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
class J extends x {
|
|
545
|
+
constructor() {
|
|
546
|
+
super(...arguments), this.dayColumns = [], this.eventElements = /* @__PURE__ */ new Map(), this.slotElements = /* @__PURE__ */ new Map();
|
|
547
|
+
}
|
|
548
|
+
render() {
|
|
549
|
+
this.clearContainer(), this.container.classList.add("scheduler-week-view");
|
|
550
|
+
const { date: e, options: t } = this.state, s = h.getWeekDays(e, t.firstDayOfWeek), n = this.createElement("div", "scheduler-day-headers"), i = this.createElement("div", "scheduler-time-gutter-space");
|
|
551
|
+
i.style.width = "var(--scheduler-time-gutter-width)", n.appendChild(i);
|
|
552
|
+
for (const d of s) {
|
|
553
|
+
const c = this.createElement("div", "scheduler-day-header");
|
|
554
|
+
h.isToday(d) && c.classList.add("today");
|
|
555
|
+
const u = this.createElement("div", "day-name");
|
|
556
|
+
u.textContent = h.getDayName(d, t.locale);
|
|
557
|
+
const v = this.createElement("div", "day-number");
|
|
558
|
+
v.textContent = String(d.getDate()), c.appendChild(u), c.appendChild(v), n.appendChild(c);
|
|
559
|
+
}
|
|
560
|
+
this.container.appendChild(n);
|
|
561
|
+
const o = this.createElement("div", "scheduler-time-grid"), r = this.createElement("div", "scheduler-time-gutter"), a = h.getTimeSlots(
|
|
562
|
+
s[0],
|
|
563
|
+
t.slotDuration,
|
|
564
|
+
t.slotMinTime,
|
|
565
|
+
t.slotMaxTime
|
|
566
|
+
);
|
|
567
|
+
for (const d of a) {
|
|
568
|
+
const c = this.createElement("div", "scheduler-time-slot-label");
|
|
569
|
+
c.textContent = h.formatTime(d.start, t.timeFormat), r.appendChild(c);
|
|
570
|
+
}
|
|
571
|
+
o.appendChild(r);
|
|
572
|
+
const l = this.createElement("div", "scheduler-days-container");
|
|
573
|
+
this.dayColumns = [];
|
|
574
|
+
for (let d = 0; d < s.length; d++) {
|
|
575
|
+
const c = s[d], u = this.createElement("div", "scheduler-day-column");
|
|
576
|
+
this.setData(u, { dayIndex: d });
|
|
577
|
+
for (let m = 0; m < a.length; m++) {
|
|
578
|
+
const p = a[m], f = new Date(c);
|
|
579
|
+
f.setHours(
|
|
580
|
+
p.start.getHours(),
|
|
581
|
+
p.start.getMinutes(),
|
|
582
|
+
0,
|
|
583
|
+
0
|
|
584
|
+
);
|
|
585
|
+
const b = new Date(c);
|
|
586
|
+
b.setHours(
|
|
587
|
+
p.end.getHours(),
|
|
588
|
+
p.end.getMinutes(),
|
|
589
|
+
0,
|
|
590
|
+
0
|
|
591
|
+
);
|
|
592
|
+
const y = this.createElement("div", "scheduler-time-slot");
|
|
593
|
+
y.setAttribute("role", "gridcell"), y.setAttribute("tabindex", "-1"), y.setAttribute("aria-selected", "false"), y.id = `scheduler-cell-w-${d}-${m}`, this.setData(y, {
|
|
594
|
+
dayIndex: d,
|
|
595
|
+
slotIndex: m,
|
|
596
|
+
start: f.toISOString(),
|
|
597
|
+
end: b.toISOString()
|
|
598
|
+
});
|
|
599
|
+
const E = `${d}-${m}`;
|
|
600
|
+
this.slotElements.set(E, y), u.appendChild(y);
|
|
601
|
+
}
|
|
602
|
+
const v = this.createElement("div", "scheduler-events-container");
|
|
603
|
+
u.appendChild(v), this.dayColumns.push(u), l.appendChild(u);
|
|
604
|
+
}
|
|
605
|
+
o.appendChild(l), this.container.appendChild(o), this.renderEvents(), this.updateCellFocusAndSelection(), this.renderNowIndicator(s, a);
|
|
606
|
+
}
|
|
607
|
+
update(e) {
|
|
608
|
+
const t = this.state.date.getTime() !== e.date.getTime(), s = this.optionsRequireRerender(this.state.options, e.options), n = this.state.selectedEvent?.id !== e.selectedEvent?.id;
|
|
609
|
+
if (this.state = e, t || s) {
|
|
610
|
+
this.render();
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
this.updateGreyedSlots(), n ? this.renderEvents() : this.renderEvents(), this.updateCellFocusAndSelection(), this.renderPreviewEvent();
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Apply roving tabindex and aria-selected to each cached slot element. Also
|
|
617
|
+
* toggles the `.selected` class so the existing `.scheduler-time-slot.selected`
|
|
618
|
+
* styling lights up cells in the keyboard-driven range. A linear time-range
|
|
619
|
+
* selection (PRD D1) lights up every slot whose [start, end) intersects
|
|
620
|
+
* the range, including across day boundaries on week view.
|
|
621
|
+
*/
|
|
622
|
+
updateCellFocusAndSelection() {
|
|
623
|
+
const e = this.state.focusedCell;
|
|
624
|
+
let t = !1, s = null;
|
|
625
|
+
for (const [, n] of this.slotElements) {
|
|
626
|
+
s || (s = n);
|
|
627
|
+
const i = n.dataset.start, o = n.dataset.end;
|
|
628
|
+
if (!i || !o) continue;
|
|
629
|
+
const r = { start: new Date(i), end: new Date(o) }, a = !!e && r.start.getTime() === e.start.getTime();
|
|
630
|
+
n.setAttribute("tabindex", a ? "0" : "-1");
|
|
631
|
+
const l = R(r, this.state, null);
|
|
632
|
+
n.setAttribute("aria-selected", l ? "true" : "false"), n.classList.toggle("selected", l), a && (t = !0);
|
|
633
|
+
}
|
|
634
|
+
!t && s && s.setAttribute("tabindex", "0");
|
|
635
|
+
}
|
|
636
|
+
optionsRequireRerender(e, t) {
|
|
637
|
+
return e.slotDuration !== t.slotDuration || e.timeFormat !== t.timeFormat || e.firstDayOfWeek !== t.firstDayOfWeek || e.slotMinTime !== t.slotMinTime || e.slotMaxTime !== t.slotMaxTime || e.locale !== t.locale;
|
|
638
|
+
}
|
|
639
|
+
renderEvents() {
|
|
640
|
+
const { date: e, events: t, options: s } = this.state, n = h.getWeekDays(e, s.firstDayOfWeek), i = n[0], o = new Date(n[6]);
|
|
641
|
+
o.setHours(23, 59, 59, 999);
|
|
642
|
+
const r = M.filterByRange(t, i, o), a = [];
|
|
643
|
+
for (const c of r) {
|
|
644
|
+
const { parts: u } = M.splitInParts(c);
|
|
645
|
+
a.push(...u);
|
|
646
|
+
}
|
|
647
|
+
const l = M.filterPartsByRange(a, i, o), d = M.getTimelinedParts(l);
|
|
648
|
+
this.eventElements.forEach((c) => c.remove()), this.eventElements.clear();
|
|
649
|
+
for (const { part: c, trackIndex: u, totalTracks: v, colspan: m } of d) {
|
|
650
|
+
if (!c.event) continue;
|
|
651
|
+
const p = n.findIndex((E) => h.isSameDay(E, c.start));
|
|
652
|
+
if (p === -1) continue;
|
|
653
|
+
const b = this.dayColumns[p].querySelector(".scheduler-events-container");
|
|
654
|
+
if (!b) continue;
|
|
655
|
+
const y = this.createEventElement(
|
|
656
|
+
c,
|
|
657
|
+
u,
|
|
658
|
+
v,
|
|
659
|
+
m,
|
|
660
|
+
s.slotDuration ?? 1800
|
|
661
|
+
);
|
|
662
|
+
b.appendChild(y), this.eventElements.set(c.id, y);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
createEventElement(e, t, s, n, i) {
|
|
666
|
+
const o = e.event, r = this.createElement("div", "scheduler-event"), a = this.state.selectedEvent?.id === o.id, l = this.state.keyboardMoveEventId === o.id;
|
|
667
|
+
r.setAttribute("role", "button"), r.setAttribute("tabindex", "0"), r.setAttribute(
|
|
668
|
+
"aria-label",
|
|
669
|
+
H(o, null, this.state.options.timeFormat)
|
|
670
|
+
), l && r.setAttribute("aria-pressed", "true"), a && (r.setAttribute("aria-current", "true"), r.classList.add("selected"));
|
|
671
|
+
const d = new Date(e.start);
|
|
672
|
+
d.setHours(0, 0, 0, 0);
|
|
673
|
+
const c = (e.start.getTime() - d.getTime()) / (1e3 * 60), v = (e.end.getTime() - d.getTime()) / (1e3 * 60) - c, m = i / 60, p = c / m * 40, f = Math.max(v / m * 40, 20), b = t / s * 100, y = n / s * 100;
|
|
674
|
+
r.style.top = `${p}px`, r.style.height = `${f}px`, r.style.left = `${b}%`, r.style.width = `calc(${y}% - 2px)`, r.style.backgroundColor = o.color ?? "#3788d8", r.style.color = o.textColor ?? I(o.color ?? "#3788d8"), this.setData(r, { eventId: o.id });
|
|
675
|
+
const E = this.createElement("div", "event-title");
|
|
676
|
+
E.textContent = o.title, r.appendChild(E);
|
|
677
|
+
const D = this.createElement("div", "event-time");
|
|
678
|
+
if (D.textContent = `${h.formatTime(e.start, this.state.options.timeFormat)} - ${h.formatTime(e.end, this.state.options.timeFormat)}`, r.appendChild(D), o.resizable !== !1) {
|
|
679
|
+
if (e.isStart) {
|
|
680
|
+
const w = this.createElement("div", "resize-handle", "top");
|
|
681
|
+
this.setData(w, { handle: "start" }), r.appendChild(w);
|
|
682
|
+
}
|
|
683
|
+
if (e.isEnd) {
|
|
684
|
+
const w = this.createElement("div", "resize-handle", "bottom");
|
|
685
|
+
this.setData(w, { handle: "end" }), r.appendChild(w);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
return r;
|
|
689
|
+
}
|
|
690
|
+
renderPreviewEvent() {
|
|
691
|
+
const e = this.container.querySelector(".scheduler-event.preview");
|
|
692
|
+
e && e.remove();
|
|
693
|
+
const { previewEvent: t, options: s, date: n } = this.state;
|
|
694
|
+
if (!t) return;
|
|
695
|
+
const o = h.getWeekDays(n, s.firstDayOfWeek).findIndex((b) => h.isSameDay(b, t.start));
|
|
696
|
+
if (o === -1) return;
|
|
697
|
+
const a = this.dayColumns[o]?.querySelector(".scheduler-events-container");
|
|
698
|
+
if (!a) return;
|
|
699
|
+
const l = this.createElement("div", "scheduler-event", "preview"), d = new Date(t.start);
|
|
700
|
+
d.setHours(0, 0, 0, 0);
|
|
701
|
+
const c = (t.start.getTime() - d.getTime()) / (1e3 * 60), v = (t.end.getTime() - d.getTime()) / (1e3 * 60) - c, m = (s.slotDuration ?? 1800) / 60, p = c / m * 40, f = Math.max(v / m * 40, 20);
|
|
702
|
+
l.style.top = `${p}px`, l.style.height = `${f}px`, l.style.left = "0", l.style.width = "100%", a.appendChild(l);
|
|
703
|
+
}
|
|
704
|
+
updateGreyedSlots() {
|
|
705
|
+
const { dragState: e, previewEvent: t, options: s, date: n } = this.state;
|
|
706
|
+
if (this.slotElements.forEach((r) => r.classList.remove("greyed")), !e || !t) return;
|
|
707
|
+
const i = h.getWeekDays(n, s.firstDayOfWeek), o = h.getTimeSlots(
|
|
708
|
+
i[0],
|
|
709
|
+
s.slotDuration,
|
|
710
|
+
s.slotMinTime,
|
|
711
|
+
s.slotMaxTime
|
|
712
|
+
);
|
|
713
|
+
for (let r = 0; r < i.length; r++) {
|
|
714
|
+
const a = i[r];
|
|
715
|
+
if (!(!h.isSameDay(a, t.start) && !h.isSameDay(a, t.end)))
|
|
716
|
+
for (let l = 0; l < o.length; l++) {
|
|
717
|
+
const d = o[l], c = new Date(a);
|
|
718
|
+
c.setHours(
|
|
719
|
+
d.start.getHours(),
|
|
720
|
+
d.start.getMinutes(),
|
|
721
|
+
0,
|
|
722
|
+
0
|
|
723
|
+
);
|
|
724
|
+
const u = new Date(a);
|
|
725
|
+
if (u.setHours(
|
|
726
|
+
d.end.getHours(),
|
|
727
|
+
d.end.getMinutes(),
|
|
728
|
+
0,
|
|
729
|
+
0
|
|
730
|
+
), c < t.end && u > t.start) {
|
|
731
|
+
const v = `${r}-${l}`, m = this.slotElements.get(v);
|
|
732
|
+
m && m.classList.add("greyed");
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
renderNowIndicator(e, t) {
|
|
738
|
+
if (!this.state.options.nowIndicator) return;
|
|
739
|
+
const s = /* @__PURE__ */ new Date(), n = e.findIndex((c) => h.isSameDay(c, s));
|
|
740
|
+
if (n === -1) return;
|
|
741
|
+
const i = this.dayColumns[n];
|
|
742
|
+
if (!i) return;
|
|
743
|
+
const o = new Date(s);
|
|
744
|
+
o.setHours(0, 0, 0, 0);
|
|
745
|
+
const r = (s.getTime() - o.getTime()) / (1e3 * 60), a = (this.state.options.slotDuration ?? 1800) / 60, l = r / a * 40, d = this.createElement("div", "scheduler-now-indicator");
|
|
746
|
+
d.style.top = `${l}px`, i.appendChild(d);
|
|
747
|
+
}
|
|
748
|
+
updateNowIndicator() {
|
|
749
|
+
if (!this.state.options.nowIndicator) return;
|
|
750
|
+
const { date: e, options: t } = this.state, s = h.getWeekDays(e, t.firstDayOfWeek), n = /* @__PURE__ */ new Date(), i = s.findIndex((u) => h.isSameDay(u, n));
|
|
751
|
+
if (i === -1) return;
|
|
752
|
+
const o = this.dayColumns[i];
|
|
753
|
+
if (!o) return;
|
|
754
|
+
const r = o.querySelector(".scheduler-now-indicator"), a = new Date(n);
|
|
755
|
+
a.setHours(0, 0, 0, 0);
|
|
756
|
+
const l = (n.getTime() - a.getTime()) / (1e3 * 60), d = (t.slotDuration ?? 1800) / 60, c = l / d * 40;
|
|
757
|
+
if (r)
|
|
758
|
+
r.style.top = `${c}px`;
|
|
759
|
+
else {
|
|
760
|
+
const u = this.createElement("div", "scheduler-now-indicator");
|
|
761
|
+
u.style.top = `${c}px`, o.appendChild(u);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
destroy() {
|
|
765
|
+
this.eventElements.clear(), this.slotElements.clear(), this.dayColumns = [], this.clearContainer();
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
class Z extends x {
|
|
769
|
+
constructor() {
|
|
770
|
+
super(...arguments), this.eventsContainer = null, this.slotElements = /* @__PURE__ */ new Map(), this.dayColumn = null;
|
|
771
|
+
}
|
|
772
|
+
render() {
|
|
773
|
+
this.clearContainer(), this.container.classList.add("scheduler-day-view");
|
|
774
|
+
const { date: e, options: t } = this.state, s = this.createElement("div", "scheduler-day-headers"), n = this.createElement("div", "scheduler-time-gutter-space");
|
|
775
|
+
n.style.width = "var(--scheduler-time-gutter-width)", s.appendChild(n);
|
|
776
|
+
const i = this.createElement("div", "scheduler-day-header");
|
|
777
|
+
h.isToday(e) && i.classList.add("today");
|
|
778
|
+
const o = this.createElement("div", "day-name");
|
|
779
|
+
o.textContent = h.getDayName(e, t.locale);
|
|
780
|
+
const r = this.createElement("div", "day-number");
|
|
781
|
+
r.textContent = String(e.getDate());
|
|
782
|
+
const a = this.createElement("div", "month-year");
|
|
783
|
+
a.textContent = h.formatDate(e, t.locale, {
|
|
784
|
+
month: "long",
|
|
785
|
+
year: "numeric"
|
|
786
|
+
}), a.style.fontSize = "12px", a.style.color = "#666", i.appendChild(o), i.appendChild(r), i.appendChild(a), s.appendChild(i), this.container.appendChild(s);
|
|
787
|
+
const l = this.createElement("div", "scheduler-time-grid"), d = this.createElement("div", "scheduler-time-gutter"), c = h.getTimeSlots(
|
|
788
|
+
e,
|
|
789
|
+
t.slotDuration,
|
|
790
|
+
t.slotMinTime,
|
|
791
|
+
t.slotMaxTime
|
|
792
|
+
);
|
|
793
|
+
for (const m of c) {
|
|
794
|
+
const p = this.createElement("div", "scheduler-time-slot-label");
|
|
795
|
+
p.textContent = h.formatTime(m.start, t.timeFormat), d.appendChild(p);
|
|
796
|
+
}
|
|
797
|
+
l.appendChild(d);
|
|
798
|
+
const u = this.createElement("div", "scheduler-days-container");
|
|
799
|
+
this.dayColumn = this.createElement("div", "scheduler-day-column");
|
|
800
|
+
const v = this.dayColumn;
|
|
801
|
+
for (let m = 0; m < c.length; m++) {
|
|
802
|
+
const p = c[m], f = this.createElement("div", "scheduler-time-slot");
|
|
803
|
+
f.setAttribute("role", "gridcell"), f.setAttribute("tabindex", "-1"), f.setAttribute("aria-selected", "false"), f.id = `scheduler-cell-d-${m}`, this.setData(f, {
|
|
804
|
+
slotIndex: m,
|
|
805
|
+
start: p.start.toISOString(),
|
|
806
|
+
end: p.end.toISOString()
|
|
807
|
+
}), this.slotElements.set(m, f), v.appendChild(f);
|
|
808
|
+
}
|
|
809
|
+
this.eventsContainer = this.createElement("div", "scheduler-events-container"), v.appendChild(this.eventsContainer), u.appendChild(v), l.appendChild(u), this.container.appendChild(l), this.renderEvents(), this.updateCellFocusAndSelection(), h.isToday(e) && t.nowIndicator && this.renderNowIndicator(v);
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Apply roving tabindex + aria-selected + `.selected` class to each cached
|
|
813
|
+
* slot element based on focusedCell and selection range.
|
|
814
|
+
*/
|
|
815
|
+
updateCellFocusAndSelection() {
|
|
816
|
+
const e = this.state.focusedCell;
|
|
817
|
+
let t = !1, s = null;
|
|
818
|
+
for (const [, n] of this.slotElements) {
|
|
819
|
+
s || (s = n);
|
|
820
|
+
const i = n.dataset.start, o = n.dataset.end;
|
|
821
|
+
if (!i || !o) continue;
|
|
822
|
+
const r = { start: new Date(i), end: new Date(o) }, a = !!e && r.start.getTime() === e.start.getTime();
|
|
823
|
+
n.setAttribute("tabindex", a ? "0" : "-1");
|
|
824
|
+
const l = R(r, this.state, null);
|
|
825
|
+
n.setAttribute("aria-selected", l ? "true" : "false"), n.classList.toggle("selected", l), a && (t = !0);
|
|
826
|
+
}
|
|
827
|
+
!t && s && s.setAttribute("tabindex", "0");
|
|
828
|
+
}
|
|
829
|
+
renderEvents() {
|
|
830
|
+
if (!this.eventsContainer) return;
|
|
831
|
+
this.eventsContainer.innerHTML = "";
|
|
832
|
+
const { date: e, events: t, options: s } = this.state, n = new Date(e);
|
|
833
|
+
n.setHours(0, 0, 0, 0);
|
|
834
|
+
const i = new Date(e);
|
|
835
|
+
i.setHours(23, 59, 59, 999);
|
|
836
|
+
const o = M.filterByRange(t, n, i), r = [];
|
|
837
|
+
for (const l of o) {
|
|
838
|
+
const { parts: d } = M.splitInParts(l), c = M.filterPartsByRange(d, n, i);
|
|
839
|
+
r.push(...c);
|
|
840
|
+
}
|
|
841
|
+
const a = M.getTimelinedParts(r);
|
|
842
|
+
for (const { part: l, trackIndex: d, totalTracks: c, colspan: u } of a) {
|
|
843
|
+
if (!l.event) continue;
|
|
844
|
+
const v = this.createEventElement(
|
|
845
|
+
l,
|
|
846
|
+
d,
|
|
847
|
+
c,
|
|
848
|
+
u,
|
|
849
|
+
s.slotDuration ?? 1800
|
|
850
|
+
);
|
|
851
|
+
this.eventsContainer.appendChild(v);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
createEventElement(e, t, s, n, i) {
|
|
855
|
+
const o = e.event, r = this.createElement("div", "scheduler-event"), a = this.state.selectedEvent?.id === o.id, l = this.state.keyboardMoveEventId === o.id;
|
|
856
|
+
r.setAttribute("role", "button"), r.setAttribute("tabindex", "0"), r.setAttribute(
|
|
857
|
+
"aria-label",
|
|
858
|
+
H(o, null, this.state.options.timeFormat)
|
|
859
|
+
), l && r.setAttribute("aria-pressed", "true"), a && (r.setAttribute("aria-current", "true"), r.classList.add("selected"));
|
|
860
|
+
const d = new Date(e.start);
|
|
861
|
+
d.setHours(0, 0, 0, 0);
|
|
862
|
+
const c = (e.start.getTime() - d.getTime()) / (1e3 * 60), v = (e.end.getTime() - d.getTime()) / (1e3 * 60) - c, m = i / 60, p = c / m * 40, f = Math.max(v / m * 40, 20), b = t / s * 100, y = n / s * 100;
|
|
863
|
+
r.style.top = `${p}px`, r.style.height = `${f}px`, r.style.left = `${b}%`, r.style.width = `calc(${y}% - 2px)`, r.style.backgroundColor = o.color ?? "#3788d8", r.style.color = o.textColor ?? I(o.color ?? "#3788d8"), this.setData(r, { eventId: o.id });
|
|
864
|
+
const E = this.createElement("div", "event-title");
|
|
865
|
+
E.textContent = o.title, r.appendChild(E);
|
|
866
|
+
const D = this.createElement("div", "event-time");
|
|
867
|
+
if (D.textContent = `${h.formatTime(e.start, this.state.options.timeFormat)} - ${h.formatTime(e.end, this.state.options.timeFormat)}`, r.appendChild(D), o.resizable !== !1) {
|
|
868
|
+
if (e.isStart) {
|
|
869
|
+
const w = this.createElement("div", "resize-handle", "top");
|
|
870
|
+
this.setData(w, { handle: "start" }), r.appendChild(w);
|
|
871
|
+
}
|
|
872
|
+
if (e.isEnd) {
|
|
873
|
+
const w = this.createElement("div", "resize-handle", "bottom");
|
|
874
|
+
this.setData(w, { handle: "end" }), r.appendChild(w);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
return r;
|
|
878
|
+
}
|
|
879
|
+
renderNowIndicator(e) {
|
|
880
|
+
const t = /* @__PURE__ */ new Date(), s = new Date(t);
|
|
881
|
+
s.setHours(0, 0, 0, 0);
|
|
882
|
+
const n = (t.getTime() - s.getTime()) / (1e3 * 60), i = (this.state.options.slotDuration ?? 1800) / 60, o = n / i * 40, r = this.createElement("div", "scheduler-now-indicator");
|
|
883
|
+
r.style.top = `${o}px`, e.appendChild(r);
|
|
884
|
+
}
|
|
885
|
+
updateNowIndicator() {
|
|
886
|
+
if (!this.dayColumn || !this.state.options.nowIndicator || !h.isToday(this.state.date)) return;
|
|
887
|
+
const e = this.dayColumn.querySelector(".scheduler-now-indicator"), t = /* @__PURE__ */ new Date(), s = new Date(t);
|
|
888
|
+
s.setHours(0, 0, 0, 0);
|
|
889
|
+
const n = (t.getTime() - s.getTime()) / (1e3 * 60), i = (this.state.options.slotDuration ?? 1800) / 60, o = n / i * 40;
|
|
890
|
+
e ? e.style.top = `${o}px` : this.renderNowIndicator(this.dayColumn);
|
|
891
|
+
}
|
|
892
|
+
update(e) {
|
|
893
|
+
const t = this.state.date.getTime() !== e.date.getTime(), s = this.optionsRequireRerender(this.state.options, e.options);
|
|
894
|
+
if (this.state = e, t || s) {
|
|
895
|
+
this.render();
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
this.updateGreyedSlots(), this.renderEvents(), this.updateCellFocusAndSelection(), this.renderPreviewEvent();
|
|
899
|
+
}
|
|
900
|
+
optionsRequireRerender(e, t) {
|
|
901
|
+
return e.slotDuration !== t.slotDuration || e.timeFormat !== t.timeFormat || e.slotMinTime !== t.slotMinTime || e.slotMaxTime !== t.slotMaxTime || e.locale !== t.locale;
|
|
902
|
+
}
|
|
903
|
+
updateGreyedSlots() {
|
|
904
|
+
const { dragState: e, previewEvent: t, options: s, date: n } = this.state;
|
|
905
|
+
if (this.slotElements.forEach((o) => o.classList.remove("greyed")), !e || !t || !h.isSameDay(n, t.start)) return;
|
|
906
|
+
const i = h.getTimeSlots(
|
|
907
|
+
n,
|
|
908
|
+
s.slotDuration,
|
|
909
|
+
s.slotMinTime,
|
|
910
|
+
s.slotMaxTime
|
|
911
|
+
);
|
|
912
|
+
for (let o = 0; o < i.length; o++) {
|
|
913
|
+
const r = i[o];
|
|
914
|
+
if (r.start < t.end && r.end > t.start) {
|
|
915
|
+
const a = this.slotElements.get(o);
|
|
916
|
+
a && a.classList.add("greyed");
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
renderPreviewEvent() {
|
|
921
|
+
if (!this.eventsContainer) return;
|
|
922
|
+
const e = this.eventsContainer.querySelector(".scheduler-event.preview");
|
|
923
|
+
e && e.remove();
|
|
924
|
+
const { previewEvent: t, options: s, date: n } = this.state;
|
|
925
|
+
if (!t || !h.isSameDay(n, t.start)) return;
|
|
926
|
+
const i = this.createElement("div", "scheduler-event", "preview"), o = new Date(t.start);
|
|
927
|
+
o.setHours(0, 0, 0, 0);
|
|
928
|
+
const r = (t.start.getTime() - o.getTime()) / (1e3 * 60), l = (t.end.getTime() - o.getTime()) / (1e3 * 60) - r, d = (s.slotDuration ?? 1800) / 60, c = r / d * 40, u = Math.max(l / d * 40, 20);
|
|
929
|
+
i.style.top = `${c}px`, i.style.height = `${u}px`, i.style.left = "0", i.style.width = "100%", this.eventsContainer.appendChild(i);
|
|
930
|
+
}
|
|
931
|
+
destroy() {
|
|
932
|
+
this.eventsContainer = null, this.dayColumn = null, this.slotElements.clear(), this.clearContainer();
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
class Q extends x {
|
|
936
|
+
constructor() {
|
|
937
|
+
super(...arguments), this.rowElements = /* @__PURE__ */ new Map(), this.slotWidth = 50;
|
|
938
|
+
}
|
|
939
|
+
render() {
|
|
940
|
+
this.clearContainer(), this.container.classList.add("scheduler-timeline-view");
|
|
941
|
+
const { date: e, options: t, resources: s, collapsedGroups: n } = this.state, i = h.getWeekDays(e, t.firstDayOfWeek), r = S.flatten(s, n).filter((y) => y.visible).length + 1, a = this.createElement("div", "scheduler-timeline");
|
|
942
|
+
a.setAttribute("role", "grid"), a.setAttribute(
|
|
943
|
+
"aria-label",
|
|
944
|
+
`Resource timeline for week starting ${h.formatDateWithWeekday(i[0], t.locale)}`
|
|
945
|
+
), a.setAttribute("aria-rowcount", String(r));
|
|
946
|
+
const l = this.createElement("div", "scheduler-timeline-header");
|
|
947
|
+
l.setAttribute("role", "row"), l.setAttribute("aria-rowindex", "1");
|
|
948
|
+
const d = this.createElement("div", "scheduler-resource-header");
|
|
949
|
+
d.setAttribute("role", "columnheader"), d.textContent = "Resources", l.appendChild(d);
|
|
950
|
+
const c = this.createElement("div", "scheduler-timeline-slots-header");
|
|
951
|
+
for (const y of i) {
|
|
952
|
+
const D = h.getTimeSlots(
|
|
953
|
+
y,
|
|
954
|
+
t.slotDuration,
|
|
955
|
+
t.slotMinTime,
|
|
956
|
+
t.slotMaxTime
|
|
957
|
+
).length, w = this.createElement("div", "scheduler-timeline-slot-header");
|
|
958
|
+
w.setAttribute("role", "columnheader"), w.style.width = `${D * this.slotWidth}px`, w.textContent = h.formatDateWithWeekday(y, t.locale), w.style.borderBottom = "1px solid var(--scheduler-border-color)", c.appendChild(w);
|
|
959
|
+
}
|
|
960
|
+
l.appendChild(c), a.appendChild(l);
|
|
961
|
+
const u = this.createElement("div", "scheduler-timeline-header"), v = this.createElement("div", "scheduler-resource-header");
|
|
962
|
+
v.style.borderBottom = "1px solid var(--scheduler-border-color)", u.appendChild(v);
|
|
963
|
+
const m = this.createElement("div", "scheduler-timeline-slots-header");
|
|
964
|
+
for (const y of i) {
|
|
965
|
+
const E = h.getTimeSlots(
|
|
966
|
+
y,
|
|
967
|
+
t.slotDuration,
|
|
968
|
+
t.slotMinTime,
|
|
969
|
+
t.slotMaxTime
|
|
970
|
+
);
|
|
971
|
+
for (const D of E) {
|
|
972
|
+
const w = this.createElement("div", "scheduler-timeline-slot-header");
|
|
973
|
+
w.setAttribute("role", "columnheader"), w.style.width = `${this.slotWidth}px`, w.textContent = h.formatTime(D.start, t.timeFormat), w.style.fontSize = "10px", m.appendChild(w);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
u.appendChild(m), a.appendChild(u);
|
|
977
|
+
const p = this.createElement("div", "scheduler-timeline-body"), f = S.flatten(s, n);
|
|
978
|
+
let b = 2;
|
|
979
|
+
for (const y of f) {
|
|
980
|
+
if (!y.visible) continue;
|
|
981
|
+
const E = this.createResourceRow(y, i);
|
|
982
|
+
E.setAttribute("aria-rowindex", String(b)), p.appendChild(E), b++;
|
|
983
|
+
}
|
|
984
|
+
a.appendChild(p), this.container.appendChild(a), this.renderEvents(i), this.updateCellFocusAndSelection();
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Apply roving tabindex + aria-selected + `.selected` class to each
|
|
988
|
+
* timeline-slot element. Selection is constrained to the resource pinned
|
|
989
|
+
* at the anchor (PRD D1: cross-resource selection ignored).
|
|
990
|
+
*/
|
|
991
|
+
updateCellFocusAndSelection() {
|
|
992
|
+
const e = this.state.focusedCell, t = this.state.focusedResourceId, s = this.container.querySelectorAll(".scheduler-timeline-slot");
|
|
993
|
+
let n = !1, i = null;
|
|
994
|
+
s.forEach((o) => {
|
|
995
|
+
i || (i = o);
|
|
996
|
+
const r = o.dataset.start, a = o.dataset.end, l = o.dataset.resourceId ?? null;
|
|
997
|
+
if (!r || !a) return;
|
|
998
|
+
const d = { start: new Date(r), end: new Date(a) }, c = !!e && d.start.getTime() === e.start.getTime() && t === l;
|
|
999
|
+
o.setAttribute("tabindex", c ? "0" : "-1");
|
|
1000
|
+
const u = R(d, this.state, l);
|
|
1001
|
+
o.setAttribute("aria-selected", u ? "true" : "false"), o.classList.toggle("selected", u), c && (n = !0);
|
|
1002
|
+
}), !n && i && i.setAttribute("tabindex", "0");
|
|
1003
|
+
}
|
|
1004
|
+
createResourceRow(e, t) {
|
|
1005
|
+
const { options: s } = this.state, n = this.createElement("div", "scheduler-timeline-row");
|
|
1006
|
+
n.setAttribute("role", "row"), $(e.item) && n.classList.add("group");
|
|
1007
|
+
const i = this.createElement("div", "scheduler-resource-cell");
|
|
1008
|
+
if (i.setAttribute("role", "rowheader"), i.style.paddingLeft = `${8 + e.depth * 16}px`, $(e.item)) {
|
|
1009
|
+
const a = this.createElement("button", "expand-toggle");
|
|
1010
|
+
a.type = "button";
|
|
1011
|
+
const l = this.state.collapsedGroups.has(e.item.id);
|
|
1012
|
+
a.textContent = l ? "▶" : "▼", a.setAttribute("aria-expanded", String(!l)), a.setAttribute("aria-label", `${l ? "Expand" : "Collapse"} ${e.item.title}`), this.setData(a, { groupId: e.item.id }), i.appendChild(a);
|
|
1013
|
+
}
|
|
1014
|
+
const o = this.createElement("span");
|
|
1015
|
+
o.textContent = e.item.title, i.appendChild(o), n.appendChild(i);
|
|
1016
|
+
const r = this.createElement("div", "scheduler-timeline-slots");
|
|
1017
|
+
for (const a of t) {
|
|
1018
|
+
const l = h.getTimeSlots(
|
|
1019
|
+
a,
|
|
1020
|
+
s.slotDuration,
|
|
1021
|
+
s.slotMinTime,
|
|
1022
|
+
s.slotMaxTime
|
|
1023
|
+
);
|
|
1024
|
+
for (const d of l) {
|
|
1025
|
+
const c = this.createElement("div", "scheduler-timeline-slot");
|
|
1026
|
+
c.setAttribute("role", "gridcell"), c.setAttribute("tabindex", "-1"), c.setAttribute("aria-selected", "false"), c.id = `scheduler-cell-t-${e.item.id}-${d.start.getTime()}`, c.style.width = `${this.slotWidth}px`, this.setData(c, {
|
|
1027
|
+
resourceId: e.item.id,
|
|
1028
|
+
start: d.start.toISOString(),
|
|
1029
|
+
end: d.end.toISOString()
|
|
1030
|
+
}), r.appendChild(c);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
if (F(e.item)) {
|
|
1034
|
+
const a = this.createElement("div", "scheduler-timeline-events");
|
|
1035
|
+
r.appendChild(a);
|
|
1036
|
+
}
|
|
1037
|
+
return n.appendChild(r), this.rowElements.set(e.item.id, n), n;
|
|
1038
|
+
}
|
|
1039
|
+
renderEvents(e) {
|
|
1040
|
+
const { events: t, resources: s, options: n, collapsedGroups: i } = this.state, o = e[0], r = new Date(e[6]);
|
|
1041
|
+
r.setHours(23, 59, 59, 999);
|
|
1042
|
+
const d = h.getTimeSlots(
|
|
1043
|
+
e[0],
|
|
1044
|
+
n.slotDuration,
|
|
1045
|
+
n.slotMinTime,
|
|
1046
|
+
n.slotMaxTime
|
|
1047
|
+
).length * 7 * this.slotWidth, c = S.getAllResources(s);
|
|
1048
|
+
for (const u of c) {
|
|
1049
|
+
const v = this.rowElements.get(u.id);
|
|
1050
|
+
if (!v) continue;
|
|
1051
|
+
const m = v.querySelector(".scheduler-timeline-events");
|
|
1052
|
+
if (!m) continue;
|
|
1053
|
+
m.innerHTML = "";
|
|
1054
|
+
const f = (u.events ?? []).filter(
|
|
1055
|
+
(y) => y.start < r && y.end > o
|
|
1056
|
+
).map((y) => ({
|
|
1057
|
+
id: y.id,
|
|
1058
|
+
event: y,
|
|
1059
|
+
start: y.start,
|
|
1060
|
+
end: y.end,
|
|
1061
|
+
isStart: !0,
|
|
1062
|
+
isEnd: !0,
|
|
1063
|
+
dayIndex: 0,
|
|
1064
|
+
totalDays: 1
|
|
1065
|
+
})), b = M.getTimelinedParts(f);
|
|
1066
|
+
for (const { part: y, trackIndex: E, totalTracks: D, colspan: w } of b) {
|
|
1067
|
+
if (!y.event) continue;
|
|
1068
|
+
const K = this.createEventElement(
|
|
1069
|
+
y.event,
|
|
1070
|
+
E,
|
|
1071
|
+
D,
|
|
1072
|
+
w,
|
|
1073
|
+
o,
|
|
1074
|
+
d,
|
|
1075
|
+
n.slotDuration ?? 1800,
|
|
1076
|
+
u.title
|
|
1077
|
+
);
|
|
1078
|
+
m.appendChild(K);
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
createEventElement(e, t, s, n, i, o, r, a = null) {
|
|
1083
|
+
const l = this.createElement("div", "scheduler-timeline-event"), d = this.state.selectedEvent?.id === e.id, c = this.state.keyboardMoveEventId === e.id;
|
|
1084
|
+
l.setAttribute("role", "button"), l.setAttribute("tabindex", "0"), l.setAttribute(
|
|
1085
|
+
"aria-label",
|
|
1086
|
+
H(e, a, this.state.options.timeFormat)
|
|
1087
|
+
), c && l.setAttribute("aria-pressed", "true"), d && (l.setAttribute("aria-current", "true"), l.classList.add("selected"));
|
|
1088
|
+
const u = Math.max(e.start.getTime(), i.getTime()), v = i.getTime() + 10080 * 60 * 1e3, m = Math.min(e.end.getTime(), v), p = u - i.getTime(), f = m - u, b = v - i.getTime(), y = p / b * o, E = Math.max(f / b * o, 20), D = t / s * 100, w = n / s * 100;
|
|
1089
|
+
return l.style.left = `${y}px`, l.style.width = `${E}px`, l.style.top = `${D}%`, l.style.height = `${w}%`, l.style.backgroundColor = e.color ?? "#3788d8", l.style.color = e.textColor ?? I(e.color ?? "#3788d8"), this.setData(l, { eventId: e.id }), l.textContent = e.title, l;
|
|
1090
|
+
}
|
|
1091
|
+
update(e) {
|
|
1092
|
+
const t = this.state.date.getTime() !== e.date.getTime(), s = this.optionsRequireRerender(this.state.options, e.options);
|
|
1093
|
+
if (this.state = e, t || s) {
|
|
1094
|
+
this.render();
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
this.updateGreyedSlots();
|
|
1098
|
+
const n = h.getWeekDays(e.date, e.options.firstDayOfWeek);
|
|
1099
|
+
this.renderEvents(n), this.updateCellFocusAndSelection();
|
|
1100
|
+
}
|
|
1101
|
+
optionsRequireRerender(e, t) {
|
|
1102
|
+
return e.slotDuration !== t.slotDuration || e.timeFormat !== t.timeFormat || e.firstDayOfWeek !== t.firstDayOfWeek || e.slotMinTime !== t.slotMinTime || e.slotMaxTime !== t.slotMaxTime || e.locale !== t.locale;
|
|
1103
|
+
}
|
|
1104
|
+
updateGreyedSlots() {
|
|
1105
|
+
const { dragState: e, previewEvent: t } = this.state, s = this.container.querySelectorAll(".scheduler-timeline-slot");
|
|
1106
|
+
s.forEach((n) => n.classList.remove("greyed")), !(!e || !t) && s.forEach((n) => {
|
|
1107
|
+
const i = new Date(n.dataset.start ?? ""), o = new Date(n.dataset.end ?? "");
|
|
1108
|
+
i < t.end && o > t.start && n.classList.add("greyed");
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
destroy() {
|
|
1112
|
+
this.rowElements.clear(), this.clearContainer();
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
const ee = W(`:host {
|
|
1116
|
+
display: block;
|
|
1117
|
+
height: 100%;
|
|
1118
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
|
|
1119
|
+
font-size: 14px;
|
|
1120
|
+
--scheduler-border-color: var(--bs-border-color, #ddd);
|
|
1121
|
+
--scheduler-header-bg: var(--bs-tertiary-bg, #f8f9fa);
|
|
1122
|
+
--scheduler-today-bg: var(--bs-warning-bg-subtle, #fff3cd);
|
|
1123
|
+
--scheduler-slot-height: 40px;
|
|
1124
|
+
--scheduler-time-gutter-width: 80px;
|
|
1125
|
+
--scheduler-event-border-radius: 4px;
|
|
1126
|
+
--scheduler-now-indicator-color: var(--bs-danger, #dc3545);
|
|
1127
|
+
--scheduler-preview-bg: rgba(0, 123, 255, 0.3);
|
|
1128
|
+
--scheduler-greyed-slot-bg: rgba(0, 0, 0, 0.1);
|
|
1129
|
+
--scheduler-column-min-width: 120px;
|
|
1130
|
+
--scheduler-touch-hold-duration: 500ms;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
* {
|
|
1134
|
+
box-sizing: border-box;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
.scheduler-container {
|
|
1138
|
+
display: flex;
|
|
1139
|
+
flex-direction: column;
|
|
1140
|
+
height: 100%;
|
|
1141
|
+
border: 1px solid var(--scheduler-border-color);
|
|
1142
|
+
border-radius: 4px;
|
|
1143
|
+
overflow: hidden;
|
|
1144
|
+
background: var(--bs-body-bg);
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
/* Header */
|
|
1148
|
+
.scheduler-header {
|
|
1149
|
+
display: flex;
|
|
1150
|
+
align-items: center;
|
|
1151
|
+
justify-content: space-between;
|
|
1152
|
+
padding: 8px 12px;
|
|
1153
|
+
background: var(--scheduler-header-bg);
|
|
1154
|
+
border-bottom: 1px solid var(--scheduler-border-color);
|
|
1155
|
+
flex-shrink: 0;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
.scheduler-nav {
|
|
1159
|
+
display: flex;
|
|
1160
|
+
align-items: center;
|
|
1161
|
+
gap: 8px;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
.scheduler-nav button {
|
|
1165
|
+
padding: 6px 12px;
|
|
1166
|
+
border: 1px solid var(--scheduler-border-color);
|
|
1167
|
+
border-radius: 4px;
|
|
1168
|
+
background: var(--bs-body-bg);
|
|
1169
|
+
cursor: pointer;
|
|
1170
|
+
font-size: 14px;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
.scheduler-nav button:hover {
|
|
1174
|
+
background: var(--bs-tertiary-bg);
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
.scheduler-title {
|
|
1178
|
+
font-size: 18px;
|
|
1179
|
+
font-weight: 600;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
.scheduler-view-switcher {
|
|
1183
|
+
display: flex;
|
|
1184
|
+
gap: 4px;
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
.scheduler-view-switcher button {
|
|
1188
|
+
padding: 6px 12px;
|
|
1189
|
+
border: 1px solid var(--scheduler-border-color);
|
|
1190
|
+
border-radius: 4px;
|
|
1191
|
+
background: var(--bs-body-bg);
|
|
1192
|
+
cursor: pointer;
|
|
1193
|
+
font-size: 13px;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
.scheduler-view-switcher button:hover {
|
|
1197
|
+
background: var(--bs-tertiary-bg);
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
.scheduler-view-switcher button.active {
|
|
1201
|
+
background: var(--bs-primary);
|
|
1202
|
+
color: #fff;
|
|
1203
|
+
border-color: var(--bs-primary);
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
/* Main content area */
|
|
1207
|
+
.scheduler-body {
|
|
1208
|
+
display: flex;
|
|
1209
|
+
flex: 1;
|
|
1210
|
+
overflow: hidden;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
.scheduler-sidebar {
|
|
1214
|
+
width: var(--scheduler-time-gutter-width);
|
|
1215
|
+
flex-shrink: 0;
|
|
1216
|
+
border-right: 1px solid var(--scheduler-border-color);
|
|
1217
|
+
background: var(--scheduler-header-bg);
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
.scheduler-content {
|
|
1221
|
+
flex: 1;
|
|
1222
|
+
overflow: auto;
|
|
1223
|
+
position: relative;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
/* Week/Day View Grid */
|
|
1227
|
+
.scheduler-grid {
|
|
1228
|
+
display: grid;
|
|
1229
|
+
min-width: 100%;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
.scheduler-day-headers {
|
|
1233
|
+
display: flex;
|
|
1234
|
+
border-bottom: 1px solid var(--scheduler-border-color);
|
|
1235
|
+
background: var(--scheduler-header-bg);
|
|
1236
|
+
position: sticky;
|
|
1237
|
+
top: 0;
|
|
1238
|
+
z-index: 10;
|
|
1239
|
+
min-width: fit-content;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
.scheduler-day-header {
|
|
1243
|
+
flex: 1 0 var(--scheduler-column-min-width);
|
|
1244
|
+
min-width: var(--scheduler-column-min-width);
|
|
1245
|
+
text-align: center;
|
|
1246
|
+
padding: 8px 4px;
|
|
1247
|
+
border-right: 1px solid var(--scheduler-border-color);
|
|
1248
|
+
font-weight: 500;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
.scheduler-day-header:last-child {
|
|
1252
|
+
border-right: none;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
.scheduler-day-header.today {
|
|
1256
|
+
background: var(--scheduler-today-bg);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
.scheduler-day-header .day-name {
|
|
1260
|
+
font-size: 12px;
|
|
1261
|
+
color: var(--bs-secondary-color);
|
|
1262
|
+
text-transform: uppercase;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
.scheduler-day-header .day-number {
|
|
1266
|
+
font-size: 20px;
|
|
1267
|
+
font-weight: 600;
|
|
1268
|
+
margin-top: 2px;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
.scheduler-time-grid {
|
|
1272
|
+
display: flex;
|
|
1273
|
+
position: relative;
|
|
1274
|
+
min-width: fit-content;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
.scheduler-time-gutter {
|
|
1278
|
+
width: var(--scheduler-time-gutter-width);
|
|
1279
|
+
flex-shrink: 0;
|
|
1280
|
+
border-right: 1px solid var(--scheduler-border-color);
|
|
1281
|
+
background: var(--scheduler-header-bg);
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
.scheduler-time-slot-label {
|
|
1285
|
+
height: var(--scheduler-slot-height);
|
|
1286
|
+
padding: 0 8px;
|
|
1287
|
+
font-size: 12px;
|
|
1288
|
+
color: var(--bs-secondary-color);
|
|
1289
|
+
text-align: right;
|
|
1290
|
+
position: relative;
|
|
1291
|
+
top: -8px;
|
|
1292
|
+
white-space: nowrap;
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
.scheduler-days-container {
|
|
1296
|
+
display: flex;
|
|
1297
|
+
flex: 1;
|
|
1298
|
+
position: relative;
|
|
1299
|
+
min-width: fit-content;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
.scheduler-day-column {
|
|
1303
|
+
flex: 1 0 var(--scheduler-column-min-width);
|
|
1304
|
+
min-width: var(--scheduler-column-min-width);
|
|
1305
|
+
position: relative;
|
|
1306
|
+
border-right: 1px solid var(--scheduler-border-color);
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
.scheduler-day-column:last-child {
|
|
1310
|
+
border-right: none;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
.scheduler-time-slot {
|
|
1314
|
+
height: var(--scheduler-slot-height);
|
|
1315
|
+
border-bottom: 1px solid var(--bs-border-color);
|
|
1316
|
+
position: relative;
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
.scheduler-time-slot:nth-child(2n) {
|
|
1320
|
+
border-bottom-color: var(--scheduler-border-color);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
.scheduler-time-slot.greyed {
|
|
1324
|
+
background: var(--scheduler-greyed-slot-bg);
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
.scheduler-time-slot.selected {
|
|
1328
|
+
background: var(--scheduler-preview-bg);
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
.scheduler-time-slot:focus-visible,
|
|
1332
|
+
.scheduler-time-slot:focus {
|
|
1333
|
+
outline: 2px solid var(--bs-primary);
|
|
1334
|
+
outline-offset: -2px;
|
|
1335
|
+
z-index: 1;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
/* Events */
|
|
1339
|
+
.scheduler-events-container {
|
|
1340
|
+
position: absolute;
|
|
1341
|
+
top: 0;
|
|
1342
|
+
left: 0;
|
|
1343
|
+
right: 0;
|
|
1344
|
+
bottom: 0;
|
|
1345
|
+
pointer-events: none;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
.scheduler-event {
|
|
1349
|
+
position: absolute;
|
|
1350
|
+
border-radius: var(--scheduler-event-border-radius);
|
|
1351
|
+
padding: 2px 4px;
|
|
1352
|
+
font-size: 12px;
|
|
1353
|
+
overflow: hidden;
|
|
1354
|
+
cursor: pointer;
|
|
1355
|
+
pointer-events: auto;
|
|
1356
|
+
border-left: 3px solid rgba(0, 0, 0, 0.2);
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
/* Prevent browser from handling touch gestures on events (enables drag) */
|
|
1360
|
+
.scheduler-event:not(.preview) {
|
|
1361
|
+
touch-action: none;
|
|
1362
|
+
-ms-touch-action: none;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
.scheduler-event:hover {
|
|
1366
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
.scheduler-event.selected {
|
|
1370
|
+
box-shadow: 0 0 0 3px var(--bs-body-color);
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
.scheduler-event .event-title {
|
|
1374
|
+
font-weight: 500;
|
|
1375
|
+
white-space: nowrap;
|
|
1376
|
+
overflow: hidden;
|
|
1377
|
+
text-overflow: ellipsis;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
.scheduler-event .event-time {
|
|
1381
|
+
font-size: 11px;
|
|
1382
|
+
opacity: 0.8;
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
.scheduler-event.preview {
|
|
1386
|
+
background: var(--scheduler-preview-bg);
|
|
1387
|
+
border: 2px dashed var(--bs-primary);
|
|
1388
|
+
pointer-events: none;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
/* Resize handles */
|
|
1392
|
+
.scheduler-event .resize-handle {
|
|
1393
|
+
position: absolute;
|
|
1394
|
+
left: 0;
|
|
1395
|
+
right: 0;
|
|
1396
|
+
height: 8px;
|
|
1397
|
+
cursor: ns-resize;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
.scheduler-event .resize-handle.top {
|
|
1401
|
+
top: 0;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
.scheduler-event .resize-handle.bottom {
|
|
1405
|
+
bottom: 0;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
/* Now indicator */
|
|
1409
|
+
.scheduler-now-indicator {
|
|
1410
|
+
position: absolute;
|
|
1411
|
+
left: 0;
|
|
1412
|
+
right: 0;
|
|
1413
|
+
height: 2px;
|
|
1414
|
+
background: var(--scheduler-now-indicator-color);
|
|
1415
|
+
z-index: 5;
|
|
1416
|
+
pointer-events: none;
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
.scheduler-now-indicator::before {
|
|
1420
|
+
content: "";
|
|
1421
|
+
position: absolute;
|
|
1422
|
+
left: -4px;
|
|
1423
|
+
top: -4px;
|
|
1424
|
+
width: 10px;
|
|
1425
|
+
height: 10px;
|
|
1426
|
+
border-radius: 50%;
|
|
1427
|
+
background: var(--scheduler-now-indicator-color);
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
/* Month View */
|
|
1431
|
+
.scheduler-month-grid {
|
|
1432
|
+
display: grid;
|
|
1433
|
+
grid-template-columns: repeat(7, 1fr);
|
|
1434
|
+
grid-auto-rows: minmax(100px, 1fr);
|
|
1435
|
+
height: 100%;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
.scheduler-month-day {
|
|
1439
|
+
border-right: 1px solid var(--scheduler-border-color);
|
|
1440
|
+
border-bottom: 1px solid var(--scheduler-border-color);
|
|
1441
|
+
padding: 4px;
|
|
1442
|
+
overflow: hidden;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
.scheduler-month-day:nth-child(7n) {
|
|
1446
|
+
border-right: none;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
.scheduler-month-day.other-month {
|
|
1450
|
+
background: var(--bs-tertiary-bg);
|
|
1451
|
+
color: var(--bs-secondary-color);
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
.scheduler-month-day.today {
|
|
1455
|
+
background: var(--scheduler-today-bg);
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
.scheduler-month-day .day-number {
|
|
1459
|
+
font-weight: 500;
|
|
1460
|
+
margin-bottom: 4px;
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
.scheduler-month-day .month-events {
|
|
1464
|
+
display: flex;
|
|
1465
|
+
flex-direction: column;
|
|
1466
|
+
gap: 2px;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
.scheduler-month-event {
|
|
1470
|
+
padding: 2px 4px;
|
|
1471
|
+
border-radius: 2px;
|
|
1472
|
+
font-size: 11px;
|
|
1473
|
+
white-space: nowrap;
|
|
1474
|
+
overflow: hidden;
|
|
1475
|
+
text-overflow: ellipsis;
|
|
1476
|
+
cursor: pointer;
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
.scheduler-more-link {
|
|
1480
|
+
font-size: 11px;
|
|
1481
|
+
color: var(--bs-primary);
|
|
1482
|
+
cursor: pointer;
|
|
1483
|
+
margin-top: 2px;
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
/* Year View */
|
|
1487
|
+
.scheduler-year-grid {
|
|
1488
|
+
display: grid;
|
|
1489
|
+
grid-template-columns: repeat(4, 1fr);
|
|
1490
|
+
gap: 16px;
|
|
1491
|
+
padding: 16px;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
.scheduler-year-month {
|
|
1495
|
+
border: 1px solid var(--scheduler-border-color);
|
|
1496
|
+
border-radius: 4px;
|
|
1497
|
+
overflow: hidden;
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
.scheduler-year-month-header {
|
|
1501
|
+
padding: 8px;
|
|
1502
|
+
background: var(--scheduler-header-bg);
|
|
1503
|
+
font-weight: 600;
|
|
1504
|
+
text-align: center;
|
|
1505
|
+
cursor: pointer;
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
.scheduler-year-month-header:hover {
|
|
1509
|
+
background: var(--bs-tertiary-bg);
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
.scheduler-mini-month {
|
|
1513
|
+
display: grid;
|
|
1514
|
+
grid-template-columns: repeat(7, 1fr);
|
|
1515
|
+
gap: 1px;
|
|
1516
|
+
padding: 4px;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
.scheduler-mini-day {
|
|
1520
|
+
aspect-ratio: 1;
|
|
1521
|
+
display: flex;
|
|
1522
|
+
align-items: center;
|
|
1523
|
+
justify-content: center;
|
|
1524
|
+
font-size: 11px;
|
|
1525
|
+
cursor: pointer;
|
|
1526
|
+
border-radius: 50%;
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
.scheduler-mini-day:hover {
|
|
1530
|
+
background: var(--bs-tertiary-bg);
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
.scheduler-mini-day.has-events {
|
|
1534
|
+
font-weight: 600;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
.scheduler-mini-day.has-events::after {
|
|
1538
|
+
content: "";
|
|
1539
|
+
position: absolute;
|
|
1540
|
+
bottom: 2px;
|
|
1541
|
+
width: 4px;
|
|
1542
|
+
height: 4px;
|
|
1543
|
+
border-radius: 50%;
|
|
1544
|
+
background: var(--bs-primary);
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
.scheduler-mini-day.today {
|
|
1548
|
+
background: var(--scheduler-today-bg);
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
.scheduler-mini-day.other-month {
|
|
1552
|
+
color: var(--bs-secondary-color);
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
/* Timeline View */
|
|
1556
|
+
.scheduler-timeline {
|
|
1557
|
+
display: flex;
|
|
1558
|
+
flex-direction: column;
|
|
1559
|
+
height: 100%;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
.scheduler-timeline-header {
|
|
1563
|
+
display: flex;
|
|
1564
|
+
border-bottom: 1px solid var(--scheduler-border-color);
|
|
1565
|
+
background: var(--scheduler-header-bg);
|
|
1566
|
+
position: sticky;
|
|
1567
|
+
top: 0;
|
|
1568
|
+
z-index: 10;
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
.scheduler-resource-header {
|
|
1572
|
+
width: 200px;
|
|
1573
|
+
flex-shrink: 0;
|
|
1574
|
+
padding: 8px;
|
|
1575
|
+
border-right: 1px solid var(--scheduler-border-color);
|
|
1576
|
+
font-weight: 600;
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
.scheduler-timeline-slots-header {
|
|
1580
|
+
display: flex;
|
|
1581
|
+
flex: 1;
|
|
1582
|
+
overflow: hidden;
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
.scheduler-timeline-slot-header {
|
|
1586
|
+
flex-shrink: 0;
|
|
1587
|
+
padding: 8px;
|
|
1588
|
+
text-align: center;
|
|
1589
|
+
border-right: 1px solid var(--scheduler-border-color);
|
|
1590
|
+
font-size: 12px;
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
.scheduler-timeline-body {
|
|
1594
|
+
display: flex;
|
|
1595
|
+
flex-direction: column;
|
|
1596
|
+
flex: 1;
|
|
1597
|
+
overflow: auto;
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
.scheduler-timeline-row {
|
|
1601
|
+
display: flex;
|
|
1602
|
+
border-bottom: 1px solid var(--scheduler-border-color);
|
|
1603
|
+
min-height: 40px;
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
.scheduler-timeline-row.group {
|
|
1607
|
+
background: var(--scheduler-header-bg);
|
|
1608
|
+
font-weight: 600;
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
.scheduler-resource-cell {
|
|
1612
|
+
width: 200px;
|
|
1613
|
+
flex-shrink: 0;
|
|
1614
|
+
padding: 8px;
|
|
1615
|
+
border-right: 1px solid var(--scheduler-border-color);
|
|
1616
|
+
display: flex;
|
|
1617
|
+
align-items: center;
|
|
1618
|
+
gap: 8px;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
.scheduler-resource-cell .expand-toggle {
|
|
1622
|
+
cursor: pointer;
|
|
1623
|
+
width: 16px;
|
|
1624
|
+
height: 16px;
|
|
1625
|
+
display: flex;
|
|
1626
|
+
align-items: center;
|
|
1627
|
+
justify-content: center;
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
.scheduler-timeline-slots {
|
|
1631
|
+
display: flex;
|
|
1632
|
+
flex: 1;
|
|
1633
|
+
position: relative;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
.scheduler-timeline-slot {
|
|
1637
|
+
flex-shrink: 0;
|
|
1638
|
+
border-right: 1px solid var(--bs-border-color);
|
|
1639
|
+
height: 100%;
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
.scheduler-timeline-slot.greyed {
|
|
1643
|
+
background: var(--scheduler-greyed-slot-bg);
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
.scheduler-timeline-slot.selected {
|
|
1647
|
+
background: var(--scheduler-preview-bg);
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
.scheduler-timeline-slot:focus-visible,
|
|
1651
|
+
.scheduler-timeline-slot:focus {
|
|
1652
|
+
outline: 2px solid var(--bs-primary);
|
|
1653
|
+
outline-offset: -2px;
|
|
1654
|
+
z-index: 1;
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
.scheduler-timeline-events {
|
|
1658
|
+
position: absolute;
|
|
1659
|
+
top: 0;
|
|
1660
|
+
left: 0;
|
|
1661
|
+
right: 0;
|
|
1662
|
+
bottom: 0;
|
|
1663
|
+
pointer-events: none;
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
.scheduler-timeline-event {
|
|
1667
|
+
position: absolute;
|
|
1668
|
+
height: calc(100% - 4px);
|
|
1669
|
+
top: 2px;
|
|
1670
|
+
border-radius: var(--scheduler-event-border-radius);
|
|
1671
|
+
padding: 2px 6px;
|
|
1672
|
+
font-size: 12px;
|
|
1673
|
+
overflow: hidden;
|
|
1674
|
+
cursor: pointer;
|
|
1675
|
+
pointer-events: auto;
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
.scheduler-timeline-event.selected {
|
|
1679
|
+
box-shadow: 0 0 0 3px var(--bs-body-color);
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
/* Loading state */
|
|
1683
|
+
.scheduler-loading {
|
|
1684
|
+
display: flex;
|
|
1685
|
+
align-items: center;
|
|
1686
|
+
justify-content: center;
|
|
1687
|
+
height: 200px;
|
|
1688
|
+
color: var(--bs-secondary-color);
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
/* Empty state */
|
|
1692
|
+
.scheduler-empty {
|
|
1693
|
+
display: flex;
|
|
1694
|
+
align-items: center;
|
|
1695
|
+
justify-content: center;
|
|
1696
|
+
height: 200px;
|
|
1697
|
+
color: var(--bs-secondary-color);
|
|
1698
|
+
font-style: italic;
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
/* Touch drag mode indicator */
|
|
1702
|
+
.scheduler-container.touch-drag-mode {
|
|
1703
|
+
cursor: grabbing;
|
|
1704
|
+
user-select: none;
|
|
1705
|
+
-webkit-user-select: none;
|
|
1706
|
+
touch-action: none;
|
|
1707
|
+
-ms-touch-action: none;
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
.scheduler-container.touch-drag-mode .scheduler-content {
|
|
1711
|
+
overflow: hidden;
|
|
1712
|
+
touch-action: none;
|
|
1713
|
+
-ms-touch-action: none;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
.scheduler-event.touch-hold-pending {
|
|
1717
|
+
animation: touch-hold-pulse 0.5s ease-in-out;
|
|
1718
|
+
touch-action: none;
|
|
1719
|
+
-ms-touch-action: none;
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
.scheduler-event.touch-hold-active {
|
|
1723
|
+
transform: scale(1.02);
|
|
1724
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
1725
|
+
z-index: 100;
|
|
1726
|
+
touch-action: none;
|
|
1727
|
+
-ms-touch-action: none;
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
.scheduler-time-slot.touch-hold-pending,
|
|
1731
|
+
.scheduler-timeline-slot.touch-hold-pending {
|
|
1732
|
+
animation: touch-hold-pulse 0.5s ease-in-out;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
.scheduler-time-slot.touch-hold-active,
|
|
1736
|
+
.scheduler-timeline-slot.touch-hold-active {
|
|
1737
|
+
background: var(--scheduler-preview-bg);
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
@keyframes touch-hold-pulse {
|
|
1741
|
+
0% {
|
|
1742
|
+
opacity: 1;
|
|
1743
|
+
}
|
|
1744
|
+
50% {
|
|
1745
|
+
opacity: 0.7;
|
|
1746
|
+
}
|
|
1747
|
+
100% {
|
|
1748
|
+
opacity: 1;
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
/* Pan mode styling */
|
|
1752
|
+
.scheduler-content.pan-mode {
|
|
1753
|
+
cursor: grabbing;
|
|
1754
|
+
user-select: none;
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
/* Scroll blocking during drag operations */
|
|
1758
|
+
.scheduler-content.scroll-blocked {
|
|
1759
|
+
overflow: hidden !important;
|
|
1760
|
+
touch-action: none !important;
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
/* Scrollbar styling */
|
|
1764
|
+
.scheduler-content::-webkit-scrollbar {
|
|
1765
|
+
width: 8px;
|
|
1766
|
+
height: 8px;
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
.scheduler-content::-webkit-scrollbar-track {
|
|
1770
|
+
background: #f1f1f1;
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
.scheduler-content::-webkit-scrollbar-thumb {
|
|
1774
|
+
background: #c1c1c1;
|
|
1775
|
+
border-radius: 4px;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
.scheduler-content::-webkit-scrollbar-thumb:hover {
|
|
1779
|
+
background: #a1a1a1;
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1783
|
+
.scheduler-event,
|
|
1784
|
+
.scheduler-timeline-event {
|
|
1785
|
+
animation: none !important;
|
|
1786
|
+
transition: none !important;
|
|
1787
|
+
}
|
|
1788
|
+
}`), L = {
|
|
1789
|
+
dragThreshold: 5,
|
|
1790
|
+
minDurationMs: 1800 * 1e3
|
|
1791
|
+
// 30 minutes
|
|
1792
|
+
};
|
|
1793
|
+
class te {
|
|
1794
|
+
constructor(e = {}) {
|
|
1795
|
+
this.config = { ...L, ...e };
|
|
1796
|
+
}
|
|
1797
|
+
/**
|
|
1798
|
+
* Calculate the preview event position based on drag state.
|
|
1799
|
+
*
|
|
1800
|
+
* @param type - The type of drag operation
|
|
1801
|
+
* @param startSlot - The slot where the drag started
|
|
1802
|
+
* @param currentSlot - The current slot under the pointer
|
|
1803
|
+
* @param originalEvent - The original event being moved/resized (null for create)
|
|
1804
|
+
* @returns The preview event with new start/end, or null if invalid
|
|
1805
|
+
*/
|
|
1806
|
+
calculatePreview(e, t, s, n) {
|
|
1807
|
+
switch (e) {
|
|
1808
|
+
case "create":
|
|
1809
|
+
return this.calculateCreatePreview(t, s);
|
|
1810
|
+
case "move":
|
|
1811
|
+
return n ? this.calculateMovePreview(t, s, n) : null;
|
|
1812
|
+
case "resize-start":
|
|
1813
|
+
return n ? this.calculateResizeStartPreview(s, n) : null;
|
|
1814
|
+
case "resize-end":
|
|
1815
|
+
return n ? this.calculateResizeEndPreview(s, n) : null;
|
|
1816
|
+
default:
|
|
1817
|
+
return null;
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
/**
|
|
1821
|
+
* Calculate preview for creating a new event.
|
|
1822
|
+
* Extends selection from start slot to current slot.
|
|
1823
|
+
*/
|
|
1824
|
+
calculateCreatePreview(e, t) {
|
|
1825
|
+
const s = new Date(
|
|
1826
|
+
Math.min(e.start.getTime(), t.start.getTime())
|
|
1827
|
+
), n = new Date(
|
|
1828
|
+
Math.max(e.end.getTime(), t.end.getTime())
|
|
1829
|
+
);
|
|
1830
|
+
return { start: s, end: n };
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Calculate preview for moving an existing event.
|
|
1834
|
+
* Preserves event duration, applies offset from drag start.
|
|
1835
|
+
*/
|
|
1836
|
+
calculateMovePreview(e, t, s) {
|
|
1837
|
+
const n = t.start.getTime() - e.start.getTime(), i = s.end.getTime() - s.start.getTime(), o = new Date(s.start.getTime() + n), r = new Date(o.getTime() + i);
|
|
1838
|
+
return { start: o, end: r };
|
|
1839
|
+
}
|
|
1840
|
+
/**
|
|
1841
|
+
* Calculate preview for resizing event start.
|
|
1842
|
+
* Moves start time while keeping end fixed.
|
|
1843
|
+
* Enforces minimum duration.
|
|
1844
|
+
*/
|
|
1845
|
+
calculateResizeStartPreview(e, t) {
|
|
1846
|
+
const s = t.end.getTime() - this.config.minDurationMs;
|
|
1847
|
+
return { start: new Date(
|
|
1848
|
+
Math.min(e.start.getTime(), s)
|
|
1849
|
+
), end: t.end };
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* Calculate preview for resizing event end.
|
|
1853
|
+
* Moves end time while keeping start fixed.
|
|
1854
|
+
* Enforces minimum duration.
|
|
1855
|
+
*/
|
|
1856
|
+
calculateResizeEndPreview(e, t) {
|
|
1857
|
+
const s = t.start.getTime() + this.config.minDurationMs, n = new Date(
|
|
1858
|
+
Math.max(e.end.getTime(), s)
|
|
1859
|
+
);
|
|
1860
|
+
return { start: t.start, end: n };
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
function C(g) {
|
|
1864
|
+
return {
|
|
1865
|
+
pointerId: 0,
|
|
1866
|
+
pointerType: "mouse",
|
|
1867
|
+
clientX: g.clientX,
|
|
1868
|
+
clientY: g.clientY,
|
|
1869
|
+
originalEvent: g,
|
|
1870
|
+
target: g.target,
|
|
1871
|
+
isPrimary: !0
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
function P(g) {
|
|
1875
|
+
const e = g.touches[0] || g.changedTouches[0];
|
|
1876
|
+
return e ? {
|
|
1877
|
+
pointerId: e.identifier,
|
|
1878
|
+
pointerType: "touch",
|
|
1879
|
+
clientX: e.clientX,
|
|
1880
|
+
clientY: e.clientY,
|
|
1881
|
+
originalEvent: g,
|
|
1882
|
+
target: e.target,
|
|
1883
|
+
isPrimary: e.identifier === 0
|
|
1884
|
+
} : null;
|
|
1885
|
+
}
|
|
1886
|
+
function z(g, e) {
|
|
1887
|
+
const t = e.x - g.x, s = e.y - g.y;
|
|
1888
|
+
return Math.sqrt(t * t + s * s);
|
|
1889
|
+
}
|
|
1890
|
+
class se {
|
|
1891
|
+
constructor(e = {}) {
|
|
1892
|
+
this.state = { phase: "idle" }, this.config = { ...L, ...e }, this.previewCalculator = new te(this.config);
|
|
1893
|
+
}
|
|
1894
|
+
/**
|
|
1895
|
+
* Get current state (read-only).
|
|
1896
|
+
*/
|
|
1897
|
+
getState() {
|
|
1898
|
+
return this.state;
|
|
1899
|
+
}
|
|
1900
|
+
/**
|
|
1901
|
+
* Get the current phase.
|
|
1902
|
+
*/
|
|
1903
|
+
getPhase() {
|
|
1904
|
+
return this.state.phase;
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Check if drag is currently active.
|
|
1908
|
+
*/
|
|
1909
|
+
isActive() {
|
|
1910
|
+
return this.state.phase === "active";
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* Check if drag is pending (waiting for threshold).
|
|
1914
|
+
*/
|
|
1915
|
+
isPending() {
|
|
1916
|
+
return this.state.phase === "pending";
|
|
1917
|
+
}
|
|
1918
|
+
/**
|
|
1919
|
+
* Check if in any drag-related state (pending or active).
|
|
1920
|
+
*/
|
|
1921
|
+
isDragging() {
|
|
1922
|
+
return this.state.phase === "pending" || this.state.phase === "active";
|
|
1923
|
+
}
|
|
1924
|
+
/**
|
|
1925
|
+
* Get the preview event if in active state.
|
|
1926
|
+
*/
|
|
1927
|
+
getPreview() {
|
|
1928
|
+
return this.state.phase === "active" ? this.state.preview : null;
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Get the completion result if in completing state.
|
|
1932
|
+
*/
|
|
1933
|
+
getCompletionResult() {
|
|
1934
|
+
return this.state.phase === "completing" ? this.state.result : null;
|
|
1935
|
+
}
|
|
1936
|
+
/**
|
|
1937
|
+
* Process an event and transition to new state.
|
|
1938
|
+
* Returns true if state changed.
|
|
1939
|
+
*/
|
|
1940
|
+
send(e) {
|
|
1941
|
+
const t = this.state.phase;
|
|
1942
|
+
return this.state = this.transition(e), this.state.phase !== t;
|
|
1943
|
+
}
|
|
1944
|
+
/**
|
|
1945
|
+
* Reset to idle state.
|
|
1946
|
+
*/
|
|
1947
|
+
reset() {
|
|
1948
|
+
this.state = { phase: "idle" };
|
|
1949
|
+
}
|
|
1950
|
+
/**
|
|
1951
|
+
* Consume the completion result and return to idle.
|
|
1952
|
+
* Call this after handling a completed drag.
|
|
1953
|
+
*/
|
|
1954
|
+
consumeResult() {
|
|
1955
|
+
if (this.state.phase === "completing") {
|
|
1956
|
+
const e = this.state.result;
|
|
1957
|
+
return this.state = { phase: "idle" }, e;
|
|
1958
|
+
}
|
|
1959
|
+
return null;
|
|
1960
|
+
}
|
|
1961
|
+
/**
|
|
1962
|
+
* Pure transition function.
|
|
1963
|
+
* Given current state and event, returns new state.
|
|
1964
|
+
*/
|
|
1965
|
+
transition(e) {
|
|
1966
|
+
switch (this.state.phase) {
|
|
1967
|
+
case "idle":
|
|
1968
|
+
return this.transitionFromIdle(e);
|
|
1969
|
+
case "pending":
|
|
1970
|
+
return this.transitionFromPending(e);
|
|
1971
|
+
case "active":
|
|
1972
|
+
return this.transitionFromActive(e);
|
|
1973
|
+
case "completing":
|
|
1974
|
+
return this.transitionFromCompleting(e);
|
|
1975
|
+
default:
|
|
1976
|
+
return this.state;
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
/**
|
|
1980
|
+
* Transitions from idle state.
|
|
1981
|
+
*/
|
|
1982
|
+
transitionFromIdle(e) {
|
|
1983
|
+
if (e.type !== "POINTER_DOWN")
|
|
1984
|
+
return this.state;
|
|
1985
|
+
const { target: t, position: s, slot: n, slotElement: i, immediate: o } = e, r = this.getOperationType(t);
|
|
1986
|
+
if (!r)
|
|
1987
|
+
return this.state;
|
|
1988
|
+
const a = t.event ?? null;
|
|
1989
|
+
if (a && a.draggable === !1)
|
|
1990
|
+
return this.state;
|
|
1991
|
+
if (o) {
|
|
1992
|
+
let l = n;
|
|
1993
|
+
if (!l && a && r === "move" && (l = {
|
|
1994
|
+
start: a.start,
|
|
1995
|
+
end: a.end
|
|
1996
|
+
}), l) {
|
|
1997
|
+
const d = this.previewCalculator.calculatePreview(
|
|
1998
|
+
r,
|
|
1999
|
+
l,
|
|
2000
|
+
l,
|
|
2001
|
+
a
|
|
2002
|
+
);
|
|
2003
|
+
if (d)
|
|
2004
|
+
return {
|
|
2005
|
+
phase: "active",
|
|
2006
|
+
operationType: r,
|
|
2007
|
+
event: a,
|
|
2008
|
+
startSlot: l,
|
|
2009
|
+
currentSlot: l,
|
|
2010
|
+
preview: d,
|
|
2011
|
+
originalEvent: a ?? void 0
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
return {
|
|
2016
|
+
phase: "pending",
|
|
2017
|
+
operationType: r,
|
|
2018
|
+
event: a,
|
|
2019
|
+
startPosition: s,
|
|
2020
|
+
startSlot: n,
|
|
2021
|
+
slotElement: i
|
|
2022
|
+
};
|
|
2023
|
+
}
|
|
2024
|
+
/**
|
|
2025
|
+
* Transitions from pending state.
|
|
2026
|
+
*/
|
|
2027
|
+
transitionFromPending(e) {
|
|
2028
|
+
if (this.state.phase !== "pending") return this.state;
|
|
2029
|
+
switch (e.type) {
|
|
2030
|
+
case "POINTER_MOVE":
|
|
2031
|
+
return z(
|
|
2032
|
+
this.state.startPosition,
|
|
2033
|
+
e.position
|
|
2034
|
+
) < this.config.dragThreshold ? this.state : this.activateDrag(e.slot);
|
|
2035
|
+
case "POINTER_UP":
|
|
2036
|
+
return {
|
|
2037
|
+
phase: "completing",
|
|
2038
|
+
result: {
|
|
2039
|
+
type: this.state.operationType,
|
|
2040
|
+
preview: this.getInitialPreview(),
|
|
2041
|
+
event: this.state.event,
|
|
2042
|
+
originalEvent: this.state.event ?? void 0,
|
|
2043
|
+
wasClick: !0
|
|
2044
|
+
}
|
|
2045
|
+
};
|
|
2046
|
+
case "CANCEL":
|
|
2047
|
+
return { phase: "idle" };
|
|
2048
|
+
default:
|
|
2049
|
+
return this.state;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
/**
|
|
2053
|
+
* Transitions from active state.
|
|
2054
|
+
*/
|
|
2055
|
+
transitionFromActive(e) {
|
|
2056
|
+
if (this.state.phase !== "active") return this.state;
|
|
2057
|
+
switch (e.type) {
|
|
2058
|
+
case "POINTER_MOVE": {
|
|
2059
|
+
if (!e.slot)
|
|
2060
|
+
return this.state;
|
|
2061
|
+
const t = this.previewCalculator.calculatePreview(
|
|
2062
|
+
this.state.operationType,
|
|
2063
|
+
this.state.startSlot,
|
|
2064
|
+
e.slot,
|
|
2065
|
+
this.state.originalEvent ?? null
|
|
2066
|
+
);
|
|
2067
|
+
return t ? {
|
|
2068
|
+
...this.state,
|
|
2069
|
+
currentSlot: e.slot,
|
|
2070
|
+
preview: t
|
|
2071
|
+
} : this.state;
|
|
2072
|
+
}
|
|
2073
|
+
case "POINTER_UP":
|
|
2074
|
+
return {
|
|
2075
|
+
phase: "completing",
|
|
2076
|
+
result: {
|
|
2077
|
+
type: this.state.operationType,
|
|
2078
|
+
preview: this.state.preview,
|
|
2079
|
+
event: this.state.event,
|
|
2080
|
+
originalEvent: this.state.originalEvent,
|
|
2081
|
+
wasClick: !1
|
|
2082
|
+
}
|
|
2083
|
+
};
|
|
2084
|
+
case "CANCEL":
|
|
2085
|
+
return { phase: "idle" };
|
|
2086
|
+
default:
|
|
2087
|
+
return this.state;
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
/**
|
|
2091
|
+
* Transitions from completing state.
|
|
2092
|
+
*/
|
|
2093
|
+
transitionFromCompleting(e) {
|
|
2094
|
+
return e.type === "CANCEL" || e.type === "POINTER_DOWN" ? { phase: "idle" } : this.state;
|
|
2095
|
+
}
|
|
2096
|
+
/**
|
|
2097
|
+
* Activate drag from pending state.
|
|
2098
|
+
*/
|
|
2099
|
+
activateDrag(e) {
|
|
2100
|
+
if (this.state.phase !== "pending")
|
|
2101
|
+
return this.state;
|
|
2102
|
+
const t = this.state.startSlot ?? e;
|
|
2103
|
+
if (!t)
|
|
2104
|
+
return { phase: "idle" };
|
|
2105
|
+
const s = e ?? t, n = this.previewCalculator.calculatePreview(
|
|
2106
|
+
this.state.operationType,
|
|
2107
|
+
t,
|
|
2108
|
+
s,
|
|
2109
|
+
this.state.event
|
|
2110
|
+
);
|
|
2111
|
+
return n ? {
|
|
2112
|
+
phase: "active",
|
|
2113
|
+
operationType: this.state.operationType,
|
|
2114
|
+
event: this.state.event,
|
|
2115
|
+
startSlot: t,
|
|
2116
|
+
currentSlot: s,
|
|
2117
|
+
preview: n,
|
|
2118
|
+
originalEvent: this.state.event ?? void 0
|
|
2119
|
+
} : { phase: "idle" };
|
|
2120
|
+
}
|
|
2121
|
+
/**
|
|
2122
|
+
* Get operation type from pointer target.
|
|
2123
|
+
*/
|
|
2124
|
+
getOperationType(e) {
|
|
2125
|
+
switch (e.type) {
|
|
2126
|
+
case "resize-handle":
|
|
2127
|
+
return e.resizeHandle === "start" ? "resize-start" : "resize-end";
|
|
2128
|
+
case "event":
|
|
2129
|
+
return "move";
|
|
2130
|
+
case "slot":
|
|
2131
|
+
return "create";
|
|
2132
|
+
default:
|
|
2133
|
+
return null;
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
/**
|
|
2137
|
+
* Get initial preview for a pending drag (used for click detection).
|
|
2138
|
+
*/
|
|
2139
|
+
getInitialPreview() {
|
|
2140
|
+
return this.state.phase !== "pending" ? { start: /* @__PURE__ */ new Date(), end: /* @__PURE__ */ new Date() } : this.state.event ? {
|
|
2141
|
+
start: this.state.event.start,
|
|
2142
|
+
end: this.state.event.end
|
|
2143
|
+
} : this.state.startSlot ? {
|
|
2144
|
+
start: this.state.startSlot.start,
|
|
2145
|
+
end: this.state.startSlot.end
|
|
2146
|
+
} : { start: /* @__PURE__ */ new Date(), end: /* @__PURE__ */ new Date() };
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
class ne {
|
|
2150
|
+
constructor(e, t = {}) {
|
|
2151
|
+
this.pendingUpdate = null, this.latestPointer = null, this.getSlotAtPosition = null, this.stateManager = e, this.config = { ...L, ...t }, this.stateMachine = new se(this.config);
|
|
2152
|
+
}
|
|
2153
|
+
/**
|
|
2154
|
+
* Set the function used to get a slot at a position.
|
|
2155
|
+
* This must be set before handling pointer events.
|
|
2156
|
+
*/
|
|
2157
|
+
setSlotResolver(e) {
|
|
2158
|
+
this.getSlotAtPosition = e;
|
|
2159
|
+
}
|
|
2160
|
+
/**
|
|
2161
|
+
* Handle pointer down - may start pending drag.
|
|
2162
|
+
* @param immediate If true, skip pending state (for touch-initiated drags)
|
|
2163
|
+
*/
|
|
2164
|
+
handlePointerDown(e, t, s = !1) {
|
|
2165
|
+
const n = this.getSlotAtPosition?.(e.clientX, e.clientY) ?? null;
|
|
2166
|
+
this.stateMachine.send({
|
|
2167
|
+
type: "POINTER_DOWN",
|
|
2168
|
+
target: t,
|
|
2169
|
+
position: { x: e.clientX, y: e.clientY },
|
|
2170
|
+
slot: n,
|
|
2171
|
+
slotElement: t.slotElement,
|
|
2172
|
+
immediate: s
|
|
2173
|
+
}), this.stateMachine.isActive() && this.syncToStateManager();
|
|
2174
|
+
}
|
|
2175
|
+
/**
|
|
2176
|
+
* Handle pointer move - may activate drag or update preview.
|
|
2177
|
+
*/
|
|
2178
|
+
handlePointerMove(e) {
|
|
2179
|
+
this.stateMachine.isDragging() && (this.latestPointer = e, this.pendingUpdate === null && (this.pendingUpdate = requestAnimationFrame(() => {
|
|
2180
|
+
this.processPendingMove();
|
|
2181
|
+
})));
|
|
2182
|
+
}
|
|
2183
|
+
/**
|
|
2184
|
+
* Handle pointer up - finalize or cancel drag.
|
|
2185
|
+
* Returns the completion result if a drag was completed.
|
|
2186
|
+
*/
|
|
2187
|
+
handlePointerUp(e) {
|
|
2188
|
+
this.cancelPendingUpdate(), this.stateMachine.send({
|
|
2189
|
+
type: "POINTER_UP",
|
|
2190
|
+
position: { x: e.clientX, y: e.clientY }
|
|
2191
|
+
});
|
|
2192
|
+
const t = this.stateMachine.consumeResult();
|
|
2193
|
+
return this.stateManager.endDrag(), t;
|
|
2194
|
+
}
|
|
2195
|
+
/**
|
|
2196
|
+
* Cancel any in-progress drag operation.
|
|
2197
|
+
*/
|
|
2198
|
+
cancel() {
|
|
2199
|
+
this.cancelPendingUpdate(), this.stateMachine.send({ type: "CANCEL" }), this.stateManager.endDrag();
|
|
2200
|
+
}
|
|
2201
|
+
/**
|
|
2202
|
+
* Check if a drag operation is in progress.
|
|
2203
|
+
*/
|
|
2204
|
+
isActive() {
|
|
2205
|
+
return this.stateMachine.isActive();
|
|
2206
|
+
}
|
|
2207
|
+
/**
|
|
2208
|
+
* Check if waiting for drag threshold.
|
|
2209
|
+
*/
|
|
2210
|
+
isPending() {
|
|
2211
|
+
return this.stateMachine.isPending();
|
|
2212
|
+
}
|
|
2213
|
+
/**
|
|
2214
|
+
* Check if in any drag-related state.
|
|
2215
|
+
*/
|
|
2216
|
+
isDragging() {
|
|
2217
|
+
return this.stateMachine.isDragging();
|
|
2218
|
+
}
|
|
2219
|
+
/**
|
|
2220
|
+
* Get the current drag phase.
|
|
2221
|
+
*/
|
|
2222
|
+
getPhase() {
|
|
2223
|
+
return this.stateMachine.getPhase();
|
|
2224
|
+
}
|
|
2225
|
+
/**
|
|
2226
|
+
* Reset the drag manager state.
|
|
2227
|
+
*/
|
|
2228
|
+
reset() {
|
|
2229
|
+
this.cancelPendingUpdate(), this.stateMachine.reset();
|
|
2230
|
+
}
|
|
2231
|
+
/**
|
|
2232
|
+
* Clean up resources.
|
|
2233
|
+
*/
|
|
2234
|
+
destroy() {
|
|
2235
|
+
this.cancelPendingUpdate(), this.latestPointer = null, this.getSlotAtPosition = null;
|
|
2236
|
+
}
|
|
2237
|
+
/**
|
|
2238
|
+
* Create a new event from a completed create drag.
|
|
2239
|
+
*/
|
|
2240
|
+
createEventFromResult(e) {
|
|
2241
|
+
return {
|
|
2242
|
+
id: V(),
|
|
2243
|
+
title: "New Event",
|
|
2244
|
+
start: e.preview.start,
|
|
2245
|
+
end: e.preview.end,
|
|
2246
|
+
color: "#3788d8"
|
|
2247
|
+
};
|
|
2248
|
+
}
|
|
2249
|
+
/**
|
|
2250
|
+
* Update an event from a completed move/resize drag.
|
|
2251
|
+
*/
|
|
2252
|
+
updateEventFromResult(e, t) {
|
|
2253
|
+
return {
|
|
2254
|
+
...t,
|
|
2255
|
+
start: e.preview.start,
|
|
2256
|
+
end: e.preview.end
|
|
2257
|
+
};
|
|
2258
|
+
}
|
|
2259
|
+
/**
|
|
2260
|
+
* Process pending pointer move using RAF.
|
|
2261
|
+
*/
|
|
2262
|
+
processPendingMove() {
|
|
2263
|
+
this.pendingUpdate = null;
|
|
2264
|
+
const e = this.latestPointer;
|
|
2265
|
+
if (this.latestPointer = null, !e || !this.stateMachine.isDragging())
|
|
2266
|
+
return;
|
|
2267
|
+
const t = this.getSlotAtPosition?.(e.clientX, e.clientY) ?? null;
|
|
2268
|
+
(this.stateMachine.send({
|
|
2269
|
+
type: "POINTER_MOVE",
|
|
2270
|
+
position: { x: e.clientX, y: e.clientY },
|
|
2271
|
+
slot: t
|
|
2272
|
+
}) || this.stateMachine.isActive()) && this.syncToStateManager();
|
|
2273
|
+
}
|
|
2274
|
+
/**
|
|
2275
|
+
* Sync state machine state to scheduler state manager.
|
|
2276
|
+
*/
|
|
2277
|
+
syncToStateManager() {
|
|
2278
|
+
const e = this.stateMachine.getState();
|
|
2279
|
+
e.phase === "active" && (this.stateManager.getState().dragState ? this.stateManager.updateDrag(e.currentSlot, e.preview) : this.stateManager.startDrag({
|
|
2280
|
+
type: e.operationType,
|
|
2281
|
+
event: e.event,
|
|
2282
|
+
startSlot: e.startSlot,
|
|
2283
|
+
currentSlot: e.currentSlot,
|
|
2284
|
+
preview: e.preview,
|
|
2285
|
+
originalEvent: e.originalEvent
|
|
2286
|
+
}));
|
|
2287
|
+
}
|
|
2288
|
+
/**
|
|
2289
|
+
* Cancel any pending RAF update.
|
|
2290
|
+
*/
|
|
2291
|
+
cancelPendingUpdate() {
|
|
2292
|
+
this.pendingUpdate !== null && (cancelAnimationFrame(this.pendingUpdate), this.pendingUpdate = null), this.latestPointer = null;
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
const ie = 600, oe = 10;
|
|
2296
|
+
class re {
|
|
2297
|
+
constructor(e, t) {
|
|
2298
|
+
this.touchHoldTimer = null, this.touchStartPosition = null, this.isTouchDragMode = !1, this.touchHoldTarget = null, this.touchHoldPointer = null, this.isPanMode = !1, this.panStartPosition = null, this.panStartScroll = null, this.panStartedOnEvent = !1, this.savedBodyStyles = null, this.config = e, this.callbacks = t, this.boundHandleMouseDown = this.handleMouseDown.bind(this), this.boundHandleMouseMove = this.handleMouseMove.bind(this), this.boundHandleMouseUp = this.handleMouseUp.bind(this), this.boundHandleClick = this.handleClick.bind(this), this.boundHandleDblClick = this.handleDblClick.bind(this), this.boundHandleTouchStart = this.handleTouchStart.bind(this), this.boundHandleTouchMove = this.handleTouchMove.bind(this), this.boundHandleTouchEnd = this.handleTouchEnd.bind(this), this.boundHandleTouchCancel = this.handleTouchCancel.bind(this);
|
|
2299
|
+
}
|
|
2300
|
+
/**
|
|
2301
|
+
* Attach all event listeners.
|
|
2302
|
+
*/
|
|
2303
|
+
attach() {
|
|
2304
|
+
const e = this.config.shadowRoot;
|
|
2305
|
+
e.addEventListener("mousedown", this.boundHandleMouseDown), document.addEventListener("mousemove", this.boundHandleMouseMove), document.addEventListener("mouseup", this.boundHandleMouseUp), e.addEventListener("click", this.boundHandleClick), e.addEventListener("dblclick", this.boundHandleDblClick), e.addEventListener("touchstart", this.boundHandleTouchStart, {
|
|
2306
|
+
passive: !1
|
|
2307
|
+
}), e.addEventListener("touchmove", this.boundHandleTouchMove, {
|
|
2308
|
+
passive: !1
|
|
2309
|
+
}), e.addEventListener("touchend", this.boundHandleTouchEnd), e.addEventListener("touchcancel", this.boundHandleTouchCancel);
|
|
2310
|
+
}
|
|
2311
|
+
/**
|
|
2312
|
+
* Detach all event listeners.
|
|
2313
|
+
*/
|
|
2314
|
+
detach() {
|
|
2315
|
+
const e = this.config.shadowRoot;
|
|
2316
|
+
e.removeEventListener("mousedown", this.boundHandleMouseDown), document.removeEventListener("mousemove", this.boundHandleMouseMove), document.removeEventListener("mouseup", this.boundHandleMouseUp), e.removeEventListener("click", this.boundHandleClick), e.removeEventListener("dblclick", this.boundHandleDblClick), e.removeEventListener("touchstart", this.boundHandleTouchStart), e.removeEventListener("touchmove", this.boundHandleTouchMove), e.removeEventListener("touchend", this.boundHandleTouchEnd), e.removeEventListener("touchcancel", this.boundHandleTouchCancel), this.cancelTouchHold(), this.exitPanMode(), this.removeScrollBlock();
|
|
2317
|
+
}
|
|
2318
|
+
/**
|
|
2319
|
+
* Check if in touch drag mode.
|
|
2320
|
+
*/
|
|
2321
|
+
isInTouchDragMode() {
|
|
2322
|
+
return this.isTouchDragMode;
|
|
2323
|
+
}
|
|
2324
|
+
/**
|
|
2325
|
+
* Analyze pointer target to determine what was clicked.
|
|
2326
|
+
*/
|
|
2327
|
+
analyzeTarget(e) {
|
|
2328
|
+
const t = e.closest(".resize-handle");
|
|
2329
|
+
if (t) {
|
|
2330
|
+
const o = t.closest(".scheduler-event")?.dataset.eventId, r = o ? this.config.getEventById(o) : null;
|
|
2331
|
+
if (r)
|
|
2332
|
+
return {
|
|
2333
|
+
type: "resize-handle",
|
|
2334
|
+
event: r,
|
|
2335
|
+
resizeHandle: t.dataset.handle
|
|
2336
|
+
};
|
|
2337
|
+
}
|
|
2338
|
+
const s = e.closest(".scheduler-event:not(.preview)");
|
|
2339
|
+
if (s) {
|
|
2340
|
+
const i = s.dataset.eventId, o = i ? this.config.getEventById(i) : null;
|
|
2341
|
+
if (o)
|
|
2342
|
+
return { type: "event", event: o };
|
|
2343
|
+
}
|
|
2344
|
+
const n = e.closest(
|
|
2345
|
+
".scheduler-time-slot, .scheduler-timeline-slot"
|
|
2346
|
+
);
|
|
2347
|
+
return n ? { type: "slot", slotElement: n } : { type: "none" };
|
|
2348
|
+
}
|
|
2349
|
+
// Mouse event handlers
|
|
2350
|
+
handleMouseDown(e) {
|
|
2351
|
+
if (!this.config.isEditable()) return;
|
|
2352
|
+
const t = C(e), s = this.analyzeTarget(t.target);
|
|
2353
|
+
s.type !== "none" && (s.type === "slot" && !this.config.isSelectable() || (e.preventDefault(), this.callbacks.onPointerDown(t, s)));
|
|
2354
|
+
}
|
|
2355
|
+
handleMouseMove(e) {
|
|
2356
|
+
const t = C(e);
|
|
2357
|
+
this.callbacks.onPointerMove(t);
|
|
2358
|
+
}
|
|
2359
|
+
handleMouseUp(e) {
|
|
2360
|
+
const t = C(e);
|
|
2361
|
+
this.callbacks.onPointerUp(t);
|
|
2362
|
+
}
|
|
2363
|
+
handleClick(e) {
|
|
2364
|
+
const t = C(e), s = this.analyzeTarget(t.target);
|
|
2365
|
+
s.type === "event" || s.type === "resize-handle" || this.callbacks.onClick(t, s);
|
|
2366
|
+
}
|
|
2367
|
+
handleDblClick(e) {
|
|
2368
|
+
const t = C(e), s = this.analyzeTarget(t.target);
|
|
2369
|
+
this.callbacks.onDoubleClick(t, s);
|
|
2370
|
+
}
|
|
2371
|
+
// Touch event handlers
|
|
2372
|
+
handleTouchStart(e) {
|
|
2373
|
+
if (!this.config.isEditable()) return;
|
|
2374
|
+
if (e.touches.length !== 1) {
|
|
2375
|
+
this.cancelTouchHold();
|
|
2376
|
+
return;
|
|
2377
|
+
}
|
|
2378
|
+
const t = P(e);
|
|
2379
|
+
if (!t) return;
|
|
2380
|
+
const s = this.analyzeTarget(t.target);
|
|
2381
|
+
if (s.type === "none" || s.type === "slot" && !this.config.isSelectable()) return;
|
|
2382
|
+
this.touchStartPosition = { x: t.clientX, y: t.clientY }, this.touchHoldTarget = t.target, this.touchHoldPointer = t, this.panStartedOnEvent = s.type === "event" || s.type === "resize-handle";
|
|
2383
|
+
const n = this, i = e.target;
|
|
2384
|
+
i.addEventListener("touchmove", function(r) {
|
|
2385
|
+
n.handleTouchMove(r);
|
|
2386
|
+
}, { passive: !1 }), i.addEventListener("touchend", function(r) {
|
|
2387
|
+
n.handleTouchEnd(r);
|
|
2388
|
+
}), i.addEventListener("touchcancel", function(r) {
|
|
2389
|
+
n.handleTouchCancel(r);
|
|
2390
|
+
}), this.addTouchFeedback(t.target, "pending");
|
|
2391
|
+
const o = this.config.touchHoldDuration ?? ie;
|
|
2392
|
+
this.touchHoldTimer = setTimeout(() => {
|
|
2393
|
+
this.activateTouchDragMode(t, s);
|
|
2394
|
+
}, o);
|
|
2395
|
+
}
|
|
2396
|
+
handleTouchMove(e) {
|
|
2397
|
+
if (e.touches.length !== 1) {
|
|
2398
|
+
this.cancelTouchHold(), this.exitPanMode();
|
|
2399
|
+
return;
|
|
2400
|
+
}
|
|
2401
|
+
const t = P(e);
|
|
2402
|
+
if (t) {
|
|
2403
|
+
if (this.isPanMode) {
|
|
2404
|
+
e.preventDefault(), this.performPan(t.clientX, t.clientY);
|
|
2405
|
+
return;
|
|
2406
|
+
}
|
|
2407
|
+
if (this.touchHoldTimer && this.touchStartPosition) {
|
|
2408
|
+
const s = this.config.touchMoveThreshold ?? oe;
|
|
2409
|
+
if (z(this.touchStartPosition, {
|
|
2410
|
+
x: t.clientX,
|
|
2411
|
+
y: t.clientY
|
|
2412
|
+
}) > s) {
|
|
2413
|
+
this.cancelTouchHold(), this.panStartedOnEvent && (this.enterPanMode(t.clientX, t.clientY), e.preventDefault());
|
|
2414
|
+
return;
|
|
2415
|
+
}
|
|
2416
|
+
e.preventDefault();
|
|
2417
|
+
return;
|
|
2418
|
+
}
|
|
2419
|
+
this.isTouchDragMode && (e.preventDefault(), this.callbacks.onPointerMove(t));
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
handleTouchEnd(e) {
|
|
2423
|
+
const t = P(e);
|
|
2424
|
+
if (this.isPanMode) {
|
|
2425
|
+
this.exitPanMode();
|
|
2426
|
+
return;
|
|
2427
|
+
}
|
|
2428
|
+
if (this.touchHoldTimer) {
|
|
2429
|
+
if (this.cancelTouchHold(), t && this.touchHoldTarget) {
|
|
2430
|
+
const s = this.analyzeTarget(this.touchHoldTarget);
|
|
2431
|
+
this.callbacks.onClick(t, s);
|
|
2432
|
+
}
|
|
2433
|
+
this.touchHoldTarget = null, this.touchHoldPointer = null;
|
|
2434
|
+
return;
|
|
2435
|
+
}
|
|
2436
|
+
this.isTouchDragMode && t && (this.callbacks.onPointerUp(t), this.exitTouchDragMode());
|
|
2437
|
+
}
|
|
2438
|
+
handleTouchCancel(e) {
|
|
2439
|
+
this.cancelTouchHold(), this.exitPanMode(), this.isTouchDragMode && (this.touchStartPosition && this.callbacks.onPointerUp({
|
|
2440
|
+
pointerId: 0,
|
|
2441
|
+
pointerType: "touch",
|
|
2442
|
+
clientX: this.touchStartPosition.x,
|
|
2443
|
+
clientY: this.touchStartPosition.y,
|
|
2444
|
+
originalEvent: e,
|
|
2445
|
+
target: this.touchHoldTarget ?? document.body,
|
|
2446
|
+
isPrimary: !0
|
|
2447
|
+
}), this.exitTouchDragMode());
|
|
2448
|
+
}
|
|
2449
|
+
// Touch helpers
|
|
2450
|
+
activateTouchDragMode(e, t) {
|
|
2451
|
+
this.touchHoldTimer = null, this.touchStartPosition = null, this.triggerHapticFeedback(), this.isTouchDragMode = !0, this.touchHoldTarget?.closest(".scheduler-event") || (document.addEventListener("touchmove", this.boundHandleTouchMove, { passive: !1 }), document.addEventListener("touchend", this.boundHandleTouchEnd), document.addEventListener("touchcancel", this.boundHandleTouchCancel)), this.touchHoldTarget && (this.removeTouchFeedback(this.touchHoldTarget, "pending"), this.addTouchFeedback(this.touchHoldTarget, "active")), this.config.shadowRoot.querySelector(".scheduler-container")?.classList.add("touch-drag-mode"), this.applyScrollBlock(), this.callbacks.onTouchDragActivated?.(), this.callbacks.onPointerDown(e, t, !0);
|
|
2452
|
+
}
|
|
2453
|
+
cancelTouchHold() {
|
|
2454
|
+
this.touchHoldTimer && (clearTimeout(this.touchHoldTimer), this.touchHoldTimer = null), document.removeEventListener("touchmove", this.boundHandleTouchMove), document.removeEventListener("touchend", this.boundHandleTouchEnd), document.removeEventListener("touchcancel", this.boundHandleTouchCancel), this.touchHoldTarget && (this.removeTouchFeedback(this.touchHoldTarget, "pending"), this.removeTouchFeedback(this.touchHoldTarget, "active"));
|
|
2455
|
+
}
|
|
2456
|
+
exitTouchDragMode() {
|
|
2457
|
+
this.isTouchDragMode = !1, this.touchStartPosition = null, this.touchHoldTarget = null, this.touchHoldPointer = null, document.removeEventListener("touchmove", this.boundHandleTouchMove), document.removeEventListener("touchend", this.boundHandleTouchEnd), document.removeEventListener("touchcancel", this.boundHandleTouchCancel), this.config.shadowRoot.querySelector(".scheduler-container")?.classList.remove("touch-drag-mode"), this.removeScrollBlock(), this.config.shadowRoot.querySelectorAll(".touch-hold-active, .touch-hold-pending").forEach((t) => {
|
|
2458
|
+
t.classList.remove("touch-hold-active", "touch-hold-pending");
|
|
2459
|
+
}), this.callbacks.onTouchDragDeactivated?.();
|
|
2460
|
+
}
|
|
2461
|
+
addTouchFeedback(e, t) {
|
|
2462
|
+
e.closest(
|
|
2463
|
+
".scheduler-event, .scheduler-time-slot, .scheduler-timeline-slot"
|
|
2464
|
+
)?.classList.add(`touch-hold-${t}`);
|
|
2465
|
+
}
|
|
2466
|
+
removeTouchFeedback(e, t) {
|
|
2467
|
+
e.closest(
|
|
2468
|
+
".scheduler-event, .scheduler-time-slot, .scheduler-timeline-slot"
|
|
2469
|
+
)?.classList.remove(`touch-hold-${t}`);
|
|
2470
|
+
}
|
|
2471
|
+
triggerHapticFeedback() {
|
|
2472
|
+
}
|
|
2473
|
+
// Pan helpers (touch-only: pan is never initiated from a mouse gesture)
|
|
2474
|
+
enterPanMode(e, t) {
|
|
2475
|
+
const s = this.callbacks.getScrollContainer?.();
|
|
2476
|
+
s && (this.isPanMode = !0, this.panStartPosition = { x: e, y: t }, this.panStartScroll = { left: s.scrollLeft, top: s.scrollTop }, s.classList.add("pan-mode"), this.touchHoldTarget && (this.removeTouchFeedback(this.touchHoldTarget, "pending"), this.removeTouchFeedback(this.touchHoldTarget, "active")));
|
|
2477
|
+
}
|
|
2478
|
+
exitPanMode() {
|
|
2479
|
+
if (!this.isPanMode) return;
|
|
2480
|
+
this.isPanMode = !1, this.panStartPosition = null, this.panStartScroll = null, this.panStartedOnEvent = !1, this.touchStartPosition = null, this.touchHoldTarget = null, this.callbacks.getScrollContainer?.()?.classList.remove("pan-mode");
|
|
2481
|
+
}
|
|
2482
|
+
performPan(e, t) {
|
|
2483
|
+
if (!this.isPanMode || !this.panStartPosition || !this.panStartScroll) return;
|
|
2484
|
+
const s = this.callbacks.getScrollContainer?.();
|
|
2485
|
+
if (!s) return;
|
|
2486
|
+
const n = this.panStartPosition.x - e, i = this.panStartPosition.y - t;
|
|
2487
|
+
s.scrollLeft = this.panStartScroll.left + n, s.scrollTop = this.panStartScroll.top + i;
|
|
2488
|
+
}
|
|
2489
|
+
// Scroll blocking helpers
|
|
2490
|
+
applyScrollBlock() {
|
|
2491
|
+
this.savedBodyStyles = {
|
|
2492
|
+
overflow: document.body.style.overflow,
|
|
2493
|
+
touchAction: document.body.style.touchAction
|
|
2494
|
+
}, document.body.style.overflow = "hidden", document.body.style.touchAction = "none";
|
|
2495
|
+
const e = this.callbacks.getScrollContainer?.();
|
|
2496
|
+
e && e.classList.add("scroll-blocked");
|
|
2497
|
+
}
|
|
2498
|
+
removeScrollBlock() {
|
|
2499
|
+
this.savedBodyStyles && (document.body.style.overflow = this.savedBodyStyles.overflow, document.body.style.touchAction = this.savedBodyStyles.touchAction, this.savedBodyStyles = null);
|
|
2500
|
+
const e = this.callbacks.getScrollContainer?.();
|
|
2501
|
+
e && e.classList.remove("scroll-blocked");
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
class ae {
|
|
2505
|
+
constructor(e) {
|
|
2506
|
+
this.host = e;
|
|
2507
|
+
}
|
|
2508
|
+
/**
|
|
2509
|
+
* Emit a scheduler custom event.
|
|
2510
|
+
* The event will bubble up through the DOM.
|
|
2511
|
+
*/
|
|
2512
|
+
emit(e) {
|
|
2513
|
+
const { type: t, ...s } = e;
|
|
2514
|
+
this.host.dispatchEvent(
|
|
2515
|
+
new CustomEvent(t, {
|
|
2516
|
+
detail: s,
|
|
2517
|
+
bubbles: !0
|
|
2518
|
+
})
|
|
2519
|
+
);
|
|
2520
|
+
}
|
|
2521
|
+
/**
|
|
2522
|
+
* Emit an event-selected event. Fired both by mouse click and by keyboard
|
|
2523
|
+
* Tab landing on an event (mouse-parity, PRD scheduler-keyboard-grid-nav D3).
|
|
2524
|
+
*/
|
|
2525
|
+
emitEventSelected(e, t) {
|
|
2526
|
+
this.emit({ type: "event-selected", event: e, originalEvent: t });
|
|
2527
|
+
}
|
|
2528
|
+
/**
|
|
2529
|
+
* Emit an event-dblclick event.
|
|
2530
|
+
*/
|
|
2531
|
+
emitEventDblClick(e, t) {
|
|
2532
|
+
this.emit({ type: "event-dblclick", event: e, originalEvent: t });
|
|
2533
|
+
}
|
|
2534
|
+
/**
|
|
2535
|
+
* Emit an `event-create` *request*. Per PRD scheduler-controlled-selection,
|
|
2536
|
+
* the scheduler does not mutate its internal events list — the consumer
|
|
2537
|
+
* receives the range and decides whether to construct an event from it.
|
|
2538
|
+
*/
|
|
2539
|
+
emitEventCreate(e, t, s, n) {
|
|
2540
|
+
this.emit({ type: "event-create", range: e, view: t, resourceId: n, originalEvent: s });
|
|
2541
|
+
}
|
|
2542
|
+
/**
|
|
2543
|
+
* Emit an event-update event.
|
|
2544
|
+
*/
|
|
2545
|
+
emitEventUpdate(e, t, s) {
|
|
2546
|
+
this.emit({ type: "event-update", event: e, oldEvent: t, originalEvent: s });
|
|
2547
|
+
}
|
|
2548
|
+
/**
|
|
2549
|
+
* Emit an event-delete event.
|
|
2550
|
+
*/
|
|
2551
|
+
emitEventDelete(e) {
|
|
2552
|
+
this.emit({ type: "event-delete", event: e });
|
|
2553
|
+
}
|
|
2554
|
+
/**
|
|
2555
|
+
* Emit a date-click event.
|
|
2556
|
+
*/
|
|
2557
|
+
emitDateClick(e, t) {
|
|
2558
|
+
this.emit({ type: "date-click", date: e, originalEvent: t });
|
|
2559
|
+
}
|
|
2560
|
+
/**
|
|
2561
|
+
* Emit a view-change event.
|
|
2562
|
+
*/
|
|
2563
|
+
emitViewChange(e, t) {
|
|
2564
|
+
this.emit({ type: "view-change", view: e, date: t });
|
|
2565
|
+
}
|
|
2566
|
+
/**
|
|
2567
|
+
* Emit a selection-change event. Carries both the single-event focus and
|
|
2568
|
+
* the time-range selection — either may be null. Fires on every transition
|
|
2569
|
+
* so consumers can react to the selection clearing without polling.
|
|
2570
|
+
*/
|
|
2571
|
+
emitSelectionChange(e, t, s, n) {
|
|
2572
|
+
this.emit({ type: "selection-change", selectedEvent: e, range: t, view: s, resourceId: n });
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
class le extends B {
|
|
2576
|
+
constructor() {
|
|
2577
|
+
super(), this.currentView = null, this.currentViewType = null, this.contentContainer = null, this.inputHandler = null, this.previousView = null, this.previousDate = null, this.previousSelectedEventId = null, this.previousRangeKey = "__init__", this.pendingDragUpdate = null, this.latestDragState = null, this.nowIndicatorTimer = null, this.liveAnnouncer = new O(this), this.keyboardMove = null, this.stateManager = new Y(), this.eventEmitter = new ae(this), this.dragManager = new ne(this.stateManager), this.dragManager.setSlotResolver((e, t) => this.getSlotAtPosition(e, t)), this.boundHandleKeyDown = this.handleKeyDown.bind(this), this.boundHandleFocusIn = this.handleFocusIn.bind(this), this.stateManager.subscribe((e) => this.onStateChange(e));
|
|
2578
|
+
}
|
|
2579
|
+
static {
|
|
2580
|
+
this.styles = [ee];
|
|
2581
|
+
}
|
|
2582
|
+
static get observedAttributes() {
|
|
2583
|
+
return [
|
|
2584
|
+
...super.observedAttributes ?? [],
|
|
2585
|
+
"view",
|
|
2586
|
+
"date",
|
|
2587
|
+
"locale",
|
|
2588
|
+
"first-day-of-week",
|
|
2589
|
+
"slot-duration",
|
|
2590
|
+
"time-format",
|
|
2591
|
+
"editable",
|
|
2592
|
+
"selectable"
|
|
2593
|
+
];
|
|
2594
|
+
}
|
|
2595
|
+
connectedCallback() {
|
|
2596
|
+
super.connectedCallback(), this.inputHandler && this.inputHandler.attach(), this.addEventListener("keydown", this.boundHandleKeyDown), this.startNowIndicatorTimer();
|
|
2597
|
+
}
|
|
2598
|
+
disconnectedCallback() {
|
|
2599
|
+
this.inputHandler?.detach(), this.removeEventListener("keydown", this.boundHandleKeyDown), this.shadowRoot?.removeEventListener("focusin", this.boundHandleFocusIn), this.currentView?.destroy(), this.dragManager.destroy(), this.stopNowIndicatorTimer(), this.pendingDragUpdate !== null && (cancelAnimationFrame(this.pendingDragUpdate), this.pendingDragUpdate = null), this.latestDragState = null, super.disconnectedCallback();
|
|
2600
|
+
}
|
|
2601
|
+
attributeChangedCallback(e, t, s) {
|
|
2602
|
+
if (super.attributeChangedCallback(e, t, s), t !== s)
|
|
2603
|
+
switch (e) {
|
|
2604
|
+
case "view":
|
|
2605
|
+
s && ["year", "month", "week", "day", "timeline"].includes(s) && this.stateManager.setView(s);
|
|
2606
|
+
break;
|
|
2607
|
+
case "date":
|
|
2608
|
+
s && this.stateManager.setDate(new Date(s));
|
|
2609
|
+
break;
|
|
2610
|
+
case "locale":
|
|
2611
|
+
s && this.stateManager.setOptions({ locale: s });
|
|
2612
|
+
break;
|
|
2613
|
+
case "first-day-of-week":
|
|
2614
|
+
if (s) {
|
|
2615
|
+
const n = parseInt(s, 10);
|
|
2616
|
+
n >= 0 && n <= 6 && this.stateManager.setOptions({
|
|
2617
|
+
firstDayOfWeek: n
|
|
2618
|
+
});
|
|
2619
|
+
}
|
|
2620
|
+
break;
|
|
2621
|
+
case "slot-duration":
|
|
2622
|
+
s && this.stateManager.setOptions({ slotDuration: parseInt(s, 10) });
|
|
2623
|
+
break;
|
|
2624
|
+
case "time-format":
|
|
2625
|
+
s && (s === "12h" || s === "24h") && this.stateManager.setOptions({ timeFormat: s });
|
|
2626
|
+
break;
|
|
2627
|
+
case "editable":
|
|
2628
|
+
this.stateManager.setOptions({ editable: s !== "false" });
|
|
2629
|
+
break;
|
|
2630
|
+
case "selectable":
|
|
2631
|
+
this.stateManager.setOptions({ selectable: s !== "false" });
|
|
2632
|
+
break;
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2635
|
+
// ============================================
|
|
2636
|
+
// Public API
|
|
2637
|
+
// ============================================
|
|
2638
|
+
get view() {
|
|
2639
|
+
return this.stateManager.getState().view;
|
|
2640
|
+
}
|
|
2641
|
+
set view(e) {
|
|
2642
|
+
this.stateManager.setView(e);
|
|
2643
|
+
}
|
|
2644
|
+
get date() {
|
|
2645
|
+
return this.stateManager.getState().date;
|
|
2646
|
+
}
|
|
2647
|
+
set date(e) {
|
|
2648
|
+
this.stateManager.setDate(e);
|
|
2649
|
+
}
|
|
2650
|
+
get events() {
|
|
2651
|
+
return this.stateManager.getState().events;
|
|
2652
|
+
}
|
|
2653
|
+
set events(e) {
|
|
2654
|
+
this.stateManager.setEvents(e);
|
|
2655
|
+
}
|
|
2656
|
+
get resources() {
|
|
2657
|
+
return this.stateManager.getState().resources;
|
|
2658
|
+
}
|
|
2659
|
+
set resources(e) {
|
|
2660
|
+
this.stateManager.setResources(e);
|
|
2661
|
+
}
|
|
2662
|
+
get options() {
|
|
2663
|
+
return this.stateManager.getState().options;
|
|
2664
|
+
}
|
|
2665
|
+
set options(e) {
|
|
2666
|
+
this.stateManager.setOptions(e);
|
|
2667
|
+
}
|
|
2668
|
+
get selectedEvent() {
|
|
2669
|
+
return this.stateManager.getState().selectedEvent;
|
|
2670
|
+
}
|
|
2671
|
+
set selectedEvent(e) {
|
|
2672
|
+
this.stateManager.setSelectedEvent(e);
|
|
2673
|
+
}
|
|
2674
|
+
get selectedRange() {
|
|
2675
|
+
const e = this.stateManager.getState();
|
|
2676
|
+
return e.previewEvent ? { start: e.previewEvent.start, end: e.previewEvent.end } : null;
|
|
2677
|
+
}
|
|
2678
|
+
next() {
|
|
2679
|
+
this.stateManager.next();
|
|
2680
|
+
}
|
|
2681
|
+
prev() {
|
|
2682
|
+
this.stateManager.prev();
|
|
2683
|
+
}
|
|
2684
|
+
today() {
|
|
2685
|
+
this.stateManager.today();
|
|
2686
|
+
}
|
|
2687
|
+
gotoDate(e) {
|
|
2688
|
+
this.stateManager.gotoDate(e);
|
|
2689
|
+
}
|
|
2690
|
+
changeView(e) {
|
|
2691
|
+
this.stateManager.setView(e), this.liveAnnouncer.announce(`View changed to ${e}.`);
|
|
2692
|
+
}
|
|
2693
|
+
/**
|
|
2694
|
+
* Clear the time-range selection and the focused-cell selection. Public
|
|
2695
|
+
* because — per PRD scheduler-controlled-selection — the WC no longer
|
|
2696
|
+
* auto-clears on commit; consumers call this from their `event-create`
|
|
2697
|
+
* handler if they want the post-create selection cleared.
|
|
2698
|
+
*/
|
|
2699
|
+
clearSelection() {
|
|
2700
|
+
this.stateManager.clearSelection();
|
|
2701
|
+
}
|
|
2702
|
+
addEvent(e) {
|
|
2703
|
+
this.stateManager.addEvent(e), this.liveAnnouncer.announce(`Event ${e.title} added.`);
|
|
2704
|
+
}
|
|
2705
|
+
updateEvent(e) {
|
|
2706
|
+
this.stateManager.updateEvent(e), this.liveAnnouncer.announce(`Event ${e.title} updated.`);
|
|
2707
|
+
}
|
|
2708
|
+
removeEvent(e) {
|
|
2709
|
+
const t = this.getEventById(e);
|
|
2710
|
+
this.stateManager.removeEvent(e), t && this.liveAnnouncer.announce(`Event ${t.title} removed.`);
|
|
2711
|
+
}
|
|
2712
|
+
getEventById(e) {
|
|
2713
|
+
return this.events.find((t) => t.id === e) ?? null;
|
|
2714
|
+
}
|
|
2715
|
+
refetchEvents() {
|
|
2716
|
+
this.currentView?.update(this.stateManager.getState());
|
|
2717
|
+
}
|
|
2718
|
+
// ============================================
|
|
2719
|
+
// Rendering
|
|
2720
|
+
// ============================================
|
|
2721
|
+
render() {
|
|
2722
|
+
return U`
|
|
2723
|
+
<div class="scheduler-container">
|
|
2724
|
+
<header class="scheduler-header"></header>
|
|
2725
|
+
<div class="scheduler-content"></div>
|
|
2726
|
+
</div>
|
|
2727
|
+
${this.liveAnnouncer.template()}
|
|
2728
|
+
`;
|
|
2729
|
+
}
|
|
2730
|
+
firstUpdated() {
|
|
2731
|
+
const e = this.shadowRoot.querySelector(".scheduler-header");
|
|
2732
|
+
this.contentContainer = this.shadowRoot.querySelector(".scheduler-content"), this.populateHeader(e), this.inputHandler = new re(
|
|
2733
|
+
{
|
|
2734
|
+
shadowRoot: this.shadowRoot,
|
|
2735
|
+
getEventById: (t) => this.getEventById(t),
|
|
2736
|
+
isEditable: () => this.stateManager.getState().options.editable ?? !0,
|
|
2737
|
+
isSelectable: () => this.stateManager.getState().options.selectable ?? !0
|
|
2738
|
+
},
|
|
2739
|
+
{
|
|
2740
|
+
onPointerDown: (t, s, n) => this.handlePointerDown(t, s, n),
|
|
2741
|
+
onPointerMove: (t) => this.handlePointerMove(t),
|
|
2742
|
+
onPointerUp: (t) => this.handlePointerUp(t),
|
|
2743
|
+
onClick: (t, s) => this.handleClick(t, s),
|
|
2744
|
+
onDoubleClick: (t, s) => this.handleDoubleClick(t, s),
|
|
2745
|
+
getScrollContainer: () => this.contentContainer
|
|
2746
|
+
}
|
|
2747
|
+
), this.inputHandler.attach(), this.shadowRoot.addEventListener("focusin", this.boundHandleFocusIn), this.renderView();
|
|
2748
|
+
}
|
|
2749
|
+
populateHeader(e) {
|
|
2750
|
+
const t = document.createElement("nav");
|
|
2751
|
+
t.className = "scheduler-nav", t.setAttribute("aria-label", "Scheduler navigation");
|
|
2752
|
+
const s = document.createElement("button");
|
|
2753
|
+
s.type = "button", s.textContent = "‹", s.setAttribute("aria-label", "Previous period"), s.title = "Previous", s.addEventListener("click", () => this.prev());
|
|
2754
|
+
const n = document.createElement("button");
|
|
2755
|
+
n.type = "button", n.textContent = "›", n.setAttribute("aria-label", "Next period"), n.title = "Next", n.addEventListener("click", () => this.next());
|
|
2756
|
+
const i = document.createElement("button");
|
|
2757
|
+
i.type = "button", i.textContent = "Today", i.setAttribute("aria-label", "Jump to today"), i.addEventListener("click", () => this.today()), t.appendChild(s), t.appendChild(n), t.appendChild(i);
|
|
2758
|
+
const o = document.createElement("div");
|
|
2759
|
+
o.className = "scheduler-title", o.setAttribute("aria-live", "polite"), o.setAttribute("aria-atomic", "true"), this.updateTitle(o);
|
|
2760
|
+
const r = document.createElement("div");
|
|
2761
|
+
r.className = "scheduler-view-switcher", r.setAttribute("role", "group"), r.setAttribute("aria-label", "Switch view");
|
|
2762
|
+
const a = [
|
|
2763
|
+
{ key: "year", label: "Year" },
|
|
2764
|
+
{ key: "month", label: "Month" },
|
|
2765
|
+
{ key: "week", label: "Week" },
|
|
2766
|
+
{ key: "day", label: "Day" },
|
|
2767
|
+
{ key: "timeline", label: "Timeline" }
|
|
2768
|
+
];
|
|
2769
|
+
for (const { key: l, label: d } of a) {
|
|
2770
|
+
const c = document.createElement("button");
|
|
2771
|
+
c.type = "button", c.textContent = d, c.dataset.view = l;
|
|
2772
|
+
const u = l === this.view;
|
|
2773
|
+
c.setAttribute("aria-pressed", String(u)), u && c.classList.add("active"), c.addEventListener("click", () => this.changeView(l)), r.appendChild(c);
|
|
2774
|
+
}
|
|
2775
|
+
e.appendChild(t), e.appendChild(o), e.appendChild(r);
|
|
2776
|
+
}
|
|
2777
|
+
updateTitle(e) {
|
|
2778
|
+
const t = e ?? this.shadowRoot.querySelector(".scheduler-title");
|
|
2779
|
+
if (!t) return;
|
|
2780
|
+
const s = this.stateManager.getState(), { date: n, view: i, options: o } = s;
|
|
2781
|
+
let r = "";
|
|
2782
|
+
switch (i) {
|
|
2783
|
+
case "year":
|
|
2784
|
+
r = n.getFullYear().toString();
|
|
2785
|
+
break;
|
|
2786
|
+
case "month":
|
|
2787
|
+
r = h.formatDate(n, o.locale, {
|
|
2788
|
+
month: "long",
|
|
2789
|
+
year: "numeric"
|
|
2790
|
+
});
|
|
2791
|
+
break;
|
|
2792
|
+
case "week":
|
|
2793
|
+
case "timeline": {
|
|
2794
|
+
const a = h.getWeekStart(n, o.firstDayOfWeek), l = h.addDays(a, 6);
|
|
2795
|
+
r = `${h.formatDate(a, o.locale, {
|
|
2796
|
+
month: "short",
|
|
2797
|
+
day: "numeric"
|
|
2798
|
+
})} - ${h.formatDate(l, o.locale, {
|
|
2799
|
+
month: "short",
|
|
2800
|
+
day: "numeric",
|
|
2801
|
+
year: "numeric"
|
|
2802
|
+
})}`;
|
|
2803
|
+
break;
|
|
2804
|
+
}
|
|
2805
|
+
case "day":
|
|
2806
|
+
r = h.formatDate(n, o.locale, {
|
|
2807
|
+
weekday: "long",
|
|
2808
|
+
month: "long",
|
|
2809
|
+
day: "numeric",
|
|
2810
|
+
year: "numeric"
|
|
2811
|
+
});
|
|
2812
|
+
break;
|
|
2813
|
+
}
|
|
2814
|
+
t.textContent = r;
|
|
2815
|
+
}
|
|
2816
|
+
renderView() {
|
|
2817
|
+
if (!this.contentContainer) return;
|
|
2818
|
+
this.currentView?.destroy();
|
|
2819
|
+
const e = this.stateManager.getState();
|
|
2820
|
+
switch (e.view) {
|
|
2821
|
+
case "year":
|
|
2822
|
+
this.currentView = new A(this.contentContainer, e), this.currentViewType = "year";
|
|
2823
|
+
break;
|
|
2824
|
+
case "month":
|
|
2825
|
+
this.currentView = new T(this.contentContainer, e), this.currentViewType = "month";
|
|
2826
|
+
break;
|
|
2827
|
+
case "week":
|
|
2828
|
+
this.currentView = new J(this.contentContainer, e), this.currentViewType = "week";
|
|
2829
|
+
break;
|
|
2830
|
+
case "day":
|
|
2831
|
+
this.currentView = new Z(this.contentContainer, e), this.currentViewType = "day";
|
|
2832
|
+
break;
|
|
2833
|
+
case "timeline":
|
|
2834
|
+
this.currentView = new Q(this.contentContainer, e), this.currentViewType = "timeline";
|
|
2835
|
+
break;
|
|
2836
|
+
}
|
|
2837
|
+
this.currentView?.render();
|
|
2838
|
+
}
|
|
2839
|
+
// ============================================
|
|
2840
|
+
// State Change Handling
|
|
2841
|
+
// ============================================
|
|
2842
|
+
onStateChange(e) {
|
|
2843
|
+
this.detectAndEmitChanges(e), this.updateUI(e);
|
|
2844
|
+
}
|
|
2845
|
+
detectAndEmitChanges(e) {
|
|
2846
|
+
const t = this.previousView !== null && this.previousView !== e.view, s = this.previousDate !== null && this.previousDate.getTime() !== e.date.getTime(), n = e.selectedEvent?.id ?? null, i = k(e), o = i ? `${i.start.getTime()}-${i.end.getTime()}-${e.selectionResourceId ?? ""}` : null, r = this.previousSelectedEventId !== n || this.previousRangeKey !== o;
|
|
2847
|
+
(t || s) && this.eventEmitter.emitViewChange(e.view, e.date), r && this.eventEmitter.emitSelectionChange(
|
|
2848
|
+
e.selectedEvent,
|
|
2849
|
+
i,
|
|
2850
|
+
e.view,
|
|
2851
|
+
e.selectionResourceId ?? void 0
|
|
2852
|
+
), this.previousView = e.view, this.previousDate = new Date(e.date), this.previousSelectedEventId = n, this.previousRangeKey = o;
|
|
2853
|
+
}
|
|
2854
|
+
updateUI(e) {
|
|
2855
|
+
this.updateTitle(), this.shadowRoot.querySelectorAll(".scheduler-view-switcher button").forEach((s) => {
|
|
2856
|
+
const n = s, i = n.dataset.view === e.view;
|
|
2857
|
+
n.classList.toggle("active", i), n.setAttribute("aria-pressed", String(i));
|
|
2858
|
+
}), this.currentView && (this.currentViewType !== e.view ? this.renderView() : e.dragState || e.previewEvent ? this.scheduleDragUpdate(e) : this.currentView.update(e));
|
|
2859
|
+
}
|
|
2860
|
+
scheduleDragUpdate(e) {
|
|
2861
|
+
this.latestDragState = e, this.pendingDragUpdate === null && (this.pendingDragUpdate = requestAnimationFrame(() => {
|
|
2862
|
+
this.pendingDragUpdate = null;
|
|
2863
|
+
const t = this.latestDragState;
|
|
2864
|
+
this.latestDragState = null, t && this.currentView && this.currentView.update(t);
|
|
2865
|
+
}));
|
|
2866
|
+
}
|
|
2867
|
+
// ============================================
|
|
2868
|
+
// Input Handling (Callbacks from InputHandler)
|
|
2869
|
+
// ============================================
|
|
2870
|
+
handlePointerDown(e, t, s) {
|
|
2871
|
+
this.dragManager.handlePointerDown(e, t, s);
|
|
2872
|
+
}
|
|
2873
|
+
handlePointerMove(e) {
|
|
2874
|
+
this.dragManager.handlePointerMove(e);
|
|
2875
|
+
}
|
|
2876
|
+
handlePointerUp(e) {
|
|
2877
|
+
const t = this.dragManager.handlePointerUp(e);
|
|
2878
|
+
t && this.handleDragComplete(t, e.originalEvent);
|
|
2879
|
+
}
|
|
2880
|
+
handleDragComplete(e, t) {
|
|
2881
|
+
if (e.wasClick) {
|
|
2882
|
+
e.event && (this.stateManager.setSelectedEvent(e.event), this.eventEmitter.emitEventSelected(e.event, t));
|
|
2883
|
+
return;
|
|
2884
|
+
}
|
|
2885
|
+
switch (e.type) {
|
|
2886
|
+
case "create": {
|
|
2887
|
+
const s = this.stateManager.getState();
|
|
2888
|
+
this.eventEmitter.emitEventCreate(
|
|
2889
|
+
{ start: e.preview.start, end: e.preview.end },
|
|
2890
|
+
s.view,
|
|
2891
|
+
t,
|
|
2892
|
+
e.preview.resourceId
|
|
2893
|
+
);
|
|
2894
|
+
break;
|
|
2895
|
+
}
|
|
2896
|
+
case "move":
|
|
2897
|
+
case "resize-start":
|
|
2898
|
+
case "resize-end": {
|
|
2899
|
+
if (e.event && e.originalEvent) {
|
|
2900
|
+
const s = {
|
|
2901
|
+
...e.event,
|
|
2902
|
+
start: e.preview.start,
|
|
2903
|
+
end: e.preview.end
|
|
2904
|
+
};
|
|
2905
|
+
this.stateManager.updateEvent(s), this.eventEmitter.emitEventUpdate(
|
|
2906
|
+
s,
|
|
2907
|
+
e.originalEvent,
|
|
2908
|
+
t
|
|
2909
|
+
);
|
|
2910
|
+
}
|
|
2911
|
+
break;
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2915
|
+
handleClick(e, t) {
|
|
2916
|
+
const s = e.target, n = s.closest(".expand-toggle");
|
|
2917
|
+
if (n) {
|
|
2918
|
+
const a = n.dataset.groupId;
|
|
2919
|
+
if (a) {
|
|
2920
|
+
this.stateManager.toggleGroupCollapse(a), this.renderView();
|
|
2921
|
+
return;
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
const i = s.closest("[data-date]");
|
|
2925
|
+
if (i) {
|
|
2926
|
+
const a = i.dataset.date;
|
|
2927
|
+
a && this.eventEmitter.emitDateClick(new Date(a), e.originalEvent);
|
|
2928
|
+
}
|
|
2929
|
+
const o = s.closest(
|
|
2930
|
+
".scheduler-year-month-header"
|
|
2931
|
+
);
|
|
2932
|
+
if (o) {
|
|
2933
|
+
const a = o.dataset.month;
|
|
2934
|
+
a && (this.stateManager.setDate(new Date(a)), this.stateManager.setView("month"));
|
|
2935
|
+
}
|
|
2936
|
+
const r = s.closest(".scheduler-more-link");
|
|
2937
|
+
if (r) {
|
|
2938
|
+
const a = r.dataset.date;
|
|
2939
|
+
a && (this.stateManager.setDate(new Date(a)), this.stateManager.setView("day"));
|
|
2940
|
+
}
|
|
2941
|
+
t.type === "event" && t.event && this.stateManager.setSelectedEvent(t.event);
|
|
2942
|
+
}
|
|
2943
|
+
handleDoubleClick(e, t) {
|
|
2944
|
+
t.type === "event" && t.event && this.eventEmitter.emitEventDblClick(t.event, e.originalEvent);
|
|
2945
|
+
}
|
|
2946
|
+
/**
|
|
2947
|
+
* When focus lands on an event block (Tab, programmatic, or click), select
|
|
2948
|
+
* the event and emit `event-selected` for mouse-parity (PRD §6.5 D3). The
|
|
2949
|
+
* subsequent setSelectedEvent call routes through detectAndEmitChanges
|
|
2950
|
+
* which fires `selection-change`.
|
|
2951
|
+
*
|
|
2952
|
+
* `focusin` bubbles across shadow boundaries but `e.target` is retargeted
|
|
2953
|
+
* to the host. Use composedPath()[0] for the actual focused element.
|
|
2954
|
+
*/
|
|
2955
|
+
handleFocusIn(e) {
|
|
2956
|
+
const s = (e.composedPath?.() ?? [])[0] ?? e.target;
|
|
2957
|
+
if (!s || !s.dataset) return;
|
|
2958
|
+
const n = s.dataset.eventId;
|
|
2959
|
+
if (!n || !s.classList.contains("scheduler-event") && !s.classList.contains("scheduler-timeline-event"))
|
|
2960
|
+
return;
|
|
2961
|
+
const i = this.getEventById(n);
|
|
2962
|
+
i && this.stateManager.getState().selectedEvent?.id !== i.id && (this.stateManager.setSelectedEvent(i), this.eventEmitter.emitEventSelected(i, e), requestAnimationFrame(() => {
|
|
2963
|
+
const o = `[data-event-id="${this.cssEscape(i.id)}"]`;
|
|
2964
|
+
this.shadowRoot?.querySelector(o)?.focus({ preventScroll: !0 });
|
|
2965
|
+
}));
|
|
2966
|
+
}
|
|
2967
|
+
handleKeyDown(e) {
|
|
2968
|
+
if (this.keyboardMove) {
|
|
2969
|
+
this.handleKeyboardMove(e);
|
|
2970
|
+
return;
|
|
2971
|
+
}
|
|
2972
|
+
if (e.key === "Escape" && this.dragManager.isDragging()) {
|
|
2973
|
+
this.dragManager.cancel();
|
|
2974
|
+
return;
|
|
2975
|
+
}
|
|
2976
|
+
if (e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey && this.handleAltShortcut(e))
|
|
2977
|
+
return;
|
|
2978
|
+
const t = this.getFocusedKind();
|
|
2979
|
+
t === "cell" ? this.handleCellKeyDown(e) : t === "event" && this.handleEventKeyDown(e);
|
|
2980
|
+
}
|
|
2981
|
+
getFocusedKind() {
|
|
2982
|
+
const e = this.shadowRoot?.activeElement;
|
|
2983
|
+
return e ? e.classList.contains("scheduler-time-slot") || e.classList.contains("scheduler-timeline-slot") || e.classList.contains("scheduler-month-day") || e.classList.contains("scheduler-year-month") ? "cell" : e.classList.contains("scheduler-event") || e.classList.contains("scheduler-timeline-event") ? "event" : "other" : "other";
|
|
2984
|
+
}
|
|
2985
|
+
handleAltShortcut(e) {
|
|
2986
|
+
switch (e.key.toLowerCase()) {
|
|
2987
|
+
case "t":
|
|
2988
|
+
return this.today(), e.preventDefault(), !0;
|
|
2989
|
+
case "y":
|
|
2990
|
+
return this.changeView("year"), e.preventDefault(), !0;
|
|
2991
|
+
case "m":
|
|
2992
|
+
return this.changeView("month"), e.preventDefault(), !0;
|
|
2993
|
+
case "w":
|
|
2994
|
+
return this.changeView("week"), e.preventDefault(), !0;
|
|
2995
|
+
case "d":
|
|
2996
|
+
return this.changeView("day"), e.preventDefault(), !0;
|
|
2997
|
+
}
|
|
2998
|
+
return !1;
|
|
2999
|
+
}
|
|
3000
|
+
handleEventKeyDown(e) {
|
|
3001
|
+
const s = this.stateManager.getState().selectedEvent;
|
|
3002
|
+
if (s)
|
|
3003
|
+
switch (e.key) {
|
|
3004
|
+
case "Enter":
|
|
3005
|
+
e.preventDefault(), this.enterEventMoveMode(s);
|
|
3006
|
+
return;
|
|
3007
|
+
case "Delete":
|
|
3008
|
+
case "Backspace":
|
|
3009
|
+
e.preventDefault(), this.eventEmitter.emitEventDelete(s);
|
|
3010
|
+
return;
|
|
3011
|
+
case "Escape":
|
|
3012
|
+
e.preventDefault(), this.focusFocusedCell();
|
|
3013
|
+
return;
|
|
3014
|
+
case "ArrowLeft":
|
|
3015
|
+
e.preventDefault(), this.focusAdjacentEvent(s, -1);
|
|
3016
|
+
return;
|
|
3017
|
+
case "ArrowRight":
|
|
3018
|
+
e.preventDefault(), this.focusAdjacentEvent(s, 1);
|
|
3019
|
+
return;
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
/**
|
|
3023
|
+
* Inter-event arrow nav (PRD scheduler-controlled-selection §5.3): walk
|
|
3024
|
+
* the events in document order (start time, with id as tiebreaker) by ±1.
|
|
3025
|
+
* No wrap at the ends — matches the APG list/feed pattern.
|
|
3026
|
+
*/
|
|
3027
|
+
focusAdjacentEvent(e, t) {
|
|
3028
|
+
const n = [...this.stateManager.getState().events].sort((l, d) => {
|
|
3029
|
+
const c = l.start.getTime() - d.start.getTime();
|
|
3030
|
+
return c !== 0 ? c : l.id.localeCompare(d.id);
|
|
3031
|
+
}), i = n.findIndex((l) => l.id === e.id);
|
|
3032
|
+
if (i < 0) return;
|
|
3033
|
+
const o = n[i + t];
|
|
3034
|
+
if (!o) return;
|
|
3035
|
+
const r = this.shadowRoot;
|
|
3036
|
+
if (!r) return;
|
|
3037
|
+
r.querySelector(
|
|
3038
|
+
`[data-event-id="${this.cssEscape(o.id)}"]`
|
|
3039
|
+
)?.focus({ preventScroll: !1 });
|
|
3040
|
+
}
|
|
3041
|
+
handleCellKeyDown(e) {
|
|
3042
|
+
const t = this.stateManager.getState();
|
|
3043
|
+
if (t.view === "month") {
|
|
3044
|
+
this.handleMonthCellKeyDown(e);
|
|
3045
|
+
return;
|
|
3046
|
+
}
|
|
3047
|
+
if (t.view === "year") {
|
|
3048
|
+
this.handleYearCellKeyDown(e);
|
|
3049
|
+
return;
|
|
3050
|
+
}
|
|
3051
|
+
t.focusedCell || this.initFocusedCellFromActive();
|
|
3052
|
+
const s = e.shiftKey, n = e.ctrlKey || e.metaKey, i = t.view === "timeline";
|
|
3053
|
+
switch (e.key) {
|
|
3054
|
+
case "ArrowUp":
|
|
3055
|
+
e.preventDefault(), i ? this.moveCellByResource(-1, s) : this.moveCellByTime(-1, s);
|
|
3056
|
+
break;
|
|
3057
|
+
case "ArrowDown":
|
|
3058
|
+
e.preventDefault(), i ? this.moveCellByResource(1, s) : this.moveCellByTime(1, s);
|
|
3059
|
+
break;
|
|
3060
|
+
case "ArrowLeft":
|
|
3061
|
+
e.preventDefault(), i ? this.moveCellByTime(-1, s) : this.moveCellByDay(-1, s);
|
|
3062
|
+
break;
|
|
3063
|
+
case "ArrowRight":
|
|
3064
|
+
e.preventDefault(), i ? this.moveCellByTime(1, s) : this.moveCellByDay(1, s);
|
|
3065
|
+
break;
|
|
3066
|
+
case "Home":
|
|
3067
|
+
e.preventDefault(), n ? this.moveCellToViewExtreme("start", s) : this.moveCellToColumnExtreme("start", s);
|
|
3068
|
+
break;
|
|
3069
|
+
case "End":
|
|
3070
|
+
e.preventDefault(), n ? this.moveCellToViewExtreme("end", s) : this.moveCellToColumnExtreme("end", s);
|
|
3071
|
+
break;
|
|
3072
|
+
case "PageUp":
|
|
3073
|
+
e.preventDefault(), this.moveCellByPeriod(-1);
|
|
3074
|
+
break;
|
|
3075
|
+
case "PageDown":
|
|
3076
|
+
e.preventDefault(), this.moveCellByPeriod(1);
|
|
3077
|
+
break;
|
|
3078
|
+
case "Enter":
|
|
3079
|
+
e.preventDefault(), this.createEventFromCellOrSelection(e);
|
|
3080
|
+
break;
|
|
3081
|
+
case "Escape":
|
|
3082
|
+
e.preventDefault(), this.stateManager.clearSelection();
|
|
3083
|
+
break;
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
/**
|
|
3087
|
+
* If a cell is the active element but state.focusedCell is empty (e.g.
|
|
3088
|
+
* Tab landed on the fallback first cell), seed the state from the
|
|
3089
|
+
* active element's data attributes.
|
|
3090
|
+
*/
|
|
3091
|
+
initFocusedCellFromActive() {
|
|
3092
|
+
const e = this.shadowRoot?.activeElement;
|
|
3093
|
+
if (!e) return;
|
|
3094
|
+
const t = e.dataset.start, s = e.dataset.end;
|
|
3095
|
+
if (!t || !s) return;
|
|
3096
|
+
const n = { start: new Date(t), end: new Date(s) }, i = e.dataset.resourceId ?? null;
|
|
3097
|
+
this.stateManager.setFocusedCell(n, i, !0);
|
|
3098
|
+
}
|
|
3099
|
+
/**
|
|
3100
|
+
* Month-view keyboard handler (PRD scheduler-controlled-selection §5.1).
|
|
3101
|
+
* Arrows walk days; ArrowUp/Down ± one week; cross-month moves auto-
|
|
3102
|
+
* advance the displayed date so the new month renders. Enter emits
|
|
3103
|
+
* `event-create` for the focused day's full range.
|
|
3104
|
+
*/
|
|
3105
|
+
handleMonthCellKeyDown(e) {
|
|
3106
|
+
switch (this.syncFocusedDateFromActive(), e.key) {
|
|
3107
|
+
case "ArrowLeft":
|
|
3108
|
+
e.preventDefault(), this.moveFocusedDateByDays(-1);
|
|
3109
|
+
return;
|
|
3110
|
+
case "ArrowRight":
|
|
3111
|
+
e.preventDefault(), this.moveFocusedDateByDays(1);
|
|
3112
|
+
return;
|
|
3113
|
+
case "ArrowUp":
|
|
3114
|
+
e.preventDefault(), this.moveFocusedDateByDays(-7);
|
|
3115
|
+
return;
|
|
3116
|
+
case "ArrowDown":
|
|
3117
|
+
e.preventDefault(), this.moveFocusedDateByDays(7);
|
|
3118
|
+
return;
|
|
3119
|
+
case "Enter":
|
|
3120
|
+
e.preventDefault(), this.commitFocusedDateAsCreate(e, "day");
|
|
3121
|
+
return;
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
/**
|
|
3125
|
+
* Year-view keyboard handler (PRD scheduler-controlled-selection §5.2).
|
|
3126
|
+
* The focus unit is a month — ArrowLeft/Right ± 1, ArrowUp/Down ± 3 to
|
|
3127
|
+
* mirror the visual 4×3 layout. Cross-year auto-advances. Enter emits
|
|
3128
|
+
* `event-create` for the focused month's full range.
|
|
3129
|
+
*/
|
|
3130
|
+
handleYearCellKeyDown(e) {
|
|
3131
|
+
switch (this.syncFocusedDateFromActive(), e.key) {
|
|
3132
|
+
case "ArrowLeft":
|
|
3133
|
+
e.preventDefault(), this.moveFocusedDateByMonths(-1);
|
|
3134
|
+
return;
|
|
3135
|
+
case "ArrowRight":
|
|
3136
|
+
e.preventDefault(), this.moveFocusedDateByMonths(1);
|
|
3137
|
+
return;
|
|
3138
|
+
case "ArrowUp":
|
|
3139
|
+
e.preventDefault(), this.moveFocusedDateByMonths(-3);
|
|
3140
|
+
return;
|
|
3141
|
+
case "ArrowDown":
|
|
3142
|
+
e.preventDefault(), this.moveFocusedDateByMonths(3);
|
|
3143
|
+
return;
|
|
3144
|
+
case "Enter":
|
|
3145
|
+
e.preventDefault(), this.commitFocusedDateAsCreate(e, "month");
|
|
3146
|
+
return;
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
/**
|
|
3150
|
+
* Sync `focusedDate` from the currently-active month/year cell. Runs at
|
|
3151
|
+
* the top of every Phase B keydown so click-driven and Tab-driven focus
|
|
3152
|
+
* moves are reflected in state before arrow keys read it.
|
|
3153
|
+
*/
|
|
3154
|
+
syncFocusedDateFromActive() {
|
|
3155
|
+
const e = this.shadowRoot?.activeElement;
|
|
3156
|
+
if (!e) return;
|
|
3157
|
+
const t = e.dataset.date ?? e.dataset.month;
|
|
3158
|
+
t && this.stateManager.setFocusedDate(new Date(t));
|
|
3159
|
+
}
|
|
3160
|
+
moveFocusedDateByDays(e) {
|
|
3161
|
+
const t = this.stateManager.getState(), s = t.focusedDate ?? t.date, n = new Date(s);
|
|
3162
|
+
n.setDate(n.getDate() + e), this.commitFocusedDate(n);
|
|
3163
|
+
}
|
|
3164
|
+
moveFocusedDateByMonths(e) {
|
|
3165
|
+
const t = this.stateManager.getState(), s = t.focusedDate ?? t.date, n = new Date(s);
|
|
3166
|
+
n.setMonth(n.getMonth() + e), this.commitFocusedDate(n);
|
|
3167
|
+
}
|
|
3168
|
+
/**
|
|
3169
|
+
* Apply a focused-date update. If the new date crosses the displayed
|
|
3170
|
+
* period (different month on month view; different year on year view),
|
|
3171
|
+
* also bump `state.date` so the view re-renders to the new period —
|
|
3172
|
+
* APG date-picker auto-advance behaviour. Then schedule a focus
|
|
3173
|
+
* restoration on the matching cell after the next render.
|
|
3174
|
+
*/
|
|
3175
|
+
commitFocusedDate(e) {
|
|
3176
|
+
const t = this.stateManager.getState();
|
|
3177
|
+
let s = null;
|
|
3178
|
+
t.view === "month" ? e.getFullYear() === t.date.getFullYear() && e.getMonth() === t.date.getMonth() || (s = e) : t.view === "year" && e.getFullYear() !== t.date.getFullYear() && (s = e), s && this.stateManager.setDate(new Date(s)), this.stateManager.setFocusedDate(e), this.scrollAndFocusDateCell(e), s && requestAnimationFrame(() => this.scrollAndFocusDateCell(e));
|
|
3179
|
+
}
|
|
3180
|
+
/**
|
|
3181
|
+
* Find the month/year date-cell DOM element by id and focus it. Keys are
|
|
3182
|
+
* built from *local* date components to match `MonthView.dayKey()` /
|
|
3183
|
+
* `YearView.monthKey()` — see those helpers for why ISO is unsafe across
|
|
3184
|
+
* non-UTC timezones.
|
|
3185
|
+
*/
|
|
3186
|
+
scrollAndFocusDateCell(e) {
|
|
3187
|
+
const t = this.stateManager.getState(), s = this.shadowRoot;
|
|
3188
|
+
if (!s) return;
|
|
3189
|
+
const n = `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}`, i = t.view === "year" ? `scheduler-cell-y-${n}` : `scheduler-cell-m-${n}-${String(e.getDate()).padStart(2, "0")}`, o = s.getElementById(i);
|
|
3190
|
+
o && (o.focus({ preventScroll: !0 }), typeof o.scrollIntoView == "function" && o.scrollIntoView({ block: "nearest", inline: "nearest" }));
|
|
3191
|
+
}
|
|
3192
|
+
/**
|
|
3193
|
+
* Emit `event-create` covering the focused day (month view) or focused
|
|
3194
|
+
* month (year view). No internal mutation per PRD
|
|
3195
|
+
* scheduler-controlled-selection — consumer constructs the actual event.
|
|
3196
|
+
*/
|
|
3197
|
+
commitFocusedDateAsCreate(e, t) {
|
|
3198
|
+
const s = this.stateManager.getState(), n = s.focusedDate;
|
|
3199
|
+
if (!n) return;
|
|
3200
|
+
const i = new Date(n);
|
|
3201
|
+
i.setHours(0, 0, 0, 0);
|
|
3202
|
+
const o = new Date(i);
|
|
3203
|
+
t === "day" ? o.setDate(o.getDate() + 1) : o.setMonth(o.getMonth() + 1), this.eventEmitter.emitEventCreate(
|
|
3204
|
+
{ start: i, end: o },
|
|
3205
|
+
s.view,
|
|
3206
|
+
e
|
|
3207
|
+
);
|
|
3208
|
+
}
|
|
3209
|
+
moveCellByTime(e, t) {
|
|
3210
|
+
const s = this.stateManager.getState(), n = s.focusedCell;
|
|
3211
|
+
if (!n) return;
|
|
3212
|
+
const i = (s.options.slotDuration ?? 1800) * 1e3, o = new Date(n.start.getTime() + e * i), r = new Date(o.getTime() + i);
|
|
3213
|
+
this.cellIsWithinView(o, s) && this.commitFocusMove({ start: o, end: r }, s.focusedResourceId, t);
|
|
3214
|
+
}
|
|
3215
|
+
/** Week view ArrowLeft/Right: ±1 day, same time-of-day. No-op on day view. */
|
|
3216
|
+
moveCellByDay(e, t) {
|
|
3217
|
+
const s = this.stateManager.getState(), n = s.focusedCell;
|
|
3218
|
+
if (!n || s.view !== "week") return;
|
|
3219
|
+
const i = (s.options.slotDuration ?? 1800) * 1e3, o = new Date(n.start);
|
|
3220
|
+
o.setDate(o.getDate() + e);
|
|
3221
|
+
const r = new Date(o.getTime() + i);
|
|
3222
|
+
this.cellIsWithinView(o, s) && this.commitFocusMove({ start: o, end: r }, null, t);
|
|
3223
|
+
}
|
|
3224
|
+
/** Timeline ArrowUp/Down: ±1 resource, same time-of-day. PRD D1: cross-resource
|
|
3225
|
+
* Shift+Arrow is intentionally ignored (resource is categorical). */
|
|
3226
|
+
moveCellByResource(e, t) {
|
|
3227
|
+
const s = this.stateManager.getState(), n = s.focusedCell;
|
|
3228
|
+
if (!n || s.view !== "timeline" || t) return;
|
|
3229
|
+
const i = this.adjacentResource(s.focusedResourceId, e, s);
|
|
3230
|
+
i && this.commitFocusMove(n, i, !1);
|
|
3231
|
+
}
|
|
3232
|
+
moveCellToColumnExtreme(e, t) {
|
|
3233
|
+
const s = this.stateManager.getState(), n = s.focusedCell;
|
|
3234
|
+
if (!n) return;
|
|
3235
|
+
const i = new Date(n.start);
|
|
3236
|
+
i.setHours(0, 0, 0, 0);
|
|
3237
|
+
const o = h.getTimeSlots(
|
|
3238
|
+
i,
|
|
3239
|
+
s.options.slotDuration,
|
|
3240
|
+
s.options.slotMinTime,
|
|
3241
|
+
s.options.slotMaxTime
|
|
3242
|
+
), r = e === "start" ? o[0] : o[o.length - 1];
|
|
3243
|
+
r && this.commitFocusMove(r, s.focusedResourceId, t);
|
|
3244
|
+
}
|
|
3245
|
+
moveCellToViewExtreme(e, t) {
|
|
3246
|
+
const s = this.stateManager.getState();
|
|
3247
|
+
let n = null, i = s.focusedResourceId;
|
|
3248
|
+
switch (s.view) {
|
|
3249
|
+
case "day": {
|
|
3250
|
+
const o = h.getTimeSlots(s.date, s.options.slotDuration, s.options.slotMinTime, s.options.slotMaxTime);
|
|
3251
|
+
n = e === "start" ? o[0] : o[o.length - 1];
|
|
3252
|
+
break;
|
|
3253
|
+
}
|
|
3254
|
+
case "week": {
|
|
3255
|
+
const o = h.getWeekDays(s.date, s.options.firstDayOfWeek), r = e === "start" ? o[0] : o[6], a = h.getTimeSlots(r, s.options.slotDuration, s.options.slotMinTime, s.options.slotMaxTime);
|
|
3256
|
+
n = e === "start" ? a[0] : a[a.length - 1];
|
|
3257
|
+
break;
|
|
3258
|
+
}
|
|
3259
|
+
case "timeline": {
|
|
3260
|
+
const r = S.flatten(s.resources, s.collapsedGroups).filter((c) => c.visible && F(c.item));
|
|
3261
|
+
if (r.length === 0) return;
|
|
3262
|
+
i = e === "start" ? r[0].item.id : r[r.length - 1].item.id;
|
|
3263
|
+
const a = h.getWeekDays(s.date, s.options.firstDayOfWeek), l = e === "start" ? a[0] : a[6], d = h.getTimeSlots(l, s.options.slotDuration, s.options.slotMinTime, s.options.slotMaxTime);
|
|
3264
|
+
n = e === "start" ? d[0] : d[d.length - 1];
|
|
3265
|
+
break;
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
n && this.commitFocusMove(n, i, t);
|
|
3269
|
+
}
|
|
3270
|
+
/**
|
|
3271
|
+
* PageUp/PageDown — advance one period (week or day) and re-focus the same
|
|
3272
|
+
* day-of-week + time-of-day in the new period. Selection is cleared since
|
|
3273
|
+
* crossing a period boundary breaks the linear-range invariant.
|
|
3274
|
+
*/
|
|
3275
|
+
moveCellByPeriod(e) {
|
|
3276
|
+
const t = this.stateManager.getState(), s = t.focusedCell, n = t.date;
|
|
3277
|
+
if (e > 0 ? this.next() : this.prev(), !s) return;
|
|
3278
|
+
const i = this.stateManager.getState();
|
|
3279
|
+
let o;
|
|
3280
|
+
if (i.view === "day")
|
|
3281
|
+
o = new Date(i.date), o.setHours(s.start.getHours(), s.start.getMinutes(), s.start.getSeconds(), 0);
|
|
3282
|
+
else {
|
|
3283
|
+
const l = h.getWeekDays(n, t.options.firstDayOfWeek), d = h.getWeekDays(i.date, i.options.firstDayOfWeek), c = l.findIndex((v) => h.isSameDay(v, s.start)), u = d[Math.max(0, c)] ?? d[0];
|
|
3284
|
+
o = new Date(u), o.setHours(s.start.getHours(), s.start.getMinutes(), s.start.getSeconds(), 0);
|
|
3285
|
+
}
|
|
3286
|
+
const r = (i.options.slotDuration ?? 1800) * 1e3, a = { start: o, end: new Date(o.getTime() + r) };
|
|
3287
|
+
this.commitFocusMove(a, t.focusedResourceId, !1);
|
|
3288
|
+
}
|
|
3289
|
+
/**
|
|
3290
|
+
* Apply the focus move to state and DOM. `extend` grows the selection
|
|
3291
|
+
* range; otherwise selection is cleared. Live-region announces the new
|
|
3292
|
+
* focused cell or selection range.
|
|
3293
|
+
*/
|
|
3294
|
+
commitFocusMove(e, t, s) {
|
|
3295
|
+
const n = this.stateManager.getState(), i = n.options.slotDuration ?? 1800;
|
|
3296
|
+
if (s) {
|
|
3297
|
+
this.stateManager.extendSelection(e, t), this.stateManager.setFocusedCell(e, t, !1);
|
|
3298
|
+
const o = this.stateManager.getState();
|
|
3299
|
+
this.liveAnnouncer.announce(_(o, i, n.options.timeFormat));
|
|
3300
|
+
} else {
|
|
3301
|
+
this.stateManager.setFocusedCell(e, t, !0);
|
|
3302
|
+
const o = this.getResourceTitle(t);
|
|
3303
|
+
this.liveAnnouncer.announce(G(e, n.options.timeFormat, o));
|
|
3304
|
+
}
|
|
3305
|
+
this.scrollAndFocusCell(e, t);
|
|
3306
|
+
}
|
|
3307
|
+
cellIsWithinView(e, t) {
|
|
3308
|
+
switch (t.view) {
|
|
3309
|
+
case "day": {
|
|
3310
|
+
const s = this.parseTimeOnDay(t.date, t.options.slotMinTime), n = this.parseTimeOnDay(t.date, t.options.slotMaxTime);
|
|
3311
|
+
return e.getTime() >= s.getTime() && e.getTime() < n.getTime();
|
|
3312
|
+
}
|
|
3313
|
+
case "week":
|
|
3314
|
+
case "timeline": {
|
|
3315
|
+
const s = h.getWeekDays(t.date, t.options.firstDayOfWeek), n = this.parseTimeOnDay(s[0], t.options.slotMinTime), i = this.parseTimeOnDay(s[6], t.options.slotMaxTime);
|
|
3316
|
+
return e.getTime() >= n.getTime() && e.getTime() < i.getTime();
|
|
3317
|
+
}
|
|
3318
|
+
default:
|
|
3319
|
+
return !1;
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
parseTimeOnDay(e, t) {
|
|
3323
|
+
const [s, n, i] = (t ?? "00:00:00").split(":").map(Number), o = new Date(e);
|
|
3324
|
+
return o.setHours(0, 0, 0, 0), o.setSeconds((s ?? 0) * 3600 + (n ?? 0) * 60 + (i ?? 0)), o;
|
|
3325
|
+
}
|
|
3326
|
+
adjacentResource(e, t, s) {
|
|
3327
|
+
const i = S.flatten(s.resources, s.collapsedGroups).filter((a) => a.visible && F(a.item));
|
|
3328
|
+
if (i.length === 0) return null;
|
|
3329
|
+
if (!e) return i[0].item.id;
|
|
3330
|
+
const o = i.findIndex((a) => a.item.id === e);
|
|
3331
|
+
if (o < 0) return i[0].item.id;
|
|
3332
|
+
const r = o + t;
|
|
3333
|
+
return r < 0 || r >= i.length ? null : i[r].item.id;
|
|
3334
|
+
}
|
|
3335
|
+
getResourceTitle(e) {
|
|
3336
|
+
if (!e) return null;
|
|
3337
|
+
for (const t of S.getAllResources(this.stateManager.getState().resources))
|
|
3338
|
+
if (t.id === e) return t.title;
|
|
3339
|
+
return null;
|
|
3340
|
+
}
|
|
3341
|
+
/**
|
|
3342
|
+
* Find the cell DOM element for a (slot, resource) pair and call .focus()
|
|
3343
|
+
* on it. scrollIntoView with block:nearest provides parity with mouse
|
|
3344
|
+
* drag-near-edge auto-pan (PRD D6).
|
|
3345
|
+
*/
|
|
3346
|
+
scrollAndFocusCell(e, t) {
|
|
3347
|
+
const s = e.start.toISOString(), n = this.shadowRoot;
|
|
3348
|
+
if (!n) return;
|
|
3349
|
+
const i = t ? `.scheduler-timeline-slot[data-resource-id="${this.cssEscape(t)}"][data-start="${s}"]` : `.scheduler-time-slot[data-start="${s}"]`, o = n.querySelector(i);
|
|
3350
|
+
o && (o.focus({ preventScroll: !0 }), typeof o.scrollIntoView == "function" && o.scrollIntoView({ block: "nearest", inline: "nearest" }));
|
|
3351
|
+
}
|
|
3352
|
+
/** Re-focus whatever cell the keyboard model currently considers focused. */
|
|
3353
|
+
focusFocusedCell() {
|
|
3354
|
+
const e = this.stateManager.getState();
|
|
3355
|
+
e.focusedCell && this.scrollAndFocusCell(e.focusedCell, e.focusedResourceId);
|
|
3356
|
+
}
|
|
3357
|
+
cssEscape(e) {
|
|
3358
|
+
return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/[^a-zA-Z0-9_-]/g, (t) => `\\${t}`);
|
|
3359
|
+
}
|
|
3360
|
+
/**
|
|
3361
|
+
* Emit `event-create` covering the active selection range, or a single
|
|
3362
|
+
* cell when no selection is active. Per PRD scheduler-controlled-selection,
|
|
3363
|
+
* this is a *request* — no internal state mutation, no auto-clear, no
|
|
3364
|
+
* auto-focus. The consumer constructs the SchedulerEvent and decides
|
|
3365
|
+
* whether/when to clear the selection.
|
|
3366
|
+
*/
|
|
3367
|
+
createEventFromCellOrSelection(e) {
|
|
3368
|
+
const t = this.stateManager.getState(), s = k(t);
|
|
3369
|
+
let n, i, o;
|
|
3370
|
+
if (s)
|
|
3371
|
+
n = s.start, i = s.end, o = t.selectionResourceId ?? void 0;
|
|
3372
|
+
else if (t.focusedCell)
|
|
3373
|
+
n = t.focusedCell.start, i = t.focusedCell.end, o = t.focusedResourceId ?? void 0;
|
|
3374
|
+
else
|
|
3375
|
+
return;
|
|
3376
|
+
this.eventEmitter.emitEventCreate(
|
|
3377
|
+
{ start: n, end: i },
|
|
3378
|
+
t.view,
|
|
3379
|
+
e,
|
|
3380
|
+
o
|
|
3381
|
+
), this.liveAnnouncer.announce(
|
|
3382
|
+
`Selection committed: ${h.formatTime(n, t.options.timeFormat)}–${h.formatTime(i, t.options.timeFormat)}.`
|
|
3383
|
+
);
|
|
3384
|
+
}
|
|
3385
|
+
/**
|
|
3386
|
+
* Enter keyboard event-move mode. Captures the working copy and a snapshot
|
|
3387
|
+
* of the resource (timeline). Visual feedback is provided by routing the
|
|
3388
|
+
* working start/end through the existing previewEvent state — the same
|
|
3389
|
+
* channel used for mouse drag — so the event renders at the projected
|
|
3390
|
+
* destination as the user nudges.
|
|
3391
|
+
*/
|
|
3392
|
+
enterEventMoveMode(e) {
|
|
3393
|
+
const t = e.resourceId ?? null;
|
|
3394
|
+
this.keyboardMove = {
|
|
3395
|
+
eventId: e.id,
|
|
3396
|
+
originalStart: new Date(e.start),
|
|
3397
|
+
originalEnd: new Date(e.end),
|
|
3398
|
+
workingStart: new Date(e.start),
|
|
3399
|
+
workingEnd: new Date(e.end),
|
|
3400
|
+
workingResourceId: t
|
|
3401
|
+
}, this.stateManager.setState({
|
|
3402
|
+
keyboardMoveEventId: e.id,
|
|
3403
|
+
previewEvent: {
|
|
3404
|
+
start: new Date(e.start),
|
|
3405
|
+
end: new Date(e.end),
|
|
3406
|
+
...t ? { resourceId: t } : {}
|
|
3407
|
+
}
|
|
3408
|
+
});
|
|
3409
|
+
const s = this.minutesPerSlot();
|
|
3410
|
+
this.liveAnnouncer.announce(
|
|
3411
|
+
`Move mode for ${e.title}. Arrow keys nudge by ${s} minutes; Shift with arrow keys resizes the end edge; Alt with Shift resizes the start edge; Enter commits, Escape cancels.`
|
|
3412
|
+
), requestAnimationFrame(() => {
|
|
3413
|
+
const n = `[data-event-id="${this.cssEscape(e.id)}"]`;
|
|
3414
|
+
this.shadowRoot?.querySelector(n)?.focus({ preventScroll: !0 });
|
|
3415
|
+
});
|
|
3416
|
+
}
|
|
3417
|
+
/**
|
|
3418
|
+
* Move-mode keymap. Layered on the existing M-mode foundation:
|
|
3419
|
+
* - bare Arrow keys nudge the event
|
|
3420
|
+
* - Shift+Arrow resizes the end edge
|
|
3421
|
+
* - Alt+Shift+Arrow resizes the start edge
|
|
3422
|
+
* - on week view, Shift+ArrowLeft/Right pushes the end edge across the
|
|
3423
|
+
* day boundary (PRD D5) — symmetric with Shift+ArrowDown for time.
|
|
3424
|
+
* - Enter commits, Escape reverts.
|
|
3425
|
+
*/
|
|
3426
|
+
handleKeyboardMove(e) {
|
|
3427
|
+
if (!this.keyboardMove) return;
|
|
3428
|
+
if (e.key === "Escape") {
|
|
3429
|
+
e.preventDefault(), this.cancelEventMoveMode();
|
|
3430
|
+
return;
|
|
3431
|
+
}
|
|
3432
|
+
if (e.key === "Enter") {
|
|
3433
|
+
e.preventDefault(), this.commitEventMoveMode();
|
|
3434
|
+
return;
|
|
3435
|
+
}
|
|
3436
|
+
const t = this.stateManager.getState().view, s = t === "timeline", n = this.minutesPerSlot() * 60 * 1e3, i = e.shiftKey, o = e.altKey;
|
|
3437
|
+
switch (e.key) {
|
|
3438
|
+
case "ArrowUp":
|
|
3439
|
+
e.preventDefault(), s ? !i && !o && this.nudgeKeyboardMoveResource(-1) : i && o ? this.resizeKeyboardMoveEdge("start", -n) : i ? this.resizeKeyboardMoveEdge("end", -n) : this.nudgeKeyboardMove(-n);
|
|
3440
|
+
return;
|
|
3441
|
+
case "ArrowDown":
|
|
3442
|
+
e.preventDefault(), s ? !i && !o && this.nudgeKeyboardMoveResource(1) : i && o ? this.resizeKeyboardMoveEdge("start", +n) : i ? this.resizeKeyboardMoveEdge("end", +n) : this.nudgeKeyboardMove(+n);
|
|
3443
|
+
return;
|
|
3444
|
+
case "ArrowLeft":
|
|
3445
|
+
e.preventDefault(), s ? i && o ? this.resizeKeyboardMoveEdge("start", -n) : i ? this.resizeKeyboardMoveEdge("end", -n) : this.nudgeKeyboardMove(-n) : t === "week" && (i && o ? this.resizeKeyboardMoveEdge("start", -864e5) : i ? this.resizeKeyboardMoveEdge("end", -864e5) : this.nudgeKeyboardMove(-864e5));
|
|
3446
|
+
return;
|
|
3447
|
+
case "ArrowRight":
|
|
3448
|
+
e.preventDefault(), s ? i && o ? this.resizeKeyboardMoveEdge("start", +n) : i ? this.resizeKeyboardMoveEdge("end", +n) : this.nudgeKeyboardMove(+n) : t === "week" && (i && o ? this.resizeKeyboardMoveEdge("start", 864e5) : i ? this.resizeKeyboardMoveEdge("end", 864e5) : this.nudgeKeyboardMove(864e5));
|
|
3449
|
+
return;
|
|
3450
|
+
}
|
|
3451
|
+
}
|
|
3452
|
+
minutesPerSlot() {
|
|
3453
|
+
const e = this.stateManager.getState().options.slotDuration ?? 1800;
|
|
3454
|
+
return Math.max(1, Math.round(e / 60));
|
|
3455
|
+
}
|
|
3456
|
+
/** Shift the working event by `deltaMs` along the time axis (preserves duration). */
|
|
3457
|
+
nudgeKeyboardMove(e) {
|
|
3458
|
+
if (!this.keyboardMove) return;
|
|
3459
|
+
const t = new Date(this.keyboardMove.workingStart.getTime() + e), s = new Date(this.keyboardMove.workingEnd.getTime() + e);
|
|
3460
|
+
this.keyboardMove.workingStart = t, this.keyboardMove.workingEnd = s, this.applyKeyboardMovePreview(), this.liveAnnouncer.announce(X(t, s, this.stateManager.getState().options.timeFormat));
|
|
3461
|
+
}
|
|
3462
|
+
/** Walk to the next/previous resource (timeline only). Updates the preview's resourceId. */
|
|
3463
|
+
nudgeKeyboardMoveResource(e) {
|
|
3464
|
+
if (!this.keyboardMove) return;
|
|
3465
|
+
const t = this.adjacentResource(this.keyboardMove.workingResourceId, e, this.stateManager.getState());
|
|
3466
|
+
if (!t) return;
|
|
3467
|
+
this.keyboardMove.workingResourceId = t, this.applyKeyboardMovePreview();
|
|
3468
|
+
const s = this.getResourceTitle(t) ?? t;
|
|
3469
|
+
this.liveAnnouncer.announce(`Moved to resource ${s}.`);
|
|
3470
|
+
}
|
|
3471
|
+
/**
|
|
3472
|
+
* Resize one edge of the working event. Clamps to a minimum duration of
|
|
3473
|
+
* one slot to keep the event valid, and refuses to invert (start ≤ end).
|
|
3474
|
+
*/
|
|
3475
|
+
resizeKeyboardMoveEdge(e, t) {
|
|
3476
|
+
if (!this.keyboardMove) return;
|
|
3477
|
+
const s = this.minutesPerSlot() * 60 * 1e3;
|
|
3478
|
+
let n = this.keyboardMove.workingStart, i = this.keyboardMove.workingEnd;
|
|
3479
|
+
if (e === "end") {
|
|
3480
|
+
if (i = new Date(i.getTime() + t), i.getTime() - n.getTime() < s) return;
|
|
3481
|
+
} else if (n = new Date(n.getTime() + t), i.getTime() - n.getTime() < s) return;
|
|
3482
|
+
this.keyboardMove.workingStart = n, this.keyboardMove.workingEnd = i, this.applyKeyboardMovePreview(), this.liveAnnouncer.announce(j(n, i, e, this.stateManager.getState().options.timeFormat));
|
|
3483
|
+
}
|
|
3484
|
+
/** Mirror keyboardMove.working* into state.previewEvent so views render the destination,
|
|
3485
|
+
* then scroll the destination into view so the sighted-keyboard user can see it (PRD D6). */
|
|
3486
|
+
applyKeyboardMovePreview() {
|
|
3487
|
+
if (!this.keyboardMove) return;
|
|
3488
|
+
const { eventId: e, workingStart: t, workingEnd: s, workingResourceId: n } = this.keyboardMove;
|
|
3489
|
+
this.stateManager.setState({
|
|
3490
|
+
previewEvent: {
|
|
3491
|
+
start: t,
|
|
3492
|
+
end: s,
|
|
3493
|
+
...n ? { resourceId: n } : {}
|
|
3494
|
+
}
|
|
3495
|
+
}), requestAnimationFrame(() => {
|
|
3496
|
+
const i = this.shadowRoot;
|
|
3497
|
+
if (!i) return;
|
|
3498
|
+
i.querySelector(`[data-event-id="${this.cssEscape(e)}"]`)?.focus({ preventScroll: !0 });
|
|
3499
|
+
const r = t.toISOString(), a = n ? `.scheduler-timeline-slot[data-resource-id="${this.cssEscape(n)}"][data-start="${r}"]` : `.scheduler-time-slot[data-start="${r}"]`, l = i.querySelector(a);
|
|
3500
|
+
l && typeof l.scrollIntoView == "function" && l.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
3501
|
+
});
|
|
3502
|
+
}
|
|
3503
|
+
commitEventMoveMode() {
|
|
3504
|
+
if (!this.keyboardMove) return;
|
|
3505
|
+
const e = this.getEventById(this.keyboardMove.eventId);
|
|
3506
|
+
if (e) {
|
|
3507
|
+
const t = {
|
|
3508
|
+
...e,
|
|
3509
|
+
start: this.keyboardMove.workingStart,
|
|
3510
|
+
end: this.keyboardMove.workingEnd,
|
|
3511
|
+
...this.keyboardMove.workingResourceId ? { resourceId: this.keyboardMove.workingResourceId } : {}
|
|
3512
|
+
};
|
|
3513
|
+
this.stateManager.updateEvent(t), this.eventEmitter.emitEventUpdate(t, e, new CustomEvent("keyboard-move")), this.liveAnnouncer.announce("Move committed.");
|
|
3514
|
+
}
|
|
3515
|
+
this.keyboardMove = null, this.stateManager.setState({ keyboardMoveEventId: null, previewEvent: null }), requestAnimationFrame(() => {
|
|
3516
|
+
const t = `[data-event-id="${this.cssEscape(e?.id ?? "")}"]`;
|
|
3517
|
+
this.shadowRoot?.querySelector(t)?.focus({ preventScroll: !1 });
|
|
3518
|
+
});
|
|
3519
|
+
}
|
|
3520
|
+
cancelEventMoveMode() {
|
|
3521
|
+
const e = this.keyboardMove?.eventId ?? null;
|
|
3522
|
+
this.keyboardMove = null, this.stateManager.setState({ keyboardMoveEventId: null, previewEvent: null }), this.liveAnnouncer.announce("Move cancelled."), e && requestAnimationFrame(() => {
|
|
3523
|
+
const t = `[data-event-id="${this.cssEscape(e)}"]`;
|
|
3524
|
+
this.shadowRoot?.querySelector(t)?.focus({ preventScroll: !1 });
|
|
3525
|
+
});
|
|
3526
|
+
}
|
|
3527
|
+
// ============================================
|
|
3528
|
+
// Now Indicator Timer
|
|
3529
|
+
// ============================================
|
|
3530
|
+
startNowIndicatorTimer() {
|
|
3531
|
+
this.nowIndicatorTimer = setInterval(() => {
|
|
3532
|
+
this.currentView?.updateNowIndicator();
|
|
3533
|
+
}, 6e4);
|
|
3534
|
+
}
|
|
3535
|
+
stopNowIndicatorTimer() {
|
|
3536
|
+
this.nowIndicatorTimer !== null && (clearInterval(this.nowIndicatorTimer), this.nowIndicatorTimer = null);
|
|
3537
|
+
}
|
|
3538
|
+
// ============================================
|
|
3539
|
+
// Slot Resolution
|
|
3540
|
+
// ============================================
|
|
3541
|
+
getSlotAtPosition(e, t) {
|
|
3542
|
+
const n = this.shadowRoot.elementsFromPoint(e, t).find(
|
|
3543
|
+
(i) => i.matches(".scheduler-time-slot, .scheduler-timeline-slot")
|
|
3544
|
+
);
|
|
3545
|
+
return n ? this.getSlotFromElement(n) : null;
|
|
3546
|
+
}
|
|
3547
|
+
getSlotFromElement(e) {
|
|
3548
|
+
const t = e.dataset.start, s = e.dataset.end;
|
|
3549
|
+
return !t || !s ? null : {
|
|
3550
|
+
start: new Date(t),
|
|
3551
|
+
end: new Date(s)
|
|
3552
|
+
};
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
typeof customElements < "u" && !customElements.get("mp-scheduler") && customElements.define("mp-scheduler", le);
|
|
3556
|
+
export {
|
|
3557
|
+
x as BaseView,
|
|
3558
|
+
Z as DayView,
|
|
3559
|
+
T as MonthView,
|
|
3560
|
+
le as MpScheduler,
|
|
3561
|
+
Y as SchedulerStateManager,
|
|
3562
|
+
Q as TimelineView,
|
|
3563
|
+
J as WeekView,
|
|
3564
|
+
A as YearView,
|
|
3565
|
+
q as createInitialState,
|
|
3566
|
+
ee as schedulerStyles
|
|
3567
|
+
};
|