@spartan-ng/brain 1.11.0-beta.2 → 1.11.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spartan-ng/brain",
3
- "version": "1.11.0-beta.2",
3
+ "version": "1.11.0",
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,19 +254,62 @@ 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;
254
313
  /** Whether the select value is being synced from the calendar rather than picked by the user */
255
314
  private _syncing;
256
315
  protected readonly _selectedMonth: _angular_core.Signal<string>;
@@ -310,6 +369,8 @@ declare class BrnCalendarPreviousButton {
310
369
  declare class BrnCalendarWeek<T> implements OnDestroy {
311
370
  /** Access the calendar */
312
371
  private readonly _calendar;
372
+ /** Access the month this week belongs to, if rendering multiple months */
373
+ private readonly _month;
313
374
  /** Access the view container ref */
314
375
  private readonly _viewContainerRef;
315
376
  /** Access the change detector */
@@ -333,6 +394,8 @@ interface BrnWeekContext<T> {
333
394
  declare class BrnCalendarWeekday<T> implements OnDestroy {
334
395
  /** Access the calendar */
335
396
  private readonly _calendar;
397
+ /** Access the month these weekdays belong to, if rendering multiple months */
398
+ private readonly _month;
336
399
  /** Access the date time adapter */
337
400
  private readonly _dateAdapter;
338
401
  /** Access the view container ref */
@@ -361,6 +424,10 @@ declare class BrnCalendarYearSelect {
361
424
  private readonly _select;
362
425
  /** Access the calendar */
363
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;
364
431
  /** Access the date adapter */
365
432
  private readonly _dateAdapter;
366
433
  /** Access the calendar i18n */
@@ -477,6 +544,8 @@ declare class BrnCalendarRange<T> implements BrnCalendarBase<T> {
477
544
  protected readonly _weekStartsOn: _angular_core.Signal<Weekday>;
478
545
  /** The default focused date. */
479
546
  readonly defaultFocusedDate: _angular_core.InputSignal<T | undefined>;
547
+ /** The number of months to display. */
548
+ readonly numberOfMonths: _angular_core.InputSignalWithTransform<number, NumberInput>;
480
549
  /** @internal Access the header */
481
550
  readonly header: _angular_core.Signal<BrnCalendarHeader | undefined>;
482
551
  /**
@@ -494,11 +563,23 @@ declare class BrnCalendarRange<T> implements BrnCalendarBase<T> {
494
563
  * The selected end date
495
564
  */
496
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>[]>;
497
573
  /**
498
574
  * Get all the days to display, this is the days of the current month
499
575
  * and the days of the previous and next month to fill the grid.
500
576
  */
501
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;
502
583
  isSelected(date: T): boolean;
503
584
  selectDate(date: T): void;
504
585
  /** @internal Constrain a date to the min and max boundaries */
@@ -531,7 +612,7 @@ declare class BrnCalendarRange<T> implements BrnCalendarBase<T> {
531
612
  unregisterCalendarCell(cell: BrnCalendarCellButton<T>): void;
532
613
  registerCalendarCell(cell: BrnCalendarCellButton<T>): void;
533
614
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<BrnCalendarRange<any>, never>;
534
- 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>;
535
616
  }
536
617
 
537
618
  declare class BrnMonthYearCalendarHeader {
@@ -749,7 +830,7 @@ declare class BrnMonthYearCalendarYearButton<T> {
749
830
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BrnMonthYearCalendarYearButton<any>, "button[brnMonthYearCalendarYearButton]", ["brnMonthYearCalendarYearButton"], { "date": { "alias": "date"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
750
831
  }
751
832
 
752
- 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];
753
834
 
754
- 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 };
755
- 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 };