@tecsinapse/cortex-react 1.6.0 → 1.7.0-beta.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/Calendar/Calendar.js +2 -0
- package/dist/cjs/components/Calendar/CalendarCell.js +2 -0
- package/dist/cjs/components/Calendar/CalendarGrid.js +2 -0
- package/dist/cjs/components/Calendar/RangeCalendar.js +2 -0
- package/dist/cjs/components/DatePicker/DatePickerInput.js +2 -0
- package/dist/cjs/components/DatePicker/DateRangePickerInput.js +2 -0
- package/dist/cjs/components/Input/Mask.js +2 -0
- package/dist/cjs/components/Input/Search.js +2 -0
- package/dist/cjs/components/Menubar/Dropdown.js +2 -0
- package/dist/cjs/components/Menubar/Header.js +2 -0
- package/dist/cjs/components/Menubar/ItemLink.js +2 -0
- package/dist/cjs/components/Menubar/Search.js +2 -0
- package/dist/cjs/components/Popover/Provider.js +2 -0
- package/dist/cjs/components/ProgressBar/ProgressBar.js +41 -0
- package/dist/cjs/components/ProgressBar/ProgressBarInfinite.js +15 -0
- package/dist/cjs/components/ProgressBar/ProgressBarSegments.js +48 -0
- package/dist/cjs/components/Select/GroupedOptions.js +2 -0
- package/dist/cjs/components/Select/MultiGroupedOptions.js +2 -0
- package/dist/cjs/components/Select/MultiOptions.js +2 -0
- package/dist/cjs/components/Select/Options.js +2 -0
- package/dist/cjs/components/Tooltip.js +2 -0
- package/dist/cjs/components/Uploader/Dropzone.js +30 -0
- package/dist/cjs/components/Uploader/Files.js +14 -0
- package/dist/cjs/components/Uploader/Modal.js +38 -0
- package/dist/cjs/components/Uploader/Root.js +38 -0
- package/dist/cjs/components/Uploader/Upload.js +31 -0
- package/dist/cjs/components/Uploader/index.js +16 -0
- package/dist/cjs/components/Uploader/types.js +70 -0
- package/dist/cjs/hooks/useFileUpload.js +85 -0
- package/dist/cjs/index.js +10 -1
- package/dist/cjs/provider/MenubarProvider.js +2 -0
- package/dist/cjs/styles/progressBar.js +32 -1
- package/dist/esm/components/Calendar/Calendar.js +2 -0
- package/dist/esm/components/Calendar/CalendarCell.js +2 -0
- package/dist/esm/components/Calendar/CalendarGrid.js +2 -0
- package/dist/esm/components/Calendar/RangeCalendar.js +2 -0
- package/dist/esm/components/DatePicker/DatePickerInput.js +2 -0
- package/dist/esm/components/DatePicker/DateRangePickerInput.js +2 -0
- package/dist/esm/components/Input/Mask.js +2 -0
- package/dist/esm/components/Input/Search.js +2 -0
- package/dist/esm/components/Menubar/Dropdown.js +2 -0
- package/dist/esm/components/Menubar/Header.js +2 -0
- package/dist/esm/components/Menubar/ItemLink.js +2 -0
- package/dist/esm/components/Menubar/Search.js +2 -0
- package/dist/esm/components/Popover/Provider.js +2 -0
- package/dist/esm/components/ProgressBar/ProgressBar.js +39 -0
- package/dist/esm/components/ProgressBar/ProgressBarInfinite.js +13 -0
- package/dist/esm/components/ProgressBar/ProgressBarSegments.js +46 -0
- package/dist/esm/components/Select/GroupedOptions.js +2 -0
- package/dist/esm/components/Select/MultiGroupedOptions.js +2 -0
- package/dist/esm/components/Select/MultiOptions.js +2 -0
- package/dist/esm/components/Select/Options.js +2 -0
- package/dist/esm/components/Tooltip.js +2 -0
- package/dist/esm/components/Uploader/Dropzone.js +28 -0
- package/dist/esm/components/Uploader/Files.js +12 -0
- package/dist/esm/components/Uploader/Modal.js +36 -0
- package/dist/esm/components/Uploader/Root.js +36 -0
- package/dist/esm/components/Uploader/Upload.js +29 -0
- package/dist/esm/components/Uploader/index.js +13 -0
- package/dist/esm/components/Uploader/types.js +67 -0
- package/dist/esm/hooks/useFileUpload.js +83 -0
- package/dist/esm/index.js +5 -1
- package/dist/esm/provider/MenubarProvider.js +2 -0
- package/dist/esm/styles/progressBar.js +32 -2
- package/dist/types/components/{ProgressBar.d.ts → ProgressBar/ProgressBar.d.ts} +4 -3
- package/dist/types/components/ProgressBar/ProgressBarInfinite.d.ts +6 -0
- package/dist/types/components/ProgressBar/ProgressBarSegments.d.ts +9 -0
- package/dist/types/components/ProgressBar/index.d.ts +1 -0
- package/dist/types/components/Uploader/Dropzone.d.ts +3 -0
- package/dist/types/components/Uploader/Files.d.ts +3 -0
- package/dist/types/components/Uploader/Modal.d.ts +2 -0
- package/dist/types/components/Uploader/Root.d.ts +3 -0
- package/dist/types/components/Uploader/Upload.d.ts +3 -0
- package/dist/types/components/Uploader/index.d.ts +9 -0
- package/dist/types/components/Uploader/types.d.ts +63 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/useFileUpload.d.ts +23 -0
- package/dist/types/styles/progressBar.d.ts +167 -0
- package/package.json +6 -4
- package/dist/cjs/components/ProgressBar.js +0 -71
- package/dist/esm/components/ProgressBar.js +0 -69
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { useDropzone } from 'react-dropzone';
|
|
3
|
+
import { v4 } from 'uuid';
|
|
4
|
+
import { FileStatus, AcceptSpecificMap } from '../components/Uploader/types.js';
|
|
5
|
+
|
|
6
|
+
const useFileUpload = ({
|
|
7
|
+
accept = {},
|
|
8
|
+
onAccept,
|
|
9
|
+
maxSize,
|
|
10
|
+
allowMultiple = true
|
|
11
|
+
}) => {
|
|
12
|
+
const [files, setFiles] = useState([]);
|
|
13
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
14
|
+
const onOpen = useCallback(() => setIsOpen(true), []);
|
|
15
|
+
const onClose = useCallback(() => setIsOpen(false), []);
|
|
16
|
+
const updateFiles = useCallback(
|
|
17
|
+
(prevFiles, newFiles) => {
|
|
18
|
+
const current = /* @__PURE__ */ new Map();
|
|
19
|
+
[...prevFiles, ...newFiles].forEach((file) => current.set(file.uid, file));
|
|
20
|
+
return [...current.values()];
|
|
21
|
+
},
|
|
22
|
+
[]
|
|
23
|
+
);
|
|
24
|
+
const onDrop = async (acceptedFiles) => {
|
|
25
|
+
const newFiles = acceptedFiles.map((file) => ({
|
|
26
|
+
file,
|
|
27
|
+
status: onAccept ? FileStatus.UPLOADING : FileStatus.SUCCESS,
|
|
28
|
+
uid: v4()
|
|
29
|
+
}));
|
|
30
|
+
try {
|
|
31
|
+
setFiles((prevFiles) => [...prevFiles, ...newFiles]);
|
|
32
|
+
if (onAccept) {
|
|
33
|
+
const updatedFiles = await onAccept(newFiles);
|
|
34
|
+
setFiles((prevFiles) => updateFiles(prevFiles, updatedFiles));
|
|
35
|
+
}
|
|
36
|
+
} catch (e) {
|
|
37
|
+
const updatedFiles = newFiles.map((f) => ({
|
|
38
|
+
...f,
|
|
39
|
+
status: FileStatus.ERROR
|
|
40
|
+
}));
|
|
41
|
+
setFiles((prevFiles) => updateFiles(prevFiles, updatedFiles));
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const addMimeTypes = (key, acc) => {
|
|
45
|
+
AcceptSpecificMap[key].forEach((mimeType) => {
|
|
46
|
+
acc[mimeType] = [];
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const mappedAccept = Object.keys(accept).reduce((acc, key) => {
|
|
50
|
+
const mimeTypes = accept[key];
|
|
51
|
+
if (Array.isArray(mimeTypes) && mimeTypes.length === 0) {
|
|
52
|
+
addMimeTypes(key, acc);
|
|
53
|
+
} else if (mimeTypes) {
|
|
54
|
+
mimeTypes.forEach((mimeType) => {
|
|
55
|
+
acc[mimeType] = [];
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return acc;
|
|
59
|
+
}, {});
|
|
60
|
+
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
|
61
|
+
onDrop,
|
|
62
|
+
accept: mappedAccept,
|
|
63
|
+
multiple: allowMultiple,
|
|
64
|
+
maxSize
|
|
65
|
+
});
|
|
66
|
+
const handleRemoveFile = useCallback((index) => {
|
|
67
|
+
setFiles((prevFiles) => prevFiles.filter((_, i) => i !== index));
|
|
68
|
+
}, []);
|
|
69
|
+
return {
|
|
70
|
+
onOpen,
|
|
71
|
+
onClose,
|
|
72
|
+
onDelete: handleRemoveFile,
|
|
73
|
+
dropzoneProps: {
|
|
74
|
+
getInputProps,
|
|
75
|
+
getRootProps,
|
|
76
|
+
isDragActive
|
|
77
|
+
},
|
|
78
|
+
open: isOpen,
|
|
79
|
+
files
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export { useFileUpload };
|
package/dist/esm/index.js
CHANGED
|
@@ -24,7 +24,7 @@ export { Loading } from './components/Loading.js';
|
|
|
24
24
|
export { Menubar } from './components/Menubar/index.js';
|
|
25
25
|
export { Modal } from './components/Modal.js';
|
|
26
26
|
export { Popover } from './components/Popover/index.js';
|
|
27
|
-
export { ProgressBar } from './components/ProgressBar.js';
|
|
27
|
+
export { ProgressBar } from './components/ProgressBar/ProgressBar.js';
|
|
28
28
|
export { RadioButton } from './components/RadioButton.js';
|
|
29
29
|
export { Select } from './components/Select/index.js';
|
|
30
30
|
export { Skeleton } from './components/Skeleton.js';
|
|
@@ -37,6 +37,7 @@ export { TimeField } from './components/TimeField/TimeField.js';
|
|
|
37
37
|
export { TimeFieldInput } from './components/TimeField/TimeFieldInput.js';
|
|
38
38
|
export { Toggle } from './components/Toggle.js';
|
|
39
39
|
export { Tooltip } from './components/Tooltip.js';
|
|
40
|
+
export { Uploader } from './components/Uploader/index.js';
|
|
40
41
|
export { useCalendar } from './hooks/useCalendar.js';
|
|
41
42
|
export { useCalendarCell } from './hooks/useCalendarCell.js';
|
|
42
43
|
export { useCalendarGrid } from './hooks/useCalendarGrid.js';
|
|
@@ -50,9 +51,12 @@ export { useRangeCalendar } from './hooks/useRangeCalendar.js';
|
|
|
50
51
|
export { useSelectGroupedOptions } from './hooks/useSelectGroupedOptions.js';
|
|
51
52
|
export { useSelectOptions } from './hooks/useSelectOptions.js';
|
|
52
53
|
export { getMask, mergeMask, useStringMask } from './hooks/useStringMask.js';
|
|
54
|
+
export { useFileUpload } from './hooks/useFileUpload.js';
|
|
53
55
|
export { SnackbarSonner } from './service/SnackbarSonner.js';
|
|
54
56
|
export { MenubarProvider } from './provider/MenubarProvider.js';
|
|
55
57
|
export { SnackbarProvider, useSnackbar } from './provider/SnackbarProvider.js';
|
|
56
58
|
export { MenubarContext } from './provider/MenubarContext.js';
|
|
57
59
|
export { useMenubar } from './provider/useMenubar.js';
|
|
58
60
|
export { BRLMask, CurrencyIMask, ExpressionMasks, Masks, NumberIMask, PercentageIMask, PercentageMask } from './components/Input/masks.js';
|
|
61
|
+
export { Root } from './components/Uploader/Root.js';
|
|
62
|
+
export { AcceptSpecificMap, FileStatus } from './components/Uploader/types.js';
|
|
@@ -5,6 +5,8 @@ import 'react-stately';
|
|
|
5
5
|
import '@floating-ui/react';
|
|
6
6
|
import 'currency.js';
|
|
7
7
|
import { useOutsideClickListener } from '../hooks/useOutsideClickListener.js';
|
|
8
|
+
import 'react-dropzone';
|
|
9
|
+
import 'uuid';
|
|
8
10
|
import { MenubarContext } from './MenubarContext.js';
|
|
9
11
|
|
|
10
12
|
const MenubarProvider = ({ children }) => {
|
|
@@ -8,12 +8,42 @@ const progressBarFilled = tv({
|
|
|
8
8
|
error: "bg-error-medium",
|
|
9
9
|
info: "bg-info-medium",
|
|
10
10
|
warning: "bg-warning-medium",
|
|
11
|
-
success: "bg-success-medium"
|
|
11
|
+
success: "bg-success-medium",
|
|
12
|
+
uploading: ""
|
|
12
13
|
},
|
|
13
14
|
showAnimation: {
|
|
14
15
|
true: "transition-[width] duration-1000 ease-linear"
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
});
|
|
19
|
+
const progressBarInfiniteVariants = tv({
|
|
20
|
+
slots: {
|
|
21
|
+
container: "relative mb-mili",
|
|
22
|
+
bar: "h-1.5 w-full overflow-hidden",
|
|
23
|
+
progress: "w-full h-full origin-left-right rounded-b-mili"
|
|
24
|
+
},
|
|
25
|
+
variants: {
|
|
26
|
+
status: {
|
|
27
|
+
uploading: {
|
|
28
|
+
progress: "bg-info-medium animate-progress"
|
|
29
|
+
},
|
|
30
|
+
success: {
|
|
31
|
+
progress: "bg-success-medium"
|
|
32
|
+
},
|
|
33
|
+
error: {
|
|
34
|
+
progress: "bg-error-medium"
|
|
35
|
+
},
|
|
36
|
+
default: {
|
|
37
|
+
progress: "bg-primary-medium"
|
|
38
|
+
},
|
|
39
|
+
info: {
|
|
40
|
+
progress: "bg-info-medium"
|
|
41
|
+
},
|
|
42
|
+
warning: {
|
|
43
|
+
progress: "bg-warning-medium"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
18
48
|
|
|
19
|
-
export { progressBarFilled };
|
|
49
|
+
export { progressBarFilled, progressBarInfiniteVariants };
|
|
@@ -3,8 +3,9 @@ export interface ProgressBarProps {
|
|
|
3
3
|
segments?: number;
|
|
4
4
|
valueMin?: number;
|
|
5
5
|
valueMax?: number;
|
|
6
|
-
valueCurrent
|
|
7
|
-
intentProgress?: 'default' | 'success' | 'warning' | 'info' | 'error';
|
|
6
|
+
valueCurrent?: number;
|
|
7
|
+
intentProgress?: 'default' | 'success' | 'warning' | 'info' | 'error' | 'uploading';
|
|
8
|
+
type?: 'infinite' | 'default';
|
|
8
9
|
animated?: boolean;
|
|
9
10
|
}
|
|
10
|
-
export declare const ProgressBar: ({ segments: _segments, valueMin, valueMax, valueCurrent, intentProgress, animated, }: ProgressBarProps) => JSX.Element;
|
|
11
|
+
export declare const ProgressBar: ({ segments: _segments, valueMin, valueMax, valueCurrent, intentProgress, type, animated, }: ProgressBarProps) => JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface ProgressBarInfiniteProps {
|
|
3
|
+
intentProgress?: 'default' | 'success' | 'warning' | 'info' | 'error' | 'uploading';
|
|
4
|
+
}
|
|
5
|
+
export declare const ProgressBarInfinite: ({ intentProgress, }: ProgressBarInfiniteProps) => JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface ProgressBarSegmentsProps {
|
|
3
|
+
segments: number;
|
|
4
|
+
totalProgress: number;
|
|
5
|
+
intentProgress?: 'default' | 'success' | 'warning' | 'info' | 'error' | 'uploading';
|
|
6
|
+
showAnimation: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const ProgressBarSegments: ({ segments, totalProgress, intentProgress, showAnimation, }: ProgressBarSegmentsProps) => JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ProgressBar';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export * from './Root';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export declare const Uploader: {
|
|
5
|
+
Dropzone: ({ dropzoneProps, selectFileText, dropText, buttonText, }: import("./types").DropzoneProps) => JSX.Element;
|
|
6
|
+
Files: <T>({ files, onDelete, uploadProgressText, }: import("./types").FilesProps<T>) => JSX.Element;
|
|
7
|
+
Modal: ({ open, onClose, children, title, }: import("./types").ModalProps) => any;
|
|
8
|
+
Root: <T_1>({ open, onClose, files, onDelete, dropzoneProps, selectFileText, dropText, buttonText, uploadProgressText, titleModal, }: import("./types").RootUploaderProps<T_1>) => JSX.Element;
|
|
9
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DropzoneInputProps, DropzoneRootProps } from 'react-dropzone';
|
|
3
|
+
export interface FileItem {
|
|
4
|
+
file: File;
|
|
5
|
+
loading: 'loading' | 'success' | 'error';
|
|
6
|
+
}
|
|
7
|
+
export interface FileProps<T> {
|
|
8
|
+
file: FileUpload<T>;
|
|
9
|
+
index: number;
|
|
10
|
+
onDelete: (index: number) => void;
|
|
11
|
+
}
|
|
12
|
+
export interface FilesProps<T> {
|
|
13
|
+
files: FileUpload<T>[];
|
|
14
|
+
onDelete: (index: number) => void;
|
|
15
|
+
uploadProgressText?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface UseDropzoneProps {
|
|
18
|
+
getRootProps: <T extends DropzoneRootProps>(props?: T) => T;
|
|
19
|
+
getInputProps: <T extends DropzoneInputProps>(props?: T) => T;
|
|
20
|
+
isDragActive: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface DropzoneProps {
|
|
23
|
+
dropzoneProps: UseDropzoneProps;
|
|
24
|
+
selectFileText?: string;
|
|
25
|
+
dropText?: string;
|
|
26
|
+
buttonText?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ModalProps {
|
|
29
|
+
open: boolean;
|
|
30
|
+
onClose: () => void;
|
|
31
|
+
children: React.ReactNode;
|
|
32
|
+
title?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare enum FileStatus {
|
|
35
|
+
SUCCESS = "success",
|
|
36
|
+
ERROR = "error",
|
|
37
|
+
UPLOADING = "uploading"
|
|
38
|
+
}
|
|
39
|
+
export type FileUpload<T> = {
|
|
40
|
+
file: File;
|
|
41
|
+
metadata?: T;
|
|
42
|
+
uid: string;
|
|
43
|
+
status: FileStatus;
|
|
44
|
+
};
|
|
45
|
+
export interface RootUploaderProps<T> {
|
|
46
|
+
open: boolean;
|
|
47
|
+
onClose: () => void;
|
|
48
|
+
files: FileUpload<T>[];
|
|
49
|
+
onDelete: (index: number) => void;
|
|
50
|
+
dropzoneProps: UseDropzoneProps;
|
|
51
|
+
selectFileText?: string;
|
|
52
|
+
dropText?: string;
|
|
53
|
+
buttonText?: string;
|
|
54
|
+
uploadProgressText?: string;
|
|
55
|
+
titleModal?: string;
|
|
56
|
+
}
|
|
57
|
+
export declare const AcceptSpecificMap: {
|
|
58
|
+
readonly APPLICATION: readonly ["application/pdf", "application/zip", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/x-rar-compressed", "application/x-7z-compressed", "application/json", "application/xml", "application/rtf", "application/x-tar", "application/x-httpd-php", "application/octet-stream"];
|
|
59
|
+
readonly IMAGE: readonly ["image/jpeg", "image/png", "image/gif", "image/bmp", "image/svg+xml", "image/tiff", "image/webp", "image/x-icon"];
|
|
60
|
+
readonly VIDEO: readonly ["video/mp4", "video/mpeg", "video/quicktime", "video/x-msvideo", "video/x-ms-wmv", "video/webm", "video/ogg", "video/x-flv"];
|
|
61
|
+
readonly AUDIO: readonly ["audio/mpeg", "audio/wav", "audio/ogg", "audio/x-aac", "audio/flac", "audio/mp4", "audio/aac", "audio/webm"];
|
|
62
|
+
readonly TEXT: readonly ["text/plain", "text/csv", "text/html", "text/css", "text/xml", "text/javascript", "text/markdown"];
|
|
63
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { UseDropzoneProps, AcceptSpecificMap, type FileUpload } from '../components/Uploader/types';
|
|
2
|
+
interface UseFileUploadOptions<T> {
|
|
3
|
+
accept?: {
|
|
4
|
+
IMAGE?: (typeof AcceptSpecificMap.IMAGE)[number][];
|
|
5
|
+
APPLICATION?: (typeof AcceptSpecificMap.APPLICATION)[number][];
|
|
6
|
+
AUDIO?: (typeof AcceptSpecificMap.AUDIO)[number][];
|
|
7
|
+
VIDEO?: (typeof AcceptSpecificMap.VIDEO)[number][];
|
|
8
|
+
TEXT?: (typeof AcceptSpecificMap.TEXT)[number][];
|
|
9
|
+
};
|
|
10
|
+
onAccept?: (files: FileUpload<T>[]) => Promise<FileUpload<T>[]>;
|
|
11
|
+
maxSize?: number;
|
|
12
|
+
allowMultiple?: boolean;
|
|
13
|
+
onDelete?: (file: FileUpload<T>) => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare const useFileUpload: <T>({ accept, onAccept, maxSize, allowMultiple, }: UseFileUploadOptions<T>) => {
|
|
16
|
+
onOpen: () => void;
|
|
17
|
+
onClose: () => void;
|
|
18
|
+
onDelete: (index: number) => void;
|
|
19
|
+
dropzoneProps: UseDropzoneProps;
|
|
20
|
+
open: boolean;
|
|
21
|
+
files: FileUpload<T>[];
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -5,6 +5,7 @@ export declare const progressBarFilled: import("tailwind-variants").TVReturnType
|
|
|
5
5
|
info: string;
|
|
6
6
|
warning: string;
|
|
7
7
|
success: string;
|
|
8
|
+
uploading: string;
|
|
8
9
|
};
|
|
9
10
|
showAnimation: {
|
|
10
11
|
true: string;
|
|
@@ -16,6 +17,7 @@ export declare const progressBarFilled: import("tailwind-variants").TVReturnType
|
|
|
16
17
|
info: string;
|
|
17
18
|
warning: string;
|
|
18
19
|
success: string;
|
|
20
|
+
uploading: string;
|
|
19
21
|
};
|
|
20
22
|
showAnimation: {
|
|
21
23
|
true: string;
|
|
@@ -27,6 +29,7 @@ export declare const progressBarFilled: import("tailwind-variants").TVReturnType
|
|
|
27
29
|
info: string;
|
|
28
30
|
warning: string;
|
|
29
31
|
success: string;
|
|
32
|
+
uploading: string;
|
|
30
33
|
};
|
|
31
34
|
showAnimation: {
|
|
32
35
|
true: string;
|
|
@@ -38,6 +41,7 @@ export declare const progressBarFilled: import("tailwind-variants").TVReturnType
|
|
|
38
41
|
info: string;
|
|
39
42
|
warning: string;
|
|
40
43
|
success: string;
|
|
44
|
+
uploading: string;
|
|
41
45
|
};
|
|
42
46
|
showAnimation: {
|
|
43
47
|
true: string;
|
|
@@ -49,6 +53,7 @@ export declare const progressBarFilled: import("tailwind-variants").TVReturnType
|
|
|
49
53
|
info: string;
|
|
50
54
|
warning: string;
|
|
51
55
|
success: string;
|
|
56
|
+
uploading: string;
|
|
52
57
|
};
|
|
53
58
|
showAnimation: {
|
|
54
59
|
true: string;
|
|
@@ -60,6 +65,7 @@ export declare const progressBarFilled: import("tailwind-variants").TVReturnType
|
|
|
60
65
|
info: string;
|
|
61
66
|
warning: string;
|
|
62
67
|
success: string;
|
|
68
|
+
uploading: string;
|
|
63
69
|
};
|
|
64
70
|
showAnimation: {
|
|
65
71
|
true: string;
|
|
@@ -71,8 +77,169 @@ export declare const progressBarFilled: import("tailwind-variants").TVReturnType
|
|
|
71
77
|
info: string;
|
|
72
78
|
warning: string;
|
|
73
79
|
success: string;
|
|
80
|
+
uploading: string;
|
|
74
81
|
};
|
|
75
82
|
showAnimation: {
|
|
76
83
|
true: string;
|
|
77
84
|
};
|
|
78
85
|
}>, unknown, unknown, undefined>>;
|
|
86
|
+
export declare const progressBarInfiniteVariants: import("tailwind-variants").TVReturnType<{
|
|
87
|
+
status: {
|
|
88
|
+
uploading: {
|
|
89
|
+
progress: string;
|
|
90
|
+
};
|
|
91
|
+
success: {
|
|
92
|
+
progress: string;
|
|
93
|
+
};
|
|
94
|
+
error: {
|
|
95
|
+
progress: string;
|
|
96
|
+
};
|
|
97
|
+
default: {
|
|
98
|
+
progress: string;
|
|
99
|
+
};
|
|
100
|
+
info: {
|
|
101
|
+
progress: string;
|
|
102
|
+
};
|
|
103
|
+
warning: {
|
|
104
|
+
progress: string;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
}, {
|
|
108
|
+
container: string;
|
|
109
|
+
bar: string;
|
|
110
|
+
progress: string;
|
|
111
|
+
}, undefined, import("tailwind-variants/dist/config").TVConfig<{
|
|
112
|
+
status: {
|
|
113
|
+
uploading: {
|
|
114
|
+
progress: string;
|
|
115
|
+
};
|
|
116
|
+
success: {
|
|
117
|
+
progress: string;
|
|
118
|
+
};
|
|
119
|
+
error: {
|
|
120
|
+
progress: string;
|
|
121
|
+
};
|
|
122
|
+
default: {
|
|
123
|
+
progress: string;
|
|
124
|
+
};
|
|
125
|
+
info: {
|
|
126
|
+
progress: string;
|
|
127
|
+
};
|
|
128
|
+
warning: {
|
|
129
|
+
progress: string;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
}, {
|
|
133
|
+
status: {
|
|
134
|
+
uploading: {
|
|
135
|
+
progress: string;
|
|
136
|
+
};
|
|
137
|
+
success: {
|
|
138
|
+
progress: string;
|
|
139
|
+
};
|
|
140
|
+
error: {
|
|
141
|
+
progress: string;
|
|
142
|
+
};
|
|
143
|
+
default: {
|
|
144
|
+
progress: string;
|
|
145
|
+
};
|
|
146
|
+
info: {
|
|
147
|
+
progress: string;
|
|
148
|
+
};
|
|
149
|
+
warning: {
|
|
150
|
+
progress: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
}>, {
|
|
154
|
+
status: {
|
|
155
|
+
uploading: {
|
|
156
|
+
progress: string;
|
|
157
|
+
};
|
|
158
|
+
success: {
|
|
159
|
+
progress: string;
|
|
160
|
+
};
|
|
161
|
+
error: {
|
|
162
|
+
progress: string;
|
|
163
|
+
};
|
|
164
|
+
default: {
|
|
165
|
+
progress: string;
|
|
166
|
+
};
|
|
167
|
+
info: {
|
|
168
|
+
progress: string;
|
|
169
|
+
};
|
|
170
|
+
warning: {
|
|
171
|
+
progress: string;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
}, {
|
|
175
|
+
container: string;
|
|
176
|
+
bar: string;
|
|
177
|
+
progress: string;
|
|
178
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
179
|
+
status: {
|
|
180
|
+
uploading: {
|
|
181
|
+
progress: string;
|
|
182
|
+
};
|
|
183
|
+
success: {
|
|
184
|
+
progress: string;
|
|
185
|
+
};
|
|
186
|
+
error: {
|
|
187
|
+
progress: string;
|
|
188
|
+
};
|
|
189
|
+
default: {
|
|
190
|
+
progress: string;
|
|
191
|
+
};
|
|
192
|
+
info: {
|
|
193
|
+
progress: string;
|
|
194
|
+
};
|
|
195
|
+
warning: {
|
|
196
|
+
progress: string;
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
}, {
|
|
200
|
+
container: string;
|
|
201
|
+
bar: string;
|
|
202
|
+
progress: string;
|
|
203
|
+
}, undefined, import("tailwind-variants/dist/config").TVConfig<{
|
|
204
|
+
status: {
|
|
205
|
+
uploading: {
|
|
206
|
+
progress: string;
|
|
207
|
+
};
|
|
208
|
+
success: {
|
|
209
|
+
progress: string;
|
|
210
|
+
};
|
|
211
|
+
error: {
|
|
212
|
+
progress: string;
|
|
213
|
+
};
|
|
214
|
+
default: {
|
|
215
|
+
progress: string;
|
|
216
|
+
};
|
|
217
|
+
info: {
|
|
218
|
+
progress: string;
|
|
219
|
+
};
|
|
220
|
+
warning: {
|
|
221
|
+
progress: string;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
}, {
|
|
225
|
+
status: {
|
|
226
|
+
uploading: {
|
|
227
|
+
progress: string;
|
|
228
|
+
};
|
|
229
|
+
success: {
|
|
230
|
+
progress: string;
|
|
231
|
+
};
|
|
232
|
+
error: {
|
|
233
|
+
progress: string;
|
|
234
|
+
};
|
|
235
|
+
default: {
|
|
236
|
+
progress: string;
|
|
237
|
+
};
|
|
238
|
+
info: {
|
|
239
|
+
progress: string;
|
|
240
|
+
};
|
|
241
|
+
warning: {
|
|
242
|
+
progress: string;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
}>, unknown, unknown, undefined>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0-beta.0",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -20,17 +20,19 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@floating-ui/react": "^0.26.18",
|
|
22
22
|
"@internationalized/date": "*",
|
|
23
|
-
"@tecsinapse/cortex-core": "0.
|
|
23
|
+
"@tecsinapse/cortex-core": "0.4.0-beta.0",
|
|
24
24
|
"clsx": "*",
|
|
25
25
|
"currency.js": "~2.0.4",
|
|
26
26
|
"react-aria": "^3.33.1",
|
|
27
|
+
"react-dropzone": "^14.2.3",
|
|
27
28
|
"react-icons": "^5.2.1",
|
|
28
29
|
"react-imask": "7.6.1",
|
|
29
30
|
"react-spring": "^9.7.4",
|
|
30
31
|
"react-spring-carousel": "^2.0.19",
|
|
31
32
|
"react-stately": "^3.31.1",
|
|
32
33
|
"sonner": "^1.5.0",
|
|
33
|
-
"tailwind-merge": "*"
|
|
34
|
+
"tailwind-merge": "*",
|
|
35
|
+
"uuid": "^10.0.0"
|
|
34
36
|
},
|
|
35
37
|
"repository": {
|
|
36
38
|
"type": "git",
|
|
@@ -46,5 +48,5 @@
|
|
|
46
48
|
"react-dom": ">=18.0.0",
|
|
47
49
|
"tailwind": ">=3.3.0"
|
|
48
50
|
},
|
|
49
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "5031f62ebd62cf2e07f26aec3ca08eebf6d3d11c"
|
|
50
52
|
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var clsx = require('clsx');
|
|
4
|
-
var React = require('react');
|
|
5
|
-
require('../styles/calendar-cell.js');
|
|
6
|
-
require('../styles/groupButton.js');
|
|
7
|
-
var progressBar = require('../styles/progressBar.js');
|
|
8
|
-
|
|
9
|
-
const ProgressBar = ({
|
|
10
|
-
segments: _segments = 1,
|
|
11
|
-
valueMin = 0,
|
|
12
|
-
valueMax = 100,
|
|
13
|
-
valueCurrent = 50,
|
|
14
|
-
intentProgress = "default",
|
|
15
|
-
animated = true
|
|
16
|
-
}) => {
|
|
17
|
-
const [displayedValue, setDisplayedValue] = React.useState(0);
|
|
18
|
-
const [showAnimation, setShowAnimation] = React.useState(true);
|
|
19
|
-
React.useEffect(() => {
|
|
20
|
-
const timeout = setTimeout(() => {
|
|
21
|
-
if (valueCurrent < displayedValue) {
|
|
22
|
-
setShowAnimation(false);
|
|
23
|
-
}
|
|
24
|
-
if (animated && valueCurrent > displayedValue) setShowAnimation(true);
|
|
25
|
-
setDisplayedValue(valueCurrent);
|
|
26
|
-
}, 0);
|
|
27
|
-
return () => clearTimeout(timeout);
|
|
28
|
-
}, [valueCurrent]);
|
|
29
|
-
const progressStyle = React.useCallback(
|
|
30
|
-
(width, index) => {
|
|
31
|
-
return {
|
|
32
|
-
width: `${width}%`,
|
|
33
|
-
transitionDelay: `${showAnimation ? `${index * 1e3}ms` : `0ms`}`
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
[showAnimation]
|
|
37
|
-
);
|
|
38
|
-
const totalProgress = (displayedValue - valueMin) / (valueMax - valueMin) * 100;
|
|
39
|
-
const segments = Math.max(1, _segments);
|
|
40
|
-
const lengthSeg = 100 / Math.max(segments);
|
|
41
|
-
const items = [...Array(segments).keys()];
|
|
42
|
-
return /* @__PURE__ */ React.createElement("div", { className: "flex gap-x-nano flex-row" }, items.map((_, index) => {
|
|
43
|
-
const max = lengthSeg * (index + 1);
|
|
44
|
-
const min = lengthSeg * index;
|
|
45
|
-
const minmax = (totalProgress - min) / (max - min);
|
|
46
|
-
const width = (minmax > 1 ? 1 : minmax < 0 ? 0 : minmax) * 100;
|
|
47
|
-
return /* @__PURE__ */ React.createElement(
|
|
48
|
-
"div",
|
|
49
|
-
{
|
|
50
|
-
"data-testid": "progress-bar",
|
|
51
|
-
key: index,
|
|
52
|
-
className: clsx(
|
|
53
|
-
"h-[0.5rem] bg-secondary-light flex flex-1 first:rounded-l-pill last:rounded-r-pill"
|
|
54
|
-
)
|
|
55
|
-
},
|
|
56
|
-
/* @__PURE__ */ React.createElement(
|
|
57
|
-
"div",
|
|
58
|
-
{
|
|
59
|
-
"data-testid": "div-segment-filled",
|
|
60
|
-
style: progressStyle(width, index),
|
|
61
|
-
className: progressBar.progressBarFilled({
|
|
62
|
-
intentProgress,
|
|
63
|
-
showAnimation
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
)
|
|
67
|
-
);
|
|
68
|
-
}));
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
exports.ProgressBar = ProgressBar;
|