fis-component 0.0.95 → 0.0.96

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 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":
@@ -71332,13 +71332,26 @@ const FISInputDate = React.forwardRef((props, ref) => {
71332
71332
  setDateValue(parsedDate);
71333
71333
  onChange?.(parsedDate.toDate());
71334
71334
  }
71335
- else {
71336
- // Keep input value but don't update date
71337
- setDateValue(null);
71338
- onChange?.(null);
71335
+ // If invalid format, keep inputValue but don't update dateValue or call onChange
71336
+ // This preserves the old date value like Antd DatePicker
71337
+ };
71338
+ const handleInputBlur = (e) => {
71339
+ // Call original onBlur if provided
71340
+ if (originalOnBlur) {
71341
+ originalOnBlur(e);
71342
+ }
71343
+ // On blur, if input format is invalid, revert to the current date value's formatted string
71344
+ const parsedDate = dayjs(inputValue, finalFormat);
71345
+ if (!parsedDate.isValid() && dateValue) {
71346
+ // Revert to formatted current date value
71347
+ setInputValue(dateValue.format(finalFormat));
71348
+ }
71349
+ else if (!parsedDate.isValid() && !dateValue) {
71350
+ // If no current date and invalid input, clear input
71351
+ setInputValue("");
71339
71352
  }
71340
71353
  };
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({
71354
+ 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
71355
  disabled,
71343
71356
  negative,
71344
71357
  positive,