@tecsinapse/cortex-react 2.1.0-beta.3 → 2.1.0-beta.5
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 +6 -6
- package/dist/cjs/components/PhoneInput/Trigger.js +4 -2
- 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 +6 -6
- package/dist/esm/components/PhoneInput/Trigger.js +4 -2
- package/dist/types/components/PhoneInput/Options.d.ts +3 -1
- package/dist/types/components/PhoneInput/Root.d.ts +2 -13
- package/dist/types/components/PhoneInput/Trigger.d.ts +2 -4
- package/dist/types/components/PhoneInput/index.d.ts +6 -16
- package/dist/types/components/PhoneInput/types.d.ts +13 -0
- 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,
|
|
@@ -10,9 +10,8 @@ var context = require('./context.js');
|
|
|
10
10
|
const PhoneInputRoot = ({
|
|
11
11
|
children,
|
|
12
12
|
className,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
onChange
|
|
13
|
+
onChange,
|
|
14
|
+
...rest
|
|
16
15
|
}) => {
|
|
17
16
|
const [triggerWidth, setTriggerWidth] = React.useState();
|
|
18
17
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
@@ -25,9 +24,10 @@ const PhoneInputRoot = ({
|
|
|
25
24
|
setCountry
|
|
26
25
|
} = reactInternationalPhone.usePhoneInput({
|
|
27
26
|
countries: reactInternationalPhone.defaultCountries,
|
|
28
|
-
onChange,
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
onChange: ({ phone: phone2, ...rest2 }) => {
|
|
28
|
+
onChange?.(phone2, { ...rest2 });
|
|
29
|
+
},
|
|
30
|
+
...rest
|
|
31
31
|
});
|
|
32
32
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
33
33
|
index.Popover.Root,
|
|
@@ -67,7 +67,8 @@ require('react-international-phone');
|
|
|
67
67
|
|
|
68
68
|
const PhoneInputTrigger = ({
|
|
69
69
|
disabled = false,
|
|
70
|
-
label
|
|
70
|
+
label,
|
|
71
|
+
...rest
|
|
71
72
|
}) => {
|
|
72
73
|
const {
|
|
73
74
|
setIsOpen,
|
|
@@ -89,7 +90,8 @@ const PhoneInputTrigger = ({
|
|
|
89
90
|
{
|
|
90
91
|
value: inputValue,
|
|
91
92
|
onChange: handlePhoneValueChange,
|
|
92
|
-
|
|
93
|
+
label: label ?? "Insert a phone number",
|
|
94
|
+
...rest
|
|
93
95
|
}
|
|
94
96
|
),
|
|
95
97
|
/* @__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,
|
|
@@ -8,9 +8,8 @@ import { PhoneInputContext } from './context.js';
|
|
|
8
8
|
const PhoneInputRoot = ({
|
|
9
9
|
children,
|
|
10
10
|
className,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
onChange
|
|
11
|
+
onChange,
|
|
12
|
+
...rest
|
|
14
13
|
}) => {
|
|
15
14
|
const [triggerWidth, setTriggerWidth] = useState();
|
|
16
15
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -23,9 +22,10 @@ const PhoneInputRoot = ({
|
|
|
23
22
|
setCountry
|
|
24
23
|
} = usePhoneInput({
|
|
25
24
|
countries: defaultCountries,
|
|
26
|
-
onChange,
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
onChange: ({ phone: phone2, ...rest2 }) => {
|
|
26
|
+
onChange?.(phone2, { ...rest2 });
|
|
27
|
+
},
|
|
28
|
+
...rest
|
|
29
29
|
});
|
|
30
30
|
return /* @__PURE__ */ jsx(
|
|
31
31
|
Popover.Root,
|
|
@@ -65,7 +65,8 @@ import 'react-international-phone';
|
|
|
65
65
|
|
|
66
66
|
const PhoneInputTrigger = ({
|
|
67
67
|
disabled = false,
|
|
68
|
-
label
|
|
68
|
+
label,
|
|
69
|
+
...rest
|
|
69
70
|
}) => {
|
|
70
71
|
const {
|
|
71
72
|
setIsOpen,
|
|
@@ -87,7 +88,8 @@ const PhoneInputTrigger = ({
|
|
|
87
88
|
{
|
|
88
89
|
value: inputValue,
|
|
89
90
|
onChange: handlePhoneValueChange,
|
|
90
|
-
|
|
91
|
+
label: label ?? "Insert a phone number",
|
|
92
|
+
...rest
|
|
91
93
|
}
|
|
92
94
|
),
|
|
93
95
|
/* @__PURE__ */ jsx(Input.Right, { children: /* @__PURE__ */ jsxs(
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const PhoneInputRoot: ({ children, className, defaultCountry, value, onChange, }: {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
value?: string;
|
|
6
|
-
onChange?: (data: {
|
|
7
|
-
phone: string;
|
|
8
|
-
inputValue: string;
|
|
9
|
-
country: ParsedCountry;
|
|
10
|
-
}) => void;
|
|
11
|
-
className?: string;
|
|
12
|
-
defaultCountry?: CountryIso2;
|
|
13
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import { PhoneInputRootProps } from './types';
|
|
2
|
+
export declare const PhoneInputRoot: ({ children, className, onChange, ...rest }: PhoneInputRootProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
label?: string;
|
|
4
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import { PhoneInputTriggerProps } from './types';
|
|
2
|
+
export declare const PhoneInputTrigger: ({ disabled, label, ...rest }: PhoneInputTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
export declare const PhoneInput: {
|
|
2
|
-
Root: ({ children, className,
|
|
3
|
-
children: import("react").ReactNode;
|
|
4
|
-
value?: string;
|
|
5
|
-
onChange?: (data: {
|
|
6
|
-
phone: string;
|
|
7
|
-
inputValue: string;
|
|
8
|
-
country: import("react-international-phone").ParsedCountry;
|
|
9
|
-
}) => void;
|
|
10
|
-
className?: string;
|
|
11
|
-
defaultCountry?: import("react-international-phone").CountryIso2;
|
|
12
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
Root: ({ children, className, onChange, ...rest }: import("./types").PhoneInputRootProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
3
|
Popover: ({ children }: {
|
|
14
4
|
children: import("react").ReactNode;
|
|
15
5
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
Trigger: ({ disabled, label, }:
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
label?: string;
|
|
19
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
Trigger: ({ disabled, label, ...rest }: import("./types").PhoneInputTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
7
|
Option: ({ country, handleSelectCountry, disableClick, }: {
|
|
21
8
|
country: import("react-international-phone").ParsedCountry;
|
|
22
9
|
handleSelectCountry: (country: import("react-international-phone").ParsedCountry) => void;
|
|
23
10
|
disableClick?: boolean;
|
|
24
11
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
Options: (
|
|
12
|
+
Options: ({ hasSearch, }: {
|
|
13
|
+
hasSearch?: boolean;
|
|
14
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
26
15
|
};
|
|
16
|
+
export * from './types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ParsedCountry, UsePhoneInputConfig } from 'react-international-phone';
|
|
2
|
+
import { InputPropsBase } from '../Input';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
export interface PhoneInputTriggerProps extends React.InputHTMLAttributes<HTMLInputElement>, InputPropsBase {
|
|
5
|
+
}
|
|
6
|
+
export interface PhoneInputRootProps extends Omit<UsePhoneInputConfig, 'onChange'> {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
onChange?: (value: string, rest: {
|
|
10
|
+
inputValue: string;
|
|
11
|
+
country: ParsedCountry;
|
|
12
|
+
}) => void;
|
|
13
|
+
}
|
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.5",
|
|
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": "56ae580d1fcdbfec243b25fa743438398b1883d9"
|
|
53
53
|
}
|