@activecollab/components
Version:
ActiveCollab Components
52 lines • 1.84 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["className", "style", "type", "disabled", "size", "invalid", "startAdornment", "endAdornment", "wrapRef", "wrapperClick", "mode"];
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"
} = _ref,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
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