mn-angular-lib 2.0.34 → 2.0.36

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 (52) hide show
  1. package/fesm2022/mn-angular-lib-alert.mjs +515 -527
  2. package/fesm2022/mn-angular-lib-alert.mjs.map +1 -1
  3. package/fesm2022/mn-angular-lib-bottom-sheet.mjs +264 -357
  4. package/fesm2022/mn-angular-lib-bottom-sheet.mjs.map +1 -1
  5. package/fesm2022/mn-angular-lib-button.mjs +819 -382
  6. package/fesm2022/mn-angular-lib-button.mjs.map +1 -1
  7. package/fesm2022/mn-angular-lib-calendar-core.mjs +240 -365
  8. package/fesm2022/mn-angular-lib-calendar-core.mjs.map +1 -1
  9. package/fesm2022/mn-angular-lib-calendar.mjs +1691 -1545
  10. package/fesm2022/mn-angular-lib-calendar.mjs.map +1 -1
  11. package/fesm2022/mn-angular-lib-collection.mjs +2367 -2796
  12. package/fesm2022/mn-angular-lib-collection.mjs.map +1 -1
  13. package/fesm2022/mn-angular-lib-core.mjs +693 -1241
  14. package/fesm2022/mn-angular-lib-core.mjs.map +1 -1
  15. package/fesm2022/mn-angular-lib-display.mjs +679 -712
  16. package/fesm2022/mn-angular-lib-display.mjs.map +1 -1
  17. package/fesm2022/mn-angular-lib-forms.mjs +3671 -4647
  18. package/fesm2022/mn-angular-lib-forms.mjs.map +1 -1
  19. package/fesm2022/mn-angular-lib-keyboard.mjs +221 -190
  20. package/fesm2022/mn-angular-lib-keyboard.mjs.map +1 -1
  21. package/fesm2022/mn-angular-lib-modal-core.mjs +711 -896
  22. package/fesm2022/mn-angular-lib-modal-core.mjs.map +1 -1
  23. package/fesm2022/mn-angular-lib-modal-ui.mjs +2089 -2035
  24. package/fesm2022/mn-angular-lib-modal-ui.mjs.map +1 -1
  25. package/fesm2022/mn-angular-lib-modal.mjs +76 -121
  26. package/fesm2022/mn-angular-lib-modal.mjs.map +1 -1
  27. package/fesm2022/mn-angular-lib-rich-text-editor.mjs +289 -277
  28. package/fesm2022/mn-angular-lib-rich-text-editor.mjs.map +1 -1
  29. package/fesm2022/mn-angular-lib-segmented.mjs +189 -241
  30. package/fesm2022/mn-angular-lib-segmented.mjs.map +1 -1
  31. package/fesm2022/mn-angular-lib-tab.mjs +409 -642
  32. package/fesm2022/mn-angular-lib-tab.mjs.map +1 -1
  33. package/fesm2022/mn-angular-lib.mjs +16 -29
  34. package/package.json +1 -1
  35. package/types/mn-angular-lib-alert.d.ts +239 -241
  36. package/types/mn-angular-lib-bottom-sheet.d.ts +190 -150
  37. package/types/mn-angular-lib-button.d.ts +319 -317
  38. package/types/mn-angular-lib-calendar-core.d.ts +199 -209
  39. package/types/mn-angular-lib-calendar.d.ts +656 -511
  40. package/types/mn-angular-lib-collection.d.ts +1649 -1585
  41. package/types/mn-angular-lib-core.d.ts +524 -535
  42. package/types/mn-angular-lib-display.d.ts +946 -886
  43. package/types/mn-angular-lib-forms.d.ts +3012 -3013
  44. package/types/mn-angular-lib-keyboard.d.ts +125 -85
  45. package/types/mn-angular-lib-modal-core.d.ts +978 -994
  46. package/types/mn-angular-lib-modal-ui.d.ts +541 -493
  47. package/types/mn-angular-lib-modal.d.ts +24 -27
  48. package/types/mn-angular-lib-rich-text-editor.d.ts +131 -98
  49. package/types/mn-angular-lib-segmented.d.ts +354 -341
  50. package/types/mn-angular-lib-tab.d.ts +345 -336
  51. package/types/mn-angular-lib.d.ts +16 -16
  52. package/fesm2022/mn-angular-lib.mjs.map +0 -1
