ngx-ode-ui 4.7.0 → 4.7.2

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.
@@ -7,7 +7,7 @@ import { NG_VALUE_ACCESSOR, NgModel, FormsModule } from '@angular/forms';
7
7
  import Flatpickr from 'flatpickr';
8
8
  import French from 'flatpickr/dist/l10n/fr.js';
9
9
  import * as i1 from '@angular/common';
10
- import { CommonModule, DatePipe } from '@angular/common';
10
+ import { CommonModule, getLocaleId, DatePipe } from '@angular/common';
11
11
  import * as i2$1 from 'ngx-ode-sijil';
12
12
  import { NgxOdeSijilModule } from 'ngx-ode-sijil';
13
13
  import * as i2$2 from 'ngx-infinite-scroll';
@@ -202,6 +202,8 @@ class DatepickerComponent extends OdeComponent {
202
202
  this.changeDate = new EventEmitter();
203
203
  this.onChangeCallback = NOOP;
204
204
  this.onTouchedCallback = NOOP;
205
+ this.onInputChangeObserver = null;
206
+ this.debounceTimer = null;
205
207
  }
206
208
  get value() {
207
209
  return this.innerValue;
@@ -250,23 +252,37 @@ class DatepickerComponent extends OdeComponent {
250
252
  altInput: !this.disabled,
251
253
  altFormat: 'd/m/Y',
252
254
  dateFormat: 'Y-m-d',
253
- allowInput: false,
255
+ allowInput: true,
254
256
  enableTime: this.enableTime,
255
257
  minDate: this.minDate,
256
258
  maxDate: this.maxDate,
257
259
  clickOpens: false,
258
260
  wrap: true,
259
- locale: datePickerLocale
261
+ locale: datePickerLocale,
262
+ onChange: (selectedDates, dateStr) => {
263
+ this.value = dateStr;
264
+ },
265
+ onClose: () => {
266
+ this.onTouchedCallback();
267
+ }
260
268
  };
261
269
  this.datePickerInst = new Flatpickr(this.datePickerElement.nativeElement, options);
262
270
  if (!this.disabled) {
271
+ // Add click handler for the alt input
263
272
  this.datePickerInst.altInput.addEventListener('click', e => {
264
273
  if (!this.readonly) {
265
274
  this.datePickerInst.toggle();
266
275
  }
267
276
  });
277
+ // Add blur handler for manual entry
278
+ this.datePickerInst.altInput.addEventListener('blur', e => {
279
+ const inputDate = this.datePickerInst.parseDate(this.datePickerInst.altInput.value, options.altFormat);
280
+ if (inputDate) {
281
+ this.datePickerInst.setDate(inputDate, true);
282
+ }
283
+ });
268
284
  }
269
- // Force updating the date input readonly attribute :
285
+ // Force updating the date input readonly attribute
270
286
  this.readonly = this._readonly;
271
287
  }
272
288
  ngOnDestroy() {
@@ -2645,8 +2661,21 @@ class LocalizedDatePipe {
2645
2661
  constructor(bundlesService) {
2646
2662
  this.bundlesService = bundlesService;
2647
2663
  }
2648
- transform(value, pattern = 'mediumDate') {
2649
- const datePipe = new DatePipe(this.bundlesService.currentLanguage);
2664
+ transform(value, pattern = "mediumDate") {
2665
+ let targetLanguage = this.bundlesService.currentLanguage || "en";
2666
+ try {
2667
+ // If targetLanguage and angular current locale are different, fall back angular locale to "en"
2668
+ if (getLocaleId(targetLanguage) !== targetLanguage) {
2669
+ targetLanguage = "en";
2670
+ }
2671
+ }
2672
+ catch (e) {
2673
+ // getLocaleId(targetLanguage) can throw an error when locale is not recognized
2674
+ // In such a case, fall back to "en"
2675
+ targetLanguage = "en";
2676
+ }
2677
+ // Use angular locale formatting for localized dates
2678
+ const datePipe = new DatePipe(targetLanguage);
2650
2679
  return datePipe.transform(value, pattern);
2651
2680
  }
2652
2681
  }