@scripso-homepad/ui 0.3.6 → 0.3.7
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/README.md +232 -78
- package/dist/index.cjs +1128 -85
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +322 -18
- package/dist/index.d.ts +322 -18
- package/dist/index.js +1107 -89
- package/dist/index.js.map +1 -1
- package/package.json +18 -6
- package/src/components/Button.stories.tsx +77 -57
- package/src/components/Button.tsx +146 -124
- package/src/components/CountryCodeSelector.stories.tsx +61 -0
- package/src/components/CountryCodeSelector.tsx +273 -0
- package/src/components/Input.stories.tsx +117 -0
- package/src/components/Input.tsx +177 -0
- package/src/components/Label.tsx +56 -0
- package/src/components/PhoneInput.stories.tsx +85 -0
- package/src/components/PhoneInput.tsx +172 -0
- package/src/data/countries.ts +98 -0
- package/src/icons/ArrowUpRightIcon.tsx +29 -0
- package/src/icons/ArrowUpRightIcon.web.tsx +35 -0
- package/src/icons/ChevronDownIcon.tsx +29 -0
- package/src/icons/ChevronDownIcon.web.tsx +35 -0
- package/src/icons/EyeIcon.tsx +48 -0
- package/src/icons/KeyIcon.tsx +36 -0
- package/src/icons/KeyIcon.web.tsx +42 -0
- package/src/icons/arrowUpRightPath.ts +2 -0
- package/src/icons/chevronDownPath.ts +1 -0
- package/src/icons/keyIconPaths.ts +5 -0
- package/src/index.ts +42 -0
- package/src/theme/input.ts +139 -0
- package/src/theme/tokens.ts +272 -0
- package/src/utils/countryDropdownScrollStyles.ts +52 -0
- package/src/utils/countryFlag.ts +9 -0
- package/src/utils/useApplyWebClassName.ts +3 -2
package/dist/index.js
CHANGED
|
@@ -1,8 +1,259 @@
|
|
|
1
|
-
import { useRef, useLayoutEffect } from 'react';
|
|
2
|
-
import { StyleSheet, TouchableOpacity, Text,
|
|
3
|
-
import {
|
|
1
|
+
import { useRef, useState, useLayoutEffect, isValidElement, cloneElement } from 'react';
|
|
2
|
+
import { StyleSheet, Platform, TouchableOpacity, Text, View, TextInput, Pressable, ScrollView, Modal, Dimensions } from 'react-native';
|
|
3
|
+
import Svg, { Path } from 'react-native-svg';
|
|
4
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
5
|
|
|
5
6
|
// src/components/Button.tsx
|
|
7
|
+
|
|
8
|
+
// src/icons/arrowUpRightPath.ts
|
|
9
|
+
var ARROW_UP_RIGHT_PATH = "M14.1667 14.1668V5.8335H5.83333M14.1667 5.8335L5.83333 14.1668";
|
|
10
|
+
function ArrowUpRightIcon({
|
|
11
|
+
size = 20,
|
|
12
|
+
color = "#08275d",
|
|
13
|
+
strokeWidth = 2
|
|
14
|
+
}) {
|
|
15
|
+
return /* @__PURE__ */ jsx(Svg, { width: size, height: size, viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ jsx(
|
|
16
|
+
Path,
|
|
17
|
+
{
|
|
18
|
+
d: ARROW_UP_RIGHT_PATH,
|
|
19
|
+
stroke: color,
|
|
20
|
+
strokeWidth,
|
|
21
|
+
strokeLinecap: "round",
|
|
22
|
+
strokeLinejoin: "round"
|
|
23
|
+
}
|
|
24
|
+
) });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// src/theme/tokens.ts
|
|
28
|
+
var stormGray = {
|
|
29
|
+
"0": "#fbfcfc",
|
|
30
|
+
"0.5": "#eceef0",
|
|
31
|
+
"1": "#dadde0",
|
|
32
|
+
"1.5": "#c7cdd1",
|
|
33
|
+
"2": "#b5bcc1",
|
|
34
|
+
"3": "#8f9aa3",
|
|
35
|
+
"4": "#6a7984",
|
|
36
|
+
"5": "#455765",
|
|
37
|
+
"6": "#374651",
|
|
38
|
+
"7": "#29343d",
|
|
39
|
+
"8": "#1c2328",
|
|
40
|
+
"8.5": "#151a1e"
|
|
41
|
+
};
|
|
42
|
+
var navy = {
|
|
43
|
+
"0": "#f8f9fb",
|
|
44
|
+
"0.5": "#e5e9ef",
|
|
45
|
+
"1": "#cdd3df",
|
|
46
|
+
"1.5": "#b4bece",
|
|
47
|
+
"2": "#9ca8be",
|
|
48
|
+
"3": "#6a7d9e",
|
|
49
|
+
"4": "#39527d",
|
|
50
|
+
"5": "#08275d",
|
|
51
|
+
"6": "#061f4a",
|
|
52
|
+
"7": "#051738",
|
|
53
|
+
"8": "#031025",
|
|
54
|
+
"8.5": "#020c1c"
|
|
55
|
+
};
|
|
56
|
+
var rubyRed = {
|
|
57
|
+
"0": "#fff5f6",
|
|
58
|
+
"0.5": "#f7dddf",
|
|
59
|
+
"1": "#efc4c8",
|
|
60
|
+
"1.5": "#e7acb1",
|
|
61
|
+
"2": "#df939a",
|
|
62
|
+
"3": "#ce626d",
|
|
63
|
+
"4": "#be313f",
|
|
64
|
+
"5": "#ae0011",
|
|
65
|
+
"6": "#8b000e",
|
|
66
|
+
"7": "#68000a",
|
|
67
|
+
"8": "#460007",
|
|
68
|
+
"8.5": "#340005"
|
|
69
|
+
};
|
|
70
|
+
var emeraldGreen = {
|
|
71
|
+
"0": "#f0fbf5",
|
|
72
|
+
"0.5": "#dcf2e5",
|
|
73
|
+
"1": "#c8e8d5",
|
|
74
|
+
"1.5": "#b4dfc5",
|
|
75
|
+
"2": "#a0d5b5",
|
|
76
|
+
"3": "#77c394",
|
|
77
|
+
"4": "#4fb074",
|
|
78
|
+
"5": "#279d54",
|
|
79
|
+
"6": "#1f7e43",
|
|
80
|
+
"7": "#175e32",
|
|
81
|
+
"8": "#103f22",
|
|
82
|
+
"8.5": "#0c2f19"
|
|
83
|
+
};
|
|
84
|
+
var brand = {
|
|
85
|
+
slateBlue: "#182e3c",
|
|
86
|
+
stormGray: stormGray["5"],
|
|
87
|
+
navy: navy["5"],
|
|
88
|
+
rubyRed: rubyRed["5"],
|
|
89
|
+
emeraldGreen: emeraldGreen["5"]
|
|
90
|
+
};
|
|
91
|
+
var colors = {
|
|
92
|
+
// Brand colors
|
|
93
|
+
slateBlue: brand.slateBlue,
|
|
94
|
+
// Emerald Green — Figma scale + brand swatch
|
|
95
|
+
emeraldGreen0: emeraldGreen["0"],
|
|
96
|
+
emeraldGreen50: emeraldGreen["0.5"],
|
|
97
|
+
emeraldGreen100: emeraldGreen["1"],
|
|
98
|
+
emeraldGreen150: emeraldGreen["1.5"],
|
|
99
|
+
emeraldGreen200: emeraldGreen["2"],
|
|
100
|
+
emeraldGreen300: emeraldGreen["3"],
|
|
101
|
+
emeraldGreen400: emeraldGreen["4"],
|
|
102
|
+
emeraldGreen500: emeraldGreen["5"],
|
|
103
|
+
emeraldGreen600: emeraldGreen["6"],
|
|
104
|
+
emeraldGreen700: emeraldGreen["7"],
|
|
105
|
+
emeraldGreen800: emeraldGreen["8"],
|
|
106
|
+
emeraldGreen850: emeraldGreen["8.5"],
|
|
107
|
+
/** Primary brand emerald green — Figma Emerald Green 5 */
|
|
108
|
+
emeraldGreen: brand.emeraldGreen,
|
|
109
|
+
// Ruby Red — Figma scale + brand swatch
|
|
110
|
+
rubyRed0: rubyRed["0"],
|
|
111
|
+
rubyRed50: rubyRed["0.5"],
|
|
112
|
+
rubyRed100: rubyRed["1"],
|
|
113
|
+
rubyRed150: rubyRed["1.5"],
|
|
114
|
+
rubyRed200: rubyRed["2"],
|
|
115
|
+
rubyRed300: rubyRed["3"],
|
|
116
|
+
rubyRed400: rubyRed["4"],
|
|
117
|
+
rubyRed500: rubyRed["5"],
|
|
118
|
+
rubyRed600: rubyRed["6"],
|
|
119
|
+
rubyRed700: rubyRed["7"],
|
|
120
|
+
rubyRed800: rubyRed["8"],
|
|
121
|
+
rubyRed850: rubyRed["8.5"],
|
|
122
|
+
/** Primary brand ruby red — Figma Ruby Red 5 */
|
|
123
|
+
rubyRed: brand.rubyRed,
|
|
124
|
+
// Navy — Figma scale + brand swatch
|
|
125
|
+
navy0: navy["0"],
|
|
126
|
+
navy50: navy["0.5"],
|
|
127
|
+
navy100: navy["1"],
|
|
128
|
+
navy150: navy["1.5"],
|
|
129
|
+
navy200: navy["2"],
|
|
130
|
+
navy300: navy["3"],
|
|
131
|
+
navy400: navy["4"],
|
|
132
|
+
navy500: navy["5"],
|
|
133
|
+
navy600: navy["6"],
|
|
134
|
+
navy700: navy["7"],
|
|
135
|
+
navy800: navy["8"],
|
|
136
|
+
navy850: navy["8.5"],
|
|
137
|
+
/** Primary brand navy — Figma Navy 5 */
|
|
138
|
+
navy: brand.navy,
|
|
139
|
+
// Storm Gray — Figma scale + brand swatch
|
|
140
|
+
stormGray0: stormGray["0"],
|
|
141
|
+
stormGray50: stormGray["0.5"],
|
|
142
|
+
stormGray100: stormGray["1"],
|
|
143
|
+
stormGray150: stormGray["1.5"],
|
|
144
|
+
stormGray200: stormGray["2"],
|
|
145
|
+
stormGray300: stormGray["3"],
|
|
146
|
+
stormGray400: stormGray["4"],
|
|
147
|
+
stormGray500: stormGray["5"],
|
|
148
|
+
/** Figma brand swatch "Storm Gray" — same as `stormGray500` */
|
|
149
|
+
stormGrayBrand: brand.stormGray,
|
|
150
|
+
stormGray600: stormGray["6"],
|
|
151
|
+
stormGray700: stormGray["7"],
|
|
152
|
+
stormGray800: stormGray["8"],
|
|
153
|
+
stormGray850: stormGray["8.5"],
|
|
154
|
+
/** @deprecated Use `stormGray0` */
|
|
155
|
+
storm0: stormGray["0"],
|
|
156
|
+
/** @deprecated Use `stormGray50` */
|
|
157
|
+
storm50: stormGray["0.5"],
|
|
158
|
+
/** @deprecated Use `stormGray200` */
|
|
159
|
+
storm200: stormGray["2"],
|
|
160
|
+
/** @deprecated Use `stormGray300` */
|
|
161
|
+
storm300: stormGray["3"],
|
|
162
|
+
/** @deprecated Use `stormGray500` */
|
|
163
|
+
storm500: stormGray["5"],
|
|
164
|
+
/** @deprecated Use `stormGray700` */
|
|
165
|
+
storm700: stormGray["7"],
|
|
166
|
+
/** @deprecated Use `stormGray850` */
|
|
167
|
+
storm900: stormGray["8.5"],
|
|
168
|
+
countrySelectorSelectedBg: `${stormGray["0.5"]}99`,
|
|
169
|
+
white: "#ffffff",
|
|
170
|
+
error: "#dc2626",
|
|
171
|
+
errorDark: "#b3261e",
|
|
172
|
+
errorLight: "#fee2e2",
|
|
173
|
+
/** @deprecated Use `rubyRed` */
|
|
174
|
+
inputError: brand.rubyRed,
|
|
175
|
+
inputOutlineFocus: navy["0.5"],
|
|
176
|
+
inputOutlineError: rubyRed["0.5"],
|
|
177
|
+
warning: "#92400e",
|
|
178
|
+
warningBg: "#fef3c7",
|
|
179
|
+
success: "#28a745",
|
|
180
|
+
successMuted: "#9fd4a8",
|
|
181
|
+
/** @deprecated Use `emeraldGreen` */
|
|
182
|
+
green: brand.emeraldGreen,
|
|
183
|
+
transparent: "transparent"
|
|
184
|
+
};
|
|
185
|
+
var radii = {
|
|
186
|
+
sm: 8,
|
|
187
|
+
md: 12,
|
|
188
|
+
lg: 16,
|
|
189
|
+
xl: 20,
|
|
190
|
+
full: 9999
|
|
191
|
+
};
|
|
192
|
+
var spacing = {
|
|
193
|
+
xs: 4,
|
|
194
|
+
sm: 8,
|
|
195
|
+
md: 12,
|
|
196
|
+
lg: 16,
|
|
197
|
+
xl: 24,
|
|
198
|
+
xxl: 32
|
|
199
|
+
};
|
|
200
|
+
var fontSize = {
|
|
201
|
+
xs: 11,
|
|
202
|
+
sm: 12,
|
|
203
|
+
md: 14,
|
|
204
|
+
base: 16,
|
|
205
|
+
lg: 18,
|
|
206
|
+
xl: 24,
|
|
207
|
+
xxl: 32
|
|
208
|
+
};
|
|
209
|
+
var fontWeight = {
|
|
210
|
+
regular: "400",
|
|
211
|
+
medium: "500",
|
|
212
|
+
semibold: "600",
|
|
213
|
+
bold: "700"
|
|
214
|
+
};
|
|
215
|
+
var fonts = {
|
|
216
|
+
sans: "Noto Sans Armenian"
|
|
217
|
+
};
|
|
218
|
+
var labelTypography = {
|
|
219
|
+
fontFamily: fonts.sans,
|
|
220
|
+
fontSize: fontSize.sm,
|
|
221
|
+
fontWeight: fontWeight.medium,
|
|
222
|
+
lineHeight: fontSize.sm,
|
|
223
|
+
letterSpacing: 0
|
|
224
|
+
};
|
|
225
|
+
var buttonTypography = {
|
|
226
|
+
lg: {
|
|
227
|
+
fontFamily: fonts.sans,
|
|
228
|
+
fontSize: 14,
|
|
229
|
+
fontWeight: fontWeight.semibold,
|
|
230
|
+
lineHeight: 14,
|
|
231
|
+
letterSpacing: 0
|
|
232
|
+
},
|
|
233
|
+
sm: {
|
|
234
|
+
fontFamily: fonts.sans,
|
|
235
|
+
fontSize: 12,
|
|
236
|
+
fontWeight: fontWeight.semibold,
|
|
237
|
+
lineHeight: 12,
|
|
238
|
+
letterSpacing: 0
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
var shadows = {
|
|
242
|
+
card: {
|
|
243
|
+
shadowColor: colors.navy,
|
|
244
|
+
shadowOffset: { width: 0, height: 4 },
|
|
245
|
+
shadowOpacity: 0.05,
|
|
246
|
+
shadowRadius: 20,
|
|
247
|
+
elevation: 2
|
|
248
|
+
},
|
|
249
|
+
cardLg: {
|
|
250
|
+
shadowColor: colors.navy,
|
|
251
|
+
shadowOffset: { width: 0, height: 4 },
|
|
252
|
+
shadowOpacity: 0.1,
|
|
253
|
+
shadowRadius: 20,
|
|
254
|
+
elevation: 4
|
|
255
|
+
}
|
|
256
|
+
};
|
|
6
257
|
function hasClassList(node) {
|
|
7
258
|
return typeof node === "object" && node !== null && "classList" in node && typeof node.classList?.add === "function";
|
|
8
259
|
}
|
|
@@ -18,9 +269,9 @@ function resolveWebElement(ref) {
|
|
|
18
269
|
}
|
|
19
270
|
return null;
|
|
20
271
|
}
|
|
21
|
-
function useApplyWebClassName(ref, className) {
|
|
272
|
+
function useApplyWebClassName(ref, className, enabled = true) {
|
|
22
273
|
useLayoutEffect(() => {
|
|
23
|
-
if (Platform.OS !== "web" || !className?.trim()) return;
|
|
274
|
+
if (!enabled || Platform.OS !== "web" || !className?.trim()) return;
|
|
24
275
|
const element = resolveWebElement(ref);
|
|
25
276
|
if (!element) return;
|
|
26
277
|
const classes = className.trim().split(/\s+/);
|
|
@@ -28,14 +279,73 @@ function useApplyWebClassName(ref, className) {
|
|
|
28
279
|
return () => {
|
|
29
280
|
element.classList.remove(...classes);
|
|
30
281
|
};
|
|
31
|
-
}, [ref, className]);
|
|
282
|
+
}, [ref, className, enabled]);
|
|
32
283
|
}
|
|
284
|
+
var variantConfig = {
|
|
285
|
+
white: {
|
|
286
|
+
backgroundColor: colors.white,
|
|
287
|
+
textColor: colors.slateBlue,
|
|
288
|
+
iconBadgeBackgroundColor: colors.stormGray150,
|
|
289
|
+
iconColor: colors.navy
|
|
290
|
+
},
|
|
291
|
+
primary: {
|
|
292
|
+
backgroundColor: colors.navy,
|
|
293
|
+
textColor: colors.stormGray0,
|
|
294
|
+
iconBadgeBackgroundColor: colors.white,
|
|
295
|
+
iconColor: colors.navy
|
|
296
|
+
},
|
|
297
|
+
green: {
|
|
298
|
+
backgroundColor: colors.green,
|
|
299
|
+
textColor: colors.stormGray0,
|
|
300
|
+
iconBadgeBackgroundColor: colors.white,
|
|
301
|
+
iconColor: colors.green
|
|
302
|
+
},
|
|
303
|
+
gray: {
|
|
304
|
+
backgroundColor: colors.stormGray50,
|
|
305
|
+
textColor: colors.slateBlue,
|
|
306
|
+
iconBadgeBackgroundColor: colors.stormGray150,
|
|
307
|
+
iconColor: colors.navy
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
var sizeConfig = {
|
|
311
|
+
lg: {
|
|
312
|
+
borderRadius: 16,
|
|
313
|
+
paddingTop: 8,
|
|
314
|
+
paddingRight: 8,
|
|
315
|
+
paddingBottom: 8,
|
|
316
|
+
paddingLeft: 24,
|
|
317
|
+
paddingHorizontalCentered: 24,
|
|
318
|
+
minHeight: 52,
|
|
319
|
+
text: buttonTypography.lg,
|
|
320
|
+
iconContainerSize: 36,
|
|
321
|
+
iconContainerRadius: 12,
|
|
322
|
+
iconContainerPadding: 8,
|
|
323
|
+
iconSize: 20
|
|
324
|
+
},
|
|
325
|
+
sm: {
|
|
326
|
+
borderRadius: 12,
|
|
327
|
+
paddingTop: 8,
|
|
328
|
+
paddingRight: 8,
|
|
329
|
+
paddingBottom: 8,
|
|
330
|
+
paddingLeft: 16,
|
|
331
|
+
paddingHorizontalCentered: 16,
|
|
332
|
+
minHeight: 48,
|
|
333
|
+
text: buttonTypography.sm,
|
|
334
|
+
iconContainerSize: 32,
|
|
335
|
+
iconContainerRadius: 8,
|
|
336
|
+
iconContainerPadding: 8,
|
|
337
|
+
iconSize: 16
|
|
338
|
+
}
|
|
339
|
+
};
|
|
33
340
|
function Button({
|
|
34
341
|
title,
|
|
342
|
+
children,
|
|
35
343
|
onPress,
|
|
36
344
|
disabled = false,
|
|
37
345
|
variant = "primary",
|
|
38
|
-
size = "
|
|
346
|
+
size = "lg",
|
|
347
|
+
showIcon = false,
|
|
348
|
+
icon,
|
|
39
349
|
style,
|
|
40
350
|
textStyle,
|
|
41
351
|
className,
|
|
@@ -43,23 +353,38 @@ function Button({
|
|
|
43
353
|
}) {
|
|
44
354
|
const containerRef = useRef(null);
|
|
45
355
|
const textRef = useRef(null);
|
|
356
|
+
const preset = variantConfig[variant];
|
|
357
|
+
const metrics = sizeConfig[size];
|
|
46
358
|
useApplyWebClassName(containerRef, className);
|
|
47
359
|
useApplyWebClassName(textRef, textClassName);
|
|
360
|
+
const label = typeof children !== "undefined" ? children : title;
|
|
361
|
+
const hasCustomChildren = typeof children !== "undefined";
|
|
362
|
+
const hasIcon = showIcon || icon != null;
|
|
363
|
+
const iconNode = icon ?? /* @__PURE__ */ jsx(ArrowUpRightIcon, { size: metrics.iconSize, color: preset.iconColor });
|
|
48
364
|
const containerStyle = [
|
|
49
365
|
styles.base,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
366
|
+
{
|
|
367
|
+
borderRadius: metrics.borderRadius,
|
|
368
|
+
backgroundColor: preset.backgroundColor,
|
|
369
|
+
minHeight: metrics.minHeight,
|
|
370
|
+
paddingTop: metrics.paddingTop,
|
|
371
|
+
paddingBottom: metrics.paddingBottom,
|
|
372
|
+
paddingLeft: hasIcon ? metrics.paddingLeft : metrics.paddingHorizontalCentered,
|
|
373
|
+
paddingRight: hasIcon ? metrics.paddingRight : metrics.paddingHorizontalCentered
|
|
374
|
+
},
|
|
375
|
+
hasIcon ? styles.withIcon : styles.centered,
|
|
376
|
+
disabled && styles.disabled,
|
|
53
377
|
style
|
|
54
378
|
];
|
|
55
379
|
const labelStyle = [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
380
|
+
styles.label,
|
|
381
|
+
metrics.text,
|
|
382
|
+
{ color: preset.textColor },
|
|
383
|
+
!hasIcon && styles.labelCentered,
|
|
384
|
+
hasIcon && styles.labelWithIcon,
|
|
60
385
|
textStyle
|
|
61
386
|
];
|
|
62
|
-
return /* @__PURE__ */
|
|
387
|
+
return /* @__PURE__ */ jsxs(
|
|
63
388
|
TouchableOpacity,
|
|
64
389
|
{
|
|
65
390
|
ref: containerRef,
|
|
@@ -69,113 +394,806 @@ function Button({
|
|
|
69
394
|
activeOpacity: 0.7,
|
|
70
395
|
accessibilityRole: "button",
|
|
71
396
|
accessibilityState: { disabled },
|
|
72
|
-
children:
|
|
397
|
+
children: [
|
|
398
|
+
hasCustomChildren ? children : /* @__PURE__ */ jsx(Text, { ref: textRef, style: labelStyle, children: label }),
|
|
399
|
+
hasIcon ? /* @__PURE__ */ jsx(
|
|
400
|
+
View,
|
|
401
|
+
{
|
|
402
|
+
style: [
|
|
403
|
+
styles.iconContainer,
|
|
404
|
+
{
|
|
405
|
+
width: metrics.iconContainerSize,
|
|
406
|
+
height: metrics.iconContainerSize,
|
|
407
|
+
borderRadius: metrics.iconContainerRadius,
|
|
408
|
+
padding: metrics.iconContainerPadding,
|
|
409
|
+
backgroundColor: preset.iconBadgeBackgroundColor
|
|
410
|
+
}
|
|
411
|
+
],
|
|
412
|
+
children: iconNode
|
|
413
|
+
}
|
|
414
|
+
) : null
|
|
415
|
+
]
|
|
73
416
|
}
|
|
74
417
|
);
|
|
75
418
|
}
|
|
76
419
|
var styles = StyleSheet.create({
|
|
77
420
|
base: {
|
|
421
|
+
flexDirection: "row",
|
|
78
422
|
alignItems: "center",
|
|
79
|
-
justifyContent: "center",
|
|
80
|
-
borderRadius: 8,
|
|
81
423
|
borderWidth: 0
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
var variantStyles = StyleSheet.create({
|
|
85
|
-
primary: {
|
|
86
|
-
backgroundColor: "#2563eb"
|
|
87
424
|
},
|
|
88
|
-
|
|
89
|
-
|
|
425
|
+
centered: {
|
|
426
|
+
justifyContent: "center"
|
|
90
427
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
borderWidth: 1,
|
|
94
|
-
borderColor: "#2563eb"
|
|
428
|
+
withIcon: {
|
|
429
|
+
justifyContent: "space-between"
|
|
95
430
|
},
|
|
96
|
-
|
|
97
|
-
|
|
431
|
+
disabled: {
|
|
432
|
+
opacity: 0.6
|
|
433
|
+
},
|
|
434
|
+
label: {},
|
|
435
|
+
labelCentered: {
|
|
436
|
+
textAlign: "center"
|
|
437
|
+
},
|
|
438
|
+
labelWithIcon: {
|
|
439
|
+
flex: 1,
|
|
440
|
+
flexShrink: 1,
|
|
441
|
+
marginRight: 8
|
|
442
|
+
},
|
|
443
|
+
iconContainer: {
|
|
444
|
+
alignItems: "center",
|
|
445
|
+
justifyContent: "center",
|
|
446
|
+
flexShrink: 0
|
|
98
447
|
}
|
|
99
448
|
});
|
|
100
|
-
var
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
449
|
+
var INPUT_HEIGHT = 52;
|
|
450
|
+
var INPUT_ICON_SIZE = 20;
|
|
451
|
+
var INPUT_ICON_GAP = 10;
|
|
452
|
+
var INPUT_OUTLINE_WIDTH = 2;
|
|
453
|
+
function resolveInputVisualState({
|
|
454
|
+
focused = false,
|
|
455
|
+
error = false,
|
|
456
|
+
disabled = false
|
|
457
|
+
}) {
|
|
458
|
+
if (disabled) return "disabled";
|
|
459
|
+
if (error) return "error";
|
|
460
|
+
if (focused) return "focused";
|
|
461
|
+
return "default";
|
|
462
|
+
}
|
|
463
|
+
function getInputFieldStyles(state) {
|
|
464
|
+
const outlineBase = {
|
|
465
|
+
borderRadius: radii.lg + INPUT_OUTLINE_WIDTH,
|
|
466
|
+
padding: INPUT_OUTLINE_WIDTH,
|
|
467
|
+
backgroundColor: colors.transparent
|
|
468
|
+
};
|
|
469
|
+
switch (state) {
|
|
470
|
+
case "disabled":
|
|
471
|
+
return {
|
|
472
|
+
outline: outlineBase,
|
|
473
|
+
container: {
|
|
474
|
+
borderWidth: 1,
|
|
475
|
+
borderColor: colors.stormGray50,
|
|
476
|
+
backgroundColor: colors.stormGray50
|
|
477
|
+
},
|
|
478
|
+
text: { color: colors.stormGray300 },
|
|
479
|
+
placeholder: colors.stormGray300,
|
|
480
|
+
icon: colors.stormGray150
|
|
481
|
+
};
|
|
482
|
+
case "error":
|
|
483
|
+
return {
|
|
484
|
+
outline: {
|
|
485
|
+
...outlineBase,
|
|
486
|
+
backgroundColor: colors.inputOutlineError
|
|
487
|
+
},
|
|
488
|
+
container: {
|
|
489
|
+
borderWidth: 1,
|
|
490
|
+
borderColor: colors.inputError,
|
|
491
|
+
backgroundColor: colors.white
|
|
492
|
+
},
|
|
493
|
+
text: { color: colors.inputError },
|
|
494
|
+
placeholder: colors.stormGray200,
|
|
495
|
+
icon: colors.inputError
|
|
496
|
+
};
|
|
497
|
+
case "focused":
|
|
498
|
+
return {
|
|
499
|
+
outline: {
|
|
500
|
+
...outlineBase,
|
|
501
|
+
backgroundColor: colors.inputOutlineFocus
|
|
502
|
+
},
|
|
503
|
+
container: {
|
|
504
|
+
borderWidth: 1,
|
|
505
|
+
borderColor: colors.navy,
|
|
506
|
+
backgroundColor: colors.white
|
|
507
|
+
},
|
|
508
|
+
text: { color: colors.slateBlue },
|
|
509
|
+
placeholder: colors.stormGray200,
|
|
510
|
+
icon: colors.navy
|
|
511
|
+
};
|
|
512
|
+
default:
|
|
513
|
+
return {
|
|
514
|
+
outline: outlineBase,
|
|
515
|
+
container: {
|
|
516
|
+
borderWidth: 1,
|
|
517
|
+
borderColor: colors.stormGray50,
|
|
518
|
+
backgroundColor: colors.white
|
|
519
|
+
},
|
|
520
|
+
text: { color: colors.slateBlue },
|
|
521
|
+
placeholder: colors.stormGray200,
|
|
522
|
+
icon: colors.stormGray150
|
|
523
|
+
};
|
|
115
524
|
}
|
|
116
|
-
}
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
525
|
+
}
|
|
526
|
+
var inputFieldMetrics = StyleSheet.create({
|
|
527
|
+
container: {
|
|
528
|
+
flexDirection: "row",
|
|
529
|
+
alignItems: "center",
|
|
530
|
+
height: INPUT_HEIGHT,
|
|
531
|
+
minHeight: INPUT_HEIGHT,
|
|
532
|
+
maxHeight: INPUT_HEIGHT,
|
|
533
|
+
borderRadius: radii.lg,
|
|
534
|
+
padding: 16,
|
|
535
|
+
gap: INPUT_ICON_GAP,
|
|
536
|
+
...Platform.OS === "web" ? { boxSizing: "border-box" } : null
|
|
121
537
|
},
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
538
|
+
input: {
|
|
539
|
+
flex: 1,
|
|
540
|
+
alignSelf: "stretch",
|
|
541
|
+
fontFamily: fonts.sans,
|
|
542
|
+
fontSize: fontSize.md,
|
|
543
|
+
fontWeight: fontWeight.medium,
|
|
544
|
+
lineHeight: fontSize.md,
|
|
545
|
+
paddingVertical: 0,
|
|
546
|
+
paddingHorizontal: 0,
|
|
547
|
+
margin: 0,
|
|
548
|
+
borderWidth: 0,
|
|
549
|
+
backgroundColor: colors.transparent,
|
|
550
|
+
...Platform.OS === "web" ? {
|
|
551
|
+
height: "100%",
|
|
552
|
+
minHeight: 0,
|
|
553
|
+
outlineStyle: "none"
|
|
554
|
+
} : null
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
function Label({
|
|
558
|
+
children,
|
|
559
|
+
required = false,
|
|
560
|
+
disabled = false,
|
|
561
|
+
style,
|
|
562
|
+
className,
|
|
563
|
+
...props
|
|
564
|
+
}) {
|
|
565
|
+
const ref = useRef(null);
|
|
566
|
+
useApplyWebClassName(ref, className);
|
|
567
|
+
return /* @__PURE__ */ jsxs(
|
|
568
|
+
Text,
|
|
569
|
+
{
|
|
570
|
+
ref,
|
|
571
|
+
style: [styles2.label, disabled && styles2.labelDisabled, style],
|
|
572
|
+
accessibilityRole: "text",
|
|
573
|
+
...props,
|
|
574
|
+
children: [
|
|
575
|
+
children,
|
|
576
|
+
required ? /* @__PURE__ */ jsx(Text, { style: styles2.required, children: " *" }) : null
|
|
577
|
+
]
|
|
578
|
+
}
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
var styles2 = StyleSheet.create({
|
|
582
|
+
label: {
|
|
583
|
+
...labelTypography,
|
|
584
|
+
color: colors.slateBlue
|
|
125
585
|
},
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
opacity: 0.7
|
|
586
|
+
labelDisabled: {
|
|
587
|
+
color: colors.stormGray400
|
|
129
588
|
},
|
|
130
|
-
|
|
131
|
-
|
|
589
|
+
required: {
|
|
590
|
+
color: colors.inputError
|
|
132
591
|
}
|
|
133
592
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
593
|
+
function renderInputIcon(icon, color) {
|
|
594
|
+
if (!icon) return null;
|
|
595
|
+
if (isValidElement(icon)) {
|
|
596
|
+
return cloneElement(icon, {
|
|
597
|
+
size: icon.props.size ?? INPUT_ICON_SIZE,
|
|
598
|
+
color: icon.props.color ?? color
|
|
599
|
+
});
|
|
137
600
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
601
|
+
return icon;
|
|
602
|
+
}
|
|
603
|
+
function Input({
|
|
604
|
+
label,
|
|
605
|
+
leftIcon,
|
|
606
|
+
rightIcon,
|
|
607
|
+
error,
|
|
608
|
+
hint,
|
|
609
|
+
containerStyle,
|
|
610
|
+
style,
|
|
611
|
+
className,
|
|
612
|
+
labelClassName,
|
|
613
|
+
inputClassName,
|
|
614
|
+
errorClassName,
|
|
615
|
+
hintClassName,
|
|
616
|
+
editable = true,
|
|
617
|
+
onFocus,
|
|
618
|
+
onBlur,
|
|
619
|
+
...props
|
|
620
|
+
}) {
|
|
621
|
+
const wrapperRef = useRef(null);
|
|
622
|
+
const inputRef = useRef(null);
|
|
623
|
+
const helperRef = useRef(null);
|
|
624
|
+
const [focused, setFocused] = useState(false);
|
|
625
|
+
useApplyWebClassName(wrapperRef, className);
|
|
626
|
+
useApplyWebClassName(inputRef, inputClassName);
|
|
627
|
+
useApplyWebClassName(helperRef, error ? errorClassName : hintClassName);
|
|
628
|
+
const isDisabled = editable === false;
|
|
629
|
+
const visualState = resolveInputVisualState({
|
|
630
|
+
focused,
|
|
631
|
+
error: Boolean(error),
|
|
632
|
+
disabled: isDisabled
|
|
633
|
+
});
|
|
634
|
+
const fieldStyles = getInputFieldStyles(visualState);
|
|
635
|
+
const iconColor = fieldStyles.icon;
|
|
636
|
+
function handleFocus(event) {
|
|
637
|
+
setFocused(true);
|
|
638
|
+
onFocus?.(event);
|
|
639
|
+
}
|
|
640
|
+
function handleBlur(event) {
|
|
641
|
+
setFocused(false);
|
|
642
|
+
onBlur?.(event);
|
|
643
|
+
}
|
|
644
|
+
const helperMessage = error ?? hint;
|
|
645
|
+
return /* @__PURE__ */ jsxs(View, { ref: wrapperRef, style: [styles3.wrapper, containerStyle], children: [
|
|
646
|
+
label ? /* @__PURE__ */ jsx(Label, { disabled: isDisabled, className: labelClassName, children: label }) : null,
|
|
647
|
+
/* @__PURE__ */ jsx(View, { style: fieldStyles.outline, children: /* @__PURE__ */ jsxs(View, { style: [inputFieldMetrics.container, fieldStyles.container], children: [
|
|
648
|
+
leftIcon ? /* @__PURE__ */ jsx(View, { style: styles3.iconSlot, children: renderInputIcon(leftIcon, iconColor) }) : null,
|
|
649
|
+
/* @__PURE__ */ jsx(
|
|
650
|
+
TextInput,
|
|
651
|
+
{
|
|
652
|
+
ref: inputRef,
|
|
653
|
+
style: [
|
|
654
|
+
inputFieldMetrics.input,
|
|
655
|
+
fieldStyles.text,
|
|
656
|
+
style
|
|
657
|
+
],
|
|
658
|
+
placeholderTextColor: fieldStyles.placeholder,
|
|
659
|
+
editable,
|
|
660
|
+
onFocus: handleFocus,
|
|
661
|
+
onBlur: handleBlur,
|
|
662
|
+
accessibilityState: { disabled: isDisabled },
|
|
663
|
+
...props
|
|
664
|
+
}
|
|
665
|
+
),
|
|
666
|
+
rightIcon ? /* @__PURE__ */ jsx(View, { style: styles3.iconSlot, children: renderInputIcon(rightIcon, iconColor) }) : null
|
|
667
|
+
] }) }),
|
|
668
|
+
helperMessage ? /* @__PURE__ */ jsx(Text, { ref: helperRef, style: error ? styles3.error : styles3.hint, children: helperMessage }) : null
|
|
669
|
+
] });
|
|
670
|
+
}
|
|
671
|
+
var styles3 = StyleSheet.create({
|
|
672
|
+
wrapper: {
|
|
673
|
+
width: "100%",
|
|
674
|
+
gap: spacing.sm
|
|
142
675
|
},
|
|
143
|
-
|
|
144
|
-
|
|
676
|
+
iconSlot: {
|
|
677
|
+
width: INPUT_ICON_SIZE,
|
|
678
|
+
height: INPUT_ICON_SIZE,
|
|
679
|
+
alignItems: "center",
|
|
680
|
+
justifyContent: "center",
|
|
681
|
+
flexShrink: 0
|
|
145
682
|
},
|
|
146
|
-
|
|
147
|
-
|
|
683
|
+
error: {
|
|
684
|
+
fontSize: 12,
|
|
685
|
+
lineHeight: 12,
|
|
686
|
+
color: colors.inputError
|
|
148
687
|
},
|
|
149
|
-
|
|
150
|
-
|
|
688
|
+
hint: {
|
|
689
|
+
fontSize: 12,
|
|
690
|
+
lineHeight: 12,
|
|
691
|
+
color: colors.stormGray300
|
|
151
692
|
}
|
|
152
693
|
});
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
694
|
+
|
|
695
|
+
// src/data/countries.ts
|
|
696
|
+
var defaultCountry = {
|
|
697
|
+
code: "AM",
|
|
698
|
+
name: "Armenia",
|
|
699
|
+
dialCode: "+374"
|
|
700
|
+
};
|
|
701
|
+
var countries = [
|
|
702
|
+
defaultCountry,
|
|
703
|
+
{ code: "AF", name: "Afghanistan", dialCode: "+93" },
|
|
704
|
+
{ code: "AL", name: "Albania", dialCode: "+355" },
|
|
705
|
+
{ code: "DZ", name: "Algeria", dialCode: "+213" },
|
|
706
|
+
{ code: "AR", name: "Argentina", dialCode: "+54" },
|
|
707
|
+
{ code: "AU", name: "Australia", dialCode: "+61" },
|
|
708
|
+
{ code: "AT", name: "Austria", dialCode: "+43" },
|
|
709
|
+
{ code: "AZ", name: "Azerbaijan", dialCode: "+994" },
|
|
710
|
+
{ code: "BH", name: "Bahrain", dialCode: "+973" },
|
|
711
|
+
{ code: "BY", name: "Belarus", dialCode: "+375" },
|
|
712
|
+
{ code: "BE", name: "Belgium", dialCode: "+32" },
|
|
713
|
+
{ code: "BR", name: "Brazil", dialCode: "+55" },
|
|
714
|
+
{ code: "BG", name: "Bulgaria", dialCode: "+359" },
|
|
715
|
+
{ code: "CA", name: "Canada", dialCode: "+1" },
|
|
716
|
+
{ code: "CL", name: "Chile", dialCode: "+56" },
|
|
717
|
+
{ code: "CN", name: "China", dialCode: "+86" },
|
|
718
|
+
{ code: "CO", name: "Colombia", dialCode: "+57" },
|
|
719
|
+
{ code: "HR", name: "Croatia", dialCode: "+385" },
|
|
720
|
+
{ code: "CY", name: "Cyprus", dialCode: "+357" },
|
|
721
|
+
{ code: "CZ", name: "Czech Republic", dialCode: "+420" },
|
|
722
|
+
{ code: "DK", name: "Denmark", dialCode: "+45" },
|
|
723
|
+
{ code: "EG", name: "Egypt", dialCode: "+20" },
|
|
724
|
+
{ code: "EE", name: "Estonia", dialCode: "+372" },
|
|
725
|
+
{ code: "FI", name: "Finland", dialCode: "+358" },
|
|
726
|
+
{ code: "FR", name: "France", dialCode: "+33" },
|
|
727
|
+
{ code: "GE", name: "Georgia", dialCode: "+995" },
|
|
728
|
+
{ code: "DE", name: "Germany", dialCode: "+49" },
|
|
729
|
+
{ code: "GR", name: "Greece", dialCode: "+30" },
|
|
730
|
+
{ code: "HK", name: "Hong Kong", dialCode: "+852" },
|
|
731
|
+
{ code: "HU", name: "Hungary", dialCode: "+36" },
|
|
732
|
+
{ code: "IN", name: "India", dialCode: "+91" },
|
|
733
|
+
{ code: "ID", name: "Indonesia", dialCode: "+62" },
|
|
734
|
+
{ code: "IR", name: "Iran", dialCode: "+98" },
|
|
735
|
+
{ code: "IQ", name: "Iraq", dialCode: "+964" },
|
|
736
|
+
{ code: "IE", name: "Ireland", dialCode: "+353" },
|
|
737
|
+
{ code: "IL", name: "Israel", dialCode: "+972" },
|
|
738
|
+
{ code: "IT", name: "Italy", dialCode: "+39" },
|
|
739
|
+
{ code: "JP", name: "Japan", dialCode: "+81" },
|
|
740
|
+
{ code: "JO", name: "Jordan", dialCode: "+962" },
|
|
741
|
+
{ code: "KZ", name: "Kazakhstan", dialCode: "+7" },
|
|
742
|
+
{ code: "KW", name: "Kuwait", dialCode: "+965" },
|
|
743
|
+
{ code: "LV", name: "Latvia", dialCode: "+371" },
|
|
744
|
+
{ code: "LB", name: "Lebanon", dialCode: "+961" },
|
|
745
|
+
{ code: "LT", name: "Lithuania", dialCode: "+370" },
|
|
746
|
+
{ code: "LU", name: "Luxembourg", dialCode: "+352" },
|
|
747
|
+
{ code: "MY", name: "Malaysia", dialCode: "+60" },
|
|
748
|
+
{ code: "MX", name: "Mexico", dialCode: "+52" },
|
|
749
|
+
{ code: "MD", name: "Moldova", dialCode: "+373" },
|
|
750
|
+
{ code: "NL", name: "Netherlands", dialCode: "+31" },
|
|
751
|
+
{ code: "NZ", name: "New Zealand", dialCode: "+64" },
|
|
752
|
+
{ code: "NG", name: "Nigeria", dialCode: "+234" },
|
|
753
|
+
{ code: "NO", name: "Norway", dialCode: "+47" },
|
|
754
|
+
{ code: "PK", name: "Pakistan", dialCode: "+92" },
|
|
755
|
+
{ code: "PS", name: "Palestine", dialCode: "+970" },
|
|
756
|
+
{ code: "PH", name: "Philippines", dialCode: "+63" },
|
|
757
|
+
{ code: "PL", name: "Poland", dialCode: "+48" },
|
|
758
|
+
{ code: "PT", name: "Portugal", dialCode: "+351" },
|
|
759
|
+
{ code: "QA", name: "Qatar", dialCode: "+974" },
|
|
760
|
+
{ code: "RO", name: "Romania", dialCode: "+40" },
|
|
761
|
+
{ code: "RU", name: "Russia", dialCode: "+7" },
|
|
762
|
+
{ code: "SA", name: "Saudi Arabia", dialCode: "+966" },
|
|
763
|
+
{ code: "RS", name: "Serbia", dialCode: "+381" },
|
|
764
|
+
{ code: "SG", name: "Singapore", dialCode: "+65" },
|
|
765
|
+
{ code: "SK", name: "Slovakia", dialCode: "+421" },
|
|
766
|
+
{ code: "SI", name: "Slovenia", dialCode: "+386" },
|
|
767
|
+
{ code: "ZA", name: "South Africa", dialCode: "+27" },
|
|
768
|
+
{ code: "KR", name: "South Korea", dialCode: "+82" },
|
|
769
|
+
{ code: "ES", name: "Spain", dialCode: "+34" },
|
|
770
|
+
{ code: "SE", name: "Sweden", dialCode: "+46" },
|
|
771
|
+
{ code: "CH", name: "Switzerland", dialCode: "+41" },
|
|
772
|
+
{ code: "SY", name: "Syria", dialCode: "+963" },
|
|
773
|
+
{ code: "TW", name: "Taiwan", dialCode: "+886" },
|
|
774
|
+
{ code: "TH", name: "Thailand", dialCode: "+66" },
|
|
775
|
+
{ code: "TR", name: "Turkey", dialCode: "+90" },
|
|
776
|
+
{ code: "UA", name: "Ukraine", dialCode: "+380" },
|
|
777
|
+
{ code: "AE", name: "United Arab Emirates", dialCode: "+971" },
|
|
778
|
+
{ code: "GB", name: "United Kingdom", dialCode: "+44" },
|
|
779
|
+
{ code: "US", name: "United States", dialCode: "+1" },
|
|
780
|
+
{ code: "UZ", name: "Uzbekistan", dialCode: "+998" },
|
|
781
|
+
{ code: "VN", name: "Vietnam", dialCode: "+84" }
|
|
782
|
+
];
|
|
783
|
+
function findCountry(code) {
|
|
784
|
+
return countries.find((country) => country.code === code) ?? defaultCountry;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// src/icons/chevronDownPath.ts
|
|
788
|
+
var CHEVRON_DOWN_PATH = "M4 6L8 10L12 6";
|
|
789
|
+
function ChevronDownIcon({
|
|
790
|
+
size = 16,
|
|
791
|
+
color = "#dadde0",
|
|
792
|
+
strokeWidth = 2
|
|
793
|
+
}) {
|
|
794
|
+
return /* @__PURE__ */ jsx(Svg, { width: size, height: size, viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsx(
|
|
795
|
+
Path,
|
|
796
|
+
{
|
|
797
|
+
d: CHEVRON_DOWN_PATH,
|
|
798
|
+
stroke: color,
|
|
799
|
+
strokeWidth,
|
|
800
|
+
strokeLinecap: "round",
|
|
801
|
+
strokeLinejoin: "round"
|
|
802
|
+
}
|
|
803
|
+
) });
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
// src/utils/countryFlag.ts
|
|
807
|
+
function countryCodeToFlagEmoji(code) {
|
|
808
|
+
const upper = code.trim().toUpperCase();
|
|
809
|
+
if (upper.length !== 2) return "";
|
|
810
|
+
return String.fromCodePoint(
|
|
811
|
+
...upper.split("").map((char) => 127462 - 65 + char.charCodeAt(0))
|
|
812
|
+
);
|
|
813
|
+
}
|
|
814
|
+
var COUNTRY_DROPDOWN_SCROLL_CLASS = "hp-country-dropdown-scroll";
|
|
815
|
+
var STYLE_ID = "hp-country-dropdown-scroll-styles";
|
|
816
|
+
var countryDropdownScrollCss = `
|
|
817
|
+
.${COUNTRY_DROPDOWN_SCROLL_CLASS} {
|
|
818
|
+
scrollbar-width: thin;
|
|
819
|
+
scrollbar-color: ${colors.stormGray300} transparent;
|
|
820
|
+
overflow-y: auto;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
.${COUNTRY_DROPDOWN_SCROLL_CLASS}::-webkit-scrollbar {
|
|
824
|
+
width: 4px;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
.${COUNTRY_DROPDOWN_SCROLL_CLASS}::-webkit-scrollbar-corner {
|
|
828
|
+
background: transparent;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
.${COUNTRY_DROPDOWN_SCROLL_CLASS}::-webkit-scrollbar-button,
|
|
832
|
+
.${COUNTRY_DROPDOWN_SCROLL_CLASS}::-webkit-scrollbar-button:single-button,
|
|
833
|
+
.${COUNTRY_DROPDOWN_SCROLL_CLASS}::-webkit-scrollbar-button:vertical:start:decrement,
|
|
834
|
+
.${COUNTRY_DROPDOWN_SCROLL_CLASS}::-webkit-scrollbar-button:vertical:end:increment {
|
|
835
|
+
display: none;
|
|
836
|
+
width: 0;
|
|
837
|
+
height: 0;
|
|
838
|
+
-webkit-appearance: none;
|
|
839
|
+
appearance: none;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
.${COUNTRY_DROPDOWN_SCROLL_CLASS}::-webkit-scrollbar-track {
|
|
843
|
+
background: transparent;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
.${COUNTRY_DROPDOWN_SCROLL_CLASS}::-webkit-scrollbar-thumb {
|
|
847
|
+
background-color: ${colors.stormGray300};
|
|
848
|
+
border-radius: 9999px;
|
|
849
|
+
}
|
|
850
|
+
`;
|
|
851
|
+
function ensureCountryDropdownScrollStyles() {
|
|
852
|
+
if (Platform.OS !== "web" || typeof document === "undefined") return;
|
|
853
|
+
if (document.getElementById(STYLE_ID)) return;
|
|
854
|
+
const style = document.createElement("style");
|
|
855
|
+
style.id = STYLE_ID;
|
|
856
|
+
style.textContent = countryDropdownScrollCss;
|
|
857
|
+
document.head.appendChild(style);
|
|
858
|
+
}
|
|
859
|
+
var DROPDOWN_GAP = 10;
|
|
860
|
+
var DROPDOWN_HEIGHT = 186;
|
|
861
|
+
var DROPDOWN_PADDING = 8;
|
|
862
|
+
var OPTION_GAP = 10;
|
|
863
|
+
var OPTION_HEIGHT = 35;
|
|
864
|
+
var TRIGGER_HEIGHT = 52;
|
|
865
|
+
var CHEVRON_SIZE = 16;
|
|
866
|
+
function resolveDropdownTop(anchor) {
|
|
867
|
+
const windowHeight = Dimensions.get("window").height;
|
|
868
|
+
const topBelow = anchor.y + anchor.height + DROPDOWN_GAP;
|
|
869
|
+
const topAbove = anchor.y - DROPDOWN_GAP - DROPDOWN_HEIGHT;
|
|
870
|
+
const fitsBelow = topBelow + DROPDOWN_HEIGHT <= windowHeight;
|
|
871
|
+
if (fitsBelow) return topBelow;
|
|
872
|
+
if (topAbove >= 0) return topAbove;
|
|
873
|
+
return Math.max(0, Math.min(topBelow, windowHeight - DROPDOWN_HEIGHT));
|
|
874
|
+
}
|
|
875
|
+
function CountryCodeSelector({
|
|
876
|
+
value = defaultCountry.code,
|
|
877
|
+
onValueChange,
|
|
878
|
+
options = countries,
|
|
879
|
+
disabled = false,
|
|
880
|
+
style,
|
|
881
|
+
className
|
|
882
|
+
}) {
|
|
883
|
+
const wrapperRef = useRef(null);
|
|
884
|
+
const triggerRef = useRef(null);
|
|
885
|
+
const scrollRef = useRef(null);
|
|
886
|
+
const [open, setOpen] = useState(false);
|
|
887
|
+
const [anchor, setAnchor] = useState(null);
|
|
888
|
+
useApplyWebClassName(wrapperRef, className);
|
|
889
|
+
useApplyWebClassName(
|
|
890
|
+
scrollRef,
|
|
891
|
+
COUNTRY_DROPDOWN_SCROLL_CLASS,
|
|
892
|
+
open && Boolean(anchor)
|
|
893
|
+
);
|
|
894
|
+
useLayoutEffect(() => {
|
|
895
|
+
ensureCountryDropdownScrollStyles();
|
|
896
|
+
}, []);
|
|
897
|
+
const selected = findCountry(value);
|
|
898
|
+
const textColor = disabled ? colors.stormGray200 : colors.slateBlue;
|
|
899
|
+
function closeDropdown() {
|
|
900
|
+
setOpen(false);
|
|
901
|
+
setAnchor(null);
|
|
902
|
+
}
|
|
903
|
+
function handleOpen() {
|
|
904
|
+
if (disabled) return;
|
|
905
|
+
triggerRef.current?.measureInWindow((x, y, width, height) => {
|
|
906
|
+
setAnchor({ x, y, width, height });
|
|
907
|
+
setOpen(true);
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
function handleSelect(code) {
|
|
911
|
+
onValueChange?.(code);
|
|
912
|
+
closeDropdown();
|
|
913
|
+
}
|
|
914
|
+
const dropdownTop = anchor ? resolveDropdownTop(anchor) : 0;
|
|
915
|
+
const optionList = options.map((item, index) => {
|
|
916
|
+
const isSelected = item.code === selected.code;
|
|
917
|
+
const isLast = index === options.length - 1;
|
|
918
|
+
return /* @__PURE__ */ jsxs(
|
|
919
|
+
Pressable,
|
|
920
|
+
{
|
|
921
|
+
accessibilityRole: "button",
|
|
922
|
+
onPress: () => handleSelect(item.code),
|
|
923
|
+
style: [
|
|
924
|
+
styles4.option,
|
|
925
|
+
isSelected && styles4.optionSelected,
|
|
926
|
+
!isLast && styles4.optionSpacing
|
|
927
|
+
],
|
|
928
|
+
children: [
|
|
929
|
+
/* @__PURE__ */ jsx(Text, { style: styles4.flag, children: countryCodeToFlagEmoji(item.code) }),
|
|
930
|
+
/* @__PURE__ */ jsx(Text, { style: styles4.optionDialCode, children: item.dialCode })
|
|
931
|
+
]
|
|
932
|
+
},
|
|
933
|
+
item.code
|
|
934
|
+
);
|
|
935
|
+
});
|
|
936
|
+
const dropdownList = /* @__PURE__ */ jsx(
|
|
937
|
+
ScrollView,
|
|
938
|
+
{
|
|
939
|
+
ref: scrollRef,
|
|
940
|
+
style: styles4.dropdownScroll,
|
|
941
|
+
contentContainerStyle: styles4.dropdownContent,
|
|
942
|
+
keyboardShouldPersistTaps: "handled",
|
|
943
|
+
showsVerticalScrollIndicator: true,
|
|
944
|
+
bounces: false,
|
|
945
|
+
nestedScrollEnabled: true,
|
|
946
|
+
children: optionList
|
|
947
|
+
}
|
|
948
|
+
);
|
|
949
|
+
return /* @__PURE__ */ jsxs(View, { ref: wrapperRef, style: [styles4.root, style], children: [
|
|
950
|
+
/* @__PURE__ */ jsxs(
|
|
951
|
+
Pressable,
|
|
952
|
+
{
|
|
953
|
+
ref: triggerRef,
|
|
954
|
+
accessibilityRole: "button",
|
|
955
|
+
disabled,
|
|
956
|
+
onPress: handleOpen,
|
|
957
|
+
style: [
|
|
958
|
+
styles4.trigger,
|
|
959
|
+
disabled ? styles4.triggerDisabled : styles4.triggerEnabled,
|
|
960
|
+
Platform.OS === "web" ? styles4.triggerWeb : null
|
|
961
|
+
],
|
|
962
|
+
children: [
|
|
963
|
+
/* @__PURE__ */ jsx(Text, { style: styles4.flag, children: countryCodeToFlagEmoji(selected.code) }),
|
|
964
|
+
/* @__PURE__ */ jsx(Text, { style: [styles4.dialCode, { color: textColor }], children: selected.dialCode }),
|
|
965
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, { size: CHEVRON_SIZE, color: colors.stormGray100 })
|
|
966
|
+
]
|
|
967
|
+
}
|
|
968
|
+
),
|
|
969
|
+
/* @__PURE__ */ jsx(
|
|
970
|
+
Modal,
|
|
971
|
+
{
|
|
972
|
+
visible: open,
|
|
973
|
+
transparent: true,
|
|
974
|
+
animationType: "fade",
|
|
975
|
+
onRequestClose: closeDropdown,
|
|
976
|
+
children: /* @__PURE__ */ jsx(Pressable, { style: styles4.overlay, onPress: closeDropdown, children: anchor ? /* @__PURE__ */ jsx(
|
|
977
|
+
View,
|
|
978
|
+
{
|
|
979
|
+
style: [
|
|
980
|
+
styles4.dropdown,
|
|
981
|
+
{
|
|
982
|
+
top: dropdownTop,
|
|
983
|
+
left: anchor.x,
|
|
984
|
+
width: anchor.width
|
|
985
|
+
}
|
|
986
|
+
],
|
|
987
|
+
children: dropdownList
|
|
988
|
+
}
|
|
989
|
+
) : null })
|
|
990
|
+
}
|
|
991
|
+
)
|
|
992
|
+
] });
|
|
993
|
+
}
|
|
994
|
+
var styles4 = StyleSheet.create({
|
|
995
|
+
root: {
|
|
996
|
+
alignSelf: "flex-start",
|
|
997
|
+
flexShrink: 0
|
|
998
|
+
},
|
|
999
|
+
trigger: {
|
|
1000
|
+
flexDirection: "row",
|
|
1001
|
+
alignItems: "center",
|
|
1002
|
+
alignSelf: "flex-start",
|
|
1003
|
+
flexGrow: 0,
|
|
1004
|
+
flexShrink: 0,
|
|
1005
|
+
height: TRIGGER_HEIGHT,
|
|
1006
|
+
borderRadius: radii.lg,
|
|
1007
|
+
borderWidth: 1,
|
|
1008
|
+
padding: spacing.lg,
|
|
1009
|
+
gap: spacing.sm
|
|
1010
|
+
},
|
|
1011
|
+
triggerEnabled: {
|
|
1012
|
+
borderColor: colors.stormGray50,
|
|
1013
|
+
backgroundColor: colors.white
|
|
1014
|
+
},
|
|
1015
|
+
triggerDisabled: {
|
|
1016
|
+
borderColor: colors.stormGray50,
|
|
1017
|
+
backgroundColor: colors.stormGray50
|
|
1018
|
+
},
|
|
1019
|
+
triggerWeb: {
|
|
1020
|
+
width: "max-content"
|
|
1021
|
+
},
|
|
1022
|
+
flag: {
|
|
1023
|
+
fontSize: 18,
|
|
1024
|
+
lineHeight: 22
|
|
1025
|
+
},
|
|
1026
|
+
dialCode: {
|
|
1027
|
+
fontSize: fontSize.md,
|
|
1028
|
+
fontWeight: fontWeight.medium
|
|
1029
|
+
},
|
|
1030
|
+
overlay: {
|
|
1031
|
+
flex: 1,
|
|
1032
|
+
backgroundColor: "transparent"
|
|
1033
|
+
},
|
|
1034
|
+
dropdown: {
|
|
1035
|
+
position: "absolute",
|
|
1036
|
+
height: DROPDOWN_HEIGHT,
|
|
1037
|
+
borderRadius: radii.lg,
|
|
1038
|
+
borderWidth: 1,
|
|
1039
|
+
borderColor: colors.stormGray50,
|
|
1040
|
+
backgroundColor: colors.white,
|
|
1041
|
+
padding: DROPDOWN_PADDING,
|
|
1042
|
+
overflow: "hidden"
|
|
1043
|
+
},
|
|
1044
|
+
dropdownScroll: {
|
|
1045
|
+
flex: 1
|
|
156
1046
|
},
|
|
157
|
-
|
|
158
|
-
|
|
1047
|
+
dropdownContent: {
|
|
1048
|
+
flexGrow: 1
|
|
159
1049
|
},
|
|
160
|
-
|
|
161
|
-
|
|
1050
|
+
option: {
|
|
1051
|
+
flexDirection: "row",
|
|
1052
|
+
alignItems: "center",
|
|
1053
|
+
height: OPTION_HEIGHT,
|
|
1054
|
+
borderRadius: radii.sm,
|
|
1055
|
+
padding: spacing.sm,
|
|
1056
|
+
gap: spacing.sm
|
|
1057
|
+
},
|
|
1058
|
+
optionSpacing: {
|
|
1059
|
+
marginBottom: OPTION_GAP
|
|
1060
|
+
},
|
|
1061
|
+
optionSelected: {
|
|
1062
|
+
backgroundColor: colors.countrySelectorSelectedBg
|
|
1063
|
+
},
|
|
1064
|
+
optionDialCode: {
|
|
1065
|
+
fontFamily: fonts.sans,
|
|
1066
|
+
fontSize: fontSize.md,
|
|
1067
|
+
fontWeight: fontWeight.regular,
|
|
1068
|
+
lineHeight: fontSize.md,
|
|
1069
|
+
letterSpacing: 0,
|
|
1070
|
+
textAlign: "center",
|
|
1071
|
+
color: colors.slateBlue
|
|
162
1072
|
}
|
|
163
1073
|
});
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
1074
|
+
function PhoneInput({
|
|
1075
|
+
label,
|
|
1076
|
+
countryCode,
|
|
1077
|
+
onCountryCodeChange,
|
|
1078
|
+
error,
|
|
1079
|
+
hint,
|
|
1080
|
+
containerStyle,
|
|
1081
|
+
style,
|
|
1082
|
+
className,
|
|
1083
|
+
labelClassName,
|
|
1084
|
+
inputClassName,
|
|
1085
|
+
errorClassName,
|
|
1086
|
+
hintClassName,
|
|
1087
|
+
editable = true,
|
|
1088
|
+
onFocus,
|
|
1089
|
+
onBlur,
|
|
1090
|
+
...props
|
|
1091
|
+
}) {
|
|
1092
|
+
const wrapperRef = useRef(null);
|
|
1093
|
+
const inputRef = useRef(null);
|
|
1094
|
+
const helperRef = useRef(null);
|
|
1095
|
+
const [focused, setFocused] = useState(false);
|
|
1096
|
+
useApplyWebClassName(wrapperRef, className);
|
|
1097
|
+
useApplyWebClassName(inputRef, inputClassName);
|
|
1098
|
+
useApplyWebClassName(helperRef, error ? errorClassName : hintClassName);
|
|
1099
|
+
const isDisabled = editable === false;
|
|
1100
|
+
const phoneVisualState = resolveInputVisualState({
|
|
1101
|
+
focused,
|
|
1102
|
+
error: Boolean(error),
|
|
1103
|
+
disabled: isDisabled
|
|
1104
|
+
});
|
|
1105
|
+
const phoneFieldStyles = getInputFieldStyles(phoneVisualState);
|
|
1106
|
+
function handleFocus(event) {
|
|
1107
|
+
setFocused(true);
|
|
1108
|
+
onFocus?.(event);
|
|
1109
|
+
}
|
|
1110
|
+
function handleBlur(event) {
|
|
1111
|
+
setFocused(false);
|
|
1112
|
+
onBlur?.(event);
|
|
1113
|
+
}
|
|
1114
|
+
const helperMessage = error ?? hint;
|
|
1115
|
+
return /* @__PURE__ */ jsxs(View, { ref: wrapperRef, style: [styles5.wrapper, containerStyle], children: [
|
|
1116
|
+
label ? /* @__PURE__ */ jsx(Label, { disabled: isDisabled, className: labelClassName, children: label }) : null,
|
|
1117
|
+
/* @__PURE__ */ jsxs(View, { style: styles5.row, children: [
|
|
1118
|
+
/* @__PURE__ */ jsx(
|
|
1119
|
+
CountryCodeSelector,
|
|
1120
|
+
{
|
|
1121
|
+
value: countryCode,
|
|
1122
|
+
onValueChange: onCountryCodeChange,
|
|
1123
|
+
disabled: isDisabled,
|
|
1124
|
+
style: styles5.countrySelector
|
|
1125
|
+
}
|
|
1126
|
+
),
|
|
1127
|
+
/* @__PURE__ */ jsxs(View, { style: styles5.phoneColumn, children: [
|
|
1128
|
+
/* @__PURE__ */ jsx(View, { style: [phoneFieldStyles.outline, styles5.phoneOutline], children: /* @__PURE__ */ jsx(
|
|
1129
|
+
View,
|
|
1130
|
+
{
|
|
1131
|
+
style: [
|
|
1132
|
+
inputFieldMetrics.container,
|
|
1133
|
+
phoneFieldStyles.container,
|
|
1134
|
+
styles5.phoneField
|
|
1135
|
+
],
|
|
1136
|
+
children: /* @__PURE__ */ jsx(
|
|
1137
|
+
TextInput,
|
|
1138
|
+
{
|
|
1139
|
+
ref: inputRef,
|
|
1140
|
+
style: [
|
|
1141
|
+
inputFieldMetrics.input,
|
|
1142
|
+
phoneFieldStyles.text,
|
|
1143
|
+
style
|
|
1144
|
+
],
|
|
1145
|
+
keyboardType: "phone-pad",
|
|
1146
|
+
placeholderTextColor: phoneFieldStyles.placeholder,
|
|
1147
|
+
editable,
|
|
1148
|
+
onFocus: handleFocus,
|
|
1149
|
+
onBlur: handleBlur,
|
|
1150
|
+
accessibilityState: { disabled: isDisabled },
|
|
1151
|
+
...props
|
|
1152
|
+
}
|
|
1153
|
+
)
|
|
1154
|
+
}
|
|
1155
|
+
) }),
|
|
1156
|
+
helperMessage ? /* @__PURE__ */ jsx(Text, { ref: helperRef, style: error ? styles5.error : styles5.hint, children: helperMessage }) : null
|
|
1157
|
+
] })
|
|
1158
|
+
] })
|
|
1159
|
+
] });
|
|
1160
|
+
}
|
|
1161
|
+
var styles5 = StyleSheet.create({
|
|
1162
|
+
wrapper: {
|
|
1163
|
+
width: "100%",
|
|
1164
|
+
gap: spacing.sm
|
|
1165
|
+
},
|
|
1166
|
+
row: {
|
|
1167
|
+
flexDirection: "row",
|
|
1168
|
+
alignItems: "flex-start",
|
|
1169
|
+
gap: INPUT_ICON_GAP
|
|
1170
|
+
},
|
|
1171
|
+
countrySelector: {
|
|
1172
|
+
flexShrink: 0,
|
|
1173
|
+
alignSelf: "flex-start"
|
|
1174
|
+
},
|
|
1175
|
+
phoneColumn: {
|
|
1176
|
+
flex: 1,
|
|
1177
|
+
gap: spacing.sm
|
|
1178
|
+
},
|
|
1179
|
+
phoneOutline: {
|
|
1180
|
+
width: "100%"
|
|
167
1181
|
},
|
|
168
|
-
|
|
169
|
-
|
|
1182
|
+
phoneField: {
|
|
1183
|
+
flex: 1
|
|
170
1184
|
},
|
|
171
|
-
|
|
172
|
-
|
|
1185
|
+
error: {
|
|
1186
|
+
fontSize: 12,
|
|
1187
|
+
lineHeight: 12,
|
|
1188
|
+
color: colors.inputError
|
|
173
1189
|
},
|
|
174
|
-
|
|
175
|
-
|
|
1190
|
+
hint: {
|
|
1191
|
+
fontSize: 12,
|
|
1192
|
+
lineHeight: 12,
|
|
1193
|
+
color: colors.stormGray300
|
|
176
1194
|
}
|
|
177
1195
|
});
|
|
178
1196
|
|
|
179
|
-
export { Button };
|
|
1197
|
+
export { Button, CountryCodeSelector, Input, Label, PhoneInput, brand, buttonTypography, colors, countries, defaultCountry, emeraldGreen, findCountry, fontSize, fontWeight, fonts, labelTypography, navy, radii, rubyRed, shadows, spacing, stormGray };
|
|
180
1198
|
//# sourceMappingURL=index.js.map
|
|
181
1199
|
//# sourceMappingURL=index.js.map
|