dolfo-angular 1.243.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),
@@ -2150,6 +2155,8 @@ var InputTextComponent = class InputTextComponent extends BaseFormInput {
2150
2155
  placeHolder = "";
2151
2156
  onFocus = new EventEmitter();
2152
2157
  onBlur = new EventEmitter();
2158
+ onKeyUp = new EventEmitter();
2159
+ onKeyDown = new EventEmitter();
2153
2160
  formInput;
2154
2161
  focus = () => this.formInput.nativeElement.focus();
2155
2162
  ngAfterViewInit() {
@@ -2179,7 +2186,9 @@ var InputTextComponent = class InputTextComponent extends BaseFormInput {
2179
2186
  },
2180
2187
  outputs: {
2181
2188
  onFocus: "onFocus",
2182
- onBlur: "onBlur"
2189
+ onBlur: "onBlur",
2190
+ onKeyUp: "onKeyUp",
2191
+ onKeyDown: "onKeyDown"
2183
2192
  },
2184
2193
  providers: [
2185
2194
  {
@@ -2207,9 +2216,9 @@ var InputTextComponent = class InputTextComponent extends BaseFormInput {
2207
2216
  ngImport: i0,
2208
2217
  template: `<dolfo-input-container>
2209
2218
  @if(type === "textarea"){
2210
- <textarea #formInput [name]="formControlName" [formControl]="input" (focus)="onFocus.emit($event)" (blur)="onBlur.emit($event)" [placeholder]="placeHolder"></textarea>
2219
+ <textarea #formInput [name]="formControlName" [formControl]="input" (focus)="onFocus.emit($event)" (blur)="onBlur.emit($event)" [placeholder]="placeHolder" (keyup)="onKeyUp.emit($event)" (keydown)="onKeyDown.emit($event)"></textarea>
2211
2220
  }@else{
2212
- <input #formInput [name]="formControlName" [type]="type" [formControl]="input" (focus)="onFocus.emit($event)" (blur)="onBlur.emit($event)" [placeholder]="placeHolder" />
2221
+ <input #formInput [name]="formControlName" [type]="type" [formControl]="input" (focus)="onFocus.emit($event)" (blur)="onBlur.emit($event)" [placeholder]="placeHolder" (keyup)="onKeyUp.emit($event)" (keydown)="onKeyDown.emit($event)" />
2213
2222
  }
2214
2223
  </dolfo-input-container>`,
2215
2224
  isInline: true,
@@ -2255,9 +2264,9 @@ i0.ɵɵngDeclareClassMetadata({
2255
2264
  selector: "dolfo-input-text",
2256
2265
  template: `<dolfo-input-container>
2257
2266
  @if(type === "textarea"){
2258
- <textarea #formInput [name]="formControlName" [formControl]="input" (focus)="onFocus.emit($event)" (blur)="onBlur.emit($event)" [placeholder]="placeHolder"></textarea>
2267
+ <textarea #formInput [name]="formControlName" [formControl]="input" (focus)="onFocus.emit($event)" (blur)="onBlur.emit($event)" [placeholder]="placeHolder" (keyup)="onKeyUp.emit($event)" (keydown)="onKeyDown.emit($event)"></textarea>
2259
2268
  }@else{
2260
- <input #formInput [name]="formControlName" [type]="type" [formControl]="input" (focus)="onFocus.emit($event)" (blur)="onBlur.emit($event)" [placeholder]="placeHolder" />
2269
+ <input #formInput [name]="formControlName" [type]="type" [formControl]="input" (focus)="onFocus.emit($event)" (blur)="onBlur.emit($event)" [placeholder]="placeHolder" (keyup)="onKeyUp.emit($event)" (keydown)="onKeyDown.emit($event)" />
2261
2270
  }
2262
2271
  </dolfo-input-container>`,
2263
2272
  providers: [
@@ -2284,6 +2293,8 @@ i0.ɵɵngDeclareClassMetadata({
2284
2293
  placeHolder: [{ type: Input }],
2285
2294
  onFocus: [{ type: Output }],
2286
2295
  onBlur: [{ type: Output }],
2296
+ onKeyUp: [{ type: Output }],
2297
+ onKeyDown: [{ type: Output }],
2287
2298
  formInput: [{
2288
2299
  type: ViewChild,
2289
2300
  args: ["formInput"]
@@ -3132,7 +3143,12 @@ var DialogComponent = class DialogComponent extends Formable {
3132
3143
  type: InputTextComponent,
3133
3144
  selector: "dolfo-input-text",
3134
3145
  inputs: ["type", "placeHolder"],
3135
- outputs: ["onFocus", "onBlur"]
3146
+ outputs: [
3147
+ "onFocus",
3148
+ "onBlur",
3149
+ "onKeyUp",
3150
+ "onKeyDown"
3151
+ ]
3136
3152
  },
3137
3153
  {
3138
3154
  kind: "component",