@fangzsx/component-library 0.0.29 → 0.0.31
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.
|
@@ -3,7 +3,7 @@ import { default as React } from 'react';
|
|
|
3
3
|
export interface CountryOption {
|
|
4
4
|
iso: string;
|
|
5
5
|
country: string;
|
|
6
|
-
|
|
6
|
+
dialCode: string;
|
|
7
7
|
}
|
|
8
8
|
export interface CountryValue {
|
|
9
9
|
iso: string | null;
|
|
@@ -11,40 +11,25 @@ export interface CountryValue {
|
|
|
11
11
|
dialCode: string | null;
|
|
12
12
|
countryCode: string | null;
|
|
13
13
|
}
|
|
14
|
-
/** Default country value — Philippines (+63) */
|
|
15
14
|
export declare const PH_DEFAULT: CountryValue;
|
|
16
15
|
interface BaseProps {
|
|
17
|
-
/** List of available countries */
|
|
18
16
|
options: CountryOption[];
|
|
19
|
-
/** Currently selected country value (defaults to Philippines) */
|
|
20
17
|
value?: CountryValue;
|
|
21
|
-
/** Called when the country selection changes */
|
|
22
18
|
onChange: (value: CountryValue) => void;
|
|
23
|
-
/** Placeholder for the search input inside the dropdown */
|
|
24
19
|
searchPlaceholder?: string;
|
|
25
|
-
/** If true, shows inline validation error styling */
|
|
26
20
|
error?: boolean;
|
|
27
|
-
/** Helper text shown below the input */
|
|
28
21
|
helperText?: string;
|
|
29
|
-
/** Disables the entire component */
|
|
30
22
|
disabled?: boolean;
|
|
31
|
-
/** Optional flag renderer — receives ISO code, return a ReactNode */
|
|
32
23
|
renderFlag?: (iso: string) => React.ReactNode;
|
|
33
24
|
}
|
|
34
25
|
interface PhoneMode extends BaseProps {
|
|
35
|
-
/** Renders phone input alongside the country dropdown */
|
|
36
26
|
mode: "phone";
|
|
37
|
-
/** Current phone number value */
|
|
38
27
|
phoneNumber: string;
|
|
39
|
-
/** Called when the phone number changes */
|
|
40
28
|
onPhoneChange: (value: string) => void;
|
|
41
|
-
/** If true, shows inline validation error on the phone input */
|
|
42
29
|
phoneError?: boolean;
|
|
43
|
-
/** Helper text for the phone input */
|
|
44
30
|
phoneHelperText?: string;
|
|
45
31
|
}
|
|
46
32
|
interface CountryMode extends BaseProps {
|
|
47
|
-
/** Renders a country-only dropdown (no phone input) */
|
|
48
33
|
mode: "country";
|
|
49
34
|
phoneNumber?: never;
|
|
50
35
|
onPhoneChange?: never;
|
|
@@ -52,5 +37,5 @@ interface CountryMode extends BaseProps {
|
|
|
52
37
|
phoneHelperText?: never;
|
|
53
38
|
}
|
|
54
39
|
export type PhoneAndCountryDropdownProps = PhoneMode | CountryMode;
|
|
55
|
-
declare
|
|
56
|
-
export
|
|
40
|
+
export declare function PhoneAndCountryDropdown(props: PhoneAndCountryDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export {};
|
|
@@ -11,26 +11,29 @@ const H = B(/* @__PURE__ */ e("path", {
|
|
|
11
11
|
country: "Philippines",
|
|
12
12
|
dialCode: "63",
|
|
13
13
|
countryCode: "PH"
|
|
14
|
-
}, R = (n) => n.replace(/-/g, "")
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
sx: {
|
|
19
|
-
fontSize: 20,
|
|
20
|
-
lineHeight: 1,
|
|
21
|
-
width: 24,
|
|
22
|
-
textAlign: "center",
|
|
23
|
-
userSelect: "none"
|
|
24
|
-
},
|
|
25
|
-
children: te(n)
|
|
26
|
-
}
|
|
27
|
-
);
|
|
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
|
+
}
|
|
28
18
|
function te(n) {
|
|
29
|
-
return
|
|
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
|
+
);
|
|
30
33
|
}
|
|
31
|
-
|
|
34
|
+
function k({
|
|
32
35
|
anchorEl: n,
|
|
33
|
-
open:
|
|
36
|
+
open: l,
|
|
34
37
|
options: x,
|
|
35
38
|
searchValue: o,
|
|
36
39
|
onSearchChange: w,
|
|
@@ -39,21 +42,21 @@ const k = ({
|
|
|
39
42
|
showDialCode: C,
|
|
40
43
|
searchPlaceholder: i = "Search country or code",
|
|
41
44
|
renderFlag: u
|
|
42
|
-
})
|
|
45
|
+
}) {
|
|
43
46
|
const f = D(null);
|
|
44
47
|
$(() => {
|
|
45
|
-
|
|
46
|
-
}, [
|
|
48
|
+
l && setTimeout(() => f.current?.focus(), 50);
|
|
49
|
+
}, [l]);
|
|
47
50
|
const a = ee(() => {
|
|
48
51
|
const r = o.toLowerCase(), h = R(r);
|
|
49
52
|
return x.filter(
|
|
50
|
-
(c) => c.country.toLowerCase().includes(r) || c.
|
|
53
|
+
(c) => c.country.toLowerCase().includes(r) || c.dialCode.includes(r) || R(c.dialCode).includes(h) || c.iso.toLowerCase().includes(r)
|
|
51
54
|
);
|
|
52
55
|
}, [x, o]);
|
|
53
|
-
return !
|
|
56
|
+
return !l || !n ? null : /* @__PURE__ */ e(
|
|
54
57
|
U,
|
|
55
58
|
{
|
|
56
|
-
open:
|
|
59
|
+
open: l,
|
|
57
60
|
anchorEl: n,
|
|
58
61
|
placement: "bottom-start",
|
|
59
62
|
disablePortal: !1,
|
|
@@ -105,7 +108,7 @@ const k = ({
|
|
|
105
108
|
),
|
|
106
109
|
C && /* @__PURE__ */ t(p, { variant: "body2", color: "text.secondary", sx: { ml: 1, whiteSpace: "nowrap" }, children: [
|
|
107
110
|
"+",
|
|
108
|
-
r.
|
|
111
|
+
r.dialCode
|
|
109
112
|
] })
|
|
110
113
|
]
|
|
111
114
|
},
|
|
@@ -117,9 +120,10 @@ const k = ({
|
|
|
117
120
|
] }) })
|
|
118
121
|
}
|
|
119
122
|
);
|
|
120
|
-
}
|
|
123
|
+
}
|
|
124
|
+
function ce(n) {
|
|
121
125
|
const {
|
|
122
|
-
mode:
|
|
126
|
+
mode: l,
|
|
123
127
|
options: x,
|
|
124
128
|
value: o = re,
|
|
125
129
|
onChange: w,
|
|
@@ -127,19 +131,19 @@ const k = ({
|
|
|
127
131
|
error: m = !1,
|
|
128
132
|
helperText: C,
|
|
129
133
|
disabled: i = !1,
|
|
130
|
-
renderFlag: u =
|
|
131
|
-
} = n, [f, a] = v(!1), [r, h] = v(""), [c, E] = v(!1), [b, S] = v(!1), g = D(null), P = (
|
|
134
|
+
renderFlag: u = te
|
|
135
|
+
} = n, [f, a] = v(!1), [r, h] = v(""), [c, E] = v(!1), [b, S] = v(!1), g = D(null), P = (s) => {
|
|
132
136
|
w({
|
|
133
|
-
iso:
|
|
134
|
-
country:
|
|
135
|
-
dialCode:
|
|
136
|
-
countryCode:
|
|
137
|
+
iso: s.iso,
|
|
138
|
+
country: s.country,
|
|
139
|
+
dialCode: s.dialCode,
|
|
140
|
+
countryCode: s.iso
|
|
137
141
|
}), a(!1), h("");
|
|
138
142
|
}, I = () => {
|
|
139
143
|
a(!1), h("");
|
|
140
144
|
};
|
|
141
|
-
if (
|
|
142
|
-
const { phoneNumber:
|
|
145
|
+
if (l === "phone") {
|
|
146
|
+
const { phoneNumber: s, onPhoneChange: q, phoneError: F, phoneHelperText: M } = n, O = F || c && !s.trim(), L = M || (c && !s.trim() ? "Phone number is required" : void 0), W = m || b && !o.iso, A = C || (b && !o.iso ? "Country is required" : void 0);
|
|
143
147
|
return /* @__PURE__ */ t(d, { sx: { position: "relative" }, children: [
|
|
144
148
|
/* @__PURE__ */ t(d, { sx: { display: "flex" }, children: [
|
|
145
149
|
/* @__PURE__ */ t(
|
|
@@ -191,7 +195,7 @@ const k = ({
|
|
|
191
195
|
fullWidth: !0,
|
|
192
196
|
size: "small",
|
|
193
197
|
type: "tel",
|
|
194
|
-
value:
|
|
198
|
+
value: s,
|
|
195
199
|
onChange: (j) => q(j.target.value),
|
|
196
200
|
onBlur: () => E(!0),
|
|
197
201
|
disabled: i,
|
|
@@ -284,8 +288,8 @@ const k = ({
|
|
|
284
288
|
}
|
|
285
289
|
)
|
|
286
290
|
] });
|
|
287
|
-
}
|
|
291
|
+
}
|
|
288
292
|
export {
|
|
289
293
|
re as PH_DEFAULT,
|
|
290
|
-
ce as
|
|
294
|
+
ce as PhoneAndCountryDropdown
|
|
291
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
|
};
|