@activecollab/components
Version:
ActiveCollab Components
50 lines • 1.52 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import React, { useCallback, useRef } from "react";
import classnames from "classnames";
import { StyledInput, StyledInputWrapper } from "./Styles";
import useForkRef from "../../utils/useForkRef";
export const Input = /*#__PURE__*/React.forwardRef((_ref, ref) => {
let {
className = "",
style,
type = "text",
disabled = false,
size = "regular",
invalid = false,
startAdornment,
endAdornment,
wrapRef,
wrapperClick,
mode = "outlined",
...rest
} = _ref;
const intInputRef = useRef(null);
const handleRef = useForkRef(ref, intInputRef);
const handleWrapperClick = useCallback(() => {
var _intInputRef$current;
(_intInputRef$current = intInputRef.current) == null || _intInputRef$current.focus();
wrapperClick && wrapperClick();
}, [wrapperClick]);
return /*#__PURE__*/React.createElement(StyledInputWrapper, {
$size: size,
$invalid: invalid,
$disabled: disabled,
$mode: mode,
style: style,
className: classnames("c-input-wrapper", className),
onClick: handleWrapperClick,
ref: wrapRef
}, startAdornment, /*#__PURE__*/React.createElement(StyledInput, _extends({
ref: handleRef,
type: type,
$size: size,
disabled: disabled,
className: "c-input",
"aria-invalid": invalid,
$invalid: invalid,
$mode: mode,
"data-form-type": "other"
}, rest)), endAdornment);
});
Input.displayName = "Input";
//# sourceMappingURL=Input.js.map