@tecsinapse/cortex-react 2.2.0-beta.6 → 2.2.0
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 +11 -1
- package/dist/cjs/components/Autocomplete/Option.js +5 -3
- package/dist/cjs/components/Autocomplete/Options.js +17 -12
- package/dist/cjs/components/Autocomplete/Root.js +8 -2
- package/dist/cjs/components/Autocomplete/Trigger.js +3 -4
- package/dist/cjs/components/Autocomplete/context.js +1 -3
- 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/index.js +2 -0
- package/dist/cjs/provider/ManagerContext.js +5 -0
- package/dist/cjs/service/SnackbarSonner.js +32 -0
- package/dist/esm/components/Autocomplete/GroupedOptions.js +11 -1
- package/dist/esm/components/Autocomplete/Option.js +5 -3
- package/dist/esm/components/Autocomplete/Options.js +18 -13
- package/dist/esm/components/Autocomplete/Root.js +8 -2
- package/dist/esm/components/Autocomplete/Trigger.js +3 -4
- package/dist/esm/components/Autocomplete/context.js +1 -3
- 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/index.js +1 -0
- package/dist/esm/provider/ManagerContext.js +5 -0
- package/dist/esm/service/SnackbarSonner.js +32 -0
- package/dist/types/components/Autocomplete/GroupedOptions.d.ts +1 -1
- package/dist/types/components/Autocomplete/Option.d.ts +1 -1
- package/dist/types/components/Autocomplete/Options.d.ts +1 -1
- package/dist/types/components/Autocomplete/Root.d.ts +1 -1
- package/dist/types/components/Autocomplete/context.d.ts +4 -3
- package/dist/types/components/Autocomplete/index.d.ts +4 -4
- package/dist/types/components/Autocomplete/types.d.ts +17 -13
- 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 +1 -0
- package/dist/types/hooks/useAutocompleteGroupedOptions.d.ts +4 -5
- package/dist/types/hooks/useAutocompleteOptions.d.ts +4 -5
- 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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare const Autocomplete: {
|
|
2
|
-
Root: ({ children }: import("./types").AutocompleteRootProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
Root: <T>({ keyExtractor, labelExtractor, children, }: import("./types").AutocompleteRootProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
Trigger: ({ inputValue, onChange, label, disabled, placeholder, }: import("./types").AutocompleteTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
Popover: ({ children, className, }: import("./types").AutocompletePopoverProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
-
Options: ({ options, onSelect, children, }: import("./types").AutocompleteOptionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
Option: ({ option, onSelect, grouped, }: import("./types").AutocompleteOptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
GroupedOptions: ({ onSelect, groupedLabelExtractor, options, }: import("./types").AutocompleteGroupedOptionsProps) => 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
8
|
};
|
|
9
9
|
export * from './types';
|
|
@@ -3,7 +3,9 @@ export interface Option {
|
|
|
3
3
|
label: string;
|
|
4
4
|
value: string;
|
|
5
5
|
}
|
|
6
|
-
export interface AutocompleteRootProps {
|
|
6
|
+
export interface AutocompleteRootProps<T> {
|
|
7
|
+
keyExtractor: (option: T) => string;
|
|
8
|
+
labelExtractor: (option: T) => string;
|
|
7
9
|
children: ReactNode;
|
|
8
10
|
className?: string;
|
|
9
11
|
}
|
|
@@ -19,27 +21,29 @@ export interface AutocompletePopoverProps {
|
|
|
19
21
|
children: ReactNode;
|
|
20
22
|
className?: string;
|
|
21
23
|
}
|
|
22
|
-
export interface AutocompleteOptionsProps {
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
export interface AutocompleteOptionsProps<T> {
|
|
25
|
+
keyExtractor?: (option: T) => string;
|
|
26
|
+
options?: T[] | (() => Promise<T[]>);
|
|
27
|
+
onSelect?: (option: T) => void;
|
|
25
28
|
children?: ReactNode;
|
|
26
29
|
}
|
|
27
|
-
export interface AutocompleteGroupedOptionsProps {
|
|
28
|
-
options?: Map<string,
|
|
30
|
+
export interface AutocompleteGroupedOptionsProps<T> {
|
|
31
|
+
options?: Map<string, T[]> | (() => Promise<Map<string, T[]>>);
|
|
29
32
|
groupedLabelExtractor: (value: string) => string;
|
|
30
|
-
onSelect?: (option:
|
|
33
|
+
onSelect?: (option: T) => void;
|
|
31
34
|
}
|
|
32
|
-
export interface AutocompleteOptionProps {
|
|
33
|
-
option:
|
|
34
|
-
|
|
35
|
+
export interface AutocompleteOptionProps<T> {
|
|
36
|
+
keyExtractor?: (option: T) => string;
|
|
37
|
+
option: T;
|
|
38
|
+
onSelect?: (option: T) => void;
|
|
35
39
|
grouped?: boolean;
|
|
36
40
|
}
|
|
37
|
-
export interface AutocompleteProps {
|
|
41
|
+
export interface AutocompleteProps<T> {
|
|
38
42
|
inputValue: string;
|
|
39
43
|
setInputValue: React.Dispatch<React.SetStateAction<string>>;
|
|
40
44
|
onChange: ChangeEventHandler<HTMLInputElement>;
|
|
41
|
-
options:
|
|
42
|
-
onSelect?: (option:
|
|
45
|
+
options: T[] | (() => Promise<T[]>);
|
|
46
|
+
onSelect?: (option: T) => void;
|
|
43
47
|
label?: string;
|
|
44
48
|
placeholder?: string;
|
|
45
49
|
disabled?: boolean;
|
|
@@ -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
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
options?: Map<string, Option[]> | (() => Promise<Map<string, Option[]>>);
|
|
1
|
+
interface useAutocompleteGroupedOptionsProps<T> {
|
|
2
|
+
options?: Map<string, T[]> | (() => Promise<Map<string, T[]>>);
|
|
4
3
|
}
|
|
5
|
-
export declare const useAutocompleteGroupedOptions: ({ options: _options, }: useAutocompleteGroupedOptionsProps) => {
|
|
4
|
+
export declare const useAutocompleteGroupedOptions: <T>({ options: _options, }: useAutocompleteGroupedOptionsProps<T>) => {
|
|
6
5
|
isLoading: boolean | undefined;
|
|
7
|
-
options: Map<string,
|
|
6
|
+
options: Map<string, T[]> | undefined;
|
|
8
7
|
error: string | undefined;
|
|
9
8
|
};
|
|
10
9
|
export {};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
options?: Option[] | (() => Promise<Option[]>);
|
|
1
|
+
interface useAutocompleteOptionsProps<T> {
|
|
2
|
+
options?: T[] | (() => Promise<T[]>);
|
|
4
3
|
}
|
|
5
|
-
export declare const useAutocompleteOptions: ({ options: _options, }: useAutocompleteOptionsProps) => {
|
|
4
|
+
export declare const useAutocompleteOptions: <T>({ options: _options, }: useAutocompleteOptionsProps<T>) => {
|
|
6
5
|
isLoading: boolean | undefined;
|
|
7
|
-
options:
|
|
6
|
+
options: T[] | undefined;
|
|
8
7
|
error: string | undefined;
|
|
9
8
|
};
|
|
10
9
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type DropEvent, type FileRejection } from 'react-dropzone';
|
|
2
2
|
import { AcceptSpecificMap, UseDropzoneProps, type FileUpload } from '../components/Uploader/types';
|
|
3
|
-
interface UseFileUploadOptions {
|
|
3
|
+
interface UseFileUploadOptions<T> {
|
|
4
4
|
accept?: {
|
|
5
5
|
IMAGE?: (typeof AcceptSpecificMap.IMAGE)[number][];
|
|
6
6
|
APPLICATION?: (typeof AcceptSpecificMap.APPLICATION)[number][];
|
|
@@ -8,7 +8,7 @@ interface UseFileUploadOptions {
|
|
|
8
8
|
VIDEO?: (typeof AcceptSpecificMap.VIDEO)[number][];
|
|
9
9
|
TEXT?: (typeof AcceptSpecificMap.TEXT)[number][];
|
|
10
10
|
};
|
|
11
|
-
onAccept?: (files: FileUpload<
|
|
11
|
+
onAccept?: (files: FileUpload<T>[]) => Promise<FileUpload<T>[]>;
|
|
12
12
|
onOpenManager?: () => void;
|
|
13
13
|
onFileRejected?: (fileRejections: FileRejection[], event: DropEvent) => void;
|
|
14
14
|
maxSize?: number;
|
|
@@ -22,7 +22,7 @@ interface UseFileUploadOptions {
|
|
|
22
22
|
noClick?: boolean;
|
|
23
23
|
ignoreRejections?: boolean;
|
|
24
24
|
}
|
|
25
|
-
export declare const useFileUpload: <T>({ accept, onAccept, onOpenManager, onFileRejected, maxSize, allowMultiple, preventDuplicates, onDuplicate, hasManager, isFolder, noClick, ignoreRejections, uploadProgressText, uploadSuccessText, }: UseFileUploadOptions) => {
|
|
25
|
+
export declare const useFileUpload: <T>({ accept, onAccept, onOpenManager, onFileRejected, maxSize, allowMultiple, preventDuplicates, onDuplicate, hasManager, isFolder, noClick, ignoreRejections, uploadProgressText, uploadSuccessText, }: UseFileUploadOptions<T>) => {
|
|
26
26
|
onOpen: () => void;
|
|
27
27
|
onClose: () => void;
|
|
28
28
|
onDelete: (index: number) => void;
|
|
@@ -31,7 +31,7 @@ export declare const useFileUpload: <T>({ accept, onAccept, onOpenManager, onFil
|
|
|
31
31
|
openManager: () => void;
|
|
32
32
|
closeManager: () => void;
|
|
33
33
|
isManagerOpen: boolean;
|
|
34
|
-
files: FileUpload<
|
|
34
|
+
files: FileUpload<any>[];
|
|
35
35
|
duplicates: File[];
|
|
36
36
|
onClearFiles: () => void;
|
|
37
37
|
};
|
|
@@ -16,5 +16,5 @@ interface ManagerContextProps<T> {
|
|
|
16
16
|
export declare const ManagerProvider: ({ children }: {
|
|
17
17
|
children: ReactNode;
|
|
18
18
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
export declare const useManager: () => ManagerContextProps<
|
|
19
|
+
export declare const useManager: () => ManagerContextProps<any>;
|
|
20
20
|
export {};
|
|
@@ -2,9 +2,28 @@ import React from 'react';
|
|
|
2
2
|
import { ExternalToast } from 'sonner';
|
|
3
3
|
import { ISnackbar, TypeSnack } from './ISnackbar';
|
|
4
4
|
import { IExternalToast } from './IExternalToast';
|
|
5
|
+
interface PromiseSnackConfig<T = unknown> {
|
|
6
|
+
loading: {
|
|
7
|
+
message: string;
|
|
8
|
+
type?: TypeSnack;
|
|
9
|
+
options?: Omit<IExternalToast, 'className' | 'style'>;
|
|
10
|
+
};
|
|
11
|
+
success?: {
|
|
12
|
+
message?: string;
|
|
13
|
+
type?: TypeSnack;
|
|
14
|
+
options?: Omit<IExternalToast, 'className' | 'style'>;
|
|
15
|
+
};
|
|
16
|
+
error?: {
|
|
17
|
+
message?: string;
|
|
18
|
+
type?: TypeSnack;
|
|
19
|
+
options?: Omit<IExternalToast, 'className' | 'style'>;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
5
22
|
export declare class SnackbarSonner implements ISnackbar<IExternalToast> {
|
|
6
23
|
_options?: IExternalToast;
|
|
7
24
|
constructor(options?: IExternalToast);
|
|
8
25
|
custom(Component: React.ReactElement, options?: ExternalToast): string | number;
|
|
9
26
|
show(type: TypeSnack, message: string, options?: Omit<IExternalToast, 'className' | 'style'>): string | number;
|
|
27
|
+
promise<T>(promise: Promise<T>, config: PromiseSnackConfig<T>): Promise<T>;
|
|
10
28
|
}
|
|
29
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "2.2.0
|
|
3
|
+
"version": "2.2.0",
|
|
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.
|
|
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": "
|
|
53
|
+
"gitHead": "7d2063d30f0d6c363a734a4f15cc66810dd2b546"
|
|
52
54
|
}
|