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 +19 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +19 -5
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -64927,13 +64927,27 @@ FISInputLabel.displayName = "FISInputLabel";
|
|
|
64927
64927
|
|
|
64928
64928
|
const FISInputText = forwardRef((props, ref) => {
|
|
64929
64929
|
const { className, typeSuffix, textLabel = "", iconLabel, required, iconPrefix, sizeInput, showCount, message, negative, positive, maxLength = 500, disabled, onChange, onEnter, onKeyDown, onClickIconLabel, onClickSuffix, ...rest } = props;
|
|
64930
|
-
const [internalValue, setInternalValue] = React__default.useState("");
|
|
64930
|
+
const [internalValue, setInternalValue] = React__default.useState(rest.value || rest.defaultValue || "");
|
|
64931
|
+
// Sync internal value with controlled value prop
|
|
64932
|
+
React__default.useEffect(() => {
|
|
64933
|
+
if (rest.value !== undefined) {
|
|
64934
|
+
setInternalValue(rest.value);
|
|
64935
|
+
}
|
|
64936
|
+
}, [rest.value]);
|
|
64937
|
+
// Get current value for display (controlled vs uncontrolled)
|
|
64938
|
+
const getCurrentValue = () => {
|
|
64939
|
+
return rest.value !== undefined ? rest.value : internalValue;
|
|
64940
|
+
};
|
|
64931
64941
|
const handleChange = React__default.useCallback((event) => {
|
|
64932
|
-
|
|
64942
|
+
const newValue = event.target.value;
|
|
64943
|
+
// Only update internal state if not controlled
|
|
64944
|
+
if (rest.value === undefined) {
|
|
64945
|
+
setInternalValue(newValue);
|
|
64946
|
+
}
|
|
64933
64947
|
if (onChange) {
|
|
64934
64948
|
onChange(event);
|
|
64935
64949
|
}
|
|
64936
|
-
}, [onChange]);
|
|
64950
|
+
}, [onChange, rest.value]);
|
|
64937
64951
|
const handleKeyPress = React__default.useCallback((event) => {
|
|
64938
64952
|
if (!event)
|
|
64939
64953
|
return;
|
|
@@ -64948,8 +64962,8 @@ const FISInputText = forwardRef((props, ref) => {
|
|
|
64948
64962
|
negative: negative,
|
|
64949
64963
|
positive: positive,
|
|
64950
64964
|
}), children: message ? message : "" }), showCount && maxLength > 0 && (jsxs(SpanCountSC, { className: classNames({
|
|
64951
|
-
negative:
|
|
64952
|
-
}), children: [
|
|
64965
|
+
negative: getCurrentValue()?.length > maxLength,
|
|
64966
|
+
}), children: [getCurrentValue()?.length, "/", maxLength] }))] }))] }));
|
|
64953
64967
|
});
|
|
64954
64968
|
FISInputText.displayName = "FISInputText";
|
|
64955
64969
|
|