UNPKG

grommet

Version:

focus on the essential experience

68 lines (67 loc) 4.83 kB
"use strict"; exports.__esModule = true; exports.StyledTextInputContainer = exports.StyledTextInput = exports.StyledSuggestions = exports.StyledPlaceholder = exports.StyledIcon = void 0; var _styledComponents = _interopRequireWildcard(require("styled-components")); var _utils = require("../../utils"); var _styles = require("../../utils/styles"); var _readOnly = require("../../utils/readOnly"); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; } var getPlainStyle = function getPlainStyle(plain) { if (plain === 'full') { return (0, _styledComponents.css)(["", " padding:0;"], _utils.plainInputStyle); } return plain && _utils.plainInputStyle; }; var StyledTextInput = exports.StyledTextInput = _styledComponents["default"].input.withConfig(_utils.styledComponentsConfig).withConfig({ displayName: "StyledTextInput", componentId: "sc-1x30a0s-0" })(["", " ", " ", " ", " ", " ", " ", " ", " ", ";"], _utils.inputStyle, function (props) { return props.readOnlyCopy ? "padding-" + (props.reverse ? 'left' : 'right') + ": 0px;" : ''; }, function (props) { return props.readOnly && "border: none;"; }, function (props) { return getPlainStyle(props.plain); }, function (props) { return props.icon && _styles.inputPadForIcon; }, function (props) { return props.disabled && (0, _utils.disabledStyle)(props.theme.textInput.disabled && props.theme.textInput.disabled.opacity); }, function (props) { return props.textAlign && _utils.textAlignStyle; }, function (props) { return props.widthProp && (0, _utils.widthStyle)(props.widthProp, props.theme); }, function (props) { return props.theme.textInput && props.theme.textInput.extend; }); var StyledTextInputContainer = exports.StyledTextInputContainer = _styledComponents["default"].div.withConfig(_utils.styledComponentsConfig).withConfig({ displayName: "StyledTextInput__StyledTextInputContainer", componentId: "sc-1x30a0s-1" })(["position:relative;width:100%;", ";", ";", " ", ";"], function (props) { return props.readOnlyProp && !props.plain && _utils.controlBorderStyle; }, function (props) { return props.readOnlyCopy && "\n box-sizing: border-box;\n flex-direction: row;\n display: flex;\n "; }, function (props) { return props.readOnlyProp && !props.plain && (0, _readOnly.readOnlyStyle)(props.theme); }, function (props) { return props.theme.textInput && props.theme.textInput.container && props.theme.textInput.container.extend; }); var StyledPlaceholder = exports.StyledPlaceholder = _styledComponents["default"].div.withConfig(_utils.styledComponentsConfig).withConfig({ displayName: "StyledTextInput__StyledPlaceholder", componentId: "sc-1x30a0s-2" })(["position:absolute;left:", "px;top:50%;transform:translateY(-50%);display:flex;justify-content:center;pointer-events:none;", ";"], function (props) { return (0, _utils.parseMetricToNum)((0, _utils.getInputPadBySide)(props, 'left')) - (0, _utils.parseMetricToNum)(props.theme.global.control.border.width); }, function (props) { return props.theme.textInput && props.theme.textInput.placeholder && props.theme.textInput.placeholder.extend; }); var StyledIcon = exports.StyledIcon = _styledComponents["default"].div.withConfig(_utils.styledComponentsConfig).withConfig({ displayName: "StyledTextInput__StyledIcon", componentId: "sc-1x30a0s-3" })(["position:absolute;display:flex;justify:center;top:50%;transform:translateY(-50%);pointer-events:none;", ""], function (props) { return props.reverse ? "right: " + (0, _utils.getInputPadBySide)(props, 'right') + ";" : "left: " + (0, _utils.getInputPadBySide)(props, 'left') + ";"; }); var StyledSuggestions = exports.StyledSuggestions = _styledComponents["default"].ol.withConfig(_utils.styledComponentsConfig).withConfig({ displayName: "StyledTextInput__StyledSuggestions", componentId: "sc-1x30a0s-4" })(["border-top-left-radius:0;border-top-right-radius:0;margin:0;padding:0;list-style-type:none;", ";"], function (props) { return props.theme.textInput && props.theme.textInput.suggestions && props.theme.textInput.suggestions.extend; });