@fangzsx/component-library 0.0.28 → 0.0.30
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.
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface CountryOption {
|
|
4
|
+
iso: string;
|
|
5
|
+
country: string;
|
|
6
|
+
code: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CountryValue {
|
|
9
|
+
iso: string | null;
|
|
10
|
+
country: string | null;
|
|
11
|
+
dialCode: string | null;
|
|
12
|
+
countryCode: string | null;
|
|
13
|
+
}
|
|
14
|
+
export declare const PH_DEFAULT: CountryValue;
|
|
15
|
+
interface BaseProps {
|
|
16
|
+
options: CountryOption[];
|
|
17
|
+
value?: CountryValue;
|
|
18
|
+
onChange: (value: CountryValue) => void;
|
|
19
|
+
searchPlaceholder?: string;
|
|
20
|
+
error?: boolean;
|
|
21
|
+
helperText?: string;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
renderFlag?: (iso: string) => React.ReactNode;
|
|
24
|
+
}
|
|
25
|
+
interface PhoneMode extends BaseProps {
|
|
26
|
+
mode: "phone";
|
|
27
|
+
phoneNumber: string;
|
|
28
|
+
onPhoneChange: (value: string) => void;
|
|
29
|
+
phoneError?: boolean;
|
|
30
|
+
phoneHelperText?: string;
|
|
31
|
+
}
|
|
32
|
+
interface CountryMode extends BaseProps {
|
|
33
|
+
mode: "country";
|
|
34
|
+
phoneNumber?: never;
|
|
35
|
+
onPhoneChange?: never;
|
|
36
|
+
phoneError?: never;
|
|
37
|
+
phoneHelperText?: never;
|
|
38
|
+
}
|
|
39
|
+
export type PhoneAndCountryDropdownProps = PhoneMode | CountryMode;
|
|
40
|
+
export declare function PhoneAndCountryDropdown(props: PhoneAndCountryDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { jsx as e, jsxs as t, Fragment as N } from "react/jsx-runtime";
|
|
2
|
+
import { c as B } from "../../createSvgIcon-C0YrvByi.js";
|
|
3
|
+
import { Box as d, Typography as p, TextField as K, Popper as U, ClickAwayListener as Y, Paper as _, InputBase as G, InputAdornment as J, List as Q, ListItemButton as V, ListItemIcon as X, ListItemText as Z } from "@mui/material";
|
|
4
|
+
import { useState as v, useRef as D, useEffect as $, useMemo as ee } from "react";
|
|
5
|
+
const H = B(/* @__PURE__ */ e("path", {
|
|
6
|
+
d: "M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"
|
|
7
|
+
}), "KeyboardArrowDown"), oe = B(/* @__PURE__ */ e("path", {
|
|
8
|
+
d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"
|
|
9
|
+
}), "Search"), re = {
|
|
10
|
+
iso: "PH",
|
|
11
|
+
country: "Philippines",
|
|
12
|
+
dialCode: "63",
|
|
13
|
+
countryCode: "PH"
|
|
14
|
+
}, R = (n) => n.replace(/-/g, "");
|
|
15
|
+
function ne(n) {
|
|
16
|
+
return n.toUpperCase().split("").map((l) => String.fromCodePoint(127397 + l.charCodeAt(0))).join("");
|
|
17
|
+
}
|
|
18
|
+
function te(n) {
|
|
19
|
+
return /* @__PURE__ */ e(
|
|
20
|
+
d,
|
|
21
|
+
{
|
|
22
|
+
component: "span",
|
|
23
|
+
sx: {
|
|
24
|
+
fontSize: 20,
|
|
25
|
+
lineHeight: 1,
|
|
26
|
+
width: 24,
|
|
27
|
+
textAlign: "center",
|
|
28
|
+
userSelect: "none"
|
|
29
|
+
},
|
|
30
|
+
children: ne(n)
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function k({
|
|
35
|
+
anchorEl: n,
|
|
36
|
+
open: l,
|
|
37
|
+
options: x,
|
|
38
|
+
searchValue: o,
|
|
39
|
+
onSearchChange: w,
|
|
40
|
+
onSelect: y,
|
|
41
|
+
onClose: m,
|
|
42
|
+
showDialCode: C,
|
|
43
|
+
searchPlaceholder: i = "Search country or code",
|
|
44
|
+
renderFlag: u
|
|
45
|
+
}) {
|
|
46
|
+
const f = D(null);
|
|
47
|
+
$(() => {
|
|
48
|
+
l && setTimeout(() => f.current?.focus(), 50);
|
|
49
|
+
}, [l]);
|
|
50
|
+
const c = ee(() => {
|
|
51
|
+
const r = o.toLowerCase(), h = R(r);
|
|
52
|
+
return x.filter(
|
|
53
|
+
(a) => a.country.toLowerCase().includes(r) || a.code.includes(r) || R(a.code).includes(h) || a.iso.toLowerCase().includes(r)
|
|
54
|
+
);
|
|
55
|
+
}, [x, o]);
|
|
56
|
+
return !l || !n ? null : /* @__PURE__ */ e(
|
|
57
|
+
U,
|
|
58
|
+
{
|
|
59
|
+
open: l,
|
|
60
|
+
anchorEl: n,
|
|
61
|
+
placement: "bottom-start",
|
|
62
|
+
disablePortal: !1,
|
|
63
|
+
sx: {
|
|
64
|
+
zIndex: 1300,
|
|
65
|
+
width: Math.max(n.offsetWidth, 340)
|
|
66
|
+
},
|
|
67
|
+
modifiers: [
|
|
68
|
+
{ name: "offset", options: { offset: [0, 4] } },
|
|
69
|
+
{ name: "preventOverflow", options: { boundary: "viewport" } }
|
|
70
|
+
],
|
|
71
|
+
children: /* @__PURE__ */ e(Y, { onClickAway: m, children: /* @__PURE__ */ t(_, { elevation: 4, sx: { borderRadius: 1.5, overflow: "hidden" }, children: [
|
|
72
|
+
/* @__PURE__ */ e(d, { sx: { px: 1.5, py: 1, borderBottom: "1px solid", borderColor: "divider" }, children: /* @__PURE__ */ e(
|
|
73
|
+
G,
|
|
74
|
+
{
|
|
75
|
+
inputRef: f,
|
|
76
|
+
fullWidth: !0,
|
|
77
|
+
placeholder: i,
|
|
78
|
+
value: o,
|
|
79
|
+
onChange: (r) => w(r.target.value),
|
|
80
|
+
startAdornment: /* @__PURE__ */ e(J, { position: "start", children: /* @__PURE__ */ e(oe, { fontSize: "small", color: "action" }) }),
|
|
81
|
+
sx: { fontSize: 14 }
|
|
82
|
+
}
|
|
83
|
+
) }),
|
|
84
|
+
/* @__PURE__ */ t(
|
|
85
|
+
Q,
|
|
86
|
+
{
|
|
87
|
+
dense: !0,
|
|
88
|
+
sx: {
|
|
89
|
+
maxHeight: 240,
|
|
90
|
+
overflowY: "auto",
|
|
91
|
+
py: 0.5
|
|
92
|
+
},
|
|
93
|
+
children: [
|
|
94
|
+
c.length === 0 && /* @__PURE__ */ e(p, { variant: "body2", color: "text.secondary", sx: { px: 2, py: 1 }, children: "No results found" }),
|
|
95
|
+
c.map((r) => /* @__PURE__ */ t(
|
|
96
|
+
V,
|
|
97
|
+
{
|
|
98
|
+
onClick: () => y(r),
|
|
99
|
+
sx: { px: 2, py: 0.75 },
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ e(X, { sx: { minWidth: 36 }, children: u(r.iso) }),
|
|
102
|
+
/* @__PURE__ */ e(
|
|
103
|
+
Z,
|
|
104
|
+
{
|
|
105
|
+
primary: r.country,
|
|
106
|
+
primaryTypographyProps: { fontSize: 14 }
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
C && /* @__PURE__ */ t(p, { variant: "body2", color: "text.secondary", sx: { ml: 1, whiteSpace: "nowrap" }, children: [
|
|
110
|
+
"+",
|
|
111
|
+
r.code
|
|
112
|
+
] })
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
r.iso
|
|
116
|
+
))
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
] }) })
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
function ae(n) {
|
|
125
|
+
const {
|
|
126
|
+
mode: l,
|
|
127
|
+
options: x,
|
|
128
|
+
value: o = re,
|
|
129
|
+
onChange: w,
|
|
130
|
+
searchPlaceholder: y,
|
|
131
|
+
error: m = !1,
|
|
132
|
+
helperText: C,
|
|
133
|
+
disabled: i = !1,
|
|
134
|
+
renderFlag: u = te
|
|
135
|
+
} = n, [f, c] = v(!1), [r, h] = v(""), [a, E] = v(!1), [b, S] = v(!1), g = D(null), P = (s) => {
|
|
136
|
+
w({
|
|
137
|
+
iso: s.iso,
|
|
138
|
+
country: s.country,
|
|
139
|
+
dialCode: s.code,
|
|
140
|
+
countryCode: s.iso
|
|
141
|
+
}), c(!1), h("");
|
|
142
|
+
}, I = () => {
|
|
143
|
+
c(!1), h("");
|
|
144
|
+
};
|
|
145
|
+
if (l === "phone") {
|
|
146
|
+
const { phoneNumber: s, onPhoneChange: q, phoneError: F, phoneHelperText: M } = n, O = F || a && !s.trim(), L = M || (a && !s.trim() ? "Phone number is required" : void 0), W = m || b && !o.iso, A = C || (b && !o.iso ? "Country is required" : void 0);
|
|
147
|
+
return /* @__PURE__ */ t(d, { sx: { position: "relative" }, children: [
|
|
148
|
+
/* @__PURE__ */ t(d, { sx: { display: "flex" }, children: [
|
|
149
|
+
/* @__PURE__ */ t(
|
|
150
|
+
d,
|
|
151
|
+
{
|
|
152
|
+
ref: g,
|
|
153
|
+
tabIndex: 0,
|
|
154
|
+
onClick: () => !i && c(!0),
|
|
155
|
+
onBlur: () => S(!0),
|
|
156
|
+
sx: {
|
|
157
|
+
display: "flex",
|
|
158
|
+
alignItems: "center",
|
|
159
|
+
gap: 0.75,
|
|
160
|
+
px: 1.5,
|
|
161
|
+
height: 40,
|
|
162
|
+
border: "1px solid",
|
|
163
|
+
borderColor: W ? "error.main" : "rgba(0,0,0,0.23)",
|
|
164
|
+
borderRight: "none",
|
|
165
|
+
borderRadius: "4px 0 0 4px",
|
|
166
|
+
cursor: i ? "default" : "pointer",
|
|
167
|
+
bgcolor: "background.paper",
|
|
168
|
+
"&:hover": i ? {} : { borderColor: "rgba(0,0,0,0.87)" },
|
|
169
|
+
minWidth: 110,
|
|
170
|
+
flexShrink: 0,
|
|
171
|
+
boxSizing: "border-box",
|
|
172
|
+
outline: "none"
|
|
173
|
+
},
|
|
174
|
+
children: [
|
|
175
|
+
o.iso && /* @__PURE__ */ t(N, { children: [
|
|
176
|
+
u(o.iso),
|
|
177
|
+
/* @__PURE__ */ t(p, { variant: "body2", sx: { whiteSpace: "nowrap" }, children: [
|
|
178
|
+
"+",
|
|
179
|
+
o.dialCode
|
|
180
|
+
] })
|
|
181
|
+
] }),
|
|
182
|
+
/* @__PURE__ */ e(
|
|
183
|
+
H,
|
|
184
|
+
{
|
|
185
|
+
fontSize: "small",
|
|
186
|
+
sx: { ml: "auto", color: "action.active" }
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
/* @__PURE__ */ e(
|
|
193
|
+
K,
|
|
194
|
+
{
|
|
195
|
+
fullWidth: !0,
|
|
196
|
+
size: "small",
|
|
197
|
+
type: "tel",
|
|
198
|
+
value: s,
|
|
199
|
+
onChange: (j) => q(j.target.value),
|
|
200
|
+
onBlur: () => E(!0),
|
|
201
|
+
disabled: i,
|
|
202
|
+
error: O,
|
|
203
|
+
sx: {
|
|
204
|
+
"& .MuiOutlinedInput-root": {
|
|
205
|
+
borderRadius: "0 4px 4px 0"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
] }),
|
|
211
|
+
(A || L) && /* @__PURE__ */ e(
|
|
212
|
+
p,
|
|
213
|
+
{
|
|
214
|
+
variant: "caption",
|
|
215
|
+
color: "error",
|
|
216
|
+
sx: { display: "block", mt: 0.5, ml: 0 },
|
|
217
|
+
children: A || L
|
|
218
|
+
}
|
|
219
|
+
),
|
|
220
|
+
/* @__PURE__ */ e(
|
|
221
|
+
k,
|
|
222
|
+
{
|
|
223
|
+
anchorEl: g.current,
|
|
224
|
+
open: f,
|
|
225
|
+
options: x,
|
|
226
|
+
searchValue: r,
|
|
227
|
+
onSearchChange: h,
|
|
228
|
+
onSelect: P,
|
|
229
|
+
onClose: I,
|
|
230
|
+
showDialCode: !0,
|
|
231
|
+
searchPlaceholder: y,
|
|
232
|
+
renderFlag: u
|
|
233
|
+
}
|
|
234
|
+
)
|
|
235
|
+
] });
|
|
236
|
+
}
|
|
237
|
+
const T = m || b && !o.iso, z = C || (b && !o.iso ? "Country is required" : void 0);
|
|
238
|
+
return /* @__PURE__ */ t(d, { sx: { position: "relative" }, children: [
|
|
239
|
+
/* @__PURE__ */ t(
|
|
240
|
+
d,
|
|
241
|
+
{
|
|
242
|
+
ref: g,
|
|
243
|
+
tabIndex: 0,
|
|
244
|
+
onClick: () => !i && c(!0),
|
|
245
|
+
onBlur: () => S(!0),
|
|
246
|
+
sx: {
|
|
247
|
+
display: "flex",
|
|
248
|
+
alignItems: "center",
|
|
249
|
+
gap: 1,
|
|
250
|
+
px: 1.5,
|
|
251
|
+
height: 40,
|
|
252
|
+
border: "1px solid",
|
|
253
|
+
borderColor: T ? "error.main" : "grey.400",
|
|
254
|
+
borderRadius: "6px",
|
|
255
|
+
cursor: i ? "default" : "pointer",
|
|
256
|
+
bgcolor: "background.paper",
|
|
257
|
+
"&:hover": i ? {} : { borderColor: "grey.800" },
|
|
258
|
+
outline: "none"
|
|
259
|
+
},
|
|
260
|
+
children: [
|
|
261
|
+
o.countryCode && u(o.countryCode),
|
|
262
|
+
/* @__PURE__ */ e(
|
|
263
|
+
p,
|
|
264
|
+
{
|
|
265
|
+
variant: "body2",
|
|
266
|
+
sx: { flex: 1, color: o.country ? "text.primary" : "text.secondary" },
|
|
267
|
+
children: o.country ?? "Select country"
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
/* @__PURE__ */ e(H, { fontSize: "small", sx: { color: "action.active" } })
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
),
|
|
274
|
+
z && /* @__PURE__ */ e(p, { variant: "caption", color: T ? "error" : "text.secondary", sx: { mt: 0.5, ml: 0.5 }, children: z }),
|
|
275
|
+
/* @__PURE__ */ e(
|
|
276
|
+
k,
|
|
277
|
+
{
|
|
278
|
+
anchorEl: g.current,
|
|
279
|
+
open: f,
|
|
280
|
+
options: x,
|
|
281
|
+
searchValue: r,
|
|
282
|
+
onSearchChange: h,
|
|
283
|
+
onSelect: P,
|
|
284
|
+
onClose: I,
|
|
285
|
+
showDialCode: !1,
|
|
286
|
+
searchPlaceholder: y,
|
|
287
|
+
renderFlag: u
|
|
288
|
+
}
|
|
289
|
+
)
|
|
290
|
+
] });
|
|
291
|
+
}
|
|
292
|
+
export {
|
|
293
|
+
re as PH_DEFAULT,
|
|
294
|
+
ae as PhoneAndCountryDropdown
|
|
295
|
+
};
|
package/dist/main.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { FlatBanner } from './components/FlatBanner';
|
|
|
9
9
|
export { Label } from './components/Label';
|
|
10
10
|
export { LinearProgress } from './components/LinearProgress';
|
|
11
11
|
export { MediaCardWithAction } from './components/MediaCardWithAction';
|
|
12
|
+
export { PhoneAndCountryDropdown } from './components/PhoneAndCountryDropdown';
|
|
12
13
|
export { PromoCode } from './components/PromoCode';
|
|
13
14
|
export { RadioButtonGroup } from './components/RadioButtonGroup';
|
|
14
15
|
export { Stepper } from './components/Stepper';
|
package/dist/main.js
CHANGED
|
@@ -3,32 +3,34 @@ import { Banner as p } from "./components/Banner/index.js";
|
|
|
3
3
|
import { B as m } from "./index-CS-LWC7Z.js";
|
|
4
4
|
import { CheckBox as a } from "./components/Checkbox/index.js";
|
|
5
5
|
import { ScrollableDialog as i } from "./components/Dialog/index.js";
|
|
6
|
-
import { CheckboxGroup as
|
|
7
|
-
import { Dropdown as
|
|
8
|
-
import { FlatBanner as
|
|
9
|
-
import { Label as
|
|
10
|
-
import { LinearProgress as
|
|
11
|
-
import { MediaCardWithAction as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
6
|
+
import { CheckboxGroup as d } from "./components/CheckboxGroup/index.js";
|
|
7
|
+
import { Dropdown as B } from "./components/Dropdown/index.js";
|
|
8
|
+
import { FlatBanner as C } from "./components/FlatBanner/index.js";
|
|
9
|
+
import { Label as h } from "./components/Label/index.js";
|
|
10
|
+
import { LinearProgress as D } from "./components/LinearProgress/index.js";
|
|
11
|
+
import { MediaCardWithAction as g } from "./components/MediaCardWithAction/index.js";
|
|
12
|
+
import { PhoneAndCountryDropdown as k } from "./components/PhoneAndCountryDropdown/index.js";
|
|
13
|
+
import { PromoCode as F } from "./components/PromoCode/index.js";
|
|
14
|
+
import { RadioButtonGroup as L } from "./components/RadioButtonGroup/index.js";
|
|
15
|
+
import { Stepper as T } from "./components/Stepper/index.js";
|
|
16
|
+
import { Text as I } from "./components/Text/index.js";
|
|
17
|
+
import { TextFieldInput as R } from "./components/TextFieldInput/index.js";
|
|
17
18
|
export {
|
|
18
19
|
e as AppBarPublic,
|
|
19
20
|
p as Banner,
|
|
20
21
|
m as Button,
|
|
21
22
|
a as CheckBox,
|
|
22
|
-
|
|
23
|
+
d as CheckboxGroup,
|
|
23
24
|
i as Dialog,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
B as Dropdown,
|
|
26
|
+
C as FlatBanner,
|
|
27
|
+
h as Label,
|
|
28
|
+
D as LinearProgress,
|
|
29
|
+
g as MediaCardWithAction,
|
|
30
|
+
k as PhoneAndCountryDropdown,
|
|
31
|
+
F as PromoCode,
|
|
32
|
+
L as RadioButtonGroup,
|
|
33
|
+
T as Stepper,
|
|
34
|
+
I as Text,
|
|
35
|
+
R as TextFieldInput
|
|
34
36
|
};
|