@invoicebox/ui 0.1.0-alpha.234 → 0.1.0-alpha.236
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.
|
@@ -151,7 +151,7 @@ var PhoneInput = exports.PhoneInput = function PhoneInput(_ref) {
|
|
|
151
151
|
var handlePaste = (0, _react.useCallback)(function (event) {
|
|
152
152
|
event.preventDefault();
|
|
153
153
|
var pasteText = event.clipboardData.getData('Text').trim();
|
|
154
|
-
handleInputValueChange(pasteText);
|
|
154
|
+
handleInputValueChange(pasteText, event);
|
|
155
155
|
}, [handleInputValueChange]);
|
|
156
156
|
var hasPureInputError = (0, _react.useMemo)(function () {
|
|
157
157
|
if (hasError) return true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TCountryRule, TCountrySelectOption, TSupportedCountries } from './types';
|
|
2
|
-
import { ChangeEvent } from 'react';
|
|
2
|
+
import { ChangeEvent, ClipboardEvent } from 'react';
|
|
3
3
|
export declare class PhoneInputLogic {
|
|
4
4
|
private isSupportCityRusPhoneNumber;
|
|
5
5
|
private allCountriesPhoneRules;
|
|
@@ -27,6 +27,6 @@ export declare class PhoneInputLogic {
|
|
|
27
27
|
getIsHaveStartSequenceInString(value: string, subsequence: string): boolean;
|
|
28
28
|
formatRusPhoneToUnifiedView(value: string, moveCaret?: (positionCaret: number) => void): string;
|
|
29
29
|
getOnlyNumbersFromString(value: string): string;
|
|
30
|
-
moveCaretByValue(event: ChangeEvent<HTMLInputElement>): (positionCaret: number) => void;
|
|
30
|
+
moveCaretByValue(event: ChangeEvent<HTMLInputElement> | ClipboardEvent<HTMLInputElement>): (positionCaret: number) => void;
|
|
31
31
|
getIsNeedChangeCountry(inputValue: string, currentCountry: TCountryRule, newCountry?: [string, TCountryRule]): boolean | "" | undefined;
|
|
32
32
|
}
|
|
@@ -113,13 +113,15 @@ var PhoneInputLogic = exports.PhoneInputLogic = /*#__PURE__*/function () {
|
|
|
113
113
|
if (value[0] === '8') {
|
|
114
114
|
result = "7".concat(value.slice(1));
|
|
115
115
|
}
|
|
116
|
+
if (value.length === 10 && value[0] !== '7' && (value[0] !== '8' || this.isSupportCityRusPhoneNumber && value[0] === '8')) {
|
|
117
|
+
result = "7".concat(value);
|
|
118
|
+
}
|
|
116
119
|
if (value[0] === '9') {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
120
|
+
result = "79".concat(value.slice(1));
|
|
121
|
+
}
|
|
122
|
+
if (moveCaret) {
|
|
123
|
+
// когда пользователь вводит номер с "9", мы подставляем в инпут "79", но каретка не переносится после "9" - также при вставке, нужно это делать вручную
|
|
124
|
+
moveCaret(this.getCaretPositionByRusValue(result));
|
|
123
125
|
}
|
|
124
126
|
return result;
|
|
125
127
|
}
|
|
@@ -136,7 +138,9 @@ var PhoneInputLogic = exports.PhoneInputLogic = /*#__PURE__*/function () {
|
|
|
136
138
|
value: function moveCaretByValue(event) {
|
|
137
139
|
return function (positionCaret) {
|
|
138
140
|
setTimeout(function () {
|
|
139
|
-
event.target
|
|
141
|
+
if ('setSelectionRange' in event.target) {
|
|
142
|
+
event.target.setSelectionRange(positionCaret, positionCaret);
|
|
143
|
+
}
|
|
140
144
|
}, 0);
|
|
141
145
|
};
|
|
142
146
|
}
|