fis-component 0.0.84 → 0.0.85

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
@@ -64947,13 +64947,27 @@ FISInputLabel.displayName = "FISInputLabel";
64947
64947
 
64948
64948
  const FISInputText = React.forwardRef((props, ref) => {
64949
64949
  const { className, typeSuffix, textLabel = "", iconLabel, required, iconPrefix, sizeInput, showCount, message, negative, positive, maxLength = 500, disabled, onChange, onEnter, onKeyDown, onClickIconLabel, onClickSuffix, ...rest } = props;
64950
- const [internalValue, setInternalValue] = React.useState("");
64950
+ const [internalValue, setInternalValue] = React.useState(rest.value || rest.defaultValue || "");
64951
+ // Sync internal value with controlled value prop
64952
+ React.useEffect(() => {
64953
+ if (rest.value !== undefined) {
64954
+ setInternalValue(rest.value);
64955
+ }
64956
+ }, [rest.value]);
64957
+ // Get current value for display (controlled vs uncontrolled)
64958
+ const getCurrentValue = () => {
64959
+ return rest.value !== undefined ? rest.value : internalValue;
64960
+ };
64951
64961
  const handleChange = React.useCallback((event) => {
64952
- setInternalValue(event.target.value);
64962
+ const newValue = event.target.value;
64963
+ // Only update internal state if not controlled
64964
+ if (rest.value === undefined) {
64965
+ setInternalValue(newValue);
64966
+ }
64953
64967
  if (onChange) {
64954
64968
  onChange(event);
64955
64969
  }
64956
- }, [onChange]);
64970
+ }, [onChange, rest.value]);
64957
64971
  const handleKeyPress = React.useCallback((event) => {
64958
64972
  if (!event)
64959
64973
  return;
@@ -64968,8 +64982,8 @@ const FISInputText = React.forwardRef((props, ref) => {
64968
64982
  negative: negative,
64969
64983
  positive: positive,
64970
64984
  }), children: message ? message : "" }), showCount && maxLength > 0 && (jsxRuntime.jsxs(SpanCountSC, { className: classNames({
64971
- negative: internalValue?.length > maxLength,
64972
- }), children: [internalValue?.length, "/", maxLength] }))] }))] }));
64985
+ negative: getCurrentValue()?.length > maxLength,
64986
+ }), children: [getCurrentValue()?.length, "/", maxLength] }))] }))] }));
64973
64987
  });
64974
64988
  FISInputText.displayName = "FISInputText";
64975
64989