@fangzsx/component-library 0.0.29 → 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.
@@ -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 const PhoneAndCountryDropdown: React.FC<PhoneAndCountryDropdownProps>;
56
- export default PhoneAndCountryDropdown;
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, ""), ne = (n) => /* @__PURE__ */ e(
15
- d,
16
- {
17
- component: "span",
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 n.toUpperCase().split("").map((s) => String.fromCodePoint(127397 + s.charCodeAt(0))).join("");
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
- const k = ({
34
+ function k({
32
35
  anchorEl: n,
33
- open: s,
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
- s && setTimeout(() => f.current?.focus(), 50);
46
- }, [s]);
47
- const a = ee(() => {
48
+ l && setTimeout(() => f.current?.focus(), 50);
49
+ }, [l]);
50
+ const c = ee(() => {
48
51
  const r = o.toLowerCase(), h = R(r);
49
52
  return x.filter(
50
- (c) => c.country.toLowerCase().includes(r) || c.code.includes(r) || R(c.code).includes(h) || c.iso.toLowerCase().includes(r)
53
+ (a) => a.country.toLowerCase().includes(r) || a.code.includes(r) || R(a.code).includes(h) || a.iso.toLowerCase().includes(r)
51
54
  );
52
55
  }, [x, o]);
53
- return !s || !n ? null : /* @__PURE__ */ e(
56
+ return !l || !n ? null : /* @__PURE__ */ e(
54
57
  U,
55
58
  {
56
- open: s,
59
+ open: l,
57
60
  anchorEl: n,
58
61
  placement: "bottom-start",
59
62
  disablePortal: !1,
@@ -88,8 +91,8 @@ const k = ({
88
91
  py: 0.5
89
92
  },
90
93
  children: [
91
- a.length === 0 && /* @__PURE__ */ e(p, { variant: "body2", color: "text.secondary", sx: { px: 2, py: 1 }, children: "No results found" }),
92
- a.map((r) => /* @__PURE__ */ t(
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(
93
96
  V,
94
97
  {
95
98
  onClick: () => y(r),
@@ -117,9 +120,10 @@ const k = ({
117
120
  ] }) })
118
121
  }
119
122
  );
120
- }, ce = (n) => {
123
+ }
124
+ function ae(n) {
121
125
  const {
122
- mode: s,
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 = ne
131
- } = n, [f, a] = v(!1), [r, h] = v(""), [c, E] = v(!1), [b, S] = v(!1), g = D(null), P = (l) => {
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) => {
132
136
  w({
133
- iso: l.iso,
134
- country: l.country,
135
- dialCode: l.code,
136
- countryCode: l.iso
137
- }), a(!1), h("");
137
+ iso: s.iso,
138
+ country: s.country,
139
+ dialCode: s.code,
140
+ countryCode: s.iso
141
+ }), c(!1), h("");
138
142
  }, I = () => {
139
- a(!1), h("");
143
+ c(!1), h("");
140
144
  };
141
- if (s === "phone") {
142
- const { phoneNumber: l, onPhoneChange: q, phoneError: F, phoneHelperText: M } = n, O = F || c && !l.trim(), L = M || (c && !l.trim() ? "Phone number is required" : void 0), W = m || b && !o.iso, A = C || (b && !o.iso ? "Country is required" : void 0);
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);
143
147
  return /* @__PURE__ */ t(d, { sx: { position: "relative" }, children: [
144
148
  /* @__PURE__ */ t(d, { sx: { display: "flex" }, children: [
145
149
  /* @__PURE__ */ t(
@@ -147,7 +151,7 @@ const k = ({
147
151
  {
148
152
  ref: g,
149
153
  tabIndex: 0,
150
- onClick: () => !i && a(!0),
154
+ onClick: () => !i && c(!0),
151
155
  onBlur: () => S(!0),
152
156
  sx: {
153
157
  display: "flex",
@@ -191,7 +195,7 @@ const k = ({
191
195
  fullWidth: !0,
192
196
  size: "small",
193
197
  type: "tel",
194
- value: l,
198
+ value: s,
195
199
  onChange: (j) => q(j.target.value),
196
200
  onBlur: () => E(!0),
197
201
  disabled: i,
@@ -237,7 +241,7 @@ const k = ({
237
241
  {
238
242
  ref: g,
239
243
  tabIndex: 0,
240
- onClick: () => !i && a(!0),
244
+ onClick: () => !i && c(!0),
241
245
  onBlur: () => S(!0),
242
246
  sx: {
243
247
  display: "flex",
@@ -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 default
294
+ ae 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 B } from "./components/CheckboxGroup/index.js";
7
- import { Dropdown as u } from "./components/Dropdown/index.js";
8
- import { FlatBanner as b } from "./components/FlatBanner/index.js";
9
- import { Label as C } from "./components/Label/index.js";
10
- import { LinearProgress as h } from "./components/LinearProgress/index.js";
11
- import { MediaCardWithAction as P } from "./components/MediaCardWithAction/index.js";
12
- import { PromoCode as A } from "./components/PromoCode/index.js";
13
- import { RadioButtonGroup as G } from "./components/RadioButtonGroup/index.js";
14
- import { Stepper as S } from "./components/Stepper/index.js";
15
- import { Text as w } from "./components/Text/index.js";
16
- import { TextFieldInput as M } from "./components/TextFieldInput/index.js";
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
- B as CheckboxGroup,
23
+ d as CheckboxGroup,
23
24
  i as Dialog,
24
- u as Dropdown,
25
- b as FlatBanner,
26
- C as Label,
27
- h as LinearProgress,
28
- P as MediaCardWithAction,
29
- A as PromoCode,
30
- G as RadioButtonGroup,
31
- S as Stepper,
32
- w as Text,
33
- M as TextFieldInput
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
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fangzsx/component-library",
3
3
  "author": "Jay Gilbert Garzon",
4
4
  "private": false,
5
- "version": "0.0.29",
5
+ "version": "0.0.30",
6
6
  "type": "module",
7
7
  "main": "dist/main.js",
8
8
  "types": "dist/main.d.ts",