fis-component 0.1.4 → 0.1.5
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 +17 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/src/components/Input/InputText/index.d.ts +2 -0
- package/dist/esm/index.js +17 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/src/components/Input/InputText/index.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -12,6 +12,8 @@ export interface InputTextProps extends InputFieldProps, Partial<InputLabelProps
|
|
|
12
12
|
onEnter?: (value: string | null) => void;
|
|
13
13
|
/** Handle onKeyDown action */
|
|
14
14
|
onKeyDown?: (event: unknown) => void;
|
|
15
|
+
/** Trim whitespace from value on blur */
|
|
16
|
+
isTrimValue?: boolean;
|
|
15
17
|
}
|
|
16
18
|
declare const FISInputText: React.ForwardRefExoticComponent<InputTextProps & React.RefAttributes<HTMLInputElement>>;
|
|
17
19
|
export default FISInputText;
|
package/dist/esm/index.js
CHANGED
|
@@ -65331,7 +65331,7 @@ function mergeRefs(...refs) {
|
|
|
65331
65331
|
}
|
|
65332
65332
|
|
|
65333
65333
|
const FISInputText = forwardRef((props, ref) => {
|
|
65334
|
-
const { className, typeSuffix, textLabel = "", iconLabel, required, iconPrefix, sizeInput, showCount, message, negative, positive, maxLength = 500, disabled, onChange, onEnter, onKeyDown, onClickIconLabel, onClickSuffix, ...rest } = props;
|
|
65334
|
+
const { className, typeSuffix, textLabel = "", iconLabel, required, iconPrefix, sizeInput, showCount, message, negative, positive, maxLength = 500, disabled, onChange, onEnter, onKeyDown, onClickIconLabel, onClickSuffix, isTrimValue = true, ...rest } = props;
|
|
65335
65335
|
// Internal ref to access DOM element for character count
|
|
65336
65336
|
const internalRef = React__default.useRef(null);
|
|
65337
65337
|
const [internalValue, setInternalValue] = React__default.useState("");
|
|
@@ -65366,7 +65366,22 @@ const FISInputText = forwardRef((props, ref) => {
|
|
|
65366
65366
|
}
|
|
65367
65367
|
}
|
|
65368
65368
|
}, [onEnter]);
|
|
65369
|
-
|
|
65369
|
+
const handleBlur = React__default.useCallback((event) => {
|
|
65370
|
+
if (!isTrimValue) {
|
|
65371
|
+
rest.onBlur?.(event);
|
|
65372
|
+
return;
|
|
65373
|
+
}
|
|
65374
|
+
const trimmedValue = event.target.value.trim();
|
|
65375
|
+
event.target.value = trimmedValue;
|
|
65376
|
+
if (rest.value === undefined) {
|
|
65377
|
+
setInternalValue(trimmedValue);
|
|
65378
|
+
}
|
|
65379
|
+
else {
|
|
65380
|
+
forceUpdate();
|
|
65381
|
+
}
|
|
65382
|
+
rest.onBlur?.(event);
|
|
65383
|
+
}, [isTrimValue, rest.value, rest.onBlur]);
|
|
65384
|
+
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, onBlur: handleBlur, disabled: disabled, negative: negative, maxLength: maxLength, onClickSuffix: onClickSuffix }), (message || showCount) && (jsxs(DivHintWrapperSC$1, { children: [jsx(SpanHintSC$3, { className: classNames({
|
|
65370
65385
|
disabled: disabled,
|
|
65371
65386
|
negative: negative,
|
|
65372
65387
|
positive: positive,
|