@xsolla/xui-input-phone 0.136.0 → 0.137.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/web/index.js +116 -38
- package/web/index.js.map +1 -1
- package/web/index.mjs +91 -13
- package/web/index.mjs.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-input-phone",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.137.0",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"test:coverage": "vitest run --coverage"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@xsolla/xui-core": "0.
|
|
17
|
-
"@xsolla/xui-primitives-core": "0.
|
|
16
|
+
"@xsolla/xui-core": "0.137.0",
|
|
17
|
+
"@xsolla/xui-primitives-core": "0.137.0",
|
|
18
18
|
"libphonenumber-js": "^1.10.56"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
package/web/index.js
CHANGED
|
@@ -41,13 +41,85 @@ __export(index_exports, {
|
|
|
41
41
|
module.exports = __toCommonJS(index_exports);
|
|
42
42
|
|
|
43
43
|
// src/InputPhone.tsx
|
|
44
|
-
var
|
|
44
|
+
var import_react4 = __toESM(require("react"));
|
|
45
45
|
|
|
46
46
|
// ../primitives-web/src/Box.tsx
|
|
47
|
-
var
|
|
47
|
+
var import_react2 = __toESM(require("react"));
|
|
48
48
|
var import_styled_components = __toESM(require("styled-components"));
|
|
49
|
+
|
|
50
|
+
// ../primitives-web/src/filterDOMProps.ts
|
|
51
|
+
var import_react = __toESM(require("react"));
|
|
52
|
+
|
|
53
|
+
// ../../node_modules/@emotion/memoize/dist/memoize.esm.js
|
|
54
|
+
function memoize(fn) {
|
|
55
|
+
var cache = {};
|
|
56
|
+
return function(arg) {
|
|
57
|
+
if (cache[arg] === void 0) cache[arg] = fn(arg);
|
|
58
|
+
return cache[arg];
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
var memoize_esm_default = memoize;
|
|
62
|
+
|
|
63
|
+
// ../../node_modules/@emotion/is-prop-valid/dist/is-prop-valid.esm.js
|
|
64
|
+
var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|inert|itemProp|itemScope|itemType|itemID|itemRef|on|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/;
|
|
65
|
+
var index = memoize_esm_default(
|
|
66
|
+
function(prop) {
|
|
67
|
+
return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110 && prop.charCodeAt(2) < 91;
|
|
68
|
+
}
|
|
69
|
+
/* Z+1 */
|
|
70
|
+
);
|
|
71
|
+
var is_prop_valid_esm_default = index;
|
|
72
|
+
|
|
73
|
+
// ../primitives-web/src/filterDOMProps.ts
|
|
74
|
+
var ADDITIONAL_BLOCKED_PROPS = /* @__PURE__ */ new Set([
|
|
75
|
+
// RN-only event handlers (pass isPropValid's on* pattern)
|
|
76
|
+
"onPress",
|
|
77
|
+
"onChangeText",
|
|
78
|
+
"onLayout",
|
|
79
|
+
"onMoveShouldSetResponder",
|
|
80
|
+
"onResponderGrant",
|
|
81
|
+
"onResponderMove",
|
|
82
|
+
"onResponderRelease",
|
|
83
|
+
"onResponderTerminate",
|
|
84
|
+
// SVG attributes that pass isPropValid
|
|
85
|
+
"strokeWidth",
|
|
86
|
+
// CSS properties that pass isPropValid but are used as component props
|
|
87
|
+
"overflow",
|
|
88
|
+
"cursor",
|
|
89
|
+
"fontSize",
|
|
90
|
+
"fontWeight",
|
|
91
|
+
"fontFamily",
|
|
92
|
+
"textDecoration"
|
|
93
|
+
]);
|
|
94
|
+
function shouldForwardProp(key) {
|
|
95
|
+
if (ADDITIONAL_BLOCKED_PROPS.has(key)) return false;
|
|
96
|
+
return is_prop_valid_esm_default(key);
|
|
97
|
+
}
|
|
98
|
+
function createFilteredElement(defaultTag) {
|
|
99
|
+
const Component = import_react.default.forwardRef(
|
|
100
|
+
({ children, elementType, ...props }, ref) => {
|
|
101
|
+
const Tag = elementType || defaultTag;
|
|
102
|
+
const htmlProps = {};
|
|
103
|
+
for (const key of Object.keys(props)) {
|
|
104
|
+
if (shouldForwardProp(key)) {
|
|
105
|
+
htmlProps[key] = props[key];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return import_react.default.createElement(
|
|
109
|
+
Tag,
|
|
110
|
+
{ ref, ...htmlProps },
|
|
111
|
+
children
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
Component.displayName = `Filtered(${defaultTag})`;
|
|
116
|
+
return Component;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ../primitives-web/src/Box.tsx
|
|
49
120
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
50
|
-
var
|
|
121
|
+
var FilteredDiv = createFilteredElement("div");
|
|
122
|
+
var StyledBox = (0, import_styled_components.default)(FilteredDiv)`
|
|
51
123
|
display: flex;
|
|
52
124
|
box-sizing: border-box;
|
|
53
125
|
background-color: ${(props) => props.backgroundColor || "transparent"};
|
|
@@ -134,7 +206,7 @@ var StyledBox = import_styled_components.default.div`
|
|
|
134
206
|
${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
|
|
135
207
|
}
|
|
136
208
|
`;
|
|
137
|
-
var Box =
|
|
209
|
+
var Box = import_react2.default.forwardRef(
|
|
138
210
|
({
|
|
139
211
|
children,
|
|
140
212
|
onPress,
|
|
@@ -159,6 +231,8 @@ var Box = import_react.default.forwardRef(
|
|
|
159
231
|
type,
|
|
160
232
|
disabled,
|
|
161
233
|
id,
|
|
234
|
+
testID,
|
|
235
|
+
"data-testid": dataTestId,
|
|
162
236
|
...props
|
|
163
237
|
}, ref) => {
|
|
164
238
|
if (as === "img" && src) {
|
|
@@ -186,7 +260,7 @@ var Box = import_react.default.forwardRef(
|
|
|
186
260
|
StyledBox,
|
|
187
261
|
{
|
|
188
262
|
ref,
|
|
189
|
-
as,
|
|
263
|
+
elementType: as,
|
|
190
264
|
id,
|
|
191
265
|
type: as === "button" ? type || "button" : void 0,
|
|
192
266
|
disabled: as === "button" ? disabled : void 0,
|
|
@@ -206,6 +280,7 @@ var Box = import_react.default.forwardRef(
|
|
|
206
280
|
"aria-controls": ariaControls,
|
|
207
281
|
"aria-live": ariaLive,
|
|
208
282
|
tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
|
|
283
|
+
"data-testid": dataTestId || testID,
|
|
209
284
|
...props,
|
|
210
285
|
children
|
|
211
286
|
}
|
|
@@ -217,7 +292,8 @@ Box.displayName = "Box";
|
|
|
217
292
|
// ../primitives-web/src/Text.tsx
|
|
218
293
|
var import_styled_components2 = __toESM(require("styled-components"));
|
|
219
294
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
220
|
-
var
|
|
295
|
+
var FilteredSpan = createFilteredElement("span");
|
|
296
|
+
var StyledText = (0, import_styled_components2.default)(FilteredSpan)`
|
|
221
297
|
color: ${(props) => props.color || "inherit"};
|
|
222
298
|
font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
|
|
223
299
|
font-weight: ${(props) => props.fontWeight || "normal"};
|
|
@@ -250,7 +326,8 @@ var Text = ({
|
|
|
250
326
|
// ../primitives-web/src/Icon.tsx
|
|
251
327
|
var import_styled_components3 = __toESM(require("styled-components"));
|
|
252
328
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
253
|
-
var
|
|
329
|
+
var FilteredDiv2 = createFilteredElement("div");
|
|
330
|
+
var StyledIcon = (0, import_styled_components3.default)(FilteredDiv2)`
|
|
254
331
|
display: flex;
|
|
255
332
|
align-items: center;
|
|
256
333
|
justify-content: center;
|
|
@@ -270,10 +347,11 @@ var Icon = ({ children, ...props }) => {
|
|
|
270
347
|
};
|
|
271
348
|
|
|
272
349
|
// ../primitives-web/src/Input.tsx
|
|
273
|
-
var
|
|
350
|
+
var import_react3 = require("react");
|
|
274
351
|
var import_styled_components4 = __toESM(require("styled-components"));
|
|
275
352
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
276
|
-
var
|
|
353
|
+
var FilteredInput = createFilteredElement("input");
|
|
354
|
+
var StyledInput = (0, import_styled_components4.default)(FilteredInput)`
|
|
277
355
|
background: transparent;
|
|
278
356
|
border: none;
|
|
279
357
|
outline: none;
|
|
@@ -304,7 +382,7 @@ var StyledInput = import_styled_components4.default.input`
|
|
|
304
382
|
-webkit-text-fill-color: ${(props) => props.color || "inherit"} !important;
|
|
305
383
|
}
|
|
306
384
|
`;
|
|
307
|
-
var InputPrimitive = (0,
|
|
385
|
+
var InputPrimitive = (0, import_react3.forwardRef)(
|
|
308
386
|
({
|
|
309
387
|
value,
|
|
310
388
|
placeholder,
|
|
@@ -2293,7 +2371,7 @@ var ChevronUp = () => /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(
|
|
|
2293
2371
|
)
|
|
2294
2372
|
}
|
|
2295
2373
|
);
|
|
2296
|
-
var InputPhone = (0,
|
|
2374
|
+
var InputPhone = (0, import_react4.forwardRef)(
|
|
2297
2375
|
({
|
|
2298
2376
|
value,
|
|
2299
2377
|
placeholder = "+1 (000) 000-0000",
|
|
@@ -2319,35 +2397,35 @@ var InputPhone = (0, import_react3.forwardRef)(
|
|
|
2319
2397
|
themeProductContext
|
|
2320
2398
|
}, ref) => {
|
|
2321
2399
|
const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
|
|
2322
|
-
const [internalState, setInternalState] = (0,
|
|
2400
|
+
const [internalState, setInternalState] = (0, import_react4.useState)(
|
|
2323
2401
|
"default"
|
|
2324
2402
|
);
|
|
2325
|
-
const [passValue, setPassValue] = (0,
|
|
2326
|
-
const [isDropdownOpen, setIsDropdownOpen] = (0,
|
|
2327
|
-
const [highlightedIndex, setHighlightedIndex] = (0,
|
|
2328
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
2329
|
-
const inputRef = (0,
|
|
2330
|
-
const dropdownRef = (0,
|
|
2331
|
-
const countryButtonRef = (0,
|
|
2332
|
-
const searchInputRef = (0,
|
|
2333
|
-
const selectedCountryRef = (0,
|
|
2334
|
-
const countryListRef = (0,
|
|
2403
|
+
const [passValue, setPassValue] = (0, import_react4.useState)(value ?? "");
|
|
2404
|
+
const [isDropdownOpen, setIsDropdownOpen] = (0, import_react4.useState)(false);
|
|
2405
|
+
const [highlightedIndex, setHighlightedIndex] = (0, import_react4.useState)(-1);
|
|
2406
|
+
const [searchQuery, setSearchQuery] = (0, import_react4.useState)("");
|
|
2407
|
+
const inputRef = (0, import_react4.useRef)(null);
|
|
2408
|
+
const dropdownRef = (0, import_react4.useRef)(null);
|
|
2409
|
+
const countryButtonRef = (0, import_react4.useRef)(null);
|
|
2410
|
+
const searchInputRef = (0, import_react4.useRef)(null);
|
|
2411
|
+
const selectedCountryRef = (0, import_react4.useRef)(null);
|
|
2412
|
+
const countryListRef = (0, import_react4.useRef)(null);
|
|
2335
2413
|
const rawId = (0, import_xui_core.useId)();
|
|
2336
2414
|
const safeId = rawId.replace(/:/g, "");
|
|
2337
2415
|
const inputId = providedId || `input-phone-${safeId}`;
|
|
2338
2416
|
const errorId = `${inputId}-error`;
|
|
2339
2417
|
const dropdownId = `${inputId}-dropdown`;
|
|
2340
|
-
|
|
2418
|
+
import_react4.default.useImperativeHandle(
|
|
2341
2419
|
ref,
|
|
2342
2420
|
() => inputRef.current,
|
|
2343
2421
|
[]
|
|
2344
2422
|
);
|
|
2345
|
-
(0,
|
|
2423
|
+
(0, import_react4.useEffect)(() => {
|
|
2346
2424
|
if (value !== void 0) {
|
|
2347
2425
|
setPassValue(value);
|
|
2348
2426
|
}
|
|
2349
2427
|
}, [value]);
|
|
2350
|
-
(0,
|
|
2428
|
+
(0, import_react4.useEffect)(() => {
|
|
2351
2429
|
if (isDropdownOpen && selectedCountryRef.current && countryListRef.current) {
|
|
2352
2430
|
const timeoutId = setTimeout(() => {
|
|
2353
2431
|
const selectedItem = selectedCountryRef.current;
|
|
@@ -2358,7 +2436,7 @@ var InputPhone = (0, import_react3.forwardRef)(
|
|
|
2358
2436
|
return () => clearTimeout(timeoutId);
|
|
2359
2437
|
}
|
|
2360
2438
|
}, [isDropdownOpen]);
|
|
2361
|
-
(0,
|
|
2439
|
+
(0, import_react4.useEffect)(() => {
|
|
2362
2440
|
if (!isDropdownOpen || !import_xui_core.isWeb) return;
|
|
2363
2441
|
const handleClickOutside = (event) => {
|
|
2364
2442
|
const target = event.target;
|
|
@@ -2489,7 +2567,7 @@ var InputPhone = (0, import_react3.forwardRef)(
|
|
|
2489
2567
|
break;
|
|
2490
2568
|
}
|
|
2491
2569
|
};
|
|
2492
|
-
(0,
|
|
2570
|
+
(0, import_react4.useEffect)(() => {
|
|
2493
2571
|
if (isDropdownOpen && highlightedIndex >= 0 && highlightedIndex < filteredCountries.length) {
|
|
2494
2572
|
const handleEnter = (e) => {
|
|
2495
2573
|
if (e.key === "Enter") {
|
|
@@ -2644,7 +2722,7 @@ var InputPhone = (0, import_react3.forwardRef)(
|
|
|
2644
2722
|
borderColor: inputColors.borderHover
|
|
2645
2723
|
} : void 0,
|
|
2646
2724
|
children: [
|
|
2647
|
-
selectedCountry?.flag ? /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(Box, { width: flagSize, height: flagSize, children:
|
|
2725
|
+
selectedCountry?.flag ? /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(Box, { width: flagSize, height: flagSize, children: import_react4.default.isValidElement(selectedCountry.flag) ? import_react4.default.cloneElement(
|
|
2648
2726
|
selectedCountry.flag,
|
|
2649
2727
|
{ size: flagSize }
|
|
2650
2728
|
) : selectedCountry.flag }) : /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(Location, { size: flagSize, variant: "line", color: iconColor }),
|
|
@@ -2864,13 +2942,13 @@ var InputPhone = (0, import_react3.forwardRef)(
|
|
|
2864
2942
|
}
|
|
2865
2943
|
)
|
|
2866
2944
|
}
|
|
2867
|
-
) : filteredCountries.map((country,
|
|
2945
|
+
) : filteredCountries.map((country, index2) => {
|
|
2868
2946
|
const isSelected = selectedCountry?.code === country.code;
|
|
2869
2947
|
const brandColors = theme.colors.control.brand.primary;
|
|
2870
2948
|
const contentColors = theme.colors.content;
|
|
2871
2949
|
const getBgColor = () => {
|
|
2872
2950
|
if (isSelected) return brandColors.bg;
|
|
2873
|
-
if (highlightedIndex ===
|
|
2951
|
+
if (highlightedIndex === index2)
|
|
2874
2952
|
return inputColors.bgHover;
|
|
2875
2953
|
return "transparent";
|
|
2876
2954
|
};
|
|
@@ -2905,7 +2983,7 @@ var InputPhone = (0, import_react3.forwardRef)(
|
|
|
2905
2983
|
backgroundColor: inputColors.bgHover
|
|
2906
2984
|
} : void 0,
|
|
2907
2985
|
children: [
|
|
2908
|
-
country.flag ? /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(Box, { width: flagSize, height: flagSize, children:
|
|
2986
|
+
country.flag ? /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(Box, { width: flagSize, height: flagSize, children: import_react4.default.isValidElement(country.flag) ? import_react4.default.cloneElement(
|
|
2909
2987
|
country.flag,
|
|
2910
2988
|
{ size: flagSize }
|
|
2911
2989
|
) : country.flag }) : /* @__PURE__ */ (0, import_jsx_runtime258.jsx)(
|
|
@@ -2972,7 +3050,7 @@ var InputPhone = (0, import_react3.forwardRef)(
|
|
|
2972
3050
|
InputPhone.displayName = "InputPhone";
|
|
2973
3051
|
|
|
2974
3052
|
// src/usePhoneNumber.ts
|
|
2975
|
-
var
|
|
3053
|
+
var import_react5 = require("react");
|
|
2976
3054
|
var import_libphonenumber_js = require("libphonenumber-js");
|
|
2977
3055
|
var getNormalizedPhoneNumber = (phoneNumber) => {
|
|
2978
3056
|
if (!phoneNumber) return "";
|
|
@@ -3037,20 +3115,20 @@ var usePhoneNumber = (options = {}) => {
|
|
|
3037
3115
|
}
|
|
3038
3116
|
return void 0;
|
|
3039
3117
|
};
|
|
3040
|
-
const [phoneNumber, setPhoneNumberState] = (0,
|
|
3118
|
+
const [phoneNumber, setPhoneNumberState] = (0, import_react5.useState)(() => {
|
|
3041
3119
|
if (initialValue) {
|
|
3042
3120
|
return getNormalizedPhoneNumber(initialValue);
|
|
3043
3121
|
}
|
|
3044
3122
|
return "";
|
|
3045
3123
|
});
|
|
3046
|
-
const [country, setCountry] = (0,
|
|
3124
|
+
const [country, setCountry] = (0, import_react5.useState)(
|
|
3047
3125
|
getInitialCountry
|
|
3048
3126
|
);
|
|
3049
3127
|
const formattedPhoneNumber = phoneNumber ? (0, import_libphonenumber_js.formatIncompletePhoneNumber)(
|
|
3050
3128
|
phoneNumber,
|
|
3051
3129
|
country?.code
|
|
3052
3130
|
) : "";
|
|
3053
|
-
const handlePhoneChange = (0,
|
|
3131
|
+
const handlePhoneChange = (0, import_react5.useCallback)(
|
|
3054
3132
|
(value) => {
|
|
3055
3133
|
let normalizedValue = value;
|
|
3056
3134
|
const digitsOnly = value.replace(/\D/g, "");
|
|
@@ -3077,7 +3155,7 @@ var usePhoneNumber = (options = {}) => {
|
|
|
3077
3155
|
},
|
|
3078
3156
|
[country?.code, onChange, onCountryChange]
|
|
3079
3157
|
);
|
|
3080
|
-
const handleCountryChange = (0,
|
|
3158
|
+
const handleCountryChange = (0, import_react5.useCallback)(
|
|
3081
3159
|
(newCountry) => {
|
|
3082
3160
|
const previousCountry = country;
|
|
3083
3161
|
setCountry(newCountry);
|
|
@@ -3102,7 +3180,7 @@ var usePhoneNumber = (options = {}) => {
|
|
|
3102
3180
|
},
|
|
3103
3181
|
[country, phoneNumber, onChange, onCountryChange]
|
|
3104
3182
|
);
|
|
3105
|
-
const setPhoneNumber = (0,
|
|
3183
|
+
const setPhoneNumber = (0, import_react5.useCallback)(
|
|
3106
3184
|
(value) => {
|
|
3107
3185
|
const normalized = getNormalizedPhoneNumber(value);
|
|
3108
3186
|
setPhoneNumberState(normalized);
|
|
@@ -3118,7 +3196,7 @@ var usePhoneNumber = (options = {}) => {
|
|
|
3118
3196
|
},
|
|
3119
3197
|
[country?.code, onChange, onCountryChange]
|
|
3120
3198
|
);
|
|
3121
|
-
(0,
|
|
3199
|
+
(0, import_react5.useEffect)(() => {
|
|
3122
3200
|
if (initialValue && initialValue !== phoneNumber) {
|
|
3123
3201
|
const normalized = getNormalizedPhoneNumber(initialValue);
|
|
3124
3202
|
setPhoneNumberState(normalized);
|