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

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.
@@ -21,13 +21,13 @@ import { MatColumnDef, MatTableDataSource, MatTable, MatHeaderCellDef, MatHeader
21
21
  import { MatProgressSpinner, MatProgressSpinnerModule } from '@angular/material/progress-spinner';
22
22
  import { MatCard, MatCardContent, MatCardActions, MatCardHeader, MatCardTitle, MatCardModule } from '@angular/material/card';
23
23
  import { MatIcon, MatIconModule } from '@angular/material/icon';
24
- import { MatError, MatFormField, MatInput, MatLabel, MatInputModule } from '@angular/material/input';
24
+ import { MatError, MatFormField, MatInput, MatLabel, MatInputModule, MatSuffix } from '@angular/material/input';
25
25
  import * as i4 from '@ctrl/ngx-codemirror';
26
26
  import { CodemirrorModule, CodemirrorComponent } from '@ctrl/ngx-codemirror';
27
27
  import * as i1$3 from '@angular/forms';
28
- import { NG_VALUE_ACCESSOR, FormsModule, UntypedFormControl, ReactiveFormsModule, Validators } from '@angular/forms';
28
+ import { NG_VALUE_ACCESSOR, FormsModule, UntypedFormControl, ReactiveFormsModule, Validators, FormControl } from '@angular/forms';
29
29
  import { MatProgressBar, MatProgressBarModule } from '@angular/material/progress-bar';
30
- import { MatDatepickerModule } from '@angular/material/datepicker';
30
+ import { MatDatepickerInput, MatDatepickerToggle, MatDatepicker, MatDatepickerModule } from '@angular/material/datepicker';
31
31
  import { NgxMatDatetimePickerModule, NgxMatTimepickerComponent, NgxMatNativeDateModule } from 'ngx-mat-datetime-picker-v2';
32
32
  import * as i1$4 from '@ngx-translate/core';
33
33
  import { TranslateDefaultParser } from '@ngx-translate/core';
@@ -3619,28 +3619,32 @@ class DatetimeComponent {
3619
3619
  this.placeHolder = null;
3620
3620
  this.mode = 'date';
3621
3621
  this.showSeconds = false;
3622
- this.inputValue = '';
3622
+ this.dateControl = new FormControl(null);
3623
+ this.hourControl = new FormControl('00', { nonNullable: true });
3624
+ this.minuteControl = new FormControl('00', { nonNullable: true });
3625
+ this.secondControl = new FormControl('00', { nonNullable: true });
3623
3626
  this.isDisabled = false;
3627
+ this.hours = Array.from({ length: 24 }, (_, value) => value.toString().padStart(2, '0'));
3628
+ this.minutes = Array.from({ length: 60 }, (_, value) => value.toString().padStart(2, '0'));
3629
+ this.seconds = Array.from({ length: 60 }, (_, value) => value.toString().padStart(2, '0'));
3624
3630
  this.onChange = () => { };
3625
3631
  this.onTouched = () => { };
3632
+ this.dateControl.valueChanges.subscribe(() => this.emitCurrentValue());
3633
+ this.hourControl.valueChanges.subscribe(() => this.emitCurrentValue());
3634
+ this.minuteControl.valueChanges.subscribe(() => this.emitCurrentValue());
3635
+ this.secondControl.valueChanges.subscribe(() => this.emitCurrentValue());
3626
3636
  }
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';
3637
+ get isDateTime() {
3638
+ return this.mode === 'datetime';
3635
3639
  }
3636
3640
  get value() {
3637
3641
  return this._value;
3638
3642
  }
3639
3643
  set value(val) {
3640
- this.updateValue(val, true);
3644
+ this.setValueFromOutside(val, true);
3641
3645
  }
3642
3646
  writeValue(obj) {
3643
- this.updateValue(obj, false);
3647
+ this.setValueFromOutside(obj, false);
3644
3648
  }
3645
3649
  registerOnChange(fn) {
3646
3650
  this.onChange = fn;
@@ -3650,33 +3654,52 @@ class DatetimeComponent {
3650
3654
  }
3651
3655
  setDisabledState(isDisabled) {
3652
3656
  this.isDisabled = isDisabled;
3657
+ const action = isDisabled ? 'disable' : 'enable';
3658
+ this.dateControl[action]({ emitEvent: false });
3659
+ this.hourControl[action]({ emitEvent: false });
3660
+ this.minuteControl[action]({ emitEvent: false });
3661
+ this.secondControl[action]({ emitEvent: false });
3653
3662
  }
3654
- onInput(rawValue) {
3655
- this.inputValue = rawValue;
3656
- if (!rawValue) {
3657
- this._value = null;
3658
- this.onChange(null);
3659
- return;
3660
- }
3661
- const parsed = this.parseInputValue(rawValue);
3662
- if (parsed) {
3663
- this._value = parsed;
3664
- this.onChange(parsed);
3665
- }
3663
+ clear() {
3664
+ this._value = null;
3665
+ this.dateControl.setValue(null, { emitEvent: false });
3666
+ this.hourControl.setValue('00', { emitEvent: false });
3667
+ this.minuteControl.setValue('00', { emitEvent: false });
3668
+ this.secondControl.setValue('00', { emitEvent: false });
3669
+ this.onChange(null);
3670
+ this.onTouched();
3666
3671
  }
3667
- onBlur() {
3668
- this.inputValue = this.formatValue(this._value);
3672
+ markTouched() {
3669
3673
  this.onTouched();
3670
3674
  }
3671
- updateValue(value, emit) {
3675
+ setValueFromOutside(value, emit) {
3672
3676
  const normalized = this.normalizeDateValue(value);
3673
3677
  this._value = normalized;
3674
- this.inputValue = this.formatValue(normalized);
3678
+ this.dateControl.setValue(normalized ? new Date(normalized.getTime()) : null, { emitEvent: false });
3679
+ this.hourControl.setValue(normalized ? normalized.getHours().toString().padStart(2, '0') : '00', { emitEvent: false });
3680
+ this.minuteControl.setValue(normalized ? normalized.getMinutes().toString().padStart(2, '0') : '00', { emitEvent: false });
3681
+ this.secondControl.setValue(normalized ? normalized.getSeconds().toString().padStart(2, '0') : '00', { emitEvent: false });
3675
3682
  if (emit) {
3676
3683
  this.onChange(normalized);
3677
3684
  this.onTouched();
3678
3685
  }
3679
3686
  }
3687
+ emitCurrentValue() {
3688
+ const date = this.dateControl.value;
3689
+ if (!date) {
3690
+ this._value = null;
3691
+ this.onChange(null);
3692
+ return;
3693
+ }
3694
+ const next = new Date(date.getTime());
3695
+ next.setHours(this.toNumber(this.hourControl.value), this.toNumber(this.minuteControl.value), this.showSeconds ? this.toNumber(this.secondControl.value) : 0, 0);
3696
+ this._value = next;
3697
+ this.onChange(next);
3698
+ }
3699
+ toNumber(value) {
3700
+ const parsed = Number.parseInt(value ?? '0', 10);
3701
+ return Number.isNaN(parsed) ? 0 : parsed;
3702
+ }
3680
3703
  normalizeDateValue(value) {
3681
3704
  if (value === undefined || value === null || value === '') {
3682
3705
  return null;
@@ -3702,26 +3725,6 @@ class DatetimeComponent {
3702
3725
  }
3703
3726
  return null;
3704
3727
  }
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);
3715
- }
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');
3724
- }
3725
3728
  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 }); }
