@tecsinapse/cortex-react 2.1.0-beta.3 → 2.1.0-beta.4
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/cjs/components/PhoneInput/Option.js +3 -4
- package/dist/cjs/components/PhoneInput/Options.js +12 -4
- package/dist/cjs/components/PhoneInput/Root.js +3 -1
- package/dist/cjs/components/PhoneInput/Trigger.js +1 -1
- package/dist/esm/components/PhoneInput/Option.js +3 -4
- package/dist/esm/components/PhoneInput/Options.js +12 -4
- package/dist/esm/components/PhoneInput/Root.js +3 -1
- package/dist/esm/components/PhoneInput/Trigger.js +1 -1
- package/dist/types/components/PhoneInput/Options.d.ts +3 -1
- package/dist/types/components/PhoneInput/Root.d.ts +1 -2
- package/dist/types/components/PhoneInput/index.d.ts +4 -3
- package/package.json +2 -2
|
@@ -8,14 +8,13 @@ const PhoneInputOption = ({
|
|
|
8
8
|
disableClick = false
|
|
9
9
|
}) => {
|
|
10
10
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11
|
-
"
|
|
11
|
+
"button",
|
|
12
12
|
{
|
|
13
13
|
className: "flex w-full h-[2rem] items-center justify-between p-centi cursor-pointer hover:bg-gray-100",
|
|
14
14
|
onClick: () => {
|
|
15
|
-
|
|
16
|
-
handleSelectCountry(country);
|
|
17
|
-
}
|
|
15
|
+
handleSelectCountry(country);
|
|
18
16
|
},
|
|
17
|
+
disabled: disableClick,
|
|
19
18
|
children: [
|
|
20
19
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: country?.name }),
|
|
21
20
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-gray-400 text-sm", children: [
|
|
@@ -68,20 +68,28 @@ var reactInternationalPhone = require('react-international-phone');
|
|
|
68
68
|
const countries = reactInternationalPhone.defaultCountries.map((c) => {
|
|
69
69
|
return reactInternationalPhone.parseCountry(c);
|
|
70
70
|
});
|
|
71
|
-
const PhoneInputOptions = (
|
|
71
|
+
const PhoneInputOptions = ({
|
|
72
|
+
hasSearch = true
|
|
73
|
+
}) => {
|
|
72
74
|
const { country, setCountry, setIsOpen } = context.usePhoneContext();
|
|
73
75
|
const [searchText, setSearchText] = React.useState("");
|
|
74
76
|
const filteredCountries = React.useMemo(() => {
|
|
75
77
|
return countries.filter(
|
|
76
|
-
(c) => c.iso2 !== country?.iso2 && c.name.includes(searchText)
|
|
78
|
+
(c) => c.iso2 !== country?.iso2 && (c.name.toLowerCase().includes(searchText.toLowerCase()) || c.dialCode.includes(searchText))
|
|
77
79
|
);
|
|
78
|
-
}, [country]);
|
|
80
|
+
}, [country, searchText]);
|
|
79
81
|
const handleSelect = (country2) => {
|
|
80
82
|
setCountry?.(country2.iso2);
|
|
81
83
|
setIsOpen?.(false);
|
|
82
84
|
};
|
|
83
85
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full h-full flex flex-col overflow-y-auto", children: [
|
|
84
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
86
|
+
hasSearch ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
87
|
+
index.Input.Search,
|
|
88
|
+
{
|
|
89
|
+
onChange: (e) => setSearchText(e.target.value),
|
|
90
|
+
variants: { className: "mx-deca my-centi outline-none" }
|
|
91
|
+
}
|
|
92
|
+
) : null,
|
|
85
93
|
country ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
86
94
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
87
95
|
Option.PhoneInputOption,
|
|
@@ -25,7 +25,9 @@ const PhoneInputRoot = ({
|
|
|
25
25
|
setCountry
|
|
26
26
|
} = reactInternationalPhone.usePhoneInput({
|
|
27
27
|
countries: reactInternationalPhone.defaultCountries,
|
|
28
|
-
onChange,
|
|
28
|
+
onChange: ({ phone: phone2, ...rest }) => {
|
|
29
|
+
onChange?.(phone2, { ...rest });
|
|
30
|
+
},
|
|
29
31
|
defaultCountry,
|
|
30
32
|
value
|
|
31
33
|
});
|
|
@@ -89,7 +89,7 @@ const PhoneInputTrigger = ({
|
|
|
89
89
|
{
|
|
90
90
|
value: inputValue,
|
|
91
91
|
onChange: handlePhoneValueChange,
|
|
92
|
-
|
|
92
|
+
label: label ?? "Insert a phone number"
|
|
93
93
|
}
|
|
94
94
|
),
|
|
95
95
|
/* @__PURE__ */ jsxRuntime.jsx(index$1.Input.Right, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -6,14 +6,13 @@ const PhoneInputOption = ({
|
|
|
6
6
|
disableClick = false
|
|
7
7
|
}) => {
|
|
8
8
|
return /* @__PURE__ */ jsxs(
|
|
9
|
-
"
|
|
9
|
+
"button",
|
|
10
10
|
{
|
|
11
11
|
className: "flex w-full h-[2rem] items-center justify-between p-centi cursor-pointer hover:bg-gray-100",
|
|
12
12
|
onClick: () => {
|
|
13
|
-
|
|
14
|
-
handleSelectCountry(country);
|
|
15
|
-
}
|
|
13
|
+
handleSelectCountry(country);
|
|
16
14
|
},
|
|
15
|
+
disabled: disableClick,
|
|
17
16
|
children: [
|
|
18
17
|
/* @__PURE__ */ jsx("span", { children: country?.name }),
|
|
19
18
|
/* @__PURE__ */ jsxs("span", { className: "text-gray-400 text-sm", children: [
|
|
@@ -66,20 +66,28 @@ import { defaultCountries, parseCountry } from 'react-international-phone';
|
|
|
66
66
|
const countries = defaultCountries.map((c) => {
|
|
67
67
|
return parseCountry(c);
|
|
68
68
|
});
|
|
69
|
-
const PhoneInputOptions = (
|
|
69
|
+
const PhoneInputOptions = ({
|
|
70
|
+
hasSearch = true
|
|
71
|
+
}) => {
|
|
70
72
|
const { country, setCountry, setIsOpen } = usePhoneContext();
|
|
71
73
|
const [searchText, setSearchText] = useState("");
|
|
72
74
|
const filteredCountries = useMemo(() => {
|
|
73
75
|
return countries.filter(
|
|
74
|
-
(c) => c.iso2 !== country?.iso2 && c.name.includes(searchText)
|
|
76
|
+
(c) => c.iso2 !== country?.iso2 && (c.name.toLowerCase().includes(searchText.toLowerCase()) || c.dialCode.includes(searchText))
|
|
75
77
|
);
|
|
76
|
-
}, [country]);
|
|
78
|
+
}, [country, searchText]);
|
|
77
79
|
const handleSelect = (country2) => {
|
|
78
80
|
setCountry?.(country2.iso2);
|
|
79
81
|
setIsOpen?.(false);
|
|
80
82
|
};
|
|
81
83
|
return /* @__PURE__ */ jsxs("div", { className: "w-full h-full flex flex-col overflow-y-auto", children: [
|
|
82
|
-
/* @__PURE__ */ jsx(
|
|
84
|
+
hasSearch ? /* @__PURE__ */ jsx(
|
|
85
|
+
Input.Search,
|
|
86
|
+
{
|
|
87
|
+
onChange: (e) => setSearchText(e.target.value),
|
|
88
|
+
variants: { className: "mx-deca my-centi outline-none" }
|
|
89
|
+
}
|
|
90
|
+
) : null,
|
|
83
91
|
country ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
84
92
|
/* @__PURE__ */ jsx(
|
|
85
93
|
PhoneInputOption,
|
|
@@ -3,8 +3,7 @@ import { ParsedCountry, CountryIso2 } from 'react-international-phone';
|
|
|
3
3
|
export declare const PhoneInputRoot: ({ children, className, defaultCountry, value, onChange, }: {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
value?: string;
|
|
6
|
-
onChange?: (
|
|
7
|
-
phone: string;
|
|
6
|
+
onChange?: (value: string, rest: {
|
|
8
7
|
inputValue: string;
|
|
9
8
|
country: ParsedCountry;
|
|
10
9
|
}) => void;
|
|
@@ -2,8 +2,7 @@ export declare const PhoneInput: {
|
|
|
2
2
|
Root: ({ children, className, defaultCountry, value, onChange, }: {
|
|
3
3
|
children: import("react").ReactNode;
|
|
4
4
|
value?: string;
|
|
5
|
-
onChange?: (
|
|
6
|
-
phone: string;
|
|
5
|
+
onChange?: (value: string, rest: {
|
|
7
6
|
inputValue: string;
|
|
8
7
|
country: import("react-international-phone").ParsedCountry;
|
|
9
8
|
}) => void;
|
|
@@ -22,5 +21,7 @@ export declare const PhoneInput: {
|
|
|
22
21
|
handleSelectCountry: (country: import("react-international-phone").ParsedCountry) => void;
|
|
23
22
|
disableClick?: boolean;
|
|
24
23
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
Options: (
|
|
24
|
+
Options: ({ hasSearch, }: {
|
|
25
|
+
hasSearch?: boolean;
|
|
26
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
26
27
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.4",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"react-icons": ">=5.2.0",
|
|
50
50
|
"tailwindcss": "^4.1.16"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "a72a848da442227f7e1149ebad300d5e015c4ca5"
|
|
53
53
|
}
|