@mintplayer/web-components 2.4.0 → 2.7.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.
Files changed (54) hide show
  1. package/a11y/index.mjs +9 -8
  2. package/checkbox/index.mjs +1 -1
  3. package/chunks/error-text-B45eDAt1.mjs +17 -0
  4. package/chunks/{form-associated-axmc5sY0.mjs → form-associated-BR-fUvZ1.mjs} +11 -26
  5. package/chunks/{color-CpFtrIoX.mjs → id-BstjfRrz.mjs} +383 -317
  6. package/chunks/{mp-checkbox-Ph2mMRGz.mjs → mp-checkbox-6EJwdUIn.mjs} +6 -5
  7. package/chunks/{mp-datatable-BwTlh9A_.mjs → mp-datatable-25O1GtvU.mjs} +1 -1
  8. package/chunks/mp-datetime-picker.element-MPTRHwyc.mjs +530 -0
  9. package/chunks/{mp-radio-BjW1HNSc.mjs → mp-radio-DvKgrTFL.mjs} +2 -2
  10. package/chunks/{mp-select-Ctu-v1-p.mjs → mp-select-CKX0eM5C.mjs} +5 -4
  11. package/chunks/{mp-timepicker.element-Bz393NDQ.mjs → mp-timepicker.element-COZEUIoE.mjs} +56 -52
  12. package/chunks/{mp-toggle-button-Kz6sIgBJ.mjs → mp-toggle-button-C4Loq_p4.mjs} +5 -4
  13. package/chunks/{overlay-controller-DPt13i8p.mjs → overlay-controller-D6agzzOI.mjs} +19 -4
  14. package/datatable/index.mjs +1 -1
  15. package/datepicker/index.mjs +1 -1
  16. package/datetime-picker/index.mjs +2 -431
  17. package/datetime-picker/src/mp-datetime-picker.element.d.ts +66 -0
  18. package/file-manager/index.mjs +1 -1
  19. package/navbar/index.mjs +1 -1
  20. package/otp-input/index.mjs +4 -3
  21. package/overlay/index.mjs +1 -1
  22. package/overlay/src/overlay-controller.d.ts +13 -0
  23. package/package.json +1 -1
  24. package/query-builder/index.mjs +2 -2
  25. package/radio/index.mjs +1 -1
  26. package/radio-group/index.mjs +2 -2
  27. package/ribbon/index.mjs +1 -1
  28. package/scheduler/index.mjs +3243 -882
  29. package/scheduler/src/components/mp-scheduler.d.ts +410 -2
  30. package/scheduler/src/events/index.d.ts +0 -1
  31. package/scheduler/src/events/scheduler-event-emitter.d.ts +20 -4
  32. package/scheduler/src/state/scheduler-state.d.ts +59 -7
  33. package/scheduler/src/views/base-view.d.ts +29 -0
  34. package/scheduler/src/views/day-view.d.ts +6 -0
  35. package/scheduler/src/views/timeline-view.d.ts +143 -4
  36. package/scheduler/src/views/week-view.d.ts +6 -0
  37. package/scheduler/src/views/year-view.d.ts +4 -2
  38. package/scheduler-core/index.mjs +63 -58
  39. package/scheduler-core/src/models/event.d.ts +6 -2
  40. package/scheduler-core/src/models/events.d.ts +76 -90
  41. package/scheduler-core/src/models/index.d.ts +1 -0
  42. package/scheduler-core/src/models/messages.d.ts +94 -0
  43. package/scheduler-core/src/models/options.d.ts +72 -16
  44. package/scheduler-core/src/models/permissions.d.ts +114 -0
  45. package/scheduler-core/src/models/time-slot.d.ts +15 -0
  46. package/scheduler-core/src/services/resource.service.d.ts +25 -11
  47. package/scheduler-core/src/utils/color.d.ts +22 -0
  48. package/select/index.mjs +1 -1
  49. package/timepicker/index.mjs +4 -3
  50. package/timepicker/src/mp-time-list.element.d.ts +44 -7
  51. package/timepicker/src/mp-timepicker.element.d.ts +5 -0
  52. package/toggle-button/index.mjs +1 -1
  53. package/tree-select/index.mjs +1 -1
  54. package/scheduler/src/events/event-types.d.ts +0 -58
