@invoicebox/ui 0.1.0-alpha.304 → 0.1.0-alpha.305
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 +17 -28
- package/dist/components/form/CurrencyInput/CoreCurrencyInput/index.js +18 -37
- package/dist/components/form/DateInput/index.js +16 -41
- package/dist/components/form/DateTimeInput/index.js +16 -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 +15 -24
- package/dist/components/form/PositiveIntegerInput/index.js +14 -32
- package/dist/components/form/Select/components/Input/index.js +16 -34
- package/dist/components/form/TextInput/index.js +14 -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 +19 -30
- package/dist/esm/components/form/CurrencyInput/CoreCurrencyInput/index.js +17 -34
- package/dist/esm/components/form/DateInput/index.js +17 -42
- package/dist/esm/components/form/DateTimeInput/index.js +17 -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 +16 -25
- package/dist/esm/components/form/PositiveIntegerInput/index.js +15 -33
- package/dist/esm/components/form/Select/components/Input/index.js +17 -35
- package/dist/esm/components/form/TextInput/index.js +15 -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
|
@@ -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,18 @@ 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
|
+
}),
|
|
93
|
+
inputLabel = _useInputStyles.inputLabel,
|
|
94
|
+
paddingAndVariantOptions = _useInputStyles.paddingAndVariantOptions,
|
|
95
|
+
modernPlaceholder = _useInputStyles.modernPlaceholder;
|
|
85
96
|
var handleStringValueChange = useCallback(function (event) {
|
|
86
97
|
setStringValue(event.target.value);
|
|
87
98
|
}, [setStringValue]);
|
|
@@ -122,35 +133,6 @@ export var DateTimeInput = function DateTimeInput(_ref) {
|
|
|
122
133
|
}, [calendarDropdownValue, handleClose, maxDate, minDate, onChange, setStringValue, value, withTime]);
|
|
123
134
|
var maxTime = calendarDropdownValue && maxDate && calendarDropdownValue.getFullYear() === maxDate.getFullYear() && calendarDropdownValue.getMonth() === maxDate.getMonth() && calendarDropdownValue.getDate() === maxDate.getDate() ? [maxDate.getHours(), maxDate.getMinutes()] : undefined;
|
|
124
135
|
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
136
|
return /*#__PURE__*/React.createElement(S.Wrapper, {
|
|
155
137
|
ref: isMobile ? undefined : elRef
|
|
156
138
|
}, /*#__PURE__*/React.createElement(InputLabel, {
|
|
@@ -159,25 +141,20 @@ export var DateTimeInput = function DateTimeInput(_ref) {
|
|
|
159
141
|
required: required,
|
|
160
142
|
useModernStyles: useModernStyles,
|
|
161
143
|
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({
|
|
144
|
+
}, /*#__PURE__*/React.createElement(S.InputWrapper, null, modernPlaceholder, /*#__PURE__*/React.createElement(PureInput, _extends({
|
|
168
145
|
onClick: handleTrigger,
|
|
169
146
|
ref: inputRef,
|
|
170
147
|
hasError: hasError,
|
|
171
148
|
inFocus: inFocus,
|
|
172
149
|
name: name,
|
|
173
|
-
placeholder:
|
|
150
|
+
placeholder: useModernStyles ? undefined : placeholder || logic.getPlaceholder(withTime),
|
|
174
151
|
onFocus: focusHandler,
|
|
175
152
|
onBlur: handleBlur,
|
|
176
153
|
value: stringValue,
|
|
177
154
|
onChange: handleStringValueChange,
|
|
178
155
|
paddingRight: 44,
|
|
179
156
|
useModernStyles: useModernStyles
|
|
180
|
-
},
|
|
157
|
+
}, paddingAndVariantOptions)), /*#__PURE__*/React.createElement(S.Icon, {
|
|
181
158
|
onClick: handleTrigger,
|
|
182
159
|
$color: palette.icon
|
|
183
160
|
}, /*#__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,17 @@ 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
|
+
}),
|
|
92
|
+
inputLabel = _useInputStyles.inputLabel,
|
|
93
|
+
paddingAndVariantOptions = _useInputStyles.paddingAndVariantOptions,
|
|
94
|
+
isHideModernPlaceholder = _useInputStyles.isHideModernPlaceholder;
|
|
83
95
|
var handleChangeCountry = useCallback(function (countryCode) {
|
|
84
96
|
setCountry(countryCode);
|
|
85
97
|
if (onCountryChange) {
|
|
@@ -154,24 +166,6 @@ export var PhoneInput = function PhoneInput(_ref) {
|
|
|
154
166
|
if (isInnerErrorHighlight) return isHaveInputError;
|
|
155
167
|
return false;
|
|
156
168
|
}, [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
169
|
var inputPlaceholder = useMemo(function () {
|
|
176
170
|
if (useModernStyles) {
|
|
177
171
|
return undefined;
|
|
@@ -180,9 +174,6 @@ export var PhoneInput = function PhoneInput(_ref) {
|
|
|
180
174
|
}
|
|
181
175
|
}, [country, currentCountriesPhoneRules, useModernStyles]);
|
|
182
176
|
var modernPlaceholderText = label || currentCountriesPhoneRules[country].placeholder;
|
|
183
|
-
var isModernPlaceholderVisible = useMemo(function () {
|
|
184
|
-
return !inFocus && !inputValue;
|
|
185
|
-
}, [inFocus, inputValue]);
|
|
186
177
|
return /*#__PURE__*/React.createElement(InputLabel, {
|
|
187
178
|
inFocus: inFocus,
|
|
188
179
|
label: inputLabel,
|
|
@@ -192,9 +183,9 @@ export var PhoneInput = function PhoneInput(_ref) {
|
|
|
192
183
|
size: size,
|
|
193
184
|
left: useModernStyles ? 65 : undefined
|
|
194
185
|
}, /*#__PURE__*/React.createElement(S.InputLabelContent, null, useModernStyles && /*#__PURE__*/React.createElement(ModernPlaceholder, {
|
|
195
|
-
visible:
|
|
186
|
+
visible: !isHideModernPlaceholder,
|
|
196
187
|
paddingLeft: isHaveSelectCountries ? 75 : 18,
|
|
197
|
-
paddingTop:
|
|
188
|
+
paddingTop: MODERN_STYLE_SIZE_PARAMS_MAP[size].$placeholderPaddingTop,
|
|
198
189
|
size: size,
|
|
199
190
|
required: required
|
|
200
191
|
}, 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 +221,7 @@ export var PhoneInput = function PhoneInput(_ref) {
|
|
|
230
221
|
autoComplete: 'new-password',
|
|
231
222
|
inputMode: "numeric",
|
|
232
223
|
autoFocus: autoFocus
|
|
233
|
-
},
|
|
224
|
+
}, paddingAndVariantOptions, {
|
|
234
225
|
useModernStyles: useModernStyles
|
|
235
226
|
}, pureInputProps)))));
|
|
236
227
|
};
|
|
@@ -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,15 +1,15 @@
|
|
|
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, { forwardRef
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
3
|
import * as S from './styles';
|
|
4
4
|
import { InputLabel } from '../../../InputLabel';
|
|
5
5
|
import { PureInput } from '../../../PureInput';
|
|
6
6
|
import { Arrow } from '../../../../common/Arrow';
|
|
7
7
|
import { ResetButton } from '../../../ResetButton';
|
|
8
|
-
import {
|
|
9
|
-
import { ModernPlaceholder } from '../../../ModernPlaceholder';
|
|
8
|
+
import { useInputStyles } from '../../../_hooks/useInputStyles';
|
|
10
9
|
export var Input = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
11
10
|
var hasError = _ref.hasError,
|
|
12
|
-
inFocus = _ref.inFocus,
|
|
11
|
+
_ref$inFocus = _ref.inFocus,
|
|
12
|
+
inFocus = _ref$inFocus === void 0 ? false : _ref$inFocus,
|
|
13
13
|
placeholder = _ref.placeholder,
|
|
14
14
|
onFocus = _ref.onFocus,
|
|
15
15
|
onBlur = _ref.onBlur,
|
|
@@ -25,43 +25,25 @@ export var Input = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
25
25
|
required = _ref.required,
|
|
26
26
|
_ref$useModernStyles = _ref.useModernStyles,
|
|
27
27
|
useModernStyles = _ref$useModernStyles === void 0 ? false : _ref$useModernStyles;
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
var _useInputStyles = useInputStyles({
|
|
29
|
+
isHaveValue: !!value,
|
|
30
|
+
useModernStyles: useModernStyles,
|
|
31
|
+
size: size,
|
|
32
|
+
label: label,
|
|
33
|
+
inFocus: inFocus,
|
|
34
|
+
placeholder: placeholder
|
|
35
|
+
}),
|
|
36
|
+
inputLabel = _useInputStyles.inputLabel,
|
|
37
|
+
paddingAndVariantOptions = _useInputStyles.paddingAndVariantOptions,
|
|
38
|
+
modernPlaceholder = _useInputStyles.modernPlaceholder;
|
|
39
39
|
var isShowResetIcon = !!value && !!onReset;
|
|
40
|
-
var isModernPlaceholderVisible = useMemo(function () {
|
|
41
|
-
return useModernStyles && !isOpen && !value;
|
|
42
|
-
}, [isOpen, useModernStyles, value]);
|
|
43
|
-
var modernInputPlaceholder = useMemo(function () {
|
|
44
|
-
return placeholder || label;
|
|
45
|
-
}, [label, placeholder]);
|
|
46
|
-
var paddingOptions = useMemo(function () {
|
|
47
|
-
if ((value || isOpen) && useModernStyles && label) {
|
|
48
|
-
return MODERN_STYLE_SIZE_PARAMS_MAP[size];
|
|
49
|
-
} else {
|
|
50
|
-
return SIZE_PARAMS_MAP[size];
|
|
51
|
-
}
|
|
52
|
-
}, [value, isOpen, useModernStyles, size, label]);
|
|
53
40
|
return /*#__PURE__*/React.createElement(InputLabel, {
|
|
54
41
|
inFocus: inFocus,
|
|
55
42
|
label: inputLabel,
|
|
56
43
|
required: required,
|
|
57
44
|
useModernStyles: useModernStyles,
|
|
58
45
|
size: size
|
|
59
|
-
}, /*#__PURE__*/React.createElement(S.ControlWrapper, null,
|
|
60
|
-
visible: isModernPlaceholderVisible,
|
|
61
|
-
paddingTop: SIZE_PARAMS_MAP[size !== null && size !== void 0 ? size : 'M'].paddingTop,
|
|
62
|
-
size: size !== null && size !== void 0 ? size : 'M',
|
|
63
|
-
required: required
|
|
64
|
-
}, modernInputPlaceholder), /*#__PURE__*/React.createElement(PureInput, _extends({
|
|
46
|
+
}, /*#__PURE__*/React.createElement(S.ControlWrapper, null, modernPlaceholder, /*#__PURE__*/React.createElement(PureInput, _extends({
|
|
65
47
|
ref: ref,
|
|
66
48
|
hasError: hasError,
|
|
67
49
|
inFocus: inFocus,
|
|
@@ -75,7 +57,7 @@ export var Input = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
75
57
|
paddingRight: 52,
|
|
76
58
|
onClick: onClick,
|
|
77
59
|
useModernStyles: useModernStyles
|
|
78
|
-
},
|
|
60
|
+
}, paddingAndVariantOptions)), /*#__PURE__*/React.createElement(S.IconWrapper, {
|
|
79
61
|
$pointerEvents: isShowResetIcon ? 'default' : 'none'
|
|
80
62
|
}, isShowResetIcon ? /*#__PURE__*/React.createElement(ResetButton, {
|
|
81
63
|
onClick: onReset
|
|
@@ -1,11 +1,10 @@
|
|
|
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 { InputLabel } from '../InputLabel';
|
|
5
5
|
import { PureInput } from '../PureInput';
|
|
6
6
|
import { useInputFocus } from '../../../hooks/useInputFocus';
|
|
7
|
-
import {
|
|
8
|
-
import { ModernPlaceholder } from '../ModernPlaceholder';
|
|
7
|
+
import { useInputStyles } from '../_hooks/useInputStyles';
|
|
9
8
|
export var TextInput = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
10
9
|
var _ref$hasError = _ref.hasError,
|
|
11
10
|
hasError = _ref$hasError === void 0 ? false : _ref$hasError,
|
|
@@ -43,33 +42,20 @@ export var TextInput = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
43
42
|
inFocus = _useInputFocus.inFocus,
|
|
44
43
|
handleFocus = _useInputFocus.handleFocus,
|
|
45
44
|
handleBlur = _useInputFocus.handleBlur;
|
|
45
|
+
var _useInputStyles = useInputStyles({
|
|
46
|
+
isHaveValue: !!value,
|
|
47
|
+
useModernStyles: useModernStyles,
|
|
48
|
+
size: size,
|
|
49
|
+
label: label,
|
|
50
|
+
inFocus: inFocus,
|
|
51
|
+
placeholder: placeholder
|
|
52
|
+
}),
|
|
53
|
+
inputLabel = _useInputStyles.inputLabel,
|
|
54
|
+
paddingAndVariantOptions = _useInputStyles.paddingAndVariantOptions,
|
|
55
|
+
modernPlaceholder = _useInputStyles.modernPlaceholder;
|
|
46
56
|
var handleChange = useCallback(function (event) {
|
|
47
57
|
onChange(event.target.value.slice(0, maxLength !== null && maxLength !== void 0 ? maxLength : Infinity));
|
|
48
58
|
}, [onChange, maxLength]);
|
|
49
|
-
var inputLabel = useMemo(function () {
|
|
50
|
-
if (useModernStyles) {
|
|
51
|
-
if (value || inFocus) {
|
|
52
|
-
return label;
|
|
53
|
-
} else {
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
return label;
|
|
58
|
-
}
|
|
59
|
-
}, [inFocus, label, value, useModernStyles]);
|
|
60
|
-
var paddingOptions = useMemo(function () {
|
|
61
|
-
if ((value || inFocus) && useModernStyles && inputLabel) {
|
|
62
|
-
return MODERN_STYLE_SIZE_PARAMS_MAP[size];
|
|
63
|
-
} else {
|
|
64
|
-
return SIZE_PARAMS_MAP[size];
|
|
65
|
-
}
|
|
66
|
-
}, [value, inFocus, useModernStyles, size, inputLabel]);
|
|
67
|
-
var modernInputPlaceholder = useMemo(function () {
|
|
68
|
-
return placeholder || label;
|
|
69
|
-
}, [label, placeholder]);
|
|
70
|
-
var isModernPlaceholderVisible = useMemo(function () {
|
|
71
|
-
return !inFocus && !value;
|
|
72
|
-
}, [inFocus, value]);
|
|
73
59
|
return /*#__PURE__*/React.createElement(InputLabel, {
|
|
74
60
|
inFocus: inFocus,
|
|
75
61
|
label: inputLabel,
|
|
@@ -77,12 +63,7 @@ export var TextInput = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
77
63
|
required: required,
|
|
78
64
|
size: size,
|
|
79
65
|
useModernStyles: useModernStyles
|
|
80
|
-
}, /*#__PURE__*/React.createElement(S.InputLabelContent, null,
|
|
81
|
-
visible: isModernPlaceholderVisible,
|
|
82
|
-
paddingTop: SIZE_PARAMS_MAP[size].paddingTop,
|
|
83
|
-
size: size,
|
|
84
|
-
required: required
|
|
85
|
-
}, modernInputPlaceholder), /*#__PURE__*/React.createElement(PureInput, _extends({
|
|
66
|
+
}, /*#__PURE__*/React.createElement(S.InputLabelContent, null, modernPlaceholder, /*#__PURE__*/React.createElement(PureInput, _extends({
|
|
86
67
|
id: id,
|
|
87
68
|
ref: ref,
|
|
88
69
|
name: name,
|
|
@@ -104,6 +85,6 @@ export var TextInput = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
104
85
|
inputMode: inputMode,
|
|
105
86
|
readOnly: readOnly,
|
|
106
87
|
autoComplete: autoComplete
|
|
107
|
-
},
|
|
88
|
+
}, paddingAndVariantOptions)), children && /*#__PURE__*/React.createElement(S.ChildrenWrapper, null, children)));
|
|
108
89
|
});
|
|
109
90
|
TextInput.displayName = 'TextInput';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { MODERN_STYLE_SIZE_PARAMS_MAP, SIZE_PARAMS_MAP } from '../constants';
|
|
8
|
+
import React, { useMemo } from 'react';
|
|
9
|
+
import { ModernPlaceholder } from '../ModernPlaceholder';
|
|
10
|
+
export var useInputStyles = function useInputStyles(_ref) {
|
|
11
|
+
var inFocus = _ref.inFocus,
|
|
12
|
+
useModernStyles = _ref.useModernStyles,
|
|
13
|
+
label = _ref.label,
|
|
14
|
+
size = _ref.size,
|
|
15
|
+
placeholder = _ref.placeholder,
|
|
16
|
+
isHaveValue = _ref.isHaveValue,
|
|
17
|
+
required = _ref.required,
|
|
18
|
+
_ref$conditionHideMod = _ref.conditionHideModernPlaceholder,
|
|
19
|
+
conditionHideModernPlaceholder = _ref$conditionHideMod === void 0 ? false : _ref$conditionHideMod;
|
|
20
|
+
var isHideModernPlaceholder = isHaveValue || inFocus || conditionHideModernPlaceholder;
|
|
21
|
+
var inputLabel = useMemo(function () {
|
|
22
|
+
if (useModernStyles) {
|
|
23
|
+
return isHideModernPlaceholder ? label : undefined;
|
|
24
|
+
} else {
|
|
25
|
+
return label;
|
|
26
|
+
}
|
|
27
|
+
}, [useModernStyles, isHideModernPlaceholder, label]);
|
|
28
|
+
var paddingAndVariantOptions = useMemo(function () {
|
|
29
|
+
if (useModernStyles) {
|
|
30
|
+
if (isHideModernPlaceholder) {
|
|
31
|
+
return MODERN_STYLE_SIZE_PARAMS_MAP[size];
|
|
32
|
+
} else {
|
|
33
|
+
return _objectSpread(_objectSpread({}, MODERN_STYLE_SIZE_PARAMS_MAP[size]), {}, {
|
|
34
|
+
paddingTop: MODERN_STYLE_SIZE_PARAMS_MAP[size].$placeholderPaddingTop,
|
|
35
|
+
paddingBottom: MODERN_STYLE_SIZE_PARAMS_MAP[size].$placeholderPaddingTop
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
return SIZE_PARAMS_MAP[size];
|
|
40
|
+
}
|
|
41
|
+
}, [useModernStyles, isHideModernPlaceholder, size]);
|
|
42
|
+
var modernInputPlaceholder = useMemo(function () {
|
|
43
|
+
return placeholder || label;
|
|
44
|
+
}, [label, placeholder]);
|
|
45
|
+
var modernPlaceholder = useModernStyles && modernInputPlaceholder && /*#__PURE__*/React.createElement(ModernPlaceholder, {
|
|
46
|
+
visible: !isHideModernPlaceholder,
|
|
47
|
+
paddingTop: MODERN_STYLE_SIZE_PARAMS_MAP[size].$placeholderPaddingTop,
|
|
48
|
+
size: size,
|
|
49
|
+
required: required
|
|
50
|
+
}, modernInputPlaceholder);
|
|
51
|
+
return {
|
|
52
|
+
inputLabel: inputLabel,
|
|
53
|
+
paddingAndVariantOptions: paddingAndVariantOptions,
|
|
54
|
+
modernInputPlaceholder: modernInputPlaceholder,
|
|
55
|
+
isHideModernPlaceholder: isHideModernPlaceholder,
|
|
56
|
+
modernPlaceholder: modernPlaceholder
|
|
57
|
+
};
|
|
58
|
+
};
|
|
@@ -17,24 +17,27 @@ export var SIZE_PARAMS_MAP = {
|
|
|
17
17
|
};
|
|
18
18
|
export var MODERN_STYLE_SIZE_PARAMS_MAP = {
|
|
19
19
|
L: {
|
|
20
|
-
paddingTop:
|
|
21
|
-
paddingBottom:
|
|
22
|
-
variant: '
|
|
23
|
-
$labelVariant: '
|
|
24
|
-
$labelPaddingTop:
|
|
20
|
+
paddingTop: 24,
|
|
21
|
+
paddingBottom: 8,
|
|
22
|
+
variant: 'headline5',
|
|
23
|
+
$labelVariant: 'labelsHintsRegular',
|
|
24
|
+
$labelPaddingTop: 8,
|
|
25
|
+
$placeholderPaddingTop: 16
|
|
25
26
|
},
|
|
26
27
|
M: {
|
|
27
28
|
paddingTop: 20,
|
|
28
|
-
paddingBottom:
|
|
29
|
-
variant: '
|
|
30
|
-
$labelVariant: '
|
|
31
|
-
$labelPaddingTop:
|
|
29
|
+
paddingBottom: 4,
|
|
30
|
+
variant: 'bodyL',
|
|
31
|
+
$labelVariant: 'labelsHintsRegular',
|
|
32
|
+
$labelPaddingTop: 4,
|
|
33
|
+
$placeholderPaddingTop: 12
|
|
32
34
|
},
|
|
33
35
|
XS: {
|
|
34
|
-
paddingTop:
|
|
35
|
-
paddingBottom:
|
|
36
|
-
variant: '
|
|
37
|
-
$labelVariant: '
|
|
38
|
-
$labelPaddingTop:
|
|
36
|
+
paddingTop: 6,
|
|
37
|
+
paddingBottom: 6,
|
|
38
|
+
variant: 'headline5',
|
|
39
|
+
$labelVariant: 'labelsHintsRegular',
|
|
40
|
+
$labelPaddingTop: -18,
|
|
41
|
+
$placeholderPaddingTop: 6
|
|
39
42
|
}
|
|
40
43
|
};
|