UNPKG

@react-md/form

Version:

This package is for creating all the different form input types.

71 lines 4.05 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { forwardRef } from "react"; import cn from "classnames"; import { bem } from "@react-md/utils"; import { useFormTheme } from "../FormThemeProvider"; import { TextFieldAddon } from "./TextFieldAddon"; var block = bem("rmd-text-field-container"); /** * This is a container component that is used to structure the text field with * different parts and themes. */ export var TextFieldContainer = forwardRef(function TextFieldContainer(_a, ref) { var _b; var className = _a.className, children = _a.children, _c = _a.inline, inline = _c === void 0 ? false : _c, propTheme = _a.theme, _d = _a.error, error = _d === void 0 ? false : _d, active = _a.active, label = _a.label, _e = _a.dense, dense = _e === void 0 ? false : _e, _f = _a.stretch, stretch = _f === void 0 ? false : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.isLeftAddon, isLeftAddon = _h === void 0 ? true : _h, _j = _a.isRightAddon, isRightAddon = _j === void 0 ? true : _j, leftChildren = _a.leftChildren, rightChildren = _a.rightChildren, propUnderlineDirection = _a.underlineDirection, props = __rest(_a, ["className", "children", "inline", "theme", "error", "active", "label", "dense", "stretch", "disabled", "isLeftAddon", "isRightAddon", "leftChildren", "rightChildren", "underlineDirection"]); var _k = useFormTheme({ theme: propTheme, underlineDirection: propUnderlineDirection, }), theme = _k.theme, underlineDirection = _k.underlineDirection; var underline = theme === "underline"; var outline = theme === "outline"; var filled = theme === "filled"; var isUnderlined = underline || filled; var isOutlineActive = outline && active; return (_jsxs("div", __assign({}, props, { ref: ref, className: cn(block((_b = { error: error, inline: inline, stretch: stretch, filled: filled, outline: outline, disabled: disabled, hoverable: !disabled && !isOutlineActive, label: label && !dense, dense: !label && dense, "dense-label": dense && label, "dense-placeholder": dense && isUnderlined && !label, "outline-active": isOutlineActive, "outline-error": outline && error, "outline-left": outline && leftChildren, "outline-right": outline && rightChildren, underline: isUnderlined, "underline-labelled": label && isUnderlined, "underline-active": isUnderlined && active }, _b["underline-".concat(underlineDirection)] = isUnderlined, _b["underline-left-addon"] = isUnderlined && leftChildren, _b["underline-right-addon"] = isUnderlined && rightChildren, _b)), className) }, { children: [isLeftAddon ? (_jsx(TextFieldAddon, { children: leftChildren })) : (leftChildren), children, isRightAddon ? (_jsx(TextFieldAddon, { children: rightChildren })) : (rightChildren)] }))); }); //# sourceMappingURL=TextFieldContainer.js.map