@gloww/gloww 20.0.0-beta.26 → 20.0.0-beta.27

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.
@@ -10,7 +10,6 @@ import { MAT_DIALOG_DATA, MatDialogTitle, MatDialogContent, MatDialogActions, Ma
10
10
  import { CdkScrollable } from '@angular/cdk/scrolling';
11
11
  import * as i2 from '@angular/router';
12
12
  import { NavigationEnd, RouterLink, RouterModule } from '@angular/router';
13
- import * as i2$1 from '@angular/material/button';
14
13
  import { MatButton, MatButtonModule } from '@angular/material/button';
15
14
  import * as i1$1 from '@angular/platform-browser';
16
15
  import * as i5 from '@kolkov/angular-editor';
@@ -22,15 +21,14 @@ import { MatColumnDef, MatTableDataSource, MatTable, MatHeaderCellDef, MatHeader
22
21
  import { MatProgressSpinner, MatProgressSpinnerModule } from '@angular/material/progress-spinner';
23
22
  import { MatCard, MatCardContent, MatCardActions, MatCardHeader, MatCardTitle, MatCardModule } from '@angular/material/card';
24
23
  import { MatIcon, MatIconModule } from '@angular/material/icon';
25
- import { MatError, MatFormField, MatInput, MatLabel, MatInputModule, MatSuffix } from '@angular/material/input';
24
+ import { MatError, MatFormField, MatInput, MatLabel, MatInputModule } from '@angular/material/input';
26
25
  import * as i4 from '@ctrl/ngx-codemirror';
27
26
  import { CodemirrorModule, CodemirrorComponent } from '@ctrl/ngx-codemirror';
28
27
  import * as i1$3 from '@angular/forms';
29
- import { NG_VALUE_ACCESSOR, FormsModule, UntypedFormControl, ReactiveFormsModule, Validators, FormControl } from '@angular/forms';
28
+ import { NG_VALUE_ACCESSOR, FormsModule, UntypedFormControl, ReactiveFormsModule, Validators } from '@angular/forms';
30
29
  import { MatProgressBar, MatProgressBarModule } from '@angular/material/progress-bar';
31
- import { MatDatepickerInput, MatDatepickerToggle, MatDatepicker, MatDatepickerModule } from '@angular/material/datepicker';
32
- import * as i3$1 from 'ngx-mat-datetime-picker-v2';
33
- import { NgxMatDatetimePickerModule, NgxMatNativeDateModule, NgxMatTimepickerComponent } from 'ngx-mat-datetime-picker-v2';
30
+ import { MatDatepickerModule } from '@angular/material/datepicker';
31
+ import { NgxMatDatetimePickerModule, NgxMatTimepickerComponent, NgxMatNativeDateModule } from 'ngx-mat-datetime-picker-v2';
34
32
  import * as i1$4 from '@ngx-translate/core';
35
33
  import { TranslateDefaultParser } from '@ngx-translate/core';
36
34
  import { MatSelect, MatOption, MatSelectModule } from '@angular/material/select';
@@ -41,7 +39,7 @@ import * as parserTypescript from 'prettier/plugins/typescript';
41
39
  import * as parserBabel from 'prettier/plugins/babel';
42
40
  import { MatToolbarModule } from '@angular/material/toolbar';
43
41
  import { MatSidenavModule } from '@angular/material/sidenav';
44
- import { MatFormFieldModule } from '@angular/material/form-field';
42
+ import { MatFormFieldModule, MatFormField as MatFormField$1, MatLabel as MatLabel$1 } from '@angular/material/form-field';
45
43
  import { jwtDecode } from 'jwt-decode';
46
44
  import { CdkDrag, CdkDragHandle, DragDropModule } from '@angular/cdk/drag-drop';
47
45
  import FileSaver from 'file-saver';
@@ -3620,32 +3618,29 @@ class DatetimeComponent {
3620
3618
  this.display = null;
3621
3619
  this.placeHolder = null;
3622
3620
  this.mode = 'date';
3623
- this.showSpinners = true;
3624
3621
  this.showSeconds = false;
3625
- this.disableMinute = false;
3626
- this.touchUi = false;
3627
- this.dateControl = new FormControl(null);
3622
+ this.inputValue = '';
3623
+ this.isDisabled = false;
3628
3624
  this.onChange = () => { };
3629
3625
  this.onTouched = () => { };
3630
- this.dateControl.valueChanges.subscribe(value => {
3631
- const normalized = this.normalizeDateValue(value);
3632
- if (value !== normalized) {
3633
- this.dateControl.setValue(normalized, { emitEvent: false });
3634
- }
3635
- this._value = normalized;
3636
- this.onChange(normalized);
3637
- });
3626
+ }
3627
+ get inputType() {
3628
+ return this.mode === 'datetime' ? 'datetime-local' : 'date';
3629
+ }
3630
+ get inputStep() {
3631
+ if (this.mode !== 'datetime') {
3632
+ return null;
3633
+ }
3634
+ return this.showSeconds ? '1' : '60';
3638
3635
  }
3639
3636
  get value() {
3640
3637
  return this._value;
3641
3638
  }
3642
3639
  set value(val) {
3643
- this.updateValue(val);
3640
+ this.updateValue(val, true);
3644
3641
  }
3645
3642
  writeValue(obj) {
3646
- const normalized = this.normalizeDateValue(obj);
3647
- this._value = normalized;
3648
- this.dateControl.setValue(normalized, { emitEvent: false });
3643
+ this.updateValue(obj, false);
3649
3644
  }
3650
3645
  registerOnChange(fn) {
3651
3646
  this.onChange = fn;
@@ -3654,37 +3649,40 @@ class DatetimeComponent {
3654
3649
  this.onTouched = fn;
3655
3650
  }
3656
3651
  setDisabledState(isDisabled) {
3657
- if (isDisabled) {
3658
- this.dateControl.disable({ emitEvent: false });
3659
- }
3660
- else {
3661
- this.dateControl.enable({ emitEvent: false });
3662
- }
3652
+ this.isDisabled = isDisabled;
3663
3653
  }
3664
- get resolvedCancelLabel() {
3665
- if (this.cancelLabel) {
3666
- return this.cancelLabel;
3654
+ onInput(rawValue) {
3655
+ this.inputValue = rawValue;
3656
+ if (!rawValue) {
3657
+ this._value = null;
3658
+ this.onChange(null);
3659
+ return;
3667
3660
  }
3668
- return this.isFrenchLocale ? 'Annuler' : 'Cancel';
3669
- }
3670
- get resolvedApplyLabel() {
3671
- if (this.applyLabel) {
3672
- return this.applyLabel;
3661
+ const parsed = this.parseInputValue(rawValue);
3662
+ if (parsed) {
3663
+ this._value = parsed;
3664
+ this.onChange(parsed);
3673
3665
  }
3674
- return 'OK';
3675
3666
  }
3676
- onDateInput() {
3677
- this.markTouched();
3667
+ onBlur() {
3668
+ this.inputValue = this.formatValue(this._value);
3669
+ this.onTouched();
3678
3670
  }
3679
- onDateChange() {
3680
- this.markTouched();
3671
+ updateValue(value, emit) {
3672
+ const normalized = this.normalizeDateValue(value);
3673
+ this._value = normalized;
3674
+ this.inputValue = this.formatValue(normalized);
3675
+ if (emit) {
3676
+ this.onChange(normalized);
3677
+ this.onTouched();
3678
+ }
3681
3679
  }
3682
3680
  normalizeDateValue(value) {
3683
3681
  if (value === undefined || value === null || value === '') {
3684
3682
  return null;
3685
3683
  }
3686
3684
  if (value instanceof Date) {
3687
- return Number.isNaN(value.getTime()) ? null : value;
3685
+ return Number.isNaN(value.getTime()) ? null : new Date(value.getTime());
3688
3686
  }
3689
3687
  if (moment.isMoment(value)) {
3690
3688
  const date = value.toDate();
@@ -3704,27 +3702,34 @@ class DatetimeComponent {
3704
3702
  }
3705
3703
  return null;
3706
3704
  }
3707
- updateValue(value) {
3708
- const normalized = this.normalizeDateValue(value);
3709
- this._value = normalized;
3710
- this.dateControl.setValue(normalized, { emitEvent: false });
3711
- this.onChange(normalized);
3712
- this.markTouched();
3713
- }
3714
- markTouched() {
3715
- this.onTouched();
3705
+ parseInputValue(rawValue) {
3706
+ if (!rawValue) {
3707
+ return null;
3708
+ }
3709
+ if (this.mode === 'date') {
3710
+ const parsed = moment(rawValue, ['YYYY-MM-DD', 'DD/MM/YYYY', 'MM/DD/YYYY'], true);
3711
+ return parsed.isValid() ? parsed.toDate() : this.normalizeDateValue(rawValue);
3712
+ }
3713
+ const parsed = moment(rawValue, ['YYYY-MM-DDTHH:mm:ss', 'YYYY-MM-DDTHH:mm', ...DatetimeComponent.DATE_FORMATS], true);
3714
+ return parsed.isValid() ? parsed.toDate() : this.normalizeDateValue(rawValue);
3716
3715
  }
3717
- get isFrenchLocale() {
3718
- return (this.locale ?? '').toLowerCase().startsWith('fr');
3716
+ formatValue(value) {
3717
+ if (!value) {
3718
+ return '';
3719
+ }
3720
+ if (this.mode === 'date') {
3721
+ return moment(value).format('YYYY-MM-DD');
3722
+ }
3723
+ return moment(value).format(this.showSeconds ? 'YYYY-MM-DDTHH:mm:ss' : 'YYYY-MM-DDTHH:mm');
3719
3724
  }
3720
3725
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: DatetimeComponent, deps: [{ token: MAT_DATE_LOCALE, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
3721
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.18", type: DatetimeComponent, isStandalone: true, selector: "gloww-datetime", inputs: { _value: ["value", "_value"], display: "display", placeHolder: "placeHolder", mode: "mode", showSpinners: "showSpinners", showSeconds: "showSeconds", disableMinute: "disableMinute", touchUi: "touchUi", cancelLabel: "cancelLabel", applyLabel: "applyLabel" }, providers: [
3726
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.18", type: DatetimeComponent, isStandalone: true, selector: "gloww-datetime", inputs: { _value: ["value", "_value"], display: "display", placeHolder: "placeHolder", mode: "mode", showSeconds: "showSeconds" }, providers: [
3722
3727
  {
3723
3728
  provide: NG_VALUE_ACCESSOR,
3724
3729
  multi: true,
3725
3730
  useExisting: DatetimeComponent
3726
3731
  }
3727
- ], ngImport: i0, template: "<div style=\"width:100%\">\n @if (mode==='date') {\n <mat-form-field>\n <mat-label>{{display}}</mat-label>\n <input matInput [matDatepicker]=\"picker\" [placeholder]=\"placeHolder\" [formControl]=\"dateControl\" (dateInput)=\"onDateInput()\" (dateChange)=\"onDateChange()\" (blur)=\"markTouched()\">\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n </mat-form-field>\n }\n\n @if (mode==='datetime') {\n <mat-form-field>\n <mat-label>{{display}}</mat-label>\n <input matInput [ngxMatDatetimePicker]=\"pickerDT\" [placeholder]=\"placeHolder\" [formControl]=\"dateControl\" (dateInput)=\"onDateInput()\" (dateChange)=\"onDateChange()\" (blur)=\"markTouched()\">\n <mat-datepicker-toggle matSuffix [for]=\"$any(pickerDT)\"></mat-datepicker-toggle>\n <ngx-mat-datetime-picker #pickerDT [showSpinners]=\"showSpinners\" [showSeconds]=\"showSeconds\" [touchUi]=\"touchUi\" [disableMinute]=\"disableMinute\">\n <ngx-mat-datepicker-actions>\n <button mat-button ngxMatDatepickerCancel>{{ resolvedCancelLabel }}</button>\n <button mat-raised-button color=\"primary\" ngxMatDatepickerApply>{{ resolvedApplyLabel }}</button>\n </ngx-mat-datepicker-actions>\n </ngx-mat-datetime-picker>\n </mat-form-field>\n }\n</div>\n", styles: [""], dependencies: [{ kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: MatLabel, selector: "mat-label" }, { kind: "directive", type: MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "directive", type: MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { kind: "directive", type: MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "component", type: MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2$1.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: NgxMatDatetimePickerModule }, { kind: "component", type: i3$1.NgxMatDatetimepicker, selector: "ngx-mat-datetime-picker", exportAs: ["ngxMatDatetimePicker"] }, { kind: "directive", type: i3$1.NgxMatDatepickerInput, selector: "input[ngxMatDatetimePicker]", inputs: ["ngxMatDatetimePicker", "min", "max", "matDatepickerFilter"], exportAs: ["ngxMatDatepickerInput"] }, { kind: "component", type: i3$1.NgxMatDatepickerActions, selector: "ngx-mat-datepicker-actions, ngx-mat-date-range-picker-actions" }, { kind: "directive", type: i3$1.NgxMatDatepickerCancel, selector: "[ngxMatDatepickerCancel], [ngxMatDateRangePickerCancel]" }, { kind: "directive", type: i3$1.NgxMatDatepickerApply, selector: "[ngxMatDatepickerApply], [ngxMatDateRangePickerApply]" }, { kind: "ngmodule", type: NgxMatNativeDateModule }] }); }
3732
+ ], ngImport: i0, template: "<div class=\"datetime-wrapper\">\n <mat-form-field>\n @if (display) {\n <mat-label>{{ display }}</mat-label>\n }\n <input\n matInput\n [type]=\"inputType\"\n [step]=\"inputStep\"\n [placeholder]=\"placeHolder\"\n [value]=\"inputValue\"\n [disabled]=\"isDisabled\"\n (input)=\"onInput($any($event.target).value)\"\n (change)=\"onInput($any($event.target).value)\"\n (blur)=\"onBlur()\">\n </mat-form-field>\n</div>\n", styles: [".datetime-wrapper,mat-form-field{width:100%}\n"], dependencies: [{ kind: "component", type: MatFormField$1, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: MatLabel$1, selector: "mat-label" }, { kind: "directive", type: MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }] }); }
3728
3733
  }
3729
3734
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: DatetimeComponent, decorators: [{
3730
3735
  type: Component,
@@ -3734,7 +3739,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
3734
3739
  multi: true,
3735
3740
  useExisting: DatetimeComponent
3736
3741
  }
3737
- ], imports: [MatFormField, MatLabel, MatInput, MatDatepickerInput, FormsModule, ReactiveFormsModule, MatDatepickerToggle, MatSuffix, MatDatepicker, MatButtonModule, NgxMatDatetimePickerModule, NgxMatNativeDateModule], template: "<div style=\"width:100%\">\n @if (mode==='date') {\n <mat-form-field>\n <mat-label>{{display}}</mat-label>\n <input matInput [matDatepicker]=\"picker\" [placeholder]=\"placeHolder\" [formControl]=\"dateControl\" (dateInput)=\"onDateInput()\" (dateChange)=\"onDateChange()\" (blur)=\"markTouched()\">\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n </mat-form-field>\n }\n\n @if (mode==='datetime') {\n <mat-form-field>\n <mat-label>{{display}}</mat-label>\n <input matInput [ngxMatDatetimePicker]=\"pickerDT\" [placeholder]=\"placeHolder\" [formControl]=\"dateControl\" (dateInput)=\"onDateInput()\" (dateChange)=\"onDateChange()\" (blur)=\"markTouched()\">\n <mat-datepicker-toggle matSuffix [for]=\"$any(pickerDT)\"></mat-datepicker-toggle>\n <ngx-mat-datetime-picker #pickerDT [showSpinners]=\"showSpinners\" [showSeconds]=\"showSeconds\" [touchUi]=\"touchUi\" [disableMinute]=\"disableMinute\">\n <ngx-mat-datepicker-actions>\n <button mat-button ngxMatDatepickerCancel>{{ resolvedCancelLabel }}</button>\n <button mat-raised-button color=\"primary\" ngxMatDatepickerApply>{{ resolvedApplyLabel }}</button>\n </ngx-mat-datepicker-actions>\n </ngx-mat-datetime-picker>\n </mat-form-field>\n }\n</div>\n" }]
3742
+ ], imports: [MatFormField$1, MatLabel$1, MatInput], template: "<div class=\"datetime-wrapper\">\n <mat-form-field>\n @if (display) {\n <mat-label>{{ display }}</mat-label>\n }\n <input\n matInput\n [type]=\"inputType\"\n [step]=\"inputStep\"\n [placeholder]=\"placeHolder\"\n [value]=\"inputValue\"\n [disabled]=\"isDisabled\"\n (input)=\"onInput($any($event.target).value)\"\n (change)=\"onInput($any($event.target).value)\"\n (blur)=\"onBlur()\">\n </mat-form-field>\n</div>\n", styles: [".datetime-wrapper,mat-form-field{width:100%}\n"] }]
3738
3743
  }], ctorParameters: () => [{ type: undefined, decorators: [{
3739
3744
  type: Optional
3740
3745
  }, {
@@ -3752,18 +3757,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
3752
3757
  }], mode: [{
3753
3758
  type: Input,
3754
3759
  args: ['mode']
3755
- }], showSpinners: [{
3756
- type: Input
3757
3760
  }], showSeconds: [{
3758
3761
  type: Input
3759
- }], disableMinute: [{
3760
- type: Input
3761
- }], touchUi: [{
3762
- type: Input
3763
- }], cancelLabel: [{
3764
- type: Input
3765
- }], applyLabel: [{
3766
- type: Input
3767
3762
  }] } });
3768
3763
 
3769
3764
  class CallbackDirective {