1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _extends2 = require('babel-runtime/helpers/extends');
|
8 |
|
9 | var _extends3 = _interopRequireDefault(_extends2);
|
10 |
|
11 | var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
|
12 |
|
13 | var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
|
14 |
|
15 | var _taggedTemplateLiteral2 = require('babel-runtime/helpers/taggedTemplateLiteral');
|
16 |
|
17 | var _taggedTemplateLiteral3 = _interopRequireDefault(_taggedTemplateLiteral2);
|
18 |
|
19 | var _templateObject = (0, _taggedTemplateLiteral3.default)(['\n background: none;\n color: #dadada;\n padding: 0rem 0 0.675rem 0rem;\n display: block;\n width: ', ';\n border: none;\n border-radius: 0;\n border-bottom: 1px solid #dadada;\n :valid {\n color: black;\n }\n :focus {\n outline: none;\n }\n &::placeholder {\n font-family: \'PT Sans\';\n }\n &:focus ~ ', ', &:valid ~ ', ' {\n /* top: -15px;\n left: 0px; */\n font-size: 3.75rem;\n color: #224233;\n }\n'], ['\n background: none;\n color: #dadada;\n padding: 0rem 0 0.675rem 0rem;\n display: block;\n width: ', ';\n border: none;\n border-radius: 0;\n border-bottom: 1px solid #dadada;\n :valid {\n color: black;\n }\n :focus {\n outline: none;\n }\n &::placeholder {\n font-family: \'PT Sans\';\n }\n &:focus ~ ', ', &:valid ~ ', ' {\n /* top: -15px;\n left: 0px; */\n font-size: 3.75rem;\n color: #224233;\n }\n']),
|
20 | _templateObject2 = (0, _taggedTemplateLiteral3.default)(['\n margin-top: 0.25rem;\n font-size: 1.25rem;\n width: 25.5rem;\n'], ['\n margin-top: 0.25rem;\n font-size: 1.25rem;\n width: 25.5rem;\n']),
|
21 | _templateObject3 = (0, _taggedTemplateLiteral3.default)(['\n position: relative;\n display: flex;\n\n :before {\n content: \'\';\n\n height: 1px;\n width: 0rem;\n bottom: 0px;\n position: absolute;\n /* background: #424242; */\n background: #d93025;\n transition: 300ms ease all;\n left: 0%;\n ', ':focus ~ & {\n width: ', ';\n }\n ', ':valid ~ & {\n background: black;\n height: 2px;\n }\n }\n'], ['\n position: relative;\n display: flex;\n\n :before {\n content: \'\';\n\n height: 1px;\n width: 0rem;\n bottom: 0px;\n position: absolute;\n /* background: #424242; */\n background: #d93025;\n transition: 300ms ease all;\n left: 0%;\n ', ':focus ~ & {\n width: ', ';\n }\n ', ':valid ~ & {\n background: black;\n height: 2px;\n }\n }\n']),
|
22 | _templateObject4 = (0, _taggedTemplateLiteral3.default)([''], ['']),
|
23 | _templateObject5 = (0, _taggedTemplateLiteral3.default)(['\n color: #d93025;\n'], ['\n color: #d93025;\n']);
|
24 |
|
25 | var _react = require('react');
|
26 |
|
27 | var _react2 = _interopRequireDefault(_react);
|
28 |
|
29 | var _helperFunctions = require('./helperFunctions');
|
30 |
|
31 | var _styledComponents = require('styled-components');
|
32 |
|
33 | var _styledComponents2 = _interopRequireDefault(_styledComponents);
|
34 |
|
35 | var _StyledForm = require('./StyledForm');
|
36 |
|
37 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
38 |
|
39 | var INPUT = (0, _styledComponents2.default)('input')(_templateObject, function (_ref) {
|
40 | var width = _ref.width;
|
41 | return width;
|
42 | }, LABEL, LABEL);
|
43 |
|
44 | var SUBLABEL = (0, _styledComponents2.default)('div')(_templateObject2);
|
45 |
|
46 | var BAR = (0, _styledComponents2.default)('div')(_templateObject3, INPUT, function (_ref2) {
|
47 | var width = _ref2.width;
|
48 | return width;
|
49 | }, INPUT);
|
50 |
|
51 | var LABEL = (0, _styledComponents2.default)(_StyledForm.INPUTBOX.LABEL)(_templateObject4);
|
52 | var ASTERISK = (0, _styledComponents2.default)('span')(_templateObject5);
|
53 |
|
54 | var getClassName = function getClassName(className, primary, secondary) {
|
55 | return (0, _helperFunctions.advancedMulti)({
|
56 | unflattenedBases: ['form', className],
|
57 | suffixes: ['__' + primary, '__' + secondary + '__' + primary]
|
58 | });
|
59 | };
|
60 |
|
61 | var InputBox = function InputBox(_ref3) {
|
62 | var id = _ref3.id,
|
63 | _ref3$border = _ref3.border,
|
64 | border = _ref3$border === undefined ? '1px solid' : _ref3$border,
|
65 | className = _ref3.className,
|
66 | placeholder = _ref3.placeholder,
|
67 | value = _ref3.value,
|
68 | onBlur = _ref3.onBlur,
|
69 | onChange = _ref3.onChange,
|
70 | _ref3$margin = _ref3.margin,
|
71 | margin = _ref3$margin === undefined ? 0 : _ref3$margin,
|
72 | _ref3$width = _ref3.width,
|
73 | width = _ref3$width === undefined ? '100%' : _ref3$width,
|
74 | _ref3$label = _ref3.label,
|
75 | label = _ref3$label === undefined ? null : _ref3$label,
|
76 | _ref3$sublabel = _ref3.sublabel,
|
77 | sublabel = _ref3$sublabel === undefined ? null : _ref3$sublabel,
|
78 | _ref3$required = _ref3.required,
|
79 | required = _ref3$required === undefined ? true : _ref3$required,
|
80 | _ref3$autoFocus = _ref3.autoFocus,
|
81 | autoFocus = _ref3$autoFocus === undefined ? false : _ref3$autoFocus,
|
82 | autocomplete = _ref3.autocomplete,
|
83 | children = _ref3.children,
|
84 | props = (0, _objectWithoutProperties3.default)(_ref3, ['id', 'border', 'className', 'placeholder', 'value', 'onBlur', 'onChange', 'margin', 'width', 'label', 'sublabel', 'required', 'autoFocus', 'autocomplete', 'children']);
|
85 |
|
86 | var getLocalClassName = function getLocalClassName(primary) {
|
87 | return getClassName(className, primary, 'inputbox');
|
88 | };
|
89 | var renderAsterisk = function renderAsterisk() {
|
90 | return required && _react2.default.createElement(
|
91 | ASTERISK,
|
92 | null,
|
93 | ' *'
|
94 | );
|
95 | };
|
96 | var renderLabel = function renderLabel() {
|
97 | return label && _react2.default.createElement(
|
98 | LABEL,
|
99 | { className: getLocalClassName('label') },
|
100 | label,
|
101 | renderAsterisk()
|
102 | );
|
103 | };
|
104 | var renderSublabel = function renderSublabel() {
|
105 | return sublabel && _react2.default.createElement(
|
106 | SUBLABEL,
|
107 | { className: getLocalClassName('sublabel') },
|
108 | sublabel
|
109 | );
|
110 | };
|
111 | return _react2.default.createElement(
|
112 | _react.Fragment,
|
113 | null,
|
114 | renderLabel(),
|
115 | _react2.default.createElement(INPUT, (0, _extends3.default)({
|
116 | id: id,
|
117 | onBlur: onBlur,
|
118 | className: getLocalClassName('input'),
|
119 | width: width,
|
120 | placeholder: placeholder,
|
121 | value: value,
|
122 | onChange: onChange,
|
123 | type: 'text',
|
124 | required: required,
|
125 | autoFocus: false,
|
126 | autocomplete: autocomplete
|
127 | }, props)),
|
128 | _react2.default.createElement(BAR, { className: getLocalClassName('bar'), width: width }),
|
129 | renderSublabel(),
|
130 | children
|
131 | );
|
132 | };
|
133 |
|
134 | exports.default = _react2.default.memo(InputBox); |
\ | No newline at end of file |