@apia/components 4.0.73 → 4.0.75

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.
package/dist/index.js CHANGED
@@ -4301,8 +4301,7 @@ class DateInputController {
4301
4301
  }
4302
4302
  }
4303
4303
  onInputChange(ev) {
4304
- if (!this.state.disabled)
4305
- this.setValueFromString(ev.target.value);
4304
+ this.setValueFromString(ev.target.value);
4306
4305
  }
4307
4306
  onCalendarSelect(value) {
4308
4307
  this.setValue(value);
@@ -4347,39 +4346,43 @@ class DateInputController {
4347
4346
  }
4348
4347
  }
4349
4348
  setValueFromString(str, fire = true) {
4350
- if (str === "" || str.replaceAll("_", "9") === getMaskForDateFormat()) {
4351
- this.inputValue = "";
4352
- this.setValue(null, fire);
4353
- } else if (str !== this.inputValue) {
4354
- const hasPlaceHolder = str.match(/_/);
4355
- if (!hasPlaceHolder) {
4356
- const value = dayjs(str, dateFormat);
4357
- const formattedDate = value.format(dateFormat);
4358
- if (value.isValid() && formattedDate === str) {
4359
- this.setValue(value.toDate(), fire);
4349
+ if (!this.state.disabled) {
4350
+ if (str === "" || str.replaceAll("_", "9") === getMaskForDateFormat()) {
4351
+ this.inputValue = "";
4352
+ this.setValue(null, fire);
4353
+ } else if (str !== this.inputValue) {
4354
+ const hasPlaceHolder = str.match(/_/);
4355
+ if (!hasPlaceHolder) {
4356
+ const value = dayjs(str, dateFormat);
4357
+ const formattedDate = value.format(dateFormat);
4358
+ if (value.isValid() && formattedDate === str) {
4359
+ this.setValue(value.toDate(), fire);
4360
+ } else {
4361
+ this.inputValue = str;
4362
+ this.props.onError?.(getLabel("msgInvalidDate").text);
4363
+ this.error = true;
4364
+ }
4360
4365
  } else {
4361
4366
  this.inputValue = str;
4362
- this.props.onError?.(getLabel("msgInvalidDate").text);
4363
- this.error = true;
4364
4367
  }
4365
- } else {
4366
- this.inputValue = str;
4367
4368
  }
4368
4369
  }
4369
4370
  }
4370
4371
  async setValue(date, fire = true) {
4371
- this.error = false;
4372
- if (date !== this.value) {
4373
- const dateValue = dayjs(date);
4374
- const newValue = dateValue.isValid() ? dateValue.format(dateFormat) : "";
4375
- const res = fire ? await this.props.onChange?.(newValue) : null;
4376
- this.inputValue = newValue || "";
4377
- if (typeof res !== "string") {
4378
- this.value = date;
4379
- } else {
4380
- this.error = true;
4381
- this.value = null;
4382
- this.props.onError?.(res);
4372
+ if (!this.state.disabled) {
4373
+ this.error = false;
4374
+ if (date !== this.value) {
4375
+ const dateValue = dayjs(date);
4376
+ const newValue = dateValue.isValid() ? dateValue.format(dateFormat) : "";
4377
+ const res = fire ? await this.props.onChange?.(newValue) : null;
4378
+ this.inputValue = newValue || "";
4379
+ if (typeof res !== "string") {
4380
+ this.value = date;
4381
+ } else {
4382
+ this.error = true;
4383
+ this.value = null;
4384
+ this.props.onError?.(res);
4385
+ }
4383
4386
  }
4384
4387
  }
4385
4388
  }