@worldcoin/mini-apps-ui-kit-react 0.0.5 → 0.0.6
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.
@@ -1,19 +1,19 @@
|
|
1
1
|
"use client";
|
2
|
-
import { jsx as
|
3
|
-
import { DROPDOWN_CONTAINER_STYLES as
|
4
|
-
import { cn as
|
5
|
-
import { Root as
|
6
|
-
import { forwardRef as
|
7
|
-
import { usePhoneInput as
|
8
|
-
import { Drawer as
|
9
|
-
import { Input as
|
10
|
-
import { SearchField as
|
2
|
+
import { jsx as t, jsxs as c } from "react/jsx-runtime";
|
3
|
+
import { DROPDOWN_CONTAINER_STYLES as te } from "../../lib/constants/dropdownStyles.js";
|
4
|
+
import { cn as oe } from "../../lib/utils.js";
|
5
|
+
import { Root as re, Trigger as ne, Portal as ae, Content as le, Viewport as se, Item as ie } from "../../node_modules/.pnpm/@radix-ui_react-select@2.1.4_@types_react-dom@18.3.5_@types_react@18.3.18__@types_react@18.3._atdh45n5c7sked5b6tbwgdz7re/node_modules/@radix-ui/react-select/dist/index.js";
|
6
|
+
import { forwardRef as ce, useRef as ue, useState as w, useMemo as F, useImperativeHandle as de } from "react";
|
7
|
+
import { usePhoneInput as me, parseCountry as O } from "../../node_modules/.pnpm/react-international-phone@4.4.0_react@18.3.1/node_modules/react-international-phone/dist/index.js";
|
8
|
+
import { Drawer as he, DrawerTrigger as fe, DrawerContent as pe, DrawerClose as Ce } from "../Drawer/Drawer.js";
|
9
|
+
import { Input as ye } from "../Input/Input.js";
|
10
|
+
import { SearchField as we } from "../SearchField/SearchField.js";
|
11
11
|
import { Typography as P } from "../Typography/Typography.js";
|
12
12
|
import L from "./CountryListItem.js";
|
13
13
|
import R from "./CountrySelectorButton.js";
|
14
|
-
import { DIAL_CODE_PREFIX as g, startAdornmentWidthByDialCodeLength as
|
15
|
-
import { getCountryDataListByCodes as
|
16
|
-
const
|
14
|
+
import { DIAL_CODE_PREFIX as g, startAdornmentWidthByDialCodeLength as ge } from "./constants.js";
|
15
|
+
import { getCountryDataListByCodes as xe, getValidatedCountryCode as u, filterCountries as Ne } from "./utils.js";
|
16
|
+
const Se = ce(
|
17
17
|
({
|
18
18
|
value: T,
|
19
19
|
onChange: d,
|
@@ -22,15 +22,20 @@ const ye = ne(
|
|
22
22
|
defaultCountryCode: n = "US",
|
23
23
|
hideDialCode: m = !1,
|
24
24
|
disableDialCodePrefill: E = !0,
|
25
|
-
disabled:
|
25
|
+
disabled: s = !1,
|
26
26
|
error: b = !1,
|
27
27
|
isValid: V,
|
28
28
|
endAdornment: W,
|
29
29
|
endAdornmentWidth: B,
|
30
30
|
countrySelectorMode: _ = "dropdown",
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
type: j = "tel",
|
32
|
+
inputMode: k = "tel",
|
33
|
+
autoComplete: M = "tel",
|
34
|
+
autoCapitalize: q = "off",
|
35
|
+
autoCorrect: H = "off",
|
36
|
+
...U
|
37
|
+
}, X) => {
|
38
|
+
const N = ue(null), [h, f] = w(!1), [Y, p] = w(!1), [C, S] = w(""), i = F(() => xe(x), [x]), { inputValue: z, country: y, inputRef: a, handlePhoneValueChange: G, setCountry: J } = me(
|
34
39
|
{
|
35
40
|
defaultCountry: n.toLowerCase(),
|
36
41
|
disableDialCodePrefill: E,
|
@@ -43,67 +48,72 @@ const ye = ne(
|
|
43
48
|
);
|
44
49
|
}
|
45
50
|
}
|
46
|
-
),
|
47
|
-
|
51
|
+
), l = u(y.iso2, n), K = 2.8, D = `${g}${y.dialCode}`, Q = m ? K : ge[y.dialCode.length];
|
52
|
+
de(X, () => a.current);
|
48
53
|
const v = (e) => {
|
49
|
-
e == null || e.preventDefault(),
|
50
|
-
var
|
51
|
-
(
|
52
|
-
}),
|
53
|
-
},
|
54
|
+
e == null || e.preventDefault(), Y && requestAnimationFrame(() => {
|
55
|
+
var o;
|
56
|
+
(o = a.current) == null || o.focus();
|
57
|
+
}), p(!1);
|
58
|
+
}, Z = (e) => {
|
54
59
|
var r;
|
55
|
-
const
|
56
|
-
|
60
|
+
const o = (r = N.current) == null ? void 0 : r.contains(e.target);
|
61
|
+
p(!!o);
|
57
62
|
}, A = (e) => {
|
58
|
-
|
59
|
-
},
|
63
|
+
J(e.toLowerCase()), f(!1);
|
64
|
+
}, ee = (e) => {
|
60
65
|
S(e.target.value);
|
61
66
|
}, I = F(
|
62
|
-
() =>
|
67
|
+
() => Ne(i, C),
|
63
68
|
[i, C]
|
64
69
|
);
|
65
|
-
return /* @__PURE__ */
|
66
|
-
|
70
|
+
return /* @__PURE__ */ t(
|
71
|
+
ye,
|
67
72
|
{
|
68
|
-
...
|
73
|
+
...U,
|
69
74
|
ref: a,
|
70
|
-
|
71
|
-
|
75
|
+
type: j,
|
76
|
+
inputMode: k,
|
77
|
+
autoComplete: M,
|
78
|
+
autoCapitalize: q,
|
79
|
+
autoCorrect: H,
|
80
|
+
value: z,
|
81
|
+
onChange: G,
|
72
82
|
placeholder: $,
|
73
|
-
disabled:
|
83
|
+
disabled: s,
|
74
84
|
error: b,
|
75
85
|
isValid: V,
|
76
86
|
endAdornment: W,
|
77
87
|
endAdornmentWidth: B,
|
78
|
-
startAdornmentWidth:
|
88
|
+
startAdornmentWidth: Q,
|
79
89
|
isFocused: h,
|
80
90
|
startAdornment: _ === "drawer" ? /* @__PURE__ */ c(
|
81
|
-
|
91
|
+
he,
|
82
92
|
{
|
83
93
|
open: h,
|
84
|
-
onOpenChange:
|
94
|
+
onOpenChange: f,
|
85
95
|
onClose: v,
|
86
96
|
onAnimationEnd: (e) => {
|
87
|
-
e &&
|
97
|
+
e && p(!0);
|
88
98
|
},
|
89
99
|
children: [
|
90
|
-
/* @__PURE__ */
|
100
|
+
/* @__PURE__ */ t(fe, { asChild: !0, className: "outline-none", children: /* @__PURE__ */ t(
|
91
101
|
R,
|
92
102
|
{
|
93
|
-
disabled:
|
94
|
-
countryCode:
|
103
|
+
disabled: s,
|
104
|
+
countryCode: l,
|
95
105
|
hideDialCode: m,
|
96
106
|
dialCode: D
|
97
107
|
}
|
98
108
|
) }),
|
99
|
-
/* @__PURE__ */
|
100
|
-
/* @__PURE__ */
|
101
|
-
/* @__PURE__ */
|
102
|
-
|
109
|
+
/* @__PURE__ */ t(pe, { className: "h-[96%]", children: /* @__PURE__ */ c("div", { className: "max-w-md w-full mx-auto flex flex-col flex-grow", children: [
|
110
|
+
/* @__PURE__ */ t(P, { variant: "subtitle", level: 2, className: "px-4 py-2", children: "Select country" }),
|
111
|
+
/* @__PURE__ */ t("div", { className: "px-4 pt-2 pb-4", children: /* @__PURE__ */ t(
|
112
|
+
we,
|
103
113
|
{
|
104
114
|
placeholder: "Search name or number",
|
105
115
|
value: C,
|
106
|
-
onChange:
|
116
|
+
onChange: ee
|
107
117
|
}
|
108
118
|
) }),
|
109
119
|
/* @__PURE__ */ c(
|
@@ -117,24 +127,24 @@ const ye = ne(
|
|
117
127
|
},
|
118
128
|
children: [
|
119
129
|
I.map((e) => {
|
120
|
-
const
|
121
|
-
|
130
|
+
const o = O(e), r = u(
|
131
|
+
o.iso2,
|
122
132
|
n
|
123
133
|
);
|
124
|
-
return /* @__PURE__ */
|
134
|
+
return /* @__PURE__ */ t(Ce, { className: "block w-full", children: /* @__PURE__ */ t(
|
125
135
|
L,
|
126
136
|
{
|
127
137
|
countryCode: r,
|
128
|
-
countryName:
|
129
|
-
dialCode: `${g}${
|
138
|
+
countryName: o.name,
|
139
|
+
dialCode: `${g}${o.dialCode}`,
|
130
140
|
onClick: () => {
|
131
141
|
A(r), S("");
|
132
142
|
},
|
133
|
-
isSelected:
|
143
|
+
isSelected: l === r
|
134
144
|
}
|
135
145
|
) }, r);
|
136
146
|
}),
|
137
|
-
I.length === 0 && /* @__PURE__ */
|
147
|
+
I.length === 0 && /* @__PURE__ */ t(P, { variant: "body", level: 2, className: "text-center", children: "No countries found" })
|
138
148
|
]
|
139
149
|
}
|
140
150
|
)
|
@@ -142,50 +152,50 @@ const ye = ne(
|
|
142
152
|
]
|
143
153
|
}
|
144
154
|
) : /* @__PURE__ */ c(
|
145
|
-
|
155
|
+
re,
|
146
156
|
{
|
147
|
-
value:
|
157
|
+
value: l,
|
148
158
|
open: h,
|
149
|
-
onOpenChange:
|
159
|
+
onOpenChange: f,
|
150
160
|
onValueChange: A,
|
151
|
-
disabled:
|
161
|
+
disabled: s,
|
152
162
|
children: [
|
153
|
-
/* @__PURE__ */
|
163
|
+
/* @__PURE__ */ t(ne, { children: /* @__PURE__ */ t(
|
154
164
|
R,
|
155
165
|
{
|
156
|
-
disabled:
|
157
|
-
countryCode:
|
166
|
+
disabled: s,
|
167
|
+
countryCode: l,
|
158
168
|
hideDialCode: m,
|
159
169
|
dialCode: D
|
160
170
|
}
|
161
171
|
) }),
|
162
|
-
/* @__PURE__ */
|
163
|
-
|
172
|
+
/* @__PURE__ */ t(ae, { children: /* @__PURE__ */ t(
|
173
|
+
le,
|
164
174
|
{
|
165
175
|
ref: (e) => {
|
166
176
|
N.current = e, e && a.current && (e.style.width = `${a.current.offsetWidth}px`);
|
167
177
|
},
|
168
178
|
position: "popper",
|
169
|
-
className:
|
179
|
+
className: oe(te, "-ml-3 mt-5 w-auto"),
|
170
180
|
onCloseAutoFocus: v,
|
171
|
-
onPointerDown:
|
172
|
-
children: /* @__PURE__ */
|
173
|
-
const
|
174
|
-
|
181
|
+
onPointerDown: Z,
|
182
|
+
children: /* @__PURE__ */ t(se, { className: "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] p-2", children: i.map((e) => {
|
183
|
+
const o = O(e), r = u(
|
184
|
+
o.iso2,
|
175
185
|
n
|
176
186
|
);
|
177
|
-
return /* @__PURE__ */
|
178
|
-
|
187
|
+
return /* @__PURE__ */ t(
|
188
|
+
ie,
|
179
189
|
{
|
180
190
|
value: r,
|
181
191
|
className: "outline-none",
|
182
|
-
children: /* @__PURE__ */
|
192
|
+
children: /* @__PURE__ */ t(
|
183
193
|
L,
|
184
194
|
{
|
185
195
|
countryCode: r,
|
186
|
-
countryName:
|
187
|
-
dialCode: `${g}${
|
188
|
-
isSelected:
|
196
|
+
countryName: o.name,
|
197
|
+
dialCode: `${g}${o.dialCode}`,
|
198
|
+
isSelected: l === r
|
189
199
|
}
|
190
200
|
)
|
191
201
|
},
|
@@ -201,8 +211,8 @@ const ye = ne(
|
|
201
211
|
);
|
202
212
|
}
|
203
213
|
);
|
204
|
-
|
214
|
+
Se.displayName = "PhoneField";
|
205
215
|
export {
|
206
|
-
|
207
|
-
|
216
|
+
Se as PhoneField,
|
217
|
+
Se as default
|
208
218
|
};
|
@@ -7,16 +7,16 @@ export interface TypographyProps extends React.HTMLAttributes<HTMLElement> {
|
|
7
7
|
as?: "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "span" | "small" | "strong" | "div" | "em";
|
8
8
|
}
|
9
9
|
export interface TypographyNumberProps extends TypographyProps {
|
10
|
-
variant
|
11
|
-
level
|
10
|
+
variant?: "number";
|
11
|
+
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
12
12
|
}
|
13
13
|
export interface TypographySubtitleBodyMonoProps extends TypographyProps {
|
14
|
-
variant
|
15
|
-
level
|
14
|
+
variant?: "subtitle" | "body" | "mono";
|
15
|
+
level?: 1 | 2 | 3 | 4;
|
16
16
|
}
|
17
17
|
export interface TypographyHeadingProps extends TypographyProps {
|
18
|
-
variant
|
19
|
-
level
|
18
|
+
variant?: "heading";
|
19
|
+
level?: 1 | 2 | 3;
|
20
20
|
}
|
21
21
|
export type TypographyComponentProps = TypographyNumberProps | TypographySubtitleBodyMonoProps | TypographyHeadingProps;
|
22
22
|
export declare const typographyVariants: (props?: ({
|