@@ -1,377 +1,252 @@
1
- import * as i0 from '@angular/core';
2
- import { InjectionToken, inject, Injectable } from '@angular/core';
3
- import { provideMnComponentConfig } from 'mn-angular-lib/core';
4
- import { of } from 'rxjs';
5
-
6
- /**
7
- * Available calendar view modes.
8
- */
1
+ import * as i0 from "@angular/core";
2
+ import { Injectable, InjectionToken, inject } from "@angular/core";
3
+ import { provideMnComponentConfig } from "mn-angular-lib/core";
4
+ import { of } from "rxjs";
9
5
  var CalendarView;
10
- (function (CalendarView) {
11
- CalendarView["MONTH"] = "MONTH";
12
- CalendarView["WEEK"] = "WEEK";
13
- CalendarView["DAY"] = "DAY";
6
+ (function(CalendarView) {
7
+ CalendarView["MONTH"] = "MONTH";
8
+ CalendarView["WEEK"] = "WEEK";
9
+ CalendarView["DAY"] = "DAY";
14
10
  })(CalendarView || (CalendarView = {}));
15
- /**
16
- * Builds locale-derived day name arrays from a BCP 47 locale string.
17
- * Uses January 1 2024 (a Monday) as the reference date.
18
- */
19
11
  function buildDayNames(locale) {
20
- const base = new Date(2024, 0, 1); // 2024-01-01 is a Monday
21
- const short = [];
22
- const long = [];
23
- for (let i = 0; i < 7; i++) {
24
- const d = new Date(base);
25
- d.setDate(base.getDate() + i);
26
- short.push(d.toLocaleDateString(locale, { weekday: 'short' }));
27
- long.push(d.toLocaleDateString(locale, { weekday: 'long' }));
28
- }
29
- return { short, long };
12
+ const base = new Date(2024, 0, 1);
13
+ const short = [];
14
+ const long = [];
15
+ for (let i = 0; i < 7; i++) {
16
+ const d = new Date(base);
17
+ d.setDate(base.getDate() + i);
18
+ short.push(d.toLocaleDateString(locale, { weekday: "short" }));
19
+ long.push(d.toLocaleDateString(locale, { weekday: "long" }));
20
+ }
21
+ return {
22
+ short,
23
+ long
24
+ };
30
25
  }
31
- /** Default calendar configuration values. */
32
26
  const DEFAULT_CALENDAR_CONFIG = (() => {
33
- const locale = 'en-US';
34
- const names = buildDayNames(locale);
35
- return {
36
- startHour: 7,
37
- endHour: 22,
38
- locale,
39
- todayLabel: 'Today',
40
- pickDateLabel: 'Pick a date',
41
- previousLabel: 'Previous',
42
- nextLabel: 'Next',
43
- upcomingEventsTitle: 'Upcoming events',
44
- noUpcomingEvents: 'No upcoming events',
45
- moreEventsLabel: 'more',
46
- viewLabels: { MONTH: 'Month', WEEK: 'Week', DAY: 'Day' },
47
- shortDayNames: names.short,
48
- longDayNames: names.long,
49
- mobileBreakpoint: 768,
50
- };
27
+ const locale = "en-US";
28
+ const names = buildDayNames(locale);
29
+ return {
30
+ startHour: 7,
31
+ endHour: 22,
32
+ locale,
33
+ todayLabel: "Today",
34
+ pickDateLabel: "Pick a date",
35
+ previousLabel: "Previous",
36
+ nextLabel: "Next",
37
+ upcomingEventsTitle: "Upcoming events",
38
+ noUpcomingEvents: "No upcoming events",
39
+ moreEventsLabel: "more",
40
+ viewLabels: {
41
+ MONTH: "Month",
42
+ WEEK: "Week",
43
+ DAY: "Day"
44
+ },
45
+ shortDayNames: names.short,
46
+ longDayNames: names.long,
47
+ mobileBreakpoint: 768
48
+ };
51
49
  })();
52
- /**
53
- * Injection token for the resolved calendar configuration.
54
- *
55
- * Prefer using {@link MN_CALENDAR_CONFIG} with `provideMnComponentConfig`
56
- * so that settings can be managed via `mn-config.json5`. This token is
57
- * kept for backward compatibility and manual `providers` usage.
58
- *
59
- * @example
60
- * ```ts
61
- * providers: [
62
- * { provide: CALENDAR_CONFIG, useValue: { startHour: 8, endHour: 20, locale: 'nl-NL' } }
63
- * ]
64
- * ```
65
- */
66
- const CALENDAR_CONFIG = new InjectionToken('CalendarConfig', {
67
- providedIn: 'root',
68
- factory: () => DEFAULT_CALENDAR_CONFIG
50
+ const CALENDAR_CONFIG = new InjectionToken("CalendarConfig", {
51
+ providedIn: "root",
52
+ factory: () => DEFAULT_CALENDAR_CONFIG
69
53
  });
70
- /**
71
- * Injection token resolved via `MnConfigService` (the `mn-config.json5` system).
72
- *
73
- * Use the helper {@link provideMnCalendarConfig} in the component's `providers`
74
- * array so that calendar settings are read from the config file and support
75
- * `$translate` markers, section scoping, and instance-id overrides.
76
- *
77
- * Component name in the config file: `'mn-calendar'`.
78
- *
79
- * @example
80
- * ```json5
81
- * // mn-config.json5
82
- * {
83
- * defaults: {
84
- * "mn-calendar": {
85
- * startHour: 8,
86
- * endHour: 20,
87
- * locale: "nl-NL",
88
- * todayLabel: { $translate: "calendar.today" }
89
- * }
90
- * }
91
- * }
92
- * ```
93
- */
94
- const MN_CALENDAR_CONFIG = new InjectionToken('MN_CALENDAR_CONFIG');
95
- /** Component name used to look up calendar settings in `mn-config.json5`. */
96
- const MN_CALENDAR_COMPONENT_NAME = 'mn-calendar';
97
- /**
98
- * Provider helper that wires the calendar into the `mn-config` system.
99
- *
100
- * Add this to the `providers` array of the component (or module) that hosts
101
- * `<mn-calendar-view>`. It reads defaults and overrides from `mn-config.json5`
102
- * under the key `"mn-calendar"` and provides them via {@link MN_CALENDAR_CONFIG}.
103
- *
104
- * @param initial — optional partial defaults merged before config-file values.
105
- */
54
+ const MN_CALENDAR_CONFIG = new InjectionToken("MN_CALENDAR_CONFIG");
55
+ const MN_CALENDAR_COMPONENT_NAME = "mn-calendar";
106
56
  function provideMnCalendarConfig(initial) {
107
- return provideMnComponentConfig(MN_CALENDAR_CONFIG, MN_CALENDAR_COMPONENT_NAME, initial);
57
+ return provideMnComponentConfig(MN_CALENDAR_CONFIG, MN_CALENDAR_COMPONENT_NAME, initial);
108
58
  }
109
- /**
110
- * Merges a partial config with defaults, re-deriving day names from locale when needed.
111
- */
112
59
  function resolveCalendarConfig(partial) {
113
- if (!partial)
114
- return { ...DEFAULT_CALENDAR_CONFIG };
115
- const locale = partial.locale ?? DEFAULT_CALENDAR_CONFIG.locale;
116
- const names = buildDayNames(locale);
117
- return {
118
- ...DEFAULT_CALENDAR_CONFIG,
119
- ...partial,
120
- locale,
121
- shortDayNames: partial.shortDayNames ?? names.short,
122
- longDayNames: partial.longDayNames ?? names.long,
123
- };
124
- }
125
-
126
- /**
127
- * Injection token for the calendar date formatter.
128
- *
129
- * @example
130
- * ```ts
131
- * providers: [
132
- * { provide: CALENDAR_DATE_FORMATTER, useClass: MyCustomFormatter }
133
- * ]
134
- * ```
135
- */
136
- const CALENDAR_DATE_FORMATTER = new InjectionToken('CalendarDateFormatter');
137
-
138
- /**
139
- * Default implementation of {@link CalendarDateFormatter} that uses the
140
- * browser's `Intl.DateTimeFormat` API for locale-aware formatting.
141
- *
142
- * The locale is read from the injected {@link CALENDAR_CONFIG}. If no config
143
- * is provided, `'en-US'` is used as the fallback.
144
- *
145
- * This service has no dependency on `@ngx-translate` or any other i18n library,
146
- * so the calendar library works out of the box. Consumers can replace it with
147
- * their own implementation via the `CALENDAR_DATE_FORMATTER` injection token.
148
- */
149
- class DefaultCalendarDateFormatter {
150
- locale;
151
- constructor() {
152
- const config = inject(CALENDAR_CONFIG, { optional: true });
153
- this.locale = config?.locale ?? DEFAULT_CALENDAR_CONFIG.locale;
154
- }
155
- /** Formats an hour and minute pair into a locale time string (e.g. "09:00 AM"). */
156
- formatTimeI(hour, minute) {
157
- const date = new Date();
158
- date.setHours(hour, minute, 0, 0);
159
- return Promise.resolve(date.toLocaleTimeString(this.locale, { hour: '2-digit', minute: '2-digit' }));
160
- }
161
- /** Formats the time portion of a Date (e.g. "2:30 PM"). Returns empty string for undefined. */
162
- formatTime(date) {
163
- if (!date)
164
- return Promise.resolve('');
165
- return Promise.resolve(date.toLocaleTimeString(this.locale, { hour: '2-digit', minute: '2-digit' }));
166
- }
167
- /** Formats a Date as a full date-time string (e.g. "May 15, 2026, 02:30 PM"). */
168
- formatDateTime(date) {
169
- return of(date.toLocaleString(this.locale, {
170
- year: 'numeric', month: 'short', day: 'numeric',
171
- hour: '2-digit', minute: '2-digit'
172
- }));
173
- }
174
- /** Formats a Date as a date-only string (e.g. "May 15, 2026"). */
175
- formatDate(date) {
176
- return of(date.toLocaleDateString(this.locale, {
177
- year: 'numeric', month: 'short', day: 'numeric'
178
- }));
179
- }
180
- /** Formats a Date as `YYYY-MM-DD` for use in `<input type="date">` controls. */
181
- formatDateForFormControl(date) {
182
- const y = date.getFullYear();
183
- const m = String(date.getMonth() + 1).padStart(2, '0');
184
- const d = String(date.getDate()).padStart(2, '0');
185
- return `${y}-${m}-${d}`;
186
- }
187
- /** Returns `true` if both dates fall on the same calendar day. */
188
- isSameDay(date1, date2) {
189
- return date1.getFullYear() === date2.getFullYear()
190
- && date1.getMonth() === date2.getMonth()
191
- && date1.getDate() === date2.getDate();
192
- }
193
- /** Formats a Date as "Month Year" (e.g. "January 2026"). */
194
- formatMonthName(date) {
195
- return Promise.resolve(date.toLocaleString(this.locale, { month: 'long', year: 'numeric' }));
196
- }
197
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: DefaultCalendarDateFormatter, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
198
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: DefaultCalendarDateFormatter });
60
+ if (!partial) return { ...DEFAULT_CALENDAR_CONFIG };
61
+ const locale = partial.locale ?? DEFAULT_CALENDAR_CONFIG.locale;
62
+ const names = buildDayNames(locale);
63
+ return {
64
+ ...DEFAULT_CALENDAR_CONFIG,
65
+ ...partial,
66
+ locale,
67
+ shortDayNames: partial.shortDayNames ?? names.short,
68
+ longDayNames: partial.longDayNames ?? names.long
69
+ };
199
70
  }
200
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: DefaultCalendarDateFormatter, decorators: [{
201
- type: Injectable
202
- }], ctorParameters: () => [] });
203
-
204
- /**
205
- * Service that computes the visual layout of calendar events within a
206
- * time-grid (week or day view).
207
- *
208
- * Responsibilities:
209
- * - Splitting multi-day events into per-day segments.
210
- * - Assigning non-overlapping column indices to concurrent events.
211
- * - Computing the width (column span) each event should occupy.
212
- *
213
- * This service is stateless — all state is passed via method parameters.
214
- * Provide it per-component (not root) so each view gets its own instance.
215
- */
216
- class CalendarEventLayoutService {
217
- /**
218
- * Returns `true` when two time ranges overlap (exclusive boundaries).
219
- */
220
- eventsOverlap(startA, endA, startB, endB) {
221
- return startA < endB && startB < endA;
222
- }
223
- /**
224
- * Returns all events whose time range overlaps the given `[start, end)` window.
225
- */
226
- getAllEventsOnSpecificTime(events, start, end) {
227
- return events.filter(e => this.eventsOverlap(e.startTime, e.endTime, start, end));
228
- }
229
- /**
230
- * Splits multi-day events into per-day segments that fit within the
231
- * visible hour range (`startHour`–`endHour`) and date range.
232
- *
233
- * Single-day events are shallow-copied as-is. Multi-day events produce
234
- * one segment per day with `continued` / `continuedEnd` flags set.
235
- */
236
- calculateMultiDayEvents(events, startHour, endHour, rangeStart, rangeEnd) {
237
- const result = [];
238
- for (const event of events) {
239
- const eventStart = new Date(event.startTime);
240
- const eventEnd = new Date(event.endTime);
241
- if (eventStart.toDateString() === eventEnd.toDateString()) {
242
- result.push({ ...event });
243
- continue;
244
- }
245
- const current = new Date(eventStart);
246
- let isFirst = true;
247
- while (current < eventEnd && current < rangeEnd) {
248
- if (current >= rangeStart) {
249
- const dayStart = new Date(current);
250
- const dayEnd = new Date(current);
251
- if (isFirst) {
252
- dayEnd.setHours(endHour, 0, 0, 0);
253
- }
254
- else {
255
- dayStart.setHours(startHour, 0, 0, 0);
256
- if (current.toDateString() === eventEnd.toDateString()) {
257
- dayEnd.setHours(eventEnd.getHours(), eventEnd.getMinutes(), 0, 0);
258
- }
259
- else {
260
- dayEnd.setHours(endHour, 0, 0, 0);
261
- }
262
- }
263
- result.push({
264
- ...event,
265
- startTime: isFirst ? eventStart : dayStart,
266
- endTime: current.toDateString() === eventEnd.toDateString() ? eventEnd : dayEnd,
267
- continued: !isFirst,
268
- continuedEnd: current.toDateString() !== eventEnd.toDateString()
269
- });
270
- }
271
- isFirst = false;
272
- current.setDate(current.getDate() + 1);
273
- current.setHours(0, 0, 0, 0);
274
- }
275
- }
276
- return result;
277
- }
278
- /**
279
- * Assigns a zero-based `column` index to each event so that overlapping
280
- * events occupy different columns.
281
- *
282
- * Events are processed in start-time order (longest duration first for ties).
283
- * Each event gets the earliest column not already occupied by an overlapping event.
284
- */
285
- assignColumnsToEvents(events) {
286
- const sorted = [...events].sort((a, b) => {
287
- const diff = a.startTime.getTime() - b.startTime.getTime();
288
- if (diff !== 0)
289
- return diff;
290
- return (b.endTime.getTime() - b.startTime.getTime()) - (a.endTime.getTime() - a.startTime.getTime());
291
- });
292
- for (const event of sorted) {
293
- event.column = this.findEarliestPossibleColumn(event, sorted);
294
- }
295
- }
296
- /**
297
- * Assigns a `width` (column span) to each event, expanding it to fill
298
- * unused columns to its right within the overlapping group.
299
- */
300
- assignWidthsToEvents(events, scanStart, scanEnd) {
301
- for (const event of events) {
302
- const overlapping = this.getAllEventsOnSpecificTime(events, event.startTime, event.endTime);
303
- const maxCol = Math.max(...overlapping.map(e => e.column ?? 0));
304
- const biggestPossible = this.findBiggestPossibleWidth(event, events, scanStart, scanEnd);
305
- event.width = Math.max(1, biggestPossible);
306
- if ((event.column ?? 0) + event.width > maxCol + 1) {
307
- event.width = maxCol + 1 - (event.column ?? 0);
308
- }
309
- if (event.width < 1)
310
- event.width = 1;
311
- }
312
- }
313
- /** Finds the lowest column index not occupied by any overlapping event. */
314
- findEarliestPossibleColumn(event, allEvents) {
315
- const overlapping = allEvents.filter(e => e !== event
316
- && e.column !== undefined
317
- && this.eventsOverlap(e.startTime, e.endTime, event.startTime, event.endTime));
318
- let column = 0;
319
- while (overlapping.some(e => e.column === column)) {
320
- column++;
321
- }
322
- return column;
323
- }
324
- /** Computes the maximum width an event can span without overlapping a neighbour to its right. */
325
- findBiggestPossibleWidth(event, allEvents, _scanStart, _scanEnd) {
326
- const overlapping = this.getAllEventsOnSpecificTime(allEvents, event.startTime, event.endTime);
327
- const maxCol = Math.max(...overlapping.map(e => e.column ?? 0));
328
- const totalColumns = maxCol + 1;
329
- const occupiedCols = overlapping
330
- .filter(e => e !== event && (e.column ?? 0) > (event.column ?? 0))
331
- .map(e => e.column ?? 0);
332
- if (occupiedCols.length === 0) {
333
- return totalColumns - (event.column ?? 0);
334
- }
335
- return Math.min(...occupiedCols) - (event.column ?? 0);
336
- }
337
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: CalendarEventLayoutService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
338
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: CalendarEventLayoutService });
339
- }
340
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: CalendarEventLayoutService, decorators: [{
341
- type: Injectable
342
- }] });
343
-
344
- /**
345
- * Static utility methods for calendar grid positioning.
346
- */
347
- class CalendarUtility {
348
- /**
349
- * Converts a weekday (from `Date.getDay()`) to a 1-based Monday-first column index.
350
- * Monday = 1, Tuesday = 2, …, Sunday = 7.
351
- */
352
- static getCorrectColumn(date) {
353
- const day = date.getDay();
354
- return day === 0 ? 7 : day;
355
- }
356
- /**
357
- * Converts an hour + minute pair to a 1-based CSS grid row index
358
- * within a half-hour grid starting at `startHour`.
359
- *
360
- * Each hour occupies two rows (one per 30-minute slot).
361
- * Formula: `(hour - startHour) * 2 + (minute >= 30 ? 1 : 0) + 1`
362
- *
363
- * @returns Grid row number (minimum 1).
364
- */
365
- static getCorrectRow(hour, minute, startHour) {
366
- const hourOffset = hour - startHour;
367
- const row = hourOffset * 2 + (minute >= 30 ? 1 : 0) + 1;
368
- return Math.max(1, row);
369
- }
370
- }
371
-
372
- /**
373
- * Generated bundle index. Do not edit.
374
- */
375
-
71
+ const CALENDAR_DATE_FORMATTER = new InjectionToken("CalendarDateFormatter");
72
+ var DefaultCalendarDateFormatter = class DefaultCalendarDateFormatter {
73
+ locale;
74
+ constructor() {
75
+ const config = inject(CALENDAR_CONFIG, { optional: true });
76
+ this.locale = config?.locale ?? DEFAULT_CALENDAR_CONFIG.locale;
77
+ }
78
+ formatTimeI(hour, minute) {
79
+ const date = /* @__PURE__ */ new Date();
80
+ date.setHours(hour, minute, 0, 0);
81
+ return Promise.resolve(date.toLocaleTimeString(this.locale, {
82
+ hour: "2-digit",
83
+ minute: "2-digit"
84
+ }));
85
+ }
86
+ formatTime(date) {
87
+ if (!date) return Promise.resolve("");
88
+ return Promise.resolve(date.toLocaleTimeString(this.locale, {
89
+ hour: "2-digit",
90
+ minute: "2-digit"
91
+ }));
92
+ }
93
+ formatDateTime(date) {
94
+ return of(date.toLocaleString(this.locale, {
95
+ year: "numeric",
96
+ month: "short",
97
+ day: "numeric",
98
+ hour: "2-digit",
99
+ minute: "2-digit"
100
+ }));
101
+ }
102
+ formatDate(date) {
103
+ return of(date.toLocaleDateString(this.locale, {
104
+ year: "numeric",
105
+ month: "short",
106
+ day: "numeric"
107
+ }));
108
+ }
109
+ formatDateForFormControl(date) {
110
+ return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
111
+ }
112
+ isSameDay(date1, date2) {
113
+ return date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth() && date1.getDate() === date2.getDate();
114
+ }
115
+ formatMonthName(date) {
116
+ return Promise.resolve(date.toLocaleString(this.locale, {
117
+ month: "long",
118
+ year: "numeric"
119
+ }));
120
+ }
121
+ static ɵfac = i0.ɵɵngDeclareFactory({
122
+ minVersion: "12.0.0",
123
+ version: "22.2.2",
124
+ ngImport: i0,
125
+ type: DefaultCalendarDateFormatter,
126
+ deps: [],
127
+ target: i0.ɵɵFactoryTarget.Injectable
128
+ });
129
+ static ɵprov = i0.ɵɵngDeclareInjectable({
130
+ minVersion: "12.0.0",
131
+ version: "22.2.2",
132
+ ngImport: i0,
133
+ type: DefaultCalendarDateFormatter
134
+ });
135
+ };
136
+ i0.ɵɵngDeclareClassMetadata({
137
+ minVersion: "12.0.0",
138
+ version: "22.2.2",
139
+ ngImport: i0,
140
+ type: DefaultCalendarDateFormatter,
141
+ decorators: [{ type: Injectable }],
142
+ ctorParameters: () => []
143
+ });
144
+ var CalendarEventLayoutService = class CalendarEventLayoutService {
145
+ eventsOverlap(startA, endA, startB, endB) {
146
+ return startA < endB && startB < endA;
147
+ }
148
+ getAllEventsOnSpecificTime(events, start, end) {
149
+ return events.filter((e) => this.eventsOverlap(e.startTime, e.endTime, start, end));
150
+ }
151
+ calculateMultiDayEvents(events, startHour, endHour, rangeStart, rangeEnd) {
152
+ const result = [];
153
+ for (const event of events) {
154
+ const eventStart = new Date(event.startTime);
155
+ const eventEnd = new Date(event.endTime);
156
+ if (eventStart.toDateString() === eventEnd.toDateString()) {
157
+ result.push({ ...event });
158
+ continue;
159
+ }
160
+ const current = new Date(eventStart);
161
+ let isFirst = true;
162
+ while (current < eventEnd && current < rangeEnd) {
163
+ if (current >= rangeStart) {
164
+ const dayStart = new Date(current);
165
+ const dayEnd = new Date(current);
166
+ if (isFirst) dayEnd.setHours(endHour, 0, 0, 0);
167
+ else {
168
+ dayStart.setHours(startHour, 0, 0, 0);
169
+ if (current.toDateString() === eventEnd.toDateString()) dayEnd.setHours(eventEnd.getHours(), eventEnd.getMinutes(), 0, 0);
170
+ else dayEnd.setHours(endHour, 0, 0, 0);
171
+ }
172
+ result.push({
173
+ ...event,
174
+ startTime: isFirst ? eventStart : dayStart,
175
+ endTime: current.toDateString() === eventEnd.toDateString() ? eventEnd : dayEnd,
176
+ continued: !isFirst,
177
+ continuedEnd: current.toDateString() !== eventEnd.toDateString()
178
+ });
179
+ }
180
+ isFirst = false;
181
+ current.setDate(current.getDate() + 1);
182
+ current.setHours(0, 0, 0, 0);
183
+ }
184
+ }
185
+ return result;
186
+ }
187
+ assignColumnsToEvents(events) {
188
+ const sorted = [...events].sort((a, b) => {
189
+ const diff = a.startTime.getTime() - b.startTime.getTime();
190
+ if (diff !== 0) return diff;
191
+ return b.endTime.getTime() - b.startTime.getTime() - (a.endTime.getTime() - a.startTime.getTime());
192
+ });
193
+ for (const event of sorted) event.column = this.findEarliestPossibleColumn(event, sorted);
194
+ }
195
+ assignWidthsToEvents(events, scanStart, scanEnd) {
196
+ for (const event of events) {
197
+ const overlapping = this.getAllEventsOnSpecificTime(events, event.startTime, event.endTime);
198
+ const maxCol = Math.max(...overlapping.map((e) => e.column ?? 0));
199
+ const biggestPossible = this.findBiggestPossibleWidth(event, events, scanStart, scanEnd);
200
+ event.width = Math.max(1, biggestPossible);
201
+ if ((event.column ?? 0) + event.width > maxCol + 1) event.width = maxCol + 1 - (event.column ?? 0);
202
+ if (event.width < 1) event.width = 1;
203
+ }
204
+ }
205
+ findEarliestPossibleColumn(event, allEvents) {
206
+ const overlapping = allEvents.filter((e) => e !== event && e.column !== void 0 && this.eventsOverlap(e.startTime, e.endTime, event.startTime, event.endTime));
207
+ let column = 0;
208
+ while (overlapping.some((e) => e.column === column)) column++;
209
+ return column;
210
+ }
211
+ findBiggestPossibleWidth(event, allEvents, _scanStart, _scanEnd) {
212
+ const overlapping = this.getAllEventsOnSpecificTime(allEvents, event.startTime, event.endTime);
213
+ const totalColumns = Math.max(...overlapping.map((e) => e.column ?? 0)) + 1;
214
+ const occupiedCols = overlapping.filter((e) => e !== event && (e.column ?? 0) > (event.column ?? 0)).map((e) => e.column ?? 0);
215
+ if (occupiedCols.length === 0) return totalColumns - (event.column ?? 0);
216
+ return Math.min(...occupiedCols) - (event.column ?? 0);
217
+ }
218
+ static ɵfac = i0.ɵɵngDeclareFactory({
219
+ minVersion: "12.0.0",
220
+ version: "22.2.2",
221
+ ngImport: i0,
222
+ type: CalendarEventLayoutService,
223
+ deps: [],
224
+ target: i0.ɵɵFactoryTarget.Injectable
225
+ });
226
+ static ɵprov = i0.ɵɵngDeclareInjectable({
227
+ minVersion: "12.0.0",
228
+ version: "22.2.2",
229
+ ngImport: i0,
230
+ type: CalendarEventLayoutService
231
+ });
232
+ };
233
+ i0.ɵɵngDeclareClassMetadata({
234
+ minVersion: "12.0.0",
235
+ version: "22.2.2",
236
+ ngImport: i0,
237
+ type: CalendarEventLayoutService,
238
+ decorators: [{ type: Injectable }]
239
+ });
240
+ var CalendarUtility = class {
241
+ static getCorrectColumn(date) {
242
+ const day = date.getDay();
243
+ return day === 0 ? 7 : day;
244
+ }
245
+ static getCorrectRow(hour, minute, startHour) {
246
+ const row = (hour - startHour) * 2 + (minute >= 30 ? 1 : 0) + 1;
247
+ return Math.max(1, row);
248
+ }
249
+ };
376
250
  export { CALENDAR_CONFIG, CALENDAR_DATE_FORMATTER, CalendarEventLayoutService, CalendarUtility, CalendarView, DEFAULT_CALENDAR_CONFIG, DefaultCalendarDateFormatter, MN_CALENDAR_COMPONENT_NAME, MN_CALENDAR_CONFIG, provideMnCalendarConfig, resolveCalendarConfig };
377
- //# sourceMappingURL=mn-angular-lib-calendar-core.mjs.map
251
+
252
+ //# sourceMappingURL=mn-angular-lib-calendar-core.mjs.map