linear-react-components-ui 1.0.17-beta.0 → 1.0.17-beta.2
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/lib/form/types.d.ts
CHANGED
|
@@ -38,8 +38,10 @@ var NumberField = function NumberField(props) {
|
|
|
38
38
|
min = props.min,
|
|
39
39
|
max = props.max,
|
|
40
40
|
_props$value = props.value,
|
|
41
|
-
value = _props$value === void 0 ? '' : _props$value
|
|
42
|
-
|
|
41
|
+
value = _props$value === void 0 ? '' : _props$value,
|
|
42
|
+
_props$removeZeroLeft = props.removeZeroLeft,
|
|
43
|
+
removeZeroLeft = _props$removeZeroLeft === void 0 ? true : _props$removeZeroLeft;
|
|
44
|
+
var _useState = (0, _react.useState)(value === null || value === void 0 ? void 0 : value.toString()),
|
|
43
45
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
46
|
numberValue = _useState2[0],
|
|
45
47
|
setNumberValue = _useState2[1];
|
|
@@ -50,13 +52,14 @@ var NumberField = function NumberField(props) {
|
|
|
50
52
|
if (min && parseInt(numericValue, 10) < min || max && parseInt(numericValue, 10) > max) {
|
|
51
53
|
return;
|
|
52
54
|
}
|
|
55
|
+
if (removeZeroLeft && numericValue.charAt(0) === '0' && numericValue.length > 1) {
|
|
56
|
+
setNumberValue(numericValue.substring(1));
|
|
57
|
+
} else {
|
|
58
|
+
setNumberValue(numericValue);
|
|
59
|
+
}
|
|
53
60
|
if (props.onChange) props.onChange(event);
|
|
54
|
-
setNumberValue(numericValue);
|
|
55
61
|
}
|
|
56
62
|
};
|
|
57
|
-
(0, _react.useEffect)(function () {
|
|
58
|
-
if (value !== numberValue) setNumberValue(value.toString());
|
|
59
|
-
}, [value]);
|
|
60
63
|
return /*#__PURE__*/_react.default.createElement(_InputTextBase.default, _extends({}, props, {
|
|
61
64
|
value: numberValue,
|
|
62
65
|
textAlign: textAlign,
|
|
@@ -12,6 +12,7 @@ import '../../icons/helper.js';
|
|
|
12
12
|
|
|
13
13
|
interface INumberFieldProps extends IMaskHOCProps {
|
|
14
14
|
onChange?: (e?: CustomInputEvent) => void;
|
|
15
|
+
removeZeroLeft?: boolean;
|
|
15
16
|
}
|
|
16
17
|
interface IBaseNumberProps extends IMaskHOCProps {
|
|
17
18
|
returnFormattedValueOnBlur?: boolean;
|
|
@@ -163,14 +163,8 @@ var MultipleSelect = function MultipleSelect(props) {
|
|
|
163
163
|
};
|
|
164
164
|
var onInputKeyDown = function onInputKeyDown(e) {
|
|
165
165
|
if (e.keyCode) {
|
|
166
|
-
if (e.keyCode === constants.keyCodes.ENTER && selected
|
|
167
|
-
if (!currents.
|
|
168
|
-
return current[idKey] === selected[idKey];
|
|
169
|
-
})) {
|
|
170
|
-
var _e$preventDefault;
|
|
171
|
-
(_e$preventDefault = e.preventDefault) === null || _e$preventDefault === void 0 ? void 0 : _e$preventDefault.call(e);
|
|
172
|
-
onSelect(selected);
|
|
173
|
-
}
|
|
166
|
+
if (e.keyCode === constants.keyCodes.ENTER && selected) {
|
|
167
|
+
if (!currents.includes(selected)) onSelect(selected);
|
|
174
168
|
} else if ([constants.keyCodes.ARROW_UP, constants.keyCodes.ARROW_DOWN].includes(e.keyCode)) {
|
|
175
169
|
if (!opened) setOpened(true);
|
|
176
170
|
var index = dataCombo ? dataCombo.findIndex(function (d) {
|
|
@@ -190,7 +190,7 @@ var SimpleSelect = function SimpleSelect(props) {
|
|
|
190
190
|
};
|
|
191
191
|
var onInputKeyDown = function onInputKeyDown(e) {
|
|
192
192
|
if (e.keyCode) {
|
|
193
|
-
if (e.keyCode === constants.keyCodes.ENTER && selected
|
|
193
|
+
if (e.keyCode === constants.keyCodes.ENTER && selected) {
|
|
194
194
|
var _e$preventDefault;
|
|
195
195
|
(_e$preventDefault = e.preventDefault) === null || _e$preventDefault === void 0 ? void 0 : _e$preventDefault.call(e);
|
|
196
196
|
onSelect(selected);
|