@sebgroup/green-angular 2.1.3 → 3.0.1

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.
@@ -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, months, years, createDatepicker, calculateDegrees, sliderColors, getSliderTrackBackground, PaginationI18n } from '@sebgroup/extract';
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 { NgControl, NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
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,130 @@ 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 dateFormat() {
427
+ var _a, _b;
428
+ return (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.dateFormat) !== null && _b !== void 0 ? _b : 'y-m-d';
429
+ }
430
+ get value() {
431
+ return this._value;
432
+ }
433
+ set value(newValue) {
434
+ if (newValue !== this._value) {
435
+ this._value = newValue || undefined;
436
+ }
437
+ console.log('value', this._value);
438
+ }
439
+ get min() {
440
+ var _a;
441
+ const minDate = (_a = this.options) === null || _a === void 0 ? void 0 : _a.minDate;
442
+ return minDate ? minDate : new Date(new Date().getFullYear() - 10, 0, 1);
443
+ }
444
+ get max() {
445
+ var _a;
446
+ const maxDate = (_a = this.options) === null || _a === void 0 ? void 0 : _a.maxDate;
447
+ return maxDate ? maxDate : new Date(new Date().getFullYear() + 10, 0, 1);
448
+ }
449
+ writeValue(value) {
450
+ console.log('writeValue', value);
451
+ this.value = value;
452
+ }
453
+ registerOnChange(fn) {
454
+ this.onChangeFn = fn;
455
+ }
456
+ registerOnTouched(fn) {
457
+ this.onTouchedFn = fn;
458
+ }
459
+ onDateChange(evt) {
460
+ const e = evt;
461
+ this.value = e.detail.value;
462
+ this.valueChange.emit(e.detail.value);
463
+ this.onChangeFn && this.onChangeFn(e.detail.value);
464
+ }
465
+ ngAfterViewInit() {
466
+ this._cdr.detectChanges();
467
+ }
468
+ }
469
+ NggDatepickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
470
+ 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: [
471
+ {
472
+ provide: NG_VALUE_ACCESSOR,
473
+ useExisting: NggDatepickerComponent,
474
+ multi: true,
475
+ },
476
+ ], 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 [dateformat]=\"dateFormat\"\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 });
477
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerComponent, decorators: [{
478
+ type: Component,
479
+ args: [{ selector: 'ngg-datepicker', providers: [
480
+ {
481
+ provide: NG_VALUE_ACCESSOR,
482
+ useExisting: NggDatepickerComponent,
483
+ multi: true,
484
+ },
485
+ ], 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 [dateformat]=\"dateFormat\"\n >\n <span slot=\"message\">\n <ng-content select=\"[data-form-info]\"></ng-content>\n </span>\n </gds-datepicker>\n</div>\n" }]
486
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { options: [{
487
+ type: Input
488
+ }], value: [{
489
+ type: Input
490
+ }], id: [{
491
+ type: Input
492
+ }], label: [{
493
+ type: Input
494
+ }], isValid: [{
495
+ type: Input
496
+ }], valueChange: [{
497
+ type: Output
498
+ }] } });
499
+ function dateValidator(dates) {
500
+ return (control) => {
501
+ const value = control.value;
502
+ if (!value) {
503
+ return null;
504
+ }
505
+ const newDate = new Date(value);
506
+ const isValidDate = !isNaN(newDate.getTime());
507
+ if (!isValidDate) {
508
+ return { validDate: true };
509
+ }
510
+ const validMinDate = (dates === null || dates === void 0 ? void 0 : dates.min) ? newDate >= startOfDay(dates.min) : true;
511
+ const validMaxDate = (dates === null || dates === void 0 ? void 0 : dates.max) ? newDate <= endOfDay(dates.max) : true;
512
+ if (!validMinDate && (dates === null || dates === void 0 ? void 0 : dates.min)) {
513
+ return {
514
+ validDate: {
515
+ minDate: startOfDay(dates.min),
516
+ actualDate: newDate,
517
+ },
518
+ };
519
+ }
520
+ if (!validMaxDate && (dates === null || dates === void 0 ? void 0 : dates.max)) {
521
+ return {
522
+ validDate: {
523
+ maxDate: endOfDay(dates.max),
524
+ actualDate: newDate,
525
+ },
526
+ };
527
+ }
528
+ return null;
529
+ };
530
+ }
531
+
408
532
  class NggDropdownOptionDirective {
409
533
  constructor(templateRef) {
410
534
  this.templateRef = templateRef;
@@ -461,7 +585,7 @@ class NggDropdownComponent {
461
585
  };
462
586
  this.searchFilterAdapter = (q, o) => {
463
587
  if (this.searchFilter)
464
- return this.searchFilter(q, o.value[this.useValue]);
588
+ return this.searchFilter(q, o.value);
465
589
  else
466
590
  return ((q, o) => o.innerHTML.toLowerCase().includes(q.toLowerCase()))(q, o);
467
591
  };
@@ -546,13 +670,13 @@ class NggDropdownComponent {
546
670
  }
547
671
  }
548
672
  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: [
673
+ 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
674
  {
551
675
  provide: NG_VALUE_ACCESSOR,
552
676
  useExisting: NggDropdownComponent,
553
677
  multi: true,
554
678
  },
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 });
679
+ ], 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
680
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDropdownComponent, decorators: [{
557
681
  type: Component,
558
682
  args: [{ selector: 'ngg-dropdown', providers: [
@@ -561,7 +685,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
561
685
  useExisting: NggDropdownComponent,
562
686
  multi: true,
563
687
  },
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"] }]
688
+ ], 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
689
  }], ctorParameters: function () {
566
690
  return [{ type: i0.Injector, decorators: [{
567
691
  type: Inject,
@@ -589,6 +713,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
589
713
  type: Input
590
714
  }], searchFilter: [{
591
715
  type: Input
716
+ }], syncPopoverWidth: [{
717
+ type: Input
592
718
  }], fixedPlacement: [{
593
719
  type: Input
594
720
  }], multiSelect: [{
@@ -612,198 +738,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
612
738
  args: ['gdsDropdown', { static: false }]
613
739
  }] } });
614
740
 
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
741
  class NggDropdownModule {
808
742
  }
809
743
  NggDropdownModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDropdownModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -834,14 +768,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
834
768
  class NggDatepickerModule {
835
769
  }
836
770
  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] });
771
+ NggDatepickerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerModule, declarations: [NggDatepickerComponent], imports: [CommonModule, NggDropdownModule, NggCoreWrapperModule], exports: [NggDatepickerComponent] });
772
+ NggDatepickerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerModule, imports: [CommonModule, NggDropdownModule, NggCoreWrapperModule] });
839
773
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerModule, decorators: [{
840
774
  type: NgModule,
841
775
  args: [{
842
776
  declarations: [NggDatepickerComponent],
843
- imports: [CommonModule, NggDropdownModule],
777
+ imports: [CommonModule, NggDropdownModule, NggCoreWrapperModule],
844
778
  exports: [NggDatepickerComponent],
779
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
845
780
  }]
846
781
  }] });
847
782