@clerk/ui 0.1.9 → 0.1.10
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/dist/{chunk-GJNJVJGS.mjs → chunk-LLOUIL3Z.mjs} +1074 -2170
- package/dist/chunk-LLOUIL3Z.mjs.map +1 -0
- package/dist/chunk-TVTJKSVH.mjs +1811 -0
- package/dist/chunk-TVTJKSVH.mjs.map +1 -0
- package/dist/components/sign-in.d.mts +1 -1
- package/dist/components/sign-in.d.ts +1 -1
- package/dist/components/sign-in.js +2663 -2296
- package/dist/components/sign-in.js.map +1 -1
- package/dist/components/sign-in.mjs +68 -30
- package/dist/components/sign-in.mjs.map +1 -1
- package/dist/components/sign-up.js +4674 -4326
- package/dist/components/sign-up.js.map +1 -1
- package/dist/components/sign-up.mjs +27 -8
- package/dist/components/sign-up.mjs.map +1 -1
- package/dist/contexts.d.mts +5 -4
- package/dist/contexts.d.ts +5 -4
- package/dist/contexts.js +993 -40
- package/dist/contexts.js.map +1 -1
- package/dist/contexts.mjs +1 -1
- package/dist/styles.css +1 -1
- package/package.json +15 -14
- package/dist/chunk-GJNJVJGS.mjs.map +0 -1
- package/dist/chunk-RVVUA25B.mjs +0 -383
- package/dist/chunk-RVVUA25B.mjs.map +0 -1
|
@@ -0,0 +1,1811 @@
|
|
|
1
|
+
import { ExclamationOctagonSm, ExclamationTriangleSm, useLocalizations, translatePasswordError, useAppearance, Alert, Icon } from './chunk-LLOUIL3Z.mjs';
|
|
2
|
+
import { useClerk } from '@clerk/shared/react';
|
|
3
|
+
import * as React6 from 'react';
|
|
4
|
+
import React6__default, { useMemo, cloneElement } from 'react';
|
|
5
|
+
import * as Common from '@clerk/elements/common';
|
|
6
|
+
import { GlobalError as GlobalError$1 } from '@clerk/elements/common';
|
|
7
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
|
+
import { cva, cx } from 'cva';
|
|
9
|
+
import { useAutoAnimate } from '@formkit/auto-animate/react';
|
|
10
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
11
|
+
import { Command } from 'cmdk';
|
|
12
|
+
import { DialogTrigger, Button, Popover, Dialog, ToggleButton } from 'react-aria-components';
|
|
13
|
+
import { useClerkHostRouter } from '@clerk/shared/router';
|
|
14
|
+
|
|
15
|
+
// src/constants/localizations.ts
|
|
16
|
+
var LOCALIZATION_NEEDED = {
|
|
17
|
+
formFieldAccessibleLabel__emailOrUsernameOrPhone: "Toggle between email or username, and phone.",
|
|
18
|
+
formFieldAccessibleLabel__phoneOrUsername: "Toggle between phone and username.",
|
|
19
|
+
developmentMode: "Development mode"
|
|
20
|
+
};
|
|
21
|
+
function useDisplayConfig() {
|
|
22
|
+
var _a;
|
|
23
|
+
const clerk = useClerk();
|
|
24
|
+
const displayConfig = (_a = clerk == null ? void 0 : clerk.__unstable__environment) == null ? void 0 : _a.displayConfig;
|
|
25
|
+
return displayConfig;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/hooks/use-card.ts
|
|
29
|
+
function useCard() {
|
|
30
|
+
const { options } = useAppearance().parsedAppearance;
|
|
31
|
+
const { applicationName, branded, logoImageUrl, homeUrl } = useDisplayConfig();
|
|
32
|
+
const logoProps = (options == null ? void 0 : options.logoVisibility) === "visible" ? {
|
|
33
|
+
href: (options == null ? void 0 : options.logoLinkUrl) || homeUrl,
|
|
34
|
+
src: (options == null ? void 0 : options.logoImageUrl) || logoImageUrl,
|
|
35
|
+
alt: applicationName
|
|
36
|
+
} : null;
|
|
37
|
+
const footerProps = {
|
|
38
|
+
branded,
|
|
39
|
+
helpPageUrl: options == null ? void 0 : options.helpPageUrl,
|
|
40
|
+
privacyPageUrl: options == null ? void 0 : options.privacyPageUrl,
|
|
41
|
+
termsPageUrl: options == null ? void 0 : options.termsPageUrl
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
logoProps,
|
|
45
|
+
footerProps
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function useEnvironment() {
|
|
49
|
+
const clerk = useClerk();
|
|
50
|
+
return clerk == null ? void 0 : clerk.__unstable__environment;
|
|
51
|
+
}
|
|
52
|
+
function useDevModeWarning() {
|
|
53
|
+
const { displayConfig, isDevelopmentOrStaging } = useEnvironment();
|
|
54
|
+
const isDevelopment = isDevelopmentOrStaging();
|
|
55
|
+
const { options } = useAppearance().parsedAppearance;
|
|
56
|
+
const unsafeDisabled = (options == null ? void 0 : options.unsafe_disableDevelopmentModeWarnings) || false;
|
|
57
|
+
const developmentUiDisabled = isDevelopment && unsafeDisabled;
|
|
58
|
+
const showDevModeWarning = useMemo(
|
|
59
|
+
() => !developmentUiDisabled && displayConfig.showDevModeWarning,
|
|
60
|
+
[developmentUiDisabled, displayConfig]
|
|
61
|
+
);
|
|
62
|
+
return showDevModeWarning;
|
|
63
|
+
}
|
|
64
|
+
function GlobalError() {
|
|
65
|
+
const { translateError } = useLocalizations();
|
|
66
|
+
return /* @__PURE__ */ jsx(GlobalError$1, { children: ({ message, code }) => {
|
|
67
|
+
return /* @__PURE__ */ jsx(Alert, { children: translateError({ message, code }) });
|
|
68
|
+
} });
|
|
69
|
+
}
|
|
70
|
+
var link = cva({
|
|
71
|
+
base: "cl-dc2a2420",
|
|
72
|
+
variants: {
|
|
73
|
+
busy: {
|
|
74
|
+
false: null,
|
|
75
|
+
true: "cl-5efab14d"
|
|
76
|
+
},
|
|
77
|
+
disabled: {
|
|
78
|
+
false: null,
|
|
79
|
+
true: "cl-d4e2e313"
|
|
80
|
+
},
|
|
81
|
+
// Override native behaviour for third-party packages
|
|
82
|
+
// e.g. react-aria-components
|
|
83
|
+
focusVisible: {
|
|
84
|
+
native: "cl-b13d8727",
|
|
85
|
+
"data-attribute": "cl-e6143e08"
|
|
86
|
+
},
|
|
87
|
+
size: {
|
|
88
|
+
sm: "cl-c74ab393",
|
|
89
|
+
base: "cl-757071a1"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
compoundVariants: [
|
|
93
|
+
{
|
|
94
|
+
busy: false,
|
|
95
|
+
disabled: false,
|
|
96
|
+
className: "cl-b5672060"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
defaultVariants: {
|
|
100
|
+
busy: false,
|
|
101
|
+
disabled: false,
|
|
102
|
+
focusVisible: "native",
|
|
103
|
+
size: "base"
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
var LinkButton = React6.forwardRef(function LinkButton2({
|
|
107
|
+
busy,
|
|
108
|
+
children,
|
|
109
|
+
className,
|
|
110
|
+
disabled,
|
|
111
|
+
size,
|
|
112
|
+
...props
|
|
113
|
+
}, forwardedRef) {
|
|
114
|
+
return (
|
|
115
|
+
// eslint-disable-next-line react/button-has-type
|
|
116
|
+
/* @__PURE__ */ jsx(
|
|
117
|
+
"button",
|
|
118
|
+
{
|
|
119
|
+
ref: forwardedRef,
|
|
120
|
+
"data-link": true,
|
|
121
|
+
className: link({ busy, disabled, size, className }),
|
|
122
|
+
disabled: busy || disabled,
|
|
123
|
+
...props,
|
|
124
|
+
children
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
);
|
|
128
|
+
});
|
|
129
|
+
function CaretRightLegacySm(props) {
|
|
130
|
+
return /* @__PURE__ */ jsx(Icon, { ...props, children: /* @__PURE__ */ jsx(
|
|
131
|
+
"svg",
|
|
132
|
+
{
|
|
133
|
+
viewBox: "0 0 16 16",
|
|
134
|
+
className: "cl-36b12e83",
|
|
135
|
+
children: /* @__PURE__ */ jsx(
|
|
136
|
+
"path",
|
|
137
|
+
{
|
|
138
|
+
d: "M10 8.25L6.5 6V10.5L10 8.25Z",
|
|
139
|
+
fill: "currentColor",
|
|
140
|
+
stroke: "currentColor",
|
|
141
|
+
strokeWidth: "1.5",
|
|
142
|
+
strokeLinecap: "round",
|
|
143
|
+
strokeLinejoin: "round"
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
) });
|
|
148
|
+
}
|
|
149
|
+
var Animated = (props) => {
|
|
150
|
+
const { children, asChild } = props;
|
|
151
|
+
const { animations } = useAppearance().parsedAppearance.options;
|
|
152
|
+
const [parent] = useAutoAnimate();
|
|
153
|
+
const ref = animations !== false ? parent : null;
|
|
154
|
+
if (asChild) {
|
|
155
|
+
return cloneElement(children, { ref });
|
|
156
|
+
}
|
|
157
|
+
return /* @__PURE__ */ jsx("div", { ref, children });
|
|
158
|
+
};
|
|
159
|
+
function CheckmarkCircleSm(props) {
|
|
160
|
+
return /* @__PURE__ */ jsx(Icon, { ...props, children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", children: [
|
|
161
|
+
/* @__PURE__ */ jsx(
|
|
162
|
+
"circle",
|
|
163
|
+
{
|
|
164
|
+
cx: "8",
|
|
165
|
+
cy: "8",
|
|
166
|
+
r: "5.25",
|
|
167
|
+
stroke: "currentColor",
|
|
168
|
+
strokeWidth: "1.5",
|
|
169
|
+
strokeLinecap: "round",
|
|
170
|
+
strokeLinejoin: "round"
|
|
171
|
+
}
|
|
172
|
+
),
|
|
173
|
+
/* @__PURE__ */ jsx(
|
|
174
|
+
"path",
|
|
175
|
+
{
|
|
176
|
+
d: "M6.25 8.35L7.65 9.75L9.75 6.25",
|
|
177
|
+
stroke: "currentColor",
|
|
178
|
+
strokeWidth: "1.5",
|
|
179
|
+
strokeLinecap: "round",
|
|
180
|
+
strokeLinejoin: "round"
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
] }) });
|
|
184
|
+
}
|
|
185
|
+
function InformationCircleSm(props) {
|
|
186
|
+
return /* @__PURE__ */ jsx(Icon, { ...props, children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", children: [
|
|
187
|
+
/* @__PURE__ */ jsx(
|
|
188
|
+
"circle",
|
|
189
|
+
{
|
|
190
|
+
cx: "8",
|
|
191
|
+
cy: "8",
|
|
192
|
+
r: "5.25",
|
|
193
|
+
stroke: "currentColor",
|
|
194
|
+
strokeWidth: "1.5",
|
|
195
|
+
strokeLinecap: "round",
|
|
196
|
+
strokeLinejoin: "round"
|
|
197
|
+
}
|
|
198
|
+
),
|
|
199
|
+
/* @__PURE__ */ jsx(
|
|
200
|
+
"path",
|
|
201
|
+
{
|
|
202
|
+
d: "M8 8.75V10.25",
|
|
203
|
+
stroke: "currentColor",
|
|
204
|
+
strokeWidth: "1.5",
|
|
205
|
+
strokeLinecap: "round",
|
|
206
|
+
strokeLinejoin: "round"
|
|
207
|
+
}
|
|
208
|
+
),
|
|
209
|
+
/* @__PURE__ */ jsx(
|
|
210
|
+
"path",
|
|
211
|
+
{
|
|
212
|
+
d: "M8 6.25024V6.26024",
|
|
213
|
+
stroke: "currentColor",
|
|
214
|
+
strokeWidth: "1.5",
|
|
215
|
+
strokeLinecap: "round",
|
|
216
|
+
strokeLinejoin: "round"
|
|
217
|
+
}
|
|
218
|
+
)
|
|
219
|
+
] }) });
|
|
220
|
+
}
|
|
221
|
+
var Root = React6.forwardRef(function FieldRoot({ children, className, ...props }, forwardedRef) {
|
|
222
|
+
return /* @__PURE__ */ jsx(
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
"data-field-root": "",
|
|
226
|
+
ref: forwardedRef,
|
|
227
|
+
...props,
|
|
228
|
+
className: cx(
|
|
229
|
+
"cl-dcb655e4",
|
|
230
|
+
"cl-03811a40",
|
|
231
|
+
"cl-81d1ec5b",
|
|
232
|
+
"cl-3a46e0d4",
|
|
233
|
+
"cl-4636b1d3",
|
|
234
|
+
"cl-3da4a9c6",
|
|
235
|
+
"cl-7c5144aa",
|
|
236
|
+
className
|
|
237
|
+
),
|
|
238
|
+
children
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
});
|
|
242
|
+
var Label = React6.forwardRef(function FieldLabel({
|
|
243
|
+
className,
|
|
244
|
+
children,
|
|
245
|
+
visuallyHidden,
|
|
246
|
+
...props
|
|
247
|
+
}, forwardedRef) {
|
|
248
|
+
return /* @__PURE__ */ jsx(
|
|
249
|
+
"label",
|
|
250
|
+
{
|
|
251
|
+
"data-field-label": "",
|
|
252
|
+
ref: forwardedRef,
|
|
253
|
+
...props,
|
|
254
|
+
className: cx(
|
|
255
|
+
visuallyHidden ? "cl-32fb0905" : [
|
|
256
|
+
"cl-e0435440",
|
|
257
|
+
"cl-b830f807"
|
|
258
|
+
],
|
|
259
|
+
className
|
|
260
|
+
),
|
|
261
|
+
children
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
});
|
|
265
|
+
var LabelEnd = React6.forwardRef(function FieldLabelEnd({ className, children, ...props }, forwardedRef) {
|
|
266
|
+
return /* @__PURE__ */ jsx(
|
|
267
|
+
"span",
|
|
268
|
+
{
|
|
269
|
+
"data-field-label-end": "",
|
|
270
|
+
ref: forwardedRef,
|
|
271
|
+
...props,
|
|
272
|
+
className: cx("cl-43770a6e", className),
|
|
273
|
+
children
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
});
|
|
277
|
+
var Hint = React6.forwardRef(function FieldHint({ className, children, ...props }, forwardedRef) {
|
|
278
|
+
return /* @__PURE__ */ jsx(
|
|
279
|
+
LabelEnd,
|
|
280
|
+
{
|
|
281
|
+
"data-field-hint": "",
|
|
282
|
+
ref: forwardedRef,
|
|
283
|
+
...props,
|
|
284
|
+
className: cx("cl-275d380b", className),
|
|
285
|
+
children
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
});
|
|
289
|
+
var Checkbox = React6.forwardRef(function FieldCheckbox(props, forwardedRef) {
|
|
290
|
+
return /* @__PURE__ */ jsx(
|
|
291
|
+
"input",
|
|
292
|
+
{
|
|
293
|
+
"data-field-checkbox": "",
|
|
294
|
+
ref: forwardedRef,
|
|
295
|
+
type: "checkbox",
|
|
296
|
+
className: cx("cl-833ca99c"),
|
|
297
|
+
...props
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
});
|
|
301
|
+
var InputGroup = React6.forwardRef(function FieldInputGroup({ className, ...props }, ref) {
|
|
302
|
+
return /* @__PURE__ */ jsx(
|
|
303
|
+
"div",
|
|
304
|
+
{
|
|
305
|
+
"data-field-input-group": "",
|
|
306
|
+
ref,
|
|
307
|
+
className: cx(
|
|
308
|
+
"cl-ddaf1b10",
|
|
309
|
+
"cl-d2d9e1f1",
|
|
310
|
+
className
|
|
311
|
+
),
|
|
312
|
+
...props
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
});
|
|
316
|
+
var InputGroupEnd = React6.forwardRef(function FieldInputGroupEnd({ className, ...props }, ref) {
|
|
317
|
+
return /* @__PURE__ */ jsx(
|
|
318
|
+
"div",
|
|
319
|
+
{
|
|
320
|
+
"data-field-input-group-end": "",
|
|
321
|
+
ref,
|
|
322
|
+
className: cx("cl-4e1b09eb", className),
|
|
323
|
+
...props
|
|
324
|
+
}
|
|
325
|
+
);
|
|
326
|
+
});
|
|
327
|
+
var Input = React6.forwardRef(function FieldInput({
|
|
328
|
+
asChild,
|
|
329
|
+
className,
|
|
330
|
+
intent = "idle",
|
|
331
|
+
state = "native",
|
|
332
|
+
variant = "default",
|
|
333
|
+
...props
|
|
334
|
+
}, forwardedRef) {
|
|
335
|
+
const Comp = asChild ? Slot : "input";
|
|
336
|
+
return /* @__PURE__ */ jsx(
|
|
337
|
+
Comp,
|
|
338
|
+
{
|
|
339
|
+
"data-field-input": "",
|
|
340
|
+
ref: forwardedRef,
|
|
341
|
+
className: cx(
|
|
342
|
+
"cl-43ccb14c",
|
|
343
|
+
"cl-f18c4e82",
|
|
344
|
+
// If an `InputGroup` exists, use the `pe` value, or fallback to the
|
|
345
|
+
// standard input `px` value
|
|
346
|
+
"cl-983f1668",
|
|
347
|
+
"cl-ed751b03",
|
|
348
|
+
"cl-2aeea0c3",
|
|
349
|
+
"cl-d4e2e313",
|
|
350
|
+
"cl-ed4ed5cf",
|
|
351
|
+
// variant
|
|
352
|
+
{
|
|
353
|
+
default: "cl-f6005322",
|
|
354
|
+
"otp-digit": "cl-cb0ccd68"
|
|
355
|
+
}[variant],
|
|
356
|
+
// state
|
|
357
|
+
{
|
|
358
|
+
native: "cl-0290fbc4",
|
|
359
|
+
hover: "cl-8d0f1e66",
|
|
360
|
+
"focus-visible": "cl-e88ce474"
|
|
361
|
+
}[state],
|
|
362
|
+
// intent
|
|
363
|
+
{
|
|
364
|
+
idle: [
|
|
365
|
+
"cl-cac18779",
|
|
366
|
+
"cl-03c582dd"
|
|
367
|
+
],
|
|
368
|
+
info: [
|
|
369
|
+
"cl-fa487ffe",
|
|
370
|
+
"cl-03c582dd"
|
|
371
|
+
],
|
|
372
|
+
error: [
|
|
373
|
+
"cl-cffb481b",
|
|
374
|
+
"cl-776840f6",
|
|
375
|
+
"cl-1e334ea3"
|
|
376
|
+
],
|
|
377
|
+
success: [
|
|
378
|
+
"cl-90c7848a",
|
|
379
|
+
"cl-204cd4cf",
|
|
380
|
+
"cl-0810e01c"
|
|
381
|
+
// (optically adjusted ring to 25 opacity)
|
|
382
|
+
],
|
|
383
|
+
warning: [
|
|
384
|
+
"cl-d250e2b7",
|
|
385
|
+
"cl-8cae7b37",
|
|
386
|
+
"cl-43888e8c"
|
|
387
|
+
]
|
|
388
|
+
}[intent],
|
|
389
|
+
className
|
|
390
|
+
),
|
|
391
|
+
...props
|
|
392
|
+
}
|
|
393
|
+
);
|
|
394
|
+
});
|
|
395
|
+
var Message = React6.forwardRef(function FieldMessage({ className, children, justify = "start", intent = "idle", ...props }, forwardedRef) {
|
|
396
|
+
return /* @__PURE__ */ jsxs(
|
|
397
|
+
"p",
|
|
398
|
+
{
|
|
399
|
+
"data-field-message": "",
|
|
400
|
+
ref: forwardedRef,
|
|
401
|
+
...props,
|
|
402
|
+
className: cx(
|
|
403
|
+
"cl-12c39ca4",
|
|
404
|
+
{
|
|
405
|
+
start: "cl-c62ec162",
|
|
406
|
+
center: "cl-a503dd37",
|
|
407
|
+
end: "cl-307644c3"
|
|
408
|
+
}[justify],
|
|
409
|
+
{
|
|
410
|
+
idle: "cl-de621653",
|
|
411
|
+
info: "cl-de621653",
|
|
412
|
+
error: "cl-e5cd1f02",
|
|
413
|
+
success: "cl-e8e05e0c",
|
|
414
|
+
warning: "cl-d794f084"
|
|
415
|
+
}[intent],
|
|
416
|
+
className
|
|
417
|
+
),
|
|
418
|
+
children: [
|
|
419
|
+
intent !== "idle" && /* @__PURE__ */ jsx("span", { className: "cl-eb8de575", children: {
|
|
420
|
+
error: /* @__PURE__ */ jsx(ExclamationOctagonSm, {}),
|
|
421
|
+
info: /* @__PURE__ */ jsx(InformationCircleSm, {}),
|
|
422
|
+
success: /* @__PURE__ */ jsx(CheckmarkCircleSm, {}),
|
|
423
|
+
warning: /* @__PURE__ */ jsx(ExclamationTriangleSm, {})
|
|
424
|
+
}[intent] }),
|
|
425
|
+
children
|
|
426
|
+
]
|
|
427
|
+
}
|
|
428
|
+
);
|
|
429
|
+
});
|
|
430
|
+
function EyeSlashSm(props) {
|
|
431
|
+
return /* @__PURE__ */ jsx(Icon, { ...props, children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", children: [
|
|
432
|
+
/* @__PURE__ */ jsx(
|
|
433
|
+
"path",
|
|
434
|
+
{
|
|
435
|
+
d: "M2.949 7C2.80739 7.40946 2.75 7.76622 2.75 8C2.75 9 3.8 12.25 8 12.25C8.35547 12.25 8.68838 12.2267 9 12.1835M11.5 11.1743C12.8384 10.134 13.25 8.62607 13.25 8C13.25 7 12.2 3.75 8 3.75C6.7199 3.75 5.73242 4.05191 4.97809 4.5",
|
|
436
|
+
stroke: "currentColor",
|
|
437
|
+
strokeWidth: "1.5",
|
|
438
|
+
strokeLinecap: "round",
|
|
439
|
+
strokeLinejoin: "round"
|
|
440
|
+
}
|
|
441
|
+
),
|
|
442
|
+
/* @__PURE__ */ jsx(
|
|
443
|
+
"path",
|
|
444
|
+
{
|
|
445
|
+
d: "M8.88388 8.88388C9.37204 8.39573 9.37204 7.60427 8.88388 7.11612C8.39573 6.62796 7.60427 6.62796 7.11612 7.11612",
|
|
446
|
+
stroke: "currentColor",
|
|
447
|
+
strokeWidth: "1.5",
|
|
448
|
+
strokeLinecap: "round",
|
|
449
|
+
strokeLinejoin: "round"
|
|
450
|
+
}
|
|
451
|
+
),
|
|
452
|
+
/* @__PURE__ */ jsx(
|
|
453
|
+
"path",
|
|
454
|
+
{
|
|
455
|
+
d: "M3 3L13 13",
|
|
456
|
+
stroke: "currentColor",
|
|
457
|
+
strokeWidth: "1.5",
|
|
458
|
+
strokeLinecap: "round",
|
|
459
|
+
strokeLinejoin: "round"
|
|
460
|
+
}
|
|
461
|
+
)
|
|
462
|
+
] }) });
|
|
463
|
+
}
|
|
464
|
+
function EyeSm(props) {
|
|
465
|
+
return /* @__PURE__ */ jsx(Icon, { ...props, children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", children: [
|
|
466
|
+
/* @__PURE__ */ jsx(
|
|
467
|
+
"path",
|
|
468
|
+
{
|
|
469
|
+
d: "M13.25 8C13.25 9 12.2 12.25 8 12.25C3.8 12.25 2.75 9 2.75 8C2.75 7 3.8 3.75 8 3.75C12.2 3.75 13.25 7 13.25 8Z",
|
|
470
|
+
stroke: "currentColor",
|
|
471
|
+
strokeWidth: "1.5",
|
|
472
|
+
strokeLinecap: "round",
|
|
473
|
+
strokeLinejoin: "round"
|
|
474
|
+
}
|
|
475
|
+
),
|
|
476
|
+
/* @__PURE__ */ jsx(
|
|
477
|
+
"circle",
|
|
478
|
+
{
|
|
479
|
+
cx: "8",
|
|
480
|
+
cy: "8",
|
|
481
|
+
r: "1.25",
|
|
482
|
+
stroke: "currentColor",
|
|
483
|
+
strokeWidth: "1.5",
|
|
484
|
+
strokeLinecap: "round",
|
|
485
|
+
strokeLinejoin: "round"
|
|
486
|
+
}
|
|
487
|
+
)
|
|
488
|
+
] }) });
|
|
489
|
+
}
|
|
490
|
+
var PasswordField = React6__default.forwardRef(function PasswordField2({
|
|
491
|
+
alternativeFieldTrigger,
|
|
492
|
+
className,
|
|
493
|
+
fieldClassName,
|
|
494
|
+
fieldRef,
|
|
495
|
+
label,
|
|
496
|
+
name = "password",
|
|
497
|
+
...props
|
|
498
|
+
}, forwardedRef) {
|
|
499
|
+
const [type, setType] = React6__default.useState("password");
|
|
500
|
+
const id = React6__default.useId();
|
|
501
|
+
const { t, locale } = useLocalizations();
|
|
502
|
+
return /* @__PURE__ */ jsx(
|
|
503
|
+
Common.Field,
|
|
504
|
+
{
|
|
505
|
+
name,
|
|
506
|
+
asChild: true,
|
|
507
|
+
children: /* @__PURE__ */ jsxs(
|
|
508
|
+
Root,
|
|
509
|
+
{
|
|
510
|
+
className: fieldClassName,
|
|
511
|
+
ref: fieldRef,
|
|
512
|
+
children: [
|
|
513
|
+
/* @__PURE__ */ jsx(Common.Label, { asChild: true, children: /* @__PURE__ */ jsxs(Label, { children: [
|
|
514
|
+
label,
|
|
515
|
+
alternativeFieldTrigger ? /* @__PURE__ */ jsx(LabelEnd, { children: alternativeFieldTrigger }) : null
|
|
516
|
+
] }) }),
|
|
517
|
+
/* @__PURE__ */ jsx(Common.FieldState, { children: ({ state }) => {
|
|
518
|
+
return /* @__PURE__ */ jsxs(InputGroup, { children: [
|
|
519
|
+
/* @__PURE__ */ jsx(
|
|
520
|
+
Common.Input,
|
|
521
|
+
{
|
|
522
|
+
type,
|
|
523
|
+
className: cx("cl-ba16e610", className),
|
|
524
|
+
...props,
|
|
525
|
+
ref: forwardedRef,
|
|
526
|
+
"aria-describedby": props.validatePassword && state !== "idle" ? id : void 0,
|
|
527
|
+
asChild: true,
|
|
528
|
+
children: /* @__PURE__ */ jsx(Input, { intent: state })
|
|
529
|
+
}
|
|
530
|
+
),
|
|
531
|
+
/* @__PURE__ */ jsx(InputGroupEnd, { children: /* @__PURE__ */ jsxs(
|
|
532
|
+
"button",
|
|
533
|
+
{
|
|
534
|
+
type: "button",
|
|
535
|
+
className: cx(
|
|
536
|
+
// Note:
|
|
537
|
+
// We set to `1.375rem` (22px) here for a hairline border
|
|
538
|
+
// around the focus ring to keep it distinct from the
|
|
539
|
+
// "surrounding" input
|
|
540
|
+
"cl-f739d7d3",
|
|
541
|
+
"cl-35c8e0b5",
|
|
542
|
+
"cl-c93b25fd"
|
|
543
|
+
),
|
|
544
|
+
onClick: () => setType((prev) => prev === "password" ? "text" : "password"),
|
|
545
|
+
title: [type === "password" ? "Show" : "Hide", "password"].join(" "),
|
|
546
|
+
disabled: props.disabled,
|
|
547
|
+
children: [
|
|
548
|
+
/* @__PURE__ */ jsx("span", { className: "cl-32fb0905", children: [type === "password" ? "Show" : "Hide", "password"].join(" ") }),
|
|
549
|
+
type === "password" ? /* @__PURE__ */ jsx(EyeSlashSm, {}) : /* @__PURE__ */ jsx(EyeSm, {})
|
|
550
|
+
]
|
|
551
|
+
}
|
|
552
|
+
) })
|
|
553
|
+
] });
|
|
554
|
+
} }),
|
|
555
|
+
/* @__PURE__ */ jsx(Animated, { children: props.validatePassword ? /* @__PURE__ */ jsx(Common.FieldState, { children: ({ state, codes }) => {
|
|
556
|
+
if (state === "idle") {
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
if (state === "success") {
|
|
560
|
+
return /* @__PURE__ */ jsx(
|
|
561
|
+
Message,
|
|
562
|
+
{
|
|
563
|
+
id,
|
|
564
|
+
intent: "success",
|
|
565
|
+
children: t("unstable__errors.zxcvbn.goodPassword")
|
|
566
|
+
}
|
|
567
|
+
);
|
|
568
|
+
}
|
|
569
|
+
if (typeof codes === "undefined") {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
return /* @__PURE__ */ jsx(
|
|
573
|
+
Message,
|
|
574
|
+
{
|
|
575
|
+
id,
|
|
576
|
+
intent: state,
|
|
577
|
+
children: translatePasswordError({ codes, locale, t })
|
|
578
|
+
}
|
|
579
|
+
);
|
|
580
|
+
} }) : /* @__PURE__ */ jsx(Common.FieldError, { asChild: true, children: ({ message }) => {
|
|
581
|
+
return /* @__PURE__ */ jsx(Message, { intent: "error", children: message });
|
|
582
|
+
} }) })
|
|
583
|
+
]
|
|
584
|
+
}
|
|
585
|
+
)
|
|
586
|
+
}
|
|
587
|
+
);
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
// src/hooks/use-attributes.ts
|
|
591
|
+
function useAttributes(attribute) {
|
|
592
|
+
const environment = useEnvironment();
|
|
593
|
+
const userSettingsAttributes = environment.userSettings.attributes;
|
|
594
|
+
return userSettingsAttributes[attribute];
|
|
595
|
+
}
|
|
596
|
+
function useSignUpAttributes(attribute) {
|
|
597
|
+
const attr = useAttributes(attribute);
|
|
598
|
+
const { options } = useAppearance().parsedAppearance;
|
|
599
|
+
const { showOptionalFields } = options;
|
|
600
|
+
return {
|
|
601
|
+
...attr,
|
|
602
|
+
show: (showOptionalFields || attr.required) && attr.enabled
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
var DEFAULT_FIELD_NAME = "emailAddress";
|
|
606
|
+
var EmailField = React6__default.forwardRef(function EmailField2({
|
|
607
|
+
alternativeFieldTrigger,
|
|
608
|
+
name = DEFAULT_FIELD_NAME,
|
|
609
|
+
enabled,
|
|
610
|
+
required,
|
|
611
|
+
...props
|
|
612
|
+
}, forwardedRef) {
|
|
613
|
+
const { t, translateError } = useLocalizations();
|
|
614
|
+
const { enabled: attributeEnabled, required: attributeRequired } = useAttributes("email_address");
|
|
615
|
+
const isEnabled = enabled !== void 0 ? enabled : attributeEnabled;
|
|
616
|
+
const isRequired = required !== void 0 ? required : attributeRequired;
|
|
617
|
+
if (!isEnabled) {
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
return /* @__PURE__ */ jsx(
|
|
621
|
+
Common.Field,
|
|
622
|
+
{
|
|
623
|
+
name,
|
|
624
|
+
asChild: true,
|
|
625
|
+
children: /* @__PURE__ */ jsxs(Root, { children: [
|
|
626
|
+
/* @__PURE__ */ jsx(Common.Label, { asChild: true, children: /* @__PURE__ */ jsxs(Label, { children: [
|
|
627
|
+
t("formFieldLabel__emailAddress"),
|
|
628
|
+
alternativeFieldTrigger ? /* @__PURE__ */ jsx(LabelEnd, { children: alternativeFieldTrigger }) : !isRequired ? /* @__PURE__ */ jsx(Hint, { children: t("formFieldHintText__optional") }) : null
|
|
629
|
+
] }) }),
|
|
630
|
+
/* @__PURE__ */ jsx(Common.FieldState, { children: ({ state }) => {
|
|
631
|
+
return /* @__PURE__ */ jsx(
|
|
632
|
+
Common.Input,
|
|
633
|
+
{
|
|
634
|
+
ref: forwardedRef,
|
|
635
|
+
type: "email",
|
|
636
|
+
...props,
|
|
637
|
+
required: isRequired,
|
|
638
|
+
asChild: true,
|
|
639
|
+
children: /* @__PURE__ */ jsx(Input, { intent: state })
|
|
640
|
+
}
|
|
641
|
+
);
|
|
642
|
+
} }),
|
|
643
|
+
/* @__PURE__ */ jsx(Animated, { children: /* @__PURE__ */ jsx(Common.FieldError, { asChild: true, children: ({ message, code }) => {
|
|
644
|
+
return /* @__PURE__ */ jsx(Message, { intent: "error", children: translateError({ message, code, name: "email_address" }) });
|
|
645
|
+
} }) })
|
|
646
|
+
] })
|
|
647
|
+
}
|
|
648
|
+
);
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
// src/constants/phone-number.ts
|
|
652
|
+
var data = [
|
|
653
|
+
["United States", "us", "1", "(...) ...-....", 100],
|
|
654
|
+
["United Kingdom", "gb", "44", ".... ......", 100],
|
|
655
|
+
["India", "in", "91", ".....-.....", 100],
|
|
656
|
+
["Canada", "ca", "1", "(...) ...-....", 100],
|
|
657
|
+
["Germany", "de", "49", "... .......", 100],
|
|
658
|
+
["France", "fr", "33", ". .. .. .. ..", 100],
|
|
659
|
+
["Russia", "ru", "7", "... ...-..-..", 100],
|
|
660
|
+
["Afghanistan", "af", "93"],
|
|
661
|
+
["Albania", "al", "355"],
|
|
662
|
+
["Algeria ", "dz", "213"],
|
|
663
|
+
["American Samoa", "as", "1684"],
|
|
664
|
+
["Andorra", "ad", "376"],
|
|
665
|
+
["Angola", "ao", "244"],
|
|
666
|
+
["Anguilla", "ai", "1264"],
|
|
667
|
+
["Antigua and Barbuda", "ag", "1268"],
|
|
668
|
+
["Argentina", "ar", "54"],
|
|
669
|
+
["Armenia", "am", "374"],
|
|
670
|
+
["Aruba", "aw", "297"],
|
|
671
|
+
["Australia", "au", "61", "... ... ..."],
|
|
672
|
+
["Austria", "at", "43"],
|
|
673
|
+
["Azerbaijan", "az", "994"],
|
|
674
|
+
["Bahamas", "bs", "1242"],
|
|
675
|
+
["Bahrain", "bh", "973"],
|
|
676
|
+
["Bangladesh", "bd", "880"],
|
|
677
|
+
["Barbados", "bb", "1246"],
|
|
678
|
+
["Belarus", "by", "375"],
|
|
679
|
+
["Belgium", "be", "32", "... .. .. .."],
|
|
680
|
+
["Belize", "bz", "501"],
|
|
681
|
+
["Benin", "bj", "229"],
|
|
682
|
+
["Bermuda", "bm", "1441"],
|
|
683
|
+
["Bhutan", "bt", "975"],
|
|
684
|
+
["Bolivia", "bo", "591"],
|
|
685
|
+
["Bosnia and Herzegovina", "ba", "387"],
|
|
686
|
+
["Botswana", "bw", "267"],
|
|
687
|
+
["Brazil", "br", "55"],
|
|
688
|
+
["British Indian Ocean Territory", "io", "246"],
|
|
689
|
+
["British Virgin Islands", "vg", "1284"],
|
|
690
|
+
["Brunei", "bn", "673"],
|
|
691
|
+
["Bulgaria", "bg", "359"],
|
|
692
|
+
["Burkina Faso", "bf", "226"],
|
|
693
|
+
["Burundi", "bi", "257"],
|
|
694
|
+
["Cambodia", "kh", "855"],
|
|
695
|
+
["Cameroon", "cm", "237"],
|
|
696
|
+
["Cape Verde", "cv", "238"],
|
|
697
|
+
["Caribbean Netherlands", "bq", "599"],
|
|
698
|
+
["Cayman Islands", "ky", "1345"],
|
|
699
|
+
["Central African Republic", "cf", "236"],
|
|
700
|
+
["Chad", "td", "235"],
|
|
701
|
+
["Chile", "cl", "56"],
|
|
702
|
+
["China", "cn", "86", "...-....-...."],
|
|
703
|
+
["Colombia", "co", "57"],
|
|
704
|
+
["Comoros", "km", "269"],
|
|
705
|
+
["Congo", "cd", "243"],
|
|
706
|
+
["Congo", "cg", "242"],
|
|
707
|
+
["Cook Islands", "ck", "682"],
|
|
708
|
+
["Costa Rica", "cr", "506", "....-...."],
|
|
709
|
+
["C\xF4te d\u2019Ivoire", "ci", "225"],
|
|
710
|
+
["Croatia", "hr", "385"],
|
|
711
|
+
["Cuba", "cu", "53"],
|
|
712
|
+
["Cura\xE7ao", "cw", "599"],
|
|
713
|
+
["Cyprus", "cy", "357"],
|
|
714
|
+
["Czech Republic", "cz", "420"],
|
|
715
|
+
["Denmark", "dk", "45", ".. .. .. .."],
|
|
716
|
+
["Djibouti", "dj", "253"],
|
|
717
|
+
["Dominica", "dm", "1767"],
|
|
718
|
+
["Dominican Republic", "do", "1"],
|
|
719
|
+
["Ecuador", "ec", "593"],
|
|
720
|
+
["Egypt", "eg", "20"],
|
|
721
|
+
["El Salvador", "sv", "503", "....-...."],
|
|
722
|
+
["Equatorial Guinea", "gq", "240"],
|
|
723
|
+
["Eritrea", "er", "291"],
|
|
724
|
+
["Estonia", "ee", "372"],
|
|
725
|
+
["Ethiopia", "et", "251"],
|
|
726
|
+
["Falkland Islands", "fk", "500"],
|
|
727
|
+
["Faroe Islands", "fo", "298"],
|
|
728
|
+
["Fiji", "fj", "679"],
|
|
729
|
+
["Finland", "fi", "358", ".. ... .. .."],
|
|
730
|
+
["French Guiana", "gf", "594"],
|
|
731
|
+
["French Polynesia", "pf", "689"],
|
|
732
|
+
["Gabon", "ga", "241"],
|
|
733
|
+
["Gambia", "gm", "220"],
|
|
734
|
+
["Georgia", "ge", "995"],
|
|
735
|
+
["Ghana", "gh", "233"],
|
|
736
|
+
["Gibraltar", "gi", "350"],
|
|
737
|
+
["Greece", "gr", "30", "... ......."],
|
|
738
|
+
["Greenland", "gl", "299"],
|
|
739
|
+
["Grenada", "gd", "1473"],
|
|
740
|
+
["Guadeloupe", "gp", "590"],
|
|
741
|
+
["Guam", "gu", "1671"],
|
|
742
|
+
["Guatemala", "gt", "502", "....-...."],
|
|
743
|
+
["Guinea", "gn", "224"],
|
|
744
|
+
["Guinea-Bissau", "gw", "245"],
|
|
745
|
+
["Guyana", "gy", "592"],
|
|
746
|
+
["Haiti", "ht", "509", "....-...."],
|
|
747
|
+
["Honduras", "hn", "504"],
|
|
748
|
+
["Hong Kong", "hk", "852", ".... ...."],
|
|
749
|
+
["Hungary", "hu", "36"],
|
|
750
|
+
["Iceland", "is", "354", "... ...."],
|
|
751
|
+
["Indonesia", "id", "62"],
|
|
752
|
+
["Iran", "ir", "98"],
|
|
753
|
+
["Iraq", "iq", "964"],
|
|
754
|
+
["Ireland", "ie", "353", ".. ......."],
|
|
755
|
+
["Israel", "il", "972"],
|
|
756
|
+
["Italy", "it", "39", "... ......"],
|
|
757
|
+
["Jamaica", "jm", "1876"],
|
|
758
|
+
["Japan", "jp", "81", "... .. ...."],
|
|
759
|
+
["Jordan", "jo", "962"],
|
|
760
|
+
["Kazakhstan", "kz", "7", "... ...-..-.."],
|
|
761
|
+
["Kenya", "ke", "254"],
|
|
762
|
+
["Kiribati", "ki", "686"],
|
|
763
|
+
["Kuwait", "kw", "965"],
|
|
764
|
+
["Kyrgyzstan", "kg", "996"],
|
|
765
|
+
["Laos", "la", "856"],
|
|
766
|
+
["Latvia", "lv", "371"],
|
|
767
|
+
["Lebanon", "lb", "961"],
|
|
768
|
+
["Lesotho", "ls", "266"],
|
|
769
|
+
["Liberia", "lr", "231"],
|
|
770
|
+
["Libya", "ly", "218"],
|
|
771
|
+
["Liechtenstein", "li", "423"],
|
|
772
|
+
["Lithuania", "lt", "370"],
|
|
773
|
+
["Luxembourg", "lu", "352"],
|
|
774
|
+
["Macau", "mo", "853"],
|
|
775
|
+
["Macedonia", "mk", "389"],
|
|
776
|
+
["Madagascar", "mg", "261"],
|
|
777
|
+
["Malawi", "mw", "265"],
|
|
778
|
+
["Malaysia", "my", "60", "..-....-...."],
|
|
779
|
+
["Maldives", "mv", "960"],
|
|
780
|
+
["Mali", "ml", "223"],
|
|
781
|
+
["Malta", "mt", "356"],
|
|
782
|
+
["Marshall Islands", "mh", "692"],
|
|
783
|
+
["Martinique", "mq", "596"],
|
|
784
|
+
["Mauritania", "mr", "222"],
|
|
785
|
+
["Mauritius", "mu", "230"],
|
|
786
|
+
["Mexico", "mx", "52"],
|
|
787
|
+
["Micronesia", "fm", "691"],
|
|
788
|
+
["Moldova", "md", "373"],
|
|
789
|
+
["Monaco", "mc", "377"],
|
|
790
|
+
["Mongolia", "mn", "976"],
|
|
791
|
+
["Montenegro", "me", "382"],
|
|
792
|
+
["Montserrat", "ms", "1664"],
|
|
793
|
+
["Morocco", "ma", "212"],
|
|
794
|
+
["Mozambique", "mz", "258"],
|
|
795
|
+
["Myanmar", "mm", "95"],
|
|
796
|
+
["Namibia", "na", "264"],
|
|
797
|
+
["Nauru", "nr", "674"],
|
|
798
|
+
["Nepal", "np", "977"],
|
|
799
|
+
["Netherlands", "nl", "31", ".. ........"],
|
|
800
|
+
["New Caledonia", "nc", "687"],
|
|
801
|
+
["New Zealand", "nz", "64", "...-...-...."],
|
|
802
|
+
["Nicaragua", "ni", "505"],
|
|
803
|
+
["Niger", "ne", "227"],
|
|
804
|
+
["Nigeria", "ng", "234"],
|
|
805
|
+
["Niue", "nu", "683"],
|
|
806
|
+
["Norfolk Island", "nf", "672"],
|
|
807
|
+
["North Korea", "kp", "850"],
|
|
808
|
+
["Northern Mariana Islands", "mp", "1670"],
|
|
809
|
+
["Norway", "no", "47", "... .. ..."],
|
|
810
|
+
["Oman", "om", "968"],
|
|
811
|
+
["Pakistan", "pk", "92", "...-......."],
|
|
812
|
+
["Palau", "pw", "680"],
|
|
813
|
+
["Palestine", "ps", "970"],
|
|
814
|
+
["Panama", "pa", "507"],
|
|
815
|
+
["Papua New Guinea", "pg", "675"],
|
|
816
|
+
["Paraguay", "py", "595"],
|
|
817
|
+
["Peru", "pe", "51"],
|
|
818
|
+
["Philippines", "ph", "63", "... ...."],
|
|
819
|
+
["Poland", "pl", "48", "...-...-..."],
|
|
820
|
+
["Portugal", "pt", "351"],
|
|
821
|
+
["Puerto Rico", "pr", "1"],
|
|
822
|
+
["Qatar", "qa", "974"],
|
|
823
|
+
["R\xE9union", "re", "262"],
|
|
824
|
+
["Romania", "ro", "40"],
|
|
825
|
+
["Rwanda", "rw", "250"],
|
|
826
|
+
["Saint Barth\xE9lemy", "bl", "590"],
|
|
827
|
+
["Saint Helena", "sh", "290"],
|
|
828
|
+
["Saint Kitts and Nevis", "kn", "1869"],
|
|
829
|
+
["Saint Lucia", "lc", "1758"],
|
|
830
|
+
["Saint Martin", "mf", "590"],
|
|
831
|
+
["Saint Pierre and Miquelon", "pm", "508"],
|
|
832
|
+
["Saint Vincent and the Grenadines", "vc", "1784"],
|
|
833
|
+
["Samoa", "ws", "685"],
|
|
834
|
+
["San Marino", "sm", "378"],
|
|
835
|
+
["S\xE3o Tom\xE9 and Pr\xEDncipe", "st", "239"],
|
|
836
|
+
["Saudi Arabia", "sa", "966"],
|
|
837
|
+
["Senegal", "sn", "221"],
|
|
838
|
+
["Serbia", "rs", "381"],
|
|
839
|
+
["Seychelles", "sc", "248"],
|
|
840
|
+
["Sierra Leone", "sl", "232"],
|
|
841
|
+
["Singapore", "sg", "65", "....-...."],
|
|
842
|
+
["Sint Maarten", "sx", "1721"],
|
|
843
|
+
["Slovakia", "sk", "421"],
|
|
844
|
+
["Slovenia", "si", "386"],
|
|
845
|
+
["Solomon Islands", "sb", "677"],
|
|
846
|
+
["Somalia", "so", "252"],
|
|
847
|
+
["South Africa", "za", "27"],
|
|
848
|
+
["South Korea", "kr", "82"],
|
|
849
|
+
["South Sudan", "ss", "211"],
|
|
850
|
+
["Spain", "es", "34", "... ... ..."],
|
|
851
|
+
["Sri Lanka", "lk", "94"],
|
|
852
|
+
["Sudan", "sd", "249"],
|
|
853
|
+
["Suriname", "sr", "597"],
|
|
854
|
+
["Swaziland", "sz", "268"],
|
|
855
|
+
["Sweden", "se", "46", ".. ... .. .."],
|
|
856
|
+
["Switzerland", "ch", "41", ".. ... .. .."],
|
|
857
|
+
["Syria", "sy", "963"],
|
|
858
|
+
["Taiwan", "tw", "886"],
|
|
859
|
+
["Tajikistan", "tj", "992"],
|
|
860
|
+
["Tanzania", "tz", "255"],
|
|
861
|
+
["Thailand", "th", "66"],
|
|
862
|
+
["Timor-Leste", "tl", "670"],
|
|
863
|
+
["Togo", "tg", "228"],
|
|
864
|
+
["Tokelau", "tk", "690"],
|
|
865
|
+
["Tonga", "to", "676"],
|
|
866
|
+
["Trinidad and Tobago", "tt", "1868"],
|
|
867
|
+
["Tunisia", "tn", "216"],
|
|
868
|
+
["Turkey", "tr", "90", "... ... .. .."],
|
|
869
|
+
["Turkmenistan", "tm", "993"],
|
|
870
|
+
["Turks and Caicos Islands", "tc", "1649"],
|
|
871
|
+
["Tuvalu", "tv", "688"],
|
|
872
|
+
["U.S. Virgin Islands", "vi", "1340"],
|
|
873
|
+
["Uganda", "ug", "256"],
|
|
874
|
+
["Ukraine", "ua", "380"],
|
|
875
|
+
["United Arab Emirates", "ae", "971"],
|
|
876
|
+
["Uruguay", "uy", "598"],
|
|
877
|
+
["Uzbekistan", "uz", "998"],
|
|
878
|
+
["Vanuatu", "vu", "678"],
|
|
879
|
+
["Vatican City", "va", "39", ".. .... ...."],
|
|
880
|
+
["Venezuela", "ve", "58"],
|
|
881
|
+
["Vietnam", "vn", "84"],
|
|
882
|
+
["Wallis and Futuna", "wf", "681"],
|
|
883
|
+
["Yemen", "ye", "967"],
|
|
884
|
+
["Zambia", "zm", "260"],
|
|
885
|
+
["Zimbabwe", "zw", "263"]
|
|
886
|
+
];
|
|
887
|
+
var UnitedStatesSubAreasSet = /* @__PURE__ */ new Set([
|
|
888
|
+
"907",
|
|
889
|
+
"205",
|
|
890
|
+
"251",
|
|
891
|
+
"256",
|
|
892
|
+
"334",
|
|
893
|
+
"479",
|
|
894
|
+
"501",
|
|
895
|
+
"870",
|
|
896
|
+
"480",
|
|
897
|
+
"520",
|
|
898
|
+
"602",
|
|
899
|
+
"623",
|
|
900
|
+
"928",
|
|
901
|
+
"209",
|
|
902
|
+
"213",
|
|
903
|
+
"310",
|
|
904
|
+
"323",
|
|
905
|
+
"408",
|
|
906
|
+
"415",
|
|
907
|
+
"510",
|
|
908
|
+
"530",
|
|
909
|
+
"559",
|
|
910
|
+
"562",
|
|
911
|
+
"619",
|
|
912
|
+
"626",
|
|
913
|
+
"650",
|
|
914
|
+
"661",
|
|
915
|
+
"707",
|
|
916
|
+
"714",
|
|
917
|
+
"760",
|
|
918
|
+
"805",
|
|
919
|
+
"818",
|
|
920
|
+
"831",
|
|
921
|
+
"858",
|
|
922
|
+
"909",
|
|
923
|
+
"916",
|
|
924
|
+
"925",
|
|
925
|
+
"949",
|
|
926
|
+
"951",
|
|
927
|
+
"303",
|
|
928
|
+
"719",
|
|
929
|
+
"970",
|
|
930
|
+
"203",
|
|
931
|
+
"860",
|
|
932
|
+
"202",
|
|
933
|
+
"302",
|
|
934
|
+
"239",
|
|
935
|
+
"305",
|
|
936
|
+
"321",
|
|
937
|
+
"352",
|
|
938
|
+
"386",
|
|
939
|
+
"407",
|
|
940
|
+
"561",
|
|
941
|
+
"727",
|
|
942
|
+
"772",
|
|
943
|
+
"813",
|
|
944
|
+
"850",
|
|
945
|
+
"863",
|
|
946
|
+
"904",
|
|
947
|
+
"941",
|
|
948
|
+
"954",
|
|
949
|
+
"229",
|
|
950
|
+
"404",
|
|
951
|
+
"478",
|
|
952
|
+
"706",
|
|
953
|
+
"770",
|
|
954
|
+
"912",
|
|
955
|
+
"808",
|
|
956
|
+
"319",
|
|
957
|
+
"515",
|
|
958
|
+
"563",
|
|
959
|
+
"641",
|
|
960
|
+
"712",
|
|
961
|
+
"208",
|
|
962
|
+
"217",
|
|
963
|
+
"309",
|
|
964
|
+
"312",
|
|
965
|
+
"618",
|
|
966
|
+
"630",
|
|
967
|
+
"708",
|
|
968
|
+
"773",
|
|
969
|
+
"815",
|
|
970
|
+
"847",
|
|
971
|
+
"219",
|
|
972
|
+
"260",
|
|
973
|
+
"317",
|
|
974
|
+
"574",
|
|
975
|
+
"765",
|
|
976
|
+
"812",
|
|
977
|
+
"316",
|
|
978
|
+
"620",
|
|
979
|
+
"785",
|
|
980
|
+
"913",
|
|
981
|
+
"270",
|
|
982
|
+
"502",
|
|
983
|
+
"606",
|
|
984
|
+
"859",
|
|
985
|
+
"225",
|
|
986
|
+
"318",
|
|
987
|
+
"337",
|
|
988
|
+
"504",
|
|
989
|
+
"985",
|
|
990
|
+
"413",
|
|
991
|
+
"508",
|
|
992
|
+
"617",
|
|
993
|
+
"781",
|
|
994
|
+
"978",
|
|
995
|
+
"301",
|
|
996
|
+
"410",
|
|
997
|
+
"207",
|
|
998
|
+
"231",
|
|
999
|
+
"248",
|
|
1000
|
+
"269",
|
|
1001
|
+
"313",
|
|
1002
|
+
"517",
|
|
1003
|
+
"586",
|
|
1004
|
+
"616",
|
|
1005
|
+
"734",
|
|
1006
|
+
"810",
|
|
1007
|
+
"906",
|
|
1008
|
+
"989",
|
|
1009
|
+
"218",
|
|
1010
|
+
"320",
|
|
1011
|
+
"507",
|
|
1012
|
+
"612",
|
|
1013
|
+
"651",
|
|
1014
|
+
"763",
|
|
1015
|
+
"952",
|
|
1016
|
+
"314",
|
|
1017
|
+
"417",
|
|
1018
|
+
"573",
|
|
1019
|
+
"636",
|
|
1020
|
+
"660",
|
|
1021
|
+
"816",
|
|
1022
|
+
"228",
|
|
1023
|
+
"601",
|
|
1024
|
+
"662",
|
|
1025
|
+
"406",
|
|
1026
|
+
"252",
|
|
1027
|
+
"336",
|
|
1028
|
+
"704",
|
|
1029
|
+
"828",
|
|
1030
|
+
"910",
|
|
1031
|
+
"919",
|
|
1032
|
+
"701",
|
|
1033
|
+
"308",
|
|
1034
|
+
"402",
|
|
1035
|
+
"603",
|
|
1036
|
+
"201",
|
|
1037
|
+
"609",
|
|
1038
|
+
"732",
|
|
1039
|
+
"856",
|
|
1040
|
+
"908",
|
|
1041
|
+
"973",
|
|
1042
|
+
"505",
|
|
1043
|
+
"575",
|
|
1044
|
+
"702",
|
|
1045
|
+
"775",
|
|
1046
|
+
"212",
|
|
1047
|
+
"315",
|
|
1048
|
+
"516",
|
|
1049
|
+
"518",
|
|
1050
|
+
"585",
|
|
1051
|
+
"607",
|
|
1052
|
+
"631",
|
|
1053
|
+
"716",
|
|
1054
|
+
"718",
|
|
1055
|
+
"845",
|
|
1056
|
+
"914",
|
|
1057
|
+
"216",
|
|
1058
|
+
"330",
|
|
1059
|
+
"419",
|
|
1060
|
+
"440",
|
|
1061
|
+
"513",
|
|
1062
|
+
"614",
|
|
1063
|
+
"740",
|
|
1064
|
+
"937",
|
|
1065
|
+
"405",
|
|
1066
|
+
"580",
|
|
1067
|
+
"918",
|
|
1068
|
+
"503",
|
|
1069
|
+
"541",
|
|
1070
|
+
"215",
|
|
1071
|
+
"412",
|
|
1072
|
+
"570",
|
|
1073
|
+
"610",
|
|
1074
|
+
"717",
|
|
1075
|
+
"724",
|
|
1076
|
+
"814",
|
|
1077
|
+
"401",
|
|
1078
|
+
"803",
|
|
1079
|
+
"843",
|
|
1080
|
+
"864",
|
|
1081
|
+
"605",
|
|
1082
|
+
"423",
|
|
1083
|
+
"615",
|
|
1084
|
+
"731",
|
|
1085
|
+
"865",
|
|
1086
|
+
"901",
|
|
1087
|
+
"931",
|
|
1088
|
+
"210",
|
|
1089
|
+
"214",
|
|
1090
|
+
"254",
|
|
1091
|
+
"281",
|
|
1092
|
+
"325",
|
|
1093
|
+
"361",
|
|
1094
|
+
"409",
|
|
1095
|
+
"432",
|
|
1096
|
+
"512",
|
|
1097
|
+
"713",
|
|
1098
|
+
"806",
|
|
1099
|
+
"817",
|
|
1100
|
+
"830",
|
|
1101
|
+
"903",
|
|
1102
|
+
"915",
|
|
1103
|
+
"936",
|
|
1104
|
+
"940",
|
|
1105
|
+
"956",
|
|
1106
|
+
"972",
|
|
1107
|
+
"979",
|
|
1108
|
+
"435",
|
|
1109
|
+
"801",
|
|
1110
|
+
"276",
|
|
1111
|
+
"434",
|
|
1112
|
+
"540",
|
|
1113
|
+
"703",
|
|
1114
|
+
"757",
|
|
1115
|
+
"804",
|
|
1116
|
+
"802",
|
|
1117
|
+
"206",
|
|
1118
|
+
"253",
|
|
1119
|
+
"360",
|
|
1120
|
+
"425",
|
|
1121
|
+
"509",
|
|
1122
|
+
"262",
|
|
1123
|
+
"414",
|
|
1124
|
+
"608",
|
|
1125
|
+
"715",
|
|
1126
|
+
"920",
|
|
1127
|
+
"304",
|
|
1128
|
+
"307"
|
|
1129
|
+
]);
|
|
1130
|
+
var CanadaSubAreaSet = /* @__PURE__ */ new Set([
|
|
1131
|
+
"204",
|
|
1132
|
+
"226",
|
|
1133
|
+
"236",
|
|
1134
|
+
"249",
|
|
1135
|
+
"250",
|
|
1136
|
+
"289",
|
|
1137
|
+
"306",
|
|
1138
|
+
"343",
|
|
1139
|
+
"365",
|
|
1140
|
+
"387",
|
|
1141
|
+
"403",
|
|
1142
|
+
"416",
|
|
1143
|
+
"418",
|
|
1144
|
+
"431",
|
|
1145
|
+
"437",
|
|
1146
|
+
"438",
|
|
1147
|
+
"450",
|
|
1148
|
+
"506",
|
|
1149
|
+
"514",
|
|
1150
|
+
"519",
|
|
1151
|
+
"548",
|
|
1152
|
+
"579",
|
|
1153
|
+
"581",
|
|
1154
|
+
"587",
|
|
1155
|
+
"604",
|
|
1156
|
+
"613",
|
|
1157
|
+
"639",
|
|
1158
|
+
"647",
|
|
1159
|
+
"672",
|
|
1160
|
+
"705",
|
|
1161
|
+
"709",
|
|
1162
|
+
"742",
|
|
1163
|
+
"778",
|
|
1164
|
+
"780",
|
|
1165
|
+
"782",
|
|
1166
|
+
"807",
|
|
1167
|
+
"819",
|
|
1168
|
+
"825",
|
|
1169
|
+
"867",
|
|
1170
|
+
"873",
|
|
1171
|
+
"902",
|
|
1172
|
+
"905"
|
|
1173
|
+
]);
|
|
1174
|
+
var SubAreaCodeSets = {
|
|
1175
|
+
us: UnitedStatesSubAreasSet,
|
|
1176
|
+
ca: CanadaSubAreaSet
|
|
1177
|
+
};
|
|
1178
|
+
var createEntry = ([
|
|
1179
|
+
name,
|
|
1180
|
+
iso,
|
|
1181
|
+
code,
|
|
1182
|
+
pattern = "",
|
|
1183
|
+
priority = 0
|
|
1184
|
+
]) => ({
|
|
1185
|
+
name,
|
|
1186
|
+
iso,
|
|
1187
|
+
code,
|
|
1188
|
+
pattern,
|
|
1189
|
+
priority
|
|
1190
|
+
});
|
|
1191
|
+
var IsoToCountryMap = data.reduce(
|
|
1192
|
+
(acc, cur) => acc.set(cur[1], createEntry(cur)),
|
|
1193
|
+
/* @__PURE__ */ new Map()
|
|
1194
|
+
);
|
|
1195
|
+
var CodeToCountriesMap = data.reduce((acc, cur) => {
|
|
1196
|
+
const code = cur[2];
|
|
1197
|
+
const country = createEntry(cur);
|
|
1198
|
+
acc.get(code) ? acc.get(code).push(country) : acc.set(code, [country]);
|
|
1199
|
+
return acc;
|
|
1200
|
+
}, /* @__PURE__ */ new Map());
|
|
1201
|
+
|
|
1202
|
+
// src/utils/phone-number.ts
|
|
1203
|
+
function getCountryIsoFromFormattedNumber(formattedNumber, fallbackIso = "us") {
|
|
1204
|
+
const number = extractDigits(formattedNumber);
|
|
1205
|
+
if (!number || number.length < 4) {
|
|
1206
|
+
return fallbackIso;
|
|
1207
|
+
}
|
|
1208
|
+
if (number.startsWith("1") && phoneNumberBelongsTo("us", number)) {
|
|
1209
|
+
return "us";
|
|
1210
|
+
}
|
|
1211
|
+
if (number.startsWith("1") && phoneNumberBelongsTo("ca", number)) {
|
|
1212
|
+
return "ca";
|
|
1213
|
+
}
|
|
1214
|
+
return getCountryFromPhoneString(number).country.iso;
|
|
1215
|
+
}
|
|
1216
|
+
function formatPhoneNumber(phoneNumber, pattern, countryCode) {
|
|
1217
|
+
if (!phoneNumber || !pattern) {
|
|
1218
|
+
return phoneNumber;
|
|
1219
|
+
}
|
|
1220
|
+
const digits = [...extractDigits(phoneNumber)].slice(0, maxE164CompliantLength(countryCode));
|
|
1221
|
+
if (digits.length <= 3) {
|
|
1222
|
+
return digits.join("");
|
|
1223
|
+
}
|
|
1224
|
+
let res = "";
|
|
1225
|
+
for (let i = 0; digits.length > 0; i++) {
|
|
1226
|
+
if (i > pattern.length - 1) {
|
|
1227
|
+
res += digits.shift();
|
|
1228
|
+
} else {
|
|
1229
|
+
res += pattern[i] === "." ? digits.shift() : pattern[i];
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
return res;
|
|
1233
|
+
}
|
|
1234
|
+
function extractDigits(formattedPhone) {
|
|
1235
|
+
return (formattedPhone || "").replace(/[^\d]/g, "");
|
|
1236
|
+
}
|
|
1237
|
+
function phoneNumberBelongsTo(iso, phoneWithCode) {
|
|
1238
|
+
var _a, _b;
|
|
1239
|
+
if (!iso || !IsoToCountryMap.get(iso) || !phoneWithCode) {
|
|
1240
|
+
return false;
|
|
1241
|
+
}
|
|
1242
|
+
const code = phoneWithCode[0];
|
|
1243
|
+
const subArea = phoneWithCode.substring(1, 4);
|
|
1244
|
+
return code === ((_a = IsoToCountryMap.get(iso)) == null ? void 0 : _a.code) && phoneWithCode.length - 1 === maxDigitCountForPattern(((_b = IsoToCountryMap.get(iso)) == null ? void 0 : _b.pattern) || "") && SubAreaCodeSets[iso].has(subArea);
|
|
1245
|
+
}
|
|
1246
|
+
function maxDigitCountForPattern(pattern) {
|
|
1247
|
+
return (pattern.match(/\./g) || []).length;
|
|
1248
|
+
}
|
|
1249
|
+
var MAX_PHONE_NUMBER_LENGTH = 15;
|
|
1250
|
+
function maxE164CompliantLength(countryCode) {
|
|
1251
|
+
const usCountryCode = "1";
|
|
1252
|
+
countryCode = countryCode || usCountryCode;
|
|
1253
|
+
const codeWithPrefix = countryCode.includes("+") ? countryCode : "+" + countryCode;
|
|
1254
|
+
return MAX_PHONE_NUMBER_LENGTH - codeWithPrefix.length;
|
|
1255
|
+
}
|
|
1256
|
+
function parsePhoneString(str) {
|
|
1257
|
+
var _a, _b;
|
|
1258
|
+
const digits = extractDigits(str);
|
|
1259
|
+
const iso = getCountryIsoFromFormattedNumber(digits);
|
|
1260
|
+
const pattern = ((_a = IsoToCountryMap.get(iso)) == null ? void 0 : _a.pattern) || "";
|
|
1261
|
+
const code = ((_b = IsoToCountryMap.get(iso)) == null ? void 0 : _b.code) || "";
|
|
1262
|
+
const number = digits.slice(code.length);
|
|
1263
|
+
const formattedNumberWithCode = `+${code} ${formatPhoneNumber(number, pattern, code)}`;
|
|
1264
|
+
return { iso, pattern, code, number, formattedNumberWithCode };
|
|
1265
|
+
}
|
|
1266
|
+
function stringToFormattedPhoneString(str) {
|
|
1267
|
+
const parsed = parsePhoneString(str);
|
|
1268
|
+
return `+${parsed.code} ${formatPhoneNumber(parsed.number, parsed.pattern, parsed.code)}`;
|
|
1269
|
+
}
|
|
1270
|
+
var byPriority = (a, b) => {
|
|
1271
|
+
return b.priority - a.priority;
|
|
1272
|
+
};
|
|
1273
|
+
function getCountryFromPhoneString(phone) {
|
|
1274
|
+
const phoneWithCode = extractDigits(phone);
|
|
1275
|
+
const matchingCountries = [];
|
|
1276
|
+
for (const i of [4, 3, 2, 1]) {
|
|
1277
|
+
const potentialCode = phoneWithCode.substring(0, i);
|
|
1278
|
+
const countries = CodeToCountriesMap.get(potentialCode) || [];
|
|
1279
|
+
if (countries.length) {
|
|
1280
|
+
matchingCountries.push(...countries);
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
const fallbackCountry = IsoToCountryMap.get("us");
|
|
1284
|
+
const country = matchingCountries.sort(byPriority)[0] || fallbackCountry;
|
|
1285
|
+
const number = phoneWithCode.slice((country == null ? void 0 : country.code.length) || 0);
|
|
1286
|
+
return { number, country };
|
|
1287
|
+
}
|
|
1288
|
+
function useFocusInput() {
|
|
1289
|
+
const ref = React6.useRef(null);
|
|
1290
|
+
const setFocus = React6.useCallback(() => {
|
|
1291
|
+
requestAnimationFrame(() => {
|
|
1292
|
+
if (ref.current) {
|
|
1293
|
+
ref.current.focus();
|
|
1294
|
+
}
|
|
1295
|
+
});
|
|
1296
|
+
}, [ref]);
|
|
1297
|
+
return [ref, setFocus];
|
|
1298
|
+
}
|
|
1299
|
+
function CheckmarkSm(props) {
|
|
1300
|
+
return /* @__PURE__ */ jsx(Icon, { ...props, children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", children: /* @__PURE__ */ jsx(
|
|
1301
|
+
"path",
|
|
1302
|
+
{
|
|
1303
|
+
d: "M4.25 8.75L7.25 11.75L11.75 4.25",
|
|
1304
|
+
stroke: "currentColor",
|
|
1305
|
+
strokeWidth: "1.5",
|
|
1306
|
+
strokeLinecap: "round",
|
|
1307
|
+
strokeLinejoin: "round"
|
|
1308
|
+
}
|
|
1309
|
+
) }) });
|
|
1310
|
+
}
|
|
1311
|
+
function ChevronUpDownSm(props) {
|
|
1312
|
+
return /* @__PURE__ */ jsx(Icon, { ...props, children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", children: [
|
|
1313
|
+
/* @__PURE__ */ jsx(
|
|
1314
|
+
"path",
|
|
1315
|
+
{
|
|
1316
|
+
d: "M5.75 5.25L8 2.75L10.25 5.25",
|
|
1317
|
+
stroke: "currentColor",
|
|
1318
|
+
strokeWidth: "1.5",
|
|
1319
|
+
strokeLinecap: "round",
|
|
1320
|
+
strokeLinejoin: "round"
|
|
1321
|
+
}
|
|
1322
|
+
),
|
|
1323
|
+
/* @__PURE__ */ jsx(
|
|
1324
|
+
"path",
|
|
1325
|
+
{
|
|
1326
|
+
d: "M5.75 10.75L8 13.25L10.25 10.75",
|
|
1327
|
+
stroke: "currentColor",
|
|
1328
|
+
strokeWidth: "1.5",
|
|
1329
|
+
strokeLinecap: "round",
|
|
1330
|
+
strokeLinejoin: "round"
|
|
1331
|
+
}
|
|
1332
|
+
)
|
|
1333
|
+
] }) });
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
// src/utils/merge-refs.ts
|
|
1337
|
+
function mergeRefs(refs) {
|
|
1338
|
+
return (value) => {
|
|
1339
|
+
refs.forEach((ref) => {
|
|
1340
|
+
if (typeof ref === "function") {
|
|
1341
|
+
ref(value);
|
|
1342
|
+
} else if (ref != null) {
|
|
1343
|
+
ref.current = value;
|
|
1344
|
+
}
|
|
1345
|
+
});
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
var format = (str, iso) => {
|
|
1349
|
+
if (!str) {
|
|
1350
|
+
return "";
|
|
1351
|
+
}
|
|
1352
|
+
const country = IsoToCountryMap.get(iso);
|
|
1353
|
+
return formatPhoneNumber(str, country == null ? void 0 : country.pattern, country == null ? void 0 : country.code);
|
|
1354
|
+
};
|
|
1355
|
+
var useFormattedPhoneNumber = (props) => {
|
|
1356
|
+
const [number, setNumber] = React6.useState(() => {
|
|
1357
|
+
const { number: number2 } = parsePhoneString(props.initPhoneWithCode || "");
|
|
1358
|
+
return number2;
|
|
1359
|
+
});
|
|
1360
|
+
const [iso, setIso] = React6.useState(
|
|
1361
|
+
parsePhoneString(props.initPhoneWithCode || "").number ? parsePhoneString(props.initPhoneWithCode || "").iso : props.locationBasedCountryIso || "us"
|
|
1362
|
+
);
|
|
1363
|
+
React6.useEffect(() => {
|
|
1364
|
+
setNumber(extractDigits(number));
|
|
1365
|
+
}, [iso, number]);
|
|
1366
|
+
const numberWithCode = React6.useMemo(() => {
|
|
1367
|
+
var _a;
|
|
1368
|
+
if (!number) {
|
|
1369
|
+
return "";
|
|
1370
|
+
}
|
|
1371
|
+
const dialCode = ((_a = IsoToCountryMap.get(iso)) == null ? void 0 : _a.code) || "1";
|
|
1372
|
+
return "+" + extractDigits(`${dialCode}${number}`);
|
|
1373
|
+
}, [iso, number]);
|
|
1374
|
+
const formattedNumber = React6.useMemo(() => {
|
|
1375
|
+
return format(number, iso);
|
|
1376
|
+
}, [iso, number]);
|
|
1377
|
+
const setNumberAndIso = React6.useCallback((str) => {
|
|
1378
|
+
const { iso: iso2, number: number2 } = parsePhoneString(str);
|
|
1379
|
+
setNumber(number2);
|
|
1380
|
+
setIso(iso2);
|
|
1381
|
+
}, []);
|
|
1382
|
+
return {
|
|
1383
|
+
setNumber,
|
|
1384
|
+
setIso,
|
|
1385
|
+
setNumberAndIso,
|
|
1386
|
+
iso,
|
|
1387
|
+
number,
|
|
1388
|
+
numberWithCode,
|
|
1389
|
+
formattedNumber
|
|
1390
|
+
};
|
|
1391
|
+
};
|
|
1392
|
+
var countryOptions = Array.from(IsoToCountryMap.values()).map((country) => {
|
|
1393
|
+
return {
|
|
1394
|
+
...country
|
|
1395
|
+
};
|
|
1396
|
+
});
|
|
1397
|
+
var PhoneNumberField = React6.forwardRef(function PhoneNumberField2({
|
|
1398
|
+
alternativeFieldTrigger,
|
|
1399
|
+
name = "phoneNumber",
|
|
1400
|
+
initPhoneWithCode = "",
|
|
1401
|
+
onChange,
|
|
1402
|
+
...props
|
|
1403
|
+
}, forwardedRef) {
|
|
1404
|
+
var _a, _b;
|
|
1405
|
+
const clerk = useClerk();
|
|
1406
|
+
const locationBasedCountryIso = clerk.__internal_country;
|
|
1407
|
+
const { t, translateError } = useLocalizations();
|
|
1408
|
+
const [isOpen, setOpen] = React6.useState(false);
|
|
1409
|
+
const [selectedCountry, setSelectedCountry] = React6.useState(countryOptions[0]);
|
|
1410
|
+
const id = React6.useId();
|
|
1411
|
+
const containerRef = React6.useRef(null);
|
|
1412
|
+
const commandListRef = React6.useRef(null);
|
|
1413
|
+
const commandInputRef = React6.useRef(null);
|
|
1414
|
+
const contentWidth = ((_b = (_a = containerRef.current) == null ? void 0 : _a.getBoundingClientRect()) == null ? void 0 : _b.width) || 0;
|
|
1415
|
+
const [inputRef, setInputFocus] = useFocusInput();
|
|
1416
|
+
const { setNumber, setIso, setNumberAndIso, numberWithCode, formattedNumber, iso } = useFormattedPhoneNumber({
|
|
1417
|
+
initPhoneWithCode,
|
|
1418
|
+
locationBasedCountryIso
|
|
1419
|
+
});
|
|
1420
|
+
const handlePaste = (e) => {
|
|
1421
|
+
e.preventDefault();
|
|
1422
|
+
const inputValue = e.clipboardData.getData("text");
|
|
1423
|
+
if (inputValue.includes("+")) {
|
|
1424
|
+
setNumberAndIso(inputValue);
|
|
1425
|
+
} else {
|
|
1426
|
+
setNumber(inputValue);
|
|
1427
|
+
}
|
|
1428
|
+
};
|
|
1429
|
+
const handlePhoneNumberChange = (e) => {
|
|
1430
|
+
const inputValue = e.target.value;
|
|
1431
|
+
if (inputValue.includes("+")) {
|
|
1432
|
+
setNumberAndIso(inputValue);
|
|
1433
|
+
} else {
|
|
1434
|
+
setNumber(inputValue);
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
1437
|
+
React6.useEffect(
|
|
1438
|
+
function syncSelectedCountry() {
|
|
1439
|
+
setSelectedCountry(countryOptions.find((c) => c.iso === iso) || countryOptions[0]);
|
|
1440
|
+
},
|
|
1441
|
+
[iso]
|
|
1442
|
+
);
|
|
1443
|
+
React6.useEffect(
|
|
1444
|
+
function scrollActiveCommandItemIntoView() {
|
|
1445
|
+
var _a2;
|
|
1446
|
+
if (isOpen) {
|
|
1447
|
+
(_a2 = commandInputRef.current) == null ? void 0 : _a2.focus();
|
|
1448
|
+
setTimeout(() => {
|
|
1449
|
+
var _a3, _b2;
|
|
1450
|
+
(_b2 = (_a3 = commandListRef.current) == null ? void 0 : _a3.querySelector("[data-checked=true]")) == null ? void 0 : _b2.scrollIntoView({ block: "start" });
|
|
1451
|
+
}, 0);
|
|
1452
|
+
}
|
|
1453
|
+
},
|
|
1454
|
+
[isOpen]
|
|
1455
|
+
);
|
|
1456
|
+
return /* @__PURE__ */ jsx(
|
|
1457
|
+
Common.Field,
|
|
1458
|
+
{
|
|
1459
|
+
name,
|
|
1460
|
+
asChild: true,
|
|
1461
|
+
children: /* @__PURE__ */ jsxs(Root, { children: [
|
|
1462
|
+
/* @__PURE__ */ jsx(Common.Label, { asChild: true, children: /* @__PURE__ */ jsxs(Label, { htmlFor: id, children: [
|
|
1463
|
+
t("formFieldLabel__phoneNumber"),
|
|
1464
|
+
" ",
|
|
1465
|
+
alternativeFieldTrigger ? /* @__PURE__ */ jsx(LabelEnd, { children: alternativeFieldTrigger }) : !(props == null ? void 0 : props.required) ? /* @__PURE__ */ jsx(Hint, { children: t("formFieldHintText__optional") }) : null
|
|
1466
|
+
] }) }),
|
|
1467
|
+
/* @__PURE__ */ jsx(Common.FieldState, { children: ({ state: intent }) => {
|
|
1468
|
+
return /* @__PURE__ */ jsxs(
|
|
1469
|
+
"div",
|
|
1470
|
+
{
|
|
1471
|
+
ref: containerRef,
|
|
1472
|
+
className: cx(
|
|
1473
|
+
// Note:
|
|
1474
|
+
// - To create the overlapping border/shadow effect"
|
|
1475
|
+
// - `ring` – "focus ring"
|
|
1476
|
+
// - `ring-offset` - border
|
|
1477
|
+
"cl-deb747c5",
|
|
1478
|
+
"cl-d9213aa4",
|
|
1479
|
+
"cl-929952e4",
|
|
1480
|
+
"cl-000b8592",
|
|
1481
|
+
"cl-2aeea0c3",
|
|
1482
|
+
"cl-b8d3fb9a",
|
|
1483
|
+
// hover
|
|
1484
|
+
"cl-31e80f10",
|
|
1485
|
+
// focus
|
|
1486
|
+
"cl-f3ff9abd",
|
|
1487
|
+
"cl-2d93da67",
|
|
1488
|
+
// intent
|
|
1489
|
+
{
|
|
1490
|
+
idle: [
|
|
1491
|
+
"cl-60b2eb1d",
|
|
1492
|
+
"cl-9722ed3e"
|
|
1493
|
+
],
|
|
1494
|
+
info: [
|
|
1495
|
+
"cl-d0aba580",
|
|
1496
|
+
"cl-9722ed3e"
|
|
1497
|
+
],
|
|
1498
|
+
error: [
|
|
1499
|
+
"cl-5a239b6d",
|
|
1500
|
+
"cl-16f89e98",
|
|
1501
|
+
"cl-a0f5bec1"
|
|
1502
|
+
],
|
|
1503
|
+
success: [
|
|
1504
|
+
"cl-903d9684",
|
|
1505
|
+
"cl-9ee10a6a",
|
|
1506
|
+
"cl-7df25448"
|
|
1507
|
+
// (optically adjusted ring to 25 opacity)
|
|
1508
|
+
],
|
|
1509
|
+
warning: [
|
|
1510
|
+
"cl-e6adb1a7",
|
|
1511
|
+
"cl-9b871c1b",
|
|
1512
|
+
"cl-08105371"
|
|
1513
|
+
]
|
|
1514
|
+
}[intent]
|
|
1515
|
+
),
|
|
1516
|
+
children: [
|
|
1517
|
+
/* @__PURE__ */ jsxs(DialogTrigger, { children: [
|
|
1518
|
+
/* @__PURE__ */ jsxs(
|
|
1519
|
+
Button,
|
|
1520
|
+
{
|
|
1521
|
+
onPress: () => setOpen(true),
|
|
1522
|
+
isDisabled: props.disabled,
|
|
1523
|
+
className: "cl-b2ddee5e",
|
|
1524
|
+
children: [
|
|
1525
|
+
/* @__PURE__ */ jsx("span", { className: "cl-6f75bc57", children: selectedCountry.iso }),
|
|
1526
|
+
/* @__PURE__ */ jsx(ChevronUpDownSm, { className: "cl-f6142057" })
|
|
1527
|
+
]
|
|
1528
|
+
}
|
|
1529
|
+
),
|
|
1530
|
+
/* @__PURE__ */ jsx(
|
|
1531
|
+
Popover,
|
|
1532
|
+
{
|
|
1533
|
+
isOpen,
|
|
1534
|
+
onOpenChange: setOpen,
|
|
1535
|
+
placement: "bottom start",
|
|
1536
|
+
crossOffset: -1,
|
|
1537
|
+
children: /* @__PURE__ */ jsx(
|
|
1538
|
+
Dialog,
|
|
1539
|
+
{
|
|
1540
|
+
className: "cl-b30fc560",
|
|
1541
|
+
style: {
|
|
1542
|
+
width: contentWidth
|
|
1543
|
+
},
|
|
1544
|
+
children: /* @__PURE__ */ jsxs(Command, { className: "cl-dc1d9f19", children: [
|
|
1545
|
+
/* @__PURE__ */ jsx("div", { className: "cl-1c0d9e31", children: /* @__PURE__ */ jsx(
|
|
1546
|
+
Command.Input,
|
|
1547
|
+
{
|
|
1548
|
+
ref: commandInputRef,
|
|
1549
|
+
placeholder: "Search country or code",
|
|
1550
|
+
className: "cl-54426bd8"
|
|
1551
|
+
}
|
|
1552
|
+
) }),
|
|
1553
|
+
/* @__PURE__ */ jsxs(
|
|
1554
|
+
Command.List,
|
|
1555
|
+
{
|
|
1556
|
+
ref: commandListRef,
|
|
1557
|
+
className: "cl-6bc50823",
|
|
1558
|
+
children: [
|
|
1559
|
+
/* @__PURE__ */ jsx(Command.Empty, { className: "cl-1facd79b", children: "No countries found" }),
|
|
1560
|
+
countryOptions.map(({ name: name2, iso: iso2, code }, index) => {
|
|
1561
|
+
return /* @__PURE__ */ jsxs(
|
|
1562
|
+
Command.Item,
|
|
1563
|
+
{
|
|
1564
|
+
onSelect: () => {
|
|
1565
|
+
setIso(iso2);
|
|
1566
|
+
setOpen(false);
|
|
1567
|
+
setInputFocus();
|
|
1568
|
+
},
|
|
1569
|
+
"data-checked": selectedCountry === countryOptions[index],
|
|
1570
|
+
className: "cl-ba59b9a7",
|
|
1571
|
+
children: [
|
|
1572
|
+
/* @__PURE__ */ jsx("span", { className: "cl-4128a507", children: selectedCountry === countryOptions[index] && /* @__PURE__ */ jsx(CheckmarkSm, { className: "cl-100c22d5" }) }),
|
|
1573
|
+
/* @__PURE__ */ jsx("span", { className: "cl-2bcc5e30", children: name2 }),
|
|
1574
|
+
/* @__PURE__ */ jsxs("span", { className: "cl-00c77415", children: [
|
|
1575
|
+
"+",
|
|
1576
|
+
code
|
|
1577
|
+
] })
|
|
1578
|
+
]
|
|
1579
|
+
},
|
|
1580
|
+
iso2
|
|
1581
|
+
);
|
|
1582
|
+
})
|
|
1583
|
+
]
|
|
1584
|
+
}
|
|
1585
|
+
)
|
|
1586
|
+
] })
|
|
1587
|
+
}
|
|
1588
|
+
)
|
|
1589
|
+
}
|
|
1590
|
+
)
|
|
1591
|
+
] }),
|
|
1592
|
+
/* @__PURE__ */ jsxs(
|
|
1593
|
+
"button",
|
|
1594
|
+
{
|
|
1595
|
+
type: "button",
|
|
1596
|
+
tabIndex: -1,
|
|
1597
|
+
className: "cl-59bd566c",
|
|
1598
|
+
onClick: () => setInputFocus(),
|
|
1599
|
+
disabled: props.disabled,
|
|
1600
|
+
children: [
|
|
1601
|
+
"+",
|
|
1602
|
+
selectedCountry.code
|
|
1603
|
+
]
|
|
1604
|
+
}
|
|
1605
|
+
),
|
|
1606
|
+
/* @__PURE__ */ jsx(
|
|
1607
|
+
Common.Input,
|
|
1608
|
+
{
|
|
1609
|
+
value: numberWithCode,
|
|
1610
|
+
className: "cl-e564b408"
|
|
1611
|
+
}
|
|
1612
|
+
),
|
|
1613
|
+
/* @__PURE__ */ jsx(
|
|
1614
|
+
"input",
|
|
1615
|
+
{
|
|
1616
|
+
ref: mergeRefs([forwardedRef, inputRef]),
|
|
1617
|
+
type: "tel",
|
|
1618
|
+
id,
|
|
1619
|
+
maxLength: 25,
|
|
1620
|
+
value: formattedNumber,
|
|
1621
|
+
onPaste: handlePaste,
|
|
1622
|
+
onChange: handlePhoneNumberChange,
|
|
1623
|
+
...props,
|
|
1624
|
+
className: "cl-4a741be6",
|
|
1625
|
+
"data-field-input": true
|
|
1626
|
+
}
|
|
1627
|
+
)
|
|
1628
|
+
]
|
|
1629
|
+
}
|
|
1630
|
+
);
|
|
1631
|
+
} }),
|
|
1632
|
+
/* @__PURE__ */ jsx(Animated, { children: /* @__PURE__ */ jsx(Common.FieldError, { asChild: true, children: ({ message, code }) => {
|
|
1633
|
+
return /* @__PURE__ */ jsx(Message, { intent: "error", children: translateError({ message, code, name: "phone_number" }) });
|
|
1634
|
+
} }) })
|
|
1635
|
+
] })
|
|
1636
|
+
}
|
|
1637
|
+
);
|
|
1638
|
+
});
|
|
1639
|
+
function EmailOrPhoneNumberField({
|
|
1640
|
+
className,
|
|
1641
|
+
name = void 0,
|
|
1642
|
+
toggleLabelEmail,
|
|
1643
|
+
toggleLabelPhoneNumber,
|
|
1644
|
+
...props
|
|
1645
|
+
}) {
|
|
1646
|
+
const [showPhoneNumberField, setShowPhoneNumberField] = React6.useState(false);
|
|
1647
|
+
const [inputRef, setInputFocus] = useFocusInput();
|
|
1648
|
+
const toggle = /* @__PURE__ */ jsx(
|
|
1649
|
+
ToggleButton,
|
|
1650
|
+
{
|
|
1651
|
+
isSelected: showPhoneNumberField,
|
|
1652
|
+
onChange: (isSelected) => {
|
|
1653
|
+
setShowPhoneNumberField(isSelected);
|
|
1654
|
+
setInputFocus();
|
|
1655
|
+
},
|
|
1656
|
+
className: link({ size: "sm", disabled: props.disabled }),
|
|
1657
|
+
children: showPhoneNumberField ? toggleLabelEmail : toggleLabelPhoneNumber
|
|
1658
|
+
}
|
|
1659
|
+
);
|
|
1660
|
+
return showPhoneNumberField ? /* @__PURE__ */ jsx(
|
|
1661
|
+
PhoneNumberField,
|
|
1662
|
+
{
|
|
1663
|
+
alternativeFieldTrigger: toggle,
|
|
1664
|
+
name,
|
|
1665
|
+
...props,
|
|
1666
|
+
ref: inputRef
|
|
1667
|
+
}
|
|
1668
|
+
) : /* @__PURE__ */ jsx(
|
|
1669
|
+
EmailField,
|
|
1670
|
+
{
|
|
1671
|
+
...props,
|
|
1672
|
+
name,
|
|
1673
|
+
alternativeFieldTrigger: toggle,
|
|
1674
|
+
ref: inputRef
|
|
1675
|
+
}
|
|
1676
|
+
);
|
|
1677
|
+
}
|
|
1678
|
+
function UsernameField({
|
|
1679
|
+
alternativeFieldTrigger,
|
|
1680
|
+
name = "username",
|
|
1681
|
+
...props
|
|
1682
|
+
}) {
|
|
1683
|
+
const { t, translateError } = useLocalizations();
|
|
1684
|
+
return /* @__PURE__ */ jsx(
|
|
1685
|
+
Common.Field,
|
|
1686
|
+
{
|
|
1687
|
+
name,
|
|
1688
|
+
asChild: true,
|
|
1689
|
+
children: /* @__PURE__ */ jsxs(Root, { children: [
|
|
1690
|
+
/* @__PURE__ */ jsx(Common.Label, { asChild: true, children: /* @__PURE__ */ jsxs(Label, { children: [
|
|
1691
|
+
t("formFieldLabel__username"),
|
|
1692
|
+
" ",
|
|
1693
|
+
alternativeFieldTrigger ? /* @__PURE__ */ jsx(LabelEnd, { children: alternativeFieldTrigger }) : !(props == null ? void 0 : props.required) ? /* @__PURE__ */ jsx(Hint, { children: t("formFieldHintText__optional") }) : null
|
|
1694
|
+
] }) }),
|
|
1695
|
+
/* @__PURE__ */ jsx(Common.FieldState, { children: ({ state }) => {
|
|
1696
|
+
return /* @__PURE__ */ jsx(
|
|
1697
|
+
Common.Input,
|
|
1698
|
+
{
|
|
1699
|
+
type: "text",
|
|
1700
|
+
...props,
|
|
1701
|
+
asChild: true,
|
|
1702
|
+
children: /* @__PURE__ */ jsx(Input, { intent: state })
|
|
1703
|
+
}
|
|
1704
|
+
);
|
|
1705
|
+
} }),
|
|
1706
|
+
/* @__PURE__ */ jsx(Animated, { children: /* @__PURE__ */ jsx(Common.FieldError, { asChild: true, children: ({ message, code }) => {
|
|
1707
|
+
return /* @__PURE__ */ jsx(Message, { intent: "error", children: translateError({ message, code, name: "username" }) });
|
|
1708
|
+
} }) })
|
|
1709
|
+
] })
|
|
1710
|
+
}
|
|
1711
|
+
);
|
|
1712
|
+
}
|
|
1713
|
+
var RouterLink = React6.forwardRef(function RouterLink2({ asChild, children, href, ...props }, forwardedRef) {
|
|
1714
|
+
const router = useClerkHostRouter();
|
|
1715
|
+
const Comp = asChild ? Slot : "a";
|
|
1716
|
+
return /* @__PURE__ */ jsx(
|
|
1717
|
+
Comp,
|
|
1718
|
+
{
|
|
1719
|
+
ref: forwardedRef,
|
|
1720
|
+
...props,
|
|
1721
|
+
href,
|
|
1722
|
+
onClick: (e) => {
|
|
1723
|
+
e.preventDefault();
|
|
1724
|
+
if (href) {
|
|
1725
|
+
router.push(href);
|
|
1726
|
+
}
|
|
1727
|
+
},
|
|
1728
|
+
children
|
|
1729
|
+
}
|
|
1730
|
+
);
|
|
1731
|
+
});
|
|
1732
|
+
function OTPField({
|
|
1733
|
+
label,
|
|
1734
|
+
resend,
|
|
1735
|
+
...props
|
|
1736
|
+
}) {
|
|
1737
|
+
return /* @__PURE__ */ jsxs("div", { className: "cl-a8dca104", children: [
|
|
1738
|
+
/* @__PURE__ */ jsx(
|
|
1739
|
+
Common.Field,
|
|
1740
|
+
{
|
|
1741
|
+
asChild: true,
|
|
1742
|
+
name: "code",
|
|
1743
|
+
children: /* @__PURE__ */ jsxs(Root, { children: [
|
|
1744
|
+
/* @__PURE__ */ jsx(Common.Label, { asChild: true, children: /* @__PURE__ */ jsx(Label, { visuallyHidden: true, children: label }) }),
|
|
1745
|
+
/* @__PURE__ */ jsx(Common.FieldState, { children: ({ state }) => /* @__PURE__ */ jsx(
|
|
1746
|
+
Common.Input,
|
|
1747
|
+
{
|
|
1748
|
+
type: "otp",
|
|
1749
|
+
autoSubmit: true,
|
|
1750
|
+
autoFocus: true,
|
|
1751
|
+
className: "cl-6f38a1ba",
|
|
1752
|
+
passwordManagerOffset: 24,
|
|
1753
|
+
render: ({ value, status }) => /* @__PURE__ */ jsx(
|
|
1754
|
+
Input,
|
|
1755
|
+
{
|
|
1756
|
+
variant: "otp-digit",
|
|
1757
|
+
intent: state,
|
|
1758
|
+
state: {
|
|
1759
|
+
cursor: "focus-visible",
|
|
1760
|
+
selected: "focus-visible",
|
|
1761
|
+
hovered: "hover",
|
|
1762
|
+
none: "native"
|
|
1763
|
+
}[status],
|
|
1764
|
+
...props,
|
|
1765
|
+
asChild: true,
|
|
1766
|
+
children: /* @__PURE__ */ jsxs("span", { children: [
|
|
1767
|
+
status === "cursor" && /* @__PURE__ */ jsx(
|
|
1768
|
+
"span",
|
|
1769
|
+
{
|
|
1770
|
+
"data-otp-field-cursor": "",
|
|
1771
|
+
className: "cl-0389eded"
|
|
1772
|
+
}
|
|
1773
|
+
),
|
|
1774
|
+
value
|
|
1775
|
+
] })
|
|
1776
|
+
}
|
|
1777
|
+
)
|
|
1778
|
+
}
|
|
1779
|
+
) }),
|
|
1780
|
+
/* @__PURE__ */ jsx(Animated, { children: /* @__PURE__ */ jsx(Common.FieldError, { asChild: true, children: ({ message }) => {
|
|
1781
|
+
return /* @__PURE__ */ jsx(
|
|
1782
|
+
Message,
|
|
1783
|
+
{
|
|
1784
|
+
justify: "center",
|
|
1785
|
+
intent: "error",
|
|
1786
|
+
children: message
|
|
1787
|
+
}
|
|
1788
|
+
);
|
|
1789
|
+
} }) })
|
|
1790
|
+
] })
|
|
1791
|
+
}
|
|
1792
|
+
),
|
|
1793
|
+
resend && resend
|
|
1794
|
+
] });
|
|
1795
|
+
}
|
|
1796
|
+
function PenSm(props) {
|
|
1797
|
+
return /* @__PURE__ */ jsx(Icon, { ...props, children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", children: /* @__PURE__ */ jsx(
|
|
1798
|
+
"path",
|
|
1799
|
+
{
|
|
1800
|
+
d: "M9.23664 3.44288L4.18161 8.33251C3.90008 8.60483 3.70471 8.95383 3.61974 9.33619L2.75 13.25L6.45529 12.3782C6.81159 12.2943 7.13805 12.1143 7.3991 11.8578L12.6265 6.72023C13.4824 5.78723 13.4537 4.34072 12.5614 3.44288C11.6433 2.51904 10.1547 2.51904 9.23664 3.44288Z",
|
|
1801
|
+
stroke: "currentColor",
|
|
1802
|
+
strokeWidth: "1.5",
|
|
1803
|
+
strokeLinecap: "round",
|
|
1804
|
+
strokeLinejoin: "round"
|
|
1805
|
+
}
|
|
1806
|
+
) }) });
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
export { Animated, CaretRightLegacySm, Checkbox, EmailField, EmailOrPhoneNumberField, GlobalError, Hint, Input, LOCALIZATION_NEEDED, Label, LinkButton, Message, OTPField, PasswordField, PenSm, PhoneNumberField, Root, RouterLink, UsernameField, link, parsePhoneString, stringToFormattedPhoneString, useAttributes, useCard, useDevModeWarning, useDisplayConfig, useEnvironment, useFocusInput, useSignUpAttributes };
|
|
1810
|
+
//# sourceMappingURL=out.js.map
|
|
1811
|
+
//# sourceMappingURL=chunk-TVTJKSVH.mjs.map
|