@tecsinapse/cortex-react 2.1.0-beta.1 → 2.1.0-beta.2
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 +30 -0
- package/dist/cjs/components/PhoneInput/Options.js +109 -0
- package/dist/cjs/components/PhoneInput/Popover.js +23 -0
- package/dist/cjs/components/PhoneInput/Root.js +61 -0
- package/dist/cjs/components/PhoneInput/Trigger.js +122 -0
- package/dist/cjs/components/PhoneInput/context.js +19 -0
- package/dist/cjs/components/PhoneInput/index.js +17 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/provider/ManagerContext.js +4 -0
- package/dist/esm/components/PhoneInput/Option.js +28 -0
- package/dist/esm/components/PhoneInput/Options.js +107 -0
- package/dist/esm/components/PhoneInput/Popover.js +21 -0
- package/dist/esm/components/PhoneInput/Root.js +59 -0
- package/dist/esm/components/PhoneInput/Trigger.js +120 -0
- package/dist/esm/components/PhoneInput/context.js +16 -0
- package/dist/esm/components/PhoneInput/index.js +15 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/provider/ManagerContext.js +4 -0
- package/dist/types/components/index.d.ts +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
|
|
5
|
+
const PhoneInputOption = ({
|
|
6
|
+
country,
|
|
7
|
+
handleSelectCountry,
|
|
8
|
+
disableClick = false
|
|
9
|
+
}) => {
|
|
10
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
className: "flex w-full h-[2rem] items-center justify-between p-centi cursor-pointer hover:bg-gray-100",
|
|
14
|
+
onClick: () => {
|
|
15
|
+
if (!disableClick) {
|
|
16
|
+
handleSelectCountry(country);
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
children: [
|
|
20
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: country?.name }),
|
|
21
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-gray-400 text-sm", children: [
|
|
22
|
+
"+",
|
|
23
|
+
country?.dialCode
|
|
24
|
+
] })
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.PhoneInputOption = PhoneInputOption;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var Divider = require('../Divider.js');
|
|
6
|
+
var context = require('./context.js');
|
|
7
|
+
var Option = require('./Option.js');
|
|
8
|
+
require('clsx');
|
|
9
|
+
require('../Accordion/context.js');
|
|
10
|
+
require('react-icons/lia');
|
|
11
|
+
require('@internationalized/date');
|
|
12
|
+
require('../Badge.js');
|
|
13
|
+
require('react-icons/md');
|
|
14
|
+
require('@tecsinapse/cortex-core');
|
|
15
|
+
require('react-aria');
|
|
16
|
+
require('react-stately');
|
|
17
|
+
require('../../provider/MenubarContext.js');
|
|
18
|
+
require('../../provider/SnackbarProvider.js');
|
|
19
|
+
require('../../provider/CalendarProvider.js');
|
|
20
|
+
require('../../provider/ManagerContext.js');
|
|
21
|
+
require('../Popover/Context.js');
|
|
22
|
+
require('react-dropzone');
|
|
23
|
+
require('uuid');
|
|
24
|
+
require('@floating-ui/react');
|
|
25
|
+
require('currency.js');
|
|
26
|
+
require('../Calendar/CalendarCell.js');
|
|
27
|
+
require('react-icons/fa');
|
|
28
|
+
require('react-icons/io');
|
|
29
|
+
require('embla-carousel-react');
|
|
30
|
+
require('embla-carousel-autoplay');
|
|
31
|
+
require('../ColorPicker.js');
|
|
32
|
+
require('../DatePicker/DateSegment.js');
|
|
33
|
+
require('../DatePicker/DatePickerInputBase.js');
|
|
34
|
+
require('../GroupButton.js');
|
|
35
|
+
var index = require('../Input/index.js');
|
|
36
|
+
require('../Menubar/Left.js');
|
|
37
|
+
require('../../styles/menubar.js');
|
|
38
|
+
require('../Menubar/Right.js');
|
|
39
|
+
require('../Menubar/Dropdown.js');
|
|
40
|
+
require('../Menubar/MostUsed.js');
|
|
41
|
+
require('../Menubar/MostUsedItem.js');
|
|
42
|
+
require('../Menubar/Header.js');
|
|
43
|
+
require('../Menubar/Item.js');
|
|
44
|
+
require('../../provider/CategoriesContext.js');
|
|
45
|
+
require('../Menubar/SubItem.js');
|
|
46
|
+
require('../ProgressBar/Progress.js');
|
|
47
|
+
require('../RadioButton.js');
|
|
48
|
+
require('../Select/GroupedOptions.js');
|
|
49
|
+
require('../Select/context.js');
|
|
50
|
+
require('../Select/MultiGroupedOptions.js');
|
|
51
|
+
require('../Select/MultiOptions.js');
|
|
52
|
+
require('../Select/Options.js');
|
|
53
|
+
require('../Select/Trigger.js');
|
|
54
|
+
require('../../styles/stepNodeVariants.js');
|
|
55
|
+
require('../TextArea/Box.js');
|
|
56
|
+
require('../TextArea/Face.js');
|
|
57
|
+
require('../TextArea/Left.js');
|
|
58
|
+
require('../TextArea/Right.js');
|
|
59
|
+
require('../TextArea/Root.js');
|
|
60
|
+
require('../TimePicker/TimeFieldInput.js');
|
|
61
|
+
require('../Tooltip.js');
|
|
62
|
+
require('react-icons/hi2');
|
|
63
|
+
require('react-icons/fa6');
|
|
64
|
+
require('react-dom');
|
|
65
|
+
require('react-icons/io5');
|
|
66
|
+
var reactInternationalPhone = require('react-international-phone');
|
|
67
|
+
|
|
68
|
+
const countries = reactInternationalPhone.defaultCountries.map((c) => {
|
|
69
|
+
return reactInternationalPhone.parseCountry(c);
|
|
70
|
+
});
|
|
71
|
+
const PhoneInputOptions = () => {
|
|
72
|
+
const { country, setCountry, setIsOpen } = context.usePhoneContext();
|
|
73
|
+
const [searchText, setSearchText] = React.useState("");
|
|
74
|
+
const filteredCountries = React.useMemo(() => {
|
|
75
|
+
return countries.filter(
|
|
76
|
+
(c) => c.iso2 !== country?.iso2 && c.name.includes(searchText)
|
|
77
|
+
);
|
|
78
|
+
}, [country]);
|
|
79
|
+
const handleSelect = (country2) => {
|
|
80
|
+
setCountry?.(country2.iso2);
|
|
81
|
+
setIsOpen?.(false);
|
|
82
|
+
};
|
|
83
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full h-full flex flex-col overflow-y-auto", children: [
|
|
84
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.Input.Search, { onChange: (e) => setSearchText(e.target.value) }),
|
|
85
|
+
country ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
86
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
87
|
+
Option.PhoneInputOption,
|
|
88
|
+
{
|
|
89
|
+
country,
|
|
90
|
+
handleSelectCountry: handleSelect,
|
|
91
|
+
disableClick: true
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
/* @__PURE__ */ jsxRuntime.jsx(Divider.Divider, {})
|
|
95
|
+
] }) : null,
|
|
96
|
+
filteredCountries.map((country2) => {
|
|
97
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
98
|
+
Option.PhoneInputOption,
|
|
99
|
+
{
|
|
100
|
+
country: country2,
|
|
101
|
+
handleSelectCountry: handleSelect
|
|
102
|
+
},
|
|
103
|
+
`${country2.dialCode} ${country2.iso2}`
|
|
104
|
+
);
|
|
105
|
+
})
|
|
106
|
+
] });
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
exports.PhoneInputOptions = PhoneInputOptions;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('@floating-ui/react');
|
|
5
|
+
var index = require('../Popover/index.js');
|
|
6
|
+
var context = require('./context.js');
|
|
7
|
+
|
|
8
|
+
const PhoneInputPopover = ({ children }) => {
|
|
9
|
+
const { triggerWidth } = context.usePhoneContext();
|
|
10
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.FloatingPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11
|
+
index.Popover.Content,
|
|
12
|
+
{
|
|
13
|
+
className: "bg-white shadow-md rounded-md overflow-hidden h-full max-h-[30vh] outline-none",
|
|
14
|
+
style: {
|
|
15
|
+
zIndex: 9999,
|
|
16
|
+
width: triggerWidth ? `${triggerWidth}px` : "auto"
|
|
17
|
+
},
|
|
18
|
+
children
|
|
19
|
+
}
|
|
20
|
+
) });
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.PhoneInputPopover = PhoneInputPopover;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var index = require('../Popover/index.js');
|
|
6
|
+
var clsx = require('clsx');
|
|
7
|
+
var reactInternationalPhone = require('react-international-phone');
|
|
8
|
+
var context = require('./context.js');
|
|
9
|
+
|
|
10
|
+
const PhoneInputRoot = ({
|
|
11
|
+
children,
|
|
12
|
+
className,
|
|
13
|
+
defaultCountry,
|
|
14
|
+
value,
|
|
15
|
+
onChange
|
|
16
|
+
}) => {
|
|
17
|
+
const [triggerWidth, setTriggerWidth] = React.useState();
|
|
18
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
19
|
+
const {
|
|
20
|
+
country,
|
|
21
|
+
handlePhoneValueChange,
|
|
22
|
+
inputRef,
|
|
23
|
+
inputValue,
|
|
24
|
+
phone,
|
|
25
|
+
setCountry
|
|
26
|
+
} = reactInternationalPhone.usePhoneInput({
|
|
27
|
+
countries: reactInternationalPhone.defaultCountries,
|
|
28
|
+
onChange,
|
|
29
|
+
defaultCountry,
|
|
30
|
+
value
|
|
31
|
+
});
|
|
32
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
33
|
+
index.Popover.Root,
|
|
34
|
+
{
|
|
35
|
+
placement: "bottom-start",
|
|
36
|
+
controlled: true,
|
|
37
|
+
isOpen,
|
|
38
|
+
setIsOpen,
|
|
39
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
40
|
+
context.PhoneInputContext.Provider,
|
|
41
|
+
{
|
|
42
|
+
value: {
|
|
43
|
+
triggerWidth,
|
|
44
|
+
setTriggerWidth,
|
|
45
|
+
isOpen,
|
|
46
|
+
setIsOpen,
|
|
47
|
+
country,
|
|
48
|
+
setCountry,
|
|
49
|
+
handlePhoneValueChange,
|
|
50
|
+
inputValue,
|
|
51
|
+
phone,
|
|
52
|
+
inputRef
|
|
53
|
+
},
|
|
54
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: clsx("relative w-full h-full", className), children })
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
exports.PhoneInputRoot = PhoneInputRoot;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var io5 = require('react-icons/io5');
|
|
5
|
+
require('clsx');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
require('../Accordion/context.js');
|
|
8
|
+
require('react-icons/lia');
|
|
9
|
+
require('@internationalized/date');
|
|
10
|
+
require('../Badge.js');
|
|
11
|
+
require('react-icons/md');
|
|
12
|
+
require('@tecsinapse/cortex-core');
|
|
13
|
+
require('react-aria');
|
|
14
|
+
require('react-stately');
|
|
15
|
+
require('../../provider/MenubarContext.js');
|
|
16
|
+
require('../../provider/SnackbarProvider.js');
|
|
17
|
+
require('../../provider/CalendarProvider.js');
|
|
18
|
+
require('../../provider/ManagerContext.js');
|
|
19
|
+
require('../Popover/Context.js');
|
|
20
|
+
require('react-dropzone');
|
|
21
|
+
require('uuid');
|
|
22
|
+
require('@floating-ui/react');
|
|
23
|
+
require('currency.js');
|
|
24
|
+
require('../Calendar/CalendarCell.js');
|
|
25
|
+
require('react-icons/fa');
|
|
26
|
+
require('react-icons/io');
|
|
27
|
+
require('embla-carousel-react');
|
|
28
|
+
require('embla-carousel-autoplay');
|
|
29
|
+
require('../ColorPicker.js');
|
|
30
|
+
require('../DatePicker/DateSegment.js');
|
|
31
|
+
var index = require('../Popover/index.js');
|
|
32
|
+
require('../DatePicker/DatePickerInputBase.js');
|
|
33
|
+
require('../GroupButton.js');
|
|
34
|
+
var index$1 = require('../Input/index.js');
|
|
35
|
+
require('../Menubar/Left.js');
|
|
36
|
+
require('../../styles/menubar.js');
|
|
37
|
+
require('../Menubar/Right.js');
|
|
38
|
+
require('../Menubar/Dropdown.js');
|
|
39
|
+
require('../Menubar/MostUsed.js');
|
|
40
|
+
require('../Menubar/MostUsedItem.js');
|
|
41
|
+
require('../Menubar/Header.js');
|
|
42
|
+
require('../Menubar/Item.js');
|
|
43
|
+
require('../../provider/CategoriesContext.js');
|
|
44
|
+
require('../Menubar/SubItem.js');
|
|
45
|
+
require('../ProgressBar/Progress.js');
|
|
46
|
+
require('../RadioButton.js');
|
|
47
|
+
require('../Select/GroupedOptions.js');
|
|
48
|
+
require('../Select/context.js');
|
|
49
|
+
require('../Select/MultiGroupedOptions.js');
|
|
50
|
+
require('../Select/MultiOptions.js');
|
|
51
|
+
require('../Select/Options.js');
|
|
52
|
+
require('../Select/Trigger.js');
|
|
53
|
+
require('../../styles/stepNodeVariants.js');
|
|
54
|
+
require('../TextArea/Box.js');
|
|
55
|
+
require('../TextArea/Face.js');
|
|
56
|
+
require('../TextArea/Left.js');
|
|
57
|
+
require('../TextArea/Right.js');
|
|
58
|
+
require('../TextArea/Root.js');
|
|
59
|
+
require('../TimePicker/TimeFieldInput.js');
|
|
60
|
+
require('../Tooltip.js');
|
|
61
|
+
require('react-icons/hi2');
|
|
62
|
+
require('react-icons/fa6');
|
|
63
|
+
require('react-dom');
|
|
64
|
+
require('./Options.js');
|
|
65
|
+
var context = require('./context.js');
|
|
66
|
+
require('react-international-phone');
|
|
67
|
+
|
|
68
|
+
const PhoneInputTrigger = ({
|
|
69
|
+
disabled = false,
|
|
70
|
+
label
|
|
71
|
+
}) => {
|
|
72
|
+
const {
|
|
73
|
+
setIsOpen,
|
|
74
|
+
setTriggerWidth,
|
|
75
|
+
country,
|
|
76
|
+
handlePhoneValueChange,
|
|
77
|
+
inputValue
|
|
78
|
+
} = context.usePhoneContext();
|
|
79
|
+
const triggerRef = React.useRef(null);
|
|
80
|
+
React.useEffect(() => {
|
|
81
|
+
if (triggerRef.current && setTriggerWidth) {
|
|
82
|
+
const width = triggerRef.current.getBoundingClientRect().width;
|
|
83
|
+
setTriggerWidth(width);
|
|
84
|
+
}
|
|
85
|
+
}, [triggerRef.current, setTriggerWidth]);
|
|
86
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index.Popover.Trigger, { disabled, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
87
|
+
index$1.Input.Face,
|
|
88
|
+
{
|
|
89
|
+
variants: { className: "outline-none border-1" },
|
|
90
|
+
ref: triggerRef,
|
|
91
|
+
children: [
|
|
92
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
93
|
+
index$1.Input.Box,
|
|
94
|
+
{
|
|
95
|
+
value: inputValue,
|
|
96
|
+
onChange: handlePhoneValueChange,
|
|
97
|
+
placeholder: label
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
/* @__PURE__ */ jsxRuntime.jsx(index$1.Input.Right, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
101
|
+
"div",
|
|
102
|
+
{
|
|
103
|
+
className: "flex items-center gap-1 cursor-pointer w-full",
|
|
104
|
+
onClick: () => setIsOpen?.(true),
|
|
105
|
+
children: [
|
|
106
|
+
country ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
107
|
+
"img",
|
|
108
|
+
{
|
|
109
|
+
src: `https://purecatamphetamine.github.io/country-flag-icons/3x2/${country?.iso2.toUpperCase()}.svg`,
|
|
110
|
+
className: "w-[25px]"
|
|
111
|
+
}
|
|
112
|
+
) : null,
|
|
113
|
+
/* @__PURE__ */ jsxRuntime.jsx(io5.IoChevronDown, { className: "h-full text-md" })
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
) })
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
) });
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
exports.PhoneInputTrigger = PhoneInputTrigger;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
const PhoneInputContext = React.createContext(
|
|
6
|
+
null
|
|
7
|
+
);
|
|
8
|
+
const usePhoneContext = () => {
|
|
9
|
+
const context = React.useContext(PhoneInputContext);
|
|
10
|
+
if (!context) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
"usePhoneInputContext must be used within a usePhoneInputProvider"
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
return context;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.PhoneInputContext = PhoneInputContext;
|
|
19
|
+
exports.usePhoneContext = usePhoneContext;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Option = require('./Option.js');
|
|
4
|
+
var Options = require('./Options.js');
|
|
5
|
+
var Popover = require('./Popover.js');
|
|
6
|
+
var Root = require('./Root.js');
|
|
7
|
+
var Trigger = require('./Trigger.js');
|
|
8
|
+
|
|
9
|
+
const PhoneInput = {
|
|
10
|
+
Root: Root.PhoneInputRoot,
|
|
11
|
+
Popover: Popover.PhoneInputPopover,
|
|
12
|
+
Trigger: Trigger.PhoneInputTrigger,
|
|
13
|
+
Option: Option.PhoneInputOption,
|
|
14
|
+
Options: Options.PhoneInputOptions
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.PhoneInput = PhoneInput;
|
package/dist/cjs/index.js
CHANGED
|
@@ -44,6 +44,7 @@ var TimeFieldInput = require('./components/TimePicker/TimeFieldInput.js');
|
|
|
44
44
|
var Toggle = require('./components/Toggle.js');
|
|
45
45
|
var Tooltip = require('./components/Tooltip.js');
|
|
46
46
|
var index$7 = require('./components/Uploader/index.js');
|
|
47
|
+
var index$8 = require('./components/PhoneInput/index.js');
|
|
47
48
|
var useCalendar = require('./hooks/useCalendar.js');
|
|
48
49
|
var useCalendarCell = require('./hooks/useCalendarCell.js');
|
|
49
50
|
var useCalendarGrid = require('./hooks/useCalendarGrid.js');
|
|
@@ -127,6 +128,7 @@ exports.TimeFieldInput = TimeFieldInput.TimeFieldInput;
|
|
|
127
128
|
exports.Toggle = Toggle.Toggle;
|
|
128
129
|
exports.Tooltip = Tooltip.Tooltip;
|
|
129
130
|
exports.Uploader = index$7.Uploader;
|
|
131
|
+
exports.PhoneInput = index$8.PhoneInput;
|
|
130
132
|
exports.useCalendar = useCalendar.useCalendar;
|
|
131
133
|
exports.useCalendarCell = useCalendarCell.useCalendarCell;
|
|
132
134
|
exports.useCalendarGrid = useCalendarGrid.useCalendarGrid;
|
|
@@ -66,6 +66,10 @@ require('../components/Tooltip.js');
|
|
|
66
66
|
require('react-icons/hi2');
|
|
67
67
|
require('react-icons/fa6');
|
|
68
68
|
require('react-dom');
|
|
69
|
+
require('../components/PhoneInput/Options.js');
|
|
70
|
+
require('../components/PhoneInput/context.js');
|
|
71
|
+
require('react-international-phone');
|
|
72
|
+
require('react-icons/io5');
|
|
69
73
|
|
|
70
74
|
const ManagerContext = React.createContext(null);
|
|
71
75
|
const ManagerProvider = ({ children }) => {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
const PhoneInputOption = ({
|
|
4
|
+
country,
|
|
5
|
+
handleSelectCountry,
|
|
6
|
+
disableClick = false
|
|
7
|
+
}) => {
|
|
8
|
+
return /* @__PURE__ */ jsxs(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
className: "flex w-full h-[2rem] items-center justify-between p-centi cursor-pointer hover:bg-gray-100",
|
|
12
|
+
onClick: () => {
|
|
13
|
+
if (!disableClick) {
|
|
14
|
+
handleSelectCountry(country);
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ jsx("span", { children: country?.name }),
|
|
19
|
+
/* @__PURE__ */ jsxs("span", { className: "text-gray-400 text-sm", children: [
|
|
20
|
+
"+",
|
|
21
|
+
country?.dialCode
|
|
22
|
+
] })
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { PhoneInputOption };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useMemo } from 'react';
|
|
3
|
+
import { Divider } from '../Divider.js';
|
|
4
|
+
import { usePhoneContext } from './context.js';
|
|
5
|
+
import { PhoneInputOption } from './Option.js';
|
|
6
|
+
import 'clsx';
|
|
7
|
+
import '../Accordion/context.js';
|
|
8
|
+
import 'react-icons/lia';
|
|
9
|
+
import '@internationalized/date';
|
|
10
|
+
import '../Badge.js';
|
|
11
|
+
import 'react-icons/md';
|
|
12
|
+
import '@tecsinapse/cortex-core';
|
|
13
|
+
import 'react-aria';
|
|
14
|
+
import 'react-stately';
|
|
15
|
+
import '../../provider/MenubarContext.js';
|
|
16
|
+
import '../../provider/SnackbarProvider.js';
|
|
17
|
+
import '../../provider/CalendarProvider.js';
|
|
18
|
+
import '../../provider/ManagerContext.js';
|
|
19
|
+
import '../Popover/Context.js';
|
|
20
|
+
import 'react-dropzone';
|
|
21
|
+
import 'uuid';
|
|
22
|
+
import '@floating-ui/react';
|
|
23
|
+
import 'currency.js';
|
|
24
|
+
import '../Calendar/CalendarCell.js';
|
|
25
|
+
import 'react-icons/fa';
|
|
26
|
+
import 'react-icons/io';
|
|
27
|
+
import 'embla-carousel-react';
|
|
28
|
+
import 'embla-carousel-autoplay';
|
|
29
|
+
import '../ColorPicker.js';
|
|
30
|
+
import '../DatePicker/DateSegment.js';
|
|
31
|
+
import '../DatePicker/DatePickerInputBase.js';
|
|
32
|
+
import '../GroupButton.js';
|
|
33
|
+
import { Input } from '../Input/index.js';
|
|
34
|
+
import '../Menubar/Left.js';
|
|
35
|
+
import '../../styles/menubar.js';
|
|
36
|
+
import '../Menubar/Right.js';
|
|
37
|
+
import '../Menubar/Dropdown.js';
|
|
38
|
+
import '../Menubar/MostUsed.js';
|
|
39
|
+
import '../Menubar/MostUsedItem.js';
|
|
40
|
+
import '../Menubar/Header.js';
|
|
41
|
+
import '../Menubar/Item.js';
|
|
42
|
+
import '../../provider/CategoriesContext.js';
|
|
43
|
+
import '../Menubar/SubItem.js';
|
|
44
|
+
import '../ProgressBar/Progress.js';
|
|
45
|
+
import '../RadioButton.js';
|
|
46
|
+
import '../Select/GroupedOptions.js';
|
|
47
|
+
import '../Select/context.js';
|
|
48
|
+
import '../Select/MultiGroupedOptions.js';
|
|
49
|
+
import '../Select/MultiOptions.js';
|
|
50
|
+
import '../Select/Options.js';
|
|
51
|
+
import '../Select/Trigger.js';
|
|
52
|
+
import '../../styles/stepNodeVariants.js';
|
|
53
|
+
import '../TextArea/Box.js';
|
|
54
|
+
import '../TextArea/Face.js';
|
|
55
|
+
import '../TextArea/Left.js';
|
|
56
|
+
import '../TextArea/Right.js';
|
|
57
|
+
import '../TextArea/Root.js';
|
|
58
|
+
import '../TimePicker/TimeFieldInput.js';
|
|
59
|
+
import '../Tooltip.js';
|
|
60
|
+
import 'react-icons/hi2';
|
|
61
|
+
import 'react-icons/fa6';
|
|
62
|
+
import 'react-dom';
|
|
63
|
+
import 'react-icons/io5';
|
|
64
|
+
import { defaultCountries, parseCountry } from 'react-international-phone';
|
|
65
|
+
|
|
66
|
+
const countries = defaultCountries.map((c) => {
|
|
67
|
+
return parseCountry(c);
|
|
68
|
+
});
|
|
69
|
+
const PhoneInputOptions = () => {
|
|
70
|
+
const { country, setCountry, setIsOpen } = usePhoneContext();
|
|
71
|
+
const [searchText, setSearchText] = useState("");
|
|
72
|
+
const filteredCountries = useMemo(() => {
|
|
73
|
+
return countries.filter(
|
|
74
|
+
(c) => c.iso2 !== country?.iso2 && c.name.includes(searchText)
|
|
75
|
+
);
|
|
76
|
+
}, [country]);
|
|
77
|
+
const handleSelect = (country2) => {
|
|
78
|
+
setCountry?.(country2.iso2);
|
|
79
|
+
setIsOpen?.(false);
|
|
80
|
+
};
|
|
81
|
+
return /* @__PURE__ */ jsxs("div", { className: "w-full h-full flex flex-col overflow-y-auto", children: [
|
|
82
|
+
/* @__PURE__ */ jsx(Input.Search, { onChange: (e) => setSearchText(e.target.value) }),
|
|
83
|
+
country ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
84
|
+
/* @__PURE__ */ jsx(
|
|
85
|
+
PhoneInputOption,
|
|
86
|
+
{
|
|
87
|
+
country,
|
|
88
|
+
handleSelectCountry: handleSelect,
|
|
89
|
+
disableClick: true
|
|
90
|
+
}
|
|
91
|
+
),
|
|
92
|
+
/* @__PURE__ */ jsx(Divider, {})
|
|
93
|
+
] }) : null,
|
|
94
|
+
filteredCountries.map((country2) => {
|
|
95
|
+
return /* @__PURE__ */ jsx(
|
|
96
|
+
PhoneInputOption,
|
|
97
|
+
{
|
|
98
|
+
country: country2,
|
|
99
|
+
handleSelectCountry: handleSelect
|
|
100
|
+
},
|
|
101
|
+
`${country2.dialCode} ${country2.iso2}`
|
|
102
|
+
);
|
|
103
|
+
})
|
|
104
|
+
] });
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { PhoneInputOptions };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { FloatingPortal } from '@floating-ui/react';
|
|
3
|
+
import { Popover } from '../Popover/index.js';
|
|
4
|
+
import { usePhoneContext } from './context.js';
|
|
5
|
+
|
|
6
|
+
const PhoneInputPopover = ({ children }) => {
|
|
7
|
+
const { triggerWidth } = usePhoneContext();
|
|
8
|
+
return /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(
|
|
9
|
+
Popover.Content,
|
|
10
|
+
{
|
|
11
|
+
className: "bg-white shadow-md rounded-md overflow-hidden h-full max-h-[30vh] outline-none",
|
|
12
|
+
style: {
|
|
13
|
+
zIndex: 9999,
|
|
14
|
+
width: triggerWidth ? `${triggerWidth}px` : "auto"
|
|
15
|
+
},
|
|
16
|
+
children
|
|
17
|
+
}
|
|
18
|
+
) });
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { PhoneInputPopover };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Popover } from '../Popover/index.js';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { usePhoneInput, defaultCountries } from 'react-international-phone';
|
|
6
|
+
import { PhoneInputContext } from './context.js';
|
|
7
|
+
|
|
8
|
+
const PhoneInputRoot = ({
|
|
9
|
+
children,
|
|
10
|
+
className,
|
|
11
|
+
defaultCountry,
|
|
12
|
+
value,
|
|
13
|
+
onChange
|
|
14
|
+
}) => {
|
|
15
|
+
const [triggerWidth, setTriggerWidth] = useState();
|
|
16
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
17
|
+
const {
|
|
18
|
+
country,
|
|
19
|
+
handlePhoneValueChange,
|
|
20
|
+
inputRef,
|
|
21
|
+
inputValue,
|
|
22
|
+
phone,
|
|
23
|
+
setCountry
|
|
24
|
+
} = usePhoneInput({
|
|
25
|
+
countries: defaultCountries,
|
|
26
|
+
onChange,
|
|
27
|
+
defaultCountry,
|
|
28
|
+
value
|
|
29
|
+
});
|
|
30
|
+
return /* @__PURE__ */ jsx(
|
|
31
|
+
Popover.Root,
|
|
32
|
+
{
|
|
33
|
+
placement: "bottom-start",
|
|
34
|
+
controlled: true,
|
|
35
|
+
isOpen,
|
|
36
|
+
setIsOpen,
|
|
37
|
+
children: /* @__PURE__ */ jsx(
|
|
38
|
+
PhoneInputContext.Provider,
|
|
39
|
+
{
|
|
40
|
+
value: {
|
|
41
|
+
triggerWidth,
|
|
42
|
+
setTriggerWidth,
|
|
43
|
+
isOpen,
|
|
44
|
+
setIsOpen,
|
|
45
|
+
country,
|
|
46
|
+
setCountry,
|
|
47
|
+
handlePhoneValueChange,
|
|
48
|
+
inputValue,
|
|
49
|
+
phone,
|
|
50
|
+
inputRef
|
|
51
|
+
},
|
|
52
|
+
children: /* @__PURE__ */ jsx("div", { className: clsx("relative w-full h-full", className), children })
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export { PhoneInputRoot };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { IoChevronDown } from 'react-icons/io5';
|
|
3
|
+
import 'clsx';
|
|
4
|
+
import { useRef, useEffect } from 'react';
|
|
5
|
+
import '../Accordion/context.js';
|
|
6
|
+
import 'react-icons/lia';
|
|
7
|
+
import '@internationalized/date';
|
|
8
|
+
import '../Badge.js';
|
|
9
|
+
import 'react-icons/md';
|
|
10
|
+
import '@tecsinapse/cortex-core';
|
|
11
|
+
import 'react-aria';
|
|
12
|
+
import 'react-stately';
|
|
13
|
+
import '../../provider/MenubarContext.js';
|
|
14
|
+
import '../../provider/SnackbarProvider.js';
|
|
15
|
+
import '../../provider/CalendarProvider.js';
|
|
16
|
+
import '../../provider/ManagerContext.js';
|
|
17
|
+
import '../Popover/Context.js';
|
|
18
|
+
import 'react-dropzone';
|
|
19
|
+
import 'uuid';
|
|
20
|
+
import '@floating-ui/react';
|
|
21
|
+
import 'currency.js';
|
|
22
|
+
import '../Calendar/CalendarCell.js';
|
|
23
|
+
import 'react-icons/fa';
|
|
24
|
+
import 'react-icons/io';
|
|
25
|
+
import 'embla-carousel-react';
|
|
26
|
+
import 'embla-carousel-autoplay';
|
|
27
|
+
import '../ColorPicker.js';
|
|
28
|
+
import '../DatePicker/DateSegment.js';
|
|
29
|
+
import { Popover } from '../Popover/index.js';
|
|
30
|
+
import '../DatePicker/DatePickerInputBase.js';
|
|
31
|
+
import '../GroupButton.js';
|
|
32
|
+
import { Input } from '../Input/index.js';
|
|
33
|
+
import '../Menubar/Left.js';
|
|
34
|
+
import '../../styles/menubar.js';
|
|
35
|
+
import '../Menubar/Right.js';
|
|
36
|
+
import '../Menubar/Dropdown.js';
|
|
37
|
+
import '../Menubar/MostUsed.js';
|
|
38
|
+
import '../Menubar/MostUsedItem.js';
|
|
39
|
+
import '../Menubar/Header.js';
|
|
40
|
+
import '../Menubar/Item.js';
|
|
41
|
+
import '../../provider/CategoriesContext.js';
|
|
42
|
+
import '../Menubar/SubItem.js';
|
|
43
|
+
import '../ProgressBar/Progress.js';
|
|
44
|
+
import '../RadioButton.js';
|
|
45
|
+
import '../Select/GroupedOptions.js';
|
|
46
|
+
import '../Select/context.js';
|
|
47
|
+
import '../Select/MultiGroupedOptions.js';
|
|
48
|
+
import '../Select/MultiOptions.js';
|
|
49
|
+
import '../Select/Options.js';
|
|
50
|
+
import '../Select/Trigger.js';
|
|
51
|
+
import '../../styles/stepNodeVariants.js';
|
|
52
|
+
import '../TextArea/Box.js';
|
|
53
|
+
import '../TextArea/Face.js';
|
|
54
|
+
import '../TextArea/Left.js';
|
|
55
|
+
import '../TextArea/Right.js';
|
|
56
|
+
import '../TextArea/Root.js';
|
|
57
|
+
import '../TimePicker/TimeFieldInput.js';
|
|
58
|
+
import '../Tooltip.js';
|
|
59
|
+
import 'react-icons/hi2';
|
|
60
|
+
import 'react-icons/fa6';
|
|
61
|
+
import 'react-dom';
|
|
62
|
+
import './Options.js';
|
|
63
|
+
import { usePhoneContext } from './context.js';
|
|
64
|
+
import 'react-international-phone';
|
|
65
|
+
|
|
66
|
+
const PhoneInputTrigger = ({
|
|
67
|
+
disabled = false,
|
|
68
|
+
label
|
|
69
|
+
}) => {
|
|
70
|
+
const {
|
|
71
|
+
setIsOpen,
|
|
72
|
+
setTriggerWidth,
|
|
73
|
+
country,
|
|
74
|
+
handlePhoneValueChange,
|
|
75
|
+
inputValue
|
|
76
|
+
} = usePhoneContext();
|
|
77
|
+
const triggerRef = useRef(null);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (triggerRef.current && setTriggerWidth) {
|
|
80
|
+
const width = triggerRef.current.getBoundingClientRect().width;
|
|
81
|
+
setTriggerWidth(width);
|
|
82
|
+
}
|
|
83
|
+
}, [triggerRef.current, setTriggerWidth]);
|
|
84
|
+
return /* @__PURE__ */ jsx(Popover.Trigger, { disabled, children: /* @__PURE__ */ jsxs(
|
|
85
|
+
Input.Face,
|
|
86
|
+
{
|
|
87
|
+
variants: { className: "outline-none border-1" },
|
|
88
|
+
ref: triggerRef,
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ jsx(
|
|
91
|
+
Input.Box,
|
|
92
|
+
{
|
|
93
|
+
value: inputValue,
|
|
94
|
+
onChange: handlePhoneValueChange,
|
|
95
|
+
placeholder: label
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
/* @__PURE__ */ jsx(Input.Right, { children: /* @__PURE__ */ jsxs(
|
|
99
|
+
"div",
|
|
100
|
+
{
|
|
101
|
+
className: "flex items-center gap-1 cursor-pointer w-full",
|
|
102
|
+
onClick: () => setIsOpen?.(true),
|
|
103
|
+
children: [
|
|
104
|
+
country ? /* @__PURE__ */ jsx(
|
|
105
|
+
"img",
|
|
106
|
+
{
|
|
107
|
+
src: `https://purecatamphetamine.github.io/country-flag-icons/3x2/${country?.iso2.toUpperCase()}.svg`,
|
|
108
|
+
className: "w-[25px]"
|
|
109
|
+
}
|
|
110
|
+
) : null,
|
|
111
|
+
/* @__PURE__ */ jsx(IoChevronDown, { className: "h-full text-md" })
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
) })
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
) });
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export { PhoneInputTrigger };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const PhoneInputContext = createContext(
|
|
4
|
+
null
|
|
5
|
+
);
|
|
6
|
+
const usePhoneContext = () => {
|
|
7
|
+
const context = useContext(PhoneInputContext);
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error(
|
|
10
|
+
"usePhoneInputContext must be used within a usePhoneInputProvider"
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
return context;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { PhoneInputContext, usePhoneContext };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PhoneInputOption } from './Option.js';
|
|
2
|
+
import { PhoneInputOptions } from './Options.js';
|
|
3
|
+
import { PhoneInputPopover } from './Popover.js';
|
|
4
|
+
import { PhoneInputRoot } from './Root.js';
|
|
5
|
+
import { PhoneInputTrigger } from './Trigger.js';
|
|
6
|
+
|
|
7
|
+
const PhoneInput = {
|
|
8
|
+
Root: PhoneInputRoot,
|
|
9
|
+
Popover: PhoneInputPopover,
|
|
10
|
+
Trigger: PhoneInputTrigger,
|
|
11
|
+
Option: PhoneInputOption,
|
|
12
|
+
Options: PhoneInputOptions
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { PhoneInput };
|
package/dist/esm/index.js
CHANGED
|
@@ -42,6 +42,7 @@ export { TimeFieldInput } from './components/TimePicker/TimeFieldInput.js';
|
|
|
42
42
|
export { Toggle } from './components/Toggle.js';
|
|
43
43
|
export { Tooltip } from './components/Tooltip.js';
|
|
44
44
|
export { Uploader } from './components/Uploader/index.js';
|
|
45
|
+
export { PhoneInput } from './components/PhoneInput/index.js';
|
|
45
46
|
export { useCalendar } from './hooks/useCalendar.js';
|
|
46
47
|
export { useCalendarCell } from './hooks/useCalendarCell.js';
|
|
47
48
|
export { useCalendarGrid } from './hooks/useCalendarGrid.js';
|
|
@@ -64,6 +64,10 @@ import '../components/Tooltip.js';
|
|
|
64
64
|
import 'react-icons/hi2';
|
|
65
65
|
import 'react-icons/fa6';
|
|
66
66
|
import 'react-dom';
|
|
67
|
+
import '../components/PhoneInput/Options.js';
|
|
68
|
+
import '../components/PhoneInput/context.js';
|
|
69
|
+
import 'react-international-phone';
|
|
70
|
+
import 'react-icons/io5';
|
|
67
71
|
|
|
68
72
|
const ManagerContext = createContext(null);
|
|
69
73
|
const ManagerProvider = ({ children }) => {
|
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.2",
|
|
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": "36974495059d2d5bba9fdaf2ef46a82eb44bfeb4"
|
|
53
53
|
}
|