@spartan-ng/brain 0.0.1-alpha.437 → 0.0.1-alpha.438
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/calendar/index.d.ts +5 -2
- package/calendar/lib/brn-calendar-cell-button.directive.d.ts +2 -2
- package/calendar/lib/brn-calendar-grid.directive.d.ts +1 -1
- package/calendar/lib/brn-calendar.directive.d.ts +4 -1
- package/calendar/lib/brn-calendar.token.d.ts +19 -5
- package/calendar/lib/mode/brn-calendar-multiple.directive.d.ts +61 -0
- package/fesm2022/spartan-ng-brain-calendar.mjs +196 -9
- package/fesm2022/spartan-ng-brain-calendar.mjs.map +1 -1
- package/fesm2022/spartan-ng-brain-select.mjs +2 -1
- package/fesm2022/spartan-ng-brain-select.mjs.map +1 -1
- package/fesm2022/spartan-ng-brain-slider.mjs +278 -342
- package/fesm2022/spartan-ng-brain-slider.mjs.map +1 -1
- package/fesm2022/spartan-ng-brain-toggle-group.mjs +260 -0
- package/fesm2022/spartan-ng-brain-toggle-group.mjs.map +1 -0
- package/fesm2022/spartan-ng-brain-toggle.mjs +6 -197
- package/fesm2022/spartan-ng-brain-toggle.mjs.map +1 -1
- package/package.json +5 -1
- package/slider/index.d.ts +9 -4
- package/slider/lib/brn-slider-range.directive.d.ts +7 -0
- package/slider/lib/brn-slider-thumb.directive.d.ts +18 -11
- package/slider/lib/brn-slider-tick.directive.d.ts +12 -0
- package/slider/lib/brn-slider-track.directive.d.ts +8 -136
- package/slider/lib/brn-slider-track.token.d.ts +5 -0
- package/slider/lib/brn-slider.directive.d.ts +37 -0
- package/slider/lib/brn-slider.token.d.ts +4 -0
- package/toggle/index.d.ts +0 -7
- package/toggle/lib/brn-toggle.directive.d.ts +0 -2
- package/toggle-group/README.md +3 -0
- package/toggle-group/index.d.ts +15 -0
- package/{toggle → toggle-group}/lib/brn-toggle-group.component.d.ts +5 -5
- package/toggle-group/lib/brn-toggle-item.directive.d.ts +25 -0
- package/slider/lib/brn-slider-tick-mark.directive.d.ts +0 -15
- package/slider/lib/brn-slider-track-active-fill.directive.d.ts +0 -10
- /package/{toggle → toggle-group}/lib/brn-toggle-group.token.d.ts +0 -0
package/calendar/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { BrnCalendarPreviousButtonDirective } from './lib/brn-calendar-previous-
|
|
|
7
7
|
import { BrnCalendarWeekDirective } from './lib/brn-calendar-week.directive';
|
|
8
8
|
import { BrnCalendarWeekdayDirective } from './lib/brn-calendar-weekday.directive';
|
|
9
9
|
import { BrnCalendarDirective } from './lib/brn-calendar.directive';
|
|
10
|
+
import { BrnCalendarMultiDirective } from './lib/mode/brn-calendar-multiple.directive';
|
|
10
11
|
import * as i0 from "@angular/core";
|
|
11
12
|
import * as i1 from "./lib/brn-calendar-cell-button.directive";
|
|
12
13
|
import * as i2 from "./lib/brn-calendar-grid.directive";
|
|
@@ -17,6 +18,7 @@ import * as i6 from "./lib/brn-calendar-week.directive";
|
|
|
17
18
|
import * as i7 from "./lib/brn-calendar-weekday.directive";
|
|
18
19
|
import * as i8 from "./lib/brn-calendar.directive";
|
|
19
20
|
import * as i9 from "./lib/brn-calendar-cell.directive";
|
|
21
|
+
import * as i10 from "./lib/mode/brn-calendar-multiple.directive";
|
|
20
22
|
export * from './lib/brn-calendar-cell-button.directive';
|
|
21
23
|
export * from './lib/brn-calendar-cell.directive';
|
|
22
24
|
export * from './lib/brn-calendar-grid.directive';
|
|
@@ -28,9 +30,10 @@ export * from './lib/brn-calendar-weekday.directive';
|
|
|
28
30
|
export * from './lib/brn-calendar.directive';
|
|
29
31
|
export * from './lib/brn-calendar.token';
|
|
30
32
|
export * from './lib/i18n/calendar-i18n';
|
|
31
|
-
export
|
|
33
|
+
export * from './lib/mode/brn-calendar-multiple.directive';
|
|
34
|
+
export declare const BrnCalendarImports: readonly [typeof BrnCalendarCellButtonDirective, typeof BrnCalendarGridDirective, typeof BrnCalendarHeaderDirective, typeof BrnCalendarNextButtonDirective, typeof BrnCalendarPreviousButtonDirective, typeof BrnCalendarWeekDirective, typeof BrnCalendarWeekdayDirective, typeof BrnCalendarDirective, typeof BrnCalendarCellDirective, typeof BrnCalendarMultiDirective];
|
|
32
35
|
export declare class BrnCalendarModule {
|
|
33
36
|
static ɵfac: i0.ɵɵFactoryDeclaration<BrnCalendarModule, never>;
|
|
34
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<BrnCalendarModule, never, [typeof i1.BrnCalendarCellButtonDirective, typeof i2.BrnCalendarGridDirective, typeof i3.BrnCalendarHeaderDirective, typeof i4.BrnCalendarNextButtonDirective, typeof i5.BrnCalendarPreviousButtonDirective, typeof i6.BrnCalendarWeekDirective, typeof i7.BrnCalendarWeekdayDirective, typeof i8.BrnCalendarDirective, typeof i9.BrnCalendarCellDirective], [typeof i1.BrnCalendarCellButtonDirective, typeof i2.BrnCalendarGridDirective, typeof i3.BrnCalendarHeaderDirective, typeof i4.BrnCalendarNextButtonDirective, typeof i5.BrnCalendarPreviousButtonDirective, typeof i6.BrnCalendarWeekDirective, typeof i7.BrnCalendarWeekdayDirective, typeof i8.BrnCalendarDirective, typeof i9.BrnCalendarCellDirective]>;
|
|
37
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<BrnCalendarModule, never, [typeof i1.BrnCalendarCellButtonDirective, typeof i2.BrnCalendarGridDirective, typeof i3.BrnCalendarHeaderDirective, typeof i4.BrnCalendarNextButtonDirective, typeof i5.BrnCalendarPreviousButtonDirective, typeof i6.BrnCalendarWeekDirective, typeof i7.BrnCalendarWeekdayDirective, typeof i8.BrnCalendarDirective, typeof i9.BrnCalendarCellDirective, typeof i10.BrnCalendarMultiDirective], [typeof i1.BrnCalendarCellButtonDirective, typeof i2.BrnCalendarGridDirective, typeof i3.BrnCalendarHeaderDirective, typeof i4.BrnCalendarNextButtonDirective, typeof i5.BrnCalendarPreviousButtonDirective, typeof i6.BrnCalendarWeekDirective, typeof i7.BrnCalendarWeekdayDirective, typeof i8.BrnCalendarDirective, typeof i9.BrnCalendarCellDirective, typeof i10.BrnCalendarMultiDirective]>;
|
|
35
38
|
static ɵinj: i0.ɵɵInjectorDeclaration<BrnCalendarModule>;
|
|
36
39
|
}
|
|
@@ -3,13 +3,13 @@ export declare class BrnCalendarCellButtonDirective<T> {
|
|
|
3
3
|
/** Access the date adapter */
|
|
4
4
|
protected readonly dateAdapter: import("@spartan-ng/brain/date-time").BrnDateAdapter<T>;
|
|
5
5
|
/** Access the calendar component */
|
|
6
|
-
protected readonly calendar: import("
|
|
6
|
+
protected readonly calendar: import("./brn-calendar.token").BrnCalendar<T>;
|
|
7
7
|
/** Access the element ref */
|
|
8
8
|
private readonly _elementRef;
|
|
9
9
|
/** The date this cell represents */
|
|
10
10
|
readonly date: import("@angular/core").InputSignal<T>;
|
|
11
11
|
/** Whether this date is currently selected */
|
|
12
|
-
readonly selected: import("@angular/core").Signal<boolean
|
|
12
|
+
readonly selected: import("@angular/core").Signal<boolean>;
|
|
13
13
|
/** Whether this date is focusable */
|
|
14
14
|
readonly focusable: import("@angular/core").Signal<boolean>;
|
|
15
15
|
readonly outside: import("@angular/core").Signal<boolean>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
2
|
export declare class BrnCalendarGridDirective<T> {
|
|
3
3
|
/** Access the calendar component */
|
|
4
|
-
protected readonly calendar: import("
|
|
4
|
+
protected readonly calendar: import("./brn-calendar.token").BrnCalendar<T>;
|
|
5
5
|
static ɵfac: i0.ɵɵFactoryDeclaration<BrnCalendarGridDirective<any>, never>;
|
|
6
6
|
static ɵdir: i0.ɵɵDirectiveDeclaration<BrnCalendarGridDirective<any>, "[brnCalendarGrid]", never, {}, {}, never, never, true, never>;
|
|
7
7
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { BooleanInput, NumberInput } from '@angular/cdk/coercion';
|
|
2
2
|
import { BrnCalendarCellButtonDirective } from './brn-calendar-cell-button.directive';
|
|
3
3
|
import { BrnCalendarHeaderDirective } from './brn-calendar-header.directive';
|
|
4
|
+
import { BrnCalendar } from './brn-calendar.token';
|
|
4
5
|
import * as i0 from "@angular/core";
|
|
5
|
-
export declare class BrnCalendarDirective<T> {
|
|
6
|
+
export declare class BrnCalendarDirective<T> implements BrnCalendar<T> {
|
|
6
7
|
/** Access the date adapter */
|
|
7
8
|
protected readonly dateAdapter: import("@spartan-ng/brain/date-time").BrnDateAdapter<T>;
|
|
8
9
|
/** Access the change detector */
|
|
@@ -11,6 +12,7 @@ export declare class BrnCalendarDirective<T> {
|
|
|
11
12
|
private readonly _injector;
|
|
12
13
|
/** The minimum date that can be selected.*/
|
|
13
14
|
readonly min: import("@angular/core").InputSignal<T | undefined>;
|
|
15
|
+
/** The maximum date that can be selected. */
|
|
14
16
|
readonly max: import("@angular/core").InputSignal<T | undefined>;
|
|
15
17
|
/** Determine if the date picker is disabled. */
|
|
16
18
|
readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
|
|
@@ -46,6 +48,7 @@ export declare class BrnCalendarDirective<T> {
|
|
|
46
48
|
constrainDate(date: T): T;
|
|
47
49
|
/** @internal Determine if a date is disabled */
|
|
48
50
|
isDateDisabled(date: T): boolean;
|
|
51
|
+
isSelected(date: T): boolean;
|
|
49
52
|
selectDate(date: T): void;
|
|
50
53
|
/** @internal Set the focused date */
|
|
51
54
|
setFocusedDate(date: T): void;
|
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
import { ExistingProvider, InjectionToken, Type } from '@angular/core';
|
|
2
|
-
import
|
|
3
|
-
export
|
|
4
|
-
|
|
1
|
+
import { ExistingProvider, InjectionToken, Signal, Type, WritableSignal } from '@angular/core';
|
|
2
|
+
import { BrnCalendarHeaderDirective } from './brn-calendar-header.directive';
|
|
3
|
+
export interface BrnCalendar<T> {
|
|
4
|
+
isSelected: (date: T) => boolean;
|
|
5
|
+
selectDate: (date: T) => void;
|
|
6
|
+
constrainDate: (date: T) => T;
|
|
7
|
+
isDateDisabled: (date: T) => boolean;
|
|
8
|
+
setFocusedDate: (date: T) => void;
|
|
9
|
+
disabled: Signal<boolean>;
|
|
10
|
+
focusedDate: Signal<T>;
|
|
11
|
+
header: Signal<BrnCalendarHeaderDirective | undefined>;
|
|
12
|
+
state: Signal<{
|
|
13
|
+
focusedDate: WritableSignal<T>;
|
|
14
|
+
}>;
|
|
15
|
+
days: Signal<T[]>;
|
|
16
|
+
}
|
|
17
|
+
export declare const BrnCalendarToken: InjectionToken<BrnCalendar<unknown>>;
|
|
18
|
+
export declare function provideBrnCalendar<T>(instance: Type<BrnCalendar<T>>): ExistingProvider;
|
|
5
19
|
/**
|
|
6
20
|
* Inject the calendar component.
|
|
7
21
|
*/
|
|
8
|
-
export declare function injectBrnCalendar<T>():
|
|
22
|
+
export declare function injectBrnCalendar<T>(): BrnCalendar<T>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { BooleanInput, NumberInput } from '@angular/cdk/coercion';
|
|
2
|
+
import { BrnCalendarCellButtonDirective } from '../brn-calendar-cell-button.directive';
|
|
3
|
+
import { BrnCalendarHeaderDirective } from '../brn-calendar-header.directive';
|
|
4
|
+
import { Weekday } from '../brn-calendar.directive';
|
|
5
|
+
import { BrnCalendar } from '../brn-calendar.token';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
export declare class BrnCalendarMultiDirective<T> implements BrnCalendar<T> {
|
|
8
|
+
protected readonly dateAdapter: import("@spartan-ng/brain/date-time").BrnDateAdapter<T>;
|
|
9
|
+
/** Access the change detector */
|
|
10
|
+
private readonly _changeDetector;
|
|
11
|
+
/** Access the injector */
|
|
12
|
+
private readonly _injector;
|
|
13
|
+
/** The minimum date that can be selected.*/
|
|
14
|
+
readonly min: import("@angular/core").InputSignal<T | undefined>;
|
|
15
|
+
/** The maximum date that can be selected. */
|
|
16
|
+
readonly max: import("@angular/core").InputSignal<T | undefined>;
|
|
17
|
+
/** The minimum selectable dates. */
|
|
18
|
+
readonly minSelection: import("@angular/core").InputSignalWithTransform<number | undefined, NumberInput>;
|
|
19
|
+
/** The maximum selectable dates. */
|
|
20
|
+
readonly maxSelection: import("@angular/core").InputSignalWithTransform<number | undefined, NumberInput>;
|
|
21
|
+
/** Determine if the date picker is disabled. */
|
|
22
|
+
readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
|
|
23
|
+
/** The selected value. */
|
|
24
|
+
readonly date: import("@angular/core").ModelSignal<T[] | undefined>;
|
|
25
|
+
/** Whether a specific date is disabled. */
|
|
26
|
+
readonly dateDisabled: import("@angular/core").InputSignal<(date: T) => boolean>;
|
|
27
|
+
/** The day the week starts on */
|
|
28
|
+
readonly weekStartsOn: import("@angular/core").InputSignalWithTransform<Weekday, NumberInput>;
|
|
29
|
+
/** The default focused date. */
|
|
30
|
+
readonly defaultFocusedDate: import("@angular/core").InputSignal<T | undefined>;
|
|
31
|
+
/** @internal Access the header */
|
|
32
|
+
readonly header: import("@angular/core").Signal<BrnCalendarHeaderDirective | undefined>;
|
|
33
|
+
/** Store the cells */
|
|
34
|
+
protected readonly cells: import("@angular/core").Signal<readonly BrnCalendarCellButtonDirective<T>[]>;
|
|
35
|
+
/**
|
|
36
|
+
* @internal
|
|
37
|
+
* The internal state of the component.
|
|
38
|
+
*/
|
|
39
|
+
readonly state: import("@angular/core").Signal<{
|
|
40
|
+
focusedDate: import("@angular/core").WritableSignal<T>;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* The focused date.
|
|
44
|
+
*/
|
|
45
|
+
readonly focusedDate: import("@angular/core").Signal<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Get all the days to display, this is the days of the current month
|
|
48
|
+
* and the days of the previous and next month to fill the grid.
|
|
49
|
+
*/
|
|
50
|
+
readonly days: import("@angular/core").Signal<T[]>;
|
|
51
|
+
isSelected(date: T): boolean;
|
|
52
|
+
selectDate(date: T): void;
|
|
53
|
+
/** @internal Constrain a date to the min and max boundaries */
|
|
54
|
+
constrainDate(date: T): T;
|
|
55
|
+
/** @internal Determine if a date is disabled */
|
|
56
|
+
isDateDisabled(date: T): boolean;
|
|
57
|
+
/** @internal Set the focused date */
|
|
58
|
+
setFocusedDate(date: T): void;
|
|
59
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<BrnCalendarMultiDirective<any>, never>;
|
|
60
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<BrnCalendarMultiDirective<any>, "[brnCalendarMulti]", never, { "min": { "alias": "min"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "minSelection": { "alias": "minSelection"; "required": false; "isSignal": true; }; "maxSelection": { "alias": "maxSelection"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "date": { "alias": "date"; "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; }; }, { "date": "dateChange"; }, ["header", "cells"], never, true, never>;
|
|
61
|
+
}
|
|
@@ -23,10 +23,7 @@ class BrnCalendarCellButtonDirective {
|
|
|
23
23
|
/** The date this cell represents */
|
|
24
24
|
date = input.required();
|
|
25
25
|
/** Whether this date is currently selected */
|
|
26
|
-
selected = computed(() =>
|
|
27
|
-
const selectedDate = this.calendar.date();
|
|
28
|
-
return selectedDate && this.dateAdapter.isSameDay(this.date(), selectedDate);
|
|
29
|
-
});
|
|
26
|
+
selected = computed(() => this.calendar.isSelected(this.date()));
|
|
30
27
|
/** Whether this date is focusable */
|
|
31
28
|
focusable = computed(() => this.dateAdapter.isSameDay(this.calendar.focusedDate(), this.date()));
|
|
32
29
|
outside = computed(() => {
|
|
@@ -445,7 +442,7 @@ class BrnCalendarDirective {
|
|
|
445
442
|
_injector = inject(Injector);
|
|
446
443
|
/** The minimum date that can be selected.*/
|
|
447
444
|
min = input();
|
|
448
|
-
|
|
445
|
+
/** The maximum date that can be selected. */
|
|
449
446
|
max = input();
|
|
450
447
|
/** Determine if the date picker is disabled. */
|
|
451
448
|
disabled = input(false, {
|
|
@@ -546,8 +543,17 @@ class BrnCalendarDirective {
|
|
|
546
543
|
}
|
|
547
544
|
return false;
|
|
548
545
|
}
|
|
546
|
+
isSelected(date) {
|
|
547
|
+
const selected = this.date();
|
|
548
|
+
return selected !== undefined && this.dateAdapter.isSameDay(date, selected);
|
|
549
|
+
}
|
|
549
550
|
selectDate(date) {
|
|
550
|
-
this.
|
|
551
|
+
if (this.isSelected(date)) {
|
|
552
|
+
this.date.set(undefined);
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
this.date.set(date);
|
|
556
|
+
}
|
|
551
557
|
this.state().focusedDate.set(date);
|
|
552
558
|
}
|
|
553
559
|
/** @internal Set the focused date */
|
|
@@ -584,6 +590,184 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImpor
|
|
|
584
590
|
}]
|
|
585
591
|
}] });
|
|
586
592
|
|
|
593
|
+
class BrnCalendarMultiDirective {
|
|
594
|
+
// /** Access the date adapter */
|
|
595
|
+
dateAdapter = injectDateAdapter();
|
|
596
|
+
/** Access the change detector */
|
|
597
|
+
_changeDetector = inject(ChangeDetectorRef);
|
|
598
|
+
/** Access the injector */
|
|
599
|
+
_injector = inject(Injector);
|
|
600
|
+
/** The minimum date that can be selected.*/
|
|
601
|
+
min = input();
|
|
602
|
+
/** The maximum date that can be selected. */
|
|
603
|
+
max = input();
|
|
604
|
+
/** The minimum selectable dates. */
|
|
605
|
+
minSelection = input(undefined, {
|
|
606
|
+
transform: numberAttribute,
|
|
607
|
+
});
|
|
608
|
+
/** The maximum selectable dates. */
|
|
609
|
+
maxSelection = input(undefined, {
|
|
610
|
+
transform: numberAttribute,
|
|
611
|
+
});
|
|
612
|
+
/** Determine if the date picker is disabled. */
|
|
613
|
+
disabled = input(false, {
|
|
614
|
+
transform: booleanAttribute,
|
|
615
|
+
});
|
|
616
|
+
/** The selected value. */
|
|
617
|
+
date = model();
|
|
618
|
+
/** Whether a specific date is disabled. */
|
|
619
|
+
dateDisabled = input(() => false);
|
|
620
|
+
/** The day the week starts on */
|
|
621
|
+
weekStartsOn = input(0, {
|
|
622
|
+
transform: (v) => numberAttribute(v),
|
|
623
|
+
});
|
|
624
|
+
/** The default focused date. */
|
|
625
|
+
defaultFocusedDate = input();
|
|
626
|
+
/** @internal Access the header */
|
|
627
|
+
header = contentChild(BrnCalendarHeaderDirective);
|
|
628
|
+
/** Store the cells */
|
|
629
|
+
cells = contentChildren(BrnCalendarCellButtonDirective, {
|
|
630
|
+
descendants: true,
|
|
631
|
+
});
|
|
632
|
+
/**
|
|
633
|
+
* @internal
|
|
634
|
+
* The internal state of the component.
|
|
635
|
+
*/
|
|
636
|
+
state = computed(() => ({
|
|
637
|
+
focusedDate: signal(this.constrainDate(this.defaultFocusedDate() ?? this.dateAdapter.now())),
|
|
638
|
+
}));
|
|
639
|
+
/**
|
|
640
|
+
* The focused date.
|
|
641
|
+
*/
|
|
642
|
+
focusedDate = computed(() => this.state().focusedDate());
|
|
643
|
+
/**
|
|
644
|
+
* Get all the days to display, this is the days of the current month
|
|
645
|
+
* and the days of the previous and next month to fill the grid.
|
|
646
|
+
*/
|
|
647
|
+
days = computed(() => {
|
|
648
|
+
const weekStartsOn = this.weekStartsOn();
|
|
649
|
+
const month = this.state().focusedDate();
|
|
650
|
+
const days = [];
|
|
651
|
+
// Get the first and last day of the month.
|
|
652
|
+
let firstDay = this.dateAdapter.startOfMonth(month);
|
|
653
|
+
let lastDay = this.dateAdapter.endOfMonth(month);
|
|
654
|
+
// we need to subtract until we get the to starting day before or on the start of the month.
|
|
655
|
+
while (this.dateAdapter.getDay(firstDay) !== weekStartsOn) {
|
|
656
|
+
firstDay = this.dateAdapter.subtract(firstDay, { days: 1 });
|
|
657
|
+
}
|
|
658
|
+
const weekEndsOn = (weekStartsOn + 6) % 7;
|
|
659
|
+
// we need to add until we get to the ending day after or on the end of the month.
|
|
660
|
+
while (this.dateAdapter.getDay(lastDay) !== weekEndsOn) {
|
|
661
|
+
lastDay = this.dateAdapter.add(lastDay, { days: 1 });
|
|
662
|
+
}
|
|
663
|
+
// collect all the days to display.
|
|
664
|
+
while (firstDay <= lastDay) {
|
|
665
|
+
days.push(firstDay);
|
|
666
|
+
firstDay = this.dateAdapter.add(firstDay, { days: 1 });
|
|
667
|
+
}
|
|
668
|
+
return days;
|
|
669
|
+
});
|
|
670
|
+
isSelected(date) {
|
|
671
|
+
return this.date()?.some((d) => this.dateAdapter.isSameDay(d, date)) ?? false;
|
|
672
|
+
}
|
|
673
|
+
selectDate(date) {
|
|
674
|
+
const selected = this.date();
|
|
675
|
+
if (this.isSelected(date)) {
|
|
676
|
+
const minSelection = this.minSelection();
|
|
677
|
+
if (selected?.length === minSelection) {
|
|
678
|
+
// min selection reached, do not allow to deselect
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
this.date.set(selected?.filter((d) => !this.dateAdapter.isSameDay(d, date)));
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
const maxSelection = this.maxSelection();
|
|
685
|
+
if (selected?.length === maxSelection) {
|
|
686
|
+
// max selection reached, reset the selection to date
|
|
687
|
+
this.date.set([date]);
|
|
688
|
+
}
|
|
689
|
+
else {
|
|
690
|
+
// add the date to the selection
|
|
691
|
+
this.date.set([...(selected ?? []), date]);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
// same as in brn-calendar.directive.ts
|
|
696
|
+
/** @internal Constrain a date to the min and max boundaries */
|
|
697
|
+
constrainDate(date) {
|
|
698
|
+
const min = this.min();
|
|
699
|
+
const max = this.max();
|
|
700
|
+
// If there is no min or max, return the date.
|
|
701
|
+
if (!min && !max) {
|
|
702
|
+
return date;
|
|
703
|
+
}
|
|
704
|
+
// If there is a min and the date is before the min, return the min.
|
|
705
|
+
if (min && this.dateAdapter.isBefore(date, this.dateAdapter.startOfDay(min))) {
|
|
706
|
+
return min;
|
|
707
|
+
}
|
|
708
|
+
// If there is a max and the date is after the max, return the max.
|
|
709
|
+
if (max && this.dateAdapter.isAfter(date, this.dateAdapter.endOfDay(max))) {
|
|
710
|
+
return max;
|
|
711
|
+
}
|
|
712
|
+
// Return the date.
|
|
713
|
+
return date;
|
|
714
|
+
}
|
|
715
|
+
/** @internal Determine if a date is disabled */
|
|
716
|
+
isDateDisabled(date) {
|
|
717
|
+
// if the calendar is disabled we can't select this date
|
|
718
|
+
if (this.disabled()) {
|
|
719
|
+
return true;
|
|
720
|
+
}
|
|
721
|
+
// if the date is outside the min and max range
|
|
722
|
+
const min = this.min();
|
|
723
|
+
const max = this.max();
|
|
724
|
+
if (min && this.dateAdapter.isBefore(date, this.dateAdapter.startOfDay(min))) {
|
|
725
|
+
return true;
|
|
726
|
+
}
|
|
727
|
+
if (max && this.dateAdapter.isAfter(date, this.dateAdapter.endOfDay(max))) {
|
|
728
|
+
return true;
|
|
729
|
+
}
|
|
730
|
+
// if this specific date is disabled
|
|
731
|
+
const disabledFn = this.dateDisabled();
|
|
732
|
+
if (disabledFn(date)) {
|
|
733
|
+
return true;
|
|
734
|
+
}
|
|
735
|
+
return false;
|
|
736
|
+
}
|
|
737
|
+
/** @internal Set the focused date */
|
|
738
|
+
setFocusedDate(date) {
|
|
739
|
+
// check if the date is disabled.
|
|
740
|
+
if (this.isDateDisabled(date)) {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
this.state().focusedDate.set(date);
|
|
744
|
+
// wait until the cells have all updated
|
|
745
|
+
afterNextRender({
|
|
746
|
+
write: () => {
|
|
747
|
+
// focus the cell with the target date.
|
|
748
|
+
const cell = this.cells().find((c) => this.dateAdapter.isSameDay(c.date(), date));
|
|
749
|
+
if (cell) {
|
|
750
|
+
cell.focus();
|
|
751
|
+
}
|
|
752
|
+
},
|
|
753
|
+
}, {
|
|
754
|
+
injector: this._injector,
|
|
755
|
+
});
|
|
756
|
+
// we must update the view to ensure the focused cell is visible.
|
|
757
|
+
this._changeDetector.detectChanges();
|
|
758
|
+
}
|
|
759
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: BrnCalendarMultiDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
760
|
+
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "19.2.1", type: BrnCalendarMultiDirective, isStandalone: true, selector: "[brnCalendarMulti]", inputs: { 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(BrnCalendarMultiDirective)], queries: [{ propertyName: "header", first: true, predicate: BrnCalendarHeaderDirective, descendants: true, isSignal: true }, { propertyName: "cells", predicate: BrnCalendarCellButtonDirective, descendants: true, isSignal: true }], ngImport: i0 });
|
|
761
|
+
}
|
|
762
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: BrnCalendarMultiDirective, decorators: [{
|
|
763
|
+
type: Directive,
|
|
764
|
+
args: [{
|
|
765
|
+
selector: '[brnCalendarMulti]',
|
|
766
|
+
standalone: true,
|
|
767
|
+
providers: [provideBrnCalendar(BrnCalendarMultiDirective)],
|
|
768
|
+
}]
|
|
769
|
+
}] });
|
|
770
|
+
|
|
587
771
|
const BrnCalendarImports = [
|
|
588
772
|
BrnCalendarCellButtonDirective,
|
|
589
773
|
BrnCalendarGridDirective,
|
|
@@ -594,6 +778,7 @@ const BrnCalendarImports = [
|
|
|
594
778
|
BrnCalendarWeekdayDirective,
|
|
595
779
|
BrnCalendarDirective,
|
|
596
780
|
BrnCalendarCellDirective,
|
|
781
|
+
BrnCalendarMultiDirective,
|
|
597
782
|
];
|
|
598
783
|
class BrnCalendarModule {
|
|
599
784
|
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: BrnCalendarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
@@ -605,7 +790,8 @@ class BrnCalendarModule {
|
|
|
605
790
|
BrnCalendarWeekDirective,
|
|
606
791
|
BrnCalendarWeekdayDirective,
|
|
607
792
|
BrnCalendarDirective,
|
|
608
|
-
BrnCalendarCellDirective
|
|
793
|
+
BrnCalendarCellDirective,
|
|
794
|
+
BrnCalendarMultiDirective], exports: [BrnCalendarCellButtonDirective,
|
|
609
795
|
BrnCalendarGridDirective,
|
|
610
796
|
BrnCalendarHeaderDirective,
|
|
611
797
|
BrnCalendarNextButtonDirective,
|
|
@@ -613,7 +799,8 @@ class BrnCalendarModule {
|
|
|
613
799
|
BrnCalendarWeekDirective,
|
|
614
800
|
BrnCalendarWeekdayDirective,
|
|
615
801
|
BrnCalendarDirective,
|
|
616
|
-
BrnCalendarCellDirective
|
|
802
|
+
BrnCalendarCellDirective,
|
|
803
|
+
BrnCalendarMultiDirective] });
|
|
617
804
|
/** @nocollapse */ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: BrnCalendarModule });
|
|
618
805
|
}
|
|
619
806
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: BrnCalendarModule, decorators: [{
|
|
@@ -628,5 +815,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImpor
|
|
|
628
815
|
* Generated bundle index. Do not edit.
|
|
629
816
|
*/
|
|
630
817
|
|
|
631
|
-
export { BrnCalendarCellButtonDirective, BrnCalendarCellDirective, BrnCalendarDirective, BrnCalendarGridDirective, BrnCalendarHeaderDirective, BrnCalendarI18nToken, BrnCalendarImports, BrnCalendarModule, BrnCalendarNextButtonDirective, BrnCalendarPreviousButtonDirective, BrnCalendarToken, BrnCalendarWeekDirective, BrnCalendarWeekdayDirective, injectBrnCalendar, injectBrnCalendarI18n, provideBrnCalendar, provideBrnCalendarI18n };
|
|
818
|
+
export { BrnCalendarCellButtonDirective, BrnCalendarCellDirective, BrnCalendarDirective, BrnCalendarGridDirective, BrnCalendarHeaderDirective, BrnCalendarI18nToken, BrnCalendarImports, BrnCalendarModule, BrnCalendarMultiDirective, BrnCalendarNextButtonDirective, BrnCalendarPreviousButtonDirective, BrnCalendarToken, BrnCalendarWeekDirective, BrnCalendarWeekdayDirective, injectBrnCalendar, injectBrnCalendarI18n, provideBrnCalendar, provideBrnCalendarI18n };
|
|
632
819
|
//# sourceMappingURL=spartan-ng-brain-calendar.mjs.map
|