@invoicebox/ui 0.1.0-alpha.304 → 0.1.0-alpha.306
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/form/Autocomplete/components/Autocomplete/index.js +18 -28
- package/dist/components/form/CurrencyInput/CoreCurrencyInput/index.js +19 -37
- package/dist/components/form/DateInput/index.js +17 -41
- package/dist/components/form/DateTimeInput/index.js +17 -39
- package/dist/components/form/DateTimeInput/index.stories.js +2 -1
- package/dist/components/form/InputLabel/index.js +6 -3
- package/dist/components/form/InputLabel/styles.d.ts +3 -1
- package/dist/components/form/InputLabel/styles.js +14 -12
- package/dist/components/form/ModernPlaceholder/index.js +1 -1
- package/dist/components/form/PhoneInput/index.js +16 -24
- package/dist/components/form/PositiveIntegerInput/index.js +14 -32
- package/dist/components/form/SearchInput/index.js +17 -31
- package/dist/components/form/SearchInput/styles.d.ts +1 -1
- package/dist/components/form/SearchInput/styles.js +2 -2
- package/dist/components/form/Select/components/Input/index.js +17 -34
- package/dist/components/form/TextInput/index.js +15 -33
- package/dist/components/form/_hooks/useInputStyles.d.ts +23 -0
- package/dist/components/form/_hooks/useInputStyles.js +66 -0
- package/dist/components/form/constants.d.ts +1 -0
- package/dist/components/form/constants.js +17 -14
- package/dist/esm/components/form/Autocomplete/components/Autocomplete/index.js +20 -30
- package/dist/esm/components/form/CurrencyInput/CoreCurrencyInput/index.js +18 -34
- package/dist/esm/components/form/DateInput/index.js +18 -42
- package/dist/esm/components/form/DateTimeInput/index.js +18 -40
- package/dist/esm/components/form/DateTimeInput/index.stories.js +2 -1
- package/dist/esm/components/form/InputLabel/index.js +6 -3
- package/dist/esm/components/form/InputLabel/styles.js +14 -12
- package/dist/esm/components/form/ModernPlaceholder/index.js +2 -2
- package/dist/esm/components/form/PhoneInput/index.js +17 -25
- package/dist/esm/components/form/PositiveIntegerInput/index.js +15 -33
- package/dist/esm/components/form/SearchInput/index.js +18 -32
- package/dist/esm/components/form/SearchInput/styles.js +2 -2
- package/dist/esm/components/form/Select/components/Input/index.js +18 -35
- package/dist/esm/components/form/TextInput/index.js +16 -34
- package/dist/esm/components/form/_hooks/useInputStyles.js +58 -0
- package/dist/esm/components/form/constants.js +17 -14
- package/package.json +1 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { InputLabel } from '../../InputLabel';
|
|
3
3
|
import { useInputFocus } from '../../../../hooks/useInputFocus';
|
|
4
4
|
import { StyledCurrencyInputFromLibrary, InputWrapper } from './styles';
|
|
5
|
-
import { MODERN_STYLE_SIZE_PARAMS_MAP, SIZE_PARAMS_MAP } from '../../constants';
|
|
6
5
|
import { useComponentPalette } from '../../../../palette';
|
|
7
|
-
import {
|
|
6
|
+
import { useInputStyles } from '../../_hooks/useInputStyles';
|
|
8
7
|
export var CoreCurrencyInput = function CoreCurrencyInput(_ref) {
|
|
9
8
|
var label = _ref.label,
|
|
10
9
|
_ref$size = _ref.size,
|
|
@@ -31,27 +30,18 @@ export var CoreCurrencyInput = function CoreCurrencyInput(_ref) {
|
|
|
31
30
|
handleFocus = _useInputFocus.handleFocus,
|
|
32
31
|
handleBlur = _useInputFocus.handleBlur;
|
|
33
32
|
var palette = useComponentPalette('pureInput');
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if ((typeof defaultValue === 'number' || typeof value === 'number' || inFocus) && useModernStyles && inputLabel) {
|
|
47
|
-
return MODERN_STYLE_SIZE_PARAMS_MAP[size];
|
|
48
|
-
} else {
|
|
49
|
-
return SIZE_PARAMS_MAP[size];
|
|
50
|
-
}
|
|
51
|
-
}, [defaultValue, useModernStyles, size, inFocus, inputLabel, value]);
|
|
52
|
-
var isModernPlaceholderVisible = useMemo(function () {
|
|
53
|
-
return !inFocus && !defaultValue && defaultValue !== 0 && !value && value !== 0;
|
|
54
|
-
}, [defaultValue, inFocus, value]);
|
|
33
|
+
var _useInputStyles = useInputStyles({
|
|
34
|
+
isHaveValue: !!value || typeof defaultValue === 'number',
|
|
35
|
+
useModernStyles: useModernStyles,
|
|
36
|
+
size: size,
|
|
37
|
+
label: label,
|
|
38
|
+
inFocus: inFocus,
|
|
39
|
+
placeholder: '',
|
|
40
|
+
required: required
|
|
41
|
+
}),
|
|
42
|
+
modernPlaceholder = _useInputStyles.modernPlaceholder,
|
|
43
|
+
paddingAndVariantOptions = _useInputStyles.paddingAndVariantOptions,
|
|
44
|
+
inputLabel = _useInputStyles.inputLabel;
|
|
55
45
|
return /*#__PURE__*/React.createElement(InputLabel, {
|
|
56
46
|
inFocus: inFocus,
|
|
57
47
|
label: inputLabel,
|
|
@@ -59,21 +49,15 @@ export var CoreCurrencyInput = function CoreCurrencyInput(_ref) {
|
|
|
59
49
|
required: required,
|
|
60
50
|
useModernStyles: useModernStyles,
|
|
61
51
|
size: size
|
|
62
|
-
}, /*#__PURE__*/React.createElement(InputWrapper, null,
|
|
63
|
-
visible: isModernPlaceholderVisible,
|
|
64
|
-
paddingLeft: 18,
|
|
65
|
-
paddingTop: SIZE_PARAMS_MAP[size].paddingTop,
|
|
66
|
-
size: size,
|
|
67
|
-
required: required
|
|
68
|
-
}, label), /*#__PURE__*/React.createElement(StyledCurrencyInputFromLibrary, {
|
|
52
|
+
}, /*#__PURE__*/React.createElement(InputWrapper, null, modernPlaceholder, /*#__PURE__*/React.createElement(StyledCurrencyInputFromLibrary, {
|
|
69
53
|
$palette: palette,
|
|
70
54
|
$hasBorder: !useModernStyles,
|
|
71
55
|
$paddingLeft: 18,
|
|
72
56
|
$paddingRight: 18,
|
|
73
57
|
$borderRadius: 10,
|
|
74
|
-
$variant:
|
|
75
|
-
$paddingTop:
|
|
76
|
-
$paddingBottom:
|
|
58
|
+
$variant: paddingAndVariantOptions.variant,
|
|
59
|
+
$paddingTop: paddingAndVariantOptions.paddingTop,
|
|
60
|
+
$paddingBottom: paddingAndVariantOptions.paddingBottom,
|
|
77
61
|
$hasError: hasError,
|
|
78
62
|
$inFocus: inFocus,
|
|
79
63
|
onBlur: handleBlur,
|
|
@@ -5,7 +5,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
5
5
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
6
6
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
7
7
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
8
|
-
import React, { useCallback, useEffect,
|
|
8
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
9
9
|
import * as S from './styles';
|
|
10
10
|
import { logic } from './logic';
|
|
11
11
|
import { useOutsideClick } from '../../../hooks/useOutsideClick';
|
|
@@ -16,10 +16,9 @@ import { Dropdown } from '../../common/Dropdown';
|
|
|
16
16
|
import { Calendar } from '../../common/Calendar';
|
|
17
17
|
import { CalendarIcon } from './components/CalendarIcon';
|
|
18
18
|
import { useComponentPalette } from '../../../palette';
|
|
19
|
-
import { MODERN_STYLE_SIZE_PARAMS_MAP, SIZE_PARAMS_MAP } from '../constants';
|
|
20
|
-
import { ModernPlaceholder } from '../ModernPlaceholder';
|
|
21
19
|
import { useMobile } from '../../../index';
|
|
22
20
|
import { MobileDrawerDateCalendar } from './components/MobileDrawerDateCalendar';
|
|
21
|
+
import { useInputStyles } from '../_hooks/useInputStyles';
|
|
23
22
|
var resetValue = null;
|
|
24
23
|
export var DateInput = function DateInput(_ref) {
|
|
25
24
|
var onChange = _ref.onChange,
|
|
@@ -71,6 +70,19 @@ export var DateInput = function DateInput(_ref) {
|
|
|
71
70
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
72
71
|
stringValue = _useState4[0],
|
|
73
72
|
setStringValue = _useState4[1];
|
|
73
|
+
var _useInputStyles = useInputStyles({
|
|
74
|
+
isHaveValue: !!stringValue,
|
|
75
|
+
useModernStyles: useModernStyles,
|
|
76
|
+
size: size,
|
|
77
|
+
label: label,
|
|
78
|
+
inFocus: inFocus,
|
|
79
|
+
placeholder: placeholder,
|
|
80
|
+
conditionHideModernPlaceholder: isOpen,
|
|
81
|
+
required: required
|
|
82
|
+
}),
|
|
83
|
+
inputLabel = _useInputStyles.inputLabel,
|
|
84
|
+
paddingAndVariantOptions = _useInputStyles.paddingAndVariantOptions,
|
|
85
|
+
modernPlaceholder = _useInputStyles.modernPlaceholder;
|
|
74
86
|
useEffect(function () {
|
|
75
87
|
if (stringValue && value === resetValue) {
|
|
76
88
|
setStringValue('');
|
|
@@ -95,37 +107,6 @@ export var DateInput = function DateInput(_ref) {
|
|
|
95
107
|
setStringValue(logic.valueToString(newValue, false));
|
|
96
108
|
onChange(newValue);
|
|
97
109
|
}, [handleClose, onChange]);
|
|
98
|
-
var inputLabel = useMemo(function () {
|
|
99
|
-
if (useModernStyles) {
|
|
100
|
-
if (stringValue || isOpen) {
|
|
101
|
-
return label;
|
|
102
|
-
} else {
|
|
103
|
-
return undefined;
|
|
104
|
-
}
|
|
105
|
-
} else {
|
|
106
|
-
return label;
|
|
107
|
-
}
|
|
108
|
-
}, [isOpen, label, stringValue, useModernStyles]);
|
|
109
|
-
var paddingOptions = useMemo(function () {
|
|
110
|
-
if ((stringValue || isOpen) && useModernStyles && inputLabel) {
|
|
111
|
-
return MODERN_STYLE_SIZE_PARAMS_MAP[size];
|
|
112
|
-
} else {
|
|
113
|
-
return SIZE_PARAMS_MAP[size];
|
|
114
|
-
}
|
|
115
|
-
}, [stringValue, isOpen, useModernStyles, size, inputLabel]);
|
|
116
|
-
var inputPlaceholder = useMemo(function () {
|
|
117
|
-
if (useModernStyles) {
|
|
118
|
-
return undefined;
|
|
119
|
-
} else {
|
|
120
|
-
return placeholder || logic.getPlaceholder();
|
|
121
|
-
}
|
|
122
|
-
}, [placeholder, useModernStyles]);
|
|
123
|
-
var modernPlaceholderText = useMemo(function () {
|
|
124
|
-
return placeholder || label || logic.getPlaceholder();
|
|
125
|
-
}, [label, placeholder]);
|
|
126
|
-
var isModernPlaceholderVisible = useMemo(function () {
|
|
127
|
-
return !isOpen && !stringValue;
|
|
128
|
-
}, [isOpen, stringValue]);
|
|
129
110
|
return /*#__PURE__*/React.createElement(S.Wrapper, {
|
|
130
111
|
ref: isMobile ? undefined : elRef
|
|
131
112
|
}, /*#__PURE__*/React.createElement(InputLabel, {
|
|
@@ -134,25 +115,20 @@ export var DateInput = function DateInput(_ref) {
|
|
|
134
115
|
useModernStyles: useModernStyles,
|
|
135
116
|
size: size,
|
|
136
117
|
required: required
|
|
137
|
-
}, /*#__PURE__*/React.createElement(S.InputWrapper, null,
|
|
138
|
-
visible: isModernPlaceholderVisible,
|
|
139
|
-
paddingTop: SIZE_PARAMS_MAP[size].paddingTop,
|
|
140
|
-
required: required,
|
|
141
|
-
size: size
|
|
142
|
-
}, modernPlaceholderText), /*#__PURE__*/React.createElement(PureInput, _extends({
|
|
118
|
+
}, /*#__PURE__*/React.createElement(S.InputWrapper, null, modernPlaceholder, /*#__PURE__*/React.createElement(PureInput, _extends({
|
|
143
119
|
onClick: handleTrigger,
|
|
144
120
|
ref: inputRef,
|
|
145
121
|
hasError: hasError,
|
|
146
122
|
inFocus: inFocus,
|
|
147
123
|
name: name,
|
|
148
|
-
placeholder:
|
|
124
|
+
placeholder: useModernStyles ? undefined : placeholder || logic.getPlaceholder(),
|
|
149
125
|
onFocus: handleFocus,
|
|
150
126
|
onBlur: handleBlur,
|
|
151
127
|
value: stringValue,
|
|
152
128
|
onChange: handleStringValueChange,
|
|
153
129
|
paddingRight: 44,
|
|
154
130
|
useModernStyles: useModernStyles
|
|
155
|
-
},
|
|
131
|
+
}, paddingAndVariantOptions)), /*#__PURE__*/React.createElement(S.Icon, {
|
|
156
132
|
onClick: handleTrigger,
|
|
157
133
|
$palette: palette
|
|
158
134
|
}, /*#__PURE__*/React.createElement(CalendarIcon, null)))), isMobile ? /*#__PURE__*/React.createElement(MobileDrawerDateCalendar, {
|
|
@@ -5,7 +5,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
5
5
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
6
6
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
7
7
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
8
|
-
import React, { useCallback,
|
|
8
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
9
9
|
import { useComponentPalette } from '../../../palette';
|
|
10
10
|
import { useOutsideClick } from '../../../hooks/useOutsideClick';
|
|
11
11
|
import { useInputFocus } from '../../../hooks/useInputFocus';
|
|
@@ -13,8 +13,6 @@ import { logic } from '../DateInput/logic';
|
|
|
13
13
|
import * as S from './styles';
|
|
14
14
|
import { InputLabel } from '../InputLabel';
|
|
15
15
|
import { PureInput } from '../PureInput';
|
|
16
|
-
import { MODERN_STYLE_SIZE_PARAMS_MAP, SIZE_PARAMS_MAP } from '../constants';
|
|
17
|
-
import { ModernPlaceholder } from '../ModernPlaceholder';
|
|
18
16
|
import { CalendarIcon } from '../DateInput/components/CalendarIcon';
|
|
19
17
|
import { Dropdown } from '../../common/Dropdown';
|
|
20
18
|
import { Calendar } from '../../common/Calendar';
|
|
@@ -23,6 +21,7 @@ import { Typography, useMobile } from '../../../index';
|
|
|
23
21
|
import { useTimePickerHeight } from './hooks/useTimePickerHeight';
|
|
24
22
|
import { useStringValue } from './hooks/useStringValue';
|
|
25
23
|
import { MobileDrawerDateTimeCalendar } from './components/MobileDrawerDateTimeCalendar';
|
|
24
|
+
import { useInputStyles } from '../_hooks/useInputStyles';
|
|
26
25
|
export var DateTimeInput = function DateTimeInput(_ref) {
|
|
27
26
|
var onChange = _ref.onChange,
|
|
28
27
|
value = _ref.value,
|
|
@@ -82,6 +81,19 @@ export var DateTimeInput = function DateTimeInput(_ref) {
|
|
|
82
81
|
inFocus = _useInputFocus.inFocus,
|
|
83
82
|
focusHandler = _useInputFocus.handleFocus,
|
|
84
83
|
blurHandler = _useInputFocus.handleBlur;
|
|
84
|
+
var _useInputStyles = useInputStyles({
|
|
85
|
+
isHaveValue: !!stringValue,
|
|
86
|
+
useModernStyles: useModernStyles,
|
|
87
|
+
size: size,
|
|
88
|
+
label: label,
|
|
89
|
+
inFocus: inFocus,
|
|
90
|
+
placeholder: placeholder,
|
|
91
|
+
conditionHideModernPlaceholder: isOpen,
|
|
92
|
+
required: required
|
|
93
|
+
}),
|
|
94
|
+
inputLabel = _useInputStyles.inputLabel,
|
|
95
|
+
paddingAndVariantOptions = _useInputStyles.paddingAndVariantOptions,
|
|
96
|
+
modernPlaceholder = _useInputStyles.modernPlaceholder;
|
|
85
97
|
var handleStringValueChange = useCallback(function (event) {
|
|
86
98
|
setStringValue(event.target.value);
|
|
87
99
|
}, [setStringValue]);
|
|
@@ -122,35 +134,6 @@ export var DateTimeInput = function DateTimeInput(_ref) {
|
|
|
122
134
|
}, [calendarDropdownValue, handleClose, maxDate, minDate, onChange, setStringValue, value, withTime]);
|
|
123
135
|
var maxTime = calendarDropdownValue && maxDate && calendarDropdownValue.getFullYear() === maxDate.getFullYear() && calendarDropdownValue.getMonth() === maxDate.getMonth() && calendarDropdownValue.getDate() === maxDate.getDate() ? [maxDate.getHours(), maxDate.getMinutes()] : undefined;
|
|
124
136
|
var minTime = calendarDropdownValue && minDate && calendarDropdownValue.getFullYear() === minDate.getFullYear() && calendarDropdownValue.getMonth() === minDate.getMonth() && calendarDropdownValue.getDate() === minDate.getDate() ? [minDate.getHours(), minDate.getMinutes()] : undefined;
|
|
125
|
-
var inputLabel = useMemo(function () {
|
|
126
|
-
if (useModernStyles) {
|
|
127
|
-
if (stringValue || isOpen) {
|
|
128
|
-
return label;
|
|
129
|
-
} else {
|
|
130
|
-
return undefined;
|
|
131
|
-
}
|
|
132
|
-
} else {
|
|
133
|
-
return label;
|
|
134
|
-
}
|
|
135
|
-
}, [isOpen, label, stringValue, useModernStyles]);
|
|
136
|
-
var paddingOptions = useMemo(function () {
|
|
137
|
-
if ((stringValue || isOpen) && useModernStyles && inputLabel) {
|
|
138
|
-
return MODERN_STYLE_SIZE_PARAMS_MAP[size];
|
|
139
|
-
} else {
|
|
140
|
-
return SIZE_PARAMS_MAP[size];
|
|
141
|
-
}
|
|
142
|
-
}, [stringValue, isOpen, useModernStyles, size, inputLabel]);
|
|
143
|
-
var inputPlaceholder = useMemo(function () {
|
|
144
|
-
if (useModernStyles) {
|
|
145
|
-
return undefined;
|
|
146
|
-
} else {
|
|
147
|
-
return placeholder || logic.getPlaceholder(withTime);
|
|
148
|
-
}
|
|
149
|
-
}, [placeholder, useModernStyles, withTime]);
|
|
150
|
-
var modernPlaceholderText = placeholder || label || logic.getPlaceholder(withTime);
|
|
151
|
-
var isModernPlaceholderVisible = useMemo(function () {
|
|
152
|
-
return !isOpen && !stringValue;
|
|
153
|
-
}, [isOpen, stringValue]);
|
|
154
137
|
return /*#__PURE__*/React.createElement(S.Wrapper, {
|
|
155
138
|
ref: isMobile ? undefined : elRef
|
|
156
139
|
}, /*#__PURE__*/React.createElement(InputLabel, {
|
|
@@ -159,25 +142,20 @@ export var DateTimeInput = function DateTimeInput(_ref) {
|
|
|
159
142
|
required: required,
|
|
160
143
|
useModernStyles: useModernStyles,
|
|
161
144
|
size: size
|
|
162
|
-
}, /*#__PURE__*/React.createElement(S.InputWrapper, null,
|
|
163
|
-
visible: isModernPlaceholderVisible,
|
|
164
|
-
paddingTop: SIZE_PARAMS_MAP[size].paddingTop,
|
|
165
|
-
size: size,
|
|
166
|
-
required: required
|
|
167
|
-
}, modernPlaceholderText), /*#__PURE__*/React.createElement(PureInput, _extends({
|
|
145
|
+
}, /*#__PURE__*/React.createElement(S.InputWrapper, null, modernPlaceholder, /*#__PURE__*/React.createElement(PureInput, _extends({
|
|
168
146
|
onClick: handleTrigger,
|
|
169
147
|
ref: inputRef,
|
|
170
148
|
hasError: hasError,
|
|
171
149
|
inFocus: inFocus,
|
|
172
150
|
name: name,
|
|
173
|
-
placeholder:
|
|
151
|
+
placeholder: useModernStyles ? undefined : placeholder || logic.getPlaceholder(withTime),
|
|
174
152
|
onFocus: focusHandler,
|
|
175
153
|
onBlur: handleBlur,
|
|
176
154
|
value: stringValue,
|
|
177
155
|
onChange: handleStringValueChange,
|
|
178
156
|
paddingRight: 44,
|
|
179
157
|
useModernStyles: useModernStyles
|
|
180
|
-
},
|
|
158
|
+
}, paddingAndVariantOptions)), /*#__PURE__*/React.createElement(S.Icon, {
|
|
181
159
|
onClick: handleTrigger,
|
|
182
160
|
$color: palette.icon
|
|
183
161
|
}, /*#__PURE__*/React.createElement(CalendarIcon, null)))), !isMobile ? /*#__PURE__*/React.createElement(Dropdown, _extends({
|
|
@@ -13,21 +13,24 @@ export var InputLabel = function InputLabel(_ref) {
|
|
|
13
13
|
required = _ref$required === void 0 ? false : _ref$required,
|
|
14
14
|
_ref$useModernStyles = _ref.useModernStyles,
|
|
15
15
|
useModernStyles = _ref$useModernStyles === void 0 ? false : _ref$useModernStyles,
|
|
16
|
-
size = _ref.size,
|
|
16
|
+
_ref$size = _ref.size,
|
|
17
|
+
size = _ref$size === void 0 ? 'M' : _ref$size,
|
|
17
18
|
left = _ref.left;
|
|
18
19
|
var palette = useComponentPalette('inputLabel');
|
|
19
20
|
return /*#__PURE__*/React.createElement(S.Wrapper, {
|
|
20
21
|
$palette: palette,
|
|
21
22
|
$disabled: disabled,
|
|
22
23
|
$isLabel: !!label,
|
|
23
|
-
$useModernStyles: useModernStyles
|
|
24
|
+
$useModernStyles: useModernStyles,
|
|
25
|
+
$marginTop: useModernStyles && MODERN_STYLE_SIZE_PARAMS_MAP[size].$labelPaddingTop < 0 && !!label ? -MODERN_STYLE_SIZE_PARAMS_MAP[size].$labelPaddingTop : undefined,
|
|
26
|
+
$paddingTop: useModernStyles ? 0 : 10
|
|
24
27
|
}, label && /*#__PURE__*/React.createElement(S.Label, {
|
|
25
28
|
$palette: palette,
|
|
26
29
|
$inFocus: inFocus,
|
|
27
30
|
variant: size && useModernStyles ? MODERN_STYLE_SIZE_PARAMS_MAP[size].$labelVariant : 'captionRegular',
|
|
28
31
|
$required: required,
|
|
29
32
|
$useModernStyles: useModernStyles,
|
|
30
|
-
$
|
|
33
|
+
$top: useModernStyles ? MODERN_STYLE_SIZE_PARAMS_MAP[size].$labelPaddingTop : 0,
|
|
31
34
|
$left: left
|
|
32
35
|
}, label), children);
|
|
33
36
|
};
|
|
@@ -6,15 +6,15 @@ export var Label = styled(Typography).withConfig({
|
|
|
6
6
|
displayName: "styles__Label",
|
|
7
7
|
componentId: "sc-1prrc3p-0"
|
|
8
8
|
})(["border-radius:10px;position:absolute;top:", ";left:", ";background-color:", ";padding:0 ", "px;z-index:2;transition:color 0.2s ease-in-out 0s;animation:", " 0.15s ease;color:", ";", ""], function (_ref) {
|
|
9
|
-
var $
|
|
10
|
-
return $
|
|
9
|
+
var $top = _ref.$top;
|
|
10
|
+
return $top ? "".concat($top, "px") : 0;
|
|
11
11
|
}, function (_ref2) {
|
|
12
12
|
var $left = _ref2.$left;
|
|
13
13
|
return typeof $left === 'number' ? "".concat($left, "px") : '10px';
|
|
14
14
|
}, function (_ref3) {
|
|
15
15
|
var $palette = _ref3.$palette,
|
|
16
16
|
$useModernStyles = _ref3.$useModernStyles;
|
|
17
|
-
return $useModernStyles ?
|
|
17
|
+
return $useModernStyles ? 'none' : $palette.bg;
|
|
18
18
|
}, LABEL_PADDING, labelFadeIn, function (_ref4) {
|
|
19
19
|
var $inFocus = _ref4.$inFocus,
|
|
20
20
|
$palette = _ref4.$palette;
|
|
@@ -29,15 +29,17 @@ export var Label = styled(Typography).withConfig({
|
|
|
29
29
|
export var Wrapper = styled.div.withConfig({
|
|
30
30
|
displayName: "styles__Wrapper",
|
|
31
31
|
componentId: "sc-1prrc3p-1"
|
|
32
|
-
})(["position:relative;
|
|
33
|
-
var $
|
|
34
|
-
$useModernStyles = _ref6.$useModernStyles;
|
|
35
|
-
return $isLabel || $useModernStyles ? 10 : 0;
|
|
36
|
-
}, function (_ref7) {
|
|
37
|
-
var $disabled = _ref7.$disabled;
|
|
32
|
+
})(["position:relative;width:100%;opacity:", ";margin-top:", "px;padding-top:", "px;&:hover ", "{", ";}"], function (_ref6) {
|
|
33
|
+
var $disabled = _ref6.$disabled;
|
|
38
34
|
return $disabled ? 0.5 : 1;
|
|
39
|
-
},
|
|
40
|
-
var $
|
|
41
|
-
|
|
35
|
+
}, function (_ref7) {
|
|
36
|
+
var $marginTop = _ref7.$marginTop;
|
|
37
|
+
return $marginTop || 0;
|
|
38
|
+
}, function (_ref8) {
|
|
39
|
+
var $paddingTop = _ref8.$paddingTop;
|
|
40
|
+
return $paddingTop;
|
|
41
|
+
}, Label, function (_ref9) {
|
|
42
|
+
var $disabled = _ref9.$disabled,
|
|
43
|
+
$palette = _ref9.$palette;
|
|
42
44
|
return !$disabled && css(["color:", ";"], $palette.textHighlight);
|
|
43
45
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import * as S from './styles';
|
|
3
3
|
import { useComponentPalette } from '../../../palette';
|
|
4
|
-
import {
|
|
4
|
+
import { MODERN_STYLE_SIZE_PARAMS_MAP } from '../constants';
|
|
5
5
|
export var ModernPlaceholder = function ModernPlaceholder(_ref) {
|
|
6
6
|
var visible = _ref.visible,
|
|
7
7
|
_ref$paddingLeft = _ref.paddingLeft,
|
|
@@ -14,7 +14,7 @@ export var ModernPlaceholder = function ModernPlaceholder(_ref) {
|
|
|
14
14
|
var pureInputPalette = useComponentPalette('pureInput');
|
|
15
15
|
var inputLabelPalette = useComponentPalette('inputLabel');
|
|
16
16
|
return /*#__PURE__*/React.createElement(S.Wrapper, {
|
|
17
|
-
variant:
|
|
17
|
+
variant: MODERN_STYLE_SIZE_PARAMS_MAP[size].variant,
|
|
18
18
|
$visible: visible,
|
|
19
19
|
$paddingLeft: paddingLeft,
|
|
20
20
|
$paddingTop: paddingTop,
|
|
@@ -16,8 +16,9 @@ import { InputLabel } from '../InputLabel';
|
|
|
16
16
|
import { PureInput } from '../PureInput';
|
|
17
17
|
import { CountrySelect } from '../CountrySelect';
|
|
18
18
|
import { useMobile } from '../../../hooks/useMedia';
|
|
19
|
-
import { MODERN_STYLE_SIZE_PARAMS_MAP
|
|
19
|
+
import { MODERN_STYLE_SIZE_PARAMS_MAP } from '../constants';
|
|
20
20
|
import { ModernPlaceholder } from '../ModernPlaceholder';
|
|
21
|
+
import { useInputStyles } from '../_hooks/useInputStyles';
|
|
21
22
|
export var PhoneInput = function PhoneInput(_ref) {
|
|
22
23
|
var onBlur = _ref.onBlur,
|
|
23
24
|
name = _ref.name,
|
|
@@ -80,6 +81,18 @@ export var PhoneInput = function PhoneInput(_ref) {
|
|
|
80
81
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
81
82
|
country = _useState8[0],
|
|
82
83
|
setCountry = _useState8[1];
|
|
84
|
+
var _useInputStyles = useInputStyles({
|
|
85
|
+
isHaveValue: !!inputValue,
|
|
86
|
+
useModernStyles: useModernStyles,
|
|
87
|
+
size: size,
|
|
88
|
+
label: label,
|
|
89
|
+
inFocus: inFocus,
|
|
90
|
+
placeholder: '',
|
|
91
|
+
required: required
|
|
92
|
+
}),
|
|
93
|
+
inputLabel = _useInputStyles.inputLabel,
|
|
94
|
+
paddingAndVariantOptions = _useInputStyles.paddingAndVariantOptions,
|
|
95
|
+
isHideModernPlaceholder = _useInputStyles.isHideModernPlaceholder;
|
|
83
96
|
var handleChangeCountry = useCallback(function (countryCode) {
|
|
84
97
|
setCountry(countryCode);
|
|
85
98
|
if (onCountryChange) {
|
|
@@ -154,24 +167,6 @@ export var PhoneInput = function PhoneInput(_ref) {
|
|
|
154
167
|
if (isInnerErrorHighlight) return isHaveInputError;
|
|
155
168
|
return false;
|
|
156
169
|
}, [hasError, isFirstBlur, isHaveInputError, isInnerErrorHighlight]);
|
|
157
|
-
var inputLabel = useMemo(function () {
|
|
158
|
-
if (useModernStyles) {
|
|
159
|
-
if (inputValue || inFocus) {
|
|
160
|
-
return label;
|
|
161
|
-
} else {
|
|
162
|
-
return undefined;
|
|
163
|
-
}
|
|
164
|
-
} else {
|
|
165
|
-
return label;
|
|
166
|
-
}
|
|
167
|
-
}, [useModernStyles, inputValue, inFocus, label]);
|
|
168
|
-
var paddingOptions = useMemo(function () {
|
|
169
|
-
if ((inputValue || inFocus) && useModernStyles && inputLabel) {
|
|
170
|
-
return MODERN_STYLE_SIZE_PARAMS_MAP[size];
|
|
171
|
-
} else {
|
|
172
|
-
return SIZE_PARAMS_MAP[size];
|
|
173
|
-
}
|
|
174
|
-
}, [inputValue, useModernStyles, size, inFocus, inputLabel]);
|
|
175
170
|
var inputPlaceholder = useMemo(function () {
|
|
176
171
|
if (useModernStyles) {
|
|
177
172
|
return undefined;
|
|
@@ -180,9 +175,6 @@ export var PhoneInput = function PhoneInput(_ref) {
|
|
|
180
175
|
}
|
|
181
176
|
}, [country, currentCountriesPhoneRules, useModernStyles]);
|
|
182
177
|
var modernPlaceholderText = label || currentCountriesPhoneRules[country].placeholder;
|
|
183
|
-
var isModernPlaceholderVisible = useMemo(function () {
|
|
184
|
-
return !inFocus && !inputValue;
|
|
185
|
-
}, [inFocus, inputValue]);
|
|
186
178
|
return /*#__PURE__*/React.createElement(InputLabel, {
|
|
187
179
|
inFocus: inFocus,
|
|
188
180
|
label: inputLabel,
|
|
@@ -192,9 +184,9 @@ export var PhoneInput = function PhoneInput(_ref) {
|
|
|
192
184
|
size: size,
|
|
193
185
|
left: useModernStyles ? 65 : undefined
|
|
194
186
|
}, /*#__PURE__*/React.createElement(S.InputLabelContent, null, useModernStyles && /*#__PURE__*/React.createElement(ModernPlaceholder, {
|
|
195
|
-
visible:
|
|
187
|
+
visible: !isHideModernPlaceholder,
|
|
196
188
|
paddingLeft: isHaveSelectCountries ? 75 : 18,
|
|
197
|
-
paddingTop:
|
|
189
|
+
paddingTop: MODERN_STYLE_SIZE_PARAMS_MAP[size].$placeholderPaddingTop,
|
|
198
190
|
size: size,
|
|
199
191
|
required: required
|
|
200
192
|
}, modernPlaceholderText), !!(countrySelectOptions !== null && countrySelectOptions !== void 0 && countrySelectOptions.length) && /*#__PURE__*/React.createElement(S.InputLabelFloatWrapper, null, /*#__PURE__*/React.createElement(S.CountrySelectWrapper, null, /*#__PURE__*/React.createElement(CountrySelect, {
|
|
@@ -230,7 +222,7 @@ export var PhoneInput = function PhoneInput(_ref) {
|
|
|
230
222
|
autoComplete: 'new-password',
|
|
231
223
|
inputMode: "numeric",
|
|
232
224
|
autoFocus: autoFocus
|
|
233
|
-
},
|
|
225
|
+
}, paddingAndVariantOptions, {
|
|
234
226
|
useModernStyles: useModernStyles
|
|
235
227
|
}, pureInputProps)))));
|
|
236
228
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React, { useCallback
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
3
|
import * as S from './styles';
|
|
4
4
|
import { useInputFocus } from '../../../hooks/useInputFocus';
|
|
5
5
|
import { InputLabel } from '../InputLabel';
|
|
@@ -9,8 +9,7 @@ import { useFilters } from './hooks/useFilters';
|
|
|
9
9
|
import { useNormalizers } from './hooks/useNormalizers';
|
|
10
10
|
import { useIncrement } from './hooks/useIncrement';
|
|
11
11
|
import { useIncrementDisabledFlags } from './hooks/useIncrementDisabledFlags';
|
|
12
|
-
import {
|
|
13
|
-
import { ModernPlaceholder } from '../ModernPlaceholder';
|
|
12
|
+
import { useInputStyles } from '../_hooks/useInputStyles';
|
|
14
13
|
export var PositiveIntegerInput = function PositiveIntegerInput(_ref) {
|
|
15
14
|
var value = _ref.value,
|
|
16
15
|
onChange = _ref.onChange,
|
|
@@ -35,6 +34,17 @@ export var PositiveIntegerInput = function PositiveIntegerInput(_ref) {
|
|
|
35
34
|
inFocus = _useInputFocus.inFocus,
|
|
36
35
|
handleFocus = _useInputFocus.handleFocus,
|
|
37
36
|
handleBlur = _useInputFocus.handleBlur;
|
|
37
|
+
var _useInputStyles = useInputStyles({
|
|
38
|
+
isHaveValue: typeof value === 'number',
|
|
39
|
+
useModernStyles: useModernStyles,
|
|
40
|
+
size: size,
|
|
41
|
+
label: label,
|
|
42
|
+
inFocus: inFocus,
|
|
43
|
+
placeholder: placeholder
|
|
44
|
+
}),
|
|
45
|
+
inputLabel = _useInputStyles.inputLabel,
|
|
46
|
+
paddingAndVariantOptions = _useInputStyles.paddingAndVariantOptions,
|
|
47
|
+
modernPlaceholder = _useInputStyles.modernPlaceholder;
|
|
38
48
|
var filters = useFilters({
|
|
39
49
|
max: max
|
|
40
50
|
});
|
|
@@ -63,40 +73,12 @@ export var PositiveIntegerInput = function PositiveIntegerInput(_ref) {
|
|
|
63
73
|
var handleDown = useCallback(function () {
|
|
64
74
|
onChange(decrement(value));
|
|
65
75
|
}, [decrement, value, onChange]);
|
|
66
|
-
var modernInputPlaceholder = useMemo(function () {
|
|
67
|
-
return placeholder || label;
|
|
68
|
-
}, [label, placeholder]);
|
|
69
|
-
var isModernPlaceholderVisible = useMemo(function () {
|
|
70
|
-
return !inFocus && value === null;
|
|
71
|
-
}, [inFocus, value]);
|
|
72
|
-
var inputLabel = useMemo(function () {
|
|
73
|
-
if (useModernStyles) {
|
|
74
|
-
if (value || inFocus) {
|
|
75
|
-
return label;
|
|
76
|
-
} else {
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
return label;
|
|
81
|
-
}
|
|
82
|
-
}, [inFocus, label, value, useModernStyles]);
|
|
83
|
-
var paddingOptions = useMemo(function () {
|
|
84
|
-
if ((value || inFocus) && useModernStyles && inputLabel) {
|
|
85
|
-
return MODERN_STYLE_SIZE_PARAMS_MAP[size];
|
|
86
|
-
} else {
|
|
87
|
-
return SIZE_PARAMS_MAP[size];
|
|
88
|
-
}
|
|
89
|
-
}, [value, inFocus, useModernStyles, size, inputLabel]);
|
|
90
76
|
return /*#__PURE__*/React.createElement(InputLabel, {
|
|
91
77
|
inFocus: inFocus,
|
|
92
78
|
label: inputLabel,
|
|
93
79
|
useModernStyles: useModernStyles,
|
|
94
80
|
size: size
|
|
95
|
-
}, /*#__PURE__*/React.createElement(S.ControlWrapper, null,
|
|
96
|
-
visible: isModernPlaceholderVisible,
|
|
97
|
-
paddingTop: SIZE_PARAMS_MAP[size].paddingTop,
|
|
98
|
-
size: size
|
|
99
|
-
}, modernInputPlaceholder), /*#__PURE__*/React.createElement(PureInput, _extends({
|
|
81
|
+
}, /*#__PURE__*/React.createElement(S.ControlWrapper, null, modernPlaceholder, /*#__PURE__*/React.createElement(PureInput, _extends({
|
|
100
82
|
name: name,
|
|
101
83
|
hasError: hasError,
|
|
102
84
|
inFocus: inFocus,
|
|
@@ -106,7 +88,7 @@ export var PositiveIntegerInput = function PositiveIntegerInput(_ref) {
|
|
|
106
88
|
value: normalizeFrom(value),
|
|
107
89
|
onChange: handleChange,
|
|
108
90
|
paddingRight: upAndDown ? 44 : undefined
|
|
109
|
-
},
|
|
91
|
+
}, paddingAndVariantOptions, {
|
|
110
92
|
useModernStyles: useModernStyles
|
|
111
93
|
})), upAndDown && /*#__PURE__*/React.createElement(S.Arrows, null, /*#__PURE__*/React.createElement(S.Arrow, {
|
|
112
94
|
onClick: handleUp,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React, { useCallback, forwardRef
|
|
2
|
+
import React, { useCallback, forwardRef } from 'react';
|
|
3
3
|
import * as S from './styles';
|
|
4
4
|
import { InputLabel } from '../InputLabel';
|
|
5
5
|
import { PureInput } from '../PureInput';
|
|
@@ -7,7 +7,7 @@ import { useInputFocus } from '../../../hooks/useInputFocus';
|
|
|
7
7
|
import { SearchIcon } from './components/SearchIcon';
|
|
8
8
|
import { useComponentPalette } from '../../../palette';
|
|
9
9
|
import { ResetButton } from '../ResetButton';
|
|
10
|
-
import {
|
|
10
|
+
import { useInputStyles } from '../_hooks/useInputStyles';
|
|
11
11
|
export var SearchInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
12
12
|
var name = _ref.name,
|
|
13
13
|
onFocus = _ref.onFocus,
|
|
@@ -31,47 +31,33 @@ export var SearchInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
31
31
|
handleFocus = _useInputFocus.handleFocus,
|
|
32
32
|
handleBlur = _useInputFocus.handleBlur;
|
|
33
33
|
var palette = useComponentPalette('searchInput');
|
|
34
|
+
var _useInputStyles = useInputStyles({
|
|
35
|
+
isHaveValue: !!value,
|
|
36
|
+
useModernStyles: useModernStyles,
|
|
37
|
+
size: size,
|
|
38
|
+
label: placeholder,
|
|
39
|
+
inFocus: inFocus,
|
|
40
|
+
placeholder: placeholder
|
|
41
|
+
}),
|
|
42
|
+
inputLabel = _useInputStyles.inputLabel,
|
|
43
|
+
paddingAndVariantOptions = _useInputStyles.paddingAndVariantOptions,
|
|
44
|
+
modernPlaceholder = _useInputStyles.modernPlaceholder;
|
|
34
45
|
var handleInputReset = useCallback(function () {
|
|
35
46
|
onChange('');
|
|
36
47
|
}, [onChange]);
|
|
37
48
|
var handleInputChange = useCallback(function (event) {
|
|
38
49
|
onChange(event.target.value);
|
|
39
50
|
}, [onChange]);
|
|
40
|
-
var inputPlaceholder = useMemo(function () {
|
|
41
|
-
if (useModernStyles) {
|
|
42
|
-
if (!inFocus) {
|
|
43
|
-
return placeholder;
|
|
44
|
-
} else {
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
return placeholder;
|
|
49
|
-
}
|
|
50
|
-
}, [placeholder, useModernStyles, inFocus]);
|
|
51
|
-
var inputLabel = useMemo(function () {
|
|
52
|
-
if (useModernStyles && (value || inFocus)) {
|
|
53
|
-
return placeholder;
|
|
54
|
-
} else {
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
}, [inFocus, placeholder, value, useModernStyles]);
|
|
58
|
-
var paddingOptions = useMemo(function () {
|
|
59
|
-
if ((value || inFocus) && useModernStyles && inputLabel) {
|
|
60
|
-
return MODERN_STYLE_SIZE_PARAMS_MAP[size];
|
|
61
|
-
} else {
|
|
62
|
-
return SIZE_PARAMS_MAP[size];
|
|
63
|
-
}
|
|
64
|
-
}, [value, inFocus, useModernStyles, size, inputLabel]);
|
|
65
51
|
return /*#__PURE__*/React.createElement(InputLabel, {
|
|
66
52
|
useModernStyles: useModernStyles,
|
|
67
53
|
size: size,
|
|
68
|
-
label: inputLabel
|
|
69
|
-
}, /*#__PURE__*/React.createElement(PureInput, _extends({
|
|
54
|
+
label: useModernStyles ? inputLabel : undefined
|
|
55
|
+
}, modernPlaceholder, /*#__PURE__*/React.createElement(PureInput, _extends({
|
|
70
56
|
ref: ref,
|
|
71
57
|
paddingRight: 56,
|
|
72
58
|
hasBorder: hasBorder,
|
|
73
59
|
onChange: handleInputChange,
|
|
74
|
-
placeholder:
|
|
60
|
+
placeholder: useModernStyles ? undefined : placeholder,
|
|
75
61
|
value: value,
|
|
76
62
|
onFocus: handleFocus,
|
|
77
63
|
onBlur: handleBlur,
|
|
@@ -80,12 +66,12 @@ export var SearchInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
80
66
|
name: name,
|
|
81
67
|
maxLength: maxLength,
|
|
82
68
|
isOnlyNumbers: isOnlyNumbers
|
|
83
|
-
},
|
|
69
|
+
}, paddingAndVariantOptions, {
|
|
84
70
|
useModernStyles: useModernStyles
|
|
85
71
|
})), /*#__PURE__*/React.createElement(S.IconWrapper, {
|
|
86
72
|
$inFocus: inFocus,
|
|
87
73
|
$palette: palette,
|
|
88
|
-
$
|
|
74
|
+
$useModernStyles: useModernStyles
|
|
89
75
|
}, value ? /*#__PURE__*/React.createElement(ResetButton, {
|
|
90
76
|
onClick: handleInputReset
|
|
91
77
|
}) : /*#__PURE__*/React.createElement(SearchIcon, null)));
|