@mintplayer/web-components 2.4.0 → 2.5.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/chunks/{color-CpFtrIoX.mjs → id-D5QCG603.mjs} +346 -305
- package/package.json +1 -1
- package/scheduler/index.mjs +1656 -478
- package/scheduler/src/components/mp-scheduler.d.ts +150 -0
- package/scheduler/src/events/index.d.ts +0 -1
- package/scheduler/src/events/scheduler-event-emitter.d.ts +20 -4
- package/scheduler/src/state/scheduler-state.d.ts +49 -7
- package/scheduler/src/views/base-view.d.ts +29 -0
- package/scheduler/src/views/day-view.d.ts +6 -0
- package/scheduler/src/views/timeline-view.d.ts +95 -4
- package/scheduler/src/views/week-view.d.ts +6 -0
- package/scheduler-core/index.mjs +62 -58
- package/scheduler-core/src/models/events.d.ts +76 -90
- package/scheduler-core/src/models/index.d.ts +1 -0
- package/scheduler-core/src/models/messages.d.ts +34 -0
- package/scheduler-core/src/models/options.d.ts +56 -16
- package/scheduler-core/src/models/permissions.d.ts +83 -0
- package/scheduler-core/src/models/time-slot.d.ts +10 -0
- package/scheduler-core/src/services/resource.service.d.ts +25 -11
- package/scheduler-core/src/utils/color.d.ts +22 -0
- package/scheduler/src/events/event-types.d.ts +0 -58
package/scheduler-core/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { D as $, d as C } from "../chunks/
|
|
2
|
-
import { a as
|
|
1
|
+
import { D as $, d as C } from "../chunks/id-D5QCG603.mjs";
|
|
2
|
+
import { a as U, b as V, c as j, e as G, f as X, R as Y, T as q, g as J, h as K, i as Q, j as Z, k as tt, l as et, m as ot, n as st, o as nt, p as it, q as ct, r as rt, s as at, t as lt, u as dt, v as gt, w as ht } from "../chunks/id-D5QCG603.mjs";
|
|
3
3
|
class w {
|
|
4
4
|
/**
|
|
5
5
|
* Calculate position for an event part in week/day view
|
|
6
6
|
*/
|
|
7
|
-
calculateWeekPosition(t, e, s, n,
|
|
8
|
-
const
|
|
7
|
+
calculateWeekPosition(t, e, s, n, i, l = {}) {
|
|
8
|
+
const c = { ...$, ...l };
|
|
9
9
|
new Date(t.start).setHours(0, 0, 0, 0);
|
|
10
|
-
const a = C.getSecondsFromMidnight(t.start), u = C.getSecondsFromMidnight(t.end) - a, [d] =
|
|
10
|
+
const a = C.getSecondsFromMidnight(t.start), u = C.getSecondsFromMidnight(t.end) - a, [d] = c.slotMinTime.split(":").map(Number), [f] = c.slotMaxTime.split(":").map(Number), g = (f - d) * 3600, m = (a - d * 3600) / g * 100, R = u / g * 100, S = 10, p = (100 - S) / i, T = p / s, b = S + n * p + e * T;
|
|
11
11
|
return {
|
|
12
12
|
top: m,
|
|
13
|
-
left:
|
|
13
|
+
left: b,
|
|
14
14
|
width: T,
|
|
15
15
|
height: R,
|
|
16
16
|
zIndex: e + 1
|
|
@@ -19,9 +19,9 @@ class w {
|
|
|
19
19
|
/**
|
|
20
20
|
* Calculate position for an event in timeline view
|
|
21
21
|
*/
|
|
22
|
-
calculateTimelinePosition(t, e, s, n,
|
|
22
|
+
calculateTimelinePosition(t, e, s, n, i, l = {}) {
|
|
23
23
|
({ ...$, ...l });
|
|
24
|
-
const
|
|
24
|
+
const c = i.getTime() - n.getTime(), r = Math.max(t.start.getTime(), n.getTime()), a = Math.min(t.end.getTime(), i.getTime()), h = r - n.getTime(), u = a - r, d = h / c * 100, f = u / c * 100, g = 100 / s;
|
|
25
25
|
return {
|
|
26
26
|
top: e * g,
|
|
27
27
|
left: d,
|
|
@@ -33,8 +33,8 @@ class w {
|
|
|
33
33
|
/**
|
|
34
34
|
* Calculate position for an all-day event in month view
|
|
35
35
|
*/
|
|
36
|
-
calculateMonthEventPosition(t, e, s, n,
|
|
37
|
-
const
|
|
36
|
+
calculateMonthEventPosition(t, e, s, n, i, l = 7) {
|
|
37
|
+
const c = 100 / l, r = 100 / s, a = n * c, h = (i - n + 1) * c;
|
|
38
38
|
return {
|
|
39
39
|
top: e * r,
|
|
40
40
|
left: a,
|
|
@@ -82,12 +82,12 @@ class w {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
const
|
|
86
|
-
function
|
|
85
|
+
const I = new w();
|
|
86
|
+
function P(o, t) {
|
|
87
87
|
const e = Object.entries(t).map(([s, n]) => `[data-${s}="${n}"]`).join("");
|
|
88
88
|
return o.querySelector(e);
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function D(o) {
|
|
91
91
|
const t = o.dataset, e = {};
|
|
92
92
|
for (const s in t) {
|
|
93
93
|
const n = t[s];
|
|
@@ -95,83 +95,87 @@ function z(o) {
|
|
|
95
95
|
}
|
|
96
96
|
return e;
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function L(o, t) {
|
|
99
99
|
return o.closest(`[data-${t}]`);
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function M(o) {
|
|
102
102
|
return {
|
|
103
103
|
top: o.scrollTop,
|
|
104
104
|
left: o.scrollLeft
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
const s = o.getBoundingClientRect(),
|
|
107
|
+
function O(o, t, e = "smooth") {
|
|
108
|
+
const s = o.getBoundingClientRect(), i = t.getBoundingClientRect().top - s.top + o.scrollTop;
|
|
109
109
|
o.scrollTo({
|
|
110
|
-
top:
|
|
110
|
+
top: i,
|
|
111
111
|
behavior: e
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function z(o, t) {
|
|
115
115
|
const e = o.getBoundingClientRect(), s = t ? t.getBoundingClientRect() : { top: 0, left: 0, bottom: window.innerHeight, right: window.innerWidth };
|
|
116
116
|
return e.top >= s.top && e.left >= s.left && e.bottom <= s.bottom && e.right <= s.right;
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function B(o, t) {
|
|
119
119
|
const e = t.getBoundingClientRect(), s = "touches" in o ? o.touches[0].clientX : o.clientX, n = "touches" in o ? o.touches[0].clientY : o.clientY;
|
|
120
120
|
return {
|
|
121
121
|
x: s - e.left,
|
|
122
122
|
y: n - e.top
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function A(o, t, e) {
|
|
126
126
|
o.style.setProperty(`--${t}`, e);
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function W(o, t) {
|
|
129
129
|
return getComputedStyle(o).getPropertyValue(`--${t}`).trim();
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function F(o, ...t) {
|
|
132
132
|
o.classList.add(...t.filter(Boolean));
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function _(o, ...t) {
|
|
135
135
|
o.classList.remove(...t.filter(Boolean));
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function k(o, t, e) {
|
|
138
138
|
o.classList.toggle(t, e);
|
|
139
139
|
}
|
|
140
140
|
export {
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
U as DEFAULT_COLORS,
|
|
142
|
+
V as DEFAULT_EVENT_COLOR,
|
|
143
|
+
j as DEFAULT_MESSAGES,
|
|
143
144
|
$ as DEFAULT_OPTIONS,
|
|
144
|
-
|
|
145
|
+
G as DEFAULT_PERMISSIONS,
|
|
146
|
+
X as DateService,
|
|
145
147
|
w as PositionService,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
Y as ResourceService,
|
|
149
|
+
q as TimelineService,
|
|
150
|
+
J as addAlpha,
|
|
151
|
+
F as addClasses,
|
|
152
|
+
K as darkenColor,
|
|
151
153
|
C as dateService,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
154
|
+
L as findClosestWithData,
|
|
155
|
+
Q as formatMessage,
|
|
156
|
+
Z as generateEventId,
|
|
157
|
+
tt as generateGroupId,
|
|
158
|
+
et as generateId,
|
|
159
|
+
ot as generateResourceId,
|
|
160
|
+
W as getCSSVariable,
|
|
161
|
+
st as getColorByIndex,
|
|
162
|
+
nt as getContrastColor,
|
|
163
|
+
D as getDataAttributes,
|
|
164
|
+
P as getElementByData,
|
|
165
|
+
B as getRelativePosition,
|
|
166
|
+
M as getScrollPosition,
|
|
167
|
+
z as isInViewport,
|
|
168
|
+
it as isResource,
|
|
169
|
+
ct as isResourceGroup,
|
|
170
|
+
rt as lightenColor,
|
|
171
|
+
I as positionService,
|
|
172
|
+
_ as removeClasses,
|
|
173
|
+
at as resolveCapability,
|
|
174
|
+
lt as resolveEventColor,
|
|
175
|
+
dt as resolveMessages,
|
|
176
|
+
gt as resourceService,
|
|
177
|
+
O as scrollToTime,
|
|
178
|
+
A as setCSSVariable,
|
|
179
|
+
ht as timelineService,
|
|
180
|
+
k as toggleClass
|
|
177
181
|
};
|
|
@@ -1,108 +1,94 @@
|
|
|
1
1
|
import { SchedulerEvent } from './event';
|
|
2
|
-
import { Resource } from './resource';
|
|
2
|
+
import { Resource, ResourceGroup } from './resource';
|
|
3
3
|
import { ViewType } from './types';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Time range carried by `selection-change` and `event-create`. `start` is the
|
|
6
|
+
* inclusive lower edge, `end` is the exclusive upper edge of the last selected
|
|
7
|
+
* slot — matching the natural slot-pair shape produced by `selectionRange()`
|
|
8
|
+
* in `views/base-view.ts`.
|
|
6
9
|
*/
|
|
7
|
-
export interface
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
export interface TimeRange {
|
|
11
|
+
start: Date;
|
|
12
|
+
end: Date;
|
|
10
13
|
}
|
|
11
14
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
+
* Every custom event `mp-scheduler` can emit, as one discriminated union.
|
|
16
|
+
*
|
|
17
|
+
* This union is the SINGLE source of truth for the event surface: the emitter
|
|
18
|
+
* accepts it, `EventDetail<T>` derives each payload from it, and
|
|
19
|
+
* `SchedulerEventMap` is a mechanical mapping of it. A second hand-written
|
|
20
|
+
* table drifts — the previous one had grown a `date-select` entry nothing
|
|
21
|
+
* emitted and a `date-click` resource field nothing sent.
|
|
22
|
+
*
|
|
23
|
+
* Every event bubbles AND is composed, so a scheduler nested inside another
|
|
24
|
+
* component's shadow root still reaches the outer consumer.
|
|
15
25
|
*/
|
|
16
|
-
export
|
|
17
|
-
|
|
26
|
+
export type SchedulerCustomEvent = {
|
|
27
|
+
type: 'event-selected';
|
|
18
28
|
event: SchedulerEvent;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
range: {
|
|
28
|
-
start: Date;
|
|
29
|
-
end: Date;
|
|
30
|
-
};
|
|
31
|
-
/** Resource the request targets (timeline view only). */
|
|
32
|
-
resourceId?: string;
|
|
33
|
-
/** View that produced the request. */
|
|
34
|
-
view: ViewType;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Selection-change detail. Fires on every transition — including the
|
|
38
|
-
* transition to an empty selection. `selectedEvent` and `range` are
|
|
39
|
-
* independent dimensions of the selection state.
|
|
40
|
-
*/
|
|
41
|
-
export interface SelectionChangeDetail {
|
|
42
|
-
selectedEvent: SchedulerEvent | null;
|
|
43
|
-
range: {
|
|
44
|
-
start: Date;
|
|
45
|
-
end: Date;
|
|
46
|
-
} | null;
|
|
29
|
+
originalEvent: Event;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'event-dblclick';
|
|
32
|
+
event: SchedulerEvent;
|
|
33
|
+
originalEvent: Event;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'event-create';
|
|
36
|
+
range: TimeRange;
|
|
47
37
|
view: ViewType;
|
|
48
38
|
resourceId?: string;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*/
|
|
53
|
-
export interface EventUpdateDetail extends BaseEventDetail {
|
|
54
|
-
/** The updated event */
|
|
39
|
+
originalEvent: Event;
|
|
40
|
+
} | {
|
|
41
|
+
type: 'event-update';
|
|
55
42
|
event: SchedulerEvent;
|
|
56
|
-
/** The event before the update */
|
|
57
43
|
oldEvent: SchedulerEvent;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
*/
|
|
62
|
-
export interface EventDeleteDetail extends BaseEventDetail {
|
|
63
|
-
/** The deleted event */
|
|
44
|
+
originalEvent: Event;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'event-delete';
|
|
64
47
|
event: SchedulerEvent;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
* Date click event detail
|
|
68
|
-
*/
|
|
69
|
-
export interface DateClickDetail extends BaseEventDetail {
|
|
70
|
-
/** The clicked date */
|
|
48
|
+
} | {
|
|
49
|
+
type: 'date-click';
|
|
71
50
|
date: Date;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Date select event detail
|
|
77
|
-
*/
|
|
78
|
-
export interface DateSelectDetail extends BaseEventDetail {
|
|
79
|
-
/** Start of the selected range */
|
|
80
|
-
start: Date;
|
|
81
|
-
/** End of the selected range */
|
|
82
|
-
end: Date;
|
|
83
|
-
/** Resource at the selected location (if applicable) */
|
|
84
|
-
resource?: Resource;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* View change event detail
|
|
88
|
-
*/
|
|
89
|
-
export interface ViewChangeDetail {
|
|
90
|
-
/** The new view */
|
|
51
|
+
originalEvent: Event;
|
|
52
|
+
} | {
|
|
53
|
+
type: 'view-change';
|
|
91
54
|
view: ViewType;
|
|
92
|
-
/** The current date in the new view */
|
|
93
55
|
date: Date;
|
|
94
|
-
}
|
|
56
|
+
} | {
|
|
57
|
+
type: 'selection-change';
|
|
58
|
+
selectedEvent: SchedulerEvent | null;
|
|
59
|
+
range: TimeRange | null;
|
|
60
|
+
view: ViewType;
|
|
61
|
+
resourceId?: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: 'resource-create';
|
|
64
|
+
parentId?: string;
|
|
65
|
+
view: ViewType;
|
|
66
|
+
originalEvent: Event;
|
|
67
|
+
} | {
|
|
68
|
+
type: 'group-create';
|
|
69
|
+
parentId?: string;
|
|
70
|
+
view: ViewType;
|
|
71
|
+
originalEvent: Event;
|
|
72
|
+
} | {
|
|
73
|
+
type: 'resource-update';
|
|
74
|
+
resource: Resource | ResourceGroup;
|
|
75
|
+
changes: Partial<Resource & ResourceGroup>;
|
|
76
|
+
originalEvent: Event;
|
|
77
|
+
} | {
|
|
78
|
+
type: 'resource-delete';
|
|
79
|
+
resource: Resource | ResourceGroup;
|
|
80
|
+
originalEvent: Event;
|
|
81
|
+
};
|
|
95
82
|
/**
|
|
96
|
-
*
|
|
83
|
+
* Payload of one scheduler event — the union arm minus its discriminant.
|
|
97
84
|
*/
|
|
98
|
-
export
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
'
|
|
107
|
-
|
|
108
|
-
}
|
|
85
|
+
export type EventDetail<T extends SchedulerCustomEvent['type']> = Omit<Extract<SchedulerCustomEvent, {
|
|
86
|
+
type: T;
|
|
87
|
+
}>, 'type'>;
|
|
88
|
+
/**
|
|
89
|
+
* `HTMLElementEventMap`-shaped view of the union, for `addEventListener`
|
|
90
|
+
* typing in consumer code.
|
|
91
|
+
*/
|
|
92
|
+
export type SchedulerEventMap = {
|
|
93
|
+
[T in SchedulerCustomEvent['type']]: CustomEvent<EventDetail<T>>;
|
|
94
|
+
};
|
|
@@ -18,14 +18,43 @@ export interface SchedulerMessages {
|
|
|
18
18
|
viewDay: string;
|
|
19
19
|
viewTimeline: string;
|
|
20
20
|
resourcesHeader: string;
|
|
21
|
+
/** Row header for the synthetic bucket holding events with no resource. */
|
|
22
|
+
unassignedResource: string;
|
|
23
|
+
/** Shown in the timeline when there are no resources AND no events at all. */
|
|
24
|
+
noResources: string;
|
|
21
25
|
/** {date} — formatted first day of the visible week */
|
|
22
26
|
timelineGridLabel: string;
|
|
23
27
|
/** {title} — resource group title */
|
|
24
28
|
expandGroup: string;
|
|
25
29
|
/** {title} — resource group title */
|
|
26
30
|
collapseGroup: string;
|
|
31
|
+
/** Toolbar at the foot of the resource column. */
|
|
32
|
+
addResourceBarLabel: string;
|
|
33
|
+
addResource: string;
|
|
34
|
+
addGroup: string;
|
|
35
|
+
/** {title} — every per-row action names its row, so N buttons aren't all "Add". */
|
|
36
|
+
addResourceToGroup: string;
|
|
37
|
+
/** {title} */
|
|
38
|
+
addGroupToGroup: string;
|
|
39
|
+
/** {title} */
|
|
40
|
+
removeResource: string;
|
|
41
|
+
/** {title} */
|
|
42
|
+
resourceColor: string;
|
|
27
43
|
/** {count} — number of hidden events */
|
|
28
44
|
moreEvents: string;
|
|
45
|
+
/** {date} — accessible name of the day popover dialog */
|
|
46
|
+
dayPopoverLabel: string;
|
|
47
|
+
/** {count} {events} — events is eventSingular/eventPlural */
|
|
48
|
+
dayPopoverCount: string;
|
|
49
|
+
eventSingular: string;
|
|
50
|
+
eventPlural: string;
|
|
51
|
+
/** Empty-day text inside the popover. */
|
|
52
|
+
dayPopoverEmpty: string;
|
|
53
|
+
/** Primary action in the popover: request an event for this day. */
|
|
54
|
+
newEvent: string;
|
|
55
|
+
/** Secondary action: drill into the day view. */
|
|
56
|
+
showDay: string;
|
|
57
|
+
closePopover: string;
|
|
29
58
|
/** {view} — localized view name */
|
|
30
59
|
viewChanged: string;
|
|
31
60
|
/** {title} */
|
|
@@ -56,6 +85,11 @@ export interface SchedulerMessages {
|
|
|
56
85
|
selectionCommitted: string;
|
|
57
86
|
gridInstructions: string;
|
|
58
87
|
eventInstructions: string;
|
|
88
|
+
/** Read-only variants: no create/move/resize/delete promises. */
|
|
89
|
+
gridInstructionsReadOnly: string;
|
|
90
|
+
eventInstructionsReadOnly: string;
|
|
91
|
+
/** Announced when a command is refused by permissions. */
|
|
92
|
+
actionNotAllowed: string;
|
|
59
93
|
/** {resource} */
|
|
60
94
|
eventOnResource: string;
|
|
61
95
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { SchedulerMessages } from './messages';
|
|
2
|
+
import { SchedulerPermissions } from './permissions';
|
|
2
3
|
import { DayOfWeek, TimeFormat, ViewType } from './types';
|
|
4
|
+
import { SchedulerEvent } from './event';
|
|
3
5
|
/**
|
|
4
6
|
* Business hours configuration
|
|
5
7
|
*/
|
|
@@ -58,25 +60,24 @@ export interface SchedulerOptions {
|
|
|
58
60
|
expandRows?: boolean;
|
|
59
61
|
/** Header toolbar configuration */
|
|
60
62
|
headerToolbar?: HeaderToolbar;
|
|
61
|
-
/** Whether events can be edited */
|
|
62
|
-
editable?: boolean;
|
|
63
|
-
/** Whether date ranges can be selected */
|
|
64
|
-
selectable?: boolean;
|
|
65
|
-
/** Whether to show a mirror element during selection */
|
|
66
|
-
selectMirror?: boolean;
|
|
67
|
-
/** Whether event duration can be changed */
|
|
68
|
-
eventDurationEditable?: boolean;
|
|
69
|
-
/** Whether event start time can be changed */
|
|
70
|
-
eventStartEditable?: boolean;
|
|
71
|
-
/** Duration of revert animation in ms */
|
|
72
|
-
dragRevertDuration?: number;
|
|
73
|
-
/** Whether to scroll during drag */
|
|
74
|
-
dragScroll?: boolean;
|
|
75
|
-
/** Snap duration in seconds */
|
|
76
|
-
snapDuration?: number;
|
|
77
63
|
/** Override any user-facing string (labels, announcements, instructions).
|
|
78
64
|
* Merged onto the English defaults — see SchedulerMessages. */
|
|
79
65
|
messages?: Partial<SchedulerMessages>;
|
|
66
|
+
/**
|
|
67
|
+
* What the user may do. `false` makes the scheduler read-only; an object gives
|
|
68
|
+
* per-capability control. See SchedulerPermissions — it gates AFFORDANCES and
|
|
69
|
+
* gestures, it is not a security boundary.
|
|
70
|
+
*
|
|
71
|
+
* Replaced the old `editable` / `selectable` / `eventStartEditable` /
|
|
72
|
+
* `eventDurationEditable` flags, and the never-implemented `selectMirror`,
|
|
73
|
+
* `dragRevertDuration`, `dragScroll` and `snapDuration`.
|
|
74
|
+
*/
|
|
75
|
+
permissions?: boolean | Partial<SchedulerPermissions>;
|
|
76
|
+
/**
|
|
77
|
+
* Fill colour for events that specify none and whose resource specifies none.
|
|
78
|
+
* Previously a `'#3788d8'` literal duplicated across five files.
|
|
79
|
+
*/
|
|
80
|
+
defaultEventColor?: string;
|
|
80
81
|
/** Whether to show current time indicator */
|
|
81
82
|
nowIndicator?: boolean;
|
|
82
83
|
/** Whether to show week numbers */
|
|
@@ -85,7 +86,46 @@ export interface SchedulerOptions {
|
|
|
85
86
|
weekText?: string;
|
|
86
87
|
/** Maximum events to show per day (true = show "+X more" link) */
|
|
87
88
|
dayMaxEvents?: boolean | number;
|
|
89
|
+
/**
|
|
90
|
+
* What the month view's "+N more" link does.
|
|
91
|
+
*
|
|
92
|
+
* - `'popover'` (default, FullCalendar's default too) — open the day popover
|
|
93
|
+
* listing every event on that day.
|
|
94
|
+
* - `'day'` — the previous behaviour: navigate to the day view.
|
|
95
|
+
* - a function — you handle it; nothing else happens.
|
|
96
|
+
*/
|
|
97
|
+
moreLinkBehavior?: MoreLinkBehavior;
|
|
98
|
+
/**
|
|
99
|
+
* What clicking a month day CELL does, beyond emitting `date-click`.
|
|
100
|
+
*
|
|
101
|
+
* Defaults to `'none'` so the `date-click` contract is unchanged for existing
|
|
102
|
+
* consumers; set `'popover'` for the "click a date to see and add events"
|
|
103
|
+
* behaviour. Clicking the day NUMBER always drills into the day view (the
|
|
104
|
+
* navLinks idiom) and is deliberately a separate target: conflating the two
|
|
105
|
+
* would make an empty cell unable to mean "create here".
|
|
106
|
+
*/
|
|
107
|
+
dayClickAction?: 'none' | 'popover';
|
|
108
|
+
/**
|
|
109
|
+
* Whether every event is expected to name a resource.
|
|
110
|
+
*
|
|
111
|
+
* Default `false`: an event with no `resourceId` renders in the timeline's
|
|
112
|
+
* "(No resource)" bucket row, which is the only non-lossy behaviour — the two
|
|
113
|
+
* alternatives the industry ships are both silent data traps (hide the event,
|
|
114
|
+
* or duplicate it into every lane where editing one appears to edit all).
|
|
115
|
+
*
|
|
116
|
+
* Set `true` in an app where a resource is mandatory: resource-less events are
|
|
117
|
+
* still bucketed and still visible, but each one is reported once via a dev
|
|
118
|
+
* warning so the gap surfaces during development instead of as a support
|
|
119
|
+
* ticket. It never hides an event, and it is not a validation error — the
|
|
120
|
+
* component does not own the data.
|
|
121
|
+
*/
|
|
122
|
+
requireEventResource?: boolean;
|
|
88
123
|
}
|
|
124
|
+
/** See `SchedulerOptions.moreLinkBehavior`. */
|
|
125
|
+
export type MoreLinkBehavior = 'popover' | 'day' | ((info: {
|
|
126
|
+
date: Date;
|
|
127
|
+
events: SchedulerEvent[];
|
|
128
|
+
}) => void);
|
|
89
129
|
/**
|
|
90
130
|
* Default options for the scheduler
|
|
91
131
|
*/
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { SchedulerEvent } from './event';
|
|
2
|
+
/**
|
|
3
|
+
* What a user may do in the scheduler.
|
|
4
|
+
*
|
|
5
|
+
* Shape follows the dominant convention (DevExtreme `editing`, Kendo `editable`):
|
|
6
|
+
* a `boolean | object` union, so `permissions: false` expresses the single most
|
|
7
|
+
* common request — make it read-only — without spelling out ten flags, while the
|
|
8
|
+
* object form covers "move but don't resize".
|
|
9
|
+
*
|
|
10
|
+
* **This is an honesty API, not a security boundary.** The component never mutates
|
|
11
|
+
* consumer data: `event-create` is a request, `event-delete` a notification, and
|
|
12
|
+
* `event-update` pre-mutates only internal state so a committed drag doesn't snap
|
|
13
|
+
* back. A consumer already refuses anything by not acting on a request. Permissions
|
|
14
|
+
* exist so the UI doesn't offer, announce or document actions that cannot succeed.
|
|
15
|
+
* Do not rely on them to protect data — authorize on your own side.
|
|
16
|
+
*/
|
|
17
|
+
export interface SchedulerPermissions {
|
|
18
|
+
/** Drag/keyboard-create a new event, and Enter on a cell or selection. */
|
|
19
|
+
createEvent: boolean;
|
|
20
|
+
/** Move an existing event in time (or across resources on the timeline). */
|
|
21
|
+
moveEvent: boolean;
|
|
22
|
+
/** Drag/keyboard the START edge. Supersedes the never-implemented `eventStartEditable`. */
|
|
23
|
+
resizeEventStart: boolean;
|
|
24
|
+
/** Drag/keyboard the END edge. Supersedes the never-implemented `eventDurationEditable`. */
|
|
25
|
+
resizeEventEnd: boolean;
|
|
26
|
+
/** Delete/Backspace on a focused event. */
|
|
27
|
+
deleteEvent: boolean;
|
|
28
|
+
/** Extend a multi-cell time range with Shift+Arrow or a slot drag. */
|
|
29
|
+
selectRange: boolean;
|
|
30
|
+
/** Add a resource row (timeline). Off by default — see the PRD. */
|
|
31
|
+
createResource: boolean;
|
|
32
|
+
/** Rename/recolour a resource (timeline). */
|
|
33
|
+
updateResource: boolean;
|
|
34
|
+
/** Remove a resource row (timeline). */
|
|
35
|
+
deleteResource: boolean;
|
|
36
|
+
/** Add a resource group / nested group (timeline). Off by default. */
|
|
37
|
+
createGroup: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Optional, data-dependent veto for creation only — e.g. "not in the past",
|
|
40
|
+
* "not on a locked resource".
|
|
41
|
+
*
|
|
42
|
+
* Deliberately narrow: it runs ONLY at pointer-down, drag completion and
|
|
43
|
+
* `Enter` commit — never per cell and never per pointer-move. Driving the
|
|
44
|
+
* greyed-slot feedback from it would mean a consumer callback per cell
|
|
45
|
+
* (`resources x days x slotsPerDay`) on every re-render, which is the cost
|
|
46
|
+
* FullCalendar documents for `selectAllow`. Slot greying is NOT driven by it.
|
|
47
|
+
*/
|
|
48
|
+
canCreateAt?: (range: {
|
|
49
|
+
start: Date;
|
|
50
|
+
end: Date;
|
|
51
|
+
}, resourceId?: string) => boolean;
|
|
52
|
+
}
|
|
53
|
+
/** Every capability name, for iteration. */
|
|
54
|
+
export type SchedulerCapability = Exclude<keyof SchedulerPermissions, 'canCreateAt'>;
|
|
55
|
+
/**
|
|
56
|
+
* Defaults: everything about events is allowed (matching the component's
|
|
57
|
+
* behaviour before permissions existed), but creating resources and groups is
|
|
58
|
+
* OFF — no surveyed calendar library ships resource-creation UI, so the default
|
|
59
|
+
* stays "resources are data the app supplies".
|
|
60
|
+
*/
|
|
61
|
+
export declare const DEFAULT_PERMISSIONS: Readonly<Record<SchedulerCapability, boolean>>;
|
|
62
|
+
/** Per-item overrides live on the data, tri-state so `null` means "inherit". */
|
|
63
|
+
export interface ItemPermissionOverrides {
|
|
64
|
+
editable?: boolean | null;
|
|
65
|
+
draggable?: boolean | null;
|
|
66
|
+
resizable?: boolean | {
|
|
67
|
+
start: boolean;
|
|
68
|
+
end: boolean;
|
|
69
|
+
} | null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Resolve one capability.
|
|
73
|
+
*
|
|
74
|
+
* Precedence: `readonly` host attribute → `permissions === false` →
|
|
75
|
+
* `permissions[cap]` → per-item override → default. A per-item flag can only
|
|
76
|
+
* ever *deny*; it cannot re-enable something a global setting switched off,
|
|
77
|
+
* mirroring the OR-down-the-tree rule mp-query-builder uses for nested disable.
|
|
78
|
+
*/
|
|
79
|
+
export declare function resolveCapability(capability: SchedulerCapability, opts: {
|
|
80
|
+
readonly?: boolean;
|
|
81
|
+
permissions?: boolean | Partial<SchedulerPermissions>;
|
|
82
|
+
event?: SchedulerEvent | null;
|
|
83
|
+
}): boolean;
|
|
@@ -6,6 +6,16 @@ export interface TimeSlot {
|
|
|
6
6
|
start: Date;
|
|
7
7
|
/** End of the time slot */
|
|
8
8
|
end: Date;
|
|
9
|
+
/**
|
|
10
|
+
* Resource the slot belongs to, for views with a resource axis (timeline).
|
|
11
|
+
*
|
|
12
|
+
* Carried so a pointer create-drag can report WHICH row it happened in:
|
|
13
|
+
* without it `event-create` always emitted `resourceId: undefined`, and the
|
|
14
|
+
* created event landed nowhere the user was pointing. `undefined` on
|
|
15
|
+
* week/day/month/year, which have no resource axis, and on the timeline's
|
|
16
|
+
* unassigned bucket row.
|
|
17
|
+
*/
|
|
18
|
+
resourceId?: string;
|
|
9
19
|
}
|
|
10
20
|
/**
|
|
11
21
|
* A row of time slots with associated metadata
|