diginet-core-ui 1.3.59 → 1.3.60
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/components/form-control/number-input/index2.js +21 -14
- package/icons/basic.js +45 -49
- package/package.json +1 -1
- package/readme.md +5 -0
|
@@ -15,6 +15,7 @@ const NumberInputRoot = css`
|
|
|
15
15
|
margin-bottom: 20px;
|
|
16
16
|
`;
|
|
17
17
|
const regexValidNumber = /[^0-9.,-]/g;
|
|
18
|
+
const regexNumber = /[^0-9]/g;
|
|
18
19
|
const regexThousandNumber = /(\d)(?=(\d{3})+\b)/g;
|
|
19
20
|
const NumberInput = /*#__PURE__*/forwardRef(({
|
|
20
21
|
viewType,
|
|
@@ -43,12 +44,14 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
43
44
|
onChange,
|
|
44
45
|
onFocus,
|
|
45
46
|
onInput,
|
|
47
|
+
onBlur,
|
|
46
48
|
onKeyDown,
|
|
47
49
|
onKeyUp,
|
|
48
50
|
validates,
|
|
49
51
|
delayOnChange,
|
|
50
52
|
fixedDecimalDigit,
|
|
51
|
-
className
|
|
53
|
+
className,
|
|
54
|
+
maxDigit
|
|
52
55
|
}, reference) => {
|
|
53
56
|
inputRef = inputRef || useRef(null);
|
|
54
57
|
const pos = useRef(null);
|
|
@@ -164,6 +167,8 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
164
167
|
});
|
|
165
168
|
}
|
|
166
169
|
}
|
|
170
|
+
|
|
171
|
+
onBlur && onBlur(e);
|
|
167
172
|
};
|
|
168
173
|
|
|
169
174
|
const _onKeyDown = e => {
|
|
@@ -184,11 +189,8 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
184
189
|
|
|
185
190
|
const isNumber = keyCode >= 48 && keyCode <= 57 && shiftKey === false || keyCode >= 96 && keyCode <= 105 || keyCode === 231 && key >= '0' && key <= '9'; // character input type="number"
|
|
186
191
|
|
|
187
|
-
|
|
188
|
-
keyCode > 34 && keyCode < 40 || keyCode ===
|
|
189
|
-
keyCode === 231 && key === '.' || // .
|
|
190
|
-
keyCode === 188 || // ,
|
|
191
|
-
(ctrlKey || metaKey) && (keyCode === 65 || keyCode === 67 || keyCode === 86) || // ctrl + A, ctrl + C, ctrl + V
|
|
192
|
+
let allowKeyTypeNumber = isNumber || keyCode === 8 || // key backspace
|
|
193
|
+
keyCode > 34 && keyCode < 40 || key === thousandSymbol || key === decimalSymbol || (ctrlKey || metaKey) && (keyCode === 65 || keyCode === 67 || keyCode === 86) || // ctrl + A, ctrl + C, ctrl + V
|
|
192
194
|
keyCode === 46 || // key delete
|
|
193
195
|
keyCode === 189 || keyCode === 109 || // -
|
|
194
196
|
keyCode === 9; // tab
|
|
@@ -197,13 +199,10 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
197
199
|
const removeDot = keyCode === 8 && selectionEnd - selectionStart <= 1 && value.charAt(selectionEnd - 1) === thousandSymbol; // Decimal
|
|
198
200
|
// Do not allow the character decimal if decimalDigit is undefined
|
|
199
201
|
|
|
200
|
-
const isDecimalSymbol = decimalSymbol ===
|
|
202
|
+
const isDecimalSymbol = decimalSymbol === key;
|
|
201
203
|
const disabledDecimalSymbol = isDecimalSymbol && !decimalDigit; // Accepts only one decimal separator
|
|
202
204
|
|
|
203
|
-
const decimalExists = value.includes(decimalSymbol) && isDecimalSymbol; //
|
|
204
|
-
|
|
205
|
-
const isThousandSymbol = (!thousandSymbol || thousandSymbol === '.') && (keyCode === 190 || keyCode === 110) || thousandSymbol === ',' && keyCode === 188;
|
|
206
|
-
const disabledThousandSymbol = isThousandSymbol; // Disabled typing input when decimal digit to limit and focus is last
|
|
205
|
+
const decimalExists = value.includes(decimalSymbol) && isDecimalSymbol; // Disabled typing input when decimal digit to limit and focus is last
|
|
207
206
|
|
|
208
207
|
const disabledTypingDecimal = ((_value$split = value.split(decimalSymbol)) === null || _value$split === void 0 ? void 0 : (_value$split$ = _value$split[1]) === null || _value$split$ === void 0 ? void 0 : _value$split$.length) >= decimalDigit && // total number after decimal symbol > {decimalDigit}
|
|
209
208
|
selectionStart === value.length; // the focus is at the end of the string
|
|
@@ -229,9 +228,11 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
229
228
|
} // disabled negative
|
|
230
229
|
|
|
231
230
|
|
|
232
|
-
const disabled180 = (keyCode === 189 || keyCode === 109) && (disabledNegative || value.includes('-')); //
|
|
231
|
+
const disabled180 = (keyCode === 189 || keyCode === 109) && (disabledNegative || value.includes('-')); // disabled max digit
|
|
232
|
+
|
|
233
|
+
const isMaxDigit = maxDigit && (value === null || value === void 0 ? void 0 : value.replace(regexNumber, '').length) === maxDigit && (isNumber || key === thousandSymbol || key === decimalSymbol) && selectionStart === selectionEnd; // Block event if include conditions
|
|
233
234
|
|
|
234
|
-
if (decimalExists ||
|
|
235
|
+
if (decimalExists || removeDot || isNumber && disabledTypingDecimal || disabledDecimalSymbol || !allowKeyTypeNumber || disabled180 || isMaxDigit) {
|
|
235
236
|
e.preventDefault();
|
|
236
237
|
}
|
|
237
238
|
|
|
@@ -415,6 +416,9 @@ NumberInput.propTypes = {
|
|
|
415
416
|
/** on focus function */
|
|
416
417
|
onFocus: PropTypes.func,
|
|
417
418
|
|
|
419
|
+
/** on blur function */
|
|
420
|
+
onBlur: PropTypes.func,
|
|
421
|
+
|
|
418
422
|
/** inputRef of NumberInput component */
|
|
419
423
|
inputRef: PropTypes.any,
|
|
420
424
|
|
|
@@ -428,6 +432,9 @@ NumberInput.propTypes = {
|
|
|
428
432
|
thousandSeparator: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['.', ','])]),
|
|
429
433
|
|
|
430
434
|
/** className of component */
|
|
431
|
-
className: PropTypes.string
|
|
435
|
+
className: PropTypes.string,
|
|
436
|
+
|
|
437
|
+
/** max character is number of NumberInput component */
|
|
438
|
+
maxDigit: PropTypes.number
|
|
432
439
|
};
|
|
433
440
|
export default NumberInput;
|
package/icons/basic.js
CHANGED
|
@@ -3720,34 +3720,6 @@ export const NotificationV2 = /*#__PURE__*/memo(({
|
|
|
3720
3720
|
fill: colors[color] || color
|
|
3721
3721
|
}));
|
|
3722
3722
|
});
|
|
3723
|
-
export const Pin = /*#__PURE__*/memo(({
|
|
3724
|
-
width,
|
|
3725
|
-
height,
|
|
3726
|
-
color = '#7F828E',
|
|
3727
|
-
viewBox = false
|
|
3728
|
-
}) => {
|
|
3729
|
-
if (viewBox) {
|
|
3730
|
-
return /*#__PURE__*/React.createElement("svg", {
|
|
3731
|
-
width: width || 24,
|
|
3732
|
-
height: height || 24,
|
|
3733
|
-
viewBox: "0 0 24 24",
|
|
3734
|
-
fill: "none"
|
|
3735
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
3736
|
-
d: "M13.7484 4H10.2395C9.714 4 9.2855 4.44029 9.2855 4.98442C9.2855 5.24611 9.38656 5.49533 9.56443 5.67809C9.69783 5.81101 9.86357 5.90239 10.0414 5.94393L9.714 10.4216C9.3623 10.5545 9.03487 10.7622 8.76402 11.0405C8.27489 11.5472 8 12.2326 8 12.9429C8 13.4621 8.41233 13.8858 8.91764 13.8858H11.0278L12.002 20L12.9722 13.8858H15.0824C15.5877 13.8858 16 13.4621 16 12.9429C16 12.2285 15.7251 11.5472 15.2319 11.0447C14.9611 10.7664 14.6377 10.5587 14.282 10.4258L13.9505 5.93977C14.1283 5.90239 14.2941 5.81101 14.4275 5.67394C14.6054 5.49117 14.7064 5.2378 14.7064 4.98027C14.7064 4.44029 14.2779 4 13.7484 4Z",
|
|
3737
|
-
fill: colors[color] || color
|
|
3738
|
-
}));
|
|
3739
|
-
}
|
|
3740
|
-
|
|
3741
|
-
return /*#__PURE__*/React.createElement("svg", {
|
|
3742
|
-
width: width || 8,
|
|
3743
|
-
height: height || 16,
|
|
3744
|
-
viewBox: "0 0 8 16",
|
|
3745
|
-
fill: "none"
|
|
3746
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
3747
|
-
d: "M5.74836 0H2.23951C1.714 0 1.2855 0.440291 1.2855 0.984424C1.2855 1.24611 1.38656 1.49533 1.56443 1.67809C1.69783 1.81101 1.86357 1.90239 2.04144 1.94393L1.714 6.4216C1.3623 6.55452 1.03487 6.7622 0.764022 7.0405C0.274886 7.54725 0 8.23261 0 8.94289C0 9.4621 0.412329 9.88577 0.917635 9.88577H3.02779L4.00202 16L4.97221 9.88577H7.08236C7.58767 9.88577 8 9.4621 8 8.94289C8 8.22845 7.72511 7.54725 7.23193 7.04465C6.96109 6.76636 6.6377 6.55867 6.28196 6.42575L5.95048 1.93977C6.12835 1.90239 6.29409 1.81101 6.42749 1.67394C6.60536 1.49117 6.70642 1.2378 6.70642 0.98027C6.70642 0.440291 6.27792 0 5.74836 0Z",
|
|
3748
|
-
fill: colors[color] || color
|
|
3749
|
-
}));
|
|
3750
|
-
});
|
|
3751
3723
|
export const Unlock = /*#__PURE__*/memo(({
|
|
3752
3724
|
width,
|
|
3753
3725
|
height,
|
|
@@ -3786,31 +3758,27 @@ export const UnPin = /*#__PURE__*/memo(({
|
|
|
3786
3758
|
color = '#7F828E',
|
|
3787
3759
|
viewBox = false
|
|
3788
3760
|
}) => {
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
return /*#__PURE__*/React.createElement("svg", {
|
|
3805
|
-
width: width || 12,
|
|
3806
|
-
height: height || 16,
|
|
3807
|
-
viewBox: "0 0 12 16",
|
|
3761
|
+
return viewBox ? /*#__PURE__*/React.createElement("svg", {
|
|
3762
|
+
width: width || 24,
|
|
3763
|
+
height: height || 24,
|
|
3764
|
+
viewBox: "0 0 24 24",
|
|
3765
|
+
fill: "none"
|
|
3766
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
3767
|
+
d: "M3.41421 1.41406L2 2.82828L8 8.82828V8.99991C8 10.6599 6.66 11.9999 5 11.9999V13.9999H10.97V20.9999L11.97 21.9999L12.97 20.9999V13.9999H13.1716L20.3848 21.2131L21.799 19.7988L3.41421 1.41406Z",
|
|
3768
|
+
fill: colors[color] || color
|
|
3769
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
3770
|
+
d: "M19 13.9999H18.8284L6.84113 2.0126C6.8929 2.00425 6.94597 1.99991 7 1.99991H17C17.55 1.99991 18 2.44991 18 2.99991C18 3.54991 17.55 3.99991 17 3.99991H16V8.99991C16 10.6599 17.34 11.9999 19 11.9999V13.9999Z",
|
|
3771
|
+
fill: colors[color] || color
|
|
3772
|
+
})) : /*#__PURE__*/React.createElement("svg", {
|
|
3773
|
+
width: width || 20,
|
|
3774
|
+
height: height || 21,
|
|
3775
|
+
viewBox: "0 0 20 21",
|
|
3808
3776
|
fill: "none"
|
|
3809
3777
|
}, /*#__PURE__*/React.createElement("path", {
|
|
3810
|
-
d: "
|
|
3778
|
+
d: "M1.41421 0.414062L0 1.82828L6 7.82828V7.99991C6 9.65991 4.66 10.9999 3 10.9999V12.9999H8.97V19.9999L9.97 20.9999L10.97 19.9999V12.9999H11.1716L18.3848 20.2131L19.799 18.7988L1.41421 0.414062Z",
|
|
3811
3779
|
fill: colors[color] || color
|
|
3812
3780
|
}), /*#__PURE__*/React.createElement("path", {
|
|
3813
|
-
d: "
|
|
3781
|
+
d: "M17 12.9999H16.8284L4.84113 1.0126C4.8929 1.00425 4.94597 0.999907 5 0.999907H15C15.55 0.999907 16 1.44991 16 1.99991C16 2.54991 15.55 2.99991 15 2.99991H14V7.99991C14 9.65991 15.34 10.9999 17 10.9999V12.9999Z",
|
|
3814
3782
|
fill: colors[color] || color
|
|
3815
3783
|
}));
|
|
3816
3784
|
});
|
|
@@ -4400,6 +4368,34 @@ export const Photo = /*#__PURE__*/memo(({
|
|
|
4400
4368
|
fill: colors[color] || color
|
|
4401
4369
|
}));
|
|
4402
4370
|
});
|
|
4371
|
+
export const Pin = /*#__PURE__*/memo(({
|
|
4372
|
+
width,
|
|
4373
|
+
height,
|
|
4374
|
+
color = '#7F828E',
|
|
4375
|
+
viewBox = false
|
|
4376
|
+
}) => {
|
|
4377
|
+
return viewBox ? /*#__PURE__*/React.createElement("svg", {
|
|
4378
|
+
width: width || 24,
|
|
4379
|
+
height: height || 24,
|
|
4380
|
+
viewBox: "0 0 24 24",
|
|
4381
|
+
fill: "none"
|
|
4382
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
4383
|
+
fillRule: "evenodd",
|
|
4384
|
+
clipRule: "evenodd",
|
|
4385
|
+
d: "M16 9V4H17C17.55 4 18 3.55 18 3C18 2.45 17.55 2 17 2H7C6.45 2 6 2.45 6 3C6 3.55 6.45 4 7 4H8V9C8 10.66 6.66 12 5 12V14H10.97V21L11.97 22L12.97 21V14H19V12C17.34 12 16 10.66 16 9Z",
|
|
4386
|
+
fill: colors[color] || color
|
|
4387
|
+
})) : /*#__PURE__*/React.createElement("svg", {
|
|
4388
|
+
width: width || 14,
|
|
4389
|
+
height: height || 20,
|
|
4390
|
+
viewBox: "0 0 14 20",
|
|
4391
|
+
fill: "none"
|
|
4392
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
4393
|
+
fillRule: "evenodd",
|
|
4394
|
+
clipRule: "evenodd",
|
|
4395
|
+
d: "M11 7V2H12C12.55 2 13 1.55 13 1C13 0.45 12.55 0 12 0H2C1.45 0 1 0.45 1 1C1 1.55 1.45 2 2 2H3V7C3 8.66 1.66 10 0 10V12H5.97V19L6.97 20L7.97 19V12H14V10C12.34 10 11 8.66 11 7Z",
|
|
4396
|
+
fill: colors[color] || color
|
|
4397
|
+
}));
|
|
4398
|
+
});
|
|
4403
4399
|
export const PlanePaper = /*#__PURE__*/memo(({
|
|
4404
4400
|
width,
|
|
4405
4401
|
height,
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -38,6 +38,11 @@ npm test
|
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Changelog
|
|
41
|
+
## 1.3.60
|
|
42
|
+
- \[Added\]: NumberInput – Add props maxDigit
|
|
43
|
+
- \[Changed\]: Icon – Pin, UnPin
|
|
44
|
+
- \[Fixed\]: NumberInput – Fix bug decimalSymbol
|
|
45
|
+
|
|
41
46
|
## 1.3.59
|
|
42
47
|
- \[Added\]: Icon – Export component Icon
|
|
43
48
|
- \[Added\]: Icon – Groups, Photo
|