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/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":
@@ -71312,13 +71312,26 @@ const FISInputDate = forwardRef((props, ref) => {
71312
71312
  setDateValue(parsedDate);
71313
71313
  onChange?.(parsedDate.toDate());
71314
71314
  }
71315
- else {
71316
- // Keep input value but don't update date
71317
- setDateValue(null);
71318
- onChange?.(null);
71315
+ // If invalid format, keep inputValue but don't update dateValue or call onChange
71316
+ // This preserves the old date value like Antd DatePicker
71317
+ };
71318
+ const handleInputBlur = (e) => {
71319
+ // Call original onBlur if provided
71320
+ if (originalOnBlur) {
71321
+ originalOnBlur(e);
71322
+ }
71323
+ // On blur, if input format is invalid, revert to the current date value's formatted string
71324
+ const parsedDate = dayjs(inputValue, finalFormat);
71325
+ if (!parsedDate.isValid() && dateValue) {
71326
+ // Revert to formatted current date value
71327
+ setInputValue(dateValue.format(finalFormat));
71328
+ }
71329
+ else if (!parsedDate.isValid() && !dateValue) {
71330
+ // If no current date and invalid input, clear input
71331
+ setInputValue("");
71319
71332
  }
71320
71333
  };
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({
71334
+ 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
71335
  disabled,
71323
71336
  negative,
71324
71337
  positive,