@@ -20,6 +20,12 @@ export declare class DayView extends BaseView {
20
20
  update(state: SchedulerState): void;
21
21
  private optionsRequireRerender;
22
22
  private updateGreyedSlots;
23
+ /**
24
+ * Dashed ghost for the day currently shown. A multi-day range contributes at
25
+ * most one part here, but it must still be CLIPPED to this day rather than
26
+ * skipped: bailing unless the range *started* today meant dragging in from
27
+ * yesterday drew no feedback at all.
28
+ */
23
29
  private renderPreviewEvent;
24
30
  destroy(): void;
25
31
  }
@@ -5,8 +5,37 @@ import { SchedulerState } from '../state/scheduler-state';
5
5
  */
6
6
  export declare class TimelineView extends BaseView {
7
7
  private rowElements;
8
- private slotWidth;
8
+ /** Focus key captured just before a rebuild; see `restoreActionFocus`. */
9
+ private pendingFocusKey;
10
+ /**
11
+ * Slot width in px. Read from `--scheduler-slot-width` so consumers can shorten
12
+ * a default week (48 slots x 7 days x 50px = 16,800px); falls back to 50.
13
+ */
14
+ private get slotWidth();
15
+ /**
16
+ * Track geometry for the timeline, in px, from the CSS custom properties so a
17
+ * consumer can retune density without forking the view.
18
+ *
19
+ * The timeline is the one view where vertical space is NOT the time axis —
20
+ * time runs horizontally and the panel scrolls — so an event's height carries
21
+ * no information. Overlapping events therefore STACK at a constant height and
22
+ * grow their resource row, instead of dividing a fixed 40px row between them
23
+ * the way week/day must (there, height IS duration).
24
+ */
25
+ private get trackMetrics();
9
26
  render(): void;
27
+ /**
28
+ * Focus key of an action control: what it does plus which row it belongs to.
29
+ * Stable across a rebuild (unlike DOM position), and unique per control.
30
+ */
31
+ private actionFocusKey;
32
+ /**
33
+ * Remember which action control the user was on, if any, before a rebuild.
34
+ * `activeElement` of the shadow root — the host's `document.activeElement` is
35
+ * the `<mp-scheduler>` element itself, not the button inside it.
36
+ */
37
+ private captureActionFocus;
38
+ private restoreActionFocus;
10
39
  /**
11
40
  * Apply roving tabindex + aria-selected + `.selected` class to each
12
41
  * timeline-slot element. Selection is constrained to the resource pinned
@@ -14,14 +43,124 @@ export declare class TimelineView extends BaseView {
14
43
  */
15
44
  private updateCellFocusAndSelection;
16
45
  private createResourceRow;
46
+ /**
47
+ * Whether the synthetic bucket row renders: only when something is actually
48
+ * unassigned, so a fully-assigned timeline shows no phantom row.
49
+ */
50
+ private hasUnassignedRow;
51
+ /** Narrowest useful column; below this the titles are gone anyway. */
52
+ private static readonly MIN_COLUMN_PX;
53
+ /** The AG-Grid guard: the frozen column may never leave less than this. */
54
+ private static readonly MIN_GRID_PX;
55
+ private columnDrag;
56
+ private boundColumnDragMove;
57
+ private boundColumnDragEnd;
58
+ /**
59
+ * The WAI-ARIA window-splitter on the resource column's right edge — the
60
+ * same pattern as the repo's splitter. It writes
61
+ * `--scheduler-resource-column-width` on the scroll container, which is the
62
+ * exact channel the consumer configures, so their own value stays the
63
+ * initial and every rule reading the custom property follows for free. The
64
+ * inline style survives view rebuilds AND view switches (clearContainer
65
+ * strips classes and ARIA, not inline style), which is what makes the
66
+ * user's chosen width sticky.
67
+ *
68
+ * Lives inside the corner columnheader, OUTSIDE the `role="grid"` focus
69
+ * model (same reasoning as the add bar, §11.2): a separator is not a grid
70
+ * cell, and a Tab stop inside a roving-tabindex grid is a trap.
71
+ */
72
+ private createColumnResizer;
73
+ private currentColumnWidth;
74
+ private maxColumnWidth;
75
+ private applyColumnWidth;
76
+ /** aria-valuenow as a percentage of the scroller, per the splitter pattern. */
77
+ private updateResizerValue;
78
+ private onColumnDragMove;
79
+ private onColumnDragEnd;
80
+ /** True when the capability is granted for the whole scheduler. */
81
+ private can;
82
+ /**
83
+ * Per-row resource actions, rendered into the pinned rowheader cell.
84
+ *
85
+ * A denied action is ABSENT, not disabled: `createResource`/`createGroup`/
86
+ * `updateResource`/`deleteResource` are all off by default, so the ordinary
87
+ * scheduler shows none of this and only an app that manages its own resource
88
+ * tree opts in. (A permanently-disabled button is noise for sighted users and
89
+ * a broken promise for AT — the same rule mp-file-manager follows.)
90
+ *
91
+ * Every name carries the row title. N buttons all called "Add" is the classic
92
+ * failure of a tree like this: a screen-reader user hears the same name on
93
+ * every row and cannot tell which group they are adding to. Depth stays out of
94
+ * it entirely — `aria-level` is invalid on these roles, so nesting is conveyed
95
+ * by the name and the indent, not by an attribute axe flags.
96
+ */
97
+ private appendResourceActions;
98
+ /**
99
+ * One icon button. The glyph is `aria-hidden` and the name lives on the
100
+ * button, so the accessible name is the localized sentence rather than "+".
101
+ */
102
+ private createResourceAction;
103
+ /**
104
+ * Native `<input type="color">` for the resource's colour — the recolour half
105
+ * of R7. Native because it is keyboard-operable, localized and screen-reader
106
+ * labelled by the platform for free; a custom swatch grid would have to
107
+ * re-earn all three.
108
+ *
109
+ * It edits whichever field actually drives the rendered events: `eventColor`
110
+ * wins over `color` in `resolveEventColor`, so writing `color` on a resource
111
+ * that has an `eventColor` would look like the control did nothing.
112
+ */
113
+ private createColorSwatch;
114
+ /**
115
+ * Root-level "Add resource" / "Add group" bar, pinned to the bottom of the
116
+ * frozen resource column (the spreadsheet/Jira idiom: creation lives at the
117
+ * end of the list, in the column the new row will appear in).
118
+ *
119
+ * Deliberately a sibling of the grid, not a row inside it: a row whose only
120
+ * content is buttons has to fake a rowheader, inflates `aria-rowcount`, and
121
+ * puts Tab stops inside a roving-tabindex grid. Outside, it is just a toolbar.
122
+ */
123
+ private createAddBar;
124
+ /**
125
+ * The "(No resource)" bucket row.
126
+ *
127
+ * Structurally identical to a resource row so keyboard nav, roving tabindex and
128
+ * the grid ARIA chain all treat it as one more row — but its slots carry
129
+ * `data-unassigned` instead of a `data-resource-id`, so a drag addressing this
130
+ * row resolves to the tri-state `resourceId: null` ("the bucket") rather than
131
+ * `undefined` ("no resource axis"). An absent attribute could not carry that
132
+ * distinction — it would read exactly like a week-view slot, and a drop here
133
+ * could never mean "unassign".
134
+ */
135
+ private createUnassignedRow;
17
136
  private renderEvents;
18
137
  private createEventElement;
19
138
  /**
20
- * Dashed ghost showing where the dragged event will land, rendered in the
21
- * dragged event's own resource row (pointer drags don't change resource).
22
- * Mirrors week-view.renderPreviewEvent for the horizontal axis.
139
+ * Dashed ghost showing where the event will land. Mirrors
140
+ * week-view.renderPreviewEvent for the horizontal axis.
141
+ *
142
+ * Gated on `previewEvent` alone — NOT on `dragState`, which only the pointer
143
+ * drag path writes. Keyboard move-mode sets `previewEvent` with no
144
+ * `dragState`, so requiring it hid the ghost from keyboard users on this
145
+ * view while week/day showed it.
23
146
  */
24
147
  private renderPreviewEvent;
148
+ /**
149
+ * Which row a drag/preview is currently addressing.
150
+ *
151
+ * Precedence: the preview's own row (a MOVE tracks the pointer's row; a
152
+ * move-mode Up/Down nudge writes it too — `null` meaning the bucket row) →
153
+ * the dragged event's own row (a resize never changes rows, and its preview
154
+ * deliberately carries none) → the row the gesture is happening in (a CREATE
155
+ * has no source event; without this fallback a create-drag showed no
156
+ * feedback at all).
157
+ *
158
+ * The dragged event is resolved from the NORMALIZED store, not
159
+ * `resource.events` — that nested array stopped being a live mirror when the
160
+ * model was normalized, so the old lookup found nothing for any event
161
+ * supplied through the `events` input.
162
+ */
163
+ private previewRowKey;
25
164
  update(state: SchedulerState): void;
26
165
  private optionsRequireRerender;
27
166
  private updateGreyedSlots;
@@ -20,6 +20,12 @@ export declare class WeekView extends BaseView {
20
20
  private optionsRequireRerender;
21
21
  private renderEvents;
22
22
  private createEventElement;
23
+ /**
24
+ * Dashed ghost showing where the dragged/created range will land — ONE box per
25
+ * day it spans, mirroring how a committed multi-day event splits into parts.
26
+ * A single box measured from the start day's midnight produced a ~2900px-tall
27
+ * box hanging out of the first column for a 3-day range.
28
+ */
23
29
  private renderPreviewEvent;
24
30
  private updateGreyedSlots;
25
31
  private renderNowIndicator;
@@ -10,9 +10,11 @@ export declare class YearView extends BaseView {
10
10
  /**
11
11
  * Build a `YYYY-MM` key from a Date, which is the unit of focus on year
12
12
  * view (PRD scheduler-controlled-selection §5.2 — year cells are months,
13
- * not days).
13
+ * not days). Public because the month card's element id
14
+ * (`scheduler-cell-y-{key}`) is also the anchor the day popover hangs off
15
+ * in this view.
14
16
  */
15
- private static monthKey;
17
+ static monthKey(d: Date): string;
16
18
  private createMonthCard;
17
19
  /**
18
20
  * Apply roving tabindex based on `state.focusedDate`'s month. Year-view's
@@ -1,16 +1,16 @@
1
- import { D as $, d as C } from "../chunks/color-CpFtrIoX.mjs";
2
- import { a as G, b as N, c as U, R as X, T as Y, e as _, f 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 ct, r as it, q as rt, t as at } from "../chunks/color-CpFtrIoX.mjs";
1
+ import { D as $, d as C } from "../chunks/id-BstjfRrz.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, x as ut } from "../chunks/id-BstjfRrz.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, c, l = {}) {
8
- const i = { ...$, ...l };
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] = i.slotMinTime.split(":").map(Number), [f] = i.slotMaxTime.split(":").map(Number), g = (f - d) * 3600, m = (a - d * 3600) / g * 100, R = u / g * 100, S = 10, p = (100 - S) / c, T = p / s, v = S + n * p + e * T;
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: v,
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, c, l = {}) {
22
+ calculateTimelinePosition(t, e, s, n, i, l = {}) {
23
23
  ({ ...$, ...l });
24
- const i = c.getTime() - n.getTime(), r = Math.max(t.start.getTime(), n.getTime()), a = Math.min(t.end.getTime(), c.getTime()), h = r - n.getTime(), u = a - r, d = h / i * 100, f = u / i * 100, g = 100 / s;
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, c, l = 7) {
37
- const i = 100 / l, r = 100 / s, a = n * i, h = (c - n + 1) * i;
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 P = new w();
86
- function M(o, t) {
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 z(o) {
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,88 @@ function z(o) {
95
95
  }
96
96
  return e;
97
97
  }
98
- function B(o, t) {
98
+ function L(o, t) {
99
99
  return o.closest(`[data-${t}]`);
100
100
  }
101
- function D(o) {
101
+ function M(o) {
102
102
  return {
103
103
  top: o.scrollTop,
104
104
  left: o.scrollLeft
105
105
  };
106
106
  }
107
- function E(o, t, e = "smooth") {
108
- const s = o.getBoundingClientRect(), c = t.getBoundingClientRect().top - s.top + o.scrollTop;
107
+ function z(o, t, e = "smooth") {
108
+ const s = o.getBoundingClientRect(), i = t.getBoundingClientRect().top - s.top + o.scrollTop;
109
109
  o.scrollTo({
110
- top: c,
110
+ top: i,
111
111
  behavior: e
112
112
  });
113
113
  }
114
- function L(o, t) {
114
+ function O(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 W(o, t) {
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 O(o, t, e) {
125
+ function A(o, t, e) {
126
126
  o.style.setProperty(`--${t}`, e);
127
127
  }
128
- function A(o, t) {
128
+ function W(o, t) {
129
129
  return getComputedStyle(o).getPropertyValue(`--${t}`).trim();
130
130
  }
131
- function k(o, ...t) {
131
+ function F(o, ...t) {
132
132
  o.classList.add(...t.filter(Boolean));
133
133
  }
134
- function F(o, ...t) {
134
+ function _(o, ...t) {
135
135
  o.classList.remove(...t.filter(Boolean));
136
136
  }
137
- function H(o, t, e) {
137
+ function k(o, t, e) {
138
138
  o.classList.toggle(t, e);
139
139
  }
140
140
  export {
141
- G as DEFAULT_COLORS,
142
- N as DEFAULT_MESSAGES,
141
+ U as DEFAULT_COLORS,
142
+ V as DEFAULT_EVENT_COLOR,
143
+ j as DEFAULT_MESSAGES,
143
144
  $ as DEFAULT_OPTIONS,
144
- U as DateService,
145
+ G as DEFAULT_PERMISSIONS,
146
+ X as DateService,
145
147
  w as PositionService,
146
- X as ResourceService,
147
- Y as TimelineService,
148
- _ as addAlpha,
149
- k as addClasses,
150
- q as darkenColor,
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
- B as findClosestWithData,
153
- J as formatMessage,
154
- K as generateEventId,
155
- Q as generateGroupId,
156
- Z as generateId,
157
- tt as generateResourceId,
158
- A as getCSSVariable,
159
- et as getColorByIndex,
160
- ot as getContrastColor,
161
- z as getDataAttributes,
162
- M as getElementByData,
163
- W as getRelativePosition,
164
- D as getScrollPosition,
165
- L as isInViewport,
166
- st as isResource,
167
- nt as isResourceGroup,
168
- ct as lightenColor,
169
- P as positionService,
170
- F as removeClasses,
171
- it as resolveMessages,
172
- rt as resourceService,
173
- E as scrollToTime,
174
- O as setCSSVariable,
175
- at as timelineService,
176
- H as toggleClass
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
+ O 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 resolveResizeEdge,
177
+ ht as resourceService,
178
+ z as scrollToTime,
179
+ A as setCSSVariable,
180
+ ut as timelineService,
181
+ k as toggleClass
177
182
  };
@@ -70,8 +70,12 @@ export interface PreviewEvent {
70
70
  start: Date;
71
71
  /** End of the preview */
72
72
  end: Date;
73
- /** Optional resource ID for resource-based views */
74
- resourceId?: string;
73
+ /**
74
+ * Row the preview belongs to. Same tri-state as `TimeSlot.resourceId`:
75
+ * `undefined` = no row information (no resource axis, or a resize, which
76
+ * never changes rows), `null` = the unassigned bucket row.
77
+ */
78
+ resourceId?: string | null;
75
79
  }
76
80
  /**
77
81
  * A track/rail containing non-overlapping events
@@ -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
- * Base event detail interface
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 BaseEventDetail {
8
- /** Original DOM event */
9
- originalEvent?: Event;
10
+ export interface TimeRange {
11
+ start: Date;
12
+ end: Date;
10
13
  }
11
14
  /**
12
- * Event-selected event detail. Fires on mouse click and on keyboard Tab
13
- * landing on an event (PRD scheduler-keyboard-grid-nav D3 — renamed from
14
- * `EventClickDetail` because keyboard Tab now triggers the same event).
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 interface EventSelectedDetail extends BaseEventDetail {
17
- /** The selected event */
26
+ export type SchedulerCustomEvent = {
27
+ type: 'event-selected';
18
28
  event: SchedulerEvent;
19
- }
20
- /**
21
- * Event create *request* detail. Per PRD scheduler-controlled-selection,
22
- * the scheduler does not construct or store the event itself — the consumer
23
- * receives the range and decides whether to add an event for it.
24
- */
25
- export interface EventCreateDetail extends BaseEventDetail {
26
- /** The selected time range. */
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
- * Event update event detail
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
- * Event delete event detail
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
- /** Resource at the clicked location (if applicable) */
73
- resource?: Resource;
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
- * Custom event map for the scheduler web component
83
+ * Payload of one scheduler event — the union arm minus its discriminant.
97
84
  */
98
- export interface SchedulerEventMap {
99
- 'event-selected': CustomEvent<EventSelectedDetail>;
100
- 'event-dblclick': CustomEvent<EventSelectedDetail>;
101
- 'event-create': CustomEvent<EventCreateDetail>;
102
- 'event-update': CustomEvent<EventUpdateDetail>;
103
- 'event-delete': CustomEvent<EventDeleteDetail>;
104
- 'date-click': CustomEvent<DateClickDetail>;
105
- 'date-select': CustomEvent<DateSelectDetail>;
106
- 'view-change': CustomEvent<ViewChangeDetail>;
107
- 'selection-change': CustomEvent<SelectionChangeDetail>;
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
+ };
@@ -4,5 +4,6 @@ export * from './resource';
4
4
  export * from './time-slot';
5
5
  export * from './options';
6
6
  export * from './messages';
7
+ export * from './permissions';
7
8
  export * from './drag-state';
8
9
  export * from './events';