react-gldn-kit 0.1.57 → 0.1.59

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.
@@ -0,0 +1,2 @@
1
+ import { IconProps } from '../types';
2
+ export declare const INSvg: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.INSvg = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var INSvg = function (props) {
17
+ var _a = props.width, width = _a === void 0 ? '20' : _a, _b = props.height, height = _b === void 0 ? '20' : _b, classes = props.classes;
18
+ return ((0, jsx_runtime_1.jsxs)("svg", __assign({ className: classes, width: width, height: height, viewBox: "-45 -30 90 60", fill: "#07038D" }, { children: [(0, jsx_runtime_1.jsx)("title", { children: "Flag of India" }), (0, jsx_runtime_1.jsx)("path", { fill: "#FFF", d: "m-45-30h90v60h-90z" }), (0, jsx_runtime_1.jsx)("path", { fill: "#FF6820", d: "m-45-30h90v20h-90z" }), (0, jsx_runtime_1.jsx)("path", { fill: "#046A38", d: "m-45 10h90v20h-90z" }), (0, jsx_runtime_1.jsx)("circle", { r: "9.25" }), (0, jsx_runtime_1.jsx)("circle", { fill: "#FFF", r: "8" }), (0, jsx_runtime_1.jsx)("circle", { r: "1.6" }), (0, jsx_runtime_1.jsxs)("g", __assign({ id: "d" }, { children: [(0, jsx_runtime_1.jsxs)("g", __assign({ id: "c" }, { children: [(0, jsx_runtime_1.jsxs)("g", __assign({ id: "b" }, { children: [(0, jsx_runtime_1.jsxs)("g", __assign({ id: "a" }, { children: [(0, jsx_runtime_1.jsx)("path", { d: "m0-8 .3 4.81409L0-.80235-.3-3.18591z" }), (0, jsx_runtime_1.jsx)("circle", { transform: "rotate(7.5)", r: "0.35", cy: "-8" })] })), (0, jsx_runtime_1.jsx)("use", { xlinkHref: "#a", transform: "scale(-1)" })] })), (0, jsx_runtime_1.jsx)("use", { xlinkHref: "#b", transform: "rotate(15)" })] })), (0, jsx_runtime_1.jsx)("use", { xlinkHref: "#c", transform: "rotate(30)" })] })), (0, jsx_runtime_1.jsx)("use", { xlinkHref: "#d", transform: "rotate(60)" }), (0, jsx_runtime_1.jsx)("use", { xlinkHref: "#d", transform: "rotate(120)" })] })));
19
+ };
20
+ exports.INSvg = INSvg;
@@ -0,0 +1,2 @@
1
+ import { IconProps } from '../types';
2
+ export declare const PKSvg: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.PKSvg = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var PKSvg = function (props) {
17
+ var _a = props.width, width = _a === void 0 ? '20' : _a, _b = props.height, height = _b === void 0 ? '20' : _b, classes = props.classes;
18
+ return ((0, jsx_runtime_1.jsxs)("svg", __assign({ width: width, height: height, viewBox: "-75 -40 120 80", fill: "none", className: classes }, { children: [(0, jsx_runtime_1.jsx)("rect", { x: "-75", y: "-40", width: "120", height: "80", fill: "#fff" }), (0, jsx_runtime_1.jsx)("rect", { x: "-45", y: "-40", width: "90", height: "80", fill: "#01411C" }), (0, jsx_runtime_1.jsx)("circle", { r: "24", fill: "#fff" }), (0, jsx_runtime_1.jsx)("circle", { r: "22", cx: "-7", cy: "-40", fill: "#01411C", transform: "rotate(-41.63354, 45, -40)" }), (0, jsx_runtime_1.jsx)("polygon", { points: "0,-513674 301930,415571 -488533,-158734 488533,-158734 -301930,415571", fill: "#fff", transform: "rotate(-41.63354) translate(16) rotate(18) scale(0.00001557408)" })] })));
19
+ };
20
+ exports.PKSvg = PKSvg;
@@ -15,6 +15,6 @@ exports.UkrSvg = void 0;
15
15
  var jsx_runtime_1 = require("react/jsx-runtime");
