Repository URL to install this package:
|
Version:
3.0.1 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const deps_1 = require("./deps");
const styled_1 = require("./styled");
function toPlaceholderProps(props, state) {
const isLabelOnTop = state.value !== '';
const placeholderText = deps_1.toPlaceholder(props, state);
const shouldAnimatePlaceholder = props.animatePlaceholder || props.shouldAnimatePlaceholder;
return Object.assign({}, props, {
shouldAnimatePlaceholder,
isLabelOnTop,
placeholderText
});
}
exports.toPlaceholderProps = toPlaceholderProps;
function renderPlaceholder(props, state) {
const {
isLabelOnTop,
placeholderText,
shouldAnimatePlaceholder
} = toPlaceholderProps(props, state);
if (shouldAnimatePlaceholder === false) {
return '';
}
return react_1.default.createElement(styled_1.StyledLabel, {
className: 'input-box-label',
isLabelOnTop: props.isLabelOnTop
}, placeholderText);
}
exports.renderPlaceholder = renderPlaceholder;
function renderError(props, state) {
return state.isValidInput === false && react_1.default.createElement(styled_1.StyledErrorMessage, {
text: state.errorMessage
});
}
exports.renderError = renderError; // @todo also renderWrap if needed
function toWrap(props) {
return props.nowrap === true ? react_1.default.Fragment : styled_1.TextBoxWrapper;
}
exports.toWrap = toWrap; //# sourceMappingURL=renderProps.js.map