@alfalab/core-components-intl-phone-input 10.0.1 → 10.0.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/component.d.ts +4 -4
- package/component.js +6 -5
- package/component.js.map +1 -1
- package/components/flag-icon/component.d.ts +1 -1
- package/components/flag-icon/component.js.map +1 -1
- package/components/flag-icon/index.css +2 -2
- package/components/flag-icon/index.module.css.js +1 -1
- package/components/flag-icon/index.module.css.js.map +1 -1
- package/components/select/component.d.ts +3 -3
- package/components/select/component.js.map +1 -1
- package/components/select/index.css +5 -5
- package/components/select/index.module.css.js +1 -1
- package/components/select/index.module.css.js.map +1 -1
- package/components/select-field/component.d.ts +2 -2
- package/components/select-field/component.js.map +1 -1
- package/components/select-field/index.css +8 -8
- package/components/select-field/index.module.css.js +1 -1
- package/components/select-field/index.module.css.js.map +1 -1
- package/cssm/component.d.ts +4 -4
- package/cssm/component.js +6 -5
- package/cssm/component.js.map +1 -1
- package/cssm/components/flag-icon/component.d.ts +1 -1
- package/cssm/components/flag-icon/component.js.map +1 -1
- package/cssm/components/select/component.d.ts +3 -3
- package/cssm/components/select/component.js.map +1 -1
- package/cssm/components/select-field/component.d.ts +2 -2
- package/cssm/components/select-field/component.js.map +1 -1
- package/cssm/useCaretAvoidCountryCode.d.ts +1 -1
- package/cssm/useCaretAvoidCountryCode.js.map +1 -1
- package/cssm/utils/format-phone-with-unclearable-country-code.d.ts +1 -1
- package/cssm/utils/format-phone-with-unclearable-country-code.js.map +1 -1
- package/esm/component.d.ts +4 -4
- package/esm/component.js +6 -5
- package/esm/component.js.map +1 -1
- package/esm/components/flag-icon/component.d.ts +1 -1
- package/esm/components/flag-icon/component.js.map +1 -1
- package/esm/components/flag-icon/index.css +2 -2
- package/esm/components/flag-icon/index.module.css.js +1 -1
- package/esm/components/flag-icon/index.module.css.js.map +1 -1
- package/esm/components/select/component.d.ts +3 -3
- package/esm/components/select/component.js.map +1 -1
- package/esm/components/select/index.css +5 -5
- package/esm/components/select/index.module.css.js +1 -1
- package/esm/components/select/index.module.css.js.map +1 -1
- package/esm/components/select-field/component.d.ts +2 -2
- package/esm/components/select-field/component.js.map +1 -1
- package/esm/components/select-field/index.css +8 -8
- package/esm/components/select-field/index.module.css.js +1 -1
- package/esm/components/select-field/index.module.css.js.map +1 -1
- package/esm/index.css +4 -4
- package/esm/index.module.css.js +1 -1
- package/esm/index.module.css.js.map +1 -1
- package/esm/useCaretAvoidCountryCode.d.ts +1 -1
- package/esm/useCaretAvoidCountryCode.js.map +1 -1
- package/esm/utils/format-phone-with-unclearable-country-code.d.ts +1 -1
- package/esm/utils/format-phone-with-unclearable-country-code.js.map +1 -1
- package/index.css +4 -4
- package/index.module.css.js +1 -1
- package/index.module.css.js.map +1 -1
- package/modern/component.d.ts +4 -4
- package/modern/component.js +1 -1
- package/modern/component.js.map +1 -1
- package/modern/components/flag-icon/component.d.ts +1 -1
- package/modern/components/flag-icon/component.js.map +1 -1
- package/modern/components/flag-icon/index.css +2 -2
- package/modern/components/flag-icon/index.module.css.js +1 -1
- package/modern/components/flag-icon/index.module.css.js.map +1 -1
- package/modern/components/select/component.d.ts +3 -3
- package/modern/components/select/component.js.map +1 -1
- package/modern/components/select/index.css +5 -5
- package/modern/components/select/index.module.css.js +1 -1
- package/modern/components/select/index.module.css.js.map +1 -1
- package/modern/components/select-field/component.d.ts +2 -2
- package/modern/components/select-field/component.js.map +1 -1
- package/modern/components/select-field/index.css +8 -8
- package/modern/components/select-field/index.module.css.js +1 -1
- package/modern/components/select-field/index.module.css.js.map +1 -1
- package/modern/index.css +4 -4
- package/modern/index.module.css.js +1 -1
- package/modern/index.module.css.js.map +1 -1
- package/modern/useCaretAvoidCountryCode.d.ts +1 -1
- package/modern/useCaretAvoidCountryCode.js.map +1 -1
- package/modern/utils/format-phone-with-unclearable-country-code.d.ts +1 -1
- package/modern/utils/format-phone-with-unclearable-country-code.js.map +1 -1
- package/moderncssm/component.d.ts +4 -4
- package/moderncssm/component.js +1 -1
- package/moderncssm/component.js.map +1 -1
- package/moderncssm/components/flag-icon/component.d.ts +1 -1
- package/moderncssm/components/flag-icon/component.js.map +1 -1
- package/moderncssm/components/flag-icon/index.module.css +2 -0
- package/moderncssm/components/select/component.d.ts +3 -3
- package/moderncssm/components/select/component.js.map +1 -1
- package/moderncssm/components/select/index.module.css +2 -0
- package/moderncssm/components/select-field/component.d.ts +2 -2
- package/moderncssm/components/select-field/component.js.map +1 -1
- package/moderncssm/components/select-field/index.module.css +2 -0
- package/moderncssm/index.module.css +2 -0
- package/moderncssm/useCaretAvoidCountryCode.d.ts +1 -1
- package/moderncssm/useCaretAvoidCountryCode.js.map +1 -1
- package/moderncssm/utils/format-phone-with-unclearable-country-code.d.ts +1 -1
- package/moderncssm/utils/format-phone-with-unclearable-country-code.js.map +1 -1
- package/package.json +4 -4
- package/src/component.tsx +6 -8
- package/src/components/flag-icon/component.tsx +1 -1
- package/src/components/flag-icon/index.module.css +1 -1
- package/src/components/select/component.tsx +4 -4
- package/src/components/select/index.module.css +1 -1
- package/src/components/select-field/component.tsx +2 -2
- package/src/components/select-field/index.module.css +1 -1
- package/src/index.module.css +1 -1
- package/src/useCaretAvoidCountryCode.ts +1 -1
- package/src/utils/format-phone-with-unclearable-country-code.ts +1 -1
- package/useCaretAvoidCountryCode.d.ts +1 -1
- package/useCaretAvoidCountryCode.js.map +1 -1
- package/utils/format-phone-with-unclearable-country-code.d.ts +1 -1
- package/utils/format-phone-with-unclearable-country-code.js.map +1 -1
package/component.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { CountryCode } from 'libphonenumber-js/min';
|
|
3
|
-
import { InputAutocompleteDesktopProps } from '@alfalab/core-components-input-autocomplete/desktop';
|
|
4
|
-
import type
|
|
5
|
-
import { Country } from '@alfalab/utils';
|
|
2
|
+
import { type CountryCode } from 'libphonenumber-js/min';
|
|
3
|
+
import { type InputAutocompleteDesktopProps } from '@alfalab/core-components-input-autocomplete/desktop';
|
|
4
|
+
import { type SelectProps } from '@alfalab/core-components-select';
|
|
5
|
+
import { type Country } from '@alfalab/utils';
|
|
6
6
|
declare type MaxPhoneLenByCountry = Record<string, number>;
|
|
7
7
|
export declare type IntlPhoneInputProps = Partial<Omit<InputAutocompleteDesktopProps, 'onChange'>> & Pick<SelectProps, 'preventFlip'> & {
|
|
8
8
|
/**
|
package/component.js
CHANGED
|
@@ -53,11 +53,12 @@ var DEFAULT_MAX_PHONE_LEN_BY_COUNTRY = { RU: 11 };
|
|
|
53
53
|
* use InternationalPhoneInput instead
|
|
54
54
|
*/
|
|
55
55
|
var IntlPhoneInput = React.forwardRef(function (_a, ref) {
|
|
56
|
-
var _b
|
|
57
|
-
var
|
|
56
|
+
var _b;
|
|
57
|
+
var _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.readOnly, readOnly = _d === void 0 ? false : _d, _e = _a.hideCountrySelect, hideCountrySelect = _e === void 0 ? false : _e, _f = _a.canBeEmptyCountry, canBeEmptyCountry = _f === void 0 ? false : _f, _g = _a.ruNumberPriority, ruNumberPriority = _g === void 0 ? false : _g, _h = _a.clear, clear = _h === void 0 ? false : _h, _j = _a.size, size = _j === void 0 ? 'm' : _j, _k = _a.colors, colors = _k === void 0 ? 'default' : _k, _l = _a.options, options = _l === void 0 ? [] : _l, _m = _a.countries, countries = _m === void 0 ? utils.getCountries() : _m, _o = _a.clearableCountryCode, clearableCountryCode = _o === void 0 ? true : _o, _p = _a.maxDialCodeLength, maxDialCodeLength = _p === void 0 ? MAX_DIAL_CODE_LENGTH : _p, className = _a.className, value = _a.value, onChange = _a.onChange, onCountryChange = _a.onCountryChange, _q = _a.defaultCountryIso2, defaultCountryIso2 = _q === void 0 ? 'ru' : _q, preventFlip = _a.preventFlip, inputProps = _a.inputProps, _r = _a.maxPhoneLen, maxPhoneLen = _r === void 0 ? DEFAULT_MAX_PHONE_LEN_BY_COUNTRY : _r, restProps = tslib.__rest(_a, ["disabled", "readOnly", "hideCountrySelect", "canBeEmptyCountry", "ruNumberPriority", "clear", "size", "colors", "options", "countries", "clearableCountryCode", "maxDialCodeLength", "className", "value", "onChange", "onCountryChange", "defaultCountryIso2", "preventFlip", "inputProps", "maxPhoneLen"]);
|
|
58
|
+
var _s = React.useState(defaultCountryIso2.toLowerCase()), countryIso2 = _s[0], setCountryIso2 = _s[1];
|
|
58
59
|
var inputRef = React.useRef(null);
|
|
59
|
-
var
|
|
60
|
-
var
|
|
60
|
+
var _t = React.useState(null), inputWrapperRef = _t[0], setInputWrapperRef = _t[1];
|
|
61
|
+
var _u = React.useState(), caretPos = _u[0], setCaretPos = _u[1];
|
|
61
62
|
var phoneLibUtils = React.useRef();
|
|
62
63
|
var formatPhone = function (inputValue, iso2) {
|
|
63
64
|
if (iso2 === void 0) { iso2 = countryIso2; }
|
|
@@ -345,7 +346,7 @@ var IntlPhoneInput = React.forwardRef(function (_a, ref) {
|
|
|
345
346
|
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
|
346
347
|
}, [value, canBeEmptyCountry, countryIso2, defaultCountryIso2]);
|
|
347
348
|
useCaretAvoidCountryCode.useCaretAvoidCountryCode({ inputRef: inputRef, countryCodeLength: countryCodeLength, clearableCountryCode: clearableCountryCode });
|
|
348
|
-
return (React__default.default.createElement(desktop.InputAutocompleteDesktop, tslib.__assign({}, restProps, { ref: ref, inputProps: tslib.__assign(tslib.__assign({ clear: clear && !isEmptyValue }, inputProps), { onClear: handleClear, ref: inputRef, wrapperRef: setInputWrapperRef, type: 'tel', colors: colors, className: cn__default.default(className, index_module[size]), addonsClassName: index_module.addons, onKeyDown: handleKeyDown, onPaste: handlePaste, leftAddons: hideCountrySelect ? (React__default.default.createElement("span", { className: index_module.flagIconWrapper }, countryIso2 ? (React__default.default.createElement(component.FlagIcon, { country: countryIso2 })) : (React__default.default.createElement(WorldMagnifierMIcon__default.default, { className: index_module.emptyCountryIcon })))) : (countries.length > 1 && (React__default.default.createElement(component$1.CountriesSelect, { dataTestId: 'countries-select', disabled: disabled || readOnly, size: size, selected: countryIso2, countries: countries, onChange: handleSelectChange, fieldWidth: inputWrapperRef
|
|
349
|
+
return (React__default.default.createElement(desktop.InputAutocompleteDesktop, tslib.__assign({}, restProps, { ref: ref, inputProps: tslib.__assign(tslib.__assign({ clear: clear && !isEmptyValue }, inputProps), { onClear: handleClear, ref: inputRef, wrapperRef: setInputWrapperRef, type: 'tel', colors: colors, className: cn__default.default(className, index_module[size]), addonsClassName: index_module.addons, onKeyDown: handleKeyDown, onPaste: handlePaste, leftAddons: hideCountrySelect ? (React__default.default.createElement("span", { className: index_module.flagIconWrapper }, countryIso2 ? (React__default.default.createElement(component.FlagIcon, { country: countryIso2 })) : (React__default.default.createElement(WorldMagnifierMIcon__default.default, { className: index_module.emptyCountryIcon })))) : (countries.length > 1 && (React__default.default.createElement(component$1.CountriesSelect, { dataTestId: 'countries-select', disabled: disabled || readOnly, size: size, selected: countryIso2, countries: countries, onChange: handleSelectChange, fieldWidth: (_b = inputWrapperRef === null || inputWrapperRef === void 0 ? void 0 : inputWrapperRef.getBoundingClientRect().width) !== null && _b !== void 0 ? _b : null, preventFlip: preventFlip }))) }), optionsListWidth: 'field', closeOnSelect: true, onInput: handleInputChange, onChange: handleChange, options: options, disabled: disabled, readOnly: readOnly, size: size, className: className, value: value })));
|
|
349
350
|
});
|
|
350
351
|
|
|
351
352
|
exports.IntlPhoneInput = IntlPhoneInput;
|
package/component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["src/component.tsx"],"sourcesContent":["import React, { forwardRef, useEffect, useRef, useState } from 'react';\nimport cn from 'classnames';\nimport { AsYouType, CountryCode } from 'libphonenumber-js/min';\n\nimport {\n InputAutocompleteDesktop,\n InputAutocompleteDesktopProps,\n} from '@alfalab/core-components-input-autocomplete/desktop';\nimport type { SelectProps } from '@alfalab/core-components-select';\nimport type { OptionShape } from '@alfalab/core-components-select/shared';\nimport WorldMagnifierMIcon from '@alfalab/icons-glyph/WorldMagnifierMIcon';\nimport { Country, getCountries, getCountriesHash } from '@alfalab/utils';\n\nimport { calculateCaretPos } from './utils/calculateCaretPos';\nimport { formatPhoneWithUnclearableCountryCode } from './utils/format-phone-with-unclearable-country-code';\nimport { preparePasteData } from './utils/preparePasteData';\nimport { CountriesSelect, FlagIcon } from './components';\nimport { useCaretAvoidCountryCode } from './useCaretAvoidCountryCode';\n\nimport styles from './index.module.css';\n\nconst countriesHash = getCountriesHash();\n\nconst MAX_DIAL_CODE_LENGTH = 4;\n\nconst MASK_SYMBOLS = [' ', '-', '(', ')'];\n\nconst MAX_PHONE_LEN = 15;\n\nconst DEFAULT_MAX_PHONE_LEN_BY_COUNTRY: MaxPhoneLenByCountry = { RU: 11 };\n\ntype MaxPhoneLenByCountry = Record<string, number>;\n\nexport type IntlPhoneInputProps = Partial<Omit<InputAutocompleteDesktopProps, 'onChange'>> &\n Pick<SelectProps, 'preventFlip'> & {\n /**\n * Значение\n */\n value: string;\n\n /**\n * Набор цветов для компонента\n */\n colors?: 'default' | 'inverted';\n\n /**\n * Обработчик события изменения значения\n */\n onChange: (value: string) => void;\n\n /**\n * Дефолтный код страны\n */\n defaultCountryIso2?: string;\n\n /**\n * Обработчик события изменения страны\n */\n onCountryChange?: (countryCode?: CountryCode) => void;\n\n /**\n * Список стран\n */\n countries?: Country[];\n\n /**\n * Максимальная длина кода страны\n */\n maxDialCodeLength?: number;\n\n /**\n * Возможность стереть код страны\n */\n clearableCountryCode?: boolean;\n\n /**\n * Ограничение длин вводимых номеров по странам.\n */\n maxPhoneLen?: MaxPhoneLenByCountry;\n\n /*\n * Отключает выбор страны через селект\n */\n hideCountrySelect?: boolean;\n\n /*\n * Разрешает состояние без выбранной страны\n */\n canBeEmptyCountry?: boolean;\n\n /*\n * Подставляет +7 при выбранной стране 'ru' и вводе первых цифр номера.\n * При canBeEmptyCountry - работает только с дефолтным значением 'ru'\n */\n ruNumberPriority?: boolean;\n\n /*\n * Разрешает очищать поле крестиком\n */\n clear?: boolean;\n };\n\n/**\n * @deprecated\n * use InternationalPhoneInput instead\n */\nexport const IntlPhoneInput = forwardRef<HTMLInputElement, IntlPhoneInputProps>(\n (\n {\n disabled = false,\n readOnly = false,\n hideCountrySelect = false,\n canBeEmptyCountry = false,\n ruNumberPriority = false,\n clear = false,\n size = 'm',\n colors = 'default',\n options = [],\n countries = getCountries(),\n clearableCountryCode = true,\n maxDialCodeLength = MAX_DIAL_CODE_LENGTH,\n className,\n value,\n onChange,\n onCountryChange,\n defaultCountryIso2 = 'ru',\n preventFlip,\n inputProps,\n maxPhoneLen = DEFAULT_MAX_PHONE_LEN_BY_COUNTRY,\n ...restProps\n },\n ref,\n ) => {\n const [countryIso2, setCountryIso2] = useState<string | undefined>(\n defaultCountryIso2.toLowerCase(),\n );\n\n const inputRef = useRef<HTMLInputElement>(null);\n const [inputWrapperRef, setInputWrapperRef] = useState<HTMLDivElement | null>(null);\n\n const [caretPos, setCaretPos] = useState<number>();\n\n const phoneLibUtils = useRef<typeof AsYouType>();\n\n const formatPhone = (inputValue: string, iso2 = countryIso2) => {\n let newValue = inputValue;\n\n if (phoneLibUtils.current) {\n const Utils = phoneLibUtils.current;\n const utils = new Utils(iso2 ? (iso2.toUpperCase() as CountryCode) : undefined);\n\n newValue = utils.input(inputValue);\n }\n\n if (iso2 === 'ru') {\n const parts = newValue.split(' ');\n\n newValue = parts.reduce((acc, part, index) => {\n if (index === 0) {\n return part;\n }\n if (index > 2) {\n return `${acc}-${part}`;\n }\n\n return `${acc} ${part}`;\n }, '');\n }\n\n return newValue;\n };\n\n const setCountryByIso2 = (iso2: string) => {\n const country = countriesHash[iso2];\n\n const inputValue = `+${country.dialCode}`;\n\n onChange(inputValue);\n setCountryIso2(country.iso2);\n\n return country;\n };\n\n const handleCountryChange = (countryCode?: string) => {\n if (onCountryChange) {\n onCountryChange(\n countryCode ? (countryCode.toUpperCase() as CountryCode) : undefined,\n );\n }\n };\n\n const getCountryByNumber = (inputValue: string) => {\n // dialcode казахстанских номеров совпадает с российскими, поэтому проверяем отдельно\n if (new RegExp('^\\\\+7(\\\\s)?7').test(inputValue)) {\n const kzCoutry = countries.find((item) => item.iso2 === 'kz');\n\n if (kzCoutry) {\n return kzCoutry;\n }\n }\n\n const targetCountry = countries.find((country) => {\n if (new RegExp(`^\\\\+${country.dialCode}`).test(inputValue)) {\n // Сначала проверяем, если приоритет не указан\n if (country.priority === undefined) {\n return true;\n }\n\n // Если страна уже была выставлена через селект, и коды совпадают\n if (countryIso2 === country.iso2 && countryIso2 !== 'kz') {\n return true;\n }\n\n // Если не совпадают - выбираем по приоритету\n if (country.priority === 0) {\n return true;\n }\n\n return false;\n }\n\n return false;\n });\n\n return targetCountry;\n };\n\n const changePhone = (phone: string, iso2?: string) => {\n const newValue = formatPhone(phone, iso2);\n\n if (newValue !== value) {\n onChange(newValue);\n }\n };\n\n const addCountryCode = (inputValue: string) => {\n if (clearableCountryCode || !countryIso2) {\n return inputValue.length === 1 && inputValue !== '+'\n ? `+${inputValue}`\n : inputValue;\n }\n const country = countriesHash[countryIso2];\n\n return formatPhoneWithUnclearableCountryCode(inputValue, country);\n };\n\n const setCountryByDialCode = (inputValue: string) => {\n const country = getCountryByNumber(inputValue);\n\n changePhone(addCountryCode(inputValue), country?.iso2);\n if (country) {\n setCountryIso2(country.iso2);\n handleCountryChange(country.iso2);\n } else if (canBeEmptyCountry) {\n setCountryIso2(undefined);\n handleCountryChange(undefined);\n }\n };\n\n const setCountryByDialCodeWithLengthCheck = (inputValue: string) => {\n if (inputRef.current) {\n const { selectionStart } = inputRef.current;\n\n if ((selectionStart || 0) <= maxDialCodeLength) {\n setCountryByDialCode(inputValue);\n }\n }\n };\n\n const handleInputChange: InputAutocompleteDesktopProps['onInput'] = (newValue) => {\n setCountryByDialCodeWithLengthCheck(newValue);\n changePhone(addCountryCode(newValue));\n };\n\n const handleSelectChange: Required<SelectProps>['onChange'] = ({ selected }) => {\n if (selected) {\n const country = setCountryByIso2(selected.value);\n const inputValue = `+${country.dialCode}`;\n\n if (inputRef.current) {\n inputRef.current.focus();\n inputRef.current.setSelectionRange(inputValue.length, inputValue.length);\n }\n\n handleCountryChange(country.iso2);\n }\n };\n\n const handleChange = (payload: {\n selected: OptionShape | null;\n selectedMultiple: OptionShape[];\n name?: string;\n }) => {\n const { selected } = payload;\n\n if (!selected) return;\n setCountryByDialCodeWithLengthCheck(selected.key);\n changePhone(selected.key);\n };\n\n const country = countryIso2 && countriesHash[countryIso2];\n const countryCodeLength = country ? `+${country.dialCode}`.length : 0;\n const isEmptyValue = clearableCountryCode\n ? value === '' || value === '+'\n : value.length <= countryCodeLength;\n\n const handleInputNewChar = (\n event: React.KeyboardEvent<HTMLInputElement>,\n caretPosition: number,\n ) => {\n const input = event.target as HTMLInputElement;\n const currentValue = input.value;\n const maxPhoneLength =\n (countryIso2 && maxPhoneLen?.[countryIso2.toUpperCase()]) || MAX_PHONE_LEN;\n // Если номер полностью заполнен, то перезатираем цифры, если каретка не в самом конце.\n const shouldReplace = maxPhoneLength === currentValue.replace(/\\D/g, '').length;\n\n let endPhonePart = currentValue.slice(caretPosition);\n\n if (shouldReplace) {\n let cursor = 0;\n\n while (MASK_SYMBOLS.includes(endPhonePart.charAt(cursor))) {\n cursor += 1;\n }\n\n endPhonePart = endPhonePart.slice(cursor + 1);\n }\n\n let newValue = currentValue.slice(0, caretPosition) + event.key + endPhonePart;\n\n const newValueDecimal = newValue.replace(/\\D/g, '');\n\n // Запрещаем ввод, если номер уже заполнен.\n if (newValueDecimal.length > maxPhoneLength) {\n newValue = newValue.slice(0, -1);\n }\n\n if (ruNumberPriority && !value && countryIso2 === 'ru') {\n if (newValue === '7' || newValue === '8') {\n newValue = '+7';\n } else if (newValueDecimal.length === 1) {\n newValue = `+7${newValueDecimal}`;\n }\n }\n\n newValue = formatPhone(addCountryCode(newValue));\n\n let phonePartWithoutMask =\n currentValue.slice(0, caretPosition).replace(/\\D/g, '') + event.key;\n\n if (shouldReplace && phonePartWithoutMask.length > maxPhoneLength) {\n phonePartWithoutMask = phonePartWithoutMask.slice(0, -1);\n }\n\n if (newValue && newValue[0] !== '+') {\n newValue = `+${newValue}`;\n }\n\n setCaretPos(calculateCaretPos(phonePartWithoutMask, newValue));\n setCountryByDialCodeWithLengthCheck(newValue);\n onChange(newValue);\n };\n\n const handleDeleteChar = (event: React.KeyboardEvent<HTMLInputElement>) => {\n const input = event.target as HTMLInputElement;\n const selectionStart = input.selectionStart || 0;\n const selectionEnd = input.selectionEnd || 0;\n\n if (!clearableCountryCode && selectionEnd <= countryCodeLength) return;\n\n const currentValue = input.value;\n\n const isMaskSymbol = (count: number) => {\n const isMask = MASK_SYMBOLS.includes(currentValue.charAt(selectionEnd - 1 - count));\n const isPossibleToRemove = clearableCountryCode\n ? selectionEnd - count > 0\n : selectionEnd - count > countryCodeLength;\n\n return isMask && isPossibleToRemove;\n };\n\n let deletedCharsCount = Math.max(1, selectionEnd - selectionStart);\n\n // Высчитываем кол-во символов, которые нужно удалить.\n while (isMaskSymbol(deletedCharsCount)) {\n deletedCharsCount += 1;\n }\n\n const phonePart = currentValue.slice(0, selectionEnd - deletedCharsCount);\n const newValue = formatPhone(\n addCountryCode(phonePart + currentValue.slice(selectionEnd)),\n );\n\n const phonePartWithoutMask = phonePart.replace(/[^0-9+]+/g, '');\n\n setCaretPos(calculateCaretPos(phonePartWithoutMask, newValue));\n setCountryByDialCodeWithLengthCheck(newValue);\n onChange(newValue);\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n const input = event.target as HTMLInputElement;\n const caretPosition = input.selectionStart || 0;\n const disallowedSymbols = /[/|?!@#$%^&*()_=A-Za-zА-Яа-яЁё,. ]/;\n const withoutCombo = !event.altKey && !event.metaKey && !event.ctrlKey;\n\n // Запрещаем вводить неразрешенные символы за исключением комбинций клавиш\n if (withoutCombo && event.key.length === 1 && disallowedSymbols.test(event.key)) {\n event.preventDefault();\n\n return;\n }\n\n // Нажат только Backspace, не сочетание клавиш с ним.\n if (!event.shiftKey && withoutCombo && event.key === 'Backspace') {\n if (!caretPosition) return;\n\n event.preventDefault();\n\n handleDeleteChar(event);\n\n return;\n }\n\n if (event.key.length === 1 && /[0-9+]/.test(event.key)) {\n event.preventDefault();\n\n handleInputNewChar(event, caretPosition);\n }\n };\n\n const handleClear: React.MouseEventHandler<HTMLButtonElement> = (event) => {\n inputProps?.onClear?.(event);\n\n if (clearableCountryCode) {\n onChange('+');\n if (canBeEmptyCountry) {\n setCountryIso2(undefined);\n handleCountryChange(undefined);\n }\n } else {\n onChange(value.substring(0, countryCodeLength));\n }\n };\n\n const handlePaste: React.ClipboardEventHandler<HTMLInputElement> = (event) => {\n inputProps?.onPaste?.(event);\n\n event.preventDefault();\n const text = event.clipboardData?.getData('Text');\n\n if (!text || !inputRef.current) {\n return;\n }\n\n const { selectionStart, selectionEnd } = inputRef.current;\n const preparedNumber = preparePasteData(\n value,\n text,\n selectionStart || 0,\n selectionEnd || 0,\n ruNumberPriority && countryIso2 === 'ru',\n );\n const targetCountry = getCountryByNumber(preparedNumber);\n const maxPhoneLength =\n (targetCountry && maxPhoneLen?.[targetCountry.iso2.toUpperCase()]) || MAX_PHONE_LEN;\n const resultNumber = preparedNumber.substring(0, maxPhoneLength + 1);\n\n if (resultNumber) {\n setCountryIso2(targetCountry ? targetCountry.iso2 : undefined);\n changePhone(addCountryCode(resultNumber));\n }\n };\n\n useEffect(() => {\n if (inputRef.current && caretPos !== undefined) {\n inputRef.current.setSelectionRange(caretPos, caretPos);\n setCaretPos(undefined);\n }\n }, [caretPos]);\n\n useEffect(() => {\n if (phoneLibUtils.current) return;\n\n import(/* webpackChunkName: \"libphonenumber\" */ 'libphonenumber-js/min')\n .then((utils) => {\n phoneLibUtils.current = utils.AsYouType;\n\n if (canBeEmptyCountry) {\n changePhone(value);\n } else {\n setCountryByDialCode(value);\n }\n })\n .catch((error) => `An error occurred while loading libphonenumber-js:\\n${error}`);\n\n /* eslint-disable-next-line react-hooks/exhaustive-deps */\n }, [value]);\n\n useEffect(() => {\n if (value && value.length > 1 && !value.includes(' ')) {\n const newCountry = getCountryByNumber(value);\n\n if (newCountry && countryIso2 !== newCountry.iso2) {\n setCountryIso2(newCountry.iso2);\n handleCountryChange(newCountry.iso2);\n } else if (\n canBeEmptyCountry &&\n !newCountry &&\n countryIso2 !== defaultCountryIso2.toLowerCase()\n ) {\n setCountryIso2(undefined);\n handleCountryChange(undefined);\n }\n\n changePhone(value, newCountry?.iso2);\n }\n /* eslint-disable-next-line react-hooks/exhaustive-deps */\n }, [value, canBeEmptyCountry, countryIso2, defaultCountryIso2]);\n\n useCaretAvoidCountryCode({ inputRef, countryCodeLength, clearableCountryCode });\n\n return (\n <InputAutocompleteDesktop\n {...restProps}\n ref={ref}\n inputProps={{\n clear: clear && !isEmptyValue,\n ...inputProps,\n onClear: handleClear,\n ref: inputRef,\n wrapperRef: setInputWrapperRef,\n type: 'tel',\n colors,\n className: cn(className, styles[size]),\n addonsClassName: styles.addons,\n onKeyDown: handleKeyDown,\n onPaste: handlePaste,\n leftAddons: hideCountrySelect ? (\n <span className={styles.flagIconWrapper}>\n {countryIso2 ? (\n <FlagIcon country={countryIso2} />\n ) : (\n <WorldMagnifierMIcon className={styles.emptyCountryIcon} />\n )}\n </span>\n ) : (\n countries.length > 1 && (\n <CountriesSelect\n dataTestId='countries-select'\n disabled={disabled || readOnly}\n size={size}\n selected={countryIso2}\n countries={countries}\n onChange={handleSelectChange}\n fieldWidth={\n inputWrapperRef && inputWrapperRef.getBoundingClientRect().width\n }\n preventFlip={preventFlip}\n />\n )\n ),\n }}\n optionsListWidth='field'\n closeOnSelect={true}\n onInput={handleInputChange}\n onChange={handleChange}\n options={options}\n disabled={disabled}\n readOnly={readOnly}\n size={size}\n className={className}\n value={value}\n />\n );\n },\n);\n"],"names":["getCountriesHash","forwardRef","getCountries","__rest","useState","useRef","formatPhoneWithUnclearableCountryCode","calculateCaretPos","preparePasteData","useEffect","useCaret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AAA,KAElCL,qCAACM,oCAAmB,EAAA,EAAC,SAAS,EAAEF,YAAM,CAAC,gBAAgB,EAAI,CAAA,CAC9D,CACE,KAEP,SAAS,CAAC,MAAM,GAAG,CAAC,KAChBJ,qCAACO,2BAAe,EAAA,EACZ,UAAU,EAAC,kBAAkB,EAC7B,QAAQ,EAAE,QAAQ,IAAI,QAAQ,EAC9B,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,WAAW,EACrB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,kBAAkB,EAC5B,UAAU,EACN,eAAe,IAAI,eAAe,CAAC,qBAAqB,EAAE,CAAC,KAAK,EAEpE,WAAW,EAAE,WAAW,GAC1B,CACL,CACJ,EAEL,CAAA,EAAA,gBAAgB,EAAC,OAAO,EACxB,aAAa,EAAE,IAAI,EACnB,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACd,CAAA,CAAA;AAEV,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"component.js","sources":["src/component.tsx"],"sourcesContent":["import React, { forwardRef, useEffect, useRef, useState } from 'react';\nimport cn from 'classnames';\nimport { type AsYouType, type CountryCode } from 'libphonenumber-js/min';\n\nimport {\n InputAutocompleteDesktop,\n type InputAutocompleteDesktopProps,\n} from '@alfalab/core-components-input-autocomplete/desktop';\nimport { type SelectProps } from '@alfalab/core-components-select';\nimport { type OptionShape } from '@alfalab/core-components-select/shared';\nimport WorldMagnifierMIcon from '@alfalab/icons-glyph/WorldMagnifierMIcon';\nimport { type Country, getCountries, getCountriesHash } from '@alfalab/utils';\n\nimport { calculateCaretPos } from './utils/calculateCaretPos';\nimport { formatPhoneWithUnclearableCountryCode } from './utils/format-phone-with-unclearable-country-code';\nimport { preparePasteData } from './utils/preparePasteData';\nimport { CountriesSelect, FlagIcon } from './components';\nimport { useCaretAvoidCountryCode } from './useCaretAvoidCountryCode';\n\nimport styles from './index.module.css';\n\nconst countriesHash = getCountriesHash();\n\nconst MAX_DIAL_CODE_LENGTH = 4;\n\nconst MASK_SYMBOLS = [' ', '-', '(', ')'];\n\nconst MAX_PHONE_LEN = 15;\n\nconst DEFAULT_MAX_PHONE_LEN_BY_COUNTRY: MaxPhoneLenByCountry = { RU: 11 };\n\ntype MaxPhoneLenByCountry = Record<string, number>;\n\nexport type IntlPhoneInputProps = Partial<Omit<InputAutocompleteDesktopProps, 'onChange'>> &\n Pick<SelectProps, 'preventFlip'> & {\n /**\n * Значение\n */\n value: string;\n\n /**\n * Набор цветов для компонента\n */\n colors?: 'default' | 'inverted';\n\n /**\n * Обработчик события изменения значения\n */\n onChange: (value: string) => void;\n\n /**\n * Дефолтный код страны\n */\n defaultCountryIso2?: string;\n\n /**\n * Обработчик события изменения страны\n */\n onCountryChange?: (countryCode?: CountryCode) => void;\n\n /**\n * Список стран\n */\n countries?: Country[];\n\n /**\n * Максимальная длина кода страны\n */\n maxDialCodeLength?: number;\n\n /**\n * Возможность стереть код страны\n */\n clearableCountryCode?: boolean;\n\n /**\n * Ограничение длин вводимых номеров по странам.\n */\n maxPhoneLen?: MaxPhoneLenByCountry;\n\n /*\n * Отключает выбор страны через селект\n */\n hideCountrySelect?: boolean;\n\n /*\n * Разрешает состояние без выбранной страны\n */\n canBeEmptyCountry?: boolean;\n\n /*\n * Подставляет +7 при выбранной стране 'ru' и вводе первых цифр номера.\n * При canBeEmptyCountry - работает только с дефолтным значением 'ru'\n */\n ruNumberPriority?: boolean;\n\n /*\n * Разрешает очищать поле крестиком\n */\n clear?: boolean;\n };\n\n/**\n * @deprecated\n * use InternationalPhoneInput instead\n */\nexport const IntlPhoneInput = forwardRef<HTMLInputElement, IntlPhoneInputProps>(\n (\n {\n disabled = false,\n readOnly = false,\n hideCountrySelect = false,\n canBeEmptyCountry = false,\n ruNumberPriority = false,\n clear = false,\n size = 'm',\n colors = 'default',\n options = [],\n countries = getCountries(),\n clearableCountryCode = true,\n maxDialCodeLength = MAX_DIAL_CODE_LENGTH,\n className,\n value,\n onChange,\n onCountryChange,\n defaultCountryIso2 = 'ru',\n preventFlip,\n inputProps,\n maxPhoneLen = DEFAULT_MAX_PHONE_LEN_BY_COUNTRY,\n ...restProps\n },\n ref,\n ) => {\n const [countryIso2, setCountryIso2] = useState<string | undefined>(\n defaultCountryIso2.toLowerCase(),\n );\n\n const inputRef = useRef<HTMLInputElement>(null);\n const [inputWrapperRef, setInputWrapperRef] = useState<HTMLDivElement | null>(null);\n\n const [caretPos, setCaretPos] = useState<number>();\n\n const phoneLibUtils = useRef<typeof AsYouType>();\n\n const formatPhone = (inputValue: string, iso2 = countryIso2) => {\n let newValue = inputValue;\n\n if (phoneLibUtils.current) {\n const Utils = phoneLibUtils.current;\n const utils = new Utils(iso2 ? (iso2.toUpperCase() as CountryCode) : undefined);\n\n newValue = utils.input(inputValue);\n }\n\n if (iso2 === 'ru') {\n const parts = newValue.split(' ');\n\n newValue = parts.reduce((acc, part, index) => {\n if (index === 0) {\n return part;\n }\n if (index > 2) {\n return `${acc}-${part}`;\n }\n\n return `${acc} ${part}`;\n }, '');\n }\n\n return newValue;\n };\n\n const setCountryByIso2 = (iso2: string) => {\n const country = countriesHash[iso2];\n\n const inputValue = `+${country.dialCode}`;\n\n onChange(inputValue);\n setCountryIso2(country.iso2);\n\n return country;\n };\n\n const handleCountryChange = (countryCode?: string) => {\n if (onCountryChange) {\n onCountryChange(\n countryCode ? (countryCode.toUpperCase() as CountryCode) : undefined,\n );\n }\n };\n\n const getCountryByNumber = (inputValue: string) => {\n // dialcode казахстанских номеров совпадает с российскими, поэтому проверяем отдельно\n if (new RegExp('^\\\\+7(\\\\s)?7').test(inputValue)) {\n const kzCoutry = countries.find((item) => item.iso2 === 'kz');\n\n if (kzCoutry) {\n return kzCoutry;\n }\n }\n\n const targetCountry = countries.find((country) => {\n if (new RegExp(`^\\\\+${country.dialCode}`).test(inputValue)) {\n // Сначала проверяем, если приоритет не указан\n if (country.priority === undefined) {\n return true;\n }\n\n // Если страна уже была выставлена через селект, и коды совпадают\n if (countryIso2 === country.iso2 && countryIso2 !== 'kz') {\n return true;\n }\n\n // Если не совпадают - выбираем по приоритету\n if (country.priority === 0) {\n return true;\n }\n\n return false;\n }\n\n return false;\n });\n\n return targetCountry;\n };\n\n const changePhone = (phone: string, iso2?: string) => {\n const newValue = formatPhone(phone, iso2);\n\n if (newValue !== value) {\n onChange(newValue);\n }\n };\n\n const addCountryCode = (inputValue: string) => {\n if (clearableCountryCode || !countryIso2) {\n return inputValue.length === 1 && inputValue !== '+'\n ? `+${inputValue}`\n : inputValue;\n }\n const country = countriesHash[countryIso2];\n\n return formatPhoneWithUnclearableCountryCode(inputValue, country);\n };\n\n const setCountryByDialCode = (inputValue: string) => {\n const country = getCountryByNumber(inputValue);\n\n changePhone(addCountryCode(inputValue), country?.iso2);\n if (country) {\n setCountryIso2(country.iso2);\n handleCountryChange(country.iso2);\n } else if (canBeEmptyCountry) {\n setCountryIso2(undefined);\n handleCountryChange(undefined);\n }\n };\n\n const setCountryByDialCodeWithLengthCheck = (inputValue: string) => {\n if (inputRef.current) {\n const { selectionStart } = inputRef.current;\n\n if ((selectionStart || 0) <= maxDialCodeLength) {\n setCountryByDialCode(inputValue);\n }\n }\n };\n\n const handleInputChange: InputAutocompleteDesktopProps['onInput'] = (newValue) => {\n setCountryByDialCodeWithLengthCheck(newValue);\n changePhone(addCountryCode(newValue));\n };\n\n const handleSelectChange: Required<SelectProps>['onChange'] = ({ selected }) => {\n if (selected) {\n const country = setCountryByIso2(selected.value);\n const inputValue = `+${country.dialCode}`;\n\n if (inputRef.current) {\n inputRef.current.focus();\n inputRef.current.setSelectionRange(inputValue.length, inputValue.length);\n }\n\n handleCountryChange(country.iso2);\n }\n };\n\n const handleChange = (payload: {\n selected: OptionShape | null;\n selectedMultiple: OptionShape[];\n name?: string;\n }) => {\n const { selected } = payload;\n\n if (!selected) return;\n setCountryByDialCodeWithLengthCheck(selected.key);\n changePhone(selected.key);\n };\n\n const country = countryIso2 && countriesHash[countryIso2];\n const countryCodeLength = country ? `+${country.dialCode}`.length : 0;\n const isEmptyValue = clearableCountryCode\n ? value === '' || value === '+'\n : value.length <= countryCodeLength;\n\n const handleInputNewChar = (\n event: React.KeyboardEvent<HTMLInputElement>,\n caretPosition: number,\n ) => {\n const input = event.target as HTMLInputElement;\n const currentValue = input.value;\n const maxPhoneLength =\n (countryIso2 && maxPhoneLen?.[countryIso2.toUpperCase()]) || MAX_PHONE_LEN;\n // Если номер полностью заполнен, то перезатираем цифры, если каретка не в самом конце.\n const shouldReplace = maxPhoneLength === currentValue.replace(/\\D/g, '').length;\n\n let endPhonePart = currentValue.slice(caretPosition);\n\n if (shouldReplace) {\n let cursor = 0;\n\n while (MASK_SYMBOLS.includes(endPhonePart.charAt(cursor))) {\n cursor += 1;\n }\n\n endPhonePart = endPhonePart.slice(cursor + 1);\n }\n\n let newValue = currentValue.slice(0, caretPosition) + event.key + endPhonePart;\n\n const newValueDecimal = newValue.replace(/\\D/g, '');\n\n // Запрещаем ввод, если номер уже заполнен.\n if (newValueDecimal.length > maxPhoneLength) {\n newValue = newValue.slice(0, -1);\n }\n\n if (ruNumberPriority && !value && countryIso2 === 'ru') {\n if (newValue === '7' || newValue === '8') {\n newValue = '+7';\n } else if (newValueDecimal.length === 1) {\n newValue = `+7${newValueDecimal}`;\n }\n }\n\n newValue = formatPhone(addCountryCode(newValue));\n\n let phonePartWithoutMask =\n currentValue.slice(0, caretPosition).replace(/\\D/g, '') + event.key;\n\n if (shouldReplace && phonePartWithoutMask.length > maxPhoneLength) {\n phonePartWithoutMask = phonePartWithoutMask.slice(0, -1);\n }\n\n if (newValue && newValue[0] !== '+') {\n newValue = `+${newValue}`;\n }\n\n setCaretPos(calculateCaretPos(phonePartWithoutMask, newValue));\n setCountryByDialCodeWithLengthCheck(newValue);\n onChange(newValue);\n };\n\n const handleDeleteChar = (event: React.KeyboardEvent<HTMLInputElement>) => {\n const input = event.target as HTMLInputElement;\n const selectionStart = input.selectionStart || 0;\n const selectionEnd = input.selectionEnd || 0;\n\n if (!clearableCountryCode && selectionEnd <= countryCodeLength) return;\n\n const currentValue = input.value;\n\n const isMaskSymbol = (count: number) => {\n const isMask = MASK_SYMBOLS.includes(currentValue.charAt(selectionEnd - 1 - count));\n const isPossibleToRemove = clearableCountryCode\n ? selectionEnd - count > 0\n : selectionEnd - count > countryCodeLength;\n\n return isMask && isPossibleToRemove;\n };\n\n let deletedCharsCount = Math.max(1, selectionEnd - selectionStart);\n\n // Высчитываем кол-во символов, которые нужно удалить.\n while (isMaskSymbol(deletedCharsCount)) {\n deletedCharsCount += 1;\n }\n\n const phonePart = currentValue.slice(0, selectionEnd - deletedCharsCount);\n const newValue = formatPhone(\n addCountryCode(phonePart + currentValue.slice(selectionEnd)),\n );\n\n const phonePartWithoutMask = phonePart.replace(/[^0-9+]+/g, '');\n\n setCaretPos(calculateCaretPos(phonePartWithoutMask, newValue));\n setCountryByDialCodeWithLengthCheck(newValue);\n onChange(newValue);\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n const input = event.target as HTMLInputElement;\n const caretPosition = input.selectionStart || 0;\n const disallowedSymbols = /[/|?!@#$%^&*()_=A-Za-zА-Яа-яЁё,. ]/;\n const withoutCombo = !event.altKey && !event.metaKey && !event.ctrlKey;\n\n // Запрещаем вводить неразрешенные символы за исключением комбинций клавиш\n if (withoutCombo && event.key.length === 1 && disallowedSymbols.test(event.key)) {\n event.preventDefault();\n\n return;\n }\n\n // Нажат только Backspace, не сочетание клавиш с ним.\n if (!event.shiftKey && withoutCombo && event.key === 'Backspace') {\n if (!caretPosition) return;\n\n event.preventDefault();\n\n handleDeleteChar(event);\n\n return;\n }\n\n if (event.key.length === 1 && /[0-9+]/.test(event.key)) {\n event.preventDefault();\n\n handleInputNewChar(event, caretPosition);\n }\n };\n\n const handleClear: React.MouseEventHandler<HTMLButtonElement> = (event) => {\n inputProps?.onClear?.(event);\n\n if (clearableCountryCode) {\n onChange('+');\n if (canBeEmptyCountry) {\n setCountryIso2(undefined);\n handleCountryChange(undefined);\n }\n } else {\n onChange(value.substring(0, countryCodeLength));\n }\n };\n\n const handlePaste: React.ClipboardEventHandler<HTMLInputElement> = (event) => {\n inputProps?.onPaste?.(event);\n\n event.preventDefault();\n const text = event.clipboardData?.getData('Text');\n\n if (!text || !inputRef.current) {\n return;\n }\n\n const { selectionStart, selectionEnd } = inputRef.current;\n const preparedNumber = preparePasteData(\n value,\n text,\n selectionStart || 0,\n selectionEnd || 0,\n ruNumberPriority && countryIso2 === 'ru',\n );\n const targetCountry = getCountryByNumber(preparedNumber);\n const maxPhoneLength =\n (targetCountry && maxPhoneLen?.[targetCountry.iso2.toUpperCase()]) || MAX_PHONE_LEN;\n const resultNumber = preparedNumber.substring(0, maxPhoneLength + 1);\n\n if (resultNumber) {\n setCountryIso2(targetCountry ? targetCountry.iso2 : undefined);\n changePhone(addCountryCode(resultNumber));\n }\n };\n\n useEffect(() => {\n if (inputRef.current && caretPos !== undefined) {\n inputRef.current.setSelectionRange(caretPos, caretPos);\n setCaretPos(undefined);\n }\n }, [caretPos]);\n\n useEffect(() => {\n if (phoneLibUtils.current) return;\n\n import(/* webpackChunkName: \"libphonenumber\" */ 'libphonenumber-js/min')\n .then((utils) => {\n phoneLibUtils.current = utils.AsYouType;\n\n if (canBeEmptyCountry) {\n changePhone(value);\n } else {\n setCountryByDialCode(value);\n }\n })\n .catch((error) => `An error occurred while loading libphonenumber-js:\\n${error}`);\n\n /* eslint-disable-next-line react-hooks/exhaustive-deps */\n }, [value]);\n\n useEffect(() => {\n if (value && value.length > 1 && !value.includes(' ')) {\n const newCountry = getCountryByNumber(value);\n\n if (newCountry && countryIso2 !== newCountry.iso2) {\n setCountryIso2(newCountry.iso2);\n handleCountryChange(newCountry.iso2);\n } else if (\n canBeEmptyCountry &&\n !newCountry &&\n countryIso2 !== defaultCountryIso2.toLowerCase()\n ) {\n setCountryIso2(undefined);\n handleCountryChange(undefined);\n }\n\n changePhone(value, newCountry?.iso2);\n }\n /* eslint-disable-next-line react-hooks/exhaustive-deps */\n }, [value, canBeEmptyCountry, countryIso2, defaultCountryIso2]);\n\n useCaretAvoidCountryCode({ inputRef, countryCodeLength, clearableCountryCode });\n\n return (\n <InputAutocompleteDesktop\n {...restProps}\n ref={ref}\n inputProps={{\n clear: clear && !isEmptyValue,\n ...inputProps,\n onClear: handleClear,\n ref: inputRef,\n wrapperRef: setInputWrapperRef,\n type: 'tel',\n colors,\n className: cn(className, styles[size]),\n addonsClassName: styles.addons,\n onKeyDown: handleKeyDown,\n onPaste: handlePaste,\n leftAddons: hideCountrySelect ? (\n <span className={styles.flagIconWrapper}>\n {countryIso2 ? (\n <FlagIcon country={countryIso2} />\n ) : (\n <WorldMagnifierMIcon className={styles.emptyCountryIcon} />\n )}\n </span>\n ) : (\n countries.length > 1 && (\n <CountriesSelect\n dataTestId='countries-select'\n disabled={disabled || readOnly}\n size={size}\n selected={countryIso2}\n countries={countries}\n onChange={handleSelectChange}\n fieldWidth={inputWrapperRef?.getBoundingClientRect().width ?? null}\n preventFlip={preventFlip}\n />\n )\n ),\n }}\n optionsListWidth='field'\n closeOnSelect={true}\n onInput={handleInputChange}\n onChange={handleChange}\n options={options}\n disabled={disabled}\n readOnly={readOnly}\n size={size}\n className={className}\n value={value}\n />\n );\n },\n);\n"],"names":["getCountriesHash","forwardRef","getCountries","__rest","useState","useRef","formatPhoneWithUnclearableCountryCode","calculateCaretPos","preparePasteData","useEffect","useCaretAvoidCountryCode","React","InputAutocompleteDesktop","__assign","cn","styles","FlagIcon","WorldMagnifierMIcon","CountriesSelect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAM,aAAa,GAAGA,sBAAgB,EAAE;AAExC,IAAM,oBAAoB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Q,EAAE,QAAQ,IAAI,QAAQ,EAC9B,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,WAAW,EACrB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,kBAAkB,EAC5B,UAAU,EAAE,CAAA,EAAA,GAAA,eAAe,aAAf,eAAe,KAAA,MAAA,GAAA,MAAA,GAAf,eAAe,CAAE,qBAAqB,EAAA,CAAG,KAAK,MAAI,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAA,IAAI,EAClE,WAAW,EAAE,WAAW,EAC1B,CAAA,CACL,CACJ,EAAA,CAAA,EAEL,gBAAgB,EAAC,OAAO,EACxB,aAAa,EAAE,IAAI,EACnB,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACd,CAAA,CAAA;AAEV,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../src/components/flag-icon/component.tsx"],"sourcesContent":["import React, { FC } from 'react';\nimport cn from 'classnames';\n\nimport { flagSprite } from './flagSprite';\n\nimport styles from './index.module.css';\n\nexport type FlagIconProps = {\n /**\n * Код страны из <a href=\"https://ru.wikipedia.org/wiki/ISO_3166-1_alpha-2\" target=\"_blank\">ISO 3166-1 alpha-2</a>\n */\n country?: string;\n\n /**\n * Дополнительный класс\n */\n className?: string;\n};\n\n/**\n * Компонент флага в виде иконки.\n */\nexport const FlagIcon: FC<FlagIconProps> = ({ country = '', className }) =>\n flagSprite[country] ? (\n <span\n className={cn(styles.flagIcon, className)}\n data-test-id={`flag-icon-${country}`}\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{ __html: flagSprite[country] }}\n />\n ) : (\n <div className={cn(styles.flagPlaceholder, className)} />\n );\n"],"names":["flagSprite","React","cn","styles"],"mappings":";;;;;;;;;;;;;;AAmBA;;AAEG;AACI,IAAM,QAAQ,GAAsB,UAAC,EAA2B,EAAA;AAAzB,IAAA,IAAA,EAAA,GAAA,EAAA,CAAA,OAAY,EAAZ,OAAO,GAAA,EAAA,KAAA,MAAA,GAAG,EAAE,GAAA,EAAA,EAAE,SAAS,GAAA,EAAA,CAAA,SAAA;IACjE,OAAAA,qBAAU,CAAC,OAAO,CAAC,IACfC,sBAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EACI,SAAS,EAAEC,mBAAE,CAACC,YAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAA,cAAA,EAC3B,YAAa,CAAA,MAAA,CAAA,OAAO,CAAE;;QAEpC,uBAAuB,EAAE,EAAE,MAAM,EAAEH,qBAAU,CAAC,OAAO,CAAC,EAAE,EAC1D,CAAA,KAEFC,sBAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAEC,mBAAE,CAACC,YAAM,CAAC,eAAe,EAAE,SAAS,CAAC,EAAA,CAAI,CAC5D;AATD;;;;"}
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../src/components/flag-icon/component.tsx"],"sourcesContent":["import React, { type FC } from 'react';\nimport cn from 'classnames';\n\nimport { flagSprite } from './flagSprite';\n\nimport styles from './index.module.css';\n\nexport type FlagIconProps = {\n /**\n * Код страны из <a href=\"https://ru.wikipedia.org/wiki/ISO_3166-1_alpha-2\" target=\"_blank\">ISO 3166-1 alpha-2</a>\n */\n country?: string;\n\n /**\n * Дополнительный класс\n */\n className?: string;\n};\n\n/**\n * Компонент флага в виде иконки.\n */\nexport const FlagIcon: FC<FlagIconProps> = ({ country = '', className }) =>\n flagSprite[country] ? (\n <span\n className={cn(styles.flagIcon, className)}\n data-test-id={`flag-icon-${country}`}\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{ __html: flagSprite[country] }}\n />\n ) : (\n <div className={cn(styles.flagPlaceholder, className)} />\n );\n"],"names":["flagSprite","React","cn","styles"],"mappings":";;;;;;;;;;;;;;AAmBA;;AAEG;AACI,IAAM,QAAQ,GAAsB,UAAC,EAA2B,EAAA;AAAzB,IAAA,IAAA,EAAA,GAAA,EAAA,CAAA,OAAY,EAAZ,OAAO,GAAA,EAAA,KAAA,MAAA,GAAG,EAAE,GAAA,EAAA,EAAE,SAAS,GAAA,EAAA,CAAA,SAAA;IACjE,OAAAA,qBAAU,CAAC,OAAO,CAAC,IACfC,sBAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EACI,SAAS,EAAEC,mBAAE,CAACC,YAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAA,cAAA,EAC3B,YAAa,CAAA,MAAA,CAAA,OAAO,CAAE;;QAEpC,uBAAuB,EAAE,EAAE,MAAM,EAAEH,qBAAU,CAAC,OAAO,CAAC,EAAE,EAC1D,CAAA,KAEFC,sBAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAEC,mBAAE,CAACC,YAAM,CAAC,eAAe,EAAE,SAAS,CAAC,EAAA,CAAI,CAC5D;AATD;;;;"}
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
} :root {
|
|
7
7
|
--gap-3xs: 2px;
|
|
8
8
|
--gap-2: var(--gap-3xs);
|
|
9
|
-
} .intl-phone-
|
|
9
|
+
} .intl-phone-input__flagIcon_1855m {
|
|
10
10
|
max-width: 24px;
|
|
11
11
|
max-height: 24px;
|
|
12
|
-
} .intl-phone-
|
|
12
|
+
} .intl-phone-input__flagPlaceholder_1855m {
|
|
13
13
|
width: 24px;
|
|
14
14
|
height: 16px;
|
|
15
15
|
max-height: 16px;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require('./index.css');
|
|
4
4
|
|
|
5
|
-
var styles = {"flagIcon":"intl-phone-
|
|
5
|
+
var styles = {"flagIcon":"intl-phone-input__flagIcon_1855m","flagPlaceholder":"intl-phone-input__flagPlaceholder_1855m"};
|
|
6
6
|
|
|
7
7
|
module.exports = styles;
|
|
8
8
|
//# sourceMappingURL=index.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.css.js","sources":["../../src/components/flag-icon/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n\n.flagIcon {\n max-width: 24px;\n max-height: 24px;\n}\n\n.flagPlaceholder {\n width: 24px;\n height: 16px;\n max-height: 16px;\n border-radius: var(--border-radius-2);\n margin-top: var(--gap-2);\n background-color: var(--color-light-neutral-translucent-300);\n}\n"],"names":[],"mappings":";;;;AAEgB,aAAe,CAAC,UAAU,CAAC,kCAAkC,CAAC,iBAAiB,CAAC,yCAAyC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.module.css.js","sources":["../../src/components/flag-icon/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/no-typography-index.css';\n\n.flagIcon {\n max-width: 24px;\n max-height: 24px;\n}\n\n.flagPlaceholder {\n width: 24px;\n height: 16px;\n max-height: 16px;\n border-radius: var(--border-radius-2);\n margin-top: var(--gap-2);\n background-color: var(--color-light-neutral-translucent-300);\n}\n"],"names":[],"mappings":";;;;AAEgB,aAAe,CAAC,UAAU,CAAC,kCAAkC,CAAC,iBAAiB,CAAC,yCAAyC,CAAC;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { SelectDesktopProps } from '@alfalab/core-components-select/desktop';
|
|
3
|
-
import { Country } from '@alfalab/utils';
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import { type SelectDesktopProps } from '@alfalab/core-components-select/desktop';
|
|
3
|
+
import { type Country } from '@alfalab/utils';
|
|
4
4
|
declare type CountriesSelectProps = Pick<SelectDesktopProps, 'size' | 'dataTestId' | 'disabled' | 'onChange' | 'preventFlip'> & {
|
|
5
5
|
selected?: string;
|
|
6
6
|
countries: Country[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../src/components/select/component.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport React, { FC, useCallback, useMemo } from 'react';\n\nimport { SelectDesktop, SelectDesktopProps } from '@alfalab/core-components-select/desktop';\nimport { OptionsListProps, VirtualOptionsList } from '@alfalab/core-components-select/shared';\nimport { Country } from '@alfalab/utils';\n\nimport { FlagIcon } from '../flag-icon';\nimport { EMPTY_COUNTRY_SELECT_FIELD, SelectField } from '../select-field';\n\nimport styles from './index.module.css';\n\ntype CountriesSelectProps = Pick<\n SelectDesktopProps,\n 'size' | 'dataTestId' | 'disabled' | 'onChange' | 'preventFlip'\n> & {\n selected?: string;\n countries: Country[];\n fieldWidth: number | null;\n};\n\nexport const CountriesSelect: FC<CountriesSelectProps> = ({\n disabled,\n size,\n selected,\n countries,\n fieldWidth,\n preventFlip,\n onChange,\n dataTestId,\n}) => {\n const options = useMemo(\n () =>\n countries.map(({ iso2, dialCode, name }) => ({\n key: iso2,\n value: iso2,\n content: (\n <span className={styles.option}>\n <FlagIcon country={iso2} className={styles.flag} />\n\n <span className={styles.optionTextWrap}>\n <span className={styles.countryName}>{name}</span>\n <span className={styles.dialCode}>+{dialCode}</span>\n </span>\n </span>\n ),\n })),\n [countries],\n );\n\n const renderOptionsList = useCallback(\n (props: OptionsListProps) => (\n <div style={{ width: fieldWidth || 0 }}>\n <VirtualOptionsList {...props} optionsListWidth='field' />\n </div>\n ),\n [fieldWidth],\n );\n\n return (\n <div className={styles.component} onClick={(event) => event.stopPropagation()}>\n <SelectDesktop\n dataTestId={dataTestId}\n disabled={disabled}\n size={size}\n options={options}\n selected={selected || EMPTY_COUNTRY_SELECT_FIELD}\n onChange={onChange}\n Field={SelectField}\n OptionsList={renderOptionsList}\n preventFlip={preventFlip}\n />\n </div>\n );\n};\n"],"names":["useMemo","React","styles","FlagIcon","useCallback","VirtualOptionsList","__assign","SelectDes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AQ,CACjD,CACJ,CACV;aACJ;AAb2C,SAa1C,CAAC;AAbH,KAaG,EACP,CAAC,SAAS,CAAC,CACd;AAED,IAAA,IAAM,iBAAiB,GAAGE,iBAAW,CACjC,UAAC,KAAuB,IAAK,QACzBH,sBAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,IAAI,CAAC,EAAE,EAAA;AAClC,QAAAA,sBAAA,CAAA,aAAA,CAACI,yBAAkB,EAAKC,cAAA,CAAA,EAAA,EAAA,KAAK,EAAE,EAAA,gBAAgB,EAAC,OAAO,EAAA,CAAA,CAAG,CACxD,IACT,EACD,CAAC,UAAU,CAAC,CACf;AAED,IAAA,QACIL,sBAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAEC,YAAM,CAAC,SAAS,EAAE,OAAO,EAAE,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,eAAe,EAAE,GAAA,EAAA;AACzE,QAAAD,sBAAA,CAAA,aAAA,CAACM,qBAAa,EACV,EAAA,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,IAAIC,sCAA0B,EAChD,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAEC,uBAAW,EAClB,WAAW,EAAE,iBAAiB,EAC9B,WAAW,EAAE,WAAW,EAC1B,CAAA,CACA;AAEd;;;;"}
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../src/components/select/component.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport React, { type FC, useCallback, useMemo } from 'react';\n\nimport { SelectDesktop, type SelectDesktopProps } from '@alfalab/core-components-select/desktop';\nimport { type OptionsListProps, VirtualOptionsList } from '@alfalab/core-components-select/shared';\nimport { type Country } from '@alfalab/utils';\n\nimport { FlagIcon } from '../flag-icon';\nimport { EMPTY_COUNTRY_SELECT_FIELD, SelectField } from '../select-field';\n\nimport styles from './index.module.css';\n\ntype CountriesSelectProps = Pick<\n SelectDesktopProps,\n 'size' | 'dataTestId' | 'disabled' | 'onChange' | 'preventFlip'\n> & {\n selected?: string;\n countries: Country[];\n fieldWidth: number | null;\n};\n\nexport const CountriesSelect: FC<CountriesSelectProps> = ({\n disabled,\n size,\n selected,\n countries,\n fieldWidth,\n preventFlip,\n onChange,\n dataTestId,\n}) => {\n const options = useMemo(\n () =>\n countries.map(({ iso2, dialCode, name }) => ({\n key: iso2,\n value: iso2,\n content: (\n <span className={styles.option}>\n <FlagIcon country={iso2} className={styles.flag} />\n\n <span className={styles.optionTextWrap}>\n <span className={styles.countryName}>{name}</span>\n <span className={styles.dialCode}>+{dialCode}</span>\n </span>\n </span>\n ),\n })),\n [countries],\n );\n\n const renderOptionsList = useCallback(\n (props: OptionsListProps) => (\n <div style={{ width: fieldWidth || 0 }}>\n <VirtualOptionsList {...props} optionsListWidth='field' />\n </div>\n ),\n [fieldWidth],\n );\n\n return (\n <div className={styles.component} onClick={(event) => event.stopPropagation()}>\n <SelectDesktop\n dataTestId={dataTestId}\n disabled={disabled}\n size={size}\n options={options}\n selected={selected || EMPTY_COUNTRY_SELECT_FIELD}\n onChange={onChange}\n Field={SelectField}\n OptionsList={renderOptionsList}\n preventFlip={preventFlip}\n />\n </div>\n );\n};\n"],"names":["useMemo","React","styles","FlagIcon","useCallback","VirtualOptionsList","__assign","SelectDesktop","EMPTY_COUNTRY_SELECT_FIELD","SelectField"],"mappings":";;;;;;;;;;;;;;;;AAsBO,IAAM,eAAe,GAA6B,UAAC,EASzD,EAAA;QARG,QAAQ,GAAA,EAAA,CAAA,QAAA,EACR,IAAI,GAAA,EAAA,CAAA,IAAA,EACJ,QAAQ,GAAA,EAAA,CAAA,QAAA,EACR,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,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AAA,CAACI,yBAAkB,EAAKC,cAAA,CAAA,EAAA,EAAA,KAAK,EAAE,EAAA,gBAAgB,EAAC,OAAO,EAAA,CAAA,CAAG,CACxD,IACT,EACD,CAAC,UAAU,CAAC,CACf;AAED,IAAA,QACIL,sBAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAEC,YAAM,CAAC,SAAS,EAAE,OAAO,EAAE,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,eAAe,EAAE,GAAA,EAAA;AACzE,QAAAD,sBAAA,CAAA,aAAA,CAACM,qBAAa,EACV,EAAA,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,IAAIC,sCAA0B,EAChD,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAEC,uBAAW,EAClB,WAAW,EAAE,iBAAiB,EAC9B,WAAW,EAAE,WAAW,EAC1B,CAAA,CACA;AAEd;;;;"}
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
} :root {
|
|
4
4
|
--gap-xs: 8px;
|
|
5
5
|
--gap-8: var(--gap-xs);
|
|
6
|
-
} .intl-phone-
|
|
6
|
+
} .intl-phone-input__component_60fyo {
|
|
7
7
|
position: static;
|
|
8
8
|
display: flex;
|
|
9
9
|
min-width: 0;
|
|
10
10
|
min-width: initial;
|
|
11
11
|
height: 100%;
|
|
12
|
-
} .intl-phone-
|
|
12
|
+
} .intl-phone-input__option_60fyo {
|
|
13
13
|
display: flex;
|
|
14
14
|
align-items: flex-start;
|
|
15
|
-
} .intl-phone-
|
|
15
|
+
} .intl-phone-input__flag_60fyo {
|
|
16
16
|
flex-shrink: 0;
|
|
17
17
|
margin-right: var(--gap-8);
|
|
18
|
-
} .intl-phone-
|
|
18
|
+
} .intl-phone-input__countryName_60fyo {
|
|
19
19
|
margin-right: var(--gap-8);
|
|
20
|
-
} .intl-phone-
|
|
20
|
+
} .intl-phone-input__dialCode_60fyo {
|
|
21
21
|
color: var(--color-light-text-secondary);
|
|
22
22
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require('./index.css');
|
|
4
4
|
|
|
5
|
-
var styles = {"component":"intl-phone-
|
|
5
|
+
var styles = {"component":"intl-phone-input__component_60fyo","option":"intl-phone-input__option_60fyo","flag":"intl-phone-input__flag_60fyo","countryName":"intl-phone-input__countryName_60fyo","dialCode":"intl-phone-input__dialCode_60fyo"};
|
|
6
6
|
|
|
7
7
|
module.exports = styles;
|
|
8
8
|
//# sourceMappingURL=index.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.css.js","sources":["../../src/components/select/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n\n.component {\n position: static;\n display: flex;\n min-width: initial;\n height: 100%;\n}\n\n.option {\n display: flex;\n align-items: flex-start;\n}\n\n.flag {\n flex-shrink: 0;\n margin-right: var(--gap-8);\n}\n\n.countryName {\n margin-right: var(--gap-8);\n}\n\n.dialCode {\n color: var(--color-light-text-secondary);\n}\n"],"names":[],"mappings":";;;;AAEgB,aAAe,CAAC,WAAW,CAAC,mCAAmC,CAAC,QAAQ,CAAC,gCAAgC,CAAC,MAAM,CAAC,8BAA8B,CAAC,aAAa,CAAC,qCAAqC,CAAC,UAAU,CAAC,kCAAkC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.module.css.js","sources":["../../src/components/select/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/no-typography-index.css';\n\n.component {\n position: static;\n display: flex;\n min-width: initial;\n height: 100%;\n}\n\n.option {\n display: flex;\n align-items: flex-start;\n}\n\n.flag {\n flex-shrink: 0;\n margin-right: var(--gap-8);\n}\n\n.countryName {\n margin-right: var(--gap-8);\n}\n\n.dialCode {\n color: var(--color-light-text-secondary);\n}\n"],"names":[],"mappings":";;;;AAEgB,aAAe,CAAC,WAAW,CAAC,mCAAmC,CAAC,QAAQ,CAAC,gCAAgC,CAAC,MAAM,CAAC,8BAA8B,CAAC,aAAa,CAAC,qCAAqC,CAAC,UAAU,CAAC,kCAAkC,CAAC;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import type
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import { type FieldProps } from '@alfalab/core-components-select/shared';
|
|
3
3
|
export declare const EMPTY_COUNTRY_SELECT_FIELD: {
|
|
4
4
|
value: string;
|
|
5
5
|
key: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../src/components/select-field/component.tsx"],"sourcesContent":["import React, { FC, useRef } from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport cn from 'classnames';\n\nimport type
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../src/components/select-field/component.tsx"],"sourcesContent":["import React, { type FC, useRef } from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport cn from 'classnames';\n\nimport { type FieldProps } from '@alfalab/core-components-select/shared';\nimport { useFocus } from '@alfalab/hooks';\nimport WorldMagnifierMIcon from '@alfalab/icons-glyph/WorldMagnifierMIcon';\n\nimport { FlagIcon } from '../flag-icon';\n\nimport styles from './index.module.css';\n\nexport const EMPTY_COUNTRY_SELECT_FIELD = {\n value: 'EMPTY_COUNTRY_SELECT_VALUE',\n key: 'EMPTY_COUNTRY_SELECT_KEY',\n};\n\nexport const SelectField: FC<FieldProps> = ({\n selected,\n Arrow,\n size,\n disabled,\n innerProps = {},\n}) => {\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n const [focusVisible] = useFocus(wrapperRef, 'keyboard');\n\n const ref = innerProps.ref ? mergeRefs([innerProps.ref, wrapperRef]) : wrapperRef;\n\n return (\n <div\n ref={ref}\n className={cn(styles.component, size && styles[size], {\n [styles.focusVisible]: focusVisible,\n [styles.disabled]: disabled,\n })}\n >\n <div {...innerProps} className={styles.inner}>\n <span className={styles.flagIconContainer}>\n {!selected || selected === EMPTY_COUNTRY_SELECT_FIELD ? (\n <WorldMagnifierMIcon className={styles.emptyCountryIcon} />\n ) : (\n <FlagIcon country={selected.value} />\n )}\n </span>\n {Arrow}\n </div>\n </div>\n );\n};\n"],"names":["useRef","useFocus","mergeRefs","React","cn","styles","__assign","WorldMagnifierMIcon","FlagIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;AAYa,IAAA,0BAA0B,GAAG;AACtC,IAAA,KAAK,EAAE,4BAA4B;AACnC,IAAA,GAAG,EAAE,0BAA0B;;AAG5B,IAAM,WAAW,GAAmB,UAAC,EAM3C,EAAA;;AALG,IAAA,IAAA,QAAQ,cAAA,EACR,KAAK,GAAA,EAAA,CAAA,KAAA,EACL,IAAI,GAAA,EAAA,CAAA,IAAA,EACJ,QAAQ,GAAA,EAAA,CAAA,QAAA,EACR,EAAe,GAAA,EAAA,CAAA,UAAA,EAAf,UAAU,GAAA,EAAA,KAAA,MAAA,GAAG,EAAE,GAAA,EAAA;AAEf,IAAA,IAAM,UAAU,GAAGA,YAAM,CAAiB,IAAI,CAAC;IAExC,IAAA,YAAY,GAAIC,cAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA,CAAA,CAApC;IAEnB,IAAM,GAAG,GAAG,UAAU,CAAC,GAAG,GAAGC,0BAAS,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,GAAG,UAAU;AAEjF,IAAA,QACIC,sBACI,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,GAAG,EAAE,GAAG,EACR,SAAS,EAAEC,mBAAE,CAACC,YAAM,CAAC,SAAS,EAAE,IAAI,IAAIA,YAAM,CAAC,IAAI,CAAC,GAAA,EAAA,GAAA,EAAA;AAChD,YAAA,EAAA,CAACA,YAAM,CAAC,YAAY,CAAA,GAAG,YAAY;AACnC,YAAA,EAAA,CAACA,YAAM,CAAC,QAAQ,CAAA,GAAG,QAAQ;AAC7B,YAAA,EAAA,EAAA,EAAA;AAEF,QAAAF,sBAAA,CAAA,aAAA,CAAA,KAAA,EAAAG,cAAA,CAAA,EAAA,EAAS,UAAU,EAAE,EAAA,SAAS,EAAED,YAAM,CAAC,KAAK,EAAA,CAAA;AACxC,YAAAF,sBAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAEE,YAAM,CAAC,iBAAiB,EAAA,EACpC,CAAC,QAAQ,IAAI,QAAQ,KAAK,0BAA0B,IACjDF,sBAAA,CAAA,aAAA,CAACI,oCAAmB,EAAC,EAAA,SAAS,EAAEF,YAAM,CAAC,gBAAgB,EAAA,CAAI,KAE3DF,sBAAA,CAAA,aAAA,CAACK,kBAAQ,EAAA,EAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,EAAA,CAAI,CACxC,CACE;YACN,KAAK,CACJ,CACJ;AAEd;;;;;"}
|
|
@@ -11,33 +11,33 @@
|
|
|
11
11
|
} :root {
|
|
12
12
|
--focus-color: var(--color-light-status-info);
|
|
13
13
|
--disabled-cursor: not-allowed;
|
|
14
|
-
} .intl-phone-
|
|
14
|
+
} .intl-phone-input__component_el72z {
|
|
15
15
|
height: 100%;
|
|
16
16
|
cursor: pointer;
|
|
17
17
|
outline: none;
|
|
18
18
|
position: relative;
|
|
19
|
-
} .intl-phone-
|
|
19
|
+
} .intl-phone-input__flagIconContainer_el72z {
|
|
20
20
|
display: flex;
|
|
21
21
|
justify-content: center;
|
|
22
22
|
align-items: center;
|
|
23
23
|
width: 24px;
|
|
24
24
|
height: 24px;
|
|
25
25
|
margin-right: var(--gap-4);
|
|
26
|
-
} .intl-phone-
|
|
26
|
+
} .intl-phone-input__emptyCountryIcon_el72z {
|
|
27
27
|
color: var(--color-light-neutral-700);
|
|
28
|
-
} .intl-phone-
|
|
28
|
+
} .intl-phone-input__disabled_el72z {
|
|
29
29
|
cursor: var(--disabled-cursor);
|
|
30
|
-
} .intl-phone-
|
|
30
|
+
} .intl-phone-input__inner_el72z {
|
|
31
31
|
position: relative;
|
|
32
32
|
display: flex;
|
|
33
33
|
align-items: center;
|
|
34
34
|
height: 100%;
|
|
35
35
|
padding-left: var(--gap-12);
|
|
36
36
|
outline: none;
|
|
37
|
-
} .intl-phone-
|
|
38
|
-
.intl-phone-
|
|
37
|
+
} .intl-phone-input__l_el72z .intl-phone-input__inner_el72z,
|
|
38
|
+
.intl-phone-input__xl_el72z .intl-phone-input__inner_el72z {
|
|
39
39
|
padding-left: var(--gap-16);
|
|
40
|
-
} .intl-phone-
|
|
40
|
+
} .intl-phone-input__focusVisible_el72z {
|
|
41
41
|
outline: 2px solid var(--focus-color);
|
|
42
42
|
outline-offset: 2px;
|
|
43
43
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require('./index.css');
|
|
4
4
|
|
|
5
|
-
var styles = {"component":"intl-phone-
|
|
5
|
+
var styles = {"component":"intl-phone-input__component_el72z","flagIconContainer":"intl-phone-input__flagIconContainer_el72z","emptyCountryIcon":"intl-phone-input__emptyCountryIcon_el72z","disabled":"intl-phone-input__disabled_el72z","inner":"intl-phone-input__inner_el72z","l":"intl-phone-input__l_el72z","xl":"intl-phone-input__xl_el72z","focusVisible":"intl-phone-input__focusVisible_el72z"};
|
|
6
6
|
|
|
7
7
|
module.exports = styles;
|
|
8
8
|
//# sourceMappingURL=index.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.css.js","sources":["../../src/components/select-field/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n\n.component {\n height: 100%;\n cursor: pointer;\n outline: none;\n position: relative;\n}\n\n.flagIconContainer {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 24px;\n height: 24px;\n margin-right: var(--gap-4);\n}\n\n.emptyCountryIcon {\n color: var(--color-light-neutral-700);\n}\n\n.disabled {\n cursor: var(--disabled-cursor);\n}\n\n.inner {\n position: relative;\n display: flex;\n align-items: center;\n height: 100%;\n padding-left: var(--gap-12);\n outline: none;\n}\n\n.l .inner,\n.xl .inner {\n padding-left: var(--gap-16);\n}\n\n.focusVisible {\n @mixin focus-outline;\n}\n"],"names":[],"mappings":";;;;AAEgB,aAAe,CAAC,WAAW,CAAC,mCAAmC,CAAC,mBAAmB,CAAC,2CAA2C,CAAC,kBAAkB,CAAC,0CAA0C,CAAC,UAAU,CAAC,kCAAkC,CAAC,OAAO,CAAC,+BAA+B,CAAC,GAAG,CAAC,2BAA2B,CAAC,IAAI,CAAC,4BAA4B,CAAC,cAAc,CAAC,sCAAsC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.module.css.js","sources":["../../src/components/select-field/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/no-typography-index.css';\n\n.component {\n height: 100%;\n cursor: pointer;\n outline: none;\n position: relative;\n}\n\n.flagIconContainer {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 24px;\n height: 24px;\n margin-right: var(--gap-4);\n}\n\n.emptyCountryIcon {\n color: var(--color-light-neutral-700);\n}\n\n.disabled {\n cursor: var(--disabled-cursor);\n}\n\n.inner {\n position: relative;\n display: flex;\n align-items: center;\n height: 100%;\n padding-left: var(--gap-12);\n outline: none;\n}\n\n.l .inner,\n.xl .inner {\n padding-left: var(--gap-16);\n}\n\n.focusVisible {\n @mixin focus-outline;\n}\n"],"names":[],"mappings":";;;;AAEgB,aAAe,CAAC,WAAW,CAAC,mCAAmC,CAAC,mBAAmB,CAAC,2CAA2C,CAAC,kBAAkB,CAAC,0CAA0C,CAAC,UAAU,CAAC,kCAAkC,CAAC,OAAO,CAAC,+BAA+B,CAAC,GAAG,CAAC,2BAA2B,CAAC,IAAI,CAAC,4BAA4B,CAAC,cAAc,CAAC,sCAAsC,CAAC;;;;"}
|
package/cssm/component.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { CountryCode } from 'libphonenumber-js/min';
|
|
3
|
-
import { InputAutocompleteDesktopProps } from '@alfalab/core-components-input-autocomplete/cssm/desktop';
|
|
4
|
-
import type
|
|
5
|
-
import { Country } from '@alfalab/utils';
|
|
2
|
+
import { type CountryCode } from 'libphonenumber-js/min';
|
|
3
|
+
import { type InputAutocompleteDesktopProps } from '@alfalab/core-components-input-autocomplete/cssm/desktop';
|
|
4
|
+
import { type SelectProps } from '@alfalab/core-components-select/cssm';
|
|
5
|
+
import { type Country } from '@alfalab/utils';
|
|
6
6
|
declare type MaxPhoneLenByCountry = Record<string, number>;
|
|
7
7
|
export declare type IntlPhoneInputProps = Partial<Omit<InputAutocompleteDesktopProps, 'onChange'>> & Pick<SelectProps, 'preventFlip'> & {
|
|
8
8
|
/**
|
package/cssm/component.js
CHANGED
|
@@ -54,11 +54,12 @@ var DEFAULT_MAX_PHONE_LEN_BY_COUNTRY = { RU: 11 };
|
|
|
54
54
|
* use InternationalPhoneInput instead
|
|
55
55
|
*/
|
|
56
56
|
var IntlPhoneInput = React.forwardRef(function (_a, ref) {
|
|
57
|
-
var _b
|
|
58
|
-
var
|
|
57
|
+
var _b;
|
|
58
|
+
var _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.readOnly, readOnly = _d === void 0 ? false : _d, _e = _a.hideCountrySelect, hideCountrySelect = _e === void 0 ? false : _e, _f = _a.canBeEmptyCountry, canBeEmptyCountry = _f === void 0 ? false : _f, _g = _a.ruNumberPriority, ruNumberPriority = _g === void 0 ? false : _g, _h = _a.clear, clear = _h === void 0 ? false : _h, _j = _a.size, size = _j === void 0 ? 'm' : _j, _k = _a.colors, colors = _k === void 0 ? 'default' : _k, _l = _a.options, options = _l === void 0 ? [] : _l, _m = _a.countries, countries = _m === void 0 ? utils.getCountries() : _m, _o = _a.clearableCountryCode, clearableCountryCode = _o === void 0 ? true : _o, _p = _a.maxDialCodeLength, maxDialCodeLength = _p === void 0 ? MAX_DIAL_CODE_LENGTH : _p, className = _a.className, value = _a.value, onChange = _a.onChange, onCountryChange = _a.onCountryChange, _q = _a.defaultCountryIso2, defaultCountryIso2 = _q === void 0 ? 'ru' : _q, preventFlip = _a.preventFlip, inputProps = _a.inputProps, _r = _a.maxPhoneLen, maxPhoneLen = _r === void 0 ? DEFAULT_MAX_PHONE_LEN_BY_COUNTRY : _r, restProps = tslib.__rest(_a, ["disabled", "readOnly", "hideCountrySelect", "canBeEmptyCountry", "ruNumberPriority", "clear", "size", "colors", "options", "countries", "clearableCountryCode", "maxDialCodeLength", "className", "value", "onChange", "onCountryChange", "defaultCountryIso2", "preventFlip", "inputProps", "maxPhoneLen"]);
|
|
59
|
+
var _s = React.useState(defaultCountryIso2.toLowerCase()), countryIso2 = _s[0], setCountryIso2 = _s[1];
|
|
59
60
|
var inputRef = React.useRef(null);
|
|
60
|
-
var
|
|
61
|
-
var
|
|
61
|
+
var _t = React.useState(null), inputWrapperRef = _t[0], setInputWrapperRef = _t[1];
|
|
62
|
+
var _u = React.useState(), caretPos = _u[0], setCaretPos = _u[1];
|
|
62
63
|
var phoneLibUtils = React.useRef();
|
|
63
64
|
var formatPhone = function (inputValue, iso2) {
|
|
64
65
|
if (iso2 === void 0) { iso2 = countryIso2; }
|
|
@@ -346,7 +347,7 @@ var IntlPhoneInput = React.forwardRef(function (_a, ref) {
|
|
|
346
347
|
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
|
347
348
|
}, [value, canBeEmptyCountry, countryIso2, defaultCountryIso2]);
|
|
348
349
|
useCaretAvoidCountryCode.useCaretAvoidCountryCode({ inputRef: inputRef, countryCodeLength: countryCodeLength, clearableCountryCode: clearableCountryCode });
|
|
349
|
-
return (React__default.default.createElement(desktop.InputAutocompleteDesktop, tslib.__assign({}, restProps, { ref: ref, inputProps: tslib.__assign(tslib.__assign({ clear: clear && !isEmptyValue }, inputProps), { onClear: handleClear, ref: inputRef, wrapperRef: setInputWrapperRef, type: 'tel', colors: colors, className: cn__default.default(className, styles__default.default[size]), addonsClassName: styles__default.default.addons, onKeyDown: handleKeyDown, onPaste: handlePaste, leftAddons: hideCountrySelect ? (React__default.default.createElement("span", { className: styles__default.default.flagIconWrapper }, countryIso2 ? (React__default.default.createElement(component.FlagIcon, { country: countryIso2 })) : (React__default.default.createElement(WorldMagnifierMIcon__default.default, { className: styles__default.default.emptyCountryIcon })))) : (countries.length > 1 && (React__default.default.createElement(component$1.CountriesSelect, { dataTestId: 'countries-select', disabled: disabled || readOnly, size: size, selected: countryIso2, countries: countries, onChange: handleSelectChange, fieldWidth: inputWrapperRef
|
|
350
|
+
return (React__default.default.createElement(desktop.InputAutocompleteDesktop, tslib.__assign({}, restProps, { ref: ref, inputProps: tslib.__assign(tslib.__assign({ clear: clear && !isEmptyValue }, inputProps), { onClear: handleClear, ref: inputRef, wrapperRef: setInputWrapperRef, type: 'tel', colors: colors, className: cn__default.default(className, styles__default.default[size]), addonsClassName: styles__default.default.addons, onKeyDown: handleKeyDown, onPaste: handlePaste, leftAddons: hideCountrySelect ? (React__default.default.createElement("span", { className: styles__default.default.flagIconWrapper }, countryIso2 ? (React__default.default.createElement(component.FlagIcon, { country: countryIso2 })) : (React__default.default.createElement(WorldMagnifierMIcon__default.default, { className: styles__default.default.emptyCountryIcon })))) : (countries.length > 1 && (React__default.default.createElement(component$1.CountriesSelect, { dataTestId: 'countries-select', disabled: disabled || readOnly, size: size, selected: countryIso2, countries: countries, onChange: handleSelectChange, fieldWidth: (_b = inputWrapperRef === null || inputWrapperRef === void 0 ? void 0 : inputWrapperRef.getBoundingClientRect().width) !== null && _b !== void 0 ? _b : null, preventFlip: preventFlip }))) }), optionsListWidth: 'field', closeOnSelect: true, onInput: handleInputChange, onChange: handleChange, options: options, disabled: disabled, readOnly: readOnly, size: size, className: className, value: value })));
|
|
350
351
|
});
|
|
351
352
|
|
|
352
353
|
exports.IntlPhoneInput = IntlPhoneInput;
|