@mintplayer/web-components 2.3.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/id-D5QCG603.mjs +940 -0
- package/package.json +1 -1
- package/scheduler/index.mjs +2157 -667
- package/scheduler/src/components/mp-scheduler.d.ts +177 -0
- package/scheduler/src/events/index.d.ts +0 -1
- package/scheduler/src/events/scheduler-event-emitter.d.ts +20 -4
- package/scheduler/src/input/input-handler.d.ts +2 -0
- package/scheduler/src/state/scheduler-state.d.ts +49 -7
- package/scheduler/src/views/base-view.d.ts +49 -6
- package/scheduler/src/views/day-view.d.ts +6 -0
- package/scheduler/src/views/timeline-view.d.ts +98 -1
- package/scheduler/src/views/week-view.d.ts +6 -0
- package/scheduler-core/index.mjs +77 -70
- package/scheduler-core/src/models/events.d.ts +76 -90
- package/scheduler-core/src/models/index.d.ts +2 -0
- package/scheduler-core/src/models/messages.d.ts +103 -0
- package/scheduler-core/src/models/options.d.ts +60 -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/chunks/color-CyamnJnn.mjs +0 -847
- package/scheduler/src/events/event-types.d.ts +0 -58
|
@@ -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
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SchedulerEvent } from '../models/event';
|
|
2
1
|
import { Resource, ResourceGroup, FlattenedResource } from '../models/resource';
|
|
3
2
|
/**
|
|
4
3
|
* Service for resource and resource group operations
|
|
@@ -13,9 +12,12 @@ export declare class ResourceService {
|
|
|
13
12
|
*/
|
|
14
13
|
getAllResources(items: (Resource | ResourceGroup)[]): Resource[];
|
|
15
14
|
/**
|
|
16
|
-
*
|
|
15
|
+
* @deprecated Since the scheduler normalized its event model, events are keyed
|
|
16
|
+
* by `resourceId` in one store — mutating a resource tree's nested `events` no
|
|
17
|
+
* longer drives what any view renders. Set `resourceId` on the event and update
|
|
18
|
+
* the `events` input instead. Unused by the component; kept to avoid a breaking
|
|
19
|
+
* removal, and slated for deletion in the next major.
|
|
17
20
|
*/
|
|
18
|
-
getAllEvents(items: (Resource | ResourceGroup)[]): SchedulerEvent[];
|
|
19
21
|
/**
|
|
20
22
|
* Find a resource by ID
|
|
21
23
|
*/
|
|
@@ -29,21 +31,33 @@ export declare class ResourceService {
|
|
|
29
31
|
*/
|
|
30
32
|
findById(items: (Resource | ResourceGroup)[], id: string): Resource | ResourceGroup | undefined;
|
|
31
33
|
/**
|
|
32
|
-
*
|
|
34
|
+
* @deprecated Since the scheduler normalized its event model, events are keyed
|
|
35
|
+
* by `resourceId` in one store — mutating a resource tree's nested `events` no
|
|
36
|
+
* longer drives what any view renders. Set `resourceId` on the event and update
|
|
37
|
+
* the `events` input instead. Unused by the component; kept to avoid a breaking
|
|
38
|
+
* removal, and slated for deletion in the next major.
|
|
33
39
|
*/
|
|
34
|
-
addEventToResource(items: (Resource | ResourceGroup)[], resourceId: string, event: SchedulerEvent): (Resource | ResourceGroup)[];
|
|
35
40
|
/**
|
|
36
|
-
*
|
|
41
|
+
* @deprecated Since the scheduler normalized its event model, events are keyed
|
|
42
|
+
* by `resourceId` in one store — mutating a resource tree's nested `events` no
|
|
43
|
+
* longer drives what any view renders. Set `resourceId` on the event and update
|
|
44
|
+
* the `events` input instead. Unused by the component; kept to avoid a breaking
|
|
45
|
+
* removal, and slated for deletion in the next major.
|
|
37
46
|
*/
|
|
38
|
-
updateEventInResource(items: (Resource | ResourceGroup)[], event: SchedulerEvent): (Resource | ResourceGroup)[];
|
|
39
47
|
/**
|
|
40
|
-
*
|
|
48
|
+
* @deprecated Since the scheduler normalized its event model, events are keyed
|
|
49
|
+
* by `resourceId` in one store — mutating a resource tree's nested `events` no
|
|
50
|
+
* longer drives what any view renders. Set `resourceId` on the event and update
|
|
51
|
+
* the `events` input instead. Unused by the component; kept to avoid a breaking
|
|
52
|
+
* removal, and slated for deletion in the next major.
|
|
41
53
|
*/
|
|
42
|
-
removeEvent(items: (Resource | ResourceGroup)[], eventId: string): (Resource | ResourceGroup)[];
|
|
43
54
|
/**
|
|
44
|
-
*
|
|
55
|
+
* @deprecated Since the scheduler normalized its event model, events are keyed
|
|
56
|
+
* by `resourceId` in one store — mutating a resource tree's nested `events` no
|
|
57
|
+
* longer drives what any view renders. Set `resourceId` on the event and update
|
|
58
|
+
* the `events` input instead. Unused by the component; kept to avoid a breaking
|
|
59
|
+
* removal, and slated for deletion in the next major.
|
|
45
60
|
*/
|
|
46
|
-
moveEventToResource(items: (Resource | ResourceGroup)[], eventId: string, newResourceId: string, updatedEvent?: Partial<SchedulerEvent>): (Resource | ResourceGroup)[];
|
|
47
61
|
/**
|
|
48
62
|
* Toggle collapse state of a group
|
|
49
63
|
*/
|
|
@@ -22,3 +22,25 @@ export declare function darkenColor(color: string, percent: number): string;
|
|
|
22
22
|
* Add alpha (opacity) to a color
|
|
23
23
|
*/
|
|
24
24
|
export declare function addAlpha(color: string, alpha: number): string;
|
|
25
|
+
/** Fallback event colour when neither the event nor its resource specifies one. */
|
|
26
|
+
export declare const DEFAULT_EVENT_COLOR = "#3788d8";
|
|
27
|
+
/**
|
|
28
|
+
* Resolve an event's fill colour.
|
|
29
|
+
*
|
|
30
|
+
* Precedence — event → resource → component default — matches the universal
|
|
31
|
+
* convention (FullCalendar, Bryntum, Syncfusion, DevExtreme, Mobiscroll, MUI X all
|
|
32
|
+
* agree), and applying a resource's colour in NON-resource views is documented
|
|
33
|
+
* practice rather than an invention.
|
|
34
|
+
*
|
|
35
|
+
* `Resource.eventColor` is the event fill and `Resource.color` the row-header tint
|
|
36
|
+
* (mirroring `ResourceGroup.color`, whose contract is the group header), but we
|
|
37
|
+
* fall back `eventColor ?? color` so a consumer who sets only one still gets
|
|
38
|
+
* sensible behaviour. Both fields had existed in the model read by nothing.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveEventColor(event: {
|
|
41
|
+
color?: string;
|
|
42
|
+
resourceId?: string;
|
|
43
|
+
}, resourceById: Map<string, {
|
|
44
|
+
color?: string;
|
|
45
|
+
eventColor?: string;
|
|
46
|
+
}>, defaultColor?: string): string;
|