16
16
  var UkrSvg = function (props) {
17
17
  var _a = props.width, width = _a === void 0 ? '20' : _a, _b = props.height, height = _b === void 0 ? '20' : _b, classes = props.classes;
18
- return ((0, jsx_runtime_1.jsxs)("svg", __assign({ width: width, height: height, viewBox: "0 0 40 40", fill: "none", className: classes }, { children: [(0, jsx_runtime_1.jsx)("path", { d: "M20 40C31.0457 40 40 31.0457 40 20C40 8.9543 31.0457 0 20 0C8.9543 0 0 8.9543 0 20C0 31.0457 8.9543 40 20 40Z", fill: "#FFDA44" }), (0, jsx_runtime_1.jsx)("path", { d: "M0 20C0 8.95437 8.95437 0 20 0C31.0456 0 40 8.95437 40 20", fill: "#338AF3" })] })));
18
+ return ((0, jsx_runtime_1.jsxs)("svg", __assign({ width: width, height: height, viewBox: "0 0 24 24", fill: "none", className: classes }, { children: [(0, jsx_runtime_1.jsx)("path", { d: "M20 40C31.0457 40 40 31.0457 40 20C40 8.9543 31.0457 0 20 0C8.9543 0 0 8.9543 0 20C0 31.0457 8.9543 40 20 40Z", fill: "#FFDA44" }), (0, jsx_runtime_1.jsx)("path", { d: "M0 20C0 8.95437 8.95437 0 20 0C31.0456 0 40 8.95437 40 20", fill: "#338AF3" })] })));
19
19
  };
20
20
  exports.UkrSvg = UkrSvg;
