@spartan-ng/brain 1.11.0-beta.1 → 1.11.0-beta.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spartan-ng/brain",
3
- "version": "1.11.0-beta.1",
3
+ "version": "1.11.0-beta.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/spartan-ng/spartan.git"
@@ -10,6 +10,8 @@ declare class BrnCalendarCellButton<T> {
10
10
  private readonly _destroyRef;
11
11
  /** Access the calendar component */
12
12
  protected readonly _calendar: _spartan_ng_brain_calendar.BrnCalendarBase<T>;
13
+ /** Access the month this cell belongs to, if rendering multiple months */
14
+ private readonly _month;
13
15
  /** Access the element ref */
14
16
  private readonly _elementRef;
15
17
  /** The date this cell represents */
@@ -21,8 +23,12 @@ declare class BrnCalendarCellButton<T> {
21
23
  readonly betweenRange: _angular_core.Signal<boolean>;
22
24
  readonly highlighted: _angular_core.Signal<boolean>;
23
25
  constructor();
24
- /** Whether this date is focusable */
26
+ /**
27
+ * Whether this date is focusable.
28
+ * Days outside of their month are never focusable, as the same date is also rendered within its own month.
29
+ */
25
30
  readonly focusable: _angular_core.Signal<boolean>;
31
+ /** Whether this date is outside of the month it is rendered in */
26
32
  readonly outside: _angular_core.Signal<boolean>;
27
33
  /** Whether this date is today */
28
34
  readonly today: _angular_core.Signal<boolean>;
@@ -77,6 +83,12 @@ declare class BrnCalendarHeader {
77
83
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCalendarHeader, "[brnCalendarHeader]", ["brnCalendarHeader"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
78
84
  }
79
85
 
86
+ interface BrnCalendarMonthData<T> {
87
+ /** The first day of the displayed month. */
88
+ month: T;
89
+ /** The days to render for this month, including the leading and trailing days of the adjacent months. */
90
+ days: T[];
91
+ }
80
92
  interface BrnCalendarBase<T> {
81
93
  isSelected: (date: T) => boolean;
82
94
  selectDate: (date: T) => void;
@@ -93,6 +105,10 @@ interface BrnCalendarBase<T> {
93
105
  header: Signal<BrnCalendarHeader | undefined>;
94
106
  days: Signal<T[]>;
95
107
  highlightDays: InputSignal<T[]>;
108
+ /** The months to display. Only implemented by calendars that support rendering multiple months. */
109
+ months?: Signal<BrnCalendarMonthData<T>[]>;
110
+ /** Show the month of the given date at the given month offset. */
111
+ showMonth?: (date: T, offset: number) => void;
96
112
  unregisterCalendarCell(cell: BrnCalendarCellButton<T>): void;
97
113
  registerCalendarCell(cell: BrnCalendarCellButton<T>): void;
98
114
  }
@@ -238,23 +254,70 @@ declare class BrnCalendarCell {
238
254
  declare class BrnCalendarGrid<T> {
239
255
  /** Access the calendar component */
240
256
  protected readonly _calendar: _spartan_ng_brain_calendar.BrnCalendarBase<T>;
257
+ /** Access the month this grid belongs to, if rendering multiple months */
258
+ protected readonly _month: _spartan_ng_brain_calendar.BrnCalendarMonthContext<T> | null;
241
259
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnCalendarGrid<any>, never>;
242
260
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCalendarGrid<any>, "[brnCalendarGrid]", ["brnCalendarGrid"], {}, {}, never, never, true, never>;
243
261
  }
244
262
 
263
+ interface BrnCalendarMonthContext<T> {
264
+ /** The first day of the displayed month. */
265
+ month: Signal<T>;
266
+ /** The days to render for this month. */
267
+ days: Signal<T[]>;
268
+ /** The header of this month. */
269
+ header: Signal<BrnCalendarHeader | undefined>;
270
+ /** The offset of this month relative to the first displayed month. */
271
+ offset: Signal<number>;
272
+ }
273
+ declare const BrnCalendarMonthToken: InjectionToken<BrnCalendarMonthContext<unknown>>;
274
+ /**
275
+ * Inject the month context, if the element is rendered within a `brnCalendarMonth`.
276
+ */
277
+ declare function injectBrnCalendarMonth<T>(): BrnCalendarMonthContext<T> | null;
278
+ /**
279
+ * Scopes the grid, weeks, weekdays, cells, header and selects within it to a single displayed month.
280
+ * Use it to render multiple months, e.g. with `numberOfMonths` on `brnCalendarRange`.
281
+ */
282
+ declare class BrnCalendarMonth<T> implements BrnCalendarMonthContext<T> {
283
+ /** Access the calendar */
284
+ private readonly _calendar;
285
+ /** Access the date adapter */
286
+ private readonly _dateAdapter;
287
+ /** The offset of this month relative to the first displayed month. */
288
+ readonly offset: _angular_core.InputSignalWithTransform<number, NumberInput>;
289
+ /** @internal The header of this month. */
290
+ readonly header: Signal<BrnCalendarHeader | undefined>;
291
+ private readonly _data;
292
+ /** The first day of the displayed month. */
293
+ readonly month: Signal<T>;
294
+ /** The days to render for this month. */
295
+ readonly days: Signal<T[]>;
296
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnCalendarMonth<any>, never>;
297
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCalendarMonth<any>, "[brnCalendarMonth]", ["brnCalendarMonth"], { "offset": { "alias": "offset"; "required": false; "isSignal": true; }; }, {}, ["header"], never, true, never>;
298
+ }
299
+
245
300
  declare class BrnCalendarMonthSelect {
246
301
  /** Access the select */
247
302
  private readonly _select;
248
303
  /** Access the calendar */
249
304
  private readonly _calendar;
305
+ /** Access the month this select belongs to, if rendering multiple months */
306
+ private readonly _month;
250
307
  /** Access the date adapter */
251
308
  private readonly _dateAdapter;
252
309
  /** Access the calendar i18n */
253
310
  protected readonly _i18n: _spartan_ng_brain_calendar.BrnCalendarI18nService;
311
+ /** The month displayed by this select */
312
+ private readonly _displayedMonth;
313
+ /** Whether the select value is being synced from the calendar rather than picked by the user */
314
+ private _syncing;
254
315
  protected readonly _selectedMonth: _angular_core.Signal<string>;
255
316
  constructor();
256
317
  /** Focus selected month */
257
318
  private monthSelected;
319
+ /** Write the calendar's value into the select without treating it as a user selection */
320
+ private _syncSelect;
258
321
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnCalendarMonthSelect, never>;
259
322
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCalendarMonthSelect, "brnSelect[brnCalendarMonthSelect],hlm-select[brnCalendarMonthSelect]", ["brnCalendarMonthSelect"], {}, {}, never, never, true, never>;
260
323
  }
@@ -306,6 +369,8 @@ declare class BrnCalendarPreviousButton {
306
369
  declare class BrnCalendarWeek<T> implements OnDestroy {
307
370
  /** Access the calendar */
308
371
  private readonly _calendar;
372
+ /** Access the month this week belongs to, if rendering multiple months */
373
+ private readonly _month;
309
374
  /** Access the view container ref */
310
375
  private readonly _viewContainerRef;
311
376
  /** Access the change detector */
@@ -329,6 +394,8 @@ interface BrnWeekContext<T> {
329
394
  declare class BrnCalendarWeekday<T> implements OnDestroy {
330
395
  /** Access the calendar */
331
396
  private readonly _calendar;
397
+ /** Access the month these weekdays belong to, if rendering multiple months */
398
+ private readonly _month;
332
399
  /** Access the date time adapter */
333
400
  private readonly _dateAdapter;
334
401
  /** Access the view container ref */
@@ -357,13 +424,21 @@ declare class BrnCalendarYearSelect {
357
424
  private readonly _select;
358
425
  /** Access the calendar */
359
426
  private readonly _calendar;
427
+ /** Access the month this select belongs to, if rendering multiple months */
428
+ private readonly _month;
429
+ /** The month displayed by this select */
430
+ private readonly _displayedMonth;
360
431
  /** Access the date adapter */
361
432
  private readonly _dateAdapter;
362
433
  /** Access the calendar i18n */
363
434
  protected readonly _i18n: _spartan_ng_brain_calendar.BrnCalendarI18nService;
435
+ /** Whether the select value is being synced from the calendar rather than picked by the user */
436
+ private _syncing;
364
437
  constructor();
365
438
  /** Focus selected year */
366
439
  private yearSelected;
440
+ /** Write the calendar's value into the select without treating it as a user selection */
441
+ private _syncSelect;
367
442
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnCalendarYearSelect, never>;
368
443
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCalendarYearSelect, "brnSelect[brnCalendarYearSelect],hlm-select[brnCalendarYearSelect]", ["brnCalendarYearSelect"], {}, {}, never, never, true, never>;
369
444
  }
@@ -469,6 +544,8 @@ declare class BrnCalendarRange<T> implements BrnCalendarBase<T> {
469
544
  protected readonly _weekStartsOn: _angular_core.Signal<Weekday>;
470
545
  /** The default focused date. */
471
546
  readonly defaultFocusedDate: _angular_core.InputSignal<T | undefined>;
547
+ /** The number of months to display. */
548
+ readonly numberOfMonths: _angular_core.InputSignalWithTransform<number, NumberInput>;
472
549
  /** @internal Access the header */
473
550
  readonly header: _angular_core.Signal<BrnCalendarHeader | undefined>;
474
551
  /**
@@ -486,11 +563,23 @@ declare class BrnCalendarRange<T> implements BrnCalendarBase<T> {
486
563
  * The selected end date
487
564
  */
488
565
  readonly endDate: _angular_core.ModelSignal<T | undefined>;
566
+ /**
567
+ * The first displayed month. It only moves when the focused date leaves the displayed months,
568
+ * so navigating within the displayed months does not shift them.
569
+ */
570
+ private readonly _firstMonth;
571
+ /** The months to display, starting with the first displayed month. */
572
+ readonly months: _angular_core.Signal<BrnCalendarMonthData<T>[]>;
489
573
  /**
490
574
  * Get all the days to display, this is the days of the current month
491
575
  * and the days of the previous and next month to fill the grid.
492
576
  */
493
577
  readonly days: _angular_core.Signal<T[]>;
578
+ /** Show the month of the given date at the given offset of the displayed months. */
579
+ showMonth(date: T, offset: number): void;
580
+ private _monthDifference;
581
+ /** Get the days of the month of the given date, padded to full weeks. */
582
+ private _getDays;
494
583
  isSelected(date: T): boolean;
495
584
  selectDate(date: T): void;
496
585
  /** @internal Constrain a date to the min and max boundaries */
@@ -523,7 +612,7 @@ declare class BrnCalendarRange<T> implements BrnCalendarBase<T> {
523
612
  unregisterCalendarCell(cell: BrnCalendarCellButton<T>): void;
524
613
  registerCalendarCell(cell: BrnCalendarCellButton<T>): void;
525
614
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnCalendarRange<any>, never>;
526
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCalendarRange<any>, "[brnCalendarRange]", ["brnCalendarRange"], { "highlightDays": { "alias": "highlightDays"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "dateDisabled": { "alias": "dateDisabled"; "required": false; "isSignal": true; }; "weekStartsOn": { "alias": "weekStartsOn"; "required": false; "isSignal": true; }; "defaultFocusedDate": { "alias": "defaultFocusedDate"; "required": false; "isSignal": true; }; "startDate": { "alias": "startDate"; "required": false; "isSignal": true; }; "endDate": { "alias": "endDate"; "required": false; "isSignal": true; }; }, { "focusedDateChange": "focusedDateChange"; "startDate": "startDateChange"; "endDate": "endDateChange"; }, ["header"], never, true, never>;
615
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnCalendarRange<any>, "[brnCalendarRange]", ["brnCalendarRange"], { "highlightDays": { "alias": "highlightDays"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "dateDisabled": { "alias": "dateDisabled"; "required": false; "isSignal": true; }; "weekStartsOn": { "alias": "weekStartsOn"; "required": false; "isSignal": true; }; "defaultFocusedDate": { "alias": "defaultFocusedDate"; "required": false; "isSignal": true; }; "numberOfMonths": { "alias": "numberOfMonths"; "required": false; "isSignal": true; }; "startDate": { "alias": "startDate"; "required": false; "isSignal": true; }; "endDate": { "alias": "endDate"; "required": false; "isSignal": true; }; }, { "focusedDateChange": "focusedDateChange"; "startDate": "startDateChange"; "endDate": "endDateChange"; }, ["header"], never, true, never>;
527
616
  }
528
617
 
529
618
  declare class BrnMonthYearCalendarHeader {
@@ -741,7 +830,7 @@ declare class BrnMonthYearCalendarYearButton<T> {
741
830
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnMonthYearCalendarYearButton<any>, "button[brnMonthYearCalendarYearButton]", ["brnMonthYearCalendarYearButton"], { "date": { "alias": "date"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
742
831
  }
743
832
 
744
- declare const BrnCalendarImports: readonly [typeof BrnCalendarCellButton, typeof BrnCalendarGrid, typeof BrnCalendarHeader, typeof BrnCalendarNextButton, typeof BrnCalendarPreviousButton, typeof BrnCalendarWeek, typeof BrnCalendarWeekday, typeof BrnCalendar, typeof BrnCalendarCell, typeof BrnCalendarMulti, typeof BrnCalendarRange, typeof BrnCalendarMonthSelect, typeof BrnCalendarYearSelect, typeof BrnMonthYearCalendar, typeof BrnMonthYearCalendarGrid, typeof BrnMonthYearCalendarHeader, typeof BrnMonthYearCalendarMonthButton, typeof BrnMonthYearCalendarNextButton, typeof BrnMonthYearCalendarPreviousButton, typeof BrnMonthYearCalendarYearButton];
833
+ declare const BrnCalendarImports: readonly [typeof BrnCalendarCellButton, typeof BrnCalendarGrid, typeof BrnCalendarHeader, typeof BrnCalendarNextButton, typeof BrnCalendarPreviousButton, typeof BrnCalendarWeek, typeof BrnCalendarWeekday, typeof BrnCalendar, typeof BrnCalendarCell, typeof BrnCalendarMonth, typeof BrnCalendarMulti, typeof BrnCalendarRange, typeof BrnCalendarMonthSelect, typeof BrnCalendarYearSelect, typeof BrnMonthYearCalendar, typeof BrnMonthYearCalendarGrid, typeof BrnMonthYearCalendarHeader, typeof BrnMonthYearCalendarMonthButton, typeof BrnMonthYearCalendarNextButton, typeof BrnMonthYearCalendarPreviousButton, typeof BrnMonthYearCalendarYearButton];
745
834
 
746
- export { BrnCalendar, BrnCalendarCell, BrnCalendarCellButton, BrnCalendarGrid, BrnCalendarHeader, BrnCalendarI18nService, BrnCalendarI18nToken, BrnCalendarImports, BrnCalendarMonthSelect, BrnCalendarMulti, BrnCalendarNextButton, BrnCalendarPreviousButton, BrnCalendarRange, BrnCalendarToken, BrnCalendarWeek, BrnCalendarWeekday, BrnCalendarYearSelect, BrnMonthYearCalendar, BrnMonthYearCalendarGrid, BrnMonthYearCalendarHeader, BrnMonthYearCalendarMonthButton, BrnMonthYearCalendarNextButton, BrnMonthYearCalendarPreviousButton, BrnMonthYearCalendarToken, BrnMonthYearCalendarYearButton, injectBrnCalendar, injectBrnCalendarI18n, injectBrnMonthYearCalendar, provideBrnCalendar, provideBrnCalendarI18n, provideBrnMonthYearCalendar };
747
- export type { BrnCalendarBase, BrnCalendarI18n, BrnMonthYearCalendarBase, BrnMonthYearCalendarCell, BrnMonthYearCalendarView, MonthLabels, Weekday };
835
+ export { BrnCalendar, BrnCalendarCell, BrnCalendarCellButton, BrnCalendarGrid, BrnCalendarHeader, BrnCalendarI18nService, BrnCalendarI18nToken, BrnCalendarImports, BrnCalendarMonth, BrnCalendarMonthSelect, BrnCalendarMonthToken, BrnCalendarMulti, BrnCalendarNextButton, BrnCalendarPreviousButton, BrnCalendarRange, BrnCalendarToken, BrnCalendarWeek, BrnCalendarWeekday, BrnCalendarYearSelect, BrnMonthYearCalendar, BrnMonthYearCalendarGrid, BrnMonthYearCalendarHeader, BrnMonthYearCalendarMonthButton, BrnMonthYearCalendarNextButton, BrnMonthYearCalendarPreviousButton, BrnMonthYearCalendarToken, BrnMonthYearCalendarYearButton, injectBrnCalendar, injectBrnCalendarI18n, injectBrnCalendarMonth, injectBrnMonthYearCalendar, provideBrnCalendar, provideBrnCalendarI18n, provideBrnMonthYearCalendar };
836
+ export type { BrnCalendarBase, BrnCalendarI18n, BrnCalendarMonthContext, BrnCalendarMonthData, BrnMonthYearCalendarBase, BrnMonthYearCalendarCell, BrnMonthYearCalendarView, MonthLabels, Weekday };