@tecsinapse/cortex-react 2.2.1-beta.0 → 2.2.1-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.
Files changed (75) hide show
  1. package/dist/cjs/components/Autocomplete/GroupedOptions.js +42 -0
  2. package/dist/cjs/components/Autocomplete/Option.js +40 -0
  3. package/dist/cjs/components/Autocomplete/Options.js +36 -0
  4. package/dist/cjs/components/Autocomplete/Popover.js +34 -0
  5. package/dist/cjs/components/Autocomplete/Root.js +40 -0
  6. package/dist/cjs/components/Autocomplete/Trigger.js +47 -0
  7. package/dist/cjs/components/Autocomplete/context.js +7 -0
  8. package/dist/cjs/components/Autocomplete/index.js +19 -0
  9. package/dist/cjs/components/PhoneInput/FlagIcon.js +46 -0
  10. package/dist/cjs/components/PhoneInput/Option.js +29 -0
  11. package/dist/cjs/components/PhoneInput/Options.js +121 -0
  12. package/dist/cjs/components/PhoneInput/Popover.js +22 -0
  13. package/dist/cjs/components/PhoneInput/Root.js +61 -0
  14. package/dist/cjs/components/PhoneInput/Trigger.js +115 -0
  15. package/dist/cjs/components/PhoneInput/context.js +19 -0
  16. package/dist/cjs/components/PhoneInput/index.js +17 -0
  17. package/dist/cjs/components/ScrollableDigitSelector.js +1 -1
  18. package/dist/cjs/components/TimePicker/TimePickerSelector.js +2 -2
  19. package/dist/cjs/components/Uploader/Files.js +1 -1
  20. package/dist/cjs/hooks/useAutocompleteGroupedOptions.js +35 -0
  21. package/dist/cjs/hooks/useAutocompleteOptions.js +35 -0
  22. package/dist/cjs/index.js +4 -0
  23. package/dist/cjs/provider/ManagerContext.js +8 -0
  24. package/dist/cjs/service/SnackbarSonner.js +32 -0
  25. package/dist/cjs/styles/calendar-cell.js +3 -3
  26. package/dist/esm/components/Autocomplete/GroupedOptions.js +40 -0
  27. package/dist/esm/components/Autocomplete/Option.js +38 -0
  28. package/dist/esm/components/Autocomplete/Options.js +34 -0
  29. package/dist/esm/components/Autocomplete/Popover.js +32 -0
  30. package/dist/esm/components/Autocomplete/Root.js +38 -0
  31. package/dist/esm/components/Autocomplete/Trigger.js +45 -0
  32. package/dist/esm/components/Autocomplete/context.js +5 -0
  33. package/dist/esm/components/Autocomplete/index.js +17 -0
  34. package/dist/esm/components/PhoneInput/FlagIcon.js +25 -0
  35. package/dist/esm/components/PhoneInput/Option.js +27 -0
  36. package/dist/esm/components/PhoneInput/Options.js +119 -0
  37. package/dist/esm/components/PhoneInput/Popover.js +20 -0
  38. package/dist/esm/components/PhoneInput/Root.js +59 -0
  39. package/dist/esm/components/PhoneInput/Trigger.js +113 -0
  40. package/dist/esm/components/PhoneInput/context.js +16 -0
  41. package/dist/esm/components/PhoneInput/index.js +15 -0
  42. package/dist/esm/components/ScrollableDigitSelector.js +1 -1
  43. package/dist/esm/components/TimePicker/TimePickerSelector.js +2 -2
  44. package/dist/esm/components/Uploader/Files.js +1 -1
  45. package/dist/esm/hooks/useAutocompleteGroupedOptions.js +33 -0
  46. package/dist/esm/hooks/useAutocompleteOptions.js +33 -0
  47. package/dist/esm/index.js +2 -0
  48. package/dist/esm/provider/ManagerContext.js +8 -0
  49. package/dist/esm/service/SnackbarSonner.js +32 -0
  50. package/dist/esm/styles/calendar-cell.js +3 -3
  51. package/dist/types/components/Autocomplete/GroupedOptions.d.ts +2 -0
  52. package/dist/types/components/Autocomplete/Option.d.ts +2 -0
  53. package/dist/types/components/Autocomplete/Options.d.ts +2 -0
  54. package/dist/types/components/Autocomplete/Popover.d.ts +2 -0
  55. package/dist/types/components/Autocomplete/Root.d.ts +2 -0
  56. package/dist/types/components/Autocomplete/Trigger.d.ts +2 -0
  57. package/dist/types/components/Autocomplete/context.d.ts +10 -0
  58. package/dist/types/components/Autocomplete/index.d.ts +9 -0
  59. package/dist/types/components/Autocomplete/types.d.ts +50 -0
  60. package/dist/types/components/PhoneInput/FlagIcon.d.ts +8 -0
  61. package/dist/types/components/PhoneInput/Option.d.ts +6 -0
  62. package/dist/types/components/PhoneInput/Options.d.ts +3 -0
  63. package/dist/types/components/PhoneInput/Popover.d.ts +4 -0
  64. package/dist/types/components/PhoneInput/Root.d.ts +2 -0
  65. package/dist/types/components/PhoneInput/Trigger.d.ts +2 -0
  66. package/dist/types/components/PhoneInput/context.d.ts +15 -0
  67. package/dist/types/components/PhoneInput/index.d.ts +16 -0
  68. package/dist/types/components/PhoneInput/types.d.ts +13 -0
  69. package/dist/types/components/index.d.ts +2 -0
  70. package/dist/types/hooks/useAutocompleteGroupedOptions.d.ts +9 -0
  71. package/dist/types/hooks/useAutocompleteOptions.d.ts +9 -0
  72. package/dist/types/hooks/useFileUpload.d.ts +4 -4
  73. package/dist/types/provider/ManagerContext.d.ts +1 -1
  74. package/dist/types/service/SnackbarSonner.d.ts +19 -0
  75. package/package.json +5 -3
