@ornikar/kitt-universal 9.40.0 → 9.41.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/dist/definitions/forms/InputPhone/InputPhone.d.ts +8 -1
- package/dist/definitions/forms/InputPhone/InputPhone.d.ts.map +1 -1
- package/dist/index-browser-all.es.android.js +50 -6
- package/dist/index-browser-all.es.android.js.map +1 -1
- package/dist/index-browser-all.es.ios.js +50 -6
- package/dist/index-browser-all.es.ios.js.map +1 -1
- package/dist/index-browser-all.es.js +50 -6
- package/dist/index-browser-all.es.js.map +1 -1
- package/dist/index-browser-all.es.web.js +50 -6
- package/dist/index-browser-all.es.web.js.map +1 -1
- package/dist/index-node-14.17.cjs.js +50 -5
- package/dist/index-node-14.17.cjs.js.map +1 -1
- package/dist/index-node-14.17.cjs.web.js +50 -5
- package/dist/index-node-14.17.cjs.web.js.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +4 -3
|
@@ -12,6 +12,7 @@ const react$1 = require('@linaria/react');
|
|
|
12
12
|
const reactPortal = require('react-portal');
|
|
13
13
|
const reactTransitionGroup = require('react-transition-group');
|
|
14
14
|
const twemojiParser = require('twemoji-parser');
|
|
15
|
+
const libphonenumberJs = require('libphonenumber-js');
|
|
15
16
|
const reactNativeSafeAreaContext = require('react-native-safe-area-context');
|
|
16
17
|
const reactDom = require('@floating-ui/react-dom');
|
|
17
18
|
const usehooksTs = require('usehooks-ts');
|
|
@@ -3366,17 +3367,17 @@ function getReturnKeyTypeForNumericInput(returnKeyType) {
|
|
|
3366
3367
|
return returnKeyType;
|
|
3367
3368
|
}
|
|
3368
3369
|
|
|
3369
|
-
function prefixWithZero(value, maxLength = 2) {
|
|
3370
|
+
function prefixWithZero$1(value, maxLength = 2) {
|
|
3370
3371
|
return `${value}`.padStart(maxLength, '0');
|
|
3371
3372
|
}
|
|
3372
3373
|
function dayFormatter(day) {
|
|
3373
|
-
return prefixWithZero(day);
|
|
3374
|
+
return prefixWithZero$1(day);
|
|
3374
3375
|
}
|
|
3375
3376
|
function monthFormatter(month) {
|
|
3376
|
-
return prefixWithZero(month);
|
|
3377
|
+
return prefixWithZero$1(month);
|
|
3377
3378
|
}
|
|
3378
3379
|
function yearFormatter(year) {
|
|
3379
|
-
return prefixWithZero(year, 4);
|
|
3380
|
+
return prefixWithZero$1(year, 4);
|
|
3380
3381
|
}
|
|
3381
3382
|
|
|
3382
3383
|
function getDayInInterval(value) {
|
|
@@ -3980,19 +3981,63 @@ const InputPassword = /*#__PURE__*/react.forwardRef(({
|
|
|
3980
3981
|
});
|
|
3981
3982
|
});
|
|
3982
3983
|
|
|
3984
|
+
function isPhoneNumberValid(number) {
|
|
3985
|
+
return libphonenumberJs.isValidNumber(number);
|
|
3986
|
+
}
|
|
3987
|
+
function prefixWithZero(value, phoneNumberLength) {
|
|
3988
|
+
return value.padStart(phoneNumberLength, '0');
|
|
3989
|
+
}
|
|
3983
3990
|
const InputPhone = /*#__PURE__*/react.forwardRef(({
|
|
3984
3991
|
returnKeyType,
|
|
3985
3992
|
autoComplete = 'tel',
|
|
3993
|
+
phoneNumberLength = 10,
|
|
3994
|
+
value,
|
|
3995
|
+
onChange,
|
|
3986
3996
|
...props
|
|
3987
3997
|
}, ref) => {
|
|
3998
|
+
const [currentValue, setCurrentValue] = react.useState(value);
|
|
3988
3999
|
const currentReturnKeyType = returnKeyType ? getReturnKeyTypeForNumericInput(returnKeyType) : undefined;
|
|
3989
4000
|
return /*#__PURE__*/jsxRuntime.jsx(InputText, {
|
|
3990
4001
|
ref: ref,
|
|
3991
4002
|
...props,
|
|
4003
|
+
value: currentValue,
|
|
3992
4004
|
keyboardType: "phone-pad",
|
|
3993
4005
|
returnKeyType: currentReturnKeyType,
|
|
3994
4006
|
autoComplete: autoComplete,
|
|
3995
|
-
textContentType: "telephoneNumber"
|
|
4007
|
+
textContentType: "telephoneNumber",
|
|
4008
|
+
onChange: event => {
|
|
4009
|
+
const number = libphonenumberJs.parseNumber(event.nativeEvent.text);
|
|
4010
|
+
|
|
4011
|
+
// When intl phone number is valid :
|
|
4012
|
+
// 1 - We extract intl data
|
|
4013
|
+
// 2 - We recreate the local value to display
|
|
4014
|
+
if (isPhoneNumberValid(number)) {
|
|
4015
|
+
const {
|
|
4016
|
+
phone
|
|
4017
|
+
} = number;
|
|
4018
|
+
const finalPhoneNumber = prefixWithZero(`${phone || ''}`, phoneNumberLength);
|
|
4019
|
+
const eventWithoutCountryCode = {
|
|
4020
|
+
...event,
|
|
4021
|
+
nativeEvent: {
|
|
4022
|
+
...event.nativeEvent,
|
|
4023
|
+
text: finalPhoneNumber
|
|
4024
|
+
}
|
|
4025
|
+
};
|
|
4026
|
+
setCurrentValue(finalPhoneNumber);
|
|
4027
|
+
if (onChange) {
|
|
4028
|
+
onChange(eventWithoutCountryCode, {
|
|
4029
|
+
...number,
|
|
4030
|
+
countryCode: libphonenumberJs.getCountryCallingCode(number.country),
|
|
4031
|
+
originalNativeEventText: event.nativeEvent.text
|
|
4032
|
+
});
|
|
4033
|
+
}
|
|
4034
|
+
return;
|
|
4035
|
+
}
|
|
4036
|
+
|
|
4037
|
+
// Value is correctly parsed but might not pass validation
|
|
4038
|
+
setCurrentValue(event.nativeEvent.text);
|
|
4039
|
+
if (onChange) onChange(event);
|
|
4040
|
+
}
|
|
3996
4041
|
});
|
|
3997
4042
|
});
|
|
3998
4043
|
|