@mintplayer/web-components 2.3.0 → 2.4.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.
@@ -54,6 +54,8 @@ export declare class MpScheduler extends LitElement {
54
54
  today(): void;
55
55
  gotoDate(date: Date): void;
56
56
  changeView(view: ViewType): void;
57
+ /** Localized display name of a view (also the view-switcher button text). */
58
+ private viewLabel;
57
59
  /**
58
60
  * Clear the time-range selection and the focused-cell selection. Public
59
61
  * because — per PRD scheduler-controlled-selection — the WC no longer
@@ -66,10 +68,25 @@ export declare class MpScheduler extends LitElement {
66
68
  removeEvent(eventId: string): void;
67
69
  getEventById(eventId: string): SchedulerEvent | null;
68
70
  refetchEvents(): void;
71
+ /**
72
+ * Localized string lookup: options.messages overrides merged onto the
73
+ * English defaults, with {placeholder} interpolation.
74
+ */
75
+ private msg;
69
76
  render(): TemplateResult;
70
77
  protected firstUpdated(): void;
71
78
  private populateHeader;
72
79
  private updateTitle;
80
+ /** Header width below which the layout wraps and the title compacts (D9). */
81
+ private static readonly NARROW_HEADER_WIDTH;
82
+ private headerResizeObserver;
83
+ private headerIsNarrow;
84
+ /**
85
+ * Component-width (not viewport) driven narrow mode — the scheduler can sit
86
+ * in a pane far narrower than the screen (splitter/dock). CSS keys the
87
+ * wrapped layout off [data-narrow]; the title text swap needs JS anyway.
88
+ */
89
+ private observeHeaderWidth;
73
90
  private renderView;
74
91
  private onStateChange;
75
92
  private previousIsLoading;
@@ -79,6 +96,16 @@ export declare class MpScheduler extends LitElement {
79
96
  private handlePointerDown;
80
97
  private handlePointerMove;
81
98
  private handlePointerUp;
99
+ /**
100
+ * Two activations of the same event within this window = a double
101
+ * click/tap. Native dblclick cannot be relied on here: the first click's
102
+ * selection re-render replaces the event node, which resets the browser's
103
+ * double-click tracking — so `event-dblclick` is synthesized from
104
+ * consecutive activations instead (and works for touch double-tap too).
105
+ */
106
+ private static readonly DBLCLICK_WINDOW_MS;
107
+ private lastEventActivation;
108
+ private registerEventActivation;
82
109
  private handleDragComplete;
83
110
  private handleClick;
84
111
  private handleDoubleClick;
@@ -34,6 +34,8 @@ export interface InputHandlerConfig {
34
34
  isEditable: () => boolean;
35
35
  /** Whether selection is enabled */
36
36
  isSelectable: () => boolean;
37
+ /** Whether the given event is the currently-selected one */
38
+ isEventSelected?: (eventId: string) => boolean;
37
39
  /** Touch hold duration in ms before drag activates (default: 500) */
38
40
  touchHoldDuration?: number;
39
41
  /** Movement threshold before touch hold is cancelled (default: 10) */
@@ -1,11 +1,12 @@
1
- import { SchedulerEvent, TimeSlot } from '@mintplayer/web-components/scheduler-core';
1
+ import { SchedulerEvent, SchedulerEventPart, SchedulerOptions, TimeSlot } from '@mintplayer/web-components/scheduler-core';
2
2
  import { SchedulerState } from '../state/scheduler-state';
3
3
  /**
4
4
  * Build the descriptive aria-label for an event block. Used by every view.
5
5
  * Format: "{title}, {start}–{end} on {resource}". Resource is omitted when
6
6
  * the event has no resource or the caller doesn't have it (week/day views).
7
+ * Strings and date formatting follow options.messages / options.locale.
7
8
  */
8
- export declare function formatEventAriaLabel(event: SchedulerEvent, resourceTitle: string | null, timeFormat?: '12h' | '24h'): string;
9
+ export declare function formatEventAriaLabel(event: SchedulerEvent, resourceTitle: string | null, options: SchedulerOptions): string;
9
10
  /**
10
11
  * Normalised selection range — covers anchor.start through extent.end (or
11
12
  * the reverse if the user shift-arrowed backwards), with the resource pinned
@@ -28,22 +29,22 @@ export declare function isSlotInSelection(slot: TimeSlot, state: SchedulerState,
28
29
  * Includes weekday + date so screen readers don't lose the user across
29
30
  * cross-day moves.
30
31
  */
31
- export declare function formatCellAnnouncement(slot: TimeSlot, timeFormat?: '12h' | '24h', resourceTitle?: string | null): string;
32
+ export declare function formatCellAnnouncement(slot: TimeSlot, options: SchedulerOptions, resourceTitle?: string | null): string;
32
33
  /**
33
34
  * Live-region announcement after Shift+Arrow grows or shrinks the range.
34
35
  * Reads "Selection: {start time, day} to {end time, day}, {N} slots".
35
36
  */
36
- export declare function formatSelectionAnnouncement(state: SchedulerState, slotDuration: number, timeFormat?: '12h' | '24h'): string;
37
+ export declare function formatSelectionAnnouncement(state: SchedulerState, slotDuration: number): string;
37
38
  /**
38
39
  * Live-region announcement for an in-progress keyboard event move.
39
40
  */
40
- export declare function formatMoveAnnouncement(start: Date, end: Date, timeFormat?: '12h' | '24h'): string;
41
+ export declare function formatMoveAnnouncement(start: Date, end: Date, options: SchedulerOptions): string;
41
42
  /**
42
43
  * Live-region announcement for an in-progress keyboard event resize. The
43
44
  * `edge` field tells the user which side they're stretching, so they can
44
45
  * tell Shift+ArrowDown (end edge) from Alt+Shift+ArrowDown (start edge).
45
46
  */
46
- export declare function formatResizeAnnouncement(start: Date, end: Date, edge: 'start' | 'end', timeFormat?: '12h' | '24h'): string;
47
+ export declare function formatResizeAnnouncement(start: Date, end: Date, edge: 'start' | 'end', options: SchedulerOptions): string;
47
48
  /**
48
49
  * Base class for scheduler views
49
50
  */
@@ -84,6 +85,17 @@ export declare abstract class BaseView {
84
85
  * Helper to clear container
85
86
  */
86
87
  protected clearContainer(): void;
88
+ /**
89
+ * Append the start/end resize handles for an event part. The handle strip
90
+ * is the pointer hit zone the drag machine targets via
91
+ * closest('.resize-handle'); the glyph inside it is a purely decorative
92
+ * affordance revealed by the .selected class — never focusable, the
93
+ * keyboard resize path lives on the event element (move-mode).
94
+ * Position classes are per-view: ['top','bottom'] for time grids,
95
+ * ['left','right'] for the timeline.
96
+ */
97
+ protected appendResizeHandles(eventEl: HTMLElement, part: SchedulerEventPart, [startClass, endClass]?: [string, string]): void;
98
+ private createResizeHandle;
87
99
  /**
88
100
  * Retrofit the ARIA grid chain onto a rendered view (wc-aria PRD step 5.7):
89
101
  * the container claims `grid`, layout-only wrappers become `presentation`
@@ -104,6 +116,8 @@ export declare abstract class BaseView {
104
116
  /** Extra gridcells (e.g. a per-row events overlay whose buttons need a
105
117
  * cell to live in — rows may not own buttons directly). */
106
118
  cells?: string;
119
+ /** Grids where Shift+Arrow extends a multi-cell range (week/day). */
120
+ multiselectable?: boolean;
107
121
  }): void;
108
122
  /** aria-current="date" on every element the views styled `.today`. */
109
123
  protected markToday(): void;
@@ -16,6 +16,12 @@ export declare class TimelineView extends BaseView {
16
16
  private createResourceRow;
17
17
  private renderEvents;
18
18
  private createEventElement;
19
+ /**
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.
23
+ */
24
+ private renderPreviewEvent;
19
25
  update(state: SchedulerState): void;
20
26
  private optionsRequireRerender;
21
27
  private updateGreyedSlots;
@@ -1,17 +1,17 @@
1
- import { D as T, d as C } from "../chunks/color-CyamnJnn.mjs";
2
- import { a as N, b as X, R as Y, T as G, c as U, e as _, g as q, f as J, h as K, i as Q, j as Z, k as tt, l as et, m as ot, n as nt, r as st, t as ct } from "../chunks/color-CyamnJnn.mjs";
3
- class x {
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";
3
+ class w {
4
4
  /**
5
5
  * Calculate position for an event part in week/day view
6
6
  */
7
- calculateWeekPosition(t, e, n, s, c, l = {}) {
8
- const i = { ...T, ...l };
7
+ calculateWeekPosition(t, e, s, n, c, l = {}) {
8
+ const i = { ...$, ...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, $ = p / n, w = S + s * p + e * $;
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;
11
11
  return {
12
12
  top: m,
13
- left: w,
14
- width: $,
13
+ left: v,
14
+ width: T,
15
15
  height: R,
16
16
  zIndex: e + 1
17
17
  };
@@ -19,9 +19,9 @@ class x {
19
19
  /**
20
20
  * Calculate position for an event in timeline view
21
21
  */
22
- calculateTimelinePosition(t, e, n, s, c, l = {}) {
23
- ({ ...T, ...l });
24
- const i = c.getTime() - s.getTime(), r = Math.max(t.start.getTime(), s.getTime()), a = Math.min(t.end.getTime(), c.getTime()), h = r - s.getTime(), u = a - r, d = h / i * 100, f = u / i * 100, g = 100 / n;
22
+ calculateTimelinePosition(t, e, s, n, c, l = {}) {
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;
25
25
  return {
26
26
  top: e * g,
27
27
  left: d,
@@ -33,8 +33,8 @@ class x {
33
33
  /**
34
34
  * Calculate position for an all-day event in month view
35
35
  */
36
- calculateMonthEventPosition(t, e, n, s, c, l = 7) {
37
- const i = 100 / l, r = 100 / n, a = s * i, h = (c - s + 1) * i;
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;
38
38
  return {
39
39
  top: e * r,
40
40
  left: a,
@@ -46,12 +46,12 @@ class x {
46
46
  /**
47
47
  * Convert percentage-based position to pixel-based
48
48
  */
49
- toPixelPosition(t, e, n) {
49
+ toPixelPosition(t, e, s) {
50
50
  return {
51
- top: t.top / 100 * n,
51
+ top: t.top / 100 * s,
52
52
  left: t.left / 100 * e,
53
53
  width: t.width / 100 * e,
54
- height: t.height / 100 * n,
54
+ height: t.height / 100 * s,
55
55
  zIndex: t.zIndex
56
56
  };
57
57
  }
@@ -82,93 +82,96 @@ class x {
82
82
  };
83
83
  }
84
84
  }
85
- const P = new x();
86
- function z(o, t) {
87
- const e = Object.entries(t).map(([n, s]) => `[data-${n}="${s}"]`).join("");
85
+ const P = new w();
86
+ function M(o, t) {
87
+ const e = Object.entries(t).map(([s, n]) => `[data-${s}="${n}"]`).join("");
88
88
  return o.querySelector(e);
89
89
  }
90
- function B(o) {
90
+ function z(o) {
91
91
  const t = o.dataset, e = {};
92
- for (const n in t) {
93
- const s = t[n];
94
- s !== void 0 && (e[n] = s);
92
+ for (const s in t) {
93
+ const n = t[s];
94
+ n !== void 0 && (e[s] = n);
95
95
  }
96
96
  return e;
97
97
  }
98
- function D(o, t) {
98
+ function B(o, t) {
99
99
  return o.closest(`[data-${t}]`);
100
100
  }
101
- function W(o) {
101
+ function D(o) {
102
102
  return {
103
103
  top: o.scrollTop,
104
104
  left: o.scrollLeft
105
105
  };
106
106
  }
107
- function L(o, t, e = "smooth") {
108
- const n = o.getBoundingClientRect(), c = t.getBoundingClientRect().top - n.top + o.scrollTop;
107
+ function E(o, t, e = "smooth") {
108
+ const s = o.getBoundingClientRect(), c = t.getBoundingClientRect().top - s.top + o.scrollTop;
109
109
  o.scrollTo({
110
110
  top: c,
111
111
  behavior: e
112
112
  });
113
113
  }
114
- function M(o, t) {
115
- const e = o.getBoundingClientRect(), n = t ? t.getBoundingClientRect() : { top: 0, left: 0, bottom: window.innerHeight, right: window.innerWidth };
116
- return e.top >= n.top && e.left >= n.left && e.bottom <= n.bottom && e.right <= n.right;
114
+ function L(o, t) {
115
+ const e = o.getBoundingClientRect(), s = t ? t.getBoundingClientRect() : { top: 0, left: 0, bottom: window.innerHeight, right: window.innerWidth };
116
+ return e.top >= s.top && e.left >= s.left && e.bottom <= s.bottom && e.right <= s.right;
117
117
  }
118
- function O(o, t) {
119
- const e = t.getBoundingClientRect(), n = "touches" in o ? o.touches[0].clientX : o.clientX, s = "touches" in o ? o.touches[0].clientY : o.clientY;
118
+ function W(o, t) {
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
- x: n - e.left,
122
- y: s - e.top
121
+ x: s - e.left,
122
+ y: n - e.top
123
123
  };
124
124
  }
125
- function k(o, t, e) {
125
+ function O(o, t, e) {
126
126
  o.style.setProperty(`--${t}`, e);
127
127
  }
128
- function E(o, t) {
128
+ function A(o, t) {
129
129
  return getComputedStyle(o).getPropertyValue(`--${t}`).trim();
130
130
  }
131
- function H(o, ...t) {
131
+ function k(o, ...t) {
132
132
  o.classList.add(...t.filter(Boolean));
133
133
  }
134
- function j(o, ...t) {
134
+ function F(o, ...t) {
135
135
  o.classList.remove(...t.filter(Boolean));
136
136
  }
137
- function A(o, t, e) {
137
+ function H(o, t, e) {
138
138
  o.classList.toggle(t, e);
139
139
  }
140
140
  export {
141
- N as DEFAULT_COLORS,
142
- T as DEFAULT_OPTIONS,
143
- X as DateService,
144
- x as PositionService,
145
- Y as ResourceService,
146
- G as TimelineService,
147
- U as addAlpha,
148
- H as addClasses,
149
- _ as darkenColor,
141
+ G as DEFAULT_COLORS,
142
+ N as DEFAULT_MESSAGES,
143
+ $ as DEFAULT_OPTIONS,
144
+ U as DateService,
145
+ w as PositionService,
146
+ X as ResourceService,
147
+ Y as TimelineService,
148
+ _ as addAlpha,
149
+ k as addClasses,
150
+ q as darkenColor,
150
151
  C as dateService,
151
- D as findClosestWithData,
152
- q as generateEventId,
153
- J as generateGroupId,
154
- K as generateId,
155
- Q as generateResourceId,
156
- E as getCSSVariable,
157
- Z as getColorByIndex,
158
- tt as getContrastColor,
159
- B as getDataAttributes,
160
- z as getElementByData,
161
- O as getRelativePosition,
162
- W as getScrollPosition,
163
- M as isInViewport,
164
- et as isResource,
165
- ot as isResourceGroup,
166
- nt as lightenColor,
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,
167
169
  P as positionService,
168
- j as removeClasses,
169
- st as resourceService,
170
- L as scrollToTime,
171
- k as setCSSVariable,
172
- ct as timelineService,
173
- A as toggleClass
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
174
177
  };
@@ -3,5 +3,6 @@ export * from './event';
3
3
  export * from './resource';
4
4
  export * from './time-slot';
5
5
  export * from './options';
6
+ export * from './messages';
6
7
  export * from './drag-state';
7
8
  export * from './events';
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Every user-facing string the scheduler renders or announces. Consumers
3
+ * localize by passing a partial table via `options.messages`; anything not
4
+ * overridden falls back to the English default. Templates interpolate
5
+ * `{placeholder}` tokens via `formatMessage` — plain substitution, no
6
+ * pluralization rules (the only plural, slot count, uses two explicit keys).
7
+ */
8
+ export interface SchedulerMessages {
9
+ navLabel: string;
10
+ previousPeriod: string;
11
+ nextPeriod: string;
12
+ jumpToToday: string;
13
+ today: string;
14
+ switchView: string;
15
+ viewYear: string;
16
+ viewMonth: string;
17
+ viewWeek: string;
18
+ viewDay: string;
19
+ viewTimeline: string;
20
+ resourcesHeader: string;
21
+ /** {date} — formatted first day of the visible week */
22
+ timelineGridLabel: string;
23
+ /** {title} — resource group title */
24
+ expandGroup: string;
25
+ /** {title} — resource group title */
26
+ collapseGroup: string;
27
+ /** {count} — number of hidden events */
28
+ moreEvents: string;
29
+ /** {view} — localized view name */
30
+ viewChanged: string;
31
+ /** {title} */
32
+ eventAdded: string;
33
+ /** {title} */
34
+ eventUpdated: string;
35
+ /** {title} */
36
+ eventRemoved: string;
37
+ loadingEvents: string;
38
+ eventsLoaded: string;
39
+ /** {title} {minutes} — move-mode entry keymap announcement */
40
+ moveModeEntered: string;
41
+ /** {start} {end} {day} */
42
+ movedTo: string;
43
+ /** {resource} */
44
+ movedToResource: string;
45
+ /** {edge} {start} {end} — edge is startEdge/endEdge below */
46
+ resizedEdge: string;
47
+ startEdge: string;
48
+ endEdge: string;
49
+ moveCommitted: string;
50
+ moveCancelled: string;
51
+ /** {start} {end} {count} {slots} — slots is slotSingular/slotPlural */
52
+ selection: string;
53
+ slotSingular: string;
54
+ slotPlural: string;
55
+ /** {start} {end} */
56
+ selectionCommitted: string;
57
+ gridInstructions: string;
58
+ eventInstructions: string;
59
+ /** {resource} */
60
+ eventOnResource: string;
61
+ }
62
+ export declare const DEFAULT_MESSAGES: SchedulerMessages;
63
+ /**
64
+ * Interpolate `{placeholder}` tokens. Unknown tokens are left verbatim so a
65
+ * typo'd override is visible rather than silently swallowed.
66
+ */
67
+ export declare function formatMessage(template: string, params?: Record<string, string | number>): string;
68
+ /** Merge a consumer's partial override table onto the English defaults. */
69
+ export declare function resolveMessages(overrides?: Partial<SchedulerMessages>): SchedulerMessages;
@@ -1,3 +1,4 @@
1
+ import { SchedulerMessages } from './messages';
1
2
  import { DayOfWeek, TimeFormat, ViewType } from './types';
2
3
  /**
3
4
  * Business hours configuration
@@ -73,6 +74,9 @@ export interface SchedulerOptions {
73
74
  dragScroll?: boolean;
74
75
  /** Snap duration in seconds */
75
76
  snapDuration?: number;
77
+ /** Override any user-facing string (labels, announcements, instructions).
78
+ * Merged onto the English defaults — see SchedulerMessages. */
79
+ messages?: Partial<SchedulerMessages>;
76
80
  /** Whether to show current time indicator */
77
81
  nowIndicator?: boolean;
78
82
  /** Whether to show week numbers */