@dotconnor/grommet
Version:
focus on the essential experience
61 lines (58 loc) • 3.26 kB
JavaScript
import styled, { css } from 'styled-components';
import { disabledStyle, getInputPadBySide, inputStyle, parseMetricToNum, plainInputStyle, textAlignStyle } from '../../utils';
import { defaultProps } from '../../default-props';
var getPlainStyle = function getPlainStyle(plain) {
if (plain === 'full') {
return css(["", " padding:0;"], plainInputStyle);
}
return plain && plainInputStyle;
};
var StyledTextInput = styled.input.withConfig({
displayName: "StyledTextInput",
componentId: "sc-1x30a0s-0"
})(["", " ", " ", " ", " ", ";", ""], inputStyle, function (props) {
return getPlainStyle(props.plain);
}, function (props) {
return props.icon && (props.reverse ? "padding-right: " + props.theme.global.edgeSize.large + ";" : "padding-left: " + props.theme.global.edgeSize.large + ";");
}, function (props) {
return props.disabled && disabledStyle(props.theme.textInput.disabled && props.theme.textInput.disabled.opacity);
}, function (props) {
return props.theme.textInput && props.theme.textInput.extend;
}, function (props) {
return props.textAlign && textAlignStyle;
});
StyledTextInput.defaultProps = {};
Object.setPrototypeOf(StyledTextInput.defaultProps, defaultProps);
var StyledTextInputContainer = styled.div.withConfig({
displayName: "StyledTextInput__StyledTextInputContainer",
componentId: "sc-1x30a0s-1"
})(["position:relative;width:100%;", ";"], function (props) {
return props.theme.textInput && props.theme.textInput.container && props.theme.textInput.container.extend;
});
StyledTextInputContainer.defaultProps = {};
Object.setPrototypeOf(StyledTextInputContainer.defaultProps, defaultProps);
var StyledPlaceholder = styled.div.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 parseMetricToNum(getInputPadBySide(props, 'left')) - parseMetricToNum(props.theme.global.control.border.width);
}, function (props) {
return props.theme.textInput && props.theme.textInput.placeholder && props.theme.textInput.placeholder.extend;
});
StyledPlaceholder.defaultProps = {};
Object.setPrototypeOf(StyledPlaceholder.defaultProps, defaultProps);
var StyledIcon = styled.div.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: " + getInputPadBySide(props, 'right') + ";" : "left: " + getInputPadBySide(props, 'left') + ";";
});
var StyledSuggestions = styled.ol.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;
});
StyledSuggestions.defaultProps = {};
Object.setPrototypeOf(StyledSuggestions.defaultProps, defaultProps);
export { StyledTextInput, StyledTextInputContainer, StyledPlaceholder, StyledIcon, StyledSuggestions };