@awsui/components-react
Version:
AWS UI is a collection of [React](https://reactjs.org/) components that help create intuitive, responsive, and accessible user experiences for web applications. It is developed by Amazon Web Services (AWS). This work is available under the terms of the [A
39 lines (38 loc) • 2.32 kB
JavaScript
import { __assign, __rest } from "tslib";
import clsx from 'clsx';
import React, { useRef } from 'react';
import { getBaseProps } from '../internal/base-component';
import InternalInput from './internal';
import { useFormFieldContext } from '../internal/context/form-field-context';
import useForwardFocus from '../internal/hooks/forward-focus';
import { useTelemetry } from '../internal/hooks/use-telemetry';
import styles from './styles.css.js';
var Input = React.forwardRef(function (_a, ref) {
var value = _a.value, _b = _a.type, type = _b === void 0 ? 'text' : _b, _c = _a.autoComplete, autoComplete = _c === void 0 ? true : _c, disabled = _a.disabled, readOnly = _a.readOnly, disableBrowserAutocorrect = _a.disableBrowserAutocorrect, onKeyDown = _a.onKeyDown, onKeyUp = _a.onKeyUp, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, ariaRequired = _a.ariaRequired, name = _a.name, placeholder = _a.placeholder, autoFocus = _a.autoFocus, ariaLabel = _a.ariaLabel, rest = __rest(_a, ["value", "type", "autoComplete", "disabled", "readOnly", "disableBrowserAutocorrect", "onKeyDown", "onKeyUp", "onChange", "onBlur", "onFocus", "ariaRequired", "name", "placeholder", "autoFocus", "ariaLabel"]);
useTelemetry('Input');
var baseProps = getBaseProps(rest);
var _d = useFormFieldContext(rest), ariaLabelledby = _d.ariaLabelledby, ariaDescribedby = _d.ariaDescribedby, controlId = _d.controlId, invalid = _d.invalid;
var inputRef = useRef(null);
useForwardFocus(ref, inputRef);
return (React.createElement(InternalInput, __assign({ ref: inputRef }, __assign(__assign({}, baseProps), { autoComplete: autoComplete,
ariaLabel: ariaLabel,
ariaDescribedby: ariaDescribedby,
ariaLabelledby: ariaLabelledby,
ariaRequired: ariaRequired,
autoFocus: autoFocus,
controlId: controlId,
disabled: disabled,
disableBrowserAutocorrect: disableBrowserAutocorrect,
invalid: invalid,
name: name,
onKeyDown: onKeyDown,
onKeyUp: onKeyUp,
onChange: onChange,
onBlur: onBlur,
onFocus: onFocus,
placeholder: placeholder,
readOnly: readOnly,
type: type,
value: value }), { className: clsx(styles.root, baseProps.className) })));
});
export default Input;