@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 * as i1$1 from '@angular/cdk/a11y';
12
12
  import { A11yModule } from '@angular/cdk/a11y';
@@ -403,6 +403,126 @@ 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 dateFormat() {
424
+ return this.options?.dateFormat ?? 'y-m-d';
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
+ const minDate = this.options?.minDate;
437
+ return minDate ? minDate : new Date(new Date().getFullYear() - 10, 0, 1);
438
+ }
439
+ get max() {
440
+ const maxDate = this.options?.maxDate;
441
+ return maxDate ? maxDate : new Date(new Date().getFullYear() + 10, 0, 1);
442
+ }
443
+ writeValue(value) {
444
+ console.log('writeValue', value);
445
+ this.value = value;
446
+ }
447
+ registerOnChange(fn) {
448
+ this.onChangeFn = fn;
449
+ }
450
+ registerOnTouched(fn) {
451
+ this.onTouchedFn = fn;
452
+ }
453
+ onDateChange(evt) {
454
+ const e = evt;
455
+ this.value = e.detail.value;
456
+ this.valueChange.emit(e.detail.value);
457
+ this.onChangeFn && this.onChangeFn(e.detail.value);
458
+ }
459
+ ngAfterViewInit() {
460
+ this._cdr.detectChanges();
461
+ }
462
+ }
463
+ NggDatepickerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
464
+ 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: [
465
+ {
466
+ provide: NG_VALUE_ACCESSOR,
467
+ useExisting: NggDatepickerComponent,
468
+ multi: true,
469
+ },
470
+ ], 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 });
471
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerComponent, decorators: [{
472
+ type: Component,
473
+ args: [{ selector: 'ngg-datepicker', providers: [
474
+ {
475
+ provide: NG_VALUE_ACCESSOR,
476
+ useExisting: NggDatepickerComponent,
477
+ multi: true,
478
+ },
479
+ ], 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" }]
480
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { options: [{
481
+ type: Input
482
+ }], value: [{
483
+ type: Input
484
+ }], id: [{
485
+ type: Input
486
+ }], label: [{
487
+ type: Input
488
+ }], isValid: [{
489
+ type: Input
490
+ }], valueChange: [{
491
+ type: Output
492
+ }] } });
493
+ function dateValidator(dates) {
494
+ return (control) => {
495
+ const value = control.value;
496
+ if (!value) {
497
+ return null;
498
+ }
499
+ const newDate = new Date(value);
500
+ const isValidDate = !isNaN(newDate.getTime());
501
+ if (!isValidDate) {
502
+ return { validDate: true };
503
+ }
504
+ const validMinDate = dates?.min ? newDate >= startOfDay(dates.min) : true;
505
+ const validMaxDate = dates?.max ? newDate <= endOfDay(dates.max) : true;
506
+ if (!validMinDate && dates?.min) {
507
+ return {
508
+ validDate: {
509
+ minDate: startOfDay(dates.min),
510
+ actualDate: newDate,
511
+ },
512
+ };
513
+ }
514
+ if (!validMaxDate && dates?.max) {
515
+ return {
516
+ validDate: {
517
+ maxDate: endOfDay(dates.max),
518
+ actualDate: newDate,
519
+ },
520
+ };
521
+ }
522
+ return null;
523
+ };
524
+ }
525
+
406
526
  class NggDropdownOptionDirective {
407
527
  constructor(templateRef) {
408
528
  this.templateRef = templateRef;
@@ -461,7 +581,7 @@ class NggDropdownComponent {
461
581
  };
462
582
  this.searchFilterAdapter = (q, o) => {
463
583
  if (this.searchFilter)
464
- return this.searchFilter(q, o.value[this.useValue]);
584
+ return this.searchFilter(q, o.value);
465
585
  else
466
586
  return ((q, o) => o.innerHTML.toLowerCase().includes(q.toLowerCase()))(q, o);
467
587
  };
@@ -551,13 +671,13 @@ class NggDropdownComponent {
551
671
  }
552
672
  }
553
673
  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: [
674
+ 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
675
  {
556
676
  provide: NG_VALUE_ACCESSOR,
557
677
  useExisting: NggDropdownComponent,
558
678
  multi: true,
559
679
  },
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 });
680
+ ], 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
681
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDropdownComponent, decorators: [{
562
682
  type: Component,
563
683
  args: [{ selector: 'ngg-dropdown', providers: [
@@ -566,7 +686,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
566
686
  useExisting: NggDropdownComponent,
567
687
  multi: true,
568
688
  },
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"] }]
689
+ ], 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
690
  }], ctorParameters: function () { return [{ type: i0.Injector, decorators: [{
571
691
  type: Inject,
572
692
  args: [Injector]
@@ -592,6 +712,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
592
712
  type: Input
593
713
  }], searchFilter: [{
594
714
  type: Input
715
+ }], syncPopoverWidth: [{
716
+ type: Input
595
717
  }], fixedPlacement: [{
596
718
  type: Input
597
719
  }], multiSelect: [{
@@ -615,197 +737,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
615
737
  args: ['gdsDropdown', { static: false }]
616
738
  }] } });
617
739
 
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
740
  class NggDropdownModule {
810
741
  }
811
742
  NggDropdownModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDropdownModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -836,14 +767,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
836
767
  class NggDatepickerModule {
837
768
  }
838
769
  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] });
770
+ NggDatepickerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerModule, declarations: [NggDatepickerComponent], imports: [CommonModule, NggDropdownModule, NggCoreWrapperModule], exports: [NggDatepickerComponent] });
771
+ NggDatepickerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerModule, imports: [CommonModule, NggDropdownModule, NggCoreWrapperModule] });
841
772
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NggDatepickerModule, decorators: [{
842
773
  type: NgModule,
843
774
  args: [{
844
775
  declarations: [NggDatepickerComponent],
845
- imports: [CommonModule, NggDropdownModule],
776
+ imports: [CommonModule, NggDropdownModule, NggCoreWrapperModule],
846
777
  exports: [NggDatepickerComponent],
778
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
847
779
  }]
848
780
  }] });
849
781