fis-component 0.0.95 → 0.0.97
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/cjs/index.js +29 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +29 -6
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -71259,7 +71259,7 @@ const HiddenDatePickerSC = styled(DatePicker) `
|
|
|
71259
71259
|
`;
|
|
71260
71260
|
|
|
71261
71261
|
const FISInputDate = forwardRef((props, ref) => {
|
|
71262
|
-
const { className, value, textLabel = "", iconLabel, required, message = "", disabled, negative, positive, format, onClickIconLabel, onChange, getPopupContainer, minDate, maxDate, picker = "date", allowClear = true, showToday = true, showTime = false, autoFocus = false, disabledDate, inputReadOnly = false, ...restProps } = props;
|
|
71262
|
+
const { className, value, textLabel = "", iconLabel, required, message = "", disabled, negative, positive, format, onClickIconLabel, onChange, getPopupContainer, minDate, maxDate, picker = "date", allowClear = true, showToday = true, showTime = false, autoFocus = false, disabledDate, inputReadOnly = false, onBlur: originalOnBlur, ...restProps } = props;
|
|
71263
71263
|
const getDefaultFormat = (pickerMode) => {
|
|
71264
71264
|
switch (pickerMode) {
|
|
71265
71265
|
case "year":
|
|
@@ -71306,19 +71306,42 @@ const FISInputDate = forwardRef((props, ref) => {
|
|
|
71306
71306
|
return;
|
|
71307
71307
|
const newInputValue = e.target.value;
|
|
71308
71308
|
setInputValue(newInputValue);
|
|
71309
|
+
// Handle empty input - user wants to clear the date
|
|
71310
|
+
if (newInputValue === "") {
|
|
71311
|
+
setDateValue(null);
|
|
71312
|
+
onChange?.(null);
|
|
71313
|
+
return;
|
|
71314
|
+
}
|
|
71309
71315
|
// Try to parse the input as a date
|
|
71310
71316
|
const parsedDate = dayjs(newInputValue, finalFormat);
|
|
71311
71317
|
if (parsedDate.isValid()) {
|
|
71312
71318
|
setDateValue(parsedDate);
|
|
71313
71319
|
onChange?.(parsedDate.toDate());
|
|
71314
71320
|
}
|
|
71315
|
-
|
|
71316
|
-
|
|
71317
|
-
|
|
71318
|
-
|
|
71321
|
+
// If invalid format, keep inputValue but don't update dateValue or call onChange
|
|
71322
|
+
// This preserves the old date value like Antd DatePicker
|
|
71323
|
+
};
|
|
71324
|
+
const handleInputBlur = (e) => {
|
|
71325
|
+
// Call original onBlur if provided
|
|
71326
|
+
if (originalOnBlur) {
|
|
71327
|
+
originalOnBlur(e);
|
|
71328
|
+
}
|
|
71329
|
+
// Don't revert if input is empty (user intentionally cleared)
|
|
71330
|
+
if (inputValue === "") {
|
|
71331
|
+
return;
|
|
71332
|
+
}
|
|
71333
|
+
// On blur, if input format is invalid, revert to the current date value's formatted string
|
|
71334
|
+
const parsedDate = dayjs(inputValue, finalFormat);
|
|
71335
|
+
if (!parsedDate.isValid() && dateValue) {
|
|
71336
|
+
// Revert to formatted current date value
|
|
71337
|
+
setInputValue(dateValue.format(finalFormat));
|
|
71338
|
+
}
|
|
71339
|
+
else if (!parsedDate.isValid() && !dateValue) {
|
|
71340
|
+
// If no current date and invalid input, clear input
|
|
71341
|
+
setInputValue("");
|
|
71319
71342
|
}
|
|
71320
71343
|
};
|
|
71321
|
-
return (jsxs(DivWrapperSC$2, { className: className, children: [(textLabel || iconLabel) && (jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxs(DivInputWrapperSC$1, { children: [jsx(FISInputField, { ...restProps, ref: mergeRef, typeSuffix: "icon", iconSuffix: jsx(DateIcon, {}), value: inputValue, negative: negative, disabled: disabled, placeholder: restProps.placeholder, readOnly: inputReadOnly, autoFocus: autoFocus, onFocus: () => setOpen(true), onChange: handleInputChange, onClickSuffix: () => setOpen(true) }), jsx(HiddenDatePickerSC, { open: open, value: dateValue, onChange: (value) => handleChange(value), onOpenChange: handleOpenChange, format: finalFormat, getPopupContainer: getPopupContainer, minDate: minDate, maxDate: maxDate, picker: picker, allowClear: allowClear, showToday: showToday, showTime: showTime, disabledDate: disabledDate })] }), message && (jsx(DivHintWrapperSC$1, { children: jsx(SpanHintSC$3, { className: classNames({
|
|
71344
|
+
return (jsxs(DivWrapperSC$2, { className: className, children: [(textLabel || iconLabel) && (jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxs(DivInputWrapperSC$1, { children: [jsx(FISInputField, { ...restProps, ref: mergeRef, typeSuffix: "icon", iconSuffix: jsx(DateIcon, {}), value: inputValue, negative: negative, disabled: disabled, placeholder: restProps.placeholder, readOnly: inputReadOnly, autoFocus: autoFocus, onFocus: () => setOpen(true), onChange: handleInputChange, onBlur: handleInputBlur, onClickSuffix: () => setOpen(true) }), jsx(HiddenDatePickerSC, { open: open, value: dateValue, onChange: (value) => handleChange(value), onOpenChange: handleOpenChange, format: finalFormat, getPopupContainer: getPopupContainer, minDate: minDate, maxDate: maxDate, picker: picker, allowClear: allowClear, showToday: showToday, showTime: showTime, disabledDate: disabledDate })] }), message && (jsx(DivHintWrapperSC$1, { children: jsx(SpanHintSC$3, { className: classNames({
|
|
71322
71345
|
disabled,
|
|
71323
71346
|
negative,
|
|
71324
71347
|
positive,
|