dolfo-angular 1.244.0 → 1.245.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.
@@ -4,7 +4,7 @@ import * as i1 from "@angular/forms";
4
4
  import { ControlContainer, FormArray, FormControl, FormGroup, FormGroupDirective, NG_VALIDATORS, NG_VALUE_ACCESSOR, ReactiveFormsModule, Validators } from "@angular/forms";
5
5
  import { BehaviorSubject, catchError, concatAll, delay, distinctUntilChanged, filter, from, fromEvent, map, mergeMap, of, race, tap, throwError, zip } from "rxjs";
6
6
  import * as i2 from "@angular/common";
7
- import { APP_BASE_HREF, CommonModule, DecimalPipe, formatDate } from "@angular/common";
7
+ import { APP_BASE_HREF, CommonModule, DatePipe, DecimalPipe, formatDate } from "@angular/common";
8
8
  import { HttpClient, HttpErrorResponse } from "@angular/common/http";
9
9
  import { BaseRouteReuseStrategy, Router } from "@angular/router";
10
10
  import { DomSanitizer } from "@angular/platform-browser";
@@ -1469,7 +1469,34 @@ var DatepickerComponent = class DatepickerComponent extends BaseFormInput {
1469
1469
  type = "date";
1470
1470
  onFocus = new EventEmitter();
1471
1471
  onBlur = new EventEmitter();
1472
+ currentValue = signal(null, ...ngDevMode ? [{ debugName: "currentValue" }] : /* istanbul ignore next */ []);
1473
+ dp = inject(DatePipe);
1472
1474
  openPicker = () => this.formInput.nativeElement.showPicker();
1475
+ ngOnInit() {
1476
+ super.ngOnInit();
1477
+ this.addSubscription(this.input.valueChanges.subscribe((value) => {
1478
+ if (!value) this.currentValue.set(null);
1479
+ else if (this.type === "date") this.currentValue.set(this.dp.transform(value, "yyyy-MM-dd"));
1480
+ else if (this.type === "datetime") this.currentValue.set(this.dp.transform(value, "yyyy-MM-ddTHH:mm"));
1481
+ else if (this.type === "time") this.currentValue.set(this.dp.transform(value, "HH:mm"));
1482
+ }));
1483
+ }
1484
+ onChangeDate = (e) => {
1485
+ const { value } = e.target;
1486
+ if (!value) this.input.setValue(null);
1487
+ else {
1488
+ let date;
1489
+ if (this.type === "date" || this.type === "datetime") {
1490
+ date = new Date(value);
1491
+ if (this.type === "date") date.setHours(0, 0, 0, 0);
1492
+ } else if (this.type === "time") {
1493
+ const [hours, minutes] = value.split(":");
1494
+ date = /* @__PURE__ */ new Date();
1495
+ date.setHours(Number(hours), Number(minutes), 0, 0);
1496
+ }
1497
+ this.input.setValue(date);
1498
+ }
1499
+ };
1473
1500
  static ɵfac = i0.ɵɵngDeclareFactory({
1474
1501
  minVersion: "12.0.0",
1475
1502
  version: "22.1.0",
@@ -1490,6 +1517,7 @@ var DatepickerComponent = class DatepickerComponent extends BaseFormInput {
1490
1517
  onBlur: "onBlur"
1491
1518
  },
1492
1519
  providers: [
1520
+ DatePipe,
1493
1521
  {
1494
1522
  provide: NG_VALUE_ACCESSOR,
1495
1523
  useExisting: forwardRef(() => DatepickerComponent),
@@ -1514,38 +1542,14 @@ var DatepickerComponent = class DatepickerComponent extends BaseFormInput {
1514
1542
  usesInheritance: true,
1515
1543
  ngImport: i0,
1516
1544
  template: `<dolfo-input-container>
1517
- <input #formInput [type]="type === 'datetime' ? 'datetime-local' : type" [formControl]="input" (focus)="openPicker(); onFocus.emit($event)" (blur)="onBlur.emit($event)" />
1545
+ <input #formInput [type]="type === 'datetime' ? 'datetime-local' : type" [value]="currentValue()" (focus)="openPicker(); onFocus.emit($event)" (blur)="onBlur.emit($event)" (input)="onChangeDate($event)" />
1518
1546
  </dolfo-input-container>`,
1519
1547
  isInline: true,
1520
- dependencies: [
1521
- {
1522
- kind: "directive",
1523
- type: i1.DefaultValueAccessor,
1524
- selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
1525
- },
1526
- {
1527
- kind: "directive",
1528
- type: i1.NgControlStatus,
1529
- selector: "[formControlName],[ngModel],[formControl]"
1530
- },
1531
- {
1532
- kind: "directive",
1533
- type: i1.FormControlDirective,
1534
- selector: "[formControl]",
1535
- inputs: [
1536
- "formControl",
1537
- "disabled",
1538
- "ngModel"
1539
- ],
1540
- outputs: ["ngModelChange"],
1541
- exportAs: ["ngForm"]
1542
- },
1543
- {
1544
- kind: "component",
1545
- type: InputContainerComponent,
1546
- selector: "dolfo-input-container"
1547
- }
1548
- ],
1548
+ dependencies: [{
1549
+ kind: "component",
1550
+ type: InputContainerComponent,
1551
+ selector: "dolfo-input-container"
1552
+ }],
1549
1553
  changeDetection: i0.ChangeDetectionStrategy.OnPush
1550
1554
  });
1551
1555
  };
@@ -1559,10 +1563,11 @@ i0.ɵɵngDeclareClassMetadata({
1559
1563
  args: [{
1560
1564
  selector: "dolfo-datepicker",
1561
1565
  template: `<dolfo-input-container>
1562
- <input #formInput [type]="type === 'datetime' ? 'datetime-local' : type" [formControl]="input" (focus)="openPicker(); onFocus.emit($event)" (blur)="onBlur.emit($event)" />
1566
+ <input #formInput [type]="type === 'datetime' ? 'datetime-local' : type" [value]="currentValue()" (focus)="openPicker(); onFocus.emit($event)" (blur)="onBlur.emit($event)" (input)="onChangeDate($event)" />
1563
1567
  </dolfo-input-container>`,
1564
1568
  standalone: false,
1565
1569
  providers: [
1570
+ DatePipe,
1566
1571
  {
1567
1572
  provide: NG_VALUE_ACCESSOR,
1568
1573
  useExisting: forwardRef(() => DatepickerComponent),