@@ -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;
@@ -46,7 +46,7 @@ const ScrollableDigitSelector = ({
46
46
  {
47
47
  className: clsx(
48
48
  "p-micro rounded-micro border-1 border-transparent hover:bg-primary-light hover:border-primary cursor-pointer",
49
- value === val && "bg-primary-medium text-light"
49
+ value === val && "bg-primary-medium text-on-primary"
50
50
  ),
51
51
  children: formatValue(val)
52
52
  }
@@ -105,7 +105,7 @@ const TimePickerSelector = ({
105
105
  {
106
106
  className: clsx(
107
107
  dayPeriodStyle,
108
- !isPM && "bg-primary-medium text-light"
108
+ !isPM && "bg-primary-medium text-on-primary"
109
109
  ),
110
110
  children: "AM"
111
111
  }
@@ -122,7 +122,7 @@ const TimePickerSelector = ({
122
122
  {
123
123
  className: clsx(
124
124
  dayPeriodStyle,
125
- isPM && "bg-primary-medium text-light"
125
+ isPM && "bg-primary-medium text-on-primary"
126
126
  ),
127
127
  children: "PM"
128
128
  }
@@ -10,7 +10,7 @@ const Files = ({
10
10
  }) => {
11
11
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white w-full border-2 p-deca flex flex-col overflow-y-auto rounded-mili h-[18rem]", children: [
12
12
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-mili items-center mb-deca", children: [
13
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center w-deca h-deca bg-primary-medium rounded-full text-micro text-light", children: `${files.length}` }),
13
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center w-deca h-deca bg-primary-medium rounded-full text-micro text-on-primary", children: `${files.length}` }),
14
14
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-md font-semibold", "data-testid": "upload-progress", children: uploadProgressText })
15
15
  ] }),
16
16
  files.map((file, index) => /* @__PURE__ */ jsxRuntime.jsx(Upload.File, { file, index, onDelete }, file.uid))
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ const useAutocompleteGroupedOptions = ({
6
+ options: _options
7
+ }) => {
8
+ const [options, setOptions] = React.useState();
9
+ const [isLoading, setIsLoading] = React.useState();
10
+ const [error, setError] = React.useState();
11
+ const initData = async (fetch) => {
12
+ setIsLoading(true);
13
+ try {
14
+ const result = await fetch();
15
+ if (result) {
16
+ setOptions(result ?? []);
17
+ }
18
+ } catch (e) {
19
+ setError(String(e));
20
+ } finally {
21
+ setIsLoading(false);
22
+ }
23
+ };
24
+ React.useEffect(() => {
25
+ if (typeof _options === "function") initData(_options);
26
+ else setOptions(_options);
27
+ }, [_options]);
28
+ return {
29
+ isLoading,
30
+ options,
31
+ error
32
+ };
33
+ };
34
+
35
+ exports.useAutocompleteGroupedOptions = useAutocompleteGroupedOptions;
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ const useAutocompleteOptions = ({
6
+ options: _options
7
+ }) => {
8
+ const [options, setOptions] = React.useState();
9
+ const [isLoading, setIsLoading] = React.useState();
10
+ const [error, setError] = React.useState();
11
+ const initData = React.useCallback(async (fetch) => {
12
+ setIsLoading(true);
13
+ try {
14
+ const result = await fetch();
15
+ if (result) {
16
+ setOptions(result ?? []);
17
+ }
18
+ } catch (e) {
19
+ setError(String(e));
20
+ } finally {
21
+ setIsLoading(false);
22
+ }
23
+ }, []);
24
+ React.useEffect(() => {
25
+ if (typeof _options === "function") initData(_options);
26
+ else setOptions(_options);
27
+ }, [_options]);
28
+ return {
29
+ isLoading,
30
+ options,
31
+ error
32
+ };
33
+ };
34
+
35
+ exports.useAutocompleteOptions = useAutocompleteOptions;
package/dist/cjs/index.js CHANGED
@@ -44,6 +44,8 @@ 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/Autocomplete/index.js');
48
+ var index$9 = require('./components/PhoneInput/index.js');
47
49
  var useCalendar = require('./hooks/useCalendar.js');
48
50
  var useCalendarCell = require('./hooks/useCalendarCell.js');
49
51
  var useCalendarGrid = require('./hooks/useCalendarGrid.js');
@@ -127,6 +129,8 @@ exports.TimeFieldInput = TimeFieldInput.TimeFieldInput;
127
129
  exports.Toggle = Toggle.Toggle;
128
130
  exports.Tooltip = Tooltip.Tooltip;
129
131
  exports.Uploader = index$7.Uploader;
132
+ exports.Autocomplete = index$8.Autocomplete;
133
+ exports.PhoneInput = index$9.PhoneInput;
130
134
  exports.useCalendar = useCalendar.useCalendar;
131
135
  exports.useCalendarCell = useCalendarCell.useCalendarCell;
132
136
  exports.useCalendarGrid = useCalendarGrid.useCalendarGrid;
@@ -66,6 +66,14 @@ require('../components/Tooltip.js');
66
66
  require('react-icons/hi2');
67
67
  require('react-icons/fa6');
68
68
  require('react-dom');
69
+ require('../components/Autocomplete/context.js');
70
+ require('../components/Autocomplete/Options.js');
71
+ require('../components/Autocomplete/GroupedOptions.js');
72
+ require('../components/PhoneInput/Options.js');
73
+ require('../components/PhoneInput/context.js');
74
+ require('react-international-phone');
75
+ require('react-icons/io5');
76
+ require('country-flag-icons/react/3x2');
69
77
 
70
78
  const ManagerContext = React.createContext(null);
71
79
  const ManagerProvider = ({ children }) => {
@@ -35,6 +35,38 @@ class SnackbarSonner {
35
35
  { ...this._options, ...options }
36
36
  );
37
37
  }
38
+ async promise(promise, config) {
39
+ const { loading, success, error } = config;
40
+ const id = this.show(loading.type ?? "info", loading.message, {
41
+ ...loading.options,
42
+ duration: loading.options?.duration ?? Infinity
43
+ });
44
+ try {
45
+ await promise;
46
+ if (!success) {
47
+ sonner.toast.dismiss(id);
48
+ } else {
49
+ const msg = success?.message ?? "Opera\xE7\xE3o conclu\xEDda com sucesso.";
50
+ this.show(success?.type ?? "success", msg, {
51
+ ...success?.options,
52
+ id,
53
+ duration: success?.options?.duration ?? this._options?.duration ?? 5e3
54
+ });
55
+ }
56
+ } catch (err) {
57
+ if (!error) {
58
+ sonner.toast.dismiss(id);
59
+ } else {
60
+ const msg = error?.message ?? "Ocorreu um erro inesperado.";
61
+ this.show(error?.type ?? "error", msg, {
62
+ ...error?.options,
63
+ id,
64
+ duration: error?.options?.duration ?? this._options?.duration ?? 5e3
65
+ });
66
+ }
67
+ }
68
+ return promise;
69
+ }
38
70
  }
39
71
 
40
72
  exports.SnackbarSonner = SnackbarSonner;
@@ -15,17 +15,17 @@ const calendarCell = tailwindVariants.tv({
15
15
  },
16
16
  isSelected: {
17
17
  true: {
18
- cell: "bg-primary-medium border-2 border-primary-medium text-light hover:bg-primary-medium"
18
+ cell: "bg-primary-medium border-2 border-primary-medium text-on-primary hover:bg-primary-medium"
19
19
  }
20
20
  },
21
21
  isSelectionStart: {
22
22
  true: {
23
- cell: "bg-primary-medium border-2 border-primary-medium rounded-r-none text-light"
23
+ cell: "bg-primary-medium border-2 border-primary-medium rounded-r-none text-on-primary"
24
24
  }
25
25
  },
26
26
  isSelectionEnd: {
27
27
  true: {
28
- cell: "bg-primary-medium border-2 border-primary-medium rounded-l-none text-light"
28
+ cell: "bg-primary-medium border-2 border-primary-medium rounded-l-none text-on-primary"
29
29
  }
30
30
  },
31
31
  inRange: {
@@ -0,0 +1,40 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { selectVariants } from '@tecsinapse/cortex-core';
3
+ import { useContext } from 'react';
4
+ import { AutocompleteOption } from './Option.js';
5
+ import { useAutocompleteGroupedOptions } from '../../hooks/useAutocompleteGroupedOptions.js';
6
+ import { SkeletonOptions } from '../Select/SkeletonOptions.js';
7
+ import { AutocompleteContext } from './context.js';
8
+
9
+ const { groupedTitle, list } = selectVariants();
10
+ const AutocompleteGroupedOptions = ({
11
+ onSelect,
12
+ groupedLabelExtractor,
13
+ options
14
+ }) => {
15
+ const { options: _options, isLoading } = useAutocompleteGroupedOptions({
16
+ options
17
+ });
18
+ const context = useContext(
19
+ AutocompleteContext
20
+ );
21
+ if (!context)
22
+ throw new Error(
23
+ "AutocompleteGroupedOptions must be used within AutocompleteRoot"
24
+ );
25
+ const { keyExtractor } = context;
26
+ return isLoading ? /* @__PURE__ */ jsx(SkeletonOptions, {}) : /* @__PURE__ */ jsx("ul", { role: "listbox", className: list(), children: [..._options ?? []].map(([key, value]) => /* @__PURE__ */ jsxs("div", { children: [
27
+ /* @__PURE__ */ jsx("span", { className: groupedTitle(), children: groupedLabelExtractor?.(key) }),
28
+ value.map((option) => /* @__PURE__ */ jsx(
29
+ AutocompleteOption,
30
+ {
31
+ grouped: true,
32
+ option,
33
+ onSelect
34
+ },
35
+ keyExtractor(option)
36
+ ))
37
+ ] }, key)) });
38
+ };
39
+
40
+ export { AutocompleteGroupedOptions };
@@ -0,0 +1,38 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { option } from '@tecsinapse/cortex-core';
3
+ import { useContext, useCallback } from 'react';
4
+ import { AutocompleteContext } from './context.js';
5
+
6
+ const AutocompleteOption = ({
7
+ option: option$1,
8
+ onSelect,
9
+ grouped = false
10
+ }) => {
11
+ const context = useContext(
12
+ AutocompleteContext
13
+ );
14
+ if (!context)
15
+ throw new Error("AutocompleteOptions must be used within AutocompleteRoot");
16
+ const { setOpen, labelExtractor } = context;
17
+ const handleSelect = useCallback(
18
+ (option2) => {
19
+ setOpen(false);
20
+ onSelect?.(option2);
21
+ },
22
+ [onSelect, setOpen]
23
+ );
24
+ return /* @__PURE__ */ jsx(
25
+ "li",
26
+ {
27
+ onClick: () => handleSelect(option$1),
28
+ className: option({
29
+ selected: false,
30
+ grouped
31
+ }),
32
+ role: "option",
33
+ children: /* @__PURE__ */ jsx("span", { className: "truncate flex-1", children: labelExtractor(option$1) })
34
+ }
35
+ );
36
+ };
37
+
38
+ export { AutocompleteOption };
@@ -0,0 +1,34 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { selectVariants } from '@tecsinapse/cortex-core';
3
+ import { useContext } from 'react';
4
+ import { AutocompleteOption } from './Option.js';
5
+ import { useAutocompleteOptions } from '../../hooks/useAutocompleteOptions.js';
6
+ import { SkeletonOptions } from '../Select/SkeletonOptions.js';
7
+ import { AutocompleteContext } from './context.js';
8
+
9
+ const { list } = selectVariants();
10
+ const AutocompleteOptions = ({
11
+ options,
12
+ onSelect,
13
+ children
14
+ }) => {
15
+ const context = useContext(
16
+ AutocompleteContext
17
+ );
18
+ if (!context)
19
+ throw new Error("AutocompleteOptions must be used within AutocompleteRoot");
20
+ const { keyExtractor } = context;
21
+ const { options: _options, isLoading } = useAutocompleteOptions({
22
+ options
23
+ });
24
+ return isLoading ? /* @__PURE__ */ jsx(SkeletonOptions, {}) : /* @__PURE__ */ jsx("ul", { role: "listbox", className: list(), children: children ?? _options?.map((option) => /* @__PURE__ */ jsx(
25
+ AutocompleteOption,
26
+ {
27
+ option,
28
+ onSelect
29
+ },
30
+ keyExtractor(option)
31
+ )) });
32
+ };
33
+
34
+ export { AutocompleteOptions };
@@ -0,0 +1,32 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useContext } from 'react';
3
+ import { FloatingPortal } from '@floating-ui/react';
4
+ import { Popover } from '../Popover/index.js';
5
+ import { AutocompleteContext } from './context.js';
6
+ import clsx from 'clsx';
7
+
8
+ const AutocompletePopover = ({
9
+ children,
10
+ className
11
+ }) => {
12
+ const context = useContext(AutocompleteContext);
13
+ if (!context)
14
+ throw new Error("AutocompletePopover must be used within AutocompleteRoot");
15
+ const { triggerWidth } = context;
16
+ return /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(
17
+ Popover.Content,
18
+ {
19
+ className: clsx(
20
+ "bg-white shadow-md rounded-md overflow-y-auto max-h-[30vh] outline-none z-9999",
21
+ className
22
+ ),
23
+ style: {
24
+ width: triggerWidth ? `${triggerWidth}px` : "auto"
25
+ },
26
+ initialFocus: -1,
27
+ children
28
+ }
29
+ ) });
30
+ };
31
+
32
+ export { AutocompletePopover };
@@ -0,0 +1,38 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useState } from 'react';
3
+ import { Popover } from '../Popover/index.js';
4
+ import { AutocompleteContext } from './context.js';
5
+
6
+ const AutocompleteRoot = ({
7
+ keyExtractor,
8
+ labelExtractor,
9
+ children
10
+ }) => {
11
+ const [triggerWidth, setTriggerWidth] = useState();
12
+ const [open, setOpen] = useState(false);
13
+ return /* @__PURE__ */ jsx(
14
+ AutocompleteContext.Provider,
15
+ {
16
+ value: {
17
+ open,
18
+ setOpen,
19
+ triggerWidth,
20
+ setTriggerWidth,
21
+ keyExtractor,
22
+ labelExtractor
23
+ },
24
+ children: /* @__PURE__ */ jsx(
25
+ Popover.Root,
26
+ {
27
+ placement: "bottom-start",
28
+ controlled: true,
29
+ isOpen: open,
30
+ setIsOpen: setOpen,
31
+ children: /* @__PURE__ */ jsx("div", { className: "relative w-full h-full", children })
32
+ }
33
+ )
34
+ }
35
+ );
36
+ };
37
+
38
+ export { AutocompleteRoot };
@@ -0,0 +1,45 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useContext, useRef, useEffect } from 'react';
3
+ import { Popover } from '../Popover/index.js';
4
+ import { Input } from '../Input/index.js';
5
+ import { AutocompleteContext } from './context.js';
6
+
7
+ const AutocompleteTrigger = ({
8
+ inputValue,
9
+ onChange,
10
+ label,
11
+ disabled,
12
+ placeholder
13
+ }) => {
14
+ const context = useContext(AutocompleteContext);
15
+ if (!context)
16
+ throw new Error("AutocompleteTrigger must be used within AutocompleteRoot");
17
+ const { setTriggerWidth, setOpen } = context;
18
+ const triggerRef = useRef(null);
19
+ useEffect(() => {
20
+ if (triggerRef.current && setTriggerWidth) {
21
+ const width = triggerRef.current.getBoundingClientRect().width;
22
+ setTriggerWidth(width);
23
+ }
24
+ }, [triggerRef.current, setTriggerWidth]);
25
+ const handleChange = (event) => {
26
+ onChange(event);
27
+ if (event.target.value.length > 0) {
28
+ setOpen(true);
29
+ } else {
30
+ setOpen(false);
31
+ }
32
+ };
33
+ return /* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx("div", { ref: triggerRef, children: /* @__PURE__ */ jsx(
34
+ Input.Root,
35
+ {
36
+ label: label ?? "Selecione uma op\xE7\xE3o",
37
+ value: inputValue,
38
+ onChange: handleChange,
39
+ disabled,
40
+ placeholder
41
+ }
42
+ ) }) });
43
+ };
44
+
45
+ export { AutocompleteTrigger };
@@ -0,0 +1,5 @@
1
+ import { createContext } from 'react';
2
+
3
+ const AutocompleteContext = createContext(void 0);
4
+
5
+ export { AutocompleteContext };
@@ -0,0 +1,17 @@
1
+ import { AutocompleteRoot } from './Root.js';
2
+ import { AutocompleteTrigger } from './Trigger.js';
3
+ import { AutocompletePopover } from './Popover.js';
4
+ import { AutocompleteOptions } from './Options.js';
5
+ import { AutocompleteOption } from './Option.js';
6
+ import { AutocompleteGroupedOptions } from './GroupedOptions.js';
7
+
8
+ const Autocomplete = {
9
+ Root: AutocompleteRoot,
10
+ Trigger: AutocompleteTrigger,
11
+ Popover: AutocompletePopover,
12
+ Options: AutocompleteOptions,
13
+ Option: AutocompleteOption,
14
+ GroupedOptions: AutocompleteGroupedOptions
15
+ };
16
+
17
+ export { Autocomplete };
@@ -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,119 @@
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 '../Autocomplete/context.js';
65
+ import '../Autocomplete/Options.js';
66
+ import '../Autocomplete/GroupedOptions.js';
67
+ import { defaultCountries, parseCountry } from 'react-international-phone';
68
+ import 'country-flag-icons/react/3x2';
69
+
70
+ const countries = defaultCountries.map((c) => {
71
+ return parseCountry(c);
72
+ });
73
+ const PhoneInputOptions = ({
74
+ hasSearch = true
75
+ }) => {
76
+ const { country, setCountry, setIsOpen } = usePhoneContext();
77
+ const [searchText, setSearchText] = useState("");
78
+ const filteredCountries = useMemo(() => {
79
+ return countries.filter(
80
+ (c) => c.iso2 !== country?.iso2 && (c.name.toLowerCase().includes(searchText.toLowerCase()) || c.dialCode.includes(searchText))
81
+ );
82
+ }, [country, searchText]);
83
+ const handleSelect = (country2) => {
84
+ setCountry?.(country2.iso2);
85
+ setIsOpen?.(false);
86
+ };
87
+ return /* @__PURE__ */ jsxs("div", { className: "w-full h-full flex flex-col overflow-y-auto", children: [
88
+ hasSearch ? /* @__PURE__ */ jsx(
89
+ Input.Search,
90
+ {
91
+ onChange: (e) => setSearchText(e.target.value),
92
+ variants: { className: "mx-deca my-centi outline-none" }
93
+ }
94
+ ) : null,
95
+ country ? /* @__PURE__ */ jsxs(Fragment, { children: [
96
+ /* @__PURE__ */ jsx(
97
+ PhoneInputOption,
98
+ {
99
+ country,
100
+ handleSelectCountry: handleSelect,
101
+ disableClick: true
102
+ }
103
+ ),
104
+ /* @__PURE__ */ jsx(Divider, {})
105
+ ] }) : null,
106
+ filteredCountries.map((country2) => {
107
+ return /* @__PURE__ */ jsx(
108
+ PhoneInputOption,
109
+ {
110
+ country: country2,
111
+ handleSelectCountry: handleSelect
112
+ },
113
+ `${country2.dialCode} ${country2.iso2}`
114
+ );
115
+ })
116
+ ] });
117
+ };
118
+
119
+ export { PhoneInputOptions };