fis-component 0.0.94 → 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,
@@ -73694,7 +73707,6 @@ const FISSelect = React.forwardRef(({ className, style, size = "md", options, va
73694
73707
  }, [multi, value, multiDisplayText, selectedItems, displayValue]);
73695
73708
  const handleToggle = React.useCallback(() => {
73696
73709
  if (!disabled) {
73697
- console.log("Toggle dropdown"); // Debug log
73698
73710
  setIsOpen((prev) => !prev);
73699
73711
  }
73700
73712
  }, [disabled]);
@@ -73705,30 +73717,18 @@ const FISSelect = React.forwardRef(({ className, style, size = "md", options, va
73705
73717
  }
73706
73718
  }, [multi, onChange, value]);
73707
73719
  const handleMenuChange = React.useCallback((values) => {
73708
- console.log("Starting selection, keeping onBlur blocked"); // Debug log
73709
73720
  if (multi) {
73710
73721
  onChange(values);
73711
- // For multi-select, allow onBlur immediately since dropdown stays open
73712
- setTimeout(() => {
73713
- console.log("Multi-selection complete, allowing onBlur"); // Debug log
73714
- isSelectingRef.current = false;
73715
- }, 50);
73716
73722
  }
73717
73723
  else {
73718
73724
  if (values.length > 0) {
73719
73725
  onChange(values[0]);
73720
73726
  setIsOpen(false);
73721
- // Keep blocking until value is processed
73722
- setTimeout(() => {
73723
- console.log("Single selection complete, allowing onBlur"); // Debug log
73724
- isSelectingRef.current = false;
73725
- }, 150);
73726
73727
  }
73727
73728
  }
73728
73729
  }, [multi, onChange]);
73729
73730
  const handleMenuClick = React.useCallback(() => {
73730
73731
  if (!multi) {
73731
- console.log("Menu click - closing dropdown"); // Debug log
73732
73732
  setIsOpen(false);
73733
73733
  }
73734
73734
  }, [multi]);
@@ -73736,13 +73736,8 @@ const FISSelect = React.forwardRef(({ className, style, size = "md", options, va
73736
73736
  const handleBlur = React.useCallback((event) => {
73737
73737
  // Block onBlur if dropdown is open OR we're in the middle of selection
73738
73738
  if (isOpen || isSelectingRef.current) {
73739
- console.log("Blocking onBlur - dropdown open or selecting:", {
73740
- isOpen,
73741
- isSelecting: isSelectingRef.current,
73742
- }); // Debug log
73743
73739
  return;
73744
73740
  }
73745
- console.log("Allowing onBlur to proceed"); // Debug log
73746
73741
  // Call original onBlur if provided
73747
73742
  if (restProps.onBlur) {
73748
73743
  restProps.onBlur(event);
@@ -73790,7 +73785,6 @@ const FISSelect = React.forwardRef(({ className, style, size = "md", options, va
73790
73785
  !referenceElement.contains(target) &&
73791
73786
  popperElement &&
73792
73787
  !popperElement.contains(target)) {
73793
- console.log("Click outside - closing dropdown"); // Debug log
73794
73788
  setIsOpen(false);
73795
73789
  }
73796
73790
  };
@@ -73803,7 +73797,6 @@ const FISSelect = React.forwardRef(({ className, style, size = "md", options, va
73803
73797
  // When dropdown closes, give time for value to be processed before allowing onBlur
73804
73798
  isSelectingRef.current = true;
73805
73799
  const timer = setTimeout(() => {
73806
- console.log("Dropdown closed delay complete, allowing onBlur"); // Debug log
73807
73800
  isSelectingRef.current = false;
73808
73801
  }, 200);
73809
73802
  return () => clearTimeout(timer);