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/cjs/index.js
CHANGED
|
@@ -71279,7 +71279,7 @@ const HiddenDatePickerSC = styled(DatePicker) `
|
|
|
71279
71279
|
`;
|
|
71280
71280
|
|
|
71281
71281
|
const FISInputDate = React.forwardRef((props, ref) => {
|
|
71282
|
-
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;
|
|
71282
|
+
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;
|
|
71283
71283
|
const getDefaultFormat = (pickerMode) => {
|
|
71284
71284
|
switch (pickerMode) {
|
|
71285
71285
|
case "year":
|
|
@@ -71326,19 +71326,42 @@ const FISInputDate = React.forwardRef((props, ref) => {
|
|
|
71326
71326
|
return;
|
|
71327
71327
|
const newInputValue = e.target.value;
|
|
71328
71328
|
setInputValue(newInputValue);
|
|
71329
|
+
// Handle empty input - user wants to clear the date
|
|
71330
|
+
if (newInputValue === "") {
|
|
71331
|
+
setDateValue(null);
|
|
71332
|
+
onChange?.(null);
|
|
71333
|
+
return;
|
|
71334
|
+
}
|
|
71329
71335
|
// Try to parse the input as a date
|
|
71330
71336
|
const parsedDate = dayjs(newInputValue, finalFormat);
|
|
71331
71337
|
if (parsedDate.isValid()) {
|
|
71332
71338
|
setDateValue(parsedDate);
|
|
71333
71339
|
onChange?.(parsedDate.toDate());
|
|
71334
71340
|
}
|
|
71335
|
-
|
|
71336
|
-
|
|
71337
|
-
|
|
71338
|
-
|
|
71341
|
+
// If invalid format, keep inputValue but don't update dateValue or call onChange
|
|
71342
|
+
// This preserves the old date value like Antd DatePicker
|
|
71343
|
+
};
|
|
71344
|
+
const handleInputBlur = (e) => {
|
|
71345
|
+
// Call original onBlur if provided
|
|
71346
|
+
if (originalOnBlur) {
|
|
71347
|
+
originalOnBlur(e);
|
|
71348
|
+
}
|
|
71349
|
+
// Don't revert if input is empty (user intentionally cleared)
|
|
71350
|
+
if (inputValue === "") {
|
|
71351
|
+
return;
|
|
71352
|
+
}
|
|
71353
|
+
// On blur, if input format is invalid, revert to the current date value's formatted string
|
|
71354
|
+
const parsedDate = dayjs(inputValue, finalFormat);
|
|
71355
|
+
if (!parsedDate.isValid() && dateValue) {
|
|
71356
|
+
// Revert to formatted current date value
|
|
71357
|
+
setInputValue(dateValue.format(finalFormat));
|
|
71358
|
+
}
|
|
71359
|
+
else if (!parsedDate.isValid() && !dateValue) {
|
|
71360
|
+
// If no current date and invalid input, clear input
|
|
71361
|
+
setInputValue("");
|
|
71339
71362
|
}
|
|
71340
71363
|
};
|
|
71341
|
-
return (jsxRuntime.jsxs(DivWrapperSC$2, { className: className, children: [(textLabel || iconLabel) && (jsxRuntime.jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxRuntime.jsxs(DivInputWrapperSC$1, { children: [jsxRuntime.jsx(FISInputField, { ...restProps, ref: mergeRef, typeSuffix: "icon", iconSuffix: jsxRuntime.jsx(DateIcon, {}), value: inputValue, negative: negative, disabled: disabled, placeholder: restProps.placeholder, readOnly: inputReadOnly, autoFocus: autoFocus, onFocus: () => setOpen(true), onChange: handleInputChange, onClickSuffix: () => setOpen(true) }), jsxRuntime.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 && (jsxRuntime.jsx(DivHintWrapperSC$1, { children: jsxRuntime.jsx(SpanHintSC$3, { className: classNames({
|
|
71364
|
+
return (jsxRuntime.jsxs(DivWrapperSC$2, { className: className, children: [(textLabel || iconLabel) && (jsxRuntime.jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxRuntime.jsxs(DivInputWrapperSC$1, { children: [jsxRuntime.jsx(FISInputField, { ...restProps, ref: mergeRef, typeSuffix: "icon", iconSuffix: jsxRuntime.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) }), jsxRuntime.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 && (jsxRuntime.jsx(DivHintWrapperSC$1, { children: jsxRuntime.jsx(SpanHintSC$3, { className: classNames({
|
|
71342
71365
|
disabled,
|
|
71343
71366
|
negative,
|
|
71344
71367
|
positive,
|