@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.
- package/dist/cjs/components/Autocomplete/GroupedOptions.js +42 -0
- package/dist/cjs/components/Autocomplete/Option.js +40 -0
- package/dist/cjs/components/Autocomplete/Options.js +36 -0
- package/dist/cjs/components/Autocomplete/Popover.js +34 -0
- package/dist/cjs/components/Autocomplete/Root.js +40 -0
- package/dist/cjs/components/Autocomplete/Trigger.js +47 -0
- package/dist/cjs/components/Autocomplete/context.js +7 -0
- package/dist/cjs/components/Autocomplete/index.js +19 -0
- package/dist/cjs/components/PhoneInput/FlagIcon.js +46 -0
- package/dist/cjs/components/PhoneInput/Option.js +29 -0
- package/dist/cjs/components/PhoneInput/Options.js +121 -0
- package/dist/cjs/components/PhoneInput/Popover.js +22 -0
- package/dist/cjs/components/PhoneInput/Root.js +61 -0
- package/dist/cjs/components/PhoneInput/Trigger.js +115 -0
- package/dist/cjs/components/PhoneInput/context.js +19 -0
- package/dist/cjs/components/PhoneInput/index.js +17 -0
- package/dist/cjs/components/ScrollableDigitSelector.js +1 -1
- package/dist/cjs/components/TimePicker/TimePickerSelector.js +2 -2
- package/dist/cjs/components/Uploader/Files.js +1 -1
- package/dist/cjs/hooks/useAutocompleteGroupedOptions.js +35 -0
- package/dist/cjs/hooks/useAutocompleteOptions.js +35 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/provider/ManagerContext.js +8 -0
- package/dist/cjs/service/SnackbarSonner.js +32 -0
- package/dist/cjs/styles/calendar-cell.js +3 -3
- package/dist/esm/components/Autocomplete/GroupedOptions.js +40 -0
- package/dist/esm/components/Autocomplete/Option.js +38 -0
- package/dist/esm/components/Autocomplete/Options.js +34 -0
- package/dist/esm/components/Autocomplete/Popover.js +32 -0
- package/dist/esm/components/Autocomplete/Root.js +38 -0
- package/dist/esm/components/Autocomplete/Trigger.js +45 -0
- package/dist/esm/components/Autocomplete/context.js +5 -0
- package/dist/esm/components/Autocomplete/index.js +17 -0
- package/dist/esm/components/PhoneInput/FlagIcon.js +25 -0
- package/dist/esm/components/PhoneInput/Option.js +27 -0
- package/dist/esm/components/PhoneInput/Options.js +119 -0
- package/dist/esm/components/PhoneInput/Popover.js +20 -0
- package/dist/esm/components/PhoneInput/Root.js +59 -0
- package/dist/esm/components/PhoneInput/Trigger.js +113 -0
- package/dist/esm/components/PhoneInput/context.js +16 -0
- package/dist/esm/components/PhoneInput/index.js +15 -0
- package/dist/esm/components/ScrollableDigitSelector.js +1 -1
- package/dist/esm/components/TimePicker/TimePickerSelector.js +2 -2
- package/dist/esm/components/Uploader/Files.js +1 -1
- package/dist/esm/hooks/useAutocompleteGroupedOptions.js +33 -0
- package/dist/esm/hooks/useAutocompleteOptions.js +33 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/provider/ManagerContext.js +8 -0
- package/dist/esm/service/SnackbarSonner.js +32 -0
- package/dist/esm/styles/calendar-cell.js +3 -3
- package/dist/types/components/Autocomplete/GroupedOptions.d.ts +2 -0
- package/dist/types/components/Autocomplete/Option.d.ts +2 -0
- package/dist/types/components/Autocomplete/Options.d.ts +2 -0
- package/dist/types/components/Autocomplete/Popover.d.ts +2 -0
- package/dist/types/components/Autocomplete/Root.d.ts +2 -0
- package/dist/types/components/Autocomplete/Trigger.d.ts +2 -0
- package/dist/types/components/Autocomplete/context.d.ts +10 -0
- package/dist/types/components/Autocomplete/index.d.ts +9 -0
- package/dist/types/components/Autocomplete/types.d.ts +50 -0
- package/dist/types/components/PhoneInput/FlagIcon.d.ts +8 -0
- package/dist/types/components/PhoneInput/Option.d.ts +6 -0
- package/dist/types/components/PhoneInput/Options.d.ts +3 -0
- package/dist/types/components/PhoneInput/Popover.d.ts +4 -0
- package/dist/types/components/PhoneInput/Root.d.ts +2 -0
- package/dist/types/components/PhoneInput/Trigger.d.ts +2 -0
- package/dist/types/components/PhoneInput/context.d.ts +15 -0
- package/dist/types/components/PhoneInput/index.d.ts +16 -0
- package/dist/types/components/PhoneInput/types.d.ts +13 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/hooks/useAutocompleteGroupedOptions.d.ts +9 -0
- package/dist/types/hooks/useAutocompleteOptions.d.ts +9 -0
- package/dist/types/hooks/useFileUpload.d.ts +4 -4
- package/dist/types/provider/ManagerContext.d.ts +1 -1
- package/dist/types/service/SnackbarSonner.d.ts +19 -0
- package/package.json +5 -3
|
@@ -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,113 @@
|
|
|
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 '../Autocomplete/context.js';
|
|
63
|
+
import '../Autocomplete/Options.js';
|
|
64
|
+
import '../Autocomplete/GroupedOptions.js';
|
|
65
|
+
import './Options.js';
|
|
66
|
+
import { usePhoneContext } from './context.js';
|
|
67
|
+
import 'react-international-phone';
|
|
68
|
+
import { FlagIcon } from './FlagIcon.js';
|
|
69
|
+
|
|
70
|
+
const PhoneInputTrigger = ({
|
|
71
|
+
disabled = false,
|
|
72
|
+
label,
|
|
73
|
+
...rest
|
|
74
|
+
}) => {
|
|
75
|
+
const {
|
|
76
|
+
setIsOpen,
|
|
77
|
+
setTriggerWidth,
|
|
78
|
+
country,
|
|
79
|
+
handlePhoneValueChange,
|
|
80
|
+
inputValue
|
|
81
|
+
} = usePhoneContext();
|
|
82
|
+
const triggerRef = useRef(null);
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (triggerRef.current && setTriggerWidth) {
|
|
85
|
+
const width = triggerRef.current.getBoundingClientRect().width;
|
|
86
|
+
setTriggerWidth(width);
|
|
87
|
+
}
|
|
88
|
+
}, [triggerRef.current, setTriggerWidth]);
|
|
89
|
+
return /* @__PURE__ */ jsx(Popover.Trigger, { disabled, children: /* @__PURE__ */ jsxs(Input.Face, { ref: triggerRef, children: [
|
|
90
|
+
/* @__PURE__ */ jsx(
|
|
91
|
+
Input.Box,
|
|
92
|
+
{
|
|
93
|
+
value: inputValue,
|
|
94
|
+
onChange: handlePhoneValueChange,
|
|
95
|
+
label: label ?? "Insert a phone number",
|
|
96
|
+
...rest
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
/* @__PURE__ */ jsx(Input.Right, { children: /* @__PURE__ */ jsxs(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
className: "flex items-center gap-1 cursor-pointer w-full",
|
|
103
|
+
onClick: () => setIsOpen?.(true),
|
|
104
|
+
children: [
|
|
105
|
+
country ? /* @__PURE__ */ jsx(FlagIcon, { countryCode: country.iso2, className: "w-[25px]" }) : null,
|
|
106
|
+
/* @__PURE__ */ jsx(IoChevronDown, { className: "h-full text-md" })
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
) })
|
|
110
|
+
] }) });
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
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 };
|
|
@@ -44,7 +44,7 @@ const ScrollableDigitSelector = ({
|
|
|
44
44
|
{
|
|
45
45
|
className: clsx(
|
|
46
46
|
"p-micro rounded-micro border-1 border-transparent hover:bg-primary-light hover:border-primary cursor-pointer",
|
|
47
|
-
value === val && "bg-primary-medium text-
|
|
47
|
+
value === val && "bg-primary-medium text-on-primary"
|
|
48
48
|
),
|
|
49
49
|
children: formatValue(val)
|
|
50
50
|
}
|
|
@@ -103,7 +103,7 @@ const TimePickerSelector = ({
|
|
|
103
103
|
{
|
|
104
104
|
className: clsx(
|
|
105
105
|
dayPeriodStyle,
|
|
106
|
-
!isPM && "bg-primary-medium text-
|
|
106
|
+
!isPM && "bg-primary-medium text-on-primary"
|
|
107
107
|
),
|
|
108
108
|
children: "AM"
|
|
109
109
|
}
|
|
@@ -120,7 +120,7 @@ const TimePickerSelector = ({
|
|
|
120
120
|
{
|
|
121
121
|
className: clsx(
|
|
122
122
|
dayPeriodStyle,
|
|
123
|
-
isPM && "bg-primary-medium text-
|
|
123
|
+
isPM && "bg-primary-medium text-on-primary"
|
|
124
124
|
),
|
|
125
125
|
children: "PM"
|
|
126
126
|
}
|
|
@@ -8,7 +8,7 @@ const Files = ({
|
|
|
8
8
|
}) => {
|
|
9
9
|
return /* @__PURE__ */ jsxs("div", { className: "bg-white w-full border-2 p-deca flex flex-col overflow-y-auto rounded-mili h-[18rem]", children: [
|
|
10
10
|
/* @__PURE__ */ jsxs("div", { className: "flex gap-mili items-center mb-deca", children: [
|
|
11
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center w-deca h-deca bg-primary-medium rounded-full text-micro text-
|
|
11
|
+
/* @__PURE__ */ 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}` }),
|
|
12
12
|
/* @__PURE__ */ jsx("h2", { className: "text-md font-semibold", "data-testid": "upload-progress", children: uploadProgressText })
|
|
13
13
|
] }),
|
|
14
14
|
files.map((file, index) => /* @__PURE__ */ jsx(File, { file, index, onDelete }, file.uid))
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const useAutocompleteGroupedOptions = ({
|
|
4
|
+
options: _options
|
|
5
|
+
}) => {
|
|
6
|
+
const [options, setOptions] = useState();
|
|
7
|
+
const [isLoading, setIsLoading] = useState();
|
|
8
|
+
const [error, setError] = useState();
|
|
9
|
+
const initData = async (fetch) => {
|
|
10
|
+
setIsLoading(true);
|
|
11
|
+
try {
|
|
12
|
+
const result = await fetch();
|
|
13
|
+
if (result) {
|
|
14
|
+
setOptions(result ?? []);
|
|
15
|
+
}
|
|
16
|
+
} catch (e) {
|
|
17
|
+
setError(String(e));
|
|
18
|
+
} finally {
|
|
19
|
+
setIsLoading(false);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (typeof _options === "function") initData(_options);
|
|
24
|
+
else setOptions(_options);
|
|
25
|
+
}, [_options]);
|
|
26
|
+
return {
|
|
27
|
+
isLoading,
|
|
28
|
+
options,
|
|
29
|
+
error
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { useAutocompleteGroupedOptions };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const useAutocompleteOptions = ({
|
|
4
|
+
options: _options
|
|
5
|
+
}) => {
|
|
6
|
+
const [options, setOptions] = useState();
|
|
7
|
+
const [isLoading, setIsLoading] = useState();
|
|
8
|
+
const [error, setError] = useState();
|
|
9
|
+
const initData = useCallback(async (fetch) => {
|
|
10
|
+
setIsLoading(true);
|
|
11
|
+
try {
|
|
12
|
+
const result = await fetch();
|
|
13
|
+
if (result) {
|
|
14
|
+
setOptions(result ?? []);
|
|
15
|
+
}
|
|
16
|
+
} catch (e) {
|
|
17
|
+
setError(String(e));
|
|
18
|
+
} finally {
|
|
19
|
+
setIsLoading(false);
|
|
20
|
+
}
|
|
21
|
+
}, []);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (typeof _options === "function") initData(_options);
|
|
24
|
+
else setOptions(_options);
|
|
25
|
+
}, [_options]);
|
|
26
|
+
return {
|
|
27
|
+
isLoading,
|
|
28
|
+
options,
|
|
29
|
+
error
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { useAutocompleteOptions };
|
package/dist/esm/index.js
CHANGED
|
@@ -42,6 +42,8 @@ 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 { Autocomplete } from './components/Autocomplete/index.js';
|
|
46
|
+
export { PhoneInput } from './components/PhoneInput/index.js';
|
|
45
47
|
export { useCalendar } from './hooks/useCalendar.js';
|
|
46
48
|
export { useCalendarCell } from './hooks/useCalendarCell.js';
|
|
47
49
|
export { useCalendarGrid } from './hooks/useCalendarGrid.js';
|
|
@@ -64,6 +64,14 @@ import '../components/Tooltip.js';
|
|
|
64
64
|
import 'react-icons/hi2';
|
|
65
65
|
import 'react-icons/fa6';
|
|
66
66
|
import 'react-dom';
|
|
67
|
+
import '../components/Autocomplete/context.js';
|
|
68
|
+
import '../components/Autocomplete/Options.js';
|
|
69
|
+
import '../components/Autocomplete/GroupedOptions.js';
|
|
70
|
+
import '../components/PhoneInput/Options.js';
|
|
71
|
+
import '../components/PhoneInput/context.js';
|
|
72
|
+
import 'react-international-phone';
|
|
73
|
+
import 'react-icons/io5';
|
|
74
|
+
import 'country-flag-icons/react/3x2';
|
|
67
75
|
|
|
68
76
|
const ManagerContext = createContext(null);
|
|
69
77
|
const ManagerProvider = ({ children }) => {
|
|
@@ -33,6 +33,38 @@ class SnackbarSonner {
|
|
|
33
33
|
{ ...this._options, ...options }
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
|
+
async promise(promise, config) {
|
|
37
|
+
const { loading, success, error } = config;
|
|
38
|
+
const id = this.show(loading.type ?? "info", loading.message, {
|
|
39
|
+
...loading.options,
|
|
40
|
+
duration: loading.options?.duration ?? Infinity
|
|
41
|
+
});
|
|
42
|
+
try {
|
|
43
|
+
await promise;
|
|
44
|
+
if (!success) {
|
|
45
|
+
toast.dismiss(id);
|
|
46
|
+
} else {
|
|
47
|
+
const msg = success?.message ?? "Opera\xE7\xE3o conclu\xEDda com sucesso.";
|
|
48
|
+
this.show(success?.type ?? "success", msg, {
|
|
49
|
+
...success?.options,
|
|
50
|
+
id,
|
|
51
|
+
duration: success?.options?.duration ?? this._options?.duration ?? 5e3
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
} catch (err) {
|
|
55
|
+
if (!error) {
|
|
56
|
+
toast.dismiss(id);
|
|
57
|
+
} else {
|
|
58
|
+
const msg = error?.message ?? "Ocorreu um erro inesperado.";
|
|
59
|
+
this.show(error?.type ?? "error", msg, {
|
|
60
|
+
...error?.options,
|
|
61
|
+
id,
|
|
62
|
+
duration: error?.options?.duration ?? this._options?.duration ?? 5e3
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return promise;
|
|
67
|
+
}
|
|
36
68
|
}
|
|
37
69
|
|
|
38
70
|
export { SnackbarSonner };
|
|
@@ -13,17 +13,17 @@ const calendarCell = tv({
|
|
|
13
13
|
},
|
|
14
14
|
isSelected: {
|
|
15
15
|
true: {
|
|
16
|
-
cell: "bg-primary-medium border-2 border-primary-medium text-
|
|
16
|
+
cell: "bg-primary-medium border-2 border-primary-medium text-on-primary hover:bg-primary-medium"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
isSelectionStart: {
|
|
20
20
|
true: {
|
|
21
|
-
cell: "bg-primary-medium border-2 border-primary-medium rounded-r-none text-
|
|
21
|
+
cell: "bg-primary-medium border-2 border-primary-medium rounded-r-none text-on-primary"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
isSelectionEnd: {
|
|
25
25
|
true: {
|
|
26
|
-
cell: "bg-primary-medium border-2 border-primary-medium rounded-l-none text-
|
|
26
|
+
cell: "bg-primary-medium border-2 border-primary-medium rounded-l-none text-on-primary"
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
inRange: {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
export interface AutocompleteContextType<T> {
|
|
3
|
+
open: boolean;
|
|
4
|
+
setOpen: (open: boolean) => void;
|
|
5
|
+
triggerWidth: number | undefined;
|
|
6
|
+
setTriggerWidth: Dispatch<SetStateAction<number | undefined>>;
|
|
7
|
+
keyExtractor: (option: T) => string;
|
|
8
|
+
labelExtractor: (option: T) => string;
|
|
9
|
+
}
|
|
10
|
+
export declare const AutocompleteContext: import("react").Context<AutocompleteContextType<any> | undefined>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const Autocomplete: {
|
|
2
|
+
Root: <T>({ keyExtractor, labelExtractor, children, }: import("./types").AutocompleteRootProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
Trigger: ({ inputValue, onChange, label, disabled, placeholder, }: import("./types").AutocompleteTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
Popover: ({ children, className, }: import("./types").AutocompletePopoverProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
Options: <T>({ options, onSelect, children, }: import("./types").AutocompleteOptionsProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
Option: <T>({ option, onSelect, grouped, }: import("./types").AutocompleteOptionProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
GroupedOptions: <T>({ onSelect, groupedLabelExtractor, options, }: import("./types").AutocompleteGroupedOptionsProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
};
|
|
9
|
+
export * from './types';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { ChangeEventHandler, ReactNode } from 'react';
|
|
2
|
+
export interface Option {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
export interface AutocompleteRootProps<T> {
|
|
7
|
+
keyExtractor: (option: T) => string;
|
|
8
|
+
labelExtractor: (option: T) => string;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AutocompleteTriggerProps {
|
|
13
|
+
inputValue: string;
|
|
14
|
+
onChange: ChangeEventHandler<HTMLInputElement>;
|
|
15
|
+
label?: string;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface AutocompletePopoverProps {
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface AutocompleteOptionsProps<T> {
|
|
25
|
+
keyExtractor?: (option: T) => string;
|
|
26
|
+
options?: T[] | (() => Promise<T[]>);
|
|
27
|
+
onSelect?: (option: T) => void;
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
export interface AutocompleteGroupedOptionsProps<T> {
|
|
31
|
+
options?: Map<string, T[]> | (() => Promise<Map<string, T[]>>);
|
|
32
|
+
groupedLabelExtractor: (value: string) => string;
|
|
33
|
+
onSelect?: (option: T) => void;
|
|
34
|
+
}
|
|
35
|
+
export interface AutocompleteOptionProps<T> {
|
|
36
|
+
keyExtractor?: (option: T) => string;
|
|
37
|
+
option: T;
|
|
38
|
+
onSelect?: (option: T) => void;
|
|
39
|
+
grouped?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface AutocompleteProps<T> {
|
|
42
|
+
inputValue: string;
|
|
43
|
+
setInputValue: React.Dispatch<React.SetStateAction<string>>;
|
|
44
|
+
onChange: ChangeEventHandler<HTMLInputElement>;
|
|
45
|
+
options: T[] | (() => Promise<T[]>);
|
|
46
|
+
onSelect?: (option: T) => void;
|
|
47
|
+
label?: string;
|
|
48
|
+
placeholder?: string;
|
|
49
|
+
disabled?: boolean;
|
|
50
|
+
}
|
|
@@ -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,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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface useAutocompleteGroupedOptionsProps<T> {
|
|
2
|
+
options?: Map<string, T[]> | (() => Promise<Map<string, T[]>>);
|
|
3
|
+
}
|
|
4
|
+
export declare const useAutocompleteGroupedOptions: <T>({ options: _options, }: useAutocompleteGroupedOptionsProps<T>) => {
|
|
5
|
+
isLoading: boolean | undefined;
|
|
6
|
+
options: Map<string, T[]> | undefined;
|
|
7
|
+
error: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface useAutocompleteOptionsProps<T> {
|
|
2
|
+
options?: T[] | (() => Promise<T[]>);
|
|
3
|
+
}
|
|
4
|
+
export declare const useAutocompleteOptions: <T>({ options: _options, }: useAutocompleteOptionsProps<T>) => {
|
|
5
|
+
isLoading: boolean | undefined;
|
|
6
|
+
options: T[] | undefined;
|
|
7
|
+
error: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
export {};
|