@spartan-ng/brain 0.0.1-alpha.717 → 0.0.1-alpha.719
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/fesm2022/spartan-ng-brain-calendar.mjs +229 -199
- package/fesm2022/spartan-ng-brain-calendar.mjs.map +1 -1
- package/fesm2022/spartan-ng-brain-resizable.mjs +60 -17
- package/fesm2022/spartan-ng-brain-resizable.mjs.map +1 -1
- package/package.json +1 -1
- package/types/spartan-ng-brain-calendar.d.ts +16 -9
- package/types/spartan-ng-brain-resizable.d.ts +7 -3
|
@@ -1,180 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { input, Directive, InjectionToken, inject, signal, Injectable, ChangeDetectorRef, Injector, booleanAttribute, model, numberAttribute, computed, contentChild, linkedSignal, afterNextRender, DestroyRef, ElementRef, effect, ViewContainerRef, TemplateRef, untracked } from '@angular/core';
|
|
3
3
|
import { injectDateAdapter } from '@spartan-ng/brain/date-time';
|
|
4
4
|
import { outputToObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
5
|
import { BrnSelect } from '@spartan-ng/brain/select';
|
|
6
6
|
|
|
7
|
-
const BrnCalendarToken = new InjectionToken('BrnCalendarToken');
|
|
8
|
-
function provideBrnCalendar(instance) {
|
|
9
|
-
return { provide: BrnCalendarToken, useExisting: instance };
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Inject the calendar component.
|
|
13
|
-
*/
|
|
14
|
-
function injectBrnCalendar() {
|
|
15
|
-
return inject(BrnCalendarToken);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
class BrnCalendarCellButton {
|
|
19
|
-
/** Access the date adapter */
|
|
20
|
-
_dateAdapter = injectDateAdapter();
|
|
21
|
-
/** Access the calendar component */
|
|
22
|
-
_calendar = injectBrnCalendar();
|
|
23
|
-
/** Access the element ref */
|
|
24
|
-
_elementRef = inject(ElementRef);
|
|
25
|
-
/** The date this cell represents */
|
|
26
|
-
date = input.required(...(ngDevMode ? [{ debugName: "date" }] : /* istanbul ignore next */ []));
|
|
27
|
-
/** Whether this date is currently selected */
|
|
28
|
-
selected = computed(() => this._calendar.isSelected(this.date()), ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
|
|
29
|
-
start = computed(() => this._calendar.isStartOfRange(this.date()), ...(ngDevMode ? [{ debugName: "start" }] : /* istanbul ignore next */ []));
|
|
30
|
-
end = computed(() => this._calendar.isEndOfRange(this.date()), ...(ngDevMode ? [{ debugName: "end" }] : /* istanbul ignore next */ []));
|
|
31
|
-
betweenRange = computed(() => this._calendar.isBetweenRange(this.date()), ...(ngDevMode ? [{ debugName: "betweenRange" }] : /* istanbul ignore next */ []));
|
|
32
|
-
highlighted = computed(() => this._calendar.highlightDays().some((d) => this._dateAdapter.isSameDay(this.date(), d)), ...(ngDevMode ? [{ debugName: "highlighted" }] : /* istanbul ignore next */ []));
|
|
33
|
-
/** Whether this date is focusable */
|
|
34
|
-
focusable = computed(() => this._dateAdapter.isSameDay(this._calendar.focusedDate(), this.date()), ...(ngDevMode ? [{ debugName: "focusable" }] : /* istanbul ignore next */ []));
|
|
35
|
-
outside = computed(() => {
|
|
36
|
-
const focusedDate = this._calendar.focusedDate();
|
|
37
|
-
return !this._dateAdapter.isSameMonth(this.date(), focusedDate);
|
|
38
|
-
}, ...(ngDevMode ? [{ debugName: "outside" }] : /* istanbul ignore next */ []));
|
|
39
|
-
/** Whether this date is today */
|
|
40
|
-
today = computed(() => this._dateAdapter.isSameDay(this.date(), this._dateAdapter.now()), ...(ngDevMode ? [{ debugName: "today" }] : /* istanbul ignore next */ []));
|
|
41
|
-
/** Whether this date is disabled */
|
|
42
|
-
disabled = computed(() => this._calendar.isDateDisabled(this.date()) || this._calendar.disabled(), ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
43
|
-
/**
|
|
44
|
-
* Focus the previous cell.
|
|
45
|
-
*/
|
|
46
|
-
focusPrevious(event) {
|
|
47
|
-
event.preventDefault();
|
|
48
|
-
event.stopPropagation();
|
|
49
|
-
// in rtl, the arrow keys are reversed.
|
|
50
|
-
const targetDate = this._dateAdapter.add(this._calendar.focusedDate(), {
|
|
51
|
-
days: this.getDirection() === 'rtl' ? 1 : -1,
|
|
52
|
-
});
|
|
53
|
-
this._calendar.setFocusedDate(targetDate);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Focus the next cell.
|
|
57
|
-
*/
|
|
58
|
-
focusNext(event) {
|
|
59
|
-
event.preventDefault();
|
|
60
|
-
event.stopPropagation();
|
|
61
|
-
const targetDate = this._dateAdapter.add(this._calendar.focusedDate(), {
|
|
62
|
-
days: this.getDirection() === 'rtl' ? -1 : 1,
|
|
63
|
-
});
|
|
64
|
-
this._calendar.setFocusedDate(targetDate);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Focus the above cell.
|
|
68
|
-
*/
|
|
69
|
-
focusAbove(event) {
|
|
70
|
-
event.preventDefault();
|
|
71
|
-
event.stopPropagation();
|
|
72
|
-
this._calendar.setFocusedDate(this._dateAdapter.subtract(this._calendar.focusedDate(), { days: 7 }));
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Focus the below cell.
|
|
76
|
-
*/
|
|
77
|
-
focusBelow(event) {
|
|
78
|
-
event.preventDefault();
|
|
79
|
-
event.stopPropagation();
|
|
80
|
-
this._calendar.setFocusedDate(this._dateAdapter.add(this._calendar.focusedDate(), { days: 7 }));
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Focus the first date of the month.
|
|
84
|
-
*/
|
|
85
|
-
focusFirst(event) {
|
|
86
|
-
event.preventDefault();
|
|
87
|
-
event.stopPropagation();
|
|
88
|
-
this._calendar.setFocusedDate(this._dateAdapter.startOfMonth(this._calendar.focusedDate()));
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Focus the last date of the month.
|
|
92
|
-
*/
|
|
93
|
-
focusLast(event) {
|
|
94
|
-
event.preventDefault();
|
|
95
|
-
event.stopPropagation();
|
|
96
|
-
this._calendar.setFocusedDate(this._dateAdapter.endOfMonth(this._calendar.focusedDate()));
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Focus the same date in the previous month.
|
|
100
|
-
*/
|
|
101
|
-
focusPreviousMonth(event) {
|
|
102
|
-
event.preventDefault();
|
|
103
|
-
event.stopPropagation();
|
|
104
|
-
const date = this._dateAdapter.getDate(this._calendar.focusedDate());
|
|
105
|
-
let previousMonthTarget = this._dateAdapter.startOfMonth(this._calendar.focusedDate());
|
|
106
|
-
previousMonthTarget = this._dateAdapter.subtract(previousMonthTarget, { months: 1 });
|
|
107
|
-
const lastDay = this._dateAdapter.endOfMonth(previousMonthTarget);
|
|
108
|
-
// if we are on a date that does not exist in the previous month, we should focus the last day of the month.
|
|
109
|
-
if (date > this._dateAdapter.getDate(lastDay)) {
|
|
110
|
-
this._calendar.setFocusedDate(lastDay);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
this._calendar.setFocusedDate(this._dateAdapter.set(previousMonthTarget, { day: date }));
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Focus the same date in the next month.
|
|
118
|
-
*/
|
|
119
|
-
focusNextMonth(event) {
|
|
120
|
-
event.preventDefault();
|
|
121
|
-
event.stopPropagation();
|
|
122
|
-
const date = this._dateAdapter.getDate(this._calendar.focusedDate());
|
|
123
|
-
let nextMonthTarget = this._dateAdapter.startOfMonth(this._calendar.focusedDate());
|
|
124
|
-
nextMonthTarget = this._dateAdapter.add(nextMonthTarget, { months: 1 });
|
|
125
|
-
const lastDay = this._dateAdapter.endOfMonth(nextMonthTarget);
|
|
126
|
-
// if we are on a date that does not exist in the next month, we should focus the last day of the month.
|
|
127
|
-
if (date > this._dateAdapter.getDate(lastDay)) {
|
|
128
|
-
this._calendar.setFocusedDate(lastDay);
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
this._calendar.setFocusedDate(this._dateAdapter.set(nextMonthTarget, { day: date }));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Get the direction of the element.
|
|
136
|
-
*/
|
|
137
|
-
getDirection() {
|
|
138
|
-
return getComputedStyle(this._elementRef.nativeElement).direction === 'rtl' ? 'rtl' : 'ltr';
|
|
139
|
-
}
|
|
140
|
-
focus() {
|
|
141
|
-
this._elementRef.nativeElement.focus();
|
|
142
|
-
}
|
|
143
|
-
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarCellButton, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
144
|
-
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.16", type: BrnCalendarCellButton, isStandalone: true, selector: "button[brnCalendarCellButton]", inputs: { date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "role": "gridcell", "type": "button" }, listeners: { "click": "_calendar.selectDate(date())", "keydown.arrowLeft": "focusPrevious($event)", "keydown.arrowRight": "focusNext($event)", "keydown.arrowUp": "focusAbove($event)", "keydown.arrowDown": "focusBelow($event)", "keydown.home": "focusFirst($event)", "keydown.end": "focusLast($event)", "keydown.pageUp": "focusPreviousMonth($event)", "keydown.pageDown": "focusNextMonth($event)" }, properties: { "tabindex": "focusable() ? 0 : -1", "attr.data-outside": "!selected() && outside() && (!end() && !start())? '' : null", "attr.data-today": "today() && !selected() ? '' : null", "attr.data-selected": "selected() ? '' : null", "attr.data-disabled": "disabled() ? '' : null", "attr.aria-selected": "selected() ? 'true' : null", "attr.aria-disabled": "disabled() ? 'true' : null", "attr.data-range-start": "start() ? \"\" : null", "attr.data-range-end": "end() ? \"\" : null", "attr.data-highlighted": "highlighted() ? \"\" : null", "attr.data-range-between": "betweenRange() ? \"\" : null", "disabled": "disabled()" } }, ngImport: i0 });
|
|
145
|
-
}
|
|
146
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarCellButton, decorators: [{
|
|
147
|
-
type: Directive,
|
|
148
|
-
args: [{
|
|
149
|
-
selector: 'button[brnCalendarCellButton]',
|
|
150
|
-
host: {
|
|
151
|
-
role: 'gridcell',
|
|
152
|
-
'[tabindex]': 'focusable() ? 0 : -1',
|
|
153
|
-
type: 'button',
|
|
154
|
-
'[attr.data-outside]': "!selected() && outside() && (!end() && !start())? '' : null",
|
|
155
|
-
'[attr.data-today]': "today() && !selected() ? '' : null",
|
|
156
|
-
'[attr.data-selected]': "selected() ? '' : null",
|
|
157
|
-
'[attr.data-disabled]': "disabled() ? '' : null",
|
|
158
|
-
'[attr.aria-selected]': "selected() ? 'true' : null",
|
|
159
|
-
'[attr.aria-disabled]': "disabled() ? 'true' : null",
|
|
160
|
-
'[attr.data-range-start]': 'start() ? "" : null',
|
|
161
|
-
'[attr.data-range-end]': 'end() ? "" : null',
|
|
162
|
-
'[attr.data-highlighted]': 'highlighted() ? "" : null',
|
|
163
|
-
'[attr.data-range-between]': 'betweenRange() ? "" : null',
|
|
164
|
-
'[disabled]': 'disabled()',
|
|
165
|
-
'(click)': '_calendar.selectDate(date())',
|
|
166
|
-
'(keydown.arrowLeft)': 'focusPrevious($event)',
|
|
167
|
-
'(keydown.arrowRight)': 'focusNext($event)',
|
|
168
|
-
'(keydown.arrowUp)': 'focusAbove($event)',
|
|
169
|
-
'(keydown.arrowDown)': 'focusBelow($event)',
|
|
170
|
-
'(keydown.home)': 'focusFirst($event)',
|
|
171
|
-
'(keydown.end)': 'focusLast($event)',
|
|
172
|
-
'(keydown.pageUp)': 'focusPreviousMonth($event)',
|
|
173
|
-
'(keydown.pageDown)': 'focusNextMonth($event)',
|
|
174
|
-
},
|
|
175
|
-
}]
|
|
176
|
-
}], propDecorators: { date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: true }] }] } });
|
|
177
|
-
|
|
178
7
|
let uniqueId = 0;
|
|
179
8
|
class BrnCalendarHeader {
|
|
180
9
|
/** The unique id for the header */
|
|
@@ -194,6 +23,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
194
23
|
}]
|
|
195
24
|
}], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }] } });
|
|
196
25
|
|
|
26
|
+
const BrnCalendarToken = new InjectionToken('BrnCalendarToken');
|
|
27
|
+
function provideBrnCalendar(instance) {
|
|
28
|
+
return { provide: BrnCalendarToken, useExisting: instance };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Inject the calendar component.
|
|
32
|
+
*/
|
|
33
|
+
function injectBrnCalendar() {
|
|
34
|
+
return inject(BrnCalendarToken);
|
|
35
|
+
}
|
|
36
|
+
|
|
197
37
|
const BrnCalendarI18nToken = new InjectionToken('BrnCalendarI18nToken');
|
|
198
38
|
/**
|
|
199
39
|
* Provide the calendar i18n configuration.
|
|
@@ -259,6 +99,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
259
99
|
args: [{ providedIn: 'root' }]
|
|
260
100
|
}] });
|
|
261
101
|
|
|
102
|
+
const compareDays = (a, b, dateAdapter) => {
|
|
103
|
+
if (a === b)
|
|
104
|
+
return true;
|
|
105
|
+
if (!a || !b)
|
|
106
|
+
return false;
|
|
107
|
+
if (a.length !== b.length)
|
|
108
|
+
return false;
|
|
109
|
+
return a.every((day, i) => dateAdapter.isSameDay(day, b[i]));
|
|
110
|
+
};
|
|
111
|
+
|
|
262
112
|
class BrnCalendar {
|
|
263
113
|
_i18n = injectBrnCalendarI18n();
|
|
264
114
|
/** Access the date adapter */
|
|
@@ -286,8 +136,7 @@ class BrnCalendar {
|
|
|
286
136
|
defaultFocusedDate = input(...(ngDevMode ? [undefined, { debugName: "defaultFocusedDate" }] : /* istanbul ignore next */ []));
|
|
287
137
|
/** @internal Access the header */
|
|
288
138
|
header = contentChild(BrnCalendarHeader, ...(ngDevMode ? [{ debugName: "header" }] : /* istanbul ignore next */ []));
|
|
289
|
-
|
|
290
|
-
_cells = contentChildren(BrnCalendarCellButton, { ...(ngDevMode ? { debugName: "_cells" } : /* istanbul ignore next */ {}), descendants: true });
|
|
139
|
+
_cells = [];
|
|
291
140
|
/**
|
|
292
141
|
* The focused date.
|
|
293
142
|
*/
|
|
@@ -318,7 +167,7 @@ class BrnCalendar {
|
|
|
318
167
|
firstDay = this._dateAdapter.add(firstDay, { days: 1 });
|
|
319
168
|
}
|
|
320
169
|
return days;
|
|
321
|
-
}, ...(ngDevMode ?
|
|
170
|
+
}, { ...(ngDevMode ? { debugName: "days" } : /* istanbul ignore next */ {}), equal: (a, b) => compareDays(a, b, this._dateAdapter) });
|
|
322
171
|
/** @internal Constrain a date to the min and max boundaries */
|
|
323
172
|
constrainDate(date) {
|
|
324
173
|
const min = this.min();
|
|
@@ -383,8 +232,7 @@ class BrnCalendar {
|
|
|
383
232
|
// wait until the cells have all updated
|
|
384
233
|
afterNextRender({
|
|
385
234
|
write: () => {
|
|
386
|
-
|
|
387
|
-
const cell = this._cells().find((c) => this._dateAdapter.isSameDay(c.date(), date));
|
|
235
|
+
const cell = this._cells.find((c) => this._dateAdapter.isSameDay(c.date(), date));
|
|
388
236
|
if (cell) {
|
|
389
237
|
cell.focus();
|
|
390
238
|
}
|
|
@@ -422,8 +270,17 @@ class BrnCalendar {
|
|
|
422
270
|
isBetweenRange(_) {
|
|
423
271
|
return false;
|
|
424
272
|
}
|
|
273
|
+
unregisterCalendarCell(cell) {
|
|
274
|
+
const index = this._cells.indexOf(cell);
|
|
275
|
+
if (index !== -1) {
|
|
276
|
+
this._cells.splice(index, 1);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
registerCalendarCell(cell) {
|
|
280
|
+
this._cells.push(cell);
|
|
281
|
+
}
|
|
425
282
|
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendar, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
426
|
-
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnCalendar, isStandalone: true, selector: "[brnCalendar]", inputs: { highlightDays: { classPropertyName: "highlightDays", publicName: "highlightDays", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: false, transformFunction: null }, dateDisabled: { classPropertyName: "dateDisabled", publicName: "dateDisabled", isSignal: true, isRequired: false, transformFunction: null }, weekStartsOn: { classPropertyName: "weekStartsOn", publicName: "weekStartsOn", isSignal: true, isRequired: false, transformFunction: null }, defaultFocusedDate: { classPropertyName: "defaultFocusedDate", publicName: "defaultFocusedDate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { date: "dateChange" }, providers: [provideBrnCalendar(BrnCalendar)], queries: [{ propertyName: "header", first: true, predicate: BrnCalendarHeader, descendants: true, isSignal: true }
|
|
283
|
+
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnCalendar, isStandalone: true, selector: "[brnCalendar]", inputs: { highlightDays: { classPropertyName: "highlightDays", publicName: "highlightDays", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: false, transformFunction: null }, dateDisabled: { classPropertyName: "dateDisabled", publicName: "dateDisabled", isSignal: true, isRequired: false, transformFunction: null }, weekStartsOn: { classPropertyName: "weekStartsOn", publicName: "weekStartsOn", isSignal: true, isRequired: false, transformFunction: null }, defaultFocusedDate: { classPropertyName: "defaultFocusedDate", publicName: "defaultFocusedDate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { date: "dateChange" }, providers: [provideBrnCalendar(BrnCalendar)], queries: [{ propertyName: "header", first: true, predicate: BrnCalendarHeader, descendants: true, isSignal: true }], ngImport: i0 });
|
|
427
284
|
}
|
|
428
285
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendar, decorators: [{
|
|
429
286
|
type: Directive,
|
|
@@ -431,9 +288,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
431
288
|
selector: '[brnCalendar]',
|
|
432
289
|
providers: [provideBrnCalendar(BrnCalendar)],
|
|
433
290
|
}]
|
|
434
|
-
}], propDecorators: { highlightDays: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlightDays", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: false }] }, { type: i0.Output, args: ["dateChange"] }], dateDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateDisabled", required: false }] }], weekStartsOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekStartsOn", required: false }] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnCalendarHeader), { isSignal: true }] }]
|
|
435
|
-
descendants: true,
|
|
436
|
-
}, isSignal: true }] }] } });
|
|
291
|
+
}], propDecorators: { highlightDays: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlightDays", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: false }] }, { type: i0.Output, args: ["dateChange"] }], dateDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateDisabled", required: false }] }], weekStartsOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekStartsOn", required: false }] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnCalendarHeader), { isSignal: true }] }] } });
|
|
437
292
|
|
|
438
293
|
class BrnCalendarCell {
|
|
439
294
|
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarCell, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
@@ -449,6 +304,171 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
449
304
|
}]
|
|
450
305
|
}] });
|
|
451
306
|
|
|
307
|
+
class BrnCalendarCellButton {
|
|
308
|
+
/** Access the date adapter */
|
|
309
|
+
_dateAdapter = injectDateAdapter();
|
|
310
|
+
_destroyRef = inject(DestroyRef);
|
|
311
|
+
/** Access the calendar component */
|
|
312
|
+
_calendar = injectBrnCalendar();
|
|
313
|
+
/** Access the element ref */
|
|
314
|
+
_elementRef = inject(ElementRef);
|
|
315
|
+
/** The date this cell represents */
|
|
316
|
+
date = input.required(...(ngDevMode ? [{ debugName: "date" }] : /* istanbul ignore next */ []));
|
|
317
|
+
/** Whether this date is currently selected */
|
|
318
|
+
selected = computed(() => this._calendar.isSelected(this.date()), ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
|
|
319
|
+
start = computed(() => this._calendar.isStartOfRange(this.date()), ...(ngDevMode ? [{ debugName: "start" }] : /* istanbul ignore next */ []));
|
|
320
|
+
end = computed(() => this._calendar.isEndOfRange(this.date()), ...(ngDevMode ? [{ debugName: "end" }] : /* istanbul ignore next */ []));
|
|
321
|
+
betweenRange = computed(() => this._calendar.isBetweenRange(this.date()), ...(ngDevMode ? [{ debugName: "betweenRange" }] : /* istanbul ignore next */ []));
|
|
322
|
+
highlighted = computed(() => this._calendar.highlightDays().some((d) => this._dateAdapter.isSameDay(this.date(), d)), ...(ngDevMode ? [{ debugName: "highlighted" }] : /* istanbul ignore next */ []));
|
|
323
|
+
constructor() {
|
|
324
|
+
this._calendar.registerCalendarCell(this);
|
|
325
|
+
this._destroyRef.onDestroy(() => this._calendar.unregisterCalendarCell(this));
|
|
326
|
+
}
|
|
327
|
+
/** Whether this date is focusable */
|
|
328
|
+
focusable = computed(() => this._dateAdapter.isSameDay(this._calendar.focusedDate(), this.date()), ...(ngDevMode ? [{ debugName: "focusable" }] : /* istanbul ignore next */ []));
|
|
329
|
+
outside = computed(() => {
|
|
330
|
+
const focusedDate = this._calendar.focusedDate();
|
|
331
|
+
return !this._dateAdapter.isSameMonth(this.date(), focusedDate);
|
|
332
|
+
}, ...(ngDevMode ? [{ debugName: "outside" }] : /* istanbul ignore next */ []));
|
|
333
|
+
/** Whether this date is today */
|
|
334
|
+
today = computed(() => this._dateAdapter.isSameDay(this.date(), this._dateAdapter.now()), ...(ngDevMode ? [{ debugName: "today" }] : /* istanbul ignore next */ []));
|
|
335
|
+
/** Whether this date is disabled */
|
|
336
|
+
disabled = computed(() => this._calendar.isDateDisabled(this.date()) || this._calendar.disabled(), ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
337
|
+
/**
|
|
338
|
+
* Focus the previous cell.
|
|
339
|
+
*/
|
|
340
|
+
focusPrevious(event) {
|
|
341
|
+
event.preventDefault();
|
|
342
|
+
event.stopPropagation();
|
|
343
|
+
// in rtl, the arrow keys are reversed.
|
|
344
|
+
const targetDate = this._dateAdapter.add(this._calendar.focusedDate(), {
|
|
345
|
+
days: this.getDirection() === 'rtl' ? 1 : -1,
|
|
346
|
+
});
|
|
347
|
+
this._calendar.setFocusedDate(targetDate);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Focus the next cell.
|
|
351
|
+
*/
|
|
352
|
+
focusNext(event) {
|
|
353
|
+
event.preventDefault();
|
|
354
|
+
event.stopPropagation();
|
|
355
|
+
const targetDate = this._dateAdapter.add(this._calendar.focusedDate(), {
|
|
356
|
+
days: this.getDirection() === 'rtl' ? -1 : 1,
|
|
357
|
+
});
|
|
358
|
+
this._calendar.setFocusedDate(targetDate);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Focus the above cell.
|
|
362
|
+
*/
|
|
363
|
+
focusAbove(event) {
|
|
364
|
+
event.preventDefault();
|
|
365
|
+
event.stopPropagation();
|
|
366
|
+
this._calendar.setFocusedDate(this._dateAdapter.subtract(this._calendar.focusedDate(), { days: 7 }));
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Focus the below cell.
|
|
370
|
+
*/
|
|
371
|
+
focusBelow(event) {
|
|
372
|
+
event.preventDefault();
|
|
373
|
+
event.stopPropagation();
|
|
374
|
+
this._calendar.setFocusedDate(this._dateAdapter.add(this._calendar.focusedDate(), { days: 7 }));
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Focus the first date of the month.
|
|
378
|
+
*/
|
|
379
|
+
focusFirst(event) {
|
|
380
|
+
event.preventDefault();
|
|
381
|
+
event.stopPropagation();
|
|
382
|
+
this._calendar.setFocusedDate(this._dateAdapter.startOfMonth(this._calendar.focusedDate()));
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Focus the last date of the month.
|
|
386
|
+
*/
|
|
387
|
+
focusLast(event) {
|
|
388
|
+
event.preventDefault();
|
|
389
|
+
event.stopPropagation();
|
|
390
|
+
this._calendar.setFocusedDate(this._dateAdapter.endOfMonth(this._calendar.focusedDate()));
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Focus the same date in the previous month.
|
|
394
|
+
*/
|
|
395
|
+
focusPreviousMonth(event) {
|
|
396
|
+
event.preventDefault();
|
|
397
|
+
event.stopPropagation();
|
|
398
|
+
const date = this._dateAdapter.getDate(this._calendar.focusedDate());
|
|
399
|
+
let previousMonthTarget = this._dateAdapter.startOfMonth(this._calendar.focusedDate());
|
|
400
|
+
previousMonthTarget = this._dateAdapter.subtract(previousMonthTarget, { months: 1 });
|
|
401
|
+
const lastDay = this._dateAdapter.endOfMonth(previousMonthTarget);
|
|
402
|
+
// if we are on a date that does not exist in the previous month, we should focus the last day of the month.
|
|
403
|
+
if (date > this._dateAdapter.getDate(lastDay)) {
|
|
404
|
+
this._calendar.setFocusedDate(lastDay);
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
this._calendar.setFocusedDate(this._dateAdapter.set(previousMonthTarget, { day: date }));
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Focus the same date in the next month.
|
|
412
|
+
*/
|
|
413
|
+
focusNextMonth(event) {
|
|
414
|
+
event.preventDefault();
|
|
415
|
+
event.stopPropagation();
|
|
416
|
+
const date = this._dateAdapter.getDate(this._calendar.focusedDate());
|
|
417
|
+
let nextMonthTarget = this._dateAdapter.startOfMonth(this._calendar.focusedDate());
|
|
418
|
+
nextMonthTarget = this._dateAdapter.add(nextMonthTarget, { months: 1 });
|
|
419
|
+
const lastDay = this._dateAdapter.endOfMonth(nextMonthTarget);
|
|
420
|
+
// if we are on a date that does not exist in the next month, we should focus the last day of the month.
|
|
421
|
+
if (date > this._dateAdapter.getDate(lastDay)) {
|
|
422
|
+
this._calendar.setFocusedDate(lastDay);
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
this._calendar.setFocusedDate(this._dateAdapter.set(nextMonthTarget, { day: date }));
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Get the direction of the element.
|
|
430
|
+
*/
|
|
431
|
+
getDirection() {
|
|
432
|
+
return getComputedStyle(this._elementRef.nativeElement).direction === 'rtl' ? 'rtl' : 'ltr';
|
|
433
|
+
}
|
|
434
|
+
focus() {
|
|
435
|
+
this._elementRef.nativeElement.focus();
|
|
436
|
+
}
|
|
437
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarCellButton, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
438
|
+
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.16", type: BrnCalendarCellButton, isStandalone: true, selector: "button[brnCalendarCellButton]", inputs: { date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "role": "gridcell", "type": "button" }, listeners: { "click": "_calendar.selectDate(date())", "keydown.arrowLeft": "focusPrevious($event)", "keydown.arrowRight": "focusNext($event)", "keydown.arrowUp": "focusAbove($event)", "keydown.arrowDown": "focusBelow($event)", "keydown.home": "focusFirst($event)", "keydown.end": "focusLast($event)", "keydown.pageUp": "focusPreviousMonth($event)", "keydown.pageDown": "focusNextMonth($event)" }, properties: { "tabindex": "focusable() ? 0 : -1", "attr.data-outside": "!selected() && outside() && (!end() && !start())? true : null", "attr.data-today": "today() && !selected() ? true : null", "attr.data-selected-single": "selected() && !start() && !end() && !betweenRange() ? true : null", "attr.data-disabled": "disabled() ? true : null", "attr.aria-selected": "selected() ? true : null", "attr.aria-disabled": "disabled() ? true : null", "attr.data-range-start": "start() ? true : null", "attr.data-range-end": "end() ? true : null", "attr.data-highlighted": "highlighted() ? true : null", "attr.data-range-middle": "betweenRange() ? true : null", "disabled": "disabled()" } }, ngImport: i0 });
|
|
439
|
+
}
|
|
440
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarCellButton, decorators: [{
|
|
441
|
+
type: Directive,
|
|
442
|
+
args: [{
|
|
443
|
+
selector: 'button[brnCalendarCellButton]',
|
|
444
|
+
host: {
|
|
445
|
+
role: 'gridcell',
|
|
446
|
+
'[tabindex]': 'focusable() ? 0 : -1',
|
|
447
|
+
type: 'button',
|
|
448
|
+
'[attr.data-outside]': '!selected() && outside() && (!end() && !start())? true : null',
|
|
449
|
+
'[attr.data-today]': 'today() && !selected() ? true : null',
|
|
450
|
+
'[attr.data-selected-single]': 'selected() && !start() && !end() && !betweenRange() ? true : null',
|
|
451
|
+
'[attr.data-disabled]': 'disabled() ? true : null',
|
|
452
|
+
'[attr.aria-selected]': 'selected() ? true : null',
|
|
453
|
+
'[attr.aria-disabled]': 'disabled() ? true : null',
|
|
454
|
+
'[attr.data-range-start]': 'start() ? true : null',
|
|
455
|
+
'[attr.data-range-end]': 'end() ? true : null',
|
|
456
|
+
'[attr.data-highlighted]': 'highlighted() ? true : null',
|
|
457
|
+
'[attr.data-range-middle]': 'betweenRange() ? true : null',
|
|
458
|
+
'[disabled]': 'disabled()',
|
|
459
|
+
'(click)': '_calendar.selectDate(date())',
|
|
460
|
+
'(keydown.arrowLeft)': 'focusPrevious($event)',
|
|
461
|
+
'(keydown.arrowRight)': 'focusNext($event)',
|
|
462
|
+
'(keydown.arrowUp)': 'focusAbove($event)',
|
|
463
|
+
'(keydown.arrowDown)': 'focusBelow($event)',
|
|
464
|
+
'(keydown.home)': 'focusFirst($event)',
|
|
465
|
+
'(keydown.end)': 'focusLast($event)',
|
|
466
|
+
'(keydown.pageUp)': 'focusPreviousMonth($event)',
|
|
467
|
+
'(keydown.pageDown)': 'focusNextMonth($event)',
|
|
468
|
+
},
|
|
469
|
+
}]
|
|
470
|
+
}], ctorParameters: () => [], propDecorators: { date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: true }] }] } });
|
|
471
|
+
|
|
452
472
|
class BrnCalendarGrid {
|
|
453
473
|
/** Access the calendar component */
|
|
454
474
|
_calendar = injectBrnCalendar();
|
|
@@ -772,6 +792,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
772
792
|
|
|
773
793
|
class BrnCalendarMulti {
|
|
774
794
|
_i18n = injectBrnCalendarI18n();
|
|
795
|
+
_cells = [];
|
|
775
796
|
/**
|
|
776
797
|
* Determine if a date is the start of a range. In a date picker, this is always false.
|
|
777
798
|
* @param date The date to check.
|
|
@@ -828,8 +849,6 @@ class BrnCalendarMulti {
|
|
|
828
849
|
defaultFocusedDate = input(...(ngDevMode ? [undefined, { debugName: "defaultFocusedDate" }] : /* istanbul ignore next */ []));
|
|
829
850
|
/** @internal Access the header */
|
|
830
851
|
header = contentChild(BrnCalendarHeader, ...(ngDevMode ? [{ debugName: "header" }] : /* istanbul ignore next */ []));
|
|
831
|
-
/** Store the cells */
|
|
832
|
-
_cells = contentChildren(BrnCalendarCellButton, { ...(ngDevMode ? { debugName: "_cells" } : /* istanbul ignore next */ {}), descendants: true });
|
|
833
852
|
/**
|
|
834
853
|
* The focused date.
|
|
835
854
|
*/
|
|
@@ -860,7 +879,7 @@ class BrnCalendarMulti {
|
|
|
860
879
|
firstDay = this._dateAdapter.add(firstDay, { days: 1 });
|
|
861
880
|
}
|
|
862
881
|
return days;
|
|
863
|
-
}, ...(ngDevMode ?
|
|
882
|
+
}, { ...(ngDevMode ? { debugName: "days" } : /* istanbul ignore next */ {}), equal: (a, b) => compareDays(a, b, this._dateAdapter) });
|
|
864
883
|
isSelected(date) {
|
|
865
884
|
return this.date()?.some((d) => this._dateAdapter.isSameDay(d, date)) ?? false;
|
|
866
885
|
}
|
|
@@ -938,8 +957,7 @@ class BrnCalendarMulti {
|
|
|
938
957
|
// wait until the cells have all updated
|
|
939
958
|
afterNextRender({
|
|
940
959
|
write: () => {
|
|
941
|
-
|
|
942
|
-
const cell = this._cells().find((c) => this._dateAdapter.isSameDay(c.date(), date));
|
|
960
|
+
const cell = this._cells.find((c) => this._dateAdapter.isSameDay(c.date(), date));
|
|
943
961
|
if (cell) {
|
|
944
962
|
cell.focus();
|
|
945
963
|
}
|
|
@@ -950,8 +968,17 @@ class BrnCalendarMulti {
|
|
|
950
968
|
// we must update the view to ensure the focused cell is visible.
|
|
951
969
|
this._changeDetector.detectChanges();
|
|
952
970
|
}
|
|
971
|
+
unregisterCalendarCell(cell) {
|
|
972
|
+
const index = this._cells.indexOf(cell);
|
|
973
|
+
if (index !== -1) {
|
|
974
|
+
this._cells.splice(index, 1);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
registerCalendarCell(cell) {
|
|
978
|
+
this._cells.push(cell);
|
|
979
|
+
}
|
|
953
980
|
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarMulti, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
954
|
-
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnCalendarMulti, isStandalone: true, selector: "[brnCalendarMulti]", inputs: { highlightDays: { classPropertyName: "highlightDays", publicName: "highlightDays", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, minSelection: { classPropertyName: "minSelection", publicName: "minSelection", isSignal: true, isRequired: false, transformFunction: null }, maxSelection: { classPropertyName: "maxSelection", publicName: "maxSelection", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: false, transformFunction: null }, dateDisabled: { classPropertyName: "dateDisabled", publicName: "dateDisabled", isSignal: true, isRequired: false, transformFunction: null }, weekStartsOn: { classPropertyName: "weekStartsOn", publicName: "weekStartsOn", isSignal: true, isRequired: false, transformFunction: null }, defaultFocusedDate: { classPropertyName: "defaultFocusedDate", publicName: "defaultFocusedDate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { date: "dateChange" }, providers: [provideBrnCalendar(BrnCalendarMulti)], queries: [{ propertyName: "header", first: true, predicate: BrnCalendarHeader, descendants: true, isSignal: true }
|
|
981
|
+
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnCalendarMulti, isStandalone: true, selector: "[brnCalendarMulti]", inputs: { highlightDays: { classPropertyName: "highlightDays", publicName: "highlightDays", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, minSelection: { classPropertyName: "minSelection", publicName: "minSelection", isSignal: true, isRequired: false, transformFunction: null }, maxSelection: { classPropertyName: "maxSelection", publicName: "maxSelection", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: false, transformFunction: null }, dateDisabled: { classPropertyName: "dateDisabled", publicName: "dateDisabled", isSignal: true, isRequired: false, transformFunction: null }, weekStartsOn: { classPropertyName: "weekStartsOn", publicName: "weekStartsOn", isSignal: true, isRequired: false, transformFunction: null }, defaultFocusedDate: { classPropertyName: "defaultFocusedDate", publicName: "defaultFocusedDate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { date: "dateChange" }, providers: [provideBrnCalendar(BrnCalendarMulti)], queries: [{ propertyName: "header", first: true, predicate: BrnCalendarHeader, descendants: true, isSignal: true }], ngImport: i0 });
|
|
955
982
|
}
|
|
956
983
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarMulti, decorators: [{
|
|
957
984
|
type: Directive,
|
|
@@ -959,11 +986,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
959
986
|
selector: '[brnCalendarMulti]',
|
|
960
987
|
providers: [provideBrnCalendar(BrnCalendarMulti)],
|
|
961
988
|
}]
|
|
962
|
-
}], propDecorators: { highlightDays: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlightDays", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], minSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "minSelection", required: false }] }], maxSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxSelection", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: false }] }, { type: i0.Output, args: ["dateChange"] }], dateDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateDisabled", required: false }] }], weekStartsOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekStartsOn", required: false }] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnCalendarHeader), { isSignal: true }] }]
|
|
963
|
-
descendants: true,
|
|
964
|
-
}, isSignal: true }] }] } });
|
|
989
|
+
}], propDecorators: { highlightDays: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlightDays", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], minSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "minSelection", required: false }] }], maxSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxSelection", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: false }] }, { type: i0.Output, args: ["dateChange"] }], dateDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateDisabled", required: false }] }], weekStartsOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekStartsOn", required: false }] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnCalendarHeader), { isSignal: true }] }] } });
|
|
965
990
|
|
|
966
991
|
class BrnCalendarRange {
|
|
992
|
+
_cells = [];
|
|
967
993
|
_i18n = injectBrnCalendarI18n();
|
|
968
994
|
// /** Access the date adapter */
|
|
969
995
|
_dateAdapter = injectDateAdapter();
|
|
@@ -988,8 +1014,6 @@ class BrnCalendarRange {
|
|
|
988
1014
|
defaultFocusedDate = input(...(ngDevMode ? [undefined, { debugName: "defaultFocusedDate" }] : /* istanbul ignore next */ []));
|
|
989
1015
|
/** @internal Access the header */
|
|
990
1016
|
header = contentChild(BrnCalendarHeader, ...(ngDevMode ? [{ debugName: "header" }] : /* istanbul ignore next */ []));
|
|
991
|
-
/** Store the cells */
|
|
992
|
-
_cells = contentChildren(BrnCalendarCellButton, { ...(ngDevMode ? { debugName: "_cells" } : /* istanbul ignore next */ {}), descendants: true });
|
|
993
1017
|
/**
|
|
994
1018
|
* The focused date.
|
|
995
1019
|
*/
|
|
@@ -1028,7 +1052,7 @@ class BrnCalendarRange {
|
|
|
1028
1052
|
firstDay = this._dateAdapter.add(firstDay, { days: 1 });
|
|
1029
1053
|
}
|
|
1030
1054
|
return days;
|
|
1031
|
-
}, ...(ngDevMode ?
|
|
1055
|
+
}, { ...(ngDevMode ? { debugName: "days" } : /* istanbul ignore next */ {}), equal: (a, b) => compareDays(a, b, this._dateAdapter) });
|
|
1032
1056
|
isSelected(date) {
|
|
1033
1057
|
const start = this.startDate();
|
|
1034
1058
|
const end = this.endDate();
|
|
@@ -1115,8 +1139,7 @@ class BrnCalendarRange {
|
|
|
1115
1139
|
// wait until the cells have all updated
|
|
1116
1140
|
afterNextRender({
|
|
1117
1141
|
write: () => {
|
|
1118
|
-
|
|
1119
|
-
const cell = this._cells().find((c) => this._dateAdapter.isSameDay(c.date(), date));
|
|
1142
|
+
const cell = this._cells.find((c) => this._dateAdapter.isSameDay(c.date(), date));
|
|
1120
1143
|
if (cell) {
|
|
1121
1144
|
cell.focus();
|
|
1122
1145
|
}
|
|
@@ -1164,8 +1187,17 @@ class BrnCalendarRange {
|
|
|
1164
1187
|
!this._dateAdapter.isSameDay(date, start) &&
|
|
1165
1188
|
!this._dateAdapter.isSameDay(date, end));
|
|
1166
1189
|
}
|
|
1190
|
+
unregisterCalendarCell(cell) {
|
|
1191
|
+
const index = this._cells.indexOf(cell);
|
|
1192
|
+
if (index !== -1) {
|
|
1193
|
+
this._cells.splice(index, 1);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
registerCalendarCell(cell) {
|
|
1197
|
+
this._cells.push(cell);
|
|
1198
|
+
}
|
|
1167
1199
|
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarRange, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1168
|
-
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnCalendarRange, isStandalone: true, selector: "[brnCalendarRange]", inputs: { highlightDays: { classPropertyName: "highlightDays", publicName: "highlightDays", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, dateDisabled: { classPropertyName: "dateDisabled", publicName: "dateDisabled", isSignal: true, isRequired: false, transformFunction: null }, weekStartsOn: { classPropertyName: "weekStartsOn", publicName: "weekStartsOn", isSignal: true, isRequired: false, transformFunction: null }, defaultFocusedDate: { classPropertyName: "defaultFocusedDate", publicName: "defaultFocusedDate", isSignal: true, isRequired: false, transformFunction: null }, startDate: { classPropertyName: "startDate", publicName: "startDate", isSignal: true, isRequired: false, transformFunction: null }, endDate: { classPropertyName: "endDate", publicName: "endDate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { startDate: "startDateChange", endDate: "endDateChange" }, providers: [provideBrnCalendar(BrnCalendarRange)], queries: [{ propertyName: "header", first: true, predicate: BrnCalendarHeader, descendants: true, isSignal: true }
|
|
1200
|
+
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnCalendarRange, isStandalone: true, selector: "[brnCalendarRange]", inputs: { highlightDays: { classPropertyName: "highlightDays", publicName: "highlightDays", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, dateDisabled: { classPropertyName: "dateDisabled", publicName: "dateDisabled", isSignal: true, isRequired: false, transformFunction: null }, weekStartsOn: { classPropertyName: "weekStartsOn", publicName: "weekStartsOn", isSignal: true, isRequired: false, transformFunction: null }, defaultFocusedDate: { classPropertyName: "defaultFocusedDate", publicName: "defaultFocusedDate", isSignal: true, isRequired: false, transformFunction: null }, startDate: { classPropertyName: "startDate", publicName: "startDate", isSignal: true, isRequired: false, transformFunction: null }, endDate: { classPropertyName: "endDate", publicName: "endDate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { startDate: "startDateChange", endDate: "endDateChange" }, providers: [provideBrnCalendar(BrnCalendarRange)], queries: [{ propertyName: "header", first: true, predicate: BrnCalendarHeader, descendants: true, isSignal: true }], ngImport: i0 });
|
|
1169
1201
|
}
|
|
1170
1202
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarRange, decorators: [{
|
|
1171
1203
|
type: Directive,
|
|
@@ -1173,9 +1205,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
1173
1205
|
selector: '[brnCalendarRange]',
|
|
1174
1206
|
providers: [provideBrnCalendar(BrnCalendarRange)],
|
|
1175
1207
|
}]
|
|
1176
|
-
}], propDecorators: { highlightDays: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlightDays", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], dateDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateDisabled", required: false }] }], weekStartsOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekStartsOn", required: false }] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnCalendarHeader), { isSignal: true }] }],
|
|
1177
|
-
descendants: true,
|
|
1178
|
-
}, isSignal: true }] }], startDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "startDate", required: false }] }, { type: i0.Output, args: ["startDateChange"] }], endDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "endDate", required: false }] }, { type: i0.Output, args: ["endDateChange"] }] } });
|
|
1208
|
+
}], propDecorators: { highlightDays: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlightDays", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], dateDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateDisabled", required: false }] }], weekStartsOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekStartsOn", required: false }] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnCalendarHeader), { isSignal: true }] }], startDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "startDate", required: false }] }, { type: i0.Output, args: ["startDateChange"] }], endDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "endDate", required: false }] }, { type: i0.Output, args: ["endDateChange"] }] } });
|
|
1179
1209
|
|
|
1180
1210
|
const BrnCalendarImports = [
|
|
1181
1211
|
BrnCalendarCellButton,
|