@tecsinapse/cortex-react 2.1.1-beta.3 → 2.1.1

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.
Files changed (31) hide show
  1. package/dist/cjs/components/PhoneInput/FlagIcon.js +46 -0
  2. package/dist/cjs/components/PhoneInput/Option.js +29 -0
  3. package/dist/cjs/components/PhoneInput/Options.js +118 -0
  4. package/dist/cjs/components/PhoneInput/Popover.js +22 -0
  5. package/dist/cjs/components/PhoneInput/Root.js +61 -0
  6. package/dist/cjs/components/PhoneInput/Trigger.js +112 -0
  7. package/dist/cjs/components/PhoneInput/context.js +19 -0
  8. package/dist/cjs/components/PhoneInput/index.js +17 -0
  9. package/dist/cjs/index.js +2 -0
  10. package/dist/cjs/provider/ManagerContext.js +5 -0
  11. package/dist/esm/components/PhoneInput/FlagIcon.js +25 -0
  12. package/dist/esm/components/PhoneInput/Option.js +27 -0
  13. package/dist/esm/components/PhoneInput/Options.js +116 -0
  14. package/dist/esm/components/PhoneInput/Popover.js +20 -0
  15. package/dist/esm/components/PhoneInput/Root.js +59 -0
  16. package/dist/esm/components/PhoneInput/Trigger.js +110 -0
  17. package/dist/esm/components/PhoneInput/context.js +16 -0
  18. package/dist/esm/components/PhoneInput/index.js +15 -0
  19. package/dist/esm/index.js +1 -0
  20. package/dist/esm/provider/ManagerContext.js +5 -0
  21. package/dist/types/components/PhoneInput/FlagIcon.d.ts +8 -0
  22. package/dist/types/components/PhoneInput/Option.d.ts +6 -0
  23. package/dist/types/components/PhoneInput/Options.d.ts +3 -0
  24. package/dist/types/components/PhoneInput/Popover.d.ts +4 -0
  25. package/dist/types/components/PhoneInput/Root.d.ts +2 -0
  26. package/dist/types/components/PhoneInput/Trigger.d.ts +2 -0
  27. package/dist/types/components/PhoneInput/context.d.ts +15 -0
  28. package/dist/types/components/PhoneInput/index.d.ts +16 -0
  29. package/dist/types/components/PhoneInput/types.d.ts +13 -0
  30. package/dist/types/components/index.d.ts +1 -0
  31. package/package.json +5 -3
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var Flags = require('country-flag-icons/react/3x2');
5
+
6
+ function _interopNamespaceDefault(e) {
7
+ var n = Object.create(null);
8
+ if (e) {
9
+ Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default') {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n.default = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ var Flags__namespace = /*#__PURE__*/_interopNamespaceDefault(Flags);
24
+
25
+ const FlagIcon = ({
26
+ countryCode,
27
+ className = "w-[25px]",
28
+ title
29
+ }) => {
30
+ if (!countryCode) return null;
31
+ const upperCode = countryCode.toUpperCase();
32
+ const FlagComponent = Flags__namespace[upperCode];
33
+ if (!FlagComponent) {
34
+ return null;
35
+ }
36
+ return /* @__PURE__ */ jsxRuntime.jsx(
37
+ FlagComponent,
38
+ {
39
+ className,
40
+ title: title || upperCode,
41
+ "aria-label": `Flag of ${upperCode}`
42
+ }
43
+ );
44
+ };
45
+
46
+ exports.FlagIcon = FlagIcon;
@@ -0,0 +1,29 @@
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
+ "button",
12
+ {
13
+ className: "flex w-full h-[2rem] items-center justify-between p-centi cursor-pointer hover:bg-secondary-xlight bg-inherit",
14
+ onClick: () => {
15
+ handleSelectCountry(country);
16
+ },
17
+ disabled: disableClick,
18
+ children: [
19
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: country?.name }),
20
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-secondary-light text-sm", children: [
21
+ "+",
22
+ country?.dialCode
23
+ ] })
24
+ ]
25
+ }
26
+ );
27
+ };
28
+
29
+ exports.PhoneInputOption = PhoneInputOption;
@@ -0,0 +1,118 @@
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
+ require('country-flag-icons/react/3x2');
68
+
69
+ const countries = reactInternationalPhone.defaultCountries.map((c) => {
70
+ return reactInternationalPhone.parseCountry(c);
71
+ });
72
+ const PhoneInputOptions = ({
73
+ hasSearch = true
74
+ }) => {
75
+ const { country, setCountry, setIsOpen } = context.usePhoneContext();
76
+ const [searchText, setSearchText] = React.useState("");
77
+ const filteredCountries = React.useMemo(() => {
78
+ return countries.filter(
79
+ (c) => c.iso2 !== country?.iso2 && (c.name.toLowerCase().includes(searchText.toLowerCase()) || c.dialCode.includes(searchText))
80
+ );
81
+ }, [country, searchText]);
82
+ const handleSelect = (country2) => {
83
+ setCountry?.(country2.iso2);
84
+ setIsOpen?.(false);
85
+ };
86
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full h-full flex flex-col overflow-y-auto", children: [
87
+ hasSearch ? /* @__PURE__ */ jsxRuntime.jsx(
88
+ index.Input.Search,
89
+ {
90
+ onChange: (e) => setSearchText(e.target.value),
91
+ variants: { className: "mx-deca my-centi outline-none" }
92
+ }
93
+ ) : null,
94
+ country ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
95
+ /* @__PURE__ */ jsxRuntime.jsx(
96
+ Option.PhoneInputOption,
97
+ {
98
+ country,
99
+ handleSelectCountry: handleSelect,
100
+ disableClick: true
101
+ }
102
+ ),
103
+ /* @__PURE__ */ jsxRuntime.jsx(Divider.Divider, {})
104
+ ] }) : null,
105
+ filteredCountries.map((country2) => {
106
+ return /* @__PURE__ */ jsxRuntime.jsx(
107
+ Option.PhoneInputOption,
108
+ {
109
+ country: country2,
110
+ handleSelectCountry: handleSelect
111
+ },
112
+ `${country2.dialCode} ${country2.iso2}`
113
+ );
114
+ })
115
+ ] });
116
+ };
117
+
118
+ exports.PhoneInputOptions = PhoneInputOptions;
@@ -0,0 +1,22 @@
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 z-9999",
14
+ style: {
15
+ width: triggerWidth ? `${triggerWidth}px` : "auto"
16
+ },
17
+ children
18
+ }
19
+ ) });
20
+ };
21
+
22
+ 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
+ onChange,
14
+ ...rest
15
+ }) => {
16
+ const [triggerWidth, setTriggerWidth] = React.useState();
17
+ const [isOpen, setIsOpen] = React.useState(false);
18
+ const {
19
+ country,
20
+ handlePhoneValueChange,
21
+ inputRef,
22
+ inputValue,
23
+ phone,
24
+ setCountry
25
+ } = reactInternationalPhone.usePhoneInput({
26
+ countries: reactInternationalPhone.defaultCountries,
27
+ onChange: ({ phone: phone2, ...rest2 }) => {
28
+ onChange?.(phone2, { ...rest2 });
29
+ },
30
+ ...rest
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,112 @@
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
+ var FlagIcon = require('./FlagIcon.js');
68
+
69
+ const PhoneInputTrigger = ({
70
+ disabled = false,
71
+ label,
72
+ ...rest
73
+ }) => {
74
+ const {
75
+ setIsOpen,
76
+ setTriggerWidth,
77
+ country,
78
+ handlePhoneValueChange,
79
+ inputValue
80
+ } = context.usePhoneContext();
81
+ const triggerRef = React.useRef(null);
82
+ React.useEffect(() => {
83
+ if (triggerRef.current && setTriggerWidth) {
84
+ const width = triggerRef.current.getBoundingClientRect().width;
85
+ setTriggerWidth(width);
86
+ }
87
+ }, [triggerRef.current, setTriggerWidth]);
88
+ return /* @__PURE__ */ jsxRuntime.jsx(index.Popover.Trigger, { disabled, children: /* @__PURE__ */ jsxRuntime.jsxs(index$1.Input.Face, { ref: triggerRef, children: [
89
+ /* @__PURE__ */ jsxRuntime.jsx(
90
+ index$1.Input.Box,
91
+ {
92
+ value: inputValue,
93
+ onChange: handlePhoneValueChange,
94
+ label: label ?? "Insert a phone number",
95
+ ...rest
96
+ }
97
+ ),
98
+ /* @__PURE__ */ jsxRuntime.jsx(index$1.Input.Right, { children: /* @__PURE__ */ jsxRuntime.jsxs(
99
+ "div",
100
+ {
101
+ className: "flex items-center gap-1 cursor-pointer w-full",
102
+ onClick: () => setIsOpen?.(true),
103
+ children: [
104
+ country ? /* @__PURE__ */ jsxRuntime.jsx(FlagIcon.FlagIcon, { countryCode: country.iso2, className: "w-[25px]" }) : null,
105
+ /* @__PURE__ */ jsxRuntime.jsx(io5.IoChevronDown, { className: "h-full text-md" })
106
+ ]
107
+ }
108
+ ) })
109
+ ] }) });
110
+ };
111
+
112
+ 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,11 @@ 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');
73
+ require('country-flag-icons/react/3x2');
69
74
 
70
75
  const ManagerContext = React.createContext(null);
71
76
  const ManagerProvider = ({ children }) => {
@@ -0,0 +1,25 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import * as Flags from 'country-flag-icons/react/3x2';
3
+
4
+ const FlagIcon = ({
5
+ countryCode,
6
+ className = "w-[25px]",
7
+ title
8
+ }) => {
9
+ if (!countryCode) return null;
10
+ const upperCode = countryCode.toUpperCase();
11
+ const FlagComponent = Flags[upperCode];
12
+ if (!FlagComponent) {
13
+ return null;
14
+ }
15
+ return /* @__PURE__ */ jsx(
16
+ FlagComponent,
17
+ {
18
+ className,
19
+ title: title || upperCode,
20
+ "aria-label": `Flag of ${upperCode}`
21
+ }
22
+ );
23
+ };
24
+
25
+ export { FlagIcon };
@@ -0,0 +1,27 @@
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
+ "button",
10
+ {
11
+ className: "flex w-full h-[2rem] items-center justify-between p-centi cursor-pointer hover:bg-secondary-xlight bg-inherit",
12
+ onClick: () => {
13
+ handleSelectCountry(country);
14
+ },
15
+ disabled: disableClick,
16
+ children: [
17
+ /* @__PURE__ */ jsx("span", { children: country?.name }),
18
+ /* @__PURE__ */ jsxs("span", { className: "text-secondary-light text-sm", children: [
19
+ "+",
20
+ country?.dialCode
21
+ ] })
22
+ ]
23
+ }
24
+ );
25
+ };
26
+
27
+ export { PhoneInputOption };
@@ -0,0 +1,116 @@
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
+ import 'country-flag-icons/react/3x2';
66
+
67
+ const countries = defaultCountries.map((c) => {
68
+ return parseCountry(c);
69
+ });
70
+ const PhoneInputOptions = ({
71
+ hasSearch = true
72
+ }) => {
73
+ const { country, setCountry, setIsOpen } = usePhoneContext();
74
+ const [searchText, setSearchText] = useState("");
75
+ const filteredCountries = useMemo(() => {
76
+ return countries.filter(
77
+ (c) => c.iso2 !== country?.iso2 && (c.name.toLowerCase().includes(searchText.toLowerCase()) || c.dialCode.includes(searchText))
78
+ );
79
+ }, [country, searchText]);
80
+ const handleSelect = (country2) => {
81
+ setCountry?.(country2.iso2);
82
+ setIsOpen?.(false);
83
+ };
84
+ return /* @__PURE__ */ jsxs("div", { className: "w-full h-full flex flex-col overflow-y-auto", children: [
85
+ hasSearch ? /* @__PURE__ */ jsx(
86
+ Input.Search,
87
+ {
88
+ onChange: (e) => setSearchText(e.target.value),
89
+ variants: { className: "mx-deca my-centi outline-none" }
90
+ }
91
+ ) : null,
92
+ country ? /* @__PURE__ */ jsxs(Fragment, { children: [
93
+ /* @__PURE__ */ jsx(
94
+ PhoneInputOption,
95
+ {
96
+ country,
97
+ handleSelectCountry: handleSelect,
98
+ disableClick: true
99
+ }
100
+ ),
101
+ /* @__PURE__ */ jsx(Divider, {})
102
+ ] }) : null,
103
+ filteredCountries.map((country2) => {
104
+ return /* @__PURE__ */ jsx(
105
+ PhoneInputOption,
106
+ {
107
+ country: country2,
108
+ handleSelectCountry: handleSelect
109
+ },
110
+ `${country2.dialCode} ${country2.iso2}`
111
+ );
112
+ })
113
+ ] });
114
+ };
115
+
116
+ export { PhoneInputOptions };
@@ -0,0 +1,20 @@
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 z-9999",
12
+ style: {
13
+ width: triggerWidth ? `${triggerWidth}px` : "auto"
14
+ },
15
+ children
16
+ }
17
+ ) });
18
+ };
19
+
20
+ 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
+ onChange,
12
+ ...rest
13
+ }) => {
14
+ const [triggerWidth, setTriggerWidth] = useState();
15
+ const [isOpen, setIsOpen] = useState(false);
16
+ const {
17
+ country,
18
+ handlePhoneValueChange,
19
+ inputRef,
20
+ inputValue,
21
+ phone,
22
+ setCountry
23
+ } = usePhoneInput({
24
+ countries: defaultCountries,
25
+ onChange: ({ phone: phone2, ...rest2 }) => {
26
+ onChange?.(phone2, { ...rest2 });
27
+ },
28
+ ...rest
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,110 @@
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
+ import { FlagIcon } from './FlagIcon.js';
66
+
67
+ const PhoneInputTrigger = ({
68
+ disabled = false,
69
+ label,
70
+ ...rest
71
+ }) => {
72
+ const {
73
+ setIsOpen,
74
+ setTriggerWidth,
75
+ country,
76
+ handlePhoneValueChange,
77
+ inputValue
78
+ } = usePhoneContext();
79
+ const triggerRef = useRef(null);
80
+ useEffect(() => {
81
+ if (triggerRef.current && setTriggerWidth) {
82
+ const width = triggerRef.current.getBoundingClientRect().width;
83
+ setTriggerWidth(width);
84
+ }
85
+ }, [triggerRef.current, setTriggerWidth]);
86
+ return /* @__PURE__ */ jsx(Popover.Trigger, { disabled, children: /* @__PURE__ */ jsxs(Input.Face, { ref: triggerRef, children: [
87
+ /* @__PURE__ */ jsx(
88
+ Input.Box,
89
+ {
90
+ value: inputValue,
91
+ onChange: handlePhoneValueChange,
92
+ label: label ?? "Insert a phone number",
93
+ ...rest
94
+ }
95
+ ),
96
+ /* @__PURE__ */ jsx(Input.Right, { children: /* @__PURE__ */ jsxs(
97
+ "div",
98
+ {
99
+ className: "flex items-center gap-1 cursor-pointer w-full",
100
+ onClick: () => setIsOpen?.(true),
101
+ children: [
102
+ country ? /* @__PURE__ */ jsx(FlagIcon, { countryCode: country.iso2, className: "w-[25px]" }) : null,
103
+ /* @__PURE__ */ jsx(IoChevronDown, { className: "h-full text-md" })
104
+ ]
105
+ }
106
+ ) })
107
+ ] }) });
108
+ };
109
+
110
+ 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,11 @@ 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';
71
+ import 'country-flag-icons/react/3x2';
67
72
 
68
73
  const ManagerContext = createContext(null);
69
74
  const ManagerProvider = ({ children }) => {
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface FlagIconProps {
3
+ countryCode: string;
4
+ className?: string;
5
+ title?: string;
6
+ }
7
+ export declare const FlagIcon: React.FC<FlagIconProps>;
8
+ export {};
@@ -0,0 +1,6 @@
1
+ import { ParsedCountry } from 'react-international-phone';
2
+ export declare const PhoneInputOption: ({ country, handleSelectCountry, disableClick, }: {
3
+ country: ParsedCountry;
4
+ handleSelectCountry: (country: ParsedCountry) => void;
5
+ disableClick?: boolean;
6
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export declare const PhoneInputOptions: ({ hasSearch, }: {
2
+ hasSearch?: boolean;
3
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { ReactNode } from 'react';
2
+ export declare const PhoneInputPopover: ({ children }: {
3
+ children: ReactNode;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { PhoneInputRootProps } from './types';
2
+ export declare const PhoneInputRoot: ({ children, className, onChange, ...rest }: PhoneInputRootProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { PhoneInputTriggerProps } from './types';
2
+ export declare const PhoneInputTrigger: ({ disabled, label, ...rest }: PhoneInputTriggerProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { usePhoneInput } from 'react-international-phone';
2
+ export interface Country {
3
+ country: string;
4
+ iso: string;
5
+ code: string;
6
+ }
7
+ interface PhoneInputContextProps extends ReturnType<typeof usePhoneInput> {
8
+ isOpen: boolean;
9
+ setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
10
+ triggerWidth?: number;
11
+ setTriggerWidth?: React.Dispatch<React.SetStateAction<number | undefined>>;
12
+ }
13
+ export declare const PhoneInputContext: import("react").Context<PhoneInputContextProps | null>;
14
+ export declare const usePhoneContext: () => PhoneInputContextProps;
15
+ export {};
@@ -0,0 +1,16 @@
1
+ export declare const PhoneInput: {
2
+ Root: ({ children, className, onChange, ...rest }: import("./types").PhoneInputRootProps) => import("react/jsx-runtime").JSX.Element;
3
+ Popover: ({ children }: {
4
+ children: import("react").ReactNode;
5
+ }) => import("react/jsx-runtime").JSX.Element;
6
+ Trigger: ({ disabled, label, ...rest }: import("./types").PhoneInputTriggerProps) => import("react/jsx-runtime").JSX.Element;
7
+ Option: ({ country, handleSelectCountry, disableClick, }: {
8
+ country: import("react-international-phone").ParsedCountry;
9
+ handleSelectCountry: (country: import("react-international-phone").ParsedCountry) => void;
10
+ disableClick?: boolean;
11
+ }) => import("react/jsx-runtime").JSX.Element;
12
+ Options: ({ hasSearch, }: {
13
+ hasSearch?: boolean;
14
+ }) => import("react/jsx-runtime").JSX.Element;
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
+ }
@@ -32,3 +32,4 @@ export * from './TimePicker';
32
32
  export * from './Toggle';
33
33
  export * from './Tooltip';
34
34
  export * from './Uploader';
35
+ export * from './PhoneInput';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tecsinapse/cortex-react",
3
- "version": "2.1.1-beta.3",
3
+ "version": "2.1.1",
4
4
  "description": "React components based in @tecsinapse/cortex-core",
5
5
  "license": "MIT",
6
6
  "main": "dist/esm/index.js",
@@ -20,14 +20,16 @@
20
20
  "dependencies": {
21
21
  "@floating-ui/react": "^0.26.18",
22
22
  "@internationalized/date": "3.7.0",
23
- "@tecsinapse/cortex-core": "2.0.0",
23
+ "@tecsinapse/cortex-core": "2.0.1",
24
24
  "clsx": "2.1.1",
25
+ "country-flag-icons": "^1.6.4",
25
26
  "currency.js": "2.0.4",
26
27
  "embla-carousel-autoplay": "^8.0.0",
27
28
  "embla-carousel-react": "^8.6.0",
28
29
  "react-aria": "3.38.1",
29
30
  "react-dropzone": "14.3.8",
30
31
  "react-imask": "7.6.1",
32
+ "react-international-phone": "^4.6.1",
31
33
  "react-spring": "9.7.5",
32
34
  "react-stately": "3.36.1",
33
35
  "sonner": "1.7.3",
@@ -48,5 +50,5 @@
48
50
  "react-icons": ">=5.2.0",
49
51
  "tailwindcss": "^4.1.16"
50
52
  },
51
- "gitHead": "4eff3b2229ad43c2e1b92f39bfd97dadd52391eb"
53
+ "gitHead": "ac795c6ed18a2acfdf8860a920b3bccba634108e"
52
54
  }