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/cjs/index.js +47 -28
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +47 -28
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -64945,9 +64945,38 @@ 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;
|
|
64975
|
+
// Internal ref to access DOM element for character count
|
|
64976
|
+
const internalRef = React.useRef(null);
|
|
64950
64977
|
const [internalValue, setInternalValue] = React.useState(rest.value || rest.defaultValue || "");
|
|
64978
|
+
// State to trigger re-render for character count (React Hook Form compatibility)
|
|
64979
|
+
const [, forceUpdate] = React.useReducer((x) => x + 1, 0);
|
|
64951
64980
|
// Sync internal value with controlled value prop
|
|
64952
64981
|
React.useEffect(() => {
|
|
64953
64982
|
if (rest.value !== undefined) {
|
|
@@ -64956,14 +64985,29 @@ const FISInputText = React.forwardRef((props, ref) => {
|
|
|
64956
64985
|
}, [rest.value]);
|
|
64957
64986
|
// Get current value for display (controlled vs uncontrolled)
|
|
64958
64987
|
const getCurrentValue = () => {
|
|
64959
|
-
|
|
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
|
|
64994
|
+
if (rest.value !== undefined) {
|
|
64995
|
+
return rest.value;
|
|
64996
|
+
}
|
|
64997
|
+
// Fallback to internal state for uncontrolled mode
|
|
64998
|
+
return internalValue ?? "";
|
|
64960
64999
|
};
|
|
64961
65000
|
const handleChange = React.useCallback((event) => {
|
|
64962
65001
|
const newValue = event.target.value;
|
|
64963
|
-
//
|
|
65002
|
+
// Update internal state for uncontrolled mode
|
|
64964
65003
|
if (rest.value === undefined) {
|
|
64965
65004
|
setInternalValue(newValue);
|
|
64966
65005
|
}
|
|
65006
|
+
else {
|
|
65007
|
+
// Force re-render only for controlled mode (React Hook Form case)
|
|
65008
|
+
// This ensures character count updates when value prop doesn't change
|
|
65009
|
+
forceUpdate();
|
|
65010
|
+
}
|
|
64967
65011
|
if (onChange) {
|
|
64968
65012
|
onChange(event);
|
|
64969
65013
|
}
|
|
@@ -64977,7 +65021,7 @@ const FISInputText = React.forwardRef((props, ref) => {
|
|
|
64977
65021
|
}
|
|
64978
65022
|
}
|
|
64979
65023
|
}, [onEnter]);
|
|
64980
|
-
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: ref, 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({
|
|
64981
65025
|
disabled: disabled,
|
|
64982
65026
|
negative: negative,
|
|
64983
65027
|
positive: positive,
|
|
@@ -71258,31 +71302,6 @@ const HiddenDatePickerSC = styled(DatePicker) `
|
|
|
71258
71302
|
z-index: -1;
|
|
71259
71303
|
`;
|
|
71260
71304
|
|
|
71261
|
-
/**
|
|
71262
|
-
* A utility function to merge multiple React refs into a single callback function.
|
|
71263
|
-
* This function accepts any number of refs as arguments and returns a callback function.
|
|
71264
|
-
* When the returned callback function is invoked with a DOM element or null,
|
|
71265
|
-
* it updates the current value of each ref accordingly.
|
|
71266
|
-
*
|
|
71267
|
-
* @template T - The type of the DOM element.
|
|
71268
|
-
* @param {...(Ref<T> | undefined)[]} refs - The refs to be merged.
|
|
71269
|
-
* @returns {(el: T | null) => void} - A callback function that updates the current value of each ref.
|
|
71270
|
-
*/
|
|
71271
|
-
function mergeRefs(...refs) {
|
|
71272
|
-
return (el) => {
|
|
71273
|
-
refs.forEach((ref) => {
|
|
71274
|
-
if (!ref)
|
|
71275
|
-
return;
|
|
71276
|
-
if (typeof ref === "function") {
|
|
71277
|
-
ref(el);
|
|
71278
|
-
}
|
|
71279
|
-
else if (typeof ref === "object" && "current" in ref) {
|
|
71280
|
-
ref.current = el;
|
|
71281
|
-
}
|
|
71282
|
-
});
|
|
71283
|
-
};
|
|
71284
|
-
}
|
|
71285
|
-
|
|
71286
71305
|
const FISInputDate = React.forwardRef((props, ref) => {
|
|
71287
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;
|
|
71288
71307
|
const getDefaultFormat = (pickerMode) => {
|