fis-component 0.0.85 → 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,9 +64925,38 @@ 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;
64955
+ // Internal ref to access DOM element for character count
64956
+ const internalRef = React__default.useRef(null);
64930
64957
  const [internalValue, setInternalValue] = React__default.useState(rest.value || rest.defaultValue || "");
64958
+ // State to trigger re-render for character count (React Hook Form compatibility)
64959
+ const [, forceUpdate] = React__default.useReducer((x) => x + 1, 0);
64931
64960
  // Sync internal value with controlled value prop
64932
64961
  React__default.useEffect(() => {
64933
64962
  if (rest.value !== undefined) {
@@ -64936,14 +64965,29 @@ const FISInputText = forwardRef((props, ref) => {
64936
64965
  }, [rest.value]);
64937
64966
  // Get current value for display (controlled vs uncontrolled)
64938
64967
  const getCurrentValue = () => {
64939
- return rest.value !== undefined ? rest.value : internalValue;
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
64974
+ if (rest.value !== undefined) {
64975
+ return rest.value;
64976
+ }
64977
+ // Fallback to internal state for uncontrolled mode
64978
+ return internalValue ?? "";
64940
64979
  };
64941
64980
  const handleChange = React__default.useCallback((event) => {
64942
64981
  const newValue = event.target.value;
64943
- // Only update internal state if not controlled
64982
+ // Update internal state for uncontrolled mode
64944
64983
  if (rest.value === undefined) {
64945
64984
  setInternalValue(newValue);
64946
64985
  }
64986
+ else {
64987
+ // Force re-render only for controlled mode (React Hook Form case)
64988
+ // This ensures character count updates when value prop doesn't change
64989
+ forceUpdate();
64990
+ }
64947
64991
  if (onChange) {
64948
64992
  onChange(event);
64949
64993
  }
@@ -64957,7 +65001,7 @@ const FISInputText = forwardRef((props, ref) => {
64957
65001
  }
64958
65002
  }
64959
65003
  }, [onEnter]);
64960
- return (jsxs(DivContainerSC$6, { className: className, children: [(textLabel || iconLabel) && (jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsx(FISInputField, { ...rest, ref: ref, 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({
64961
65005
  disabled: disabled,
64962
65006
  negative: negative,
64963
65007
  positive: positive,
@@ -71238,31 +71282,6 @@ const HiddenDatePickerSC = styled(DatePicker) `
71238
71282
  z-index: -1;
71239
71283
  `;
71240
71284
 
71241
- /**
71242
- * A utility function to merge multiple React refs into a single callback function.
71243
- * This function accepts any number of refs as arguments and returns a callback function.
71244
- * When the returned callback function is invoked with a DOM element or null,
71245
- * it updates the current value of each ref accordingly.
71246
- *
71247
- * @template T - The type of the DOM element.
71248
- * @param {...(Ref<T> | undefined)[]} refs - The refs to be merged.
71249
- * @returns {(el: T | null) => void} - A callback function that updates the current value of each ref.
71250
- */
71251
- function mergeRefs(...refs) {
71252
- return (el) => {
71253
- refs.forEach((ref) => {
71254
- if (!ref)
71255
- return;
71256
- if (typeof ref === "function") {
71257
- ref(el);
71258
- }
71259
- else if (typeof ref === "object" && "current" in ref) {
71260
- ref.current = el;
71261
- }
71262
- });
71263
- };
71264
- }
71265
-
71266
71285
  const FISInputDate = forwardRef((props, ref) => {
71267
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;
71268
71287
  const getDefaultFormat = (pickerMode) => {