@sebgroup/green-angular 2.1.3 → 3.0.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/esm2020/lib/datepicker/datepicker.component.mjs +27 -101
- package/esm2020/lib/datepicker/datepicker.module.mjs +7 -5
- package/esm2020/lib/dropdown/dropdown.component.mjs +6 -4
- package/fesm2015/sebgroup-green-angular.mjs +131 -200
- package/fesm2015/sebgroup-green-angular.mjs.map +1 -1
- package/fesm2020/sebgroup-green-angular.mjs +128 -199
- package/fesm2020/sebgroup-green-angular.mjs.map +1 -1
- package/lib/datepicker/datepicker.component.d.ts +22 -25
- package/lib/datepicker/datepicker.module.d.ts +2 -1
- package/lib/dropdown/dropdown.component.d.ts +3 -1
- package/package.json +4 -4
|
@@ -2,11 +2,11 @@ import * as i1 from '@angular/common';
|
|
|
2
2
|
import { CommonModule, DOCUMENT } from '@angular/common';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
4
|
import { EventEmitter, Component, Input, Output, ContentChildren, NgModule, ChangeDetectionStrategy, HostBinding, inject, Renderer2, ViewContainerRef, ChangeDetectorRef, TemplateRef, Directive, ViewChild, CUSTOM_ELEMENTS_SCHEMA, Injector, Inject, ContentChild, InjectionToken } from '@angular/core';
|
|
5
|
-
import { randomId,
|
|
5
|
+
import { randomId, calculateDegrees, sliderColors, getSliderTrackBackground, PaginationI18n } from '@sebgroup/extract';
|
|
6
6
|
import { getScopedTagName } from '@sebgroup/green-core';
|
|
7
7
|
import { registerTransitionalStyles } from '@sebgroup/green-core/transitional-styles';
|
|
8
8
|
import * as i2 from '@angular/forms';
|
|
9
|
-
import {
|
|
9
|
+
import { NG_VALUE_ACCESSOR, NgControl, FormsModule } from '@angular/forms';
|
|
10
10
|
import { startOfDay, endOfDay } from 'date-fns';
|
|
11
11
|
import * as i1$1 from '@angular/cdk/a11y';
|
|
12
12
|
import { A11yModule } from '@angular/cdk/a11y';
|
|
@@ -403,6 +403,123 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
403
403
|
}]
|
|
404
404
|
}] });
|
|
405
405
|
|
|
406
|
+
class NggDatepickerComponent {
|
|
407
|
+
constructor(_cdr) {
|
|
408
|
+
this._cdr = _cdr;
|
|
409
|
+
this.id = randomId();
|
|
410
|
+
this.isValid = null;
|
|
411
|
+
this.valueChange = new EventEmitter();
|
|
412
|
+
registerTransitionalStyles();
|
|
413
|
+
}
|
|
414
|
+
get options() {
|
|
415
|
+
return this._options;
|
|
416
|
+
}
|
|
417
|
+
set options(value) {
|
|
418
|
+
this._options = value;
|
|
419
|
+
}
|
|
420
|
+
get showWeekNumbers() {
|
|
421
|
+
return this.options?.showWeeks ?? false;
|
|
422
|
+
}
|
|
423
|
+
get value() {
|
|
424
|
+
return this._value;
|
|
425
|
+
}
|
|
426
|
+
set value(newValue) {
|
|
427
|
+
if (newValue !== this._value) {
|
|
428
|
+
this._value = newValue || undefined;
|
|
429
|
+
}
|
|
430
|
+
console.log('value', this._value);
|
|
431
|
+
}
|
|
432
|
+
get min() {
|
|
433
|
+
const minDate = this.options?.minDate;
|
|
434
|
+
return minDate ? minDate : new Date(new Date().getFullYear() - 10, 0, 1);
|
|
435
|
+
}
|
|
436
|
+
get max() {
|
|
437
|
+
const maxDate = this.options?.maxDate;
|
|
438
|
+
return maxDate ? maxDate : new Date(new Date().getFullYear() + 10, 0, 1);
|
|
439
|
+
}
|
|
440
|
+
writeValue(value) {
|
|
441
|
+
console.log('writeValue', value);
|
|
442
|
+
this.value = value;
|
|
443
|
+
}
|
|
444
|
+
registerOnChange(fn) {
|
|
445
|
+
this.onChangeFn = fn;
|
|
446
|
+
}
|
|
447
|
+
registerOnTouched(fn) {
|
|
448
|
+
this.onTouchedFn = fn;
|
|
449
|
+
}
|
|
450
|
+
onDateChange(evt) {
|
|
451
|
+
const e = evt;
|
|
452
|
+
this.value = e.detail.value;
|
|
453
|
+
this.valueChange.emit(e.detail.value);
|
|
454
|
+
this.onChangeFn && this.onChangeFn(e.detail.value);
|
|
455
|
+
}
|
|
456
|
+
ngAfterViewInit() {
|
|
457
|
+
this._cdr.detectChanges();
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
NggDatepickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
461
|
+
NggDatepickerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: NggDatepickerComponent, selector: "ngg-datepicker", inputs: { options: "options", value: "value", id: "id", label: "label", isValid: "isValid" }, outputs: { valueChange: "valueChange" }, providers: [
|
|
462
|
+
{
|
|
463
|
+
provide: NG_VALUE_ACCESSOR,
|
|
464
|
+
useExisting: NggDatepickerComponent,
|
|
465
|
+
multi: true,
|
|
466
|
+
},
|
|
467
|
+
], ngImport: i0, template: "<div class=\"form-group\">\n <gds-datepicker\n *nggCoreElement\n [attr.id]=\"id\"\n [label]=\"label\"\n [value]=\"value\"\n (change)=\"onDateChange($event)\"\n [invalid]=\"isValid === false\"\n [min]=\"min\"\n [max]=\"max\"\n [showWeekNumbers]=\"showWeekNumbers\"\n >\n <span slot=\"message\">\n <ng-content select=\"[data-form-info]\"></ng-content>\n </span>\n </gds-datepicker>\n</div>\n", dependencies: [{ kind: "directive", type: NggCoreElementDirective, selector: "[nggCoreElement]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
468
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerComponent, decorators: [{
|
|
469
|
+
type: Component,
|
|
470
|
+
args: [{ selector: 'ngg-datepicker', providers: [
|
|
471
|
+
{
|
|
472
|
+
provide: NG_VALUE_ACCESSOR,
|
|
473
|
+
useExisting: NggDatepickerComponent,
|
|
474
|
+
multi: true,
|
|
475
|
+
},
|
|
476
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"form-group\">\n <gds-datepicker\n *nggCoreElement\n [attr.id]=\"id\"\n [label]=\"label\"\n [value]=\"value\"\n (change)=\"onDateChange($event)\"\n [invalid]=\"isValid === false\"\n [min]=\"min\"\n [max]=\"max\"\n [showWeekNumbers]=\"showWeekNumbers\"\n >\n <span slot=\"message\">\n <ng-content select=\"[data-form-info]\"></ng-content>\n </span>\n </gds-datepicker>\n</div>\n" }]
|
|
477
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { options: [{
|
|
478
|
+
type: Input
|
|
479
|
+
}], value: [{
|
|
480
|
+
type: Input
|
|
481
|
+
}], id: [{
|
|
482
|
+
type: Input
|
|
483
|
+
}], label: [{
|
|
484
|
+
type: Input
|
|
485
|
+
}], isValid: [{
|
|
486
|
+
type: Input
|
|
487
|
+
}], valueChange: [{
|
|
488
|
+
type: Output
|
|
489
|
+
}] } });
|
|
490
|
+
function dateValidator(dates) {
|
|
491
|
+
return (control) => {
|
|
492
|
+
const value = control.value;
|
|
493
|
+
if (!value) {
|
|
494
|
+
return null;
|
|
495
|
+
}
|
|
496
|
+
const newDate = new Date(value);
|
|
497
|
+
const isValidDate = !isNaN(newDate.getTime());
|
|
498
|
+
if (!isValidDate) {
|
|
499
|
+
return { validDate: true };
|
|
500
|
+
}
|
|
501
|
+
const validMinDate = dates?.min ? newDate >= startOfDay(dates.min) : true;
|
|
502
|
+
const validMaxDate = dates?.max ? newDate <= endOfDay(dates.max) : true;
|
|
503
|
+
if (!validMinDate && dates?.min) {
|
|
504
|
+
return {
|
|
505
|
+
validDate: {
|
|
506
|
+
minDate: startOfDay(dates.min),
|
|
507
|
+
actualDate: newDate,
|
|
508
|
+
},
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
if (!validMaxDate && dates?.max) {
|
|
512
|
+
return {
|
|
513
|
+
validDate: {
|
|
514
|
+
maxDate: endOfDay(dates.max),
|
|
515
|
+
actualDate: newDate,
|
|
516
|
+
},
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
return null;
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
|
|
406
523
|
class NggDropdownOptionDirective {
|
|
407
524
|
constructor(templateRef) {
|
|
408
525
|
this.templateRef = templateRef;
|
|
@@ -551,13 +668,13 @@ class NggDropdownComponent {
|
|
|
551
668
|
}
|
|
552
669
|
}
|
|
553
670
|
NggDropdownComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDropdownComponent, deps: [{ token: Injector }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
554
|
-
NggDropdownComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: NggDropdownComponent, selector: "ngg-dropdown", inputs: { id: "id", texts: "texts", loop: "loop", display: "display", useValue: "useValue", label: "label", options: "options", valid: "valid", invalid: "invalid", compareWith: "compareWith", searchFilter: "searchFilter", fixedPlacement: "fixedPlacement", multiSelect: "multiSelect", searchable: "searchable", value: "value" }, outputs: { valueChange: "valueChange", touched: "touched" }, providers: [
|
|
671
|
+
NggDropdownComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: NggDropdownComponent, selector: "ngg-dropdown", inputs: { id: "id", texts: "texts", loop: "loop", display: "display", useValue: "useValue", label: "label", options: "options", valid: "valid", invalid: "invalid", compareWith: "compareWith", searchFilter: "searchFilter", syncPopoverWidth: "syncPopoverWidth", fixedPlacement: "fixedPlacement", multiSelect: "multiSelect", searchable: "searchable", value: "value" }, outputs: { valueChange: "valueChange", touched: "touched" }, providers: [
|
|
555
672
|
{
|
|
556
673
|
provide: NG_VALUE_ACCESSOR,
|
|
557
674
|
useExisting: NggDropdownComponent,
|
|
558
675
|
multi: true,
|
|
559
676
|
},
|
|
560
|
-
], queries: [{ propertyName: "customOption", first: true, predicate: NggDropdownOptionDirective, descendants: true }, { propertyName: "customButton", first: true, predicate: NggDropdownButtonDirective, descendants: true }], viewQueries: [{ propertyName: "gdsDropdown", first: true, predicate: ["gdsDropdown"], descendants: true }], ngImport: i0, template: "<div class=\"form-group\">\n <gds-dropdown\n *nggCoreElement\n #gdsDropdown\n [value]=\"value\"\n [searchable]=\"searchable\"\n [label]=\"label\"\n (change)=\"onValueChange($event)\"\n [multiple]=\"multiSelect\"\n [invalid]=\"invalid\"\n [compareWith]=\"compareWithAdapter\"\n [searchFilter]=\"searchFilterAdapter\"\n >\n <span slot=\"message\" #formInfo\n ><ng-content select=\"[data-form-info]\"></ng-content\n ></span>\n\n <span slot=\"trigger\"\n ><ng-container\n *ngTemplateOutlet=\"\n customButton?.templateRef && selectedOption\n ? customButton!.templateRef\n : defaultButton;\n context: { option: selectedOption }\n \"\n ></ng-container\n ></span>\n\n <ng-container *ngFor=\"let option of options; let index = index\">\n <gds-option *nggCoreElement [value]=\"option[useValue]\"\n ><ng-container\n *ngTemplateOutlet=\"\n customOption?.templateRef\n ? customOption!.templateRef\n : defaultOption;\n context: { option: option, index: index }\n \"\n ></ng-container\n ></gds-option>\n </ng-container>\n </gds-dropdown>\n</div>\n\n<ng-template #defaultButton let-selected=\"option\">\n <span class=\"trigger\">{{ texts?.select }}</span>\n</ng-template>\n\n<ng-template #defaultOption let-option=\"option\">\n {{ display ? option[display] : option.name }}\n</ng-template>\n", styles: [".trigger{display:block;overflow:hidden;text-overflow:ellipsis;text-wrap:nowrap}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: NggCoreElementDirective, selector: "[nggCoreElement]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
677
|
+
], queries: [{ propertyName: "customOption", first: true, predicate: NggDropdownOptionDirective, descendants: true }, { propertyName: "customButton", first: true, predicate: NggDropdownButtonDirective, descendants: true }], viewQueries: [{ propertyName: "gdsDropdown", first: true, predicate: ["gdsDropdown"], descendants: true }], ngImport: i0, template: "<div class=\"form-group\">\n <gds-dropdown\n *nggCoreElement\n #gdsDropdown\n [value]=\"value\"\n [searchable]=\"searchable\"\n [label]=\"label\"\n (change)=\"onValueChange($event)\"\n [multiple]=\"multiSelect\"\n [invalid]=\"invalid\"\n [compareWith]=\"compareWithAdapter\"\n [searchFilter]=\"searchFilterAdapter\"\n [syncPopoverWidth]=\"syncPopoverWidth\"\n >\n <span slot=\"message\" #formInfo\n ><ng-content select=\"[data-form-info]\"></ng-content\n ></span>\n\n <span slot=\"trigger\"\n ><ng-container\n *ngTemplateOutlet=\"\n customButton?.templateRef && selectedOption\n ? customButton!.templateRef\n : defaultButton;\n context: { option: selectedOption }\n \"\n ></ng-container\n ></span>\n\n <ng-container *ngFor=\"let option of options; let index = index\">\n <gds-option *nggCoreElement [value]=\"option[useValue]\"\n ><ng-container\n *ngTemplateOutlet=\"\n customOption?.templateRef\n ? customOption!.templateRef\n : defaultOption;\n context: { option: option, index: index }\n \"\n ></ng-container\n ></gds-option>\n </ng-container>\n </gds-dropdown>\n</div>\n\n<ng-template #defaultButton let-selected=\"option\">\n <span class=\"trigger\">{{ texts?.select }}</span>\n</ng-template>\n\n<ng-template #defaultOption let-option=\"option\">\n {{ display ? option[display] : option.name }}\n</ng-template>\n", styles: [".trigger{display:block;overflow:hidden;text-overflow:ellipsis;text-wrap:nowrap}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: NggCoreElementDirective, selector: "[nggCoreElement]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
561
678
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDropdownComponent, decorators: [{
|
|
562
679
|
type: Component,
|
|
563
680
|
args: [{ selector: 'ngg-dropdown', providers: [
|
|
@@ -566,7 +683,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
566
683
|
useExisting: NggDropdownComponent,
|
|
567
684
|
multi: true,
|
|
568
685
|
},
|
|
569
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"form-group\">\n <gds-dropdown\n *nggCoreElement\n #gdsDropdown\n [value]=\"value\"\n [searchable]=\"searchable\"\n [label]=\"label\"\n (change)=\"onValueChange($event)\"\n [multiple]=\"multiSelect\"\n [invalid]=\"invalid\"\n [compareWith]=\"compareWithAdapter\"\n [searchFilter]=\"searchFilterAdapter\"\n >\n <span slot=\"message\" #formInfo\n ><ng-content select=\"[data-form-info]\"></ng-content\n ></span>\n\n <span slot=\"trigger\"\n ><ng-container\n *ngTemplateOutlet=\"\n customButton?.templateRef && selectedOption\n ? customButton!.templateRef\n : defaultButton;\n context: { option: selectedOption }\n \"\n ></ng-container\n ></span>\n\n <ng-container *ngFor=\"let option of options; let index = index\">\n <gds-option *nggCoreElement [value]=\"option[useValue]\"\n ><ng-container\n *ngTemplateOutlet=\"\n customOption?.templateRef\n ? customOption!.templateRef\n : defaultOption;\n context: { option: option, index: index }\n \"\n ></ng-container\n ></gds-option>\n </ng-container>\n </gds-dropdown>\n</div>\n\n<ng-template #defaultButton let-selected=\"option\">\n <span class=\"trigger\">{{ texts?.select }}</span>\n</ng-template>\n\n<ng-template #defaultOption let-option=\"option\">\n {{ display ? option[display] : option.name }}\n</ng-template>\n", styles: [".trigger{display:block;overflow:hidden;text-overflow:ellipsis;text-wrap:nowrap}\n"] }]
|
|
686
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"form-group\">\n <gds-dropdown\n *nggCoreElement\n #gdsDropdown\n [value]=\"value\"\n [searchable]=\"searchable\"\n [label]=\"label\"\n (change)=\"onValueChange($event)\"\n [multiple]=\"multiSelect\"\n [invalid]=\"invalid\"\n [compareWith]=\"compareWithAdapter\"\n [searchFilter]=\"searchFilterAdapter\"\n [syncPopoverWidth]=\"syncPopoverWidth\"\n >\n <span slot=\"message\" #formInfo\n ><ng-content select=\"[data-form-info]\"></ng-content\n ></span>\n\n <span slot=\"trigger\"\n ><ng-container\n *ngTemplateOutlet=\"\n customButton?.templateRef && selectedOption\n ? customButton!.templateRef\n : defaultButton;\n context: { option: selectedOption }\n \"\n ></ng-container\n ></span>\n\n <ng-container *ngFor=\"let option of options; let index = index\">\n <gds-option *nggCoreElement [value]=\"option[useValue]\"\n ><ng-container\n *ngTemplateOutlet=\"\n customOption?.templateRef\n ? customOption!.templateRef\n : defaultOption;\n context: { option: option, index: index }\n \"\n ></ng-container\n ></gds-option>\n </ng-container>\n </gds-dropdown>\n</div>\n\n<ng-template #defaultButton let-selected=\"option\">\n <span class=\"trigger\">{{ texts?.select }}</span>\n</ng-template>\n\n<ng-template #defaultOption let-option=\"option\">\n {{ display ? option[display] : option.name }}\n</ng-template>\n", styles: [".trigger{display:block;overflow:hidden;text-overflow:ellipsis;text-wrap:nowrap}\n"] }]
|
|
570
687
|
}], ctorParameters: function () { return [{ type: i0.Injector, decorators: [{
|
|
571
688
|
type: Inject,
|
|
572
689
|
args: [Injector]
|
|
@@ -592,6 +709,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
592
709
|
type: Input
|
|
593
710
|
}], searchFilter: [{
|
|
594
711
|
type: Input
|
|
712
|
+
}], syncPopoverWidth: [{
|
|
713
|
+
type: Input
|
|
595
714
|
}], fixedPlacement: [{
|
|
596
715
|
type: Input
|
|
597
716
|
}], multiSelect: [{
|
|
@@ -615,197 +734,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
615
734
|
args: ['gdsDropdown', { static: false }]
|
|
616
735
|
}] } });
|
|
617
736
|
|
|
618
|
-
class NggDatepickerComponent {
|
|
619
|
-
constructor(_cdr) {
|
|
620
|
-
this._cdr = _cdr;
|
|
621
|
-
this.id = randomId();
|
|
622
|
-
this.isValid = null;
|
|
623
|
-
this.valueChange = new EventEmitter();
|
|
624
|
-
this._months = months({});
|
|
625
|
-
this.listener = (data, state) => {
|
|
626
|
-
if (this.dp && state) {
|
|
627
|
-
this.dp.state = { ...state };
|
|
628
|
-
this.years = years({
|
|
629
|
-
from: this.dp.state?.minDate?.getFullYear(),
|
|
630
|
-
to: this.dp.state?.maxDate?.getFullYear(),
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
if (data) {
|
|
634
|
-
// only emit change event if date has changed
|
|
635
|
-
if (this.data?.selectedDate !== data.selectedDate) {
|
|
636
|
-
this.valueChange.emit(data.selectedDate);
|
|
637
|
-
this.onChangeFn && this.onChangeFn(data.selectedDate);
|
|
638
|
-
}
|
|
639
|
-
this.data = data;
|
|
640
|
-
}
|
|
641
|
-
this._cdr.detectChanges();
|
|
642
|
-
};
|
|
643
|
-
}
|
|
644
|
-
get months() {
|
|
645
|
-
return this._months;
|
|
646
|
-
}
|
|
647
|
-
set months(value) {
|
|
648
|
-
this._months = value;
|
|
649
|
-
}
|
|
650
|
-
get options() {
|
|
651
|
-
return this._options;
|
|
652
|
-
}
|
|
653
|
-
set options(value) {
|
|
654
|
-
this._options = value;
|
|
655
|
-
if (value.locale) {
|
|
656
|
-
this.months = months({ locale: this.options?.locale });
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
get value() {
|
|
660
|
-
return this._value;
|
|
661
|
-
}
|
|
662
|
-
set value(newValue) {
|
|
663
|
-
if (newValue !== this._value) {
|
|
664
|
-
this._value = newValue || '';
|
|
665
|
-
if (this._value !== undefined && this.dp) {
|
|
666
|
-
this.dp.select(this._value);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
writeValue(value) {
|
|
671
|
-
this.value = value;
|
|
672
|
-
}
|
|
673
|
-
registerOnChange(fn) {
|
|
674
|
-
this.onChangeFn = fn;
|
|
675
|
-
}
|
|
676
|
-
registerOnTouched(fn) {
|
|
677
|
-
this.onTouchedFn = fn;
|
|
678
|
-
}
|
|
679
|
-
get data() {
|
|
680
|
-
return this._data;
|
|
681
|
-
}
|
|
682
|
-
set data(value) {
|
|
683
|
-
this._data = value;
|
|
684
|
-
}
|
|
685
|
-
onDateChange(value) {
|
|
686
|
-
const newDate = new Date(value);
|
|
687
|
-
// Only pass valid date to date picker
|
|
688
|
-
if (!isNaN(newDate.getTime())) {
|
|
689
|
-
this.dp?.select(value);
|
|
690
|
-
}
|
|
691
|
-
else {
|
|
692
|
-
this.valueChange.emit(value);
|
|
693
|
-
this.onChangeFn && this.onChangeFn(value);
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
trackWeek(index, week) {
|
|
697
|
-
return week;
|
|
698
|
-
}
|
|
699
|
-
ngOnChanges(changes) {
|
|
700
|
-
//ignore changes until datepicker has been initialised in ngAfterViewInit
|
|
701
|
-
if (!this.dp)
|
|
702
|
-
return;
|
|
703
|
-
if (changes.options) {
|
|
704
|
-
this._createDatepicker();
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
ngAfterViewInit() {
|
|
708
|
-
this._createDatepicker();
|
|
709
|
-
this._cdr.detectChanges();
|
|
710
|
-
}
|
|
711
|
-
_createDatepicker() {
|
|
712
|
-
if (this.datepickerElRef &&
|
|
713
|
-
this.datepickerDialogElRef &&
|
|
714
|
-
this.dateInputElRef &&
|
|
715
|
-
this.datepickerTriggerElRef) {
|
|
716
|
-
this.dp = createDatepicker(this.listener, {
|
|
717
|
-
...this.options,
|
|
718
|
-
selectedDate: this.value,
|
|
719
|
-
}, this.datepickerElRef.nativeElement, this.datepickerDialogElRef.nativeElement, this.dateInputElRef.nativeElement, this.datepickerTriggerElRef.nativeElement);
|
|
720
|
-
}
|
|
721
|
-
else {
|
|
722
|
-
throw 'Missing one or more elements...';
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
blurInput() {
|
|
726
|
-
this.onTouchedFn && this.onTouchedFn();
|
|
727
|
-
}
|
|
728
|
-
focusoutDialog(event) {
|
|
729
|
-
if (!this.datepickerDialogElRef?.nativeElement.contains(event.relatedTarget)) {
|
|
730
|
-
this.onTouchedFn && this.onTouchedFn();
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
NggDatepickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
735
|
-
NggDatepickerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: NggDatepickerComponent, selector: "ngg-datepicker", inputs: { options: "options", value: "value", id: "id", label: "label", isValid: "isValid" }, outputs: { valueChange: "valueChange" }, providers: [
|
|
736
|
-
{
|
|
737
|
-
provide: NG_VALUE_ACCESSOR,
|
|
738
|
-
useExisting: NggDatepickerComponent,
|
|
739
|
-
multi: true,
|
|
740
|
-
},
|
|
741
|
-
], viewQueries: [{ propertyName: "datepickerDialogElRef", first: true, predicate: ["datepickerDialogElRef"], descendants: true }, { propertyName: "dateInputElRef", first: true, predicate: ["dateInputElRef"], descendants: true }, { propertyName: "datepickerElRef", first: true, predicate: ["datepickerElRef"], descendants: true }, { propertyName: "datepickerTriggerElRef", first: true, predicate: ["datepickerTriggerElRef"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"form-group\">\n <label *ngIf=\"label\" [for]=\"id\">{{ label }}</label>\n <div\n class=\"group\"\n #datepickerElRef\n [class.is-valid]=\"isValid\"\n [class.is-invalid]=\"isValid === false\"\n >\n <input\n (blur)=\"blurInput()\"\n [attr.id]=\"id\"\n [attr.aria-describedby]=\"\n formInfo?.innerText && formInfo.innerText.length > 0\n ? id + '_info'\n : null\n \"\n type=\"text\"\n placeholder=\"yyyy-mm-dd\"\n #dateInputElRef\n [value]=\"data?.formattedSelectedDate || ''\"\n (change)=\"onDateChange(dateInputElRef.value)\"\n />\n <button\n #datepickerTriggerElRef\n (click)=\"dp?.toggle()\"\n type=\"button\"\n class=\"primary\"\n >\n <i class=\"sg-icon sg-icon-calendar\">Select date</i>\n </button>\n </div>\n <span class=\"form-info\" #formInfo [attr.id]=\"id + '_info'\"\n ><ng-content select=\"[data-form-info]\"></ng-content\n ></span>\n</div>\n<!-- TODO: get or set attributes from within datepicker instance (dp) -->\n<div\n #datepickerDialogElRef\n class=\"popover popover-datepicker\"\n [class.active]=\"dp?.state?.isActive\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Choose Date\"\n (focusout)=\"focusoutDialog($event)\"\n>\n <button type=\"button\" class=\"close\" (click)=\"dp?.close()\">\n <i></i>Close\n </button>\n <div class=\"sg-date\">\n <header>\n <button type=\"button\" class=\"link\" (click)=\"dp?.sub(1, 'months')\">\n <i class=\"sg-icon sg-icon-previous\">Previous month</i>\n </button>\n <ngg-dropdown\n [options]=\"months\"\n display=\"key\"\n text=\"Select\"\n [value]=\"data?.month\"\n (valueChange)=\"dp?.setMonth($event)\"\n ></ngg-dropdown>\n <ngg-dropdown\n *ngIf=\"years\"\n [options]=\"years\"\n display=\"key\"\n text=\"Select\"\n [value]=\"data?.year\"\n (valueChange)=\"dp?.setYear($event)\"\n ></ngg-dropdown>\n <button type=\"button\" class=\"link\" (click)=\"dp?.add(1, 'months')\">\n <i class=\"sg-icon sg-icon-next\">Next month</i>\n </button>\n </header>\n <main>\n <table role=\"grid\">\n <thead>\n <tr>\n <th\n scope=\"col\"\n *ngFor=\"let header of data?.calendar?.headers\"\n [abbr]=\"header.abbr\"\n [class.sg-week-header]=\"header.type === 'week'\"\n [class.sg-day-header]=\"header.type === 'day'\"\n >\n {{ header.displayText }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr\n *ngFor=\"\n let week of data?.calendar?.calendarGrid;\n trackBy: trackWeek;\n let i = index\n \"\n >\n <th\n *ngIf=\"data?.calendar?.weekNumbers as weekNumbers\"\n class=\"sg-week-number\"\n >\n {{ weekNumbers[i] }}\n </th>\n <td\n *ngFor=\"let day of week\"\n [attr.data-date]=\"day.formattedDate\"\n [attr.role]=\"day.selected ? 'gridcell' : null\"\n [attr.aria-selected]=\"\n day.selected && !data?.highlightedDate ? true : null\n \"\n [class.disabled]=\"day.disabled\"\n [class.sg-date-today]=\"day.today\"\n [title]=\"day.today ? 'Today' : ''\"\n [tabIndex]=\"\n day.highlighted ||\n (day.selected && !data?.highlightedDate) ||\n (day.today && !data?.highlightedDate && !data?.selectedDate)\n ? 0\n : -1\n \"\n (click)=\"day.currentMonth && dp?.select(day.date)\"\n >\n {{ day.day }}\n </td>\n </tr>\n </tbody>\n </table>\n </main>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: NggDropdownComponent, selector: "ngg-dropdown", inputs: ["id", "texts", "loop", "display", "useValue", "label", "options", "valid", "invalid", "compareWith", "searchFilter", "fixedPlacement", "multiSelect", "searchable", "value"], outputs: ["valueChange", "touched"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
742
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerComponent, decorators: [{
|
|
743
|
-
type: Component,
|
|
744
|
-
args: [{ selector: 'ngg-datepicker', providers: [
|
|
745
|
-
{
|
|
746
|
-
provide: NG_VALUE_ACCESSOR,
|
|
747
|
-
useExisting: NggDatepickerComponent,
|
|
748
|
-
multi: true,
|
|
749
|
-
},
|
|
750
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"form-group\">\n <label *ngIf=\"label\" [for]=\"id\">{{ label }}</label>\n <div\n class=\"group\"\n #datepickerElRef\n [class.is-valid]=\"isValid\"\n [class.is-invalid]=\"isValid === false\"\n >\n <input\n (blur)=\"blurInput()\"\n [attr.id]=\"id\"\n [attr.aria-describedby]=\"\n formInfo?.innerText && formInfo.innerText.length > 0\n ? id + '_info'\n : null\n \"\n type=\"text\"\n placeholder=\"yyyy-mm-dd\"\n #dateInputElRef\n [value]=\"data?.formattedSelectedDate || ''\"\n (change)=\"onDateChange(dateInputElRef.value)\"\n />\n <button\n #datepickerTriggerElRef\n (click)=\"dp?.toggle()\"\n type=\"button\"\n class=\"primary\"\n >\n <i class=\"sg-icon sg-icon-calendar\">Select date</i>\n </button>\n </div>\n <span class=\"form-info\" #formInfo [attr.id]=\"id + '_info'\"\n ><ng-content select=\"[data-form-info]\"></ng-content\n ></span>\n</div>\n<!-- TODO: get or set attributes from within datepicker instance (dp) -->\n<div\n #datepickerDialogElRef\n class=\"popover popover-datepicker\"\n [class.active]=\"dp?.state?.isActive\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Choose Date\"\n (focusout)=\"focusoutDialog($event)\"\n>\n <button type=\"button\" class=\"close\" (click)=\"dp?.close()\">\n <i></i>Close\n </button>\n <div class=\"sg-date\">\n <header>\n <button type=\"button\" class=\"link\" (click)=\"dp?.sub(1, 'months')\">\n <i class=\"sg-icon sg-icon-previous\">Previous month</i>\n </button>\n <ngg-dropdown\n [options]=\"months\"\n display=\"key\"\n text=\"Select\"\n [value]=\"data?.month\"\n (valueChange)=\"dp?.setMonth($event)\"\n ></ngg-dropdown>\n <ngg-dropdown\n *ngIf=\"years\"\n [options]=\"years\"\n display=\"key\"\n text=\"Select\"\n [value]=\"data?.year\"\n (valueChange)=\"dp?.setYear($event)\"\n ></ngg-dropdown>\n <button type=\"button\" class=\"link\" (click)=\"dp?.add(1, 'months')\">\n <i class=\"sg-icon sg-icon-next\">Next month</i>\n </button>\n </header>\n <main>\n <table role=\"grid\">\n <thead>\n <tr>\n <th\n scope=\"col\"\n *ngFor=\"let header of data?.calendar?.headers\"\n [abbr]=\"header.abbr\"\n [class.sg-week-header]=\"header.type === 'week'\"\n [class.sg-day-header]=\"header.type === 'day'\"\n >\n {{ header.displayText }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr\n *ngFor=\"\n let week of data?.calendar?.calendarGrid;\n trackBy: trackWeek;\n let i = index\n \"\n >\n <th\n *ngIf=\"data?.calendar?.weekNumbers as weekNumbers\"\n class=\"sg-week-number\"\n >\n {{ weekNumbers[i] }}\n </th>\n <td\n *ngFor=\"let day of week\"\n [attr.data-date]=\"day.formattedDate\"\n [attr.role]=\"day.selected ? 'gridcell' : null\"\n [attr.aria-selected]=\"\n day.selected && !data?.highlightedDate ? true : null\n \"\n [class.disabled]=\"day.disabled\"\n [class.sg-date-today]=\"day.today\"\n [title]=\"day.today ? 'Today' : ''\"\n [tabIndex]=\"\n day.highlighted ||\n (day.selected && !data?.highlightedDate) ||\n (day.today && !data?.highlightedDate && !data?.selectedDate)\n ? 0\n : -1\n \"\n (click)=\"day.currentMonth && dp?.select(day.date)\"\n >\n {{ day.day }}\n </td>\n </tr>\n </tbody>\n </table>\n </main>\n </div>\n</div>\n" }]
|
|
751
|
-
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { options: [{
|
|
752
|
-
type: Input
|
|
753
|
-
}], value: [{
|
|
754
|
-
type: Input
|
|
755
|
-
}], id: [{
|
|
756
|
-
type: Input
|
|
757
|
-
}], label: [{
|
|
758
|
-
type: Input
|
|
759
|
-
}], isValid: [{
|
|
760
|
-
type: Input
|
|
761
|
-
}], valueChange: [{
|
|
762
|
-
type: Output
|
|
763
|
-
}], datepickerDialogElRef: [{
|
|
764
|
-
type: ViewChild,
|
|
765
|
-
args: ['datepickerDialogElRef']
|
|
766
|
-
}], dateInputElRef: [{
|
|
767
|
-
type: ViewChild,
|
|
768
|
-
args: ['dateInputElRef']
|
|
769
|
-
}], datepickerElRef: [{
|
|
770
|
-
type: ViewChild,
|
|
771
|
-
args: ['datepickerElRef']
|
|
772
|
-
}], datepickerTriggerElRef: [{
|
|
773
|
-
type: ViewChild,
|
|
774
|
-
args: ['datepickerTriggerElRef']
|
|
775
|
-
}] } });
|
|
776
|
-
function dateValidator(dates) {
|
|
777
|
-
return (control) => {
|
|
778
|
-
const value = control.value;
|
|
779
|
-
if (!value) {
|
|
780
|
-
return null;
|
|
781
|
-
}
|
|
782
|
-
const newDate = new Date(value);
|
|
783
|
-
const isValidDate = !isNaN(newDate.getTime());
|
|
784
|
-
if (!isValidDate) {
|
|
785
|
-
return { validDate: true };
|
|
786
|
-
}
|
|
787
|
-
const validMinDate = dates?.min ? newDate >= startOfDay(dates.min) : true;
|
|
788
|
-
const validMaxDate = dates?.max ? newDate <= endOfDay(dates.max) : true;
|
|
789
|
-
if (!validMinDate && dates?.min) {
|
|
790
|
-
return {
|
|
791
|
-
validDate: {
|
|
792
|
-
minDate: startOfDay(dates.min),
|
|
793
|
-
actualDate: newDate,
|
|
794
|
-
},
|
|
795
|
-
};
|
|
796
|
-
}
|
|
797
|
-
if (!validMaxDate && dates?.max) {
|
|
798
|
-
return {
|
|
799
|
-
validDate: {
|
|
800
|
-
maxDate: endOfDay(dates.max),
|
|
801
|
-
actualDate: newDate,
|
|
802
|
-
},
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
|
-
return null;
|
|
806
|
-
};
|
|
807
|
-
}
|
|
808
|
-
|
|
809
737
|
class NggDropdownModule {
|
|
810
738
|
}
|
|
811
739
|
NggDropdownModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDropdownModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
@@ -836,14 +764,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
836
764
|
class NggDatepickerModule {
|
|
837
765
|
}
|
|
838
766
|
NggDatepickerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
839
|
-
NggDatepickerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerModule, declarations: [NggDatepickerComponent], imports: [CommonModule, NggDropdownModule], exports: [NggDatepickerComponent] });
|
|
840
|
-
NggDatepickerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerModule, imports: [CommonModule, NggDropdownModule] });
|
|
767
|
+
NggDatepickerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerModule, declarations: [NggDatepickerComponent], imports: [CommonModule, NggDropdownModule, NggCoreWrapperModule], exports: [NggDatepickerComponent] });
|
|
768
|
+
NggDatepickerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerModule, imports: [CommonModule, NggDropdownModule, NggCoreWrapperModule] });
|
|
841
769
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerModule, decorators: [{
|
|
842
770
|
type: NgModule,
|
|
843
771
|
args: [{
|
|
844
772
|
declarations: [NggDatepickerComponent],
|
|
845
|
-
imports: [CommonModule, NggDropdownModule],
|
|
773
|
+
imports: [CommonModule, NggDropdownModule, NggCoreWrapperModule],
|
|
846
774
|
exports: [NggDatepickerComponent],
|
|
775
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
847
776
|
}]
|
|
848
777
|
}] });
|
|
849
778
|
|