UNPKG

@primer/components

Version:
47 lines (46 loc) 1.66 kB
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import classnames from 'classnames'; import React from 'react'; import UnstyledTextInput from './_UnstyledTextInput'; import TextInputWrapper from './_TextInputWrapper'; // using forwardRef is important so that other components (ex. SelectMenu) can autofocus the input const TextInput = /*#__PURE__*/React.forwardRef(({ icon: IconComponent, block, className, contrast, disabled, sx: sxProp, theme, width: widthProp, minWidth: minWidthProp, maxWidth: maxWidthProp, variant: variantProp, ...inputProps }, ref) => { // this class is necessary to style FilterSearch, plz no touchy! const wrapperClasses = classnames(className, 'TextInput-wrapper'); return /*#__PURE__*/React.createElement(TextInputWrapper, { block: block, className: wrapperClasses, contrast: contrast, disabled: disabled, hasIcon: !!IconComponent, sx: sxProp, theme: theme, width: widthProp, minWidth: minWidthProp, maxWidth: maxWidthProp, variant: variantProp }, IconComponent && /*#__PURE__*/React.createElement(IconComponent, { className: "TextInput-icon" }), /*#__PURE__*/React.createElement(UnstyledTextInput, _extends({ ref: ref, disabled: disabled }, inputProps))); }); TextInput.defaultProps = { type: 'text' }; TextInput.displayName = 'TextInput'; export default TextInput;