@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 { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';
|
|
12
12
|
import * as i1$1 from '@angular/cdk/a11y';
|
|
@@ -405,6 +405,126 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
405
405
|
}]
|
|
406
406
|
}] });
|
|
407
407
|
|
|
408
|
+
class NggDatepickerComponent {
|
|
409
|
+
constructor(_cdr) {
|
|
410
|
+
this._cdr = _cdr;
|
|
411
|
+
this.id = randomId();
|
|
412
|
+
this.isValid = null;
|
|
413
|
+
this.valueChange = new EventEmitter();
|
|
414
|
+
registerTransitionalStyles();
|
|
415
|
+
}
|
|
416
|
+
get options() {
|
|
417
|
+
return this._options;
|
|
418
|
+
}
|
|
419
|
+
set options(value) {
|
|
420
|
+
this._options = value;
|
|
421
|
+
}
|
|
422
|
+
get showWeekNumbers() {
|
|
423
|
+
var _a, _b;
|
|
424
|
+
return (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.showWeeks) !== null && _b !== void 0 ? _b : false;
|
|
425
|
+
}
|
|
426
|
+
get value() {
|
|
427
|
+
return this._value;
|
|
428
|
+
}
|
|
429
|
+
set value(newValue) {
|
|
430
|
+
if (newValue !== this._value) {
|
|
431
|
+
this._value = newValue || undefined;
|
|
432
|
+
}
|
|
433
|
+
console.log('value', this._value);
|
|
434
|
+
}
|
|
435
|
+
get min() {
|
|
436
|
+
var _a;
|
|
437
|
+
const minDate = (_a = this.options) === null || _a === void 0 ? void 0 : _a.minDate;
|
|
438
|
+
return minDate ? minDate : new Date(new Date().getFullYear() - 10, 0, 1);
|
|
439
|
+
}
|
|
440
|
+
get max() {
|
|
441
|
+
var _a;
|
|
442
|
+
const maxDate = (_a = this.options) === null || _a === void 0 ? void 0 : _a.maxDate;
|
|
443
|
+
return maxDate ? maxDate : new Date(new Date().getFullYear() + 10, 0, 1);
|
|
444
|
+
}
|
|
445
|
+
writeValue(value) {
|
|
446
|
+
console.log('writeValue', value);
|
|
447
|
+
this.value = value;
|
|
448
|
+
}
|
|
449
|
+
registerOnChange(fn) {
|
|
450
|
+
this.onChangeFn = fn;
|
|
451
|
+
}
|
|
452
|
+
registerOnTouched(fn) {
|
|
453
|
+
this.onTouchedFn = fn;
|
|
454
|
+
}
|
|
455
|
+
onDateChange(evt) {
|
|
456
|
+
const e = evt;
|
|
457
|
+
this.value = e.detail.value;
|
|
458
|
+
this.valueChange.emit(e.detail.value);
|
|
459
|
+
this.onChangeFn && this.onChangeFn(e.detail.value);
|
|
460
|
+
}
|
|
461
|
+
ngAfterViewInit() {
|
|
462
|
+
this._cdr.detectChanges();
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
NggDatepickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
466
|
+
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: [
|
|
467
|
+
{
|
|
468
|
+
provide: NG_VALUE_ACCESSOR,
|
|
469
|
+
useExisting: NggDatepickerComponent,
|
|
470
|
+
multi: true,
|
|
471
|
+
},
|
|
472
|
+
], 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 });
|
|
473
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerComponent, decorators: [{
|
|
474
|
+
type: Component,
|
|
475
|
+
args: [{ selector: 'ngg-datepicker', providers: [
|
|
476
|
+
{
|
|
477
|
+
provide: NG_VALUE_ACCESSOR,
|
|
478
|
+
useExisting: NggDatepickerComponent,
|
|
479
|
+
multi: true,
|
|
480
|
+
},
|
|
481
|
+
], 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" }]
|
|
482
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { options: [{
|
|
483
|
+
type: Input
|
|
484
|
+
}], value: [{
|
|
485
|
+
type: Input
|
|
486
|
+
}], id: [{
|
|
487
|
+
type: Input
|
|
488
|
+
}], label: [{
|
|
489
|
+
type: Input
|
|
490
|
+
}], isValid: [{
|
|
491
|
+
type: Input
|
|
492
|
+
}], valueChange: [{
|
|
493
|
+
type: Output
|
|
494
|
+
}] } });
|
|
495
|
+
function dateValidator(dates) {
|
|
496
|
+
return (control) => {
|
|
497
|
+
const value = control.value;
|
|
498
|
+
if (!value) {
|
|
499
|
+
return null;
|
|
500
|
+
}
|
|
501
|
+
const newDate = new Date(value);
|
|
502
|
+
const isValidDate = !isNaN(newDate.getTime());
|
|
503
|
+
if (!isValidDate) {
|
|
504
|
+
return { validDate: true };
|
|
505
|
+
}
|
|
506
|
+
const validMinDate = (dates === null || dates === void 0 ? void 0 : dates.min) ? newDate >= startOfDay(dates.min) : true;
|
|
507
|
+
const validMaxDate = (dates === null || dates === void 0 ? void 0 : dates.max) ? newDate <= endOfDay(dates.max) : true;
|
|
508
|
+
if (!validMinDate && (dates === null || dates === void 0 ? void 0 : dates.min)) {
|
|
509
|
+
return {
|
|
510
|
+
validDate: {
|
|
511
|
+
minDate: startOfDay(dates.min),
|
|
512
|
+
actualDate: newDate,
|
|
513
|
+
},
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
if (!validMaxDate && (dates === null || dates === void 0 ? void 0 : dates.max)) {
|
|
517
|
+
return {
|
|
518
|
+
validDate: {
|
|
519
|
+
maxDate: endOfDay(dates.max),
|
|
520
|
+
actualDate: newDate,
|
|
521
|
+
},
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
return null;
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
|
|
408
528
|
class NggDropdownOptionDirective {
|
|
409
529
|
constructor(templateRef) {
|
|
410
530
|
this.templateRef = templateRef;
|
|
@@ -546,13 +666,13 @@ class NggDropdownComponent {
|
|
|
546
666
|
}
|
|
547
667
|
}
|
|
548
668
|
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 });
|
|
549
|
-
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: [
|
|
669
|
+
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: [
|
|
550
670
|
{
|
|
551
671
|
provide: NG_VALUE_ACCESSOR,
|
|
552
672
|
useExisting: NggDropdownComponent,
|
|
553
673
|
multi: true,
|
|
554
674
|
},
|
|
555
|
-
], 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 });
|
|
675
|
+
], 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 });
|
|
556
676
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDropdownComponent, decorators: [{
|
|
557
677
|
type: Component,
|
|
558
678
|
args: [{ selector: 'ngg-dropdown', providers: [
|
|
@@ -561,7 +681,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
561
681
|
useExisting: NggDropdownComponent,
|
|
562
682
|
multi: true,
|
|
563
683
|
},
|
|
564
|
-
], 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"] }]
|
|
684
|
+
], 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"] }]
|
|
565
685
|
}], ctorParameters: function () {
|
|
566
686
|
return [{ type: i0.Injector, decorators: [{
|
|
567
687
|
type: Inject,
|
|
@@ -589,6 +709,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
589
709
|
type: Input
|
|
590
710
|
}], searchFilter: [{
|
|
591
711
|
type: Input
|
|
712
|
+
}], syncPopoverWidth: [{
|
|
713
|
+
type: Input
|
|
592
714
|
}], fixedPlacement: [{
|
|
593
715
|
type: Input
|
|
594
716
|
}], multiSelect: [{
|
|
@@ -612,198 +734,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
612
734
|
args: ['gdsDropdown', { static: false }]
|
|
613
735
|
}] } });
|
|
614
736
|
|
|
615
|
-
class NggDatepickerComponent {
|
|
616
|
-
constructor(_cdr) {
|
|
617
|
-
this._cdr = _cdr;
|
|
618
|
-
this.id = randomId();
|
|
619
|
-
this.isValid = null;
|
|
620
|
-
this.valueChange = new EventEmitter();
|
|
621
|
-
this._months = months({});
|
|
622
|
-
this.listener = (data, state) => {
|
|
623
|
-
var _a, _b, _c, _d, _e;
|
|
624
|
-
if (this.dp && state) {
|
|
625
|
-
this.dp.state = Object.assign({}, state);
|
|
626
|
-
this.years = years({
|
|
627
|
-
from: (_b = (_a = this.dp.state) === null || _a === void 0 ? void 0 : _a.minDate) === null || _b === void 0 ? void 0 : _b.getFullYear(),
|
|
628
|
-
to: (_d = (_c = this.dp.state) === null || _c === void 0 ? void 0 : _c.maxDate) === null || _d === void 0 ? void 0 : _d.getFullYear(),
|
|
629
|
-
});
|
|
630
|
-
}
|
|
631
|
-
if (data) {
|
|
632
|
-
// only emit change event if date has changed
|
|
633
|
-
if (((_e = this.data) === null || _e === void 0 ? void 0 : _e.selectedDate) !== data.selectedDate) {
|
|
634
|
-
this.valueChange.emit(data.selectedDate);
|
|
635
|
-
this.onChangeFn && this.onChangeFn(data.selectedDate);
|
|
636
|
-
}
|
|
637
|
-
this.data = data;
|
|
638
|
-
}
|
|
639
|
-
this._cdr.detectChanges();
|
|
640
|
-
};
|
|
641
|
-
}
|
|
642
|
-
get months() {
|
|
643
|
-
return this._months;
|
|
644
|
-
}
|
|
645
|
-
set months(value) {
|
|
646
|
-
this._months = value;
|
|
647
|
-
}
|
|
648
|
-
get options() {
|
|
649
|
-
return this._options;
|
|
650
|
-
}
|
|
651
|
-
set options(value) {
|
|
652
|
-
var _a;
|
|
653
|
-
this._options = value;
|
|
654
|
-
if (value.locale) {
|
|
655
|
-
this.months = months({ locale: (_a = this.options) === null || _a === void 0 ? void 0 : _a.locale });
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
get value() {
|
|
659
|
-
return this._value;
|
|
660
|
-
}
|
|
661
|
-
set value(newValue) {
|
|
662
|
-
if (newValue !== this._value) {
|
|
663
|
-
this._value = newValue || '';
|
|
664
|
-
if (this._value !== undefined && this.dp) {
|
|
665
|
-
this.dp.select(this._value);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
writeValue(value) {
|
|
670
|
-
this.value = value;
|
|
671
|
-
}
|
|
672
|
-
registerOnChange(fn) {
|
|
673
|
-
this.onChangeFn = fn;
|
|
674
|
-
}
|
|
675
|
-
registerOnTouched(fn) {
|
|
676
|
-
this.onTouchedFn = fn;
|
|
677
|
-
}
|
|
678
|
-
get data() {
|
|
679
|
-
return this._data;
|
|
680
|
-
}
|
|
681
|
-
set data(value) {
|
|
682
|
-
this._data = value;
|
|
683
|
-
}
|
|
684
|
-
onDateChange(value) {
|
|
685
|
-
var _a;
|
|
686
|
-
const newDate = new Date(value);
|
|
687
|
-
// Only pass valid date to date picker
|
|
688
|
-
if (!isNaN(newDate.getTime())) {
|
|
689
|
-
(_a = this.dp) === null || _a === void 0 ? void 0 : _a.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, Object.assign(Object.assign({}, this.options), { selectedDate: this.value }), this.datepickerElRef.nativeElement, this.datepickerDialogElRef.nativeElement, this.dateInputElRef.nativeElement, this.datepickerTriggerElRef.nativeElement);
|
|
717
|
-
}
|
|
718
|
-
else {
|
|
719
|
-
throw 'Missing one or more elements...';
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
blurInput() {
|
|
723
|
-
this.onTouchedFn && this.onTouchedFn();
|
|
724
|
-
}
|
|
725
|
-
focusoutDialog(event) {
|
|
726
|
-
var _a;
|
|
727
|
-
if (!((_a = this.datepickerDialogElRef) === null || _a === void 0 ? void 0 : _a.nativeElement.contains(event.relatedTarget))) {
|
|
728
|
-
this.onTouchedFn && this.onTouchedFn();
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
NggDatepickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
733
|
-
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: [
|
|
734
|
-
{
|
|
735
|
-
provide: NG_VALUE_ACCESSOR,
|
|
736
|
-
useExisting: NggDatepickerComponent,
|
|
737
|
-
multi: true,
|
|
738
|
-
},
|
|
739
|
-
], 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 });
|
|
740
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerComponent, decorators: [{
|
|
741
|
-
type: Component,
|
|
742
|
-
args: [{ selector: 'ngg-datepicker', providers: [
|
|
743
|
-
{
|
|
744
|
-
provide: NG_VALUE_ACCESSOR,
|
|
745
|
-
useExisting: NggDatepickerComponent,
|
|
746
|
-
multi: true,
|
|
747
|
-
},
|
|
748
|
-
], 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" }]
|
|
749
|
-
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { options: [{
|
|
750
|
-
type: Input
|
|
751
|
-
}], value: [{
|
|
752
|
-
type: Input
|
|
753
|
-
}], id: [{
|
|
754
|
-
type: Input
|
|
755
|
-
}], label: [{
|
|
756
|
-
type: Input
|
|
757
|
-
}], isValid: [{
|
|
758
|
-
type: Input
|
|
759
|
-
}], valueChange: [{
|
|
760
|
-
type: Output
|
|
761
|
-
}], datepickerDialogElRef: [{
|
|
762
|
-
type: ViewChild,
|
|
763
|
-
args: ['datepickerDialogElRef']
|
|
764
|
-
}], dateInputElRef: [{
|
|
765
|
-
type: ViewChild,
|
|
766
|
-
args: ['dateInputElRef']
|
|
767
|
-
}], datepickerElRef: [{
|
|
768
|
-
type: ViewChild,
|
|
769
|
-
args: ['datepickerElRef']
|
|
770
|
-
}], datepickerTriggerElRef: [{
|
|
771
|
-
type: ViewChild,
|
|
772
|
-
args: ['datepickerTriggerElRef']
|
|
773
|
-
}] } });
|
|
774
|
-
function dateValidator(dates) {
|
|
775
|
-
return (control) => {
|
|
776
|
-
const value = control.value;
|
|
777
|
-
if (!value) {
|
|
778
|
-
return null;
|
|
779
|
-
}
|
|
780
|
-
const newDate = new Date(value);
|
|
781
|
-
const isValidDate = !isNaN(newDate.getTime());
|
|
782
|
-
if (!isValidDate) {
|
|
783
|
-
return { validDate: true };
|
|
784
|
-
}
|
|
785
|
-
const validMinDate = (dates === null || dates === void 0 ? void 0 : dates.min) ? newDate >= startOfDay(dates.min) : true;
|
|
786
|
-
const validMaxDate = (dates === null || dates === void 0 ? void 0 : dates.max) ? newDate <= endOfDay(dates.max) : true;
|
|
787
|
-
if (!validMinDate && (dates === null || dates === void 0 ? void 0 : dates.min)) {
|
|
788
|
-
return {
|
|
789
|
-
validDate: {
|
|
790
|
-
minDate: startOfDay(dates.min),
|
|
791
|
-
actualDate: newDate,
|
|
792
|
-
},
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
if (!validMaxDate && (dates === null || dates === void 0 ? void 0 : dates.max)) {
|
|
796
|
-
return {
|
|
797
|
-
validDate: {
|
|
798
|
-
maxDate: endOfDay(dates.max),
|
|
799
|
-
actualDate: newDate,
|
|
800
|
-
},
|
|
801
|
-
};
|
|
802
|
-
}
|
|
803
|
-
return null;
|
|
804
|
-
};
|
|
805
|
-
}
|
|
806
|
-
|
|
807
737
|
class NggDropdownModule {
|
|
808
738
|
}
|
|
809
739
|
NggDropdownModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDropdownModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
@@ -834,14 +764,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
834
764
|
class NggDatepickerModule {
|
|
835
765
|
}
|
|
836
766
|
NggDatepickerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
837
|
-
NggDatepickerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerModule, declarations: [NggDatepickerComponent], imports: [CommonModule, NggDropdownModule], exports: [NggDatepickerComponent] });
|
|
838
|
-
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] });
|
|
839
769
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerModule, decorators: [{
|
|
840
770
|
type: NgModule,
|
|
841
771
|
args: [{
|
|
842
772
|
declarations: [NggDatepickerComponent],
|
|
843
|
-
imports: [CommonModule, NggDropdownModule],
|
|
773
|
+
imports: [CommonModule, NggDropdownModule, NggCoreWrapperModule],
|
|
844
774
|
exports: [NggDatepickerComponent],
|
|
775
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
845
776
|
}]
|
|
846
777
|
}] });
|
|
847
778
|
|