@panneau/field-number 3.0.308 → 4.0.0
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/es/index.js +22 -38
- package/package.json +6 -6
package/es/index.js
CHANGED
|
@@ -4,7 +4,6 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
|
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import isNaN from 'lodash-es/isNaN';
|
|
6
6
|
import isNumber from 'lodash-es/isNumber';
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
8
7
|
import React, { useCallback, useState } from 'react';
|
|
9
8
|
import Icon from '@panneau/element-icon';
|
|
10
9
|
import TextField from '@panneau/field-text';
|
|
@@ -12,44 +11,31 @@ import TextField from '@panneau/field-text';
|
|
|
12
11
|
var styles = {"container":"panneau-field-number-container","arrow":"panneau-field-number-arrow","dataListItems":"panneau-field-number-dataListItems","dataListItem":"panneau-field-number-dataListItem","dataListItemButton":"panneau-field-number-dataListItemButton"};
|
|
13
12
|
|
|
14
13
|
var _excluded = ["value", "step", "floatStep", "float", "dataList", "autoComplete", "disabled", "className", "onChange"];
|
|
15
|
-
var propTypes = {
|
|
16
|
-
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
17
|
-
step: PropTypes.number,
|
|
18
|
-
floatStep: PropTypes.number,
|
|
19
|
-
"float": PropTypes.bool,
|
|
20
|
-
dataList: PropTypes.arrayOf(PropTypes.number),
|
|
21
|
-
autoComplete: PropTypes.bool,
|
|
22
|
-
disabled: PropTypes.bool,
|
|
23
|
-
className: PropTypes.string,
|
|
24
|
-
onChange: PropTypes.func
|
|
25
|
-
};
|
|
26
|
-
var defaultProps = {
|
|
27
|
-
value: null,
|
|
28
|
-
step: 1,
|
|
29
|
-
floatStep: 0.1,
|
|
30
|
-
"float": false,
|
|
31
|
-
dataList: null,
|
|
32
|
-
autoComplete: false,
|
|
33
|
-
disabled: false,
|
|
34
|
-
className: null,
|
|
35
|
-
onChange: null
|
|
36
|
-
};
|
|
37
14
|
function isNumeric(str) {
|
|
38
15
|
if (typeof str !== 'string') return false; // we only process strings!
|
|
39
16
|
return !isNaN(str) &&
|
|
40
17
|
// use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
|
|
41
18
|
!isNaN(parseFloat(str));
|
|
42
19
|
}
|
|
43
|
-
|
|
44
|
-
var value = _ref.value,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
20
|
+
function NumberField(_ref) {
|
|
21
|
+
var _ref$value = _ref.value,
|
|
22
|
+
value = _ref$value === void 0 ? null : _ref$value,
|
|
23
|
+
_ref$step = _ref.step,
|
|
24
|
+
step = _ref$step === void 0 ? 1 : _ref$step,
|
|
25
|
+
_ref$floatStep = _ref.floatStep,
|
|
26
|
+
floatStep = _ref$floatStep === void 0 ? 0.1 : _ref$floatStep,
|
|
27
|
+
_ref$float = _ref["float"],
|
|
28
|
+
_float = _ref$float === void 0 ? false : _ref$float,
|
|
29
|
+
_ref$dataList = _ref.dataList,
|
|
30
|
+
dataList = _ref$dataList === void 0 ? null : _ref$dataList,
|
|
31
|
+
_ref$autoComplete = _ref.autoComplete,
|
|
32
|
+
autoComplete = _ref$autoComplete === void 0 ? false : _ref$autoComplete,
|
|
33
|
+
_ref$disabled = _ref.disabled,
|
|
34
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
35
|
+
_ref$className = _ref.className,
|
|
36
|
+
className = _ref$className === void 0 ? null : _ref$className,
|
|
37
|
+
_ref$onChange = _ref.onChange,
|
|
38
|
+
onChange = _ref$onChange === void 0 ? null : _ref$onChange,
|
|
53
39
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
54
40
|
var parseValue = useCallback(function (newValue) {
|
|
55
41
|
if (newValue !== null) {
|
|
@@ -74,7 +60,7 @@ var NumberField = function NumberField(_ref) {
|
|
|
74
60
|
}
|
|
75
61
|
onChange(val !== null && val.length > 0 ? parseValue(val) : null);
|
|
76
62
|
}
|
|
77
|
-
}, [onChange, _float]);
|
|
63
|
+
}, [onChange, _float, parseValue]);
|
|
78
64
|
|
|
79
65
|
// Datalist
|
|
80
66
|
|
|
@@ -98,7 +84,7 @@ var NumberField = function NumberField(_ref) {
|
|
|
98
84
|
onChange(parseValue(dataListValue));
|
|
99
85
|
setDataListActive(false);
|
|
100
86
|
}
|
|
101
|
-
}, [onChange, setDataListActive]);
|
|
87
|
+
}, [onChange, setDataListActive, parseValue]);
|
|
102
88
|
return /*#__PURE__*/React.createElement("div", {
|
|
103
89
|
className: classNames([styles.container, _defineProperty({}, className, className !== null)])
|
|
104
90
|
}, /*#__PURE__*/React.createElement(TextField, Object.assign({
|
|
@@ -132,9 +118,7 @@ var NumberField = function NumberField(_ref) {
|
|
|
132
118
|
}
|
|
133
119
|
}, dataListValue));
|
|
134
120
|
})) : null);
|
|
135
|
-
}
|
|
136
|
-
NumberField.propTypes = propTypes;
|
|
137
|
-
NumberField.defaultProps = defaultProps;
|
|
121
|
+
}
|
|
138
122
|
|
|
139
123
|
var definition = {
|
|
140
124
|
id: 'number',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/field-number",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "A number field",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@babel/runtime": "^7.12.5",
|
|
62
|
-
"@panneau/core": "^
|
|
63
|
-
"@panneau/element-icon": "^
|
|
64
|
-
"@panneau/field-text": "^
|
|
65
|
-
"@panneau/themes": "^
|
|
62
|
+
"@panneau/core": "^4.0.0",
|
|
63
|
+
"@panneau/element-icon": "^4.0.0",
|
|
64
|
+
"@panneau/field-text": "^4.0.0",
|
|
65
|
+
"@panneau/themes": "^4.0.0",
|
|
66
66
|
"classnames": "^2.5.1",
|
|
67
67
|
"lodash-es": "^4.17.21",
|
|
68
68
|
"prop-types": "^15.7.2"
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "2cca874e0388b4a20c39aadb205c0e67d5a946fc"
|
|
74
74
|
}
|