UNPKG

2.22 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
5exports.__esModule = true;
6exports["default"] = void 0;
7
8var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
10var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
12var _core = require("@emotion/core");
13
14var _react = require("react");
15
16var _FormControl = require("../FormControl");
17
18var _PseudoBox = _interopRequireDefault(require("../PseudoBox"));
19
20var _styles = _interopRequireDefault(require("./styles"));
21
22/** @jsx jsx */
23var Input = (0, _react.forwardRef)(function (props, ref) {
24 var size = props.size,
25 variant = props.variant,
26 as = props.as,
27 ariaLabel = props["aria-label"],
28 ariaDescribedby = props["aria-describedby"],
29 isReadOnly = props.isReadOnly,
30 isFullWidth = props.isFullWidth,
31 isDisabled = props.isDisabled,
32 isInvalid = props.isInvalid,
33 isRequired = props.isRequired,
34 focusBorderColor = props.focusBorderColor,
35 errorBorderColor = props.errorBorderColor,
36 rest = (0, _objectWithoutPropertiesLoose2["default"])(props, ["size", "variant", "as", "aria-label", "aria-describedby", "isReadOnly", "isFullWidth", "isDisabled", "isInvalid", "isRequired", "focusBorderColor", "errorBorderColor"]);
37 var inputStyleProps = (0, _styles["default"])(props);
38 var formControl = (0, _FormControl.useFormControl)(props);
39 return (0, _core.jsx)(_PseudoBox["default"], (0, _extends2["default"])({
40 ref: ref,
41 as: as,
42 readOnly: formControl.isReadOnly,
43 "aria-readonly": isReadOnly,
44 disabled: formControl.isDisabled,
45 "aria-label": ariaLabel,
46 "aria-invalid": formControl.isInvalid,
47 required: formControl.isRequired,
48 "aria-required": formControl.isRequired,
49 "aria-disabled": formControl.isDisabled,
50 "aria-describedby": ariaDescribedby
51 }, inputStyleProps, rest));
52});
53Input.displayName = "Input";
54Input.defaultProps = {
55 size: "md",
56 as: "input",
57 variant: "outline",
58 isFullWidth: true,
59 focusBorderColor: "blue.500",
60 errorBorderColor: "red.500"
61};
62var _default = Input;
63exports["default"] = _default;
\No newline at end of file