ecomlab-components-next 0.1.92 → 0.1.94
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.
|
@@ -145,7 +145,7 @@ var ModalBitrixForm = function ModalBitrixForm(_ref) {
|
|
|
145
145
|
}
|
|
146
146
|
} else if (inputType === 'tel') {
|
|
147
147
|
var regex = /^\+7 \(\d{3}\) \d{3}-\d{2}-\d{2}$/;
|
|
148
|
-
if (
|
|
148
|
+
if (value.length < 1) {
|
|
149
149
|
error[id] = 'Неверный телефон';
|
|
150
150
|
isValid = false;
|
|
151
151
|
}
|
|
@@ -230,7 +230,7 @@ var ModalBitrixForm = function ModalBitrixForm(_ref) {
|
|
|
230
230
|
}
|
|
231
231
|
} else if (inputType === 'tel') {
|
|
232
232
|
var regex = /^\+7 \(\d{3}\) \d{3}-\d{2}-\d{2}$/;
|
|
233
|
-
if (
|
|
233
|
+
if (value.length < 1) {
|
|
234
234
|
isValid = false;
|
|
235
235
|
}
|
|
236
236
|
} else if (inputType === 'dropdown') {
|
|
@@ -337,6 +337,8 @@ var ModalBitrixForm = function ModalBitrixForm(_ref) {
|
|
|
337
337
|
autoComplete: false,
|
|
338
338
|
err: err === null || err === void 0 ? void 0 : err[id],
|
|
339
339
|
required: required,
|
|
340
|
+
countrySelect: inputType === 'tel',
|
|
341
|
+
countryDefault: 'TH',
|
|
340
342
|
textErr: err === null || err === void 0 ? void 0 : err[id],
|
|
341
343
|
onBlur: function onBlur(value) {
|
|
342
344
|
return handleBlur(id, inputType, value);
|
|
@@ -9,6 +9,8 @@ exports["default"] = void 0;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _imask = _interopRequireDefault(require("imask"));
|
|
11
11
|
var _libphonenumberJs = require("libphonenumber-js");
|
|
12
|
+
var _DownSelector = _interopRequireDefault(require("../../Inputs/DropDownSelector/DownSelector"));
|
|
13
|
+
var _examples = _interopRequireDefault(require("libphonenumber-js/mobile/examples"));
|
|
12
14
|
require("./InputDinamycPlaceholder.scss");
|
|
13
15
|
var _excluded = ["tooltip", "tooltipStatic", "rows", "changeValue", "setChangeValue", "classname", "placeholder", "type", "onChange", "passwordTooltip", "err", "textErr", "infoHeader", "info", "autoComplete", "disabled", "showClearIndicator", "multiline", "maxLength", "autoFocus", "variant", "size", "maxlength", "required", "onBlur", "mask", "readOnly", "countrySelect", "countryDefault"];
|
|
14
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
@@ -89,6 +91,15 @@ var InputDinamycPlaceholder = function InputDinamycPlaceholder(_ref) {
|
|
|
89
91
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
90
92
|
country = _useState10[0],
|
|
91
93
|
setCountry = _useState10[1]; // По умолчанию Россия
|
|
94
|
+
var _useState11 = (0, _react.useState)({
|
|
95
|
+
label: countryDefault,
|
|
96
|
+
value: countryDefault
|
|
97
|
+
}),
|
|
98
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
99
|
+
selectedCountry = _useState12[0],
|
|
100
|
+
setSelectedCountry = _useState12[1];
|
|
101
|
+
|
|
102
|
+
// По умолчанию Россия
|
|
92
103
|
var inputRef = (0, _react.useRef)(null);
|
|
93
104
|
var maskRef = (0, _react.useRef)(null);
|
|
94
105
|
|
|
@@ -97,14 +108,14 @@ var InputDinamycPlaceholder = function InputDinamycPlaceholder(_ref) {
|
|
|
97
108
|
|
|
98
109
|
// Обработчик изменения страны
|
|
99
110
|
var handleCountryChange = function handleCountryChange(e) {
|
|
100
|
-
var newCountry = e.
|
|
111
|
+
var newCountry = e === null || e === void 0 ? void 0 : e.value;
|
|
101
112
|
setCountry(newCountry);
|
|
102
113
|
|
|
103
114
|
// Обновляем маску для IMask
|
|
104
115
|
if (type === 'tel' && inputRef.current) {
|
|
105
116
|
var code = (0, _libphonenumberJs.getCountryCallingCode)(newCountry);
|
|
106
117
|
var newMask = {
|
|
107
|
-
mask: "+".concat(code, " (000) 000-00-00")
|
|
118
|
+
mask: countryDefault == 'RU' ? "+".concat(code, " (000) 000-00-00") : "+".concat(code, " 000000000000")
|
|
108
119
|
}; // Пример маски для России
|
|
109
120
|
|
|
110
121
|
if (maskRef.current) {
|
|
@@ -133,49 +144,48 @@ var InputDinamycPlaceholder = function InputDinamycPlaceholder(_ref) {
|
|
|
133
144
|
(0, _react.useEffect)(function () {
|
|
134
145
|
setValueInside(changeValue || '');
|
|
135
146
|
}, [changeValue]);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return (_maskRef$current = maskRef.current) === null || _maskRef$current === void 0 ? void 0 : _maskRef$current.destroy();
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
}, [type, country]);
|
|
147
|
+
|
|
148
|
+
// useEffect(() => {
|
|
149
|
+
// if (type === 'tel' && inputRef.current) {
|
|
150
|
+
// const code = getCountryCallingCode(country);
|
|
151
|
+
// const maskOptions = { mask: `+${code} 000000000000` };
|
|
152
|
+
// maskRef.current = IMask(inputRef.current, maskOptions);
|
|
153
|
+
// maskRef.current.on('accept', () => {
|
|
154
|
+
// setValueInside(maskRef.current.value);
|
|
155
|
+
// });
|
|
156
|
+
// return () => maskRef.current?.destroy();
|
|
157
|
+
// }
|
|
158
|
+
// }, [type, country]);
|
|
152
159
|
|
|
153
160
|
// Обновление значения из props
|
|
154
161
|
(0, _react.useEffect)(function () {
|
|
155
162
|
setValueInside(changeValue || '');
|
|
156
163
|
}, [changeValue]);
|
|
164
|
+
var options_country = countries.map(function (countryCode) {
|
|
165
|
+
return {
|
|
166
|
+
label: "".concat(getCountryName(countryCode), " +").concat((0, _libphonenumberJs.getCountryCallingCode)(countryCode)),
|
|
167
|
+
value: "".concat(getCountryName(countryCode))
|
|
168
|
+
};
|
|
169
|
+
});
|
|
157
170
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
158
171
|
className: "input-dinamyc-placeholder",
|
|
159
172
|
style: {
|
|
160
173
|
width: '100%',
|
|
161
174
|
marginBottom: tooltip ? '24px' : ''
|
|
162
175
|
}
|
|
163
|
-
}, countrySelect && /*#__PURE__*/_react["default"].createElement("
|
|
164
|
-
|
|
165
|
-
|
|
176
|
+
}, countrySelect && /*#__PURE__*/_react["default"].createElement(_DownSelector["default"], {
|
|
177
|
+
options_prop: options_country,
|
|
178
|
+
state: selectedCountry,
|
|
179
|
+
setState: function setState(e) {
|
|
180
|
+
setSelectedCountry(e);
|
|
181
|
+
handleCountryChange(e);
|
|
182
|
+
},
|
|
183
|
+
width: "100%",
|
|
184
|
+
isClearable: false,
|
|
166
185
|
style: {
|
|
167
|
-
marginRight: '10px',
|
|
168
|
-
padding: '8px',
|
|
169
|
-
borderRadius: '4px',
|
|
170
|
-
border: '1px solid #ccc',
|
|
171
186
|
marginBottom: '12px'
|
|
172
187
|
}
|
|
173
|
-
},
|
|
174
|
-
return /*#__PURE__*/_react["default"].createElement("option", {
|
|
175
|
-
key: countryCode,
|
|
176
|
-
value: countryCode
|
|
177
|
-
}, getCountryName(countryCode), " (+", (0, _libphonenumberJs.getCountryCallingCode)(countryCode), ")");
|
|
178
|
-
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
188
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
179
189
|
className: "".concat(err ? 'input-box__err' : 'input-box', " ").concat(size === 's' ? 'size-s' : 'size-l', " ").concat(disabled ? 'input-box_disabled' : '')
|
|
180
190
|
}, /*#__PURE__*/_react["default"].createElement("input", {
|
|
181
191
|
ref: inputRef,
|