@@ -0,0 +1,2 @@
1
+ import { IconProps } from '../types';
2
+ export declare const WorldSvg: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.WorldSvg = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var WorldSvg = function (props) {
17
+ var _a = props.width, width = _a === void 0 ? '20' : _a, _b = props.height, height = _b === void 0 ? '20' : _b, classes = props.classes;
18
+ return ((0, jsx_runtime_1.jsx)("svg", __assign({ width: width, height: height, viewBox: "0 0 24 24", fill: "none", className: classes }, { children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M6.15407 7.30116C7.52877 5.59304 9.63674 4.5 12 4.5C12.365 4.5 12.7238 4.52607 13.0748 4.57644L13.7126 5.85192L11.2716 8.2929L8.6466 8.6679L7.36009 9.95441L6.15407 7.30116ZM5.2011 8.82954C4.75126 9.79256 4.5 10.8669 4.5 12C4.5 15.6945 7.17133 18.7651 10.6878 19.3856L11.0989 18.7195L8.8147 15.547L10.3741 13.5256L9.63268 13.1549L6.94027 13.6036L6.41366 11.4972L5.2011 8.82954ZM7.95559 11.4802L8.05962 11.8964L9.86722 11.5951L11.3726 12.3478L14.0824 11.9714L18.9544 14.8135C19.3063 13.9447 19.5 12.995 19.5 12C19.5 8.93729 17.6642 6.30336 15.033 5.13856L15.5377 6.1481L11.9787 9.70711L9.35371 10.0821L7.95559 11.4802ZM18.2539 16.1414C16.9774 18.0652 14.8369 19.366 12.3859 19.4902L12.9011 18.6555L10.6853 15.578L12.0853 13.7632L13.7748 13.5286L18.2539 16.1414ZM12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3Z", fill: "white" }) })));
19
+ };
20
+ exports.WorldSvg = WorldSvg;
@@ -0,0 +1,16 @@
1
+ import { DefaultInputType } from 'components/ui/Inputs/BaseInput/types';
2
+ import React, { ReactElement } from 'react';
3
+ type Props = {
4
+ phone: DefaultInputType;
5
+ Flag: React.FC;
6
+ code: string;
7
+ handleSetValue: (d: React.ChangeEvent<HTMLInputElement>) => void;
8
+ children?: ReactElement;
9
+ toggleValue?: () => void;
10
+ isOpened?: boolean;
11
+ mask?: string;
12
+ placeholder: string;
13
+ classes?: string;
14
+ };
15
+ declare const PhoneView: (props: Props) => import("react/jsx-runtime").JSX.Element;
16
+ export default PhoneView;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ var jsx_runtime_1 = require("react/jsx-runtime");
41
+ var classnames_1 = __importDefault(require("classnames"));
42
+ var ArrowButton_1 = require("components/ui/Buttons/ArrowButton");
43
+ var BaseInputUi_1 = require("components/ui/Inputs/BaseInput/BaseInputUi");
44
+ var validation_1 = require("service/validation");
45
+ var styles = __importStar(require("./PhoneView.module.css"));
46
+ var PhoneView = function (props) {
47
+ var _a, _b;
48
+ var phone = props.phone, Flag = props.Flag, children = props.children, toggleValue = props.toggleValue, isOpened = props.isOpened, mask = props.mask, code = props.code, handleSetValue = props.handleSetValue, classes = props.classes, placeholder = props.placeholder;
49
+ var value = phone.value, errorText = phone.errorText;
50
+ return ((0, jsx_runtime_1.jsxs)("div", __assign({ className: (0, classnames_1.default)(styles.row, classes, (_a = {},
51
+ _a[styles.opened] = isOpened,
52
+ _a)) }, { children: [(0, jsx_runtime_1.jsx)("div", __assign({ className: styles.code }, { children: (0, jsx_runtime_1.jsx)(Flag, {}) })), (0, jsx_runtime_1.jsx)(BaseInputUi_1.BaseInputUi, __assign({ size: "full", placeholder: placeholder, value: value, baseValue: code, defaultValue: code, handleChange: handleSetValue, patternFn: (0, validation_1.replaceValueByMask)(mask), classes: (0, classnames_1.default)(styles.input, (_b = {},
53
+ _b[styles.errorBorder] = errorText,
54
+ _b)) }, { children: children })), (0, jsx_runtime_1.jsx)("div", __assign({ className: styles.arrow }, { children: toggleValue && ((0, jsx_runtime_1.jsx)(ArrowButton_1.ArrowButton, { isOpened: isOpened, toggleState: toggleValue })) }))] })));
55
+ };
56
+ exports.default = PhoneView;
@@ -0,0 +1,11 @@
1
+ import { PhoneMask } from './types';
2
+ export declare const PHONE_MASK: {
3
+ [countryCodeDefault: string]: PhoneMask;
4
+ };
5
+ export declare const DEFAULT_COUNTRY_INFO: {
6
+ name: string;
7
+ code: string;
8
+ mask: string;
9
+ length: number;
10
+ Flag: (props: import("../../Icons/types").IconProps) => import("react/jsx-runtime").JSX.Element;
11
+ };
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_COUNTRY_INFO = exports.PHONE_MASK = void 0;
4
+ var BnSvg_1 = require("components/ui/Icons/FlagIcons/BnSvg");
5
+ var AzeSvg_1 = require("components/ui/Icons/FlagIcons/AzeSvg");
6
+ var TrSvg_1 = require("components/ui/Icons/FlagIcons/TrSvg");
7
+ var PtSvg_1 = require("components/ui/Icons/FlagIcons/PtSvg");
8
+ var PKSvg_1 = require("components/ui/Icons/FlagIcons/PKSvg");
9
+ var InSvg_1 = require("components/ui/Icons/FlagIcons/InSvg");
10
+ var WorldSvg_1 = require("components/ui/Icons/FlagIcons/WorldSvg");
11
+ exports.PHONE_MASK = {
12
+ BD: {
13
+ name: 'Bangladesh',
14
+ code: '+880',
15
+ mask: 'XXXX XXXXXX',
16
+ length: 10,
17
+ Flag: BnSvg_1.BnSvg,
18
+ },
19
+ TR: {
20
+ name: 'Turkey',
21
+ code: '+90',
22
+ mask: 'XXX XXX XXXX',
23
+ length: 10,
24
+ Flag: TrSvg_1.TrSvg,
25
+ },
26
+ IN: {
27
+ name: 'India',
28
+ code: '+91',
29
+ mask: 'XXXXX XXXXX',
30
+ length: 10,
31
+ Flag: InSvg_1.INSvg,
32
+ },
33
+ AZ: {
34
+ name: 'Azerbaijan',
35
+ code: '+994',
36
+ mask: 'XX XXX XX XX',
37
+ length: 9,
38
+ Flag: AzeSvg_1.AzeSvg,
39
+ },
40
+ PK: {
41
+ name: 'Pakistan',
42
+ code: '+92',
43
+ mask: 'XXXX XXXXXXX',
44
+ length: 10,
45
+ Flag: PKSvg_1.PKSvg,
46
+ },
47
+ BR: {
48
+ name: 'Brazil',
49
+ code: '+55',
50
+ mask: 'XX XXXXX XXXX',
51
+ length: 11,
52
+ Flag: PtSvg_1.PtSvg,
53
+ },
54
+ };
55
+ exports.DEFAULT_COUNTRY_INFO = {
56
+ name: '-',
57
+ code: '+',
58
+ mask: '',
59
+ length: 0,
60
+ Flag: WorldSvg_1.WorldSvg,
61
+ };
@@ -41,7 +41,6 @@ exports.PhoneInput = void 0;
41
41
  var jsx_runtime_1 = require("react/jsx-runtime");
42
42
  var react_1 = require("react");
43
43
  var classnames_1 = __importDefault(require("classnames"));
44
- var react_phone_number_input_1 = __importStar(require("react-phone-number-input"));
45
44
  var validation_1 = require("service/validation");
46
45
  var Text_1 = require("components/Text");
47
46
  var BaseButton_1 = require("components/ui/Buttons/BaseButton");
@@ -49,21 +48,15 @@ var Timer_1 = __importDefault(require("components/ui/Timer"));
49
48
  var constant_1 = require("../BaseInput/constant");
50
49
  var styles = __importStar(require("./PhoneInput.module.css"));
51
50
  var mock_1 = require("constants/mock");
51
+ var constants_1 = require("./constants");
52
+ var WorldSvg_1 = require("components/ui/Icons/FlagIcons/WorldSvg");
53
+ var PhoneView_1 = __importDefault(require("./components/PhoneView"));
52
54
  var PhoneInput = function (props) {
53
- var _a;
54
- var withConfirm = props.withConfirm, requestId = props.requestId, sendDataType = props.sendDataType, children = props.children, classesWrapper = props.classesWrapper, requestCallback = props.requestCallback, onChange = props.onChange, sendKey = props.sendKey, countryCodeDefault = props.countryCodeDefault, _b = props.section, section = _b === void 0 ? undefined : _b, requestCode = props.requestCode, countryInfo = props.countryInfo, buttonClasses = props.buttonClasses;
55
- var _c = (0, react_1.useState)(constant_1.DEFAULT_INPUT_VALUE), phone = _c[0], setPhone = _c[1];
55
+ var withConfirm = props.withConfirm, requestId = props.requestId, sendDataType = props.sendDataType, children = props.children, classesWrapper = props.classesWrapper, requestCallback = props.requestCallback, onChange = props.onChange, sendKey = props.sendKey, countryCodeDefault = props.countryCodeDefault, _a = props.section, section = _a === void 0 ? undefined : _a, requestCode = props.requestCode, countryInfo = props.countryInfo, buttonClasses = props.buttonClasses;
56
+ var _b = (0, react_1.useState)(__assign(__assign({}, constant_1.DEFAULT_INPUT_VALUE), { value: '+' })), phone = _b[0], setPhone = _b[1];
57
+ var _c = (0, react_1.useState)(false), isOpened = _c[0], setOpenState = _c[1];
56
58
  var _d = (0, react_1.useState)(false), isRequestedCode = _d[0], setRequestedCodeStatus = _d[1];
57
- var defaultCountry = (0, react_1.useMemo)(function () {
58
- var _a, _b;
59
- var country = countryCodeDefault ||
60
- ((_b = (_a = mock_1.COUNTRY_MOCK.find(function (c) { return c.id === (countryInfo === null || countryInfo === void 0 ? void 0 : countryInfo.countryId); })) === null || _a === void 0 ? void 0 : _a.imageCode) === null || _b === void 0 ? void 0 : _b.toLocaleUpperCase());
61
- return country;
62
- }, [countryInfo, countryCodeDefault]);
63
- var isValidPhone = (0, react_1.useMemo)(function () {
64
- var isValid = phone.value.length > 2 && !phone.errorText;
65
- return isValid;
66
- }, [phone]);
59
+ var _e = (0, react_1.useState)(null), countryPhoneSettings = _e[0], setCountryPhoneSettings = _e[1];
67
60
  var handleRequestCode = function () {
68
61
  if (!withConfirm) {
69
62
  return;
@@ -78,47 +71,93 @@ var PhoneInput = function (props) {
78
71
  var baseKey = sendKey || '22x';
79
72
  requestCode === null || requestCode === void 0 ? void 0 : requestCode(baseKey, baseData);
80
73
  };
81
- var handleSetValue = function (value) {
82
- if (value === void 0) { value = ''; }
83
- var errorText = (0, react_phone_number_input_1.isValidPhoneNumber)(value) ? '' : 'errors.phone';
84
- if (countryCodeDefault === 'BD') {
85
- var isValidRegionCode = value.startsWith('+8801');
86
- if (!isValidRegionCode) {
87
- errorText = 'errors.phone';
88
- }
89
- }
90
- if (countryCodeDefault === 'IN') {
91
- errorText = value.length !== 13 ? 'errors.phone' : '';
74
+ var handleValidatePhoneNumber = (0, react_1.useCallback)(function (phone) {
75
+ if (!countryPhoneSettings) {
76
+ return false;
92
77
  }
93
- setPhone({ value: value, errorText: errorText });
78
+ var value = phone.replace(countryPhoneSettings.code, '').trim();
79
+ return value.length === countryPhoneSettings.length;
80
+ }, [countryPhoneSettings]);
81
+ var isValidPhone = (0, react_1.useMemo)(function () {
82
+ var isValid = countryPhoneSettings.length
83
+ ? handleValidatePhoneNumber(phone.value)
84
+ : phone.value.length > 1 && !phone.errorText;
85
+ return isValid;
86
+ }, [phone, countryPhoneSettings]);
87
+ var toggleValue = function () {
88
+ setOpenState(!isOpened);
94
89
  };
90
+ var handleChooseSettings = function (p) { return function () {
91
+ setCountryPhoneSettings(p);
92
+ setPhone({
93
+ value: p.code,
94
+ errorText: '',
95
+ });
96
+ toggleValue();
97
+ }; };
98
+ var handleSetValue = (0, react_1.useCallback)(function (_a) {
99
+ var target = _a.target;
100
+ var value = target.value;
101
+ var _b = countryPhoneSettings.length, length = _b === void 0 ? 0 : _b, code = countryPhoneSettings.code;
102
+ var fullLength = length + code.length;
103
+ if (!value) {
104
+ return;
105
+ }
106
+ if ((countryPhoneSettings === null || countryPhoneSettings === void 0 ? void 0 : countryPhoneSettings.length) &&
107
+ (value.length > fullLength || !+value || code.length > value.length)) {
108
+ return;
109
+ }
110
+ if ((countryPhoneSettings === null || countryPhoneSettings === void 0 ? void 0 : countryPhoneSettings.length) === undefined) {
111
+ return;
112
+ }
113
+ if (!length) {
114
+ setPhone({
115
+ value: "+".concat(value.replace('+', '')),
116
+ errorText: value.length > 12 && value.length < 16 ? '' : 'errors.phone',
117
+ });
118
+ return;
119
+ }
120
+ setPhone({
121
+ value: value,
122
+ errorText: handleValidatePhoneNumber(value) ? '' : 'errors.phone',
123
+ });
124
+ }, [handleValidatePhoneNumber, countryPhoneSettings]);
95
125
  var showTimer = function () {
96
126
  handleRequestCode();
97
127
  setRequestedCodeStatus(true);
98
128
  requestCallback === null || requestCallback === void 0 ? void 0 : requestCallback();
99
129
  };
130
+ (0, react_1.useEffect)(function () {
131
+ if (countryCodeDefault) {
132
+ var defaultValue = constants_1.PHONE_MASK[countryCodeDefault];
133
+ setCountryPhoneSettings(defaultValue || constants_1.DEFAULT_COUNTRY_INFO);
134
+ return;
135
+ }
136
+ if (!countryInfo) {
137
+ return;
138
+ }
139
+ var countryFullInfo = mock_1.COUNTRY_MOCK.find(function (c) { return c.id === countryInfo.countryId; });
140
+ if (!countryFullInfo) {
141
+ setCountryPhoneSettings(constants_1.DEFAULT_COUNTRY_INFO);
142
+ return;
143
+ }
144
+ var country = Object.values(constants_1.PHONE_MASK).find(function (c) { return c.code === countryFullInfo.dialCode; });
145
+ if (country) {
146
+ setPhone({ value: country.code, errorText: '' });
147
+ }
148
+ setCountryPhoneSettings(country || constants_1.DEFAULT_COUNTRY_INFO);
149
+ }, [countryCodeDefault, countryInfo]);
100
150
  (0, react_1.useEffect)(function () {
101
151
  if (phone.value && !phone.errorText) {
102
- var errorText = (0, validation_1.composeValidations)([
103
- (0, validation_1.isRequired)({ value: phone.value, errorText: 'errors.required' }),
104
- (0, validation_1.isPhone)({ value: phone.value, errorText: 'errors.phone' }),
105
- ]);
106
- // TODO first render
107
- if (errorText) {
108
- return;
109
- }
110
152
  onChange(phone.value);
111
153
  return;
112
154
  }
113
155
  onChange('');
114
156
  }, [phone, onChange]);
115
- return ((0, jsx_runtime_1.jsxs)("div", __assign({ className: (0, classnames_1.default)(styles.wrapper, classesWrapper) }, { children: [(0, jsx_runtime_1.jsx)(react_phone_number_input_1.default, __assign({ international: true, countryCallingCodeEditable: false, isvalid: phone.errorText, withCountryCallingCode: countryCodeDefault, limitMaxLength: true,
116
- // CountryCode
117
- // @ts-ignore
118
- defaultCountry: defaultCountry,
119
- // @ts-ignore
120
- countries: countryCodeDefault ? [countryCodeDefault] : undefined, disabled: isRequestedCode, onChange: handleSetValue, className: (0, classnames_1.default)(styles.input, (_a = {},
121
- _a[styles.errorBorder] = phone.errorText,
122
- _a)) }, { children: children })), phone.errorText && ((0, jsx_runtime_1.jsx)("div", __assign({ className: styles.error }, { children: (0, jsx_runtime_1.jsx)(Text_1.Text, { idT: phone.errorText }) }))), withConfirm && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isRequestedCode ? ((0, jsx_runtime_1.jsx)(Timer_1.default, { handleRequestCode: handleRequestCode })) : ((0, jsx_runtime_1.jsx)(BaseButton_1.BaseButton, { text: "getCodeBtn", disabled: !isValidPhone, color: "primary", handleClick: showTimer, size: "--button-full", centreText: true, buttonHeight: "--button-height-full", classes: buttonClasses })) }))] })));
157
+ var Flag = (countryPhoneSettings || {}).Flag;
158
+ return ((0, jsx_runtime_1.jsxs)("div", __assign({ className: (0, classnames_1.default)(styles.wrapper, classesWrapper) }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ className: styles.list }, { children: [(0, jsx_runtime_1.jsx)(PhoneView_1.default, __assign({ placeholder: (countryPhoneSettings === null || countryPhoneSettings === void 0 ? void 0 : countryPhoneSettings.name) || '', phone: phone, Flag: Flag || WorldSvg_1.WorldSvg, code: (countryPhoneSettings === null || countryPhoneSettings === void 0 ? void 0 : countryPhoneSettings.code) || '+', handleSetValue: handleSetValue, toggleValue: toggleValue, isOpened: isOpened, mask: countryPhoneSettings === null || countryPhoneSettings === void 0 ? void 0 : countryPhoneSettings.mask }, { children: children })), isOpened && ((0, jsx_runtime_1.jsx)("div", __assign({ className: styles.items }, { children: Object.values(constants_1.PHONE_MASK).map(function (p) {
159
+ var CountryFlag = p.Flag;
160
+ return ((0, jsx_runtime_1.jsx)("div", __assign({ onClick: handleChooseSettings(p) }, { children: (0, jsx_runtime_1.jsx)(PhoneView_1.default, { placeholder: "", phone: { value: p.code, errorText: '' }, Flag: CountryFlag, code: p.code, handleSetValue: console.info, mask: p.mask, classes: styles.disabledBorder }) }), p.code));
161
+ }) })))] })), phone.errorText && ((0, jsx_runtime_1.jsx)("div", __assign({ className: styles.error }, { children: (0, jsx_runtime_1.jsx)(Text_1.Text, { idT: phone.errorText }) }))), withConfirm && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isRequestedCode ? ((0, jsx_runtime_1.jsx)(Timer_1.default, { handleRequestCode: handleRequestCode })) : ((0, jsx_runtime_1.jsx)(BaseButton_1.BaseButton, { text: "getCodeBtn", disabled: !isValidPhone, color: "primary", handleClick: showTimer, size: "--button-full", centreText: true, buttonHeight: "--button-height-full", classes: buttonClasses })) }))] })));
123
162
  };
