@apia/components 4.0.75 → 4.0.77
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 +28 -31
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -4301,7 +4301,8 @@ class DateInputController {
|
|
|
4301
4301
|
}
|
|
4302
4302
|
}
|
|
4303
4303
|
onInputChange(ev) {
|
|
4304
|
-
this.
|
|
4304
|
+
if (!this.state.disabled)
|
|
4305
|
+
this.setValueFromString(ev.target.value);
|
|
4305
4306
|
}
|
|
4306
4307
|
onCalendarSelect(value) {
|
|
4307
4308
|
this.setValue(value);
|
|
@@ -4346,43 +4347,39 @@ class DateInputController {
|
|
|
4346
4347
|
}
|
|
4347
4348
|
}
|
|
4348
4349
|
setValueFromString(str, fire = true) {
|
|
4349
|
-
if (
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
this.setValue(value.toDate(), fire);
|
|
4360
|
-
} else {
|
|
4361
|
-
this.inputValue = str;
|
|
4362
|
-
this.props.onError?.(getLabel("msgInvalidDate").text);
|
|
4363
|
-
this.error = true;
|
|
4364
|
-
}
|
|
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);
|
|
4365
4360
|
} else {
|
|
4366
4361
|
this.inputValue = str;
|
|
4362
|
+
this.props.onError?.(getLabel("msgInvalidDate").text);
|
|
4363
|
+
this.error = true;
|
|
4367
4364
|
}
|
|
4365
|
+
} else {
|
|
4366
|
+
this.inputValue = str;
|
|
4368
4367
|
}
|
|
4369
4368
|
}
|
|
4370
4369
|
}
|
|
4371
4370
|
async setValue(date, fire = true) {
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
this.props.onError?.(res);
|
|
4385
|
-
}
|
|
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);
|
|
4386
4383
|
}
|
|
4387
4384
|
}
|
|
4388
4385
|
}
|