@mintplayer/web-components 2.7.0 → 2.8.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.
@@ -32,9 +32,20 @@ export interface SchedulerOptions {
32
32
  initialView?: ViewType;
33
33
  /** Initial date to display */
34
34
  initialDate?: Date;
35
- /** Locale for date formatting (e.g., 'en-US') */
35
+ /**
36
+ * Locale for date and time formatting (e.g. 'nl-BE').
37
+ *
38
+ * Leave it unset and the browser's own locale is used — every formatter here
39
+ * passes the value straight to `Intl`, which resolves `undefined` to the
40
+ * runtime default. Set it only to override the user's browser.
41
+ */
36
42
  locale?: string;
37
- /** First day of the week (0 = Sunday, 1 = Monday) */
43
+ /**
44
+ * First day of the week (0 = Sunday, 1 = Monday).
45
+ *
46
+ * Unset means "derive from the locale" — Sunday for en-US and ja-JP, Monday
47
+ * for most of Europe. Set it to pin the week start regardless of locale.
48
+ */
38
49
  firstDayOfWeek?: DayOfWeek;
39
50
  /** Timezone identifier (e.g., 'America/New_York') */
40
51
  timeZone?: string;
@@ -80,10 +91,6 @@ export interface SchedulerOptions {
80
91
  defaultEventColor?: string;
81
92
  /** Whether to show current time indicator */
82
93
  nowIndicator?: boolean;
83
- /** Whether to show week numbers */
84
- weekNumbers?: boolean;
85
- /** Text to display before week number */
86
- weekText?: string;
87
94
  /** Maximum events to show per day (true = show "+X more" link) */
88
95
  dayMaxEvents?: boolean | number;
89
96
  /**
@@ -145,4 +152,14 @@ export type MoreLinkBehavior = 'popover' | 'day' | ((info: {
145
152
  /**
146
153
  * Default options for the scheduler
147
154
  */
148
- export declare const DEFAULT_OPTIONS: Required<SchedulerOptions>;
155
+ /**
156
+ * The defaults table.
157
+ *
158
+ * `locale`, `timeFormat` and `firstDayOfWeek` are deliberately ABSENT rather than
159
+ * guessed. A default of `'en-US'` is not a neutral fallback — it is an
160
+ * instruction to `Intl` to render US English, which is why a Dutch browser used
161
+ * to show "Mon, Oct 27" instead of "ma 27 okt". Undefined means "ask the
162
+ * platform", and every consumer of these three resolves it that way.
163
+ */
164
+ export type SchedulerDefaultOptions = Required<Omit<SchedulerOptions, 'locale' | 'timeFormat' | 'firstDayOfWeek'>> & Pick<SchedulerOptions, 'locale' | 'timeFormat' | 'firstDayOfWeek'>;
165
+ export declare const DEFAULT_OPTIONS: SchedulerDefaultOptions;
@@ -61,18 +61,76 @@ export declare class DateService {
61
61
  * Uses the Intl API to determine if the locale uses 12-hour or 24-hour time
62
62
  */
63
63
  detectTimeFormat(locale?: string): TimeFormat;
64
+ /** Memoized `getWeekInfo().firstDay` per locale — see resolveFirstDayOfWeek. */
65
+ private readonly weekStarts;
66
+ /**
67
+ * Which day the week starts on: the caller's explicit choice, else the
68
+ * locale's own convention, else Monday.
69
+ *
70
+ * Two numbering systems meet here and they disagree about Sunday.
71
+ * `Date.prototype.getDay()` — which every calculation in this file speaks — is
72
+ * 0-6 with **Sunday = 0**. `Intl.Locale…getWeekInfo().firstDay` is 1-7 with
73
+ * **Sunday = 7**. The `% 7` is that conversion, and it is the only place the
74
+ * 1-7 domain is allowed to exist: `DayOfWeek` stays 0-6 because it is also the
75
+ * type of `BusinessHours.daysOfWeek`, which is `getDay()`-based and would
76
+ * silently accept a meaningless 7 if the type were widened.
77
+ *
78
+ * Resolved from the locale the CALLER passes, never from a stored default. A
79
+ * derivation reading `DEFAULT_OPTIONS.locale` would have read the old 'en-US'
80
+ * literal and handed every user on earth a Sunday start, Europe included.
81
+ *
82
+ * `getWeekInfo` is absent in Firefox, and is a getter on some engines and a
83
+ * method on others; both shapes and neither are handled.
84
+ */
85
+ resolveFirstDayOfWeek(explicit?: DayOfWeek, locale?: string): DayOfWeek;
86
+ /**
87
+ * Format a time of day.
88
+ *
89
+ * Was hand-rolled — `${hours}:${minutes}` with hardcoded 'AM'/'PM' literals —
90
+ * which no locale could reach: nl wants "a.m.", ja "午前", and several locales
91
+ * separate with something other than a colon.
92
+ *
93
+ * `format` is an explicit override. Leave it undefined and `hour12` is not
94
+ * passed at all, so `Intl` applies whatever the locale itself does — which is
95
+ * the behaviour the scheduler wants by default and the reason
96
+ * `detectTimeFormat` is not needed on this path.
97
+ */
98
+ formatTime(date: Date, format?: TimeFormat, locale?: string): string;
99
+ /**
100
+ * `Intl.DateTimeFormat` instances are expensive to construct and this runs once
101
+ * per slot per day — hundreds of times per render. Memoized on the only two
102
+ * inputs that vary.
103
+ */
104
+ private readonly timeFormatters;
105
+ private timeFormatter;
106
+ /**
107
+ * Format date for display.
108
+ *
109
+ * `locale` is optional and stays optional all the way down: `undefined` tells
110
+ * `Intl` to use the runtime's own locale. It used to default to `'en-US'`,
111
+ * which is not a neutral fallback but an instruction to render US English.
112
+ */
113
+ formatDate(date: Date, locale?: string, options?: Intl.DateTimeFormatOptions): string;
64
114
  /**
65
- * Format time according to format preference
115
+ * Format date with weekday — "Mon, Jul 27" in en-US, "ma 27 jul" in nl-BE,
116
+ * "7月27日(月)" in ja-JP. The field order is the locale's business, not ours.
66
117
  */
67
- formatTime(date: Date, format?: TimeFormat): string;
118
+ formatDateWithWeekday(date: Date, locale?: string): string;
68
119
  /**
69
- * Format date for display
120
+ * Format a date RANGE, letting the locale place the separator and elide the
121
+ * shared parts ("Jul 27 – Aug 2, 2026"). Falls back to a plain join where
122
+ * `formatRange` is unavailable.
70
123
  */
71
- formatDate(date: Date, locale?: string, options?: Intl.DateTimeFormatOptions): string;
124
+ formatDateRange(start: Date, end: Date, locale?: string, options?: Intl.DateTimeFormatOptions): string;
72
125
  /**
73
- * Format date with weekday
126
+ * Format a start–end time pair as one range.
127
+ *
128
+ * Beats joining two `formatTime` results with a literal separator: the locale
129
+ * chooses the dash AND elides what the ends share, so en-US reads
130
+ * "9:00 – 10:00 AM" rather than "9:00 AM - 10:00 AM". The event chips used a
131
+ * hyphen while the announcements used an en-dash; now neither hardcodes one.
74
132
  */
75
- formatDateWithWeekday(date: Date, locale?: string): string;
133
+ formatTimeRange(start: Date, end: Date, format?: TimeFormat, locale?: string): string;
76
134
  /**
77
135
  * Get month name
78
136
  */
@@ -121,10 +179,6 @@ export declare class DateService {
121
179
  * Add years to a date
122
180
  */
123
181
  addYears(date: Date, years: number): Date;
124
- /**
125
- * Get week number of the year
126
- */
127
- getWeekNumber(date: Date): number;
128
182
  /**
129
183
  * Get seconds from midnight for a date
130
184
  */
@@ -10,6 +10,25 @@ export declare function getColorByIndex(index: number): string;
10
10
  * Calculate contrasting text color (black or white) for a background
11
11
  */
12
12
  export declare function getContrastColor(backgroundColor: string): string;
13
+ /**
14
+ * Black or white — whichever actually scores the higher WCAG contrast ratio
15
+ * against `background`. `null` when the colour cannot be parsed.
16
+ *
17
+ * Distinct from {@link getContrastColor}, which computes YIQ *perceived
18
+ * brightness* against a 0.5 threshold. YIQ is a reasonable approximation for
19
+ * decorative text and is what every event label in the scheduler already uses,
20
+ * but it is not the WCAG formula and can pick the losing foreground on mid-tone
21
+ * backgrounds. Use this one wherever the result carries meaning a user must be
22
+ * able to read — an interactive control's glyph, say — and leave the existing
23
+ * callers alone: switching them would recolour every event label in all five
24
+ * views, which deserves its own visual review rather than a drive-by.
25
+ */
26
+ export declare function getReadableTextColor(background: string): string | null;
27
+ /**
28
+ * The WCAG contrast ratio between a hex colour and black or white, so callers
29
+ * (and tests) can assert a threshold rather than trust a branch.
30
+ */
31
+ export declare function contrastRatioWith(background: string, foreground: string): number | null;
13
32
  /**
14
33
  * Lighten a color by a percentage
15
34
  */