fis-component 0.0.86 → 0.0.87

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
@@ -64945,11 +64945,35 @@ const FISInputLabel = (props) => {
64945
64945
  };
64946
64946
  FISInputLabel.displayName = "FISInputLabel";
64947
64947
 
64948
+ /**
64949
+ * A utility function to merge multiple React refs into a single callback function.
64950
+ * This function accepts any number of refs as arguments and returns a callback function.
64951
+ * When the returned callback function is invoked with a DOM element or null,
64952
+ * it updates the current value of each ref accordingly.
64953
+ *
64954
+ * @template T - The type of the DOM element.
64955
+ * @param {...(Ref<T> | undefined)[]} refs - The refs to be merged.
64956
+ * @returns {(el: T | null) => void} - A callback function that updates the current value of each ref.
64957
+ */
64958
+ function mergeRefs(...refs) {
64959
+ return (el) => {
64960
+ refs.forEach((ref) => {
64961
+ if (!ref)
64962
+ return;
64963
+ if (typeof ref === "function") {
64964
+ ref(el);
64965
+ }
64966
+ else if (typeof ref === "object" && "current" in ref) {
64967
+ ref.current = el;
64968
+ }
64969
+ });
64970
+ };
64971
+ }
64972
+
64948
64973
  const FISInputText = React.forwardRef((props, ref) => {
64949
64974
  const { className, typeSuffix, textLabel = "", iconLabel, required, iconPrefix, sizeInput, showCount, message, negative, positive, maxLength = 500, disabled, onChange, onEnter, onKeyDown, onClickIconLabel, onClickSuffix, ...rest } = props;
64950
- // Internal ref to access DOM element when external ref is not provided
64975
+ // Internal ref to access DOM element for character count
64951
64976
  const internalRef = React.useRef(null);
64952
- const inputRef = ref || internalRef;
64953
64977
  const [internalValue, setInternalValue] = React.useState(rest.value || rest.defaultValue || "");
64954
64978
  // State to trigger re-render for character count (React Hook Form compatibility)
64955
64979
  const [, forceUpdate] = React.useReducer((x) => x + 1, 0);
@@ -64961,28 +64985,33 @@ const FISInputText = React.forwardRef((props, ref) => {
64961
64985
  }, [rest.value]);
64962
64986
  // Get current value for display (controlled vs uncontrolled)
64963
64987
  const getCurrentValue = () => {
64964
- // Controlled mode: use value prop
64988
+ // Always prioritize DOM value for React Hook Form compatibility
64989
+ const domValue = internalRef.current?.value;
64990
+ if (domValue !== undefined) {
64991
+ return domValue;
64992
+ }
64993
+ // Fallback to controlled value prop
64965
64994
  if (rest.value !== undefined) {
64966
64995
  return rest.value;
64967
64996
  }
64968
- // Uncontrolled mode: use internal state, fallback to DOM value for React Hook Form
64969
- return internalValue ?? inputRef.current?.value ?? "";
64997
+ // Fallback to internal state for uncontrolled mode
64998
+ return internalValue ?? "";
64970
64999
  };
64971
65000
  const handleChange = React.useCallback((event) => {
64972
65001
  const newValue = event.target.value;
64973
- // Only update internal state if not controlled
65002
+ // Update internal state for uncontrolled mode
64974
65003
  if (rest.value === undefined) {
64975
65004
  setInternalValue(newValue);
64976
65005
  }
64977
65006
  else {
64978
- // Force re-render for character count when using React Hook Form
64979
- // This ensures character count updates even when value prop doesn't change
65007
+ // Force re-render only for controlled mode (React Hook Form case)
65008
+ // This ensures character count updates when value prop doesn't change
64980
65009
  forceUpdate();
64981
65010
  }
64982
65011
  if (onChange) {
64983
65012
  onChange(event);
64984
65013
  }
64985
- }, [onChange, rest.value, forceUpdate]);
65014
+ }, [onChange, rest.value]);
64986
65015
  const handleKeyPress = React.useCallback((event) => {
64987
65016
  if (!event)
64988
65017
  return;
@@ -64992,7 +65021,7 @@ const FISInputText = React.forwardRef((props, ref) => {
64992
65021
  }
64993
65022
  }
64994
65023
  }, [onEnter]);
64995
- return (jsxRuntime.jsxs(DivContainerSC$6, { className: className, children: [(textLabel || iconLabel) && (jsxRuntime.jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxRuntime.jsx(FISInputField, { ...rest, ref: inputRef, typeSuffix: typeSuffix, sizeInput: sizeInput, iconPrefix: iconPrefix, onKeyPress: handleKeyPress, onChange: handleChange, disabled: disabled, negative: negative, maxLength: maxLength, onClickSuffix: onClickSuffix }), (message || showCount) && (jsxRuntime.jsxs(DivHintWrapperSC$1, { children: [jsxRuntime.jsx(SpanHintSC$3, { className: classNames({
65024
+ return (jsxRuntime.jsxs(DivContainerSC$6, { className: className, children: [(textLabel || iconLabel) && (jsxRuntime.jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxRuntime.jsx(FISInputField, { ...rest, ref: mergeRefs(ref, internalRef), typeSuffix: typeSuffix, sizeInput: sizeInput, iconPrefix: iconPrefix, onKeyPress: handleKeyPress, onChange: handleChange, disabled: disabled, negative: negative, maxLength: maxLength, onClickSuffix: onClickSuffix }), (message || showCount) && (jsxRuntime.jsxs(DivHintWrapperSC$1, { children: [jsxRuntime.jsx(SpanHintSC$3, { className: classNames({
64996
65025
  disabled: disabled,
64997
65026
  negative: negative,
64998
65027
  positive: positive,
@@ -71273,31 +71302,6 @@ const HiddenDatePickerSC = styled(DatePicker) `
71273
71302
  z-index: -1;
71274
71303
  `;
71275
71304
 
71276
- /**
71277
- * A utility function to merge multiple React refs into a single callback function.
71278
- * This function accepts any number of refs as arguments and returns a callback function.
71279
- * When the returned callback function is invoked with a DOM element or null,
71280
- * it updates the current value of each ref accordingly.
71281
- *
71282
- * @template T - The type of the DOM element.
71283
- * @param {...(Ref<T> | undefined)[]} refs - The refs to be merged.
71284
- * @returns {(el: T | null) => void} - A callback function that updates the current value of each ref.
71285
- */
71286
- function mergeRefs(...refs) {
71287
- return (el) => {
71288
- refs.forEach((ref) => {
71289
- if (!ref)
71290
- return;
71291
- if (typeof ref === "function") {
71292
- ref(el);
71293
- }
71294
- else if (typeof ref === "object" && "current" in ref) {
71295
- ref.current = el;
71296
- }
71297
- });
71298
- };
71299
- }
71300
-
71301
71305
  const FISInputDate = React.forwardRef((props, ref) => {
71302
71306
  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;
71303
71307
  const getDefaultFormat = (pickerMode) => {