3726
3729
  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: [
3727
3730
  {
@@ -3729,7 +3732,7 @@ class DatetimeComponent {
3729
3732
  multi: true,
3730
3733
  useExisting: DatetimeComponent
3731
3734
  }
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"] }] }); }
3735
+ ], ngImport: i0, template: "<div class=\"datetime-wrapper\">\n <mat-form-field class=\"date-field\">\n @if (display) {\n <mat-label>{{ display }}</mat-label>\n }\n <input\n matInput\n [matDatepicker]=\"picker\"\n [placeholder]=\"placeHolder\"\n [formControl]=\"dateControl\"\n [disabled]=\"isDisabled\"\n (dateChange)=\"markTouched()\"\n (blur)=\"markTouched()\">\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n </mat-form-field>\n\n @if (isDateTime) {\n <div class=\"time-row\">\n <mat-form-field class=\"time-field\">\n <mat-label>HH</mat-label>\n <mat-select [formControl]=\"hourControl\" [disabled]=\"isDisabled\" (selectionChange)=\"markTouched()\">\n @for (hour of hours; track hour) {\n <mat-option [value]=\"hour\">{{ hour }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <mat-form-field class=\"time-field\">\n <mat-label>MM</mat-label>\n <mat-select [formControl]=\"minuteControl\" [disabled]=\"isDisabled\" (selectionChange)=\"markTouched()\">\n @for (minute of minutes; track minute) {\n <mat-option [value]=\"minute\">{{ minute }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n @if (showSeconds) {\n <mat-form-field class=\"time-field\">\n <mat-label>SS</mat-label>\n <mat-select [formControl]=\"secondControl\" [disabled]=\"isDisabled\" (selectionChange)=\"markTouched()\">\n @for (second of seconds; track second) {\n <mat-option [value]=\"second\">{{ second }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n }\n </div>\n }\n\n <div class=\"actions-row\">\n <button mat-button type=\"button\" (click)=\"clear()\" [disabled]=\"isDisabled\">Clear</button>\n </div>\n</div>\n", styles: [".datetime-wrapper{display:flex;flex-direction:column;gap:8px;width:100%}.date-field,.time-field{width:100%}.time-row{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr))}.actions-row{display:flex;justify-content:flex-end}@media(min-width:720px){.time-row{grid-template-columns:repeat(3,minmax(0,1fr))}}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { 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: "directive", type: i1$3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { 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"] }, { kind: "directive", type: MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { kind: "component", type: MatDatepickerToggle, selector: "mat-datepicker-toggle", inputs: ["for", "tabIndex", "aria-label", "disabled", "disableRipple"], exportAs: ["matDatepickerToggle"] }, { kind: "component", type: MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { kind: "directive", type: MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "component", type: MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "component", type: 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"] }] }); }
3733
3736
  }
3734
3737
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: DatetimeComponent, decorators: [{
3735
3738
  type: Component,
@@ -3739,7 +3742,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImpo
3739
3742
  multi: true,
3740
3743
  useExisting: DatetimeComponent
3741
3744
  }
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"] }]
3745
+ ], imports: [ReactiveFormsModule, MatFormField$1, MatLabel$1, MatInput, MatDatepickerInput, MatDatepickerToggle, MatDatepicker, MatSuffix, MatSelect, MatOption, MatButton], template: "<div class=\"datetime-wrapper\">\n <mat-form-field class=\"date-field\">\n @if (display) {\n <mat-label>{{ display }}</mat-label>\n }\n <input\n matInput\n [matDatepicker]=\"picker\"\n [placeholder]=\"placeHolder\"\n [formControl]=\"dateControl\"\n [disabled]=\"isDisabled\"\n (dateChange)=\"markTouched()\"\n (blur)=\"markTouched()\">\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n <mat-datepicker #picker></mat-datepicker>\n </mat-form-field>\n\n @if (isDateTime) {\n <div class=\"time-row\">\n <mat-form-field class=\"time-field\">\n <mat-label>HH</mat-label>\n <mat-select [formControl]=\"hourControl\" [disabled]=\"isDisabled\" (selectionChange)=\"markTouched()\">\n @for (hour of hours; track hour) {\n <mat-option [value]=\"hour\">{{ hour }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n <mat-form-field class=\"time-field\">\n <mat-label>MM</mat-label>\n <mat-select [formControl]=\"minuteControl\" [disabled]=\"isDisabled\" (selectionChange)=\"markTouched()\">\n @for (minute of minutes; track minute) {\n <mat-option [value]=\"minute\">{{ minute }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n\n @if (showSeconds) {\n <mat-form-field class=\"time-field\">\n <mat-label>SS</mat-label>\n <mat-select [formControl]=\"secondControl\" [disabled]=\"isDisabled\" (selectionChange)=\"markTouched()\">\n @for (second of seconds; track second) {\n <mat-option [value]=\"second\">{{ second }}</mat-option>\n }\n </mat-select>\n </mat-form-field>\n }\n </div>\n }\n\n <div class=\"actions-row\">\n <button mat-button type=\"button\" (click)=\"clear()\" [disabled]=\"isDisabled\">Clear</button>\n </div>\n</div>\n", styles: [".datetime-wrapper{display:flex;flex-direction:column;gap:8px;width:100%}.date-field,.time-field{width:100%}.time-row{display:grid;gap:8px;grid-template-columns:repeat(2,minmax(0,1fr))}.actions-row{display:flex;justify-content:flex-end}@media(min-width:720px){.time-row{grid-template-columns:repeat(3,minmax(0,1fr))}}\n"] }]
3743
3746
  }], ctorParameters: () => [{ type: undefined, decorators: [{
3744
3747
  type: Optional
3745
3748
  }, {