124
163
  exports.PhoneInput = PhoneInput;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ERequestIds, RecoverySubType } from 'react-memory-optimization/dist/lib/binary/types';
2
3
  import { BaseInputProps } from '../BaseInput/types';
3
4
  export type PhoneInputProps = BaseInputProps & (PhoneInputPropsWithConfirmation | PhoneInputPropsWithoutConfirmation) & {
@@ -25,3 +26,10 @@ export type PhoneInputPropsWithConfirmation = {
25
26
  requestCallback?: () => void;
26
27
  sendKey?: string;
27
28
  };
29
+ export type PhoneMask = {
30
+ name: string;
31
+ code: string;
32
+ mask: string;
33
+ length: number;
34
+ Flag: React.FC;
35
+ };
package/dist/main.css CHANGED
@@ -1473,6 +1473,81 @@
1473
1473
  color: var(--input-base-autofill-text-color);
1474
1474
  background-clip: text;
1475
1475
  }
1476
+
1477
+ .KIT__PhoneInput-module__list___GgLkp {
1478
+ position: relative;
1479
+ }
1480
+
1481
+ .KIT__PhoneInput-module__list___GgLkp .KIT__PhoneInput-module__items___UoSJS {
1482
+ position: absolute;
1483
+ top: 100%;
1484
+ width: 100%;
1485
+ left: 0;
1486
+ border: var(--input-border);
1487
+ background-color: var(--input-background);
1488
+ z-index: 3;
1489
+ border-radius: 0 0 10px 10px;
1490
+ }
1491
+
1492
+ .KIT__PhoneInput-module__list___GgLkp .KIT__PhoneInput-module__items___UoSJS .KIT__PhoneInput-module__disabledBorder___UYdKe * {
1493
+ border: none;
1494
+ background: #1F222F;
1495
+ border-radius: 0;
1496
+ }
1497
+ .KIT__PhoneView-module__row___EVJyb {
1498
+ display: flex;
1499
+ }
1500
+
1501
+ .KIT__PhoneView-module__row___EVJyb .KIT__PhoneView-module__code___y3pYW {
1502
+ border-radius: 10px 0 0 10px;
1503
+ display: flex;
1504
+ align-items: center;
1505
+ flex-wrap: nowrap;
1506
+ border: 2px solid transparent;
1507
+ border: 2px solid var(--base-700, transparent);
1508
+ border-right: 0;
1509
+ padding-left: var(--indent-s);
1510
+ padding-right: var(--indent-xs);
1511
+ background-color: var(--input-background);
1512
+
1513
+ }
1514
+
1515
+ .KIT__PhoneView-module__row___EVJyb .KIT__PhoneView-module__arrow___Qw7Mg {
1516
+ border-radius: 0 10px 10px 0;
1517
+ display: flex;
1518
+ width: 45px;
1519
+ border: 2px solid transparent;
1520
+ border: 2px solid var(--base-700, transparent);
1521
+ border-left: 0;
1522
+ align-items: center;
1523
+ justify-content: center;
1524
+
1525
+ background-color: var(--input-background);
1526
+ }
1527
+
1528
+ .KIT__PhoneView-module__row___EVJyb .KIT__PhoneView-module__arrow___Qw7Mg svg {
1529
+ transform: rotate(180deg);
1530
+ width: 15px;
1531
+ height: 10px;
1532
+ }
1533
+
1534
+ .KIT__PhoneView-module__row___EVJyb.KIT__PhoneView-module__opened___cbAQs * {
1535
+ border-bottom: 0;
1536
+ }
1537
+
1538
+ .KIT__PhoneView-module__row___EVJyb.KIT__PhoneView-module__opened___cbAQs .KIT__PhoneView-module__arrow___Qw7Mg {
1539
+ border-radius: 0 10px 0 0;
1540
+ }
1541
+
1542
+ .KIT__PhoneView-module__row___EVJyb.KIT__PhoneView-module__opened___cbAQs .KIT__PhoneView-module__code___y3pYW {
1543
+ border-radius: 10px 0 0 0;
1544
+ }
1545
+
1546
+ .KIT__PhoneView-module__input___gRvqf {
1547
+ border-right: 0;
1548
+ border-left: 0;
1549
+ border-radius: 0;
1550
+ }
1476
1551
  .KIT__Code-module__drop____Xnq2 {
1477
1552
  height: 100%;
1478
1553
  border-radius: var(--radius-1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-gldn-kit",
3
- "version": "0.1.57",
3
+ "version": "0.1.59",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "keywords": [],