mcr-design-systems 1.0.21 → 1.0.22
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/components/MenuItem/index.js +29 -26
- package/dist/components/PhoneInput/index.js +124 -112
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as e, jsxs as T } from "react/jsx-runtime";
|
|
2
2
|
import * as R from "react";
|
|
3
3
|
import { cn as i } from "../../shared/utils/cn.js";
|
|
4
|
-
import { dataTestId as
|
|
5
|
-
import
|
|
4
|
+
import { dataTestId as x } from "../../shared/utils/dataTestId.js";
|
|
5
|
+
import y from "../Icon/Icon.js";
|
|
6
6
|
import { menuItemVariants as j } from "./helper/variants.js";
|
|
7
7
|
import { Typography as S } from "../Typography/index.js";
|
|
8
8
|
import { Tooltip as q } from "../Tooltip/index.js";
|
|
@@ -10,15 +10,15 @@ import { useTruncateTooltip as A } from "../../shared/hooks/useTruncateTooltip.j
|
|
|
10
10
|
const D = R.forwardRef(
|
|
11
11
|
({
|
|
12
12
|
label: m,
|
|
13
|
-
disabled:
|
|
14
|
-
icon:
|
|
15
|
-
endIcon:
|
|
16
|
-
shortcut:
|
|
17
|
-
selected:
|
|
18
|
-
showCheckmark:
|
|
19
|
-
className:
|
|
20
|
-
"data-testid":
|
|
21
|
-
onSelect:
|
|
13
|
+
disabled: g = !1,
|
|
14
|
+
icon: o,
|
|
15
|
+
endIcon: c,
|
|
16
|
+
shortcut: l,
|
|
17
|
+
selected: n = !1,
|
|
18
|
+
showCheckmark: z = !1,
|
|
19
|
+
className: f,
|
|
20
|
+
"data-testid": s,
|
|
21
|
+
onSelect: d,
|
|
22
22
|
children: u,
|
|
23
23
|
size: b,
|
|
24
24
|
variant: k,
|
|
@@ -28,13 +28,13 @@ const D = R.forwardRef(
|
|
|
28
28
|
endIconSize: E = "md",
|
|
29
29
|
...h
|
|
30
30
|
}, N) => {
|
|
31
|
-
const a = j({ size: b, variant: k, state: w, selected:
|
|
31
|
+
const a = j({ size: b, variant: k, state: w, selected: n }), { textRef: I, isTruncated: M } = A(), v = (r, t) => r ? typeof r == "string" ? /* @__PURE__ */ e(y, { name: r, size: 16, className: t }) : typeof r == "function" ? /* @__PURE__ */ e("span", { className: t, children: r(n) }) : /* @__PURE__ */ e("span", { className: t, children: r }) : null;
|
|
32
32
|
return u ? /* @__PURE__ */ e(
|
|
33
33
|
"div",
|
|
34
34
|
{
|
|
35
35
|
ref: N,
|
|
36
|
-
className: i(a.item(),
|
|
37
|
-
onClick:
|
|
36
|
+
className: i(a.item(), f),
|
|
37
|
+
onClick: d,
|
|
38
38
|
onMouseEnter: (r) => {
|
|
39
39
|
r.preventDefault();
|
|
40
40
|
},
|
|
@@ -44,7 +44,7 @@ const D = R.forwardRef(
|
|
|
44
44
|
);
|
|
45
45
|
t && document.activeElement === t && (r.currentTarget.blur(), t.focus());
|
|
46
46
|
},
|
|
47
|
-
...
|
|
47
|
+
...s && x(s),
|
|
48
48
|
...h,
|
|
49
49
|
children: u
|
|
50
50
|
}
|
|
@@ -54,37 +54,40 @@ const D = R.forwardRef(
|
|
|
54
54
|
ref: N,
|
|
55
55
|
className: i(
|
|
56
56
|
a.item({
|
|
57
|
-
disabled:
|
|
57
|
+
disabled: g
|
|
58
58
|
}),
|
|
59
|
-
|
|
59
|
+
f
|
|
60
60
|
),
|
|
61
|
-
onClick:
|
|
62
|
-
...
|
|
61
|
+
onClick: d,
|
|
62
|
+
...s && x(s),
|
|
63
63
|
...h,
|
|
64
64
|
children: [
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
z && n && /* @__PURE__ */ e("div", { className: a.indicator(), children: /* @__PURE__ */ e(y, { name: "check", size: 12 }) }),
|
|
66
|
+
o && /* @__PURE__ */ e(
|
|
67
67
|
"span",
|
|
68
68
|
{
|
|
69
69
|
className: a.iconStart({
|
|
70
70
|
size: C || "md"
|
|
71
71
|
}),
|
|
72
|
-
children: v(
|
|
72
|
+
children: v(o)
|
|
73
73
|
}
|
|
74
74
|
),
|
|
75
75
|
p ? /* @__PURE__ */ e("span", { className: a.label(), children: p }) : /* @__PURE__ */ e(q, { content: m, disabled: !M, showArrow: !1, children: /* @__PURE__ */ e(
|
|
76
76
|
S,
|
|
77
77
|
{
|
|
78
78
|
ref: I,
|
|
79
|
-
variants: "body",
|
|
79
|
+
variants: n ? "action-emphasize" : "body",
|
|
80
80
|
size: "md",
|
|
81
|
-
className: i(a.label(), "text-left"
|
|
81
|
+
className: i(a.label(), "text-left", {
|
|
82
|
+
"text-fg-selected-rest": n,
|
|
83
|
+
"text-fg-neutral-main": !n
|
|
84
|
+
}),
|
|
82
85
|
children: m
|
|
83
86
|
}
|
|
84
87
|
) }),
|
|
85
88
|
/* @__PURE__ */ T("div", { className: a.endContent(), children: [
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
l && /* @__PURE__ */ e("span", { className: a.shortcut(), children: l }),
|
|
90
|
+
c && /* @__PURE__ */ e("span", { className: a.iconEnd({ size: E || "md" }), children: v(c) })
|
|
88
91
|
] })
|
|
89
92
|
]
|
|
90
93
|
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { jsxs as m, jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import { cn as
|
|
5
|
-
import { COUNTRIES_DATA as
|
|
6
|
-
import { FLAG_POSITIONS as
|
|
7
|
-
import { FLAG_BASE64 as
|
|
8
|
-
import { phoneInputVariants as
|
|
9
|
-
import { Dropdown as
|
|
10
|
-
import { Typography as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { getExampleNumber as
|
|
14
|
-
import { AsYouType as
|
|
15
|
-
const
|
|
16
|
-
countryCode:
|
|
1
|
+
import { jsxs as m, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import * as r from "react";
|
|
3
|
+
import K from "../../node_modules/libphonenumber-js/examples.mobile.json.js";
|
|
4
|
+
import { cn as I } from "../../shared/utils/cn.js";
|
|
5
|
+
import { COUNTRIES_DATA as X } from "../../shared/flags/countries-data.js";
|
|
6
|
+
import { FLAG_POSITIONS as Z } from "../../shared/flags/flag-positions.js";
|
|
7
|
+
import { FLAG_BASE64 as ee } from "../../shared/flags/base64.js";
|
|
8
|
+
import { phoneInputVariants as te } from "./helper/variants.js";
|
|
9
|
+
import { Dropdown as oe } from "../Dropdown/index.js";
|
|
10
|
+
import { Typography as R } from "../Typography/index.js";
|
|
11
|
+
import M from "../Icon/Icon.js";
|
|
12
|
+
import ne from "./FagDefault.js";
|
|
13
|
+
import { getExampleNumber as re } from "../../node_modules/libphonenumber-js/min/exports/getExampleNumber.js";
|
|
14
|
+
import { AsYouType as ae } from "../../node_modules/libphonenumber-js/min/exports/AsYouType.js";
|
|
15
|
+
const O = ({
|
|
16
|
+
countryCode: n
|
|
17
17
|
}) => {
|
|
18
|
-
const t =
|
|
19
|
-
return /* @__PURE__ */
|
|
18
|
+
const t = Z[n];
|
|
19
|
+
return /* @__PURE__ */ i("div", { className: "w-[30px] h-[20px] overflow-hidden rounded-xs", children: t === void 0 ? /* @__PURE__ */ i(ne, {}) : /* @__PURE__ */ i(
|
|
20
20
|
"div",
|
|
21
21
|
{
|
|
22
|
-
className:
|
|
22
|
+
className: I(),
|
|
23
23
|
style: {
|
|
24
|
-
backgroundImage: `url('${
|
|
24
|
+
backgroundImage: `url('${ee}')`,
|
|
25
25
|
backgroundPosition: `${t.x}px ${t.y}px`,
|
|
26
26
|
backgroundSize: "512px 512px",
|
|
27
27
|
width: "32px",
|
|
@@ -30,91 +30,91 @@ const F = ({
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
) });
|
|
33
|
-
},
|
|
33
|
+
}, se = (n) => {
|
|
34
34
|
try {
|
|
35
|
-
const t =
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const t = re(
|
|
36
|
+
n.toUpperCase(),
|
|
37
|
+
K
|
|
38
38
|
);
|
|
39
39
|
if (t)
|
|
40
40
|
return t.formatNational();
|
|
41
41
|
} catch {
|
|
42
42
|
console.warn(
|
|
43
|
-
`Could not get example number for country code: ${
|
|
43
|
+
`Could not get example number for country code: ${n}`
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
return "Enter phone number";
|
|
47
|
-
},
|
|
48
|
-
if (!
|
|
47
|
+
}, z = (n, t) => {
|
|
48
|
+
if (!n || !n.trim()) return "";
|
|
49
49
|
try {
|
|
50
|
-
const a = new
|
|
50
|
+
const a = new ae(t.toUpperCase()), l = n.replace(/[^\d]/g, "");
|
|
51
51
|
if (!l) return "";
|
|
52
52
|
let s = "";
|
|
53
|
-
for (const
|
|
54
|
-
s = a.input(
|
|
53
|
+
for (const b of l)
|
|
54
|
+
s = a.input(b);
|
|
55
55
|
return s || l;
|
|
56
56
|
} catch {
|
|
57
|
-
return
|
|
57
|
+
return n.replace(/[^\d]/g, "") || "";
|
|
58
58
|
}
|
|
59
|
-
},
|
|
59
|
+
}, ie = r.forwardRef(
|
|
60
60
|
({
|
|
61
|
-
onCountryChange:
|
|
61
|
+
onCountryChange: n,
|
|
62
62
|
value: t = "",
|
|
63
63
|
onValueChange: a,
|
|
64
64
|
placeholder: l,
|
|
65
|
-
countries: s =
|
|
66
|
-
showSearch:
|
|
67
|
-
searchPlaceholder:
|
|
68
|
-
className:
|
|
65
|
+
countries: s = X,
|
|
66
|
+
showSearch: b = !1,
|
|
67
|
+
searchPlaceholder: k = "Search countries",
|
|
68
|
+
className: A,
|
|
69
69
|
size: p = "md",
|
|
70
|
-
"data-testid":
|
|
71
|
-
error:
|
|
72
|
-
clearText:
|
|
73
|
-
defaultCountryCode:
|
|
70
|
+
"data-testid": L,
|
|
71
|
+
error: _,
|
|
72
|
+
clearText: $,
|
|
73
|
+
defaultCountryCode: N,
|
|
74
74
|
// placeholder = 'Enter phone number',
|
|
75
|
-
...
|
|
76
|
-
},
|
|
77
|
-
const [
|
|
78
|
-
|
|
79
|
-
), [
|
|
80
|
-
|
|
81
|
-
}, []), d =
|
|
82
|
-
() => s.find((e) => e.code ===
|
|
83
|
-
[s,
|
|
75
|
+
...B
|
|
76
|
+
}, E) => {
|
|
77
|
+
const [v, j] = r.useState(!1), [U, P] = r.useState(!1), [c, V] = r.useState(
|
|
78
|
+
N || s[0]?.code || "us"
|
|
79
|
+
), [C, T] = r.useState(""), D = r.useRef(null), F = v, w = r.useCallback((e) => {
|
|
80
|
+
j(e), e || T("");
|
|
81
|
+
}, []), d = r.useMemo(
|
|
82
|
+
() => s.find((e) => e.code === c) || s[0],
|
|
83
|
+
[s, c]
|
|
84
84
|
);
|
|
85
|
-
console.log(d,
|
|
86
|
-
const
|
|
85
|
+
console.log(d, N);
|
|
86
|
+
const G = r.useMemo(() => l || se(c), [c, l]), S = te({
|
|
87
87
|
size: p,
|
|
88
|
-
opened:
|
|
89
|
-
inputFocused:
|
|
90
|
-
}),
|
|
88
|
+
opened: F,
|
|
89
|
+
inputFocused: U
|
|
90
|
+
}), Q = r.useCallback(
|
|
91
91
|
(e) => {
|
|
92
|
-
if (
|
|
93
|
-
const
|
|
92
|
+
if (n?.(e), w(!1), V(e.code), t && t.trim()) {
|
|
93
|
+
const o = z(
|
|
94
94
|
t,
|
|
95
95
|
e.code
|
|
96
96
|
);
|
|
97
97
|
a?.({
|
|
98
|
-
formatted:
|
|
98
|
+
formatted: o,
|
|
99
99
|
raw: t,
|
|
100
100
|
country: e
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
|
-
[
|
|
105
|
-
),
|
|
106
|
-
(e) => e.name.toLowerCase().includes(
|
|
104
|
+
[n, w, t, a]
|
|
105
|
+
), W = r.useMemo(() => s.filter(
|
|
106
|
+
(e) => e.name.toLowerCase().includes(C.toLowerCase()) || e.code.toLowerCase().includes(C.toLowerCase())
|
|
107
107
|
).map((e) => ({
|
|
108
108
|
label: e.name,
|
|
109
109
|
value: e.code,
|
|
110
|
-
icon: /* @__PURE__ */
|
|
110
|
+
icon: /* @__PURE__ */ i(O, { countryCode: e.code }),
|
|
111
111
|
startIconSize: "auto",
|
|
112
112
|
endIconSize: "auto",
|
|
113
|
-
endIcon: /* @__PURE__ */ m(
|
|
113
|
+
endIcon: /* @__PURE__ */ m(R, { variants: "body", size: "sm", color: "fg-neutral-subtlest", children: [
|
|
114
114
|
"+",
|
|
115
115
|
e.dial_code
|
|
116
116
|
] })
|
|
117
|
-
})), [s,
|
|
117
|
+
})), [s, C]), Y = $ ? /* @__PURE__ */ i(
|
|
118
118
|
"div",
|
|
119
119
|
{
|
|
120
120
|
onMouseDown: (e) => {
|
|
@@ -130,8 +130,8 @@ const F = ({
|
|
|
130
130
|
role: "button",
|
|
131
131
|
tabIndex: 0,
|
|
132
132
|
"aria-label": "Clear text",
|
|
133
|
-
children: /* @__PURE__ */
|
|
134
|
-
|
|
133
|
+
children: /* @__PURE__ */ i(
|
|
134
|
+
M,
|
|
135
135
|
{
|
|
136
136
|
name: "x-circle",
|
|
137
137
|
variant: "solid",
|
|
@@ -144,90 +144,102 @@ const F = ({
|
|
|
144
144
|
}
|
|
145
145
|
)
|
|
146
146
|
}
|
|
147
|
-
) : null,
|
|
147
|
+
) : null, q = r.useCallback(
|
|
148
148
|
(e) => {
|
|
149
|
-
const
|
|
150
|
-
if (
|
|
149
|
+
const o = e.target.value, f = t, u = e.target.selectionStart || 0, y = o.length < f.length;
|
|
150
|
+
if (o.length > 20) {
|
|
151
151
|
e.preventDefault();
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
|
-
if (/^[0-9\s\-()+ ]*$/.test(
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
154
|
+
if (/^[0-9\s\-()+ ]*$/.test(o) || o === "") {
|
|
155
|
+
const h = o.replace(/[^\d]/g, ""), H = f.replace(/[^\d]/g, "");
|
|
156
|
+
if (y && h === H) {
|
|
157
157
|
a?.({
|
|
158
|
-
formatted:
|
|
159
|
-
raw:
|
|
158
|
+
formatted: o,
|
|
159
|
+
raw: o.replace(/[^\d]/g, ""),
|
|
160
160
|
country: d
|
|
161
|
-
})
|
|
161
|
+
}), setTimeout(() => {
|
|
162
|
+
e.target && e.target.setSelectionRange(u, u);
|
|
163
|
+
}, 0);
|
|
162
164
|
return;
|
|
163
165
|
}
|
|
164
|
-
const
|
|
166
|
+
const g = h ? z(h, c) : "";
|
|
167
|
+
let x = u;
|
|
168
|
+
if (!y && g.length > o.length) {
|
|
169
|
+
const J = g.length - o.length;
|
|
170
|
+
x = Math.min(
|
|
171
|
+
u + J,
|
|
172
|
+
g.length
|
|
173
|
+
);
|
|
174
|
+
} else y && (x = Math.max(0, u));
|
|
165
175
|
a?.({
|
|
166
|
-
formatted:
|
|
167
|
-
raw:
|
|
176
|
+
formatted: g,
|
|
177
|
+
raw: h,
|
|
168
178
|
country: d
|
|
169
|
-
})
|
|
179
|
+
}), setTimeout(() => {
|
|
180
|
+
e.target && e.target.setSelectionRange(x, x);
|
|
181
|
+
}, 0);
|
|
170
182
|
}
|
|
171
183
|
},
|
|
172
|
-
[d, a,
|
|
184
|
+
[d, a, c, t]
|
|
173
185
|
);
|
|
174
|
-
return /* @__PURE__ */ m("div", { className:
|
|
175
|
-
/* @__PURE__ */
|
|
176
|
-
|
|
186
|
+
return /* @__PURE__ */ m("div", { className: I("flex items-center", A), ref: D, children: [
|
|
187
|
+
/* @__PURE__ */ i(
|
|
188
|
+
oe,
|
|
177
189
|
{
|
|
178
|
-
open:
|
|
179
|
-
onOpenChange:
|
|
180
|
-
items:
|
|
181
|
-
value:
|
|
190
|
+
open: v,
|
|
191
|
+
onOpenChange: w,
|
|
192
|
+
items: W,
|
|
193
|
+
value: c,
|
|
182
194
|
onValueChange: (e) => {
|
|
183
|
-
const
|
|
184
|
-
(
|
|
195
|
+
const o = s.find(
|
|
196
|
+
(f) => f.code === e
|
|
185
197
|
);
|
|
186
|
-
|
|
198
|
+
o && Q(o);
|
|
187
199
|
},
|
|
188
200
|
align: "start",
|
|
189
201
|
"data-testid": "align-start-dropdown",
|
|
190
|
-
search:
|
|
191
|
-
searchPlaceholder:
|
|
202
|
+
search: b,
|
|
203
|
+
searchPlaceholder: k,
|
|
192
204
|
enableVirtualization: !0,
|
|
193
205
|
onSearchChange: (e) => {
|
|
194
|
-
|
|
206
|
+
T(e);
|
|
195
207
|
},
|
|
196
|
-
width:
|
|
197
|
-
children: /* @__PURE__ */ m("div", { className:
|
|
198
|
-
/* @__PURE__ */
|
|
208
|
+
width: D.current?.clientWidth || "auto",
|
|
209
|
+
children: /* @__PURE__ */ m("div", { className: S.countryButton(), children: [
|
|
210
|
+
/* @__PURE__ */ i(O, { countryCode: c }),
|
|
199
211
|
/* @__PURE__ */ m("div", { className: "flex gap-xs-4", children: [
|
|
200
|
-
/* @__PURE__ */ m(
|
|
212
|
+
/* @__PURE__ */ m(R, { variants: "body", size: "md", color: "fg-neutral-main", children: [
|
|
201
213
|
"+",
|
|
202
214
|
d.dial_code
|
|
203
215
|
] }),
|
|
204
|
-
/* @__PURE__ */
|
|
216
|
+
/* @__PURE__ */ i(M, { name: F ? "chevron-up" : "chevron-down", size: 16, className: "text-fg-neutral-main" })
|
|
205
217
|
] })
|
|
206
218
|
] })
|
|
207
219
|
}
|
|
208
220
|
),
|
|
209
|
-
/* @__PURE__ */ m("div", { className:
|
|
210
|
-
/* @__PURE__ */
|
|
221
|
+
/* @__PURE__ */ m("div", { className: S.inputContainer({ error: _, size: p }), children: [
|
|
222
|
+
/* @__PURE__ */ i(
|
|
211
223
|
"input",
|
|
212
224
|
{
|
|
213
|
-
...
|
|
214
|
-
ref:
|
|
215
|
-
className:
|
|
216
|
-
placeholder:
|
|
225
|
+
...B,
|
|
226
|
+
ref: E,
|
|
227
|
+
className: I(S.input({ size: p })),
|
|
228
|
+
placeholder: G,
|
|
217
229
|
value: t,
|
|
218
|
-
onChange:
|
|
219
|
-
onFocus: () =>
|
|
220
|
-
onBlur: () =>
|
|
221
|
-
"data-testid":
|
|
230
|
+
onChange: q,
|
|
231
|
+
onFocus: () => P(!0),
|
|
232
|
+
onBlur: () => P(!1),
|
|
233
|
+
"data-testid": L
|
|
222
234
|
}
|
|
223
235
|
),
|
|
224
|
-
|
|
236
|
+
Y
|
|
225
237
|
] })
|
|
226
238
|
] });
|
|
227
239
|
}
|
|
228
240
|
);
|
|
229
|
-
|
|
241
|
+
ie.displayName = "PhoneInput";
|
|
230
242
|
export {
|
|
231
|
-
|
|
232
|
-
|
|
243
|
+
ie as PhoneInput,
|
|
244
|
+
ie as default
|
|
233
245
|
};
|