@gloww/gloww 20.0.0-beta.25 → 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 i1$5 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
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 i2$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,21 +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;
3622
+ this.inputValue = '';
3623
+ this.isDisabled = false;
3627
3624
  this.onChange = () => { };
3628
3625
  this.onTouched = () => { };
3629
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';
3635
+ }
3630
3636
  get value() {
3631
3637
  return this._value;
3632
3638
  }
3633
3639
  set value(val) {
3634
- this.updateValue(val);
3640
+ this.updateValue(val, true);
3635
3641
  }
3636
3642
  writeValue(obj) {
3637
- this._value = this.normalizeDateValue(obj);
3643
+ this.updateValue(obj, false);
3638
3644
  }
3639
3645
  registerOnChange(fn) {
3640
3646
  this.onChange = fn;
@@ -3643,32 +3649,40 @@ class DatetimeComponent {
3643
3649
  this.onTouched = fn;
3644
3650
  }
3645
3651
  setDisabledState(isDisabled) {
3646
- //throw new Error('Method not implemented.');
3652
+ this.isDisabled = isDisabled;
3647
3653
  }
3648
- get resolvedCancelLabel() {
3649
- if (this.cancelLabel) {
3650
- return this.cancelLabel;
3654
+ onInput(rawValue) {
3655
+ this.inputValue = rawValue;
3656
+ if (!rawValue) {
3657
+ this._value = null;
3658
+ this.onChange(null);
3659
+ return;
3651
3660
  }
3652
- return this.isFrenchLocale ? 'Annuler' : 'Cancel';
3653
- }
3654
- get resolvedApplyLabel() {
3655
- if (this.applyLabel) {
3656
- return this.applyLabel;
3661
+ const parsed = this.parseInputValue(rawValue);
3662
+ if (parsed) {
3663
+ this._value = parsed;
3664
+ this.onChange(parsed);
3657
3665
  }
3658
- return 'OK';
3659
3666
  }
3660
- onDateInput(value) {
3661
- this.updateValue(value);
3667
+ onBlur() {
3668
+ this.inputValue = this.formatValue(this._value);
3669
+ this.onTouched();
3662
3670
  }
3663
- onDateChange(value) {
3664
- this.updateValue(value);
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
+ }
3665
3679
  }
3666
3680
  normalizeDateValue(value) {
3667
3681
  if (value === undefined || value === null || value === '') {
3668
3682
  return null;
3669
3683
  }
3670
3684
  if (value instanceof Date) {
3671
- return Number.isNaN(value.getTime()) ? null : value;
3685
+ return Number.isNaN(value.getTime()) ? null : new Date(value.getTime());
3672
3686
  }
3673
3687
  if (moment.isMoment(value)) {
3674
3688
  const date = value.toDate();
@@ -3688,22 +3702,34 @@ class DatetimeComponent {
3688
3702
  }
3689
3703
  return null;
3690
3704
  }
3691
- updateValue(value) {
3692
- this._value = this.normalizeDateValue(value);
3693
- this.onChange(this._value);
3694
- 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);
3695
3715
  }
3696
- get isFrenchLocale() {
3697
- 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');
3698
3724
  }
3699
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 }); }
3700
- 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: [
3701
3727
  {
3702
3728
  provide: NG_VALUE_ACCESSOR,
3703
3729
  multi: true,
3704
3730
  useExisting: DatetimeComponent
3705
3731
  }
3706
- ], 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\" [value]=\"value\" (dateInput)=\"onDateInput($event.value)\" (dateChange)=\"onDateChange($event.value)\">\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\" [value]=\"value\" (dateInput)=\"onDateInput($event.value)\" (dateChange)=\"onDateChange($event.value)\" readonly>\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: "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: i1$5.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: i2$1.NgxMatDatetimepicker, selector: "ngx-mat-datetime-picker", exportAs: ["ngxMatDatetimePicker"] }, { kind: "directive", type: i2$1.NgxMatDatepickerInput, selector: "input[ngxMatDatetimePicker]", inputs: ["ngxMatDatetimePicker", "min", "max", "matDatepickerFilter"], exportAs: ["ngxMatDatepickerInput"] }, { kind: "component", type: i2$1.NgxMatDatepickerActions, selector: "ngx-mat-datepicker-actions, ngx-mat-date-range-picker-actions" }, { kind: "directive", type: i2$1.NgxMatDatepickerCancel, selector: "[ngxMatDatepickerCancel], [ngxMatDateRangePickerCancel]" }, { kind: "directive", type: i2$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"] }] }); }
3707
3733
  }
3708
3734
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: DatetimeComponent, decorators: [{
3709
3735
  type: Component,
@@ -3713,7 +3739,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
3713
3739
  multi: true,
3714
3740
  useExisting: DatetimeComponent
3715
3741
  }
3716
- ], imports: [MatFormField, MatLabel, MatInput, MatDatepickerInput, FormsModule, 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\" [value]=\"value\" (dateInput)=\"onDateInput($event.value)\" (dateChange)=\"onDateChange($event.value)\">\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\" [value]=\"value\" (dateInput)=\"onDateInput($event.value)\" (dateChange)=\"onDateChange($event.value)\" readonly>\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"] }]
3717
3743
  }], ctorParameters: () => [{ type: undefined, decorators: [{
3718
3744
  type: Optional
3719
3745
  }, {
@@ -3731,18 +3757,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
3731
3757
  }], mode: [{
3732
3758
  type: Input,
3733
3759
  args: ['mode']
3734
- }], showSpinners: [{
3735
- type: Input
3736
3760
  }], showSeconds: [{
3737
3761
  type: Input
3738
- }], disableMinute: [{
3739
- type: Input
3740
- }], touchUi: [{
3741
- type: Input
3742
- }], cancelLabel: [{
3743
- type: Input
3744
- }], applyLabel: [{
3745
- type: Input
3746
3762
  }] } });
3747
3763
 
3748
3764
  class CallbackDirective {