@wolkabout/commons 0.2.6 → 0.3.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.
@@ -4749,6 +4749,8 @@ class DateTimeFormFieldComponent {
4749
4749
  timeLabel;
4750
4750
  validators = input(...(ngDevMode ? [undefined, { debugName: "validators" }] : []));
4751
4751
  showErrorInTooltip = input(false, ...(ngDevMode ? [{ debugName: "showErrorInTooltip" }] : []));
4752
+ timezone = input(null, ...(ngDevMode ? [{ debugName: "timezone" }] : []));
4753
+ tenantProperties = inject(TenantPropertiesService);
4752
4754
  formGroup = new FormGroup({
4753
4755
  date: new FormControl(null),
4754
4756
  time: new FormControl(null)
@@ -4775,8 +4777,11 @@ class DateTimeFormFieldComponent {
4775
4777
  writeValue(obj) {
4776
4778
  if (obj) {
4777
4779
  const jsDateValue = obj instanceof Date ? obj : new Date(obj);
4778
- const dateTimeValue = DateTime.fromJSDate(jsDateValue);
4779
- const minutesAndHours = String(jsDateValue.getHours() + ':' + jsDateValue.getMinutes());
4780
+ const zone = this.resolveZone();
4781
+ const dateTimeValue = zone
4782
+ ? DateTime.fromJSDate(jsDateValue).setZone(zone)
4783
+ : DateTime.fromJSDate(jsDateValue);
4784
+ const minutesAndHours = `${String(dateTimeValue.hour).padStart(2, '0')}:${String(dateTimeValue.minute).padStart(2, '0')}`;
4780
4785
  this.formGroup.get('date')?.setValue(dateTimeValue, { emitEvent: false });
4781
4786
  this.formGroup.get('time')?.setValue(minutesAndHours, { emitEvent: false });
4782
4787
  }
@@ -4788,10 +4793,9 @@ class DateTimeFormFieldComponent {
4788
4793
  registerOnChange(fn) {
4789
4794
  combineLatest([this.formGroup.valueChanges, this.timeChange]).pipe(takeUntil(this.destroy$), map(([{ date }, time]) => {
4790
4795
  if (date && time && this.timeRegex.test(time)) {
4791
- const jsDate = date.toJSDate();
4792
- const [hours, minutes] = time.split(':');
4793
- jsDate.setHours(Number(hours), Number(minutes));
4794
- return jsDate;
4796
+ const [hours, minutes] = time.split(':').map(Number);
4797
+ const zone = this.resolveZone();
4798
+ return DateTime.fromObject({ year: date.year, month: date.month, day: date.day, hour: hours, minute: minutes, second: 0, millisecond: 0 }, zone ? { zone } : {}).toJSDate();
4795
4799
  }
4796
4800
  else {
4797
4801
  return null;
@@ -4830,6 +4834,9 @@ class DateTimeFormFieldComponent {
4830
4834
  getTimeErrorTooltip() {
4831
4835
  return this.getTimeErrors().map((error) => this.translate.instant('COMMON.ERROR_VALIDATION_' + error) + '\n').toString();
4832
4836
  }
4837
+ resolveZone() {
4838
+ return this.timezone() ?? this.tenantProperties.timezone ?? null;
4839
+ }
4833
4840
  onInputChange(event) {
4834
4841
  const inputEl = event.target;
4835
4842
  const value = inputEl.value;
@@ -4838,7 +4845,7 @@ class DateTimeFormFieldComponent {
4838
4845
  }
4839
4846
  }
4840
4847
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: DateTimeFormFieldComponent, deps: [{ token: i1$1.TranslateService }], target: i0.ɵɵFactoryTarget.Component });
4841
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.0", type: DateTimeFormFieldComponent, isStandalone: true, selector: "app-date-time-form-field", inputs: { dateLabel: { classPropertyName: "dateLabel", publicName: "dateLabel", isSignal: false, isRequired: false, transformFunction: null }, timeLabel: { classPropertyName: "timeLabel", publicName: "timeLabel", isSignal: false, isRequired: false, transformFunction: null }, validators: { classPropertyName: "validators", publicName: "validators", isSignal: true, isRequired: false, transformFunction: null }, showErrorInTooltip: { classPropertyName: "showErrorInTooltip", publicName: "showErrorInTooltip", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
4848
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.0", type: DateTimeFormFieldComponent, isStandalone: true, selector: "app-date-time-form-field", inputs: { dateLabel: { classPropertyName: "dateLabel", publicName: "dateLabel", isSignal: false, isRequired: false, transformFunction: null }, timeLabel: { classPropertyName: "timeLabel", publicName: "timeLabel", isSignal: false, isRequired: false, transformFunction: null }, validators: { classPropertyName: "validators", publicName: "validators", isSignal: true, isRequired: false, transformFunction: null }, showErrorInTooltip: { classPropertyName: "showErrorInTooltip", publicName: "showErrorInTooltip", isSignal: true, isRequired: false, transformFunction: null }, timezone: { classPropertyName: "timezone", publicName: "timezone", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
4842
4849
  {
4843
4850
  provide: NG_VALUE_ACCESSOR,
4844
4851
  useExisting: forwardRef(() => DateTimeFormFieldComponent),
@@ -4869,7 +4876,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
4869
4876
  type: Input
4870
4877
  }], timeLabel: [{
4871
4878
  type: Input
4872
- }], validators: [{ type: i0.Input, args: [{ isSignal: true, alias: "validators", required: false }] }], showErrorInTooltip: [{ type: i0.Input, args: [{ isSignal: true, alias: "showErrorInTooltip", required: false }] }] } });
4879
+ }], validators: [{ type: i0.Input, args: [{ isSignal: true, alias: "validators", required: false }] }], showErrorInTooltip: [{ type: i0.Input, args: [{ isSignal: true, alias: "showErrorInTooltip", required: false }] }], timezone: [{ type: i0.Input, args: [{ isSignal: true, alias: "timezone", required: false }] }] } });
4873
4880
 
4874
4881
  class DragDropFileUploadComponent {
4875
4882
  controlDir;
@@ -6672,7 +6679,7 @@ class ValueInputDateComponent {
6672
6679
  useExisting: forwardRef(() => ValueInputDateComponent),
6673
6680
  multi: true,
6674
6681
  }
6675
- ], ngImport: i0, template: "<app-date-time-form-field [formControl]=\"formControl\" [validators]=\"validators()\" [showErrorInTooltip]=\"showErrorInTooltip()\" class=\"w-full\"></app-date-time-form-field>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: SharedModule }, { kind: "directive", type: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: DateTimeFormFieldComponent, selector: "app-date-time-form-field", inputs: ["dateLabel", "timeLabel", "validators", "showErrorInTooltip"] }] });
6682
+ ], ngImport: i0, template: "<app-date-time-form-field [formControl]=\"formControl\" [validators]=\"validators()\" [showErrorInTooltip]=\"showErrorInTooltip()\" class=\"w-full\"></app-date-time-form-field>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: SharedModule }, { kind: "directive", type: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: DateTimeFormFieldComponent, selector: "app-date-time-form-field", inputs: ["dateLabel", "timeLabel", "validators", "showErrorInTooltip", "timezone"] }] });
6676
6683
  }
6677
6684
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: ValueInputDateComponent, decorators: [{
6678
6685
  type: Component,