import 'react';
import '@emotion/core';
import { _ as __rest, a as __assign, b as __makeTemplateObject } from './_tslib-5c49bd3f.js';
import { jsx } from '@emotion/react/jsx-runtime';
import '@emotion/styled';
import '@emotion/react';
import { s as styled } from './css-efbd0d2d.js';
import { u as useId } from './auto-id.esm-d84df351.js';
import { u as useCustomCss } from './utilities-357c56e6.js';
import { InputWrapper } from './InputWrapper.js';

var TextInput = function (_a) {
    var idFromProps = _a.id, _b = _a.label, label = _b === void 0 ? '' : _b, _c = _a.description, description = _c === void 0 ? '' : _c, value = _a.value, placeholder = _a.placeholder, _d = _a.wrapperProps, wrapperProps = _d === void 0 ? {} : _d, _e = _a.className, className = _e === void 0 ? '' : _e, _f = _a.valid, valid = _f === void 0 ? null : _f, _g = _a.disabled, disabled = _g === void 0 ? null : _g, _h = _a.errorMessage, errorMessage = _h === void 0 ? '' : _h, _j = _a.customCss, customCss = _j === void 0 ? '' : _j, onChange = _a.onChange, props = __rest(_a, ["id", "label", "description", "value", "placeholder", "wrapperProps", "className", "valid", "disabled", "errorMessage", "customCss", "onChange"]);
    var resolvedCss = useCustomCss(customCss);
    var id = useId(idFromProps);
    var descriptionId = "desc-" + id;
    var errorId = "err-" + id;
    var handleChange = function (e) {
        if (onChange) {
            onChange(e);
        }
    };
    return (jsx(InputWrapper, __assign({ customCss: resolvedCss, className: className, label: label, description: description, errorMessage: errorMessage, id: id, descriptionId: descriptionId, errorId: errorId }, wrapperProps, { children: jsx(Input, __assign({ type: "text", placeholder: placeholder, "aria-describedby": descriptionId + " " + errorId, "aria-invalid": valid === false, "data-valid": valid, id: id, value: value, onChange: handleChange, disabled: !!disabled }, props), void 0) }), void 0));
};
var Input = styled('input')(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n  width: 100%;\n  font-size: 1em;\n  border: 3px solid;\n  border-color: ", ";\n  height: 35px;\n  border-radius: 5px;\n  padding: 5px;\n  &[data-valid='true'] {\n    border-color: ", ";\n  }\n  &[data-valid='false'] {\n    border-color: ", ";\n  }\n  &:focus-visible,\n  &:active {\n    border: 3px solid ", ";\n    outline: none;\n  }\n"], ["\n  width: 100%;\n  font-size: 1em;\n  border: 3px solid;\n  border-color: ", ";\n  height: 35px;\n  border-radius: 5px;\n  padding: 5px;\n  &[data-valid='true'] {\n    border-color: ", ";\n  }\n  &[data-valid='false'] {\n    border-color: ", ";\n  }\n  &:focus-visible,\n  &:active {\n    border: 3px solid ", ";\n    outline: none;\n  }\n"])), function (_a) {
    var theme = _a.theme;
    return theme.colors.neutral;
}, function (_a) {
    var theme = _a.theme;
    return theme.colors.success;
}, function (_a) {
    var theme = _a.theme;
    return theme.colors.danger;
}, function (_a) {
    var theme = _a.theme;
    return theme.colors.inputFocus;
});
var templateObject_1;

export { TextInput };
//# sourceMappingURL=TextInput.js.map
