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/esm/index.js CHANGED
@@ -64925,11 +64925,35 @@ const FISInputLabel = (props) => {
64925
64925
  };
64926
64926
  FISInputLabel.displayName = "FISInputLabel";
64927
64927
 
64928
+ /**
64929
+ * A utility function to merge multiple React refs into a single callback function.
64930
+ * This function accepts any number of refs as arguments and returns a callback function.
64931
+ * When the returned callback function is invoked with a DOM element or null,
64932
+ * it updates the current value of each ref accordingly.
64933
+ *
64934
+ * @template T - The type of the DOM element.
64935
+ * @param {...(Ref<T> | undefined)[]} refs - The refs to be merged.
64936
+ * @returns {(el: T | null) => void} - A callback function that updates the current value of each ref.
64937
+ */
64938
+ function mergeRefs(...refs) {
64939
+ return (el) => {
64940
+ refs.forEach((ref) => {
64941
+ if (!ref)
64942
+ return;
64943
+ if (typeof ref === "function") {
64944
+ ref(el);
64945
+ }
64946
+ else if (typeof ref === "object" && "current" in ref) {
64947
+ ref.current = el;
64948
+ }
64949
+ });
64950
+ };
64951
+ }
64952
+
64928
64953
  const FISInputText = forwardRef((props, ref) => {
64929
64954
  const { className, typeSuffix, textLabel = "", iconLabel, required, iconPrefix, sizeInput, showCount, message, negative, positive, maxLength = 500, disabled, onChange, onEnter, onKeyDown, onClickIconLabel, onClickSuffix, ...rest } = props;
64930
- // Internal ref to access DOM element when external ref is not provided
64955
+ // Internal ref to access DOM element for character count
64931
64956
  const internalRef = React__default.useRef(null);
64932
- const inputRef = ref || internalRef;
64933
64957
  const [internalValue, setInternalValue] = React__default.useState(rest.value || rest.defaultValue || "");
64934
64958
  // State to trigger re-render for character count (React Hook Form compatibility)
64935
64959
  const [, forceUpdate] = React__default.useReducer((x) => x + 1, 0);
@@ -64941,28 +64965,33 @@ const FISInputText = forwardRef((props, ref) => {
64941
64965
  }, [rest.value]);
64942
64966
  // Get current value for display (controlled vs uncontrolled)
64943
64967
  const getCurrentValue = () => {
64944
- // Controlled mode: use value prop
64968
+ // Always prioritize DOM value for React Hook Form compatibility
64969
+ const domValue = internalRef.current?.value;
64970
+ if (domValue !== undefined) {
64971
+ return domValue;
64972
+ }
64973
+ // Fallback to controlled value prop
64945
64974
  if (rest.value !== undefined) {
64946
64975
  return rest.value;
64947
64976
  }
64948
- // Uncontrolled mode: use internal state, fallback to DOM value for React Hook Form
64949
- return internalValue ?? inputRef.current?.value ?? "";
64977
+ // Fallback to internal state for uncontrolled mode
64978
+ return internalValue ?? "";
64950
64979
  };
64951
64980
  const handleChange = React__default.useCallback((event) => {
64952
64981
  const newValue = event.target.value;
64953
- // Only update internal state if not controlled
64982
+ // Update internal state for uncontrolled mode
64954
64983
  if (rest.value === undefined) {
64955
64984
  setInternalValue(newValue);
64956
64985
  }
64957
64986
  else {
64958
- // Force re-render for character count when using React Hook Form
64959
- // This ensures character count updates even when value prop doesn't change
64987
+ // Force re-render only for controlled mode (React Hook Form case)
64988
+ // This ensures character count updates when value prop doesn't change
64960
64989
  forceUpdate();
64961
64990
  }
64962
64991
  if (onChange) {
64963
64992
  onChange(event);
64964
64993
  }
64965
- }, [onChange, rest.value, forceUpdate]);
64994
+ }, [onChange, rest.value]);
64966
64995
  const handleKeyPress = React__default.useCallback((event) => {
64967
64996
  if (!event)
64968
64997
  return;
@@ -64972,7 +65001,7 @@ const FISInputText = forwardRef((props, ref) => {
64972
65001
  }
64973
65002
  }
64974
65003
  }, [onEnter]);
64975
- return (jsxs(DivContainerSC$6, { className: className, children: [(textLabel || iconLabel) && (jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), 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) && (jsxs(DivHintWrapperSC$1, { children: [jsx(SpanHintSC$3, { className: classNames({
65004
+ return (jsxs(DivContainerSC$6, { className: className, children: [(textLabel || iconLabel) && (jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), 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) && (jsxs(DivHintWrapperSC$1, { children: [jsx(SpanHintSC$3, { className: classNames({
64976
65005
  disabled: disabled,
64977
65006
  negative: negative,
64978
65007
  positive: positive,
@@ -71253,31 +71282,6 @@ const HiddenDatePickerSC = styled(DatePicker) `
71253
71282
  z-index: -1;
71254
71283
  `;
71255
71284
 
71256
- /**
71257
- * A utility function to merge multiple React refs into a single callback function.
71258
- * This function accepts any number of refs as arguments and returns a callback function.
71259
- * When the returned callback function is invoked with a DOM element or null,
71260
- * it updates the current value of each ref accordingly.
71261
- *
71262
- * @template T - The type of the DOM element.
71263
- * @param {...(Ref<T> | undefined)[]} refs - The refs to be merged.
71264
- * @returns {(el: T | null) => void} - A callback function that updates the current value of each ref.
71265
- */
71266
- function mergeRefs(...refs) {
71267
- return (el) => {
71268
- refs.forEach((ref) => {
71269
- if (!ref)
71270
- return;
71271
- if (typeof ref === "function") {
71272
- ref(el);
71273
- }
71274
- else if (typeof ref === "object" && "current" in ref) {
71275
- ref.current = el;
71276
- }
71277
- });
71278
- };
71279
- }
71280
-
71281
71285
  const FISInputDate = forwardRef((props, ref) => {
71282
71286
  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;
71283
71287
  const getDefaultFormat = (pickerMode) => {