@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
package/dist/cjs/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var Loading = require('./components/Loading.js');
|
|
|
26
26
|
var index$1 = require('./components/Menubar/index.js');
|
|
27
27
|
var Modal = require('./components/Modal.js');
|
|
28
28
|
var index$2 = require('./components/Popover/index.js');
|
|
29
|
-
var ProgressBar = require('./components/ProgressBar.js');
|
|
29
|
+
var ProgressBar = require('./components/ProgressBar/ProgressBar.js');
|
|
30
30
|
var RadioButton = require('./components/RadioButton.js');
|
|
31
31
|
var index$3 = require('./components/Select/index.js');
|
|
32
32
|
var Skeleton = require('./components/Skeleton.js');
|
|
@@ -39,6 +39,7 @@ var TimeField = require('./components/TimeField/TimeField.js');
|
|
|
39
39
|
var TimeFieldInput = require('./components/TimeField/TimeFieldInput.js');
|
|
40
40
|
var Toggle = require('./components/Toggle.js');
|
|
41
41
|
var Tooltip = require('./components/Tooltip.js');
|
|
42
|
+
var index$5 = require('./components/Uploader/index.js');
|
|
42
43
|
var useCalendar = require('./hooks/useCalendar.js');
|
|
43
44
|
var useCalendarCell = require('./hooks/useCalendarCell.js');
|
|
44
45
|
var useCalendarGrid = require('./hooks/useCalendarGrid.js');
|
|
@@ -52,12 +53,15 @@ var useRangeCalendar = require('./hooks/useRangeCalendar.js');
|
|
|
52
53
|
var useSelectGroupedOptions = require('./hooks/useSelectGroupedOptions.js');
|
|
53
54
|
var useSelectOptions = require('./hooks/useSelectOptions.js');
|
|
54
55
|
var useStringMask = require('./hooks/useStringMask.js');
|
|
56
|
+
var useFileUpload = require('./hooks/useFileUpload.js');
|
|
55
57
|
var SnackbarSonner = require('./service/SnackbarSonner.js');
|
|
56
58
|
var MenubarProvider = require('./provider/MenubarProvider.js');
|
|
57
59
|
var SnackbarProvider = require('./provider/SnackbarProvider.js');
|
|
58
60
|
var MenubarContext = require('./provider/MenubarContext.js');
|
|
59
61
|
var useMenubar = require('./provider/useMenubar.js');
|
|
60
62
|
var masks = require('./components/Input/masks.js');
|
|
63
|
+
var Root = require('./components/Uploader/Root.js');
|
|
64
|
+
var types = require('./components/Uploader/types.js');
|
|
61
65
|
|
|
62
66
|
|
|
63
67
|
|
|
@@ -109,6 +113,7 @@ exports.TimeField = TimeField.TimeField;
|
|
|
109
113
|
exports.TimeFieldInput = TimeFieldInput.TimeFieldInput;
|
|
110
114
|
exports.Toggle = Toggle.Toggle;
|
|
111
115
|
exports.Tooltip = Tooltip.Tooltip;
|
|
116
|
+
exports.Uploader = index$5.Uploader;
|
|
112
117
|
exports.useCalendar = useCalendar.useCalendar;
|
|
113
118
|
exports.useCalendarCell = useCalendarCell.useCalendarCell;
|
|
114
119
|
exports.useCalendarGrid = useCalendarGrid.useCalendarGrid;
|
|
@@ -125,6 +130,7 @@ exports.useSelectOptions = useSelectOptions.useSelectOptions;
|
|
|
125
130
|
exports.getMask = useStringMask.getMask;
|
|
126
131
|
exports.mergeMask = useStringMask.mergeMask;
|
|
127
132
|
exports.useStringMask = useStringMask.useStringMask;
|
|
133
|
+
exports.useFileUpload = useFileUpload.useFileUpload;
|
|
128
134
|
exports.SnackbarSonner = SnackbarSonner.SnackbarSonner;
|
|
129
135
|
exports.MenubarProvider = MenubarProvider.MenubarProvider;
|
|
130
136
|
exports.SnackbarProvider = SnackbarProvider.SnackbarProvider;
|
|
@@ -138,3 +144,6 @@ exports.Masks = masks.Masks;
|
|
|
138
144
|
exports.NumberIMask = masks.NumberIMask;
|
|
139
145
|
exports.PercentageIMask = masks.PercentageIMask;
|
|
140
146
|
exports.PercentageMask = masks.PercentageMask;
|
|
147
|
+
exports.Root = Root.Root;
|
|
148
|
+
exports.AcceptSpecificMap = types.AcceptSpecificMap;
|
|
149
|
+
exports.FileStatus = types.FileStatus;
|
|
@@ -7,6 +7,8 @@ require('react-stately');
|
|
|
7
7
|
require('@floating-ui/react');
|
|
8
8
|
require('currency.js');
|
|
9
9
|
var useOutsideClickListener = require('../hooks/useOutsideClickListener.js');
|
|
10
|
+
require('react-dropzone');
|
|
11
|
+
require('uuid');
|
|
10
12
|
var MenubarContext = require('./MenubarContext.js');
|
|
11
13
|
|
|
12
14
|
const MenubarProvider = ({ children }) => {
|
|
@@ -10,12 +10,43 @@ const progressBarFilled = tailwindVariants.tv({
|
|
|
10
10
|
error: "bg-error-medium",
|
|
11
11
|
info: "bg-info-medium",
|
|
12
12
|
warning: "bg-warning-medium",
|
|
13
|
-
success: "bg-success-medium"
|
|
13
|
+
success: "bg-success-medium",
|
|
14
|
+
uploading: ""
|
|
14
15
|
},
|
|
15
16
|
showAnimation: {
|
|
16
17
|
true: "transition-[width] duration-1000 ease-linear"
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
});
|
|
21
|
+
const progressBarInfiniteVariants = tailwindVariants.tv({
|
|
22
|
+
slots: {
|
|
23
|
+
container: "relative mb-mili",
|
|
24
|
+
bar: "h-1.5 w-full overflow-hidden",
|
|
25
|
+
progress: "w-full h-full origin-left-right rounded-b-mili"
|
|
26
|
+
},
|
|
27
|
+
variants: {
|
|
28
|
+
status: {
|
|
29
|
+
uploading: {
|
|
30
|
+
progress: "bg-info-medium animate-progress"
|
|
31
|
+
},
|
|
32
|
+
success: {
|
|
33
|
+
progress: "bg-success-medium"
|
|
34
|
+
},
|
|
35
|
+
error: {
|
|
36
|
+
progress: "bg-error-medium"
|
|
37
|
+
},
|
|
38
|
+
default: {
|
|
39
|
+
progress: "bg-primary-medium"
|
|
40
|
+
},
|
|
41
|
+
info: {
|
|
42
|
+
progress: "bg-info-medium"
|
|
43
|
+
},
|
|
44
|
+
warning: {
|
|
45
|
+
progress: "bg-warning-medium"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
20
50
|
|
|
21
51
|
exports.progressBarFilled = progressBarFilled;
|
|
52
|
+
exports.progressBarInfiniteVariants = progressBarInfiniteVariants;
|
|
@@ -5,6 +5,8 @@ import 'react-stately';
|
|
|
5
5
|
import { useCalendarCell } from '../../hooks/useCalendarCell.js';
|
|
6
6
|
import '@floating-ui/react';
|
|
7
7
|
import 'currency.js';
|
|
8
|
+
import 'react-dropzone';
|
|
9
|
+
import 'uuid';
|
|
8
10
|
import { calendarCell } from '../../styles/calendar-cell.js';
|
|
9
11
|
import '../../styles/groupButton.js';
|
|
10
12
|
import '../../styles/progressBar.js';
|
|
@@ -5,6 +5,8 @@ import 'react-stately';
|
|
|
5
5
|
import { useCalendarGrid } from '../../hooks/useCalendarGrid.js';
|
|
6
6
|
import '@floating-ui/react';
|
|
7
7
|
import 'currency.js';
|
|
8
|
+
import 'react-dropzone';
|
|
9
|
+
import 'uuid';
|
|
8
10
|
import { CalendarGridBodyRows } from './CalendarGridBodyRows.js';
|
|
9
11
|
import { CalendarGridHeaderRow } from './CalendarGridHeaderRow.js';
|
|
10
12
|
|
|
@@ -5,6 +5,8 @@ import 'react-stately';
|
|
|
5
5
|
import '@floating-ui/react';
|
|
6
6
|
import 'currency.js';
|
|
7
7
|
import { useRangeCalendar } from '../../hooks/useRangeCalendar.js';
|
|
8
|
+
import 'react-dropzone';
|
|
9
|
+
import 'uuid';
|
|
8
10
|
import { CalendarGrid } from './CalendarGrid.js';
|
|
9
11
|
import { CalendarHeader } from './CalendarHeader.js';
|
|
10
12
|
|
|
@@ -6,6 +6,8 @@ import { dateToCalendarDate } from '../utils.js';
|
|
|
6
6
|
import { useDatePickerInput } from '../../hooks/useDatePickerInput.js';
|
|
7
7
|
import '@floating-ui/react';
|
|
8
8
|
import 'currency.js';
|
|
9
|
+
import 'react-dropzone';
|
|
10
|
+
import 'uuid';
|
|
9
11
|
import { Calendar } from '../Calendar/Calendar.js';
|
|
10
12
|
import { DateField } from './DateField.js';
|
|
11
13
|
import { DatePickerInputBase } from './DatePickerInputBase.js';
|
|
@@ -6,6 +6,8 @@ import { dateToCalendarDate } from '../utils.js';
|
|
|
6
6
|
import { useDateRangePickerInput } from '../../hooks/useDateRangePickerInput.js';
|
|
7
7
|
import '@floating-ui/react';
|
|
8
8
|
import 'currency.js';
|
|
9
|
+
import 'react-dropzone';
|
|
10
|
+
import 'uuid';
|
|
9
11
|
import { RangeCalendar } from '../Calendar/RangeCalendar.js';
|
|
10
12
|
import { DateField } from './DateField.js';
|
|
11
13
|
import { DatePickerInputBase } from './DatePickerInputBase.js';
|
|
@@ -5,6 +5,8 @@ import 'react-stately';
|
|
|
5
5
|
import '@floating-ui/react';
|
|
6
6
|
import { useNumberMask } from '../../hooks/useNumberMask.js';
|
|
7
7
|
import { useStringMask } from '../../hooks/useStringMask.js';
|
|
8
|
+
import 'react-dropzone';
|
|
9
|
+
import 'uuid';
|
|
8
10
|
import { InputRoot } from './Root.js';
|
|
9
11
|
|
|
10
12
|
const InputMask = React__default.forwardRef(
|
|
@@ -6,6 +6,8 @@ import 'react-stately';
|
|
|
6
6
|
import { useDebouncedState } from '../../hooks/useDebouncedState.js';
|
|
7
7
|
import '@floating-ui/react';
|
|
8
8
|
import 'currency.js';
|
|
9
|
+
import 'react-dropzone';
|
|
10
|
+
import 'uuid';
|
|
9
11
|
import { InputBox } from './Box.js';
|
|
10
12
|
import { InputFace } from './Face.js';
|
|
11
13
|
import { InputLeft } from './Left.js';
|
|
@@ -6,6 +6,8 @@ import 'react-aria';
|
|
|
6
6
|
import 'react-stately';
|
|
7
7
|
import '@floating-ui/react';
|
|
8
8
|
import 'currency.js';
|
|
9
|
+
import 'react-dropzone';
|
|
10
|
+
import 'uuid';
|
|
9
11
|
import '../../provider/MenubarContext.js';
|
|
10
12
|
import '../../provider/SnackbarProvider.js';
|
|
11
13
|
import { useMenubar } from '../../provider/useMenubar.js';
|
|
@@ -5,6 +5,8 @@ import 'react-aria';
|
|
|
5
5
|
import 'react-stately';
|
|
6
6
|
import '@floating-ui/react';
|
|
7
7
|
import 'currency.js';
|
|
8
|
+
import 'react-dropzone';
|
|
9
|
+
import 'uuid';
|
|
8
10
|
import '../../provider/MenubarContext.js';
|
|
9
11
|
import '../../provider/SnackbarProvider.js';
|
|
10
12
|
import { useMenubar } from '../../provider/useMenubar.js';
|
|
@@ -5,6 +5,8 @@ import 'react-aria';
|
|
|
5
5
|
import 'react-stately';
|
|
6
6
|
import '@floating-ui/react';
|
|
7
7
|
import 'currency.js';
|
|
8
|
+
import 'react-dropzone';
|
|
9
|
+
import 'uuid';
|
|
8
10
|
import '../../provider/MenubarContext.js';
|
|
9
11
|
import '../../provider/SnackbarProvider.js';
|
|
10
12
|
import { useMenubar } from '../../provider/useMenubar.js';
|
|
@@ -7,6 +7,8 @@ import 'react-aria';
|
|
|
7
7
|
import 'react-stately';
|
|
8
8
|
import '@floating-ui/react';
|
|
9
9
|
import 'currency.js';
|
|
10
|
+
import 'react-dropzone';
|
|
11
|
+
import 'uuid';
|
|
10
12
|
import '../../provider/MenubarContext.js';
|
|
11
13
|
import '../../provider/SnackbarProvider.js';
|
|
12
14
|
import { useMenubar } from '../../provider/useMenubar.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React__default, { useState, useEffect } from 'react';
|
|
2
|
+
import { ProgressBarInfinite } from './ProgressBarInfinite.js';
|
|
3
|
+
import { ProgressBarSegments } from './ProgressBarSegments.js';
|
|
4
|
+
|
|
5
|
+
const ProgressBar = ({
|
|
6
|
+
segments: _segments = 1,
|
|
7
|
+
valueMin = 0,
|
|
8
|
+
valueMax = 100,
|
|
9
|
+
valueCurrent = 50,
|
|
10
|
+
intentProgress = "default",
|
|
11
|
+
type = "default",
|
|
12
|
+
animated = true
|
|
13
|
+
}) => {
|
|
14
|
+
const [displayedValue, setDisplayedValue] = useState(0);
|
|
15
|
+
const [showAnimation, setShowAnimation] = useState(true);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const timeout = setTimeout(() => {
|
|
18
|
+
if (valueCurrent < displayedValue) {
|
|
19
|
+
setShowAnimation(false);
|
|
20
|
+
}
|
|
21
|
+
if (animated && valueCurrent > displayedValue) setShowAnimation(true);
|
|
22
|
+
setDisplayedValue(valueCurrent);
|
|
23
|
+
}, 0);
|
|
24
|
+
return () => clearTimeout(timeout);
|
|
25
|
+
}, [valueCurrent]);
|
|
26
|
+
const totalProgress = (displayedValue - valueMin) / (valueMax - valueMin) * 100;
|
|
27
|
+
const segments = Math.max(1, _segments);
|
|
28
|
+
return type === "infinite" ? /* @__PURE__ */ React__default.createElement(ProgressBarInfinite, { intentProgress }) : /* @__PURE__ */ React__default.createElement(
|
|
29
|
+
ProgressBarSegments,
|
|
30
|
+
{
|
|
31
|
+
segments,
|
|
32
|
+
totalProgress,
|
|
33
|
+
intentProgress,
|
|
34
|
+
showAnimation
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { ProgressBar };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import '../../styles/calendar-cell.js';
|
|
3
|
+
import '../../styles/groupButton.js';
|
|
4
|
+
import { progressBarInfiniteVariants } from '../../styles/progressBar.js';
|
|
5
|
+
|
|
6
|
+
const { container, bar, progress } = progressBarInfiniteVariants();
|
|
7
|
+
const ProgressBarInfinite = ({
|
|
8
|
+
intentProgress
|
|
9
|
+
}) => {
|
|
10
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: container() }, /* @__PURE__ */ React__default.createElement("div", { className: bar(), "data-testid": "infinite-progress-bar" }, /* @__PURE__ */ React__default.createElement("div", { className: progress({ status: intentProgress }) })));
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { ProgressBarInfinite };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React__default, { useCallback } from 'react';
|
|
2
|
+
import '../../styles/calendar-cell.js';
|
|
3
|
+
import '../../styles/groupButton.js';
|
|
4
|
+
import { progressBarFilled } from '../../styles/progressBar.js';
|
|
5
|
+
|
|
6
|
+
const ProgressBarSegments = ({
|
|
7
|
+
segments,
|
|
8
|
+
totalProgress,
|
|
9
|
+
intentProgress,
|
|
10
|
+
showAnimation
|
|
11
|
+
}) => {
|
|
12
|
+
const lengthSeg = 100 / segments;
|
|
13
|
+
const items = [...Array(segments).keys()];
|
|
14
|
+
const progressStyle = useCallback(
|
|
15
|
+
(width, index) => {
|
|
16
|
+
return {
|
|
17
|
+
width: `${width}%`,
|
|
18
|
+
transitionDelay: `${showAnimation ? `${index * 1e3}ms` : `0ms`}`
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
[showAnimation]
|
|
22
|
+
);
|
|
23
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "flex gap-x-nano flex-row", "data-testid": "progress-bar" }, items.map((_, index) => {
|
|
24
|
+
const max = lengthSeg * (index + 1);
|
|
25
|
+
const min = lengthSeg * index;
|
|
26
|
+
const minmax = (totalProgress - min) / (max - min);
|
|
27
|
+
const width = (minmax > 1 ? 1 : minmax < 0 ? 0 : minmax) * 100;
|
|
28
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
29
|
+
"div",
|
|
30
|
+
{
|
|
31
|
+
key: index,
|
|
32
|
+
className: "h-[0.5rem] bg-secondary-light flex flex-1 first:rounded-l-pill last:rounded-r-pill"
|
|
33
|
+
},
|
|
34
|
+
/* @__PURE__ */ React__default.createElement(
|
|
35
|
+
"div",
|
|
36
|
+
{
|
|
37
|
+
style: progressStyle(width, index),
|
|
38
|
+
"data-testid": "div-segment-filled",
|
|
39
|
+
className: progressBarFilled({ intentProgress, showAnimation })
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
);
|
|
43
|
+
}));
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { ProgressBarSegments };
|
|
@@ -6,6 +6,8 @@ import 'react-stately';
|
|
|
6
6
|
import '@floating-ui/react';
|
|
7
7
|
import 'currency.js';
|
|
8
8
|
import { useSelectGroupedOptions } from '../../hooks/useSelectGroupedOptions.js';
|
|
9
|
+
import 'react-dropzone';
|
|
10
|
+
import 'uuid';
|
|
9
11
|
import { usePopoverContext } from '../Popover/Context.js';
|
|
10
12
|
import { SelectOption } from './Option.js';
|
|
11
13
|
import { SkeletonOptions } from './SkeletonOptions.js';
|
|
@@ -6,6 +6,8 @@ import 'react-stately';
|
|
|
6
6
|
import '@floating-ui/react';
|
|
7
7
|
import 'currency.js';
|
|
8
8
|
import { useSelectGroupedOptions } from '../../hooks/useSelectGroupedOptions.js';
|
|
9
|
+
import 'react-dropzone';
|
|
10
|
+
import 'uuid';
|
|
9
11
|
import { SelectMultiOption } from './MultiOption.js';
|
|
10
12
|
import { SkeletonOptions } from './SkeletonOptions.js';
|
|
11
13
|
import { SelectContext, SelectMultiOptionsContext } from './context.js';
|
|
@@ -6,6 +6,8 @@ import 'react-stately';
|
|
|
6
6
|
import '@floating-ui/react';
|
|
7
7
|
import 'currency.js';
|
|
8
8
|
import { useSelectOptions } from '../../hooks/useSelectOptions.js';
|
|
9
|
+
import 'react-dropzone';
|
|
10
|
+
import 'uuid';
|
|
9
11
|
import { SelectMultiOption } from './MultiOption.js';
|
|
10
12
|
import { SkeletonOptions } from './SkeletonOptions.js';
|
|
11
13
|
import { SelectContext, SelectMultiOptionsContext } from './context.js';
|
|
@@ -6,6 +6,8 @@ import 'react-stately';
|
|
|
6
6
|
import '@floating-ui/react';
|
|
7
7
|
import 'currency.js';
|
|
8
8
|
import { useSelectOptions } from '../../hooks/useSelectOptions.js';
|
|
9
|
+
import 'react-dropzone';
|
|
10
|
+
import 'uuid';
|
|
9
11
|
import { usePopoverContext } from '../Popover/Context.js';
|
|
10
12
|
import { SelectOption } from './Option.js';
|
|
11
13
|
import { SkeletonOptions } from './SkeletonOptions.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { HiOutlineCloudArrowUp } from 'react-icons/hi2';
|
|
3
|
+
import { button } from '@tecsinapse/cortex-core';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
|
|
6
|
+
const Dropzone = ({
|
|
7
|
+
dropzoneProps,
|
|
8
|
+
selectFileText = "Select a file to start",
|
|
9
|
+
dropText = "By dragging and dropping it here or clicking the button below",
|
|
10
|
+
buttonText = "Select File"
|
|
11
|
+
}) => {
|
|
12
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
13
|
+
"div",
|
|
14
|
+
{
|
|
15
|
+
...dropzoneProps.getRootProps(),
|
|
16
|
+
className: clsx(
|
|
17
|
+
"bg-white w-full border-dashed border-2 p-deca flex flex-col justify-center rounded-mili",
|
|
18
|
+
{
|
|
19
|
+
"border-success-medium bg-gray-100": dropzoneProps.isDragActive
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
},
|
|
23
|
+
/* @__PURE__ */ React__default.createElement("input", { ...dropzoneProps.getInputProps() }),
|
|
24
|
+
/* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col justify-center text-center items-center gap-deca" }, /* @__PURE__ */ React__default.createElement(HiOutlineCloudArrowUp, { className: "text-primary-medium", size: 35 }), /* @__PURE__ */ React__default.createElement("div", { className: "gap-mili" }, /* @__PURE__ */ React__default.createElement("p", { className: "text-lg font-semibold", "data-testid": "select-dropzone" }, selectFileText), /* @__PURE__ */ React__default.createElement("p", { className: "text-sm text-secondary-medium" }, dropText)), /* @__PURE__ */ React__default.createElement("button", { className: button() }, buttonText))
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { Dropzone };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { File } from './Upload.js';
|
|
3
|
+
|
|
4
|
+
const Files = ({
|
|
5
|
+
files,
|
|
6
|
+
onDelete,
|
|
7
|
+
uploadProgressText = "Upload(s) in progress"
|
|
8
|
+
}) => {
|
|
9
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "bg-white w-full border-2 p-deca flex flex-col overflow-y-auto rounded-mili" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex gap-mili items-center mb-deca" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex items-center justify-center w-deca h-deca bg-primary-medium rounded-full text-micro text-white" }, `${files.length}`), /* @__PURE__ */ React__default.createElement("h2", { className: "text-md font-semibold", "data-testid": "upload-progress" }, uploadProgressText)), files.map((file, index) => /* @__PURE__ */ React__default.createElement(File, { key: file.uid, file, index, onDelete })));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { Files };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { MdClose } from 'react-icons/md';
|
|
3
|
+
import { button } from '@tecsinapse/cortex-core';
|
|
4
|
+
import { Modal as Modal$1 } from '../Modal.js';
|
|
5
|
+
import { createPortal } from 'react-dom';
|
|
6
|
+
|
|
7
|
+
const Modal = ({
|
|
8
|
+
open,
|
|
9
|
+
onClose,
|
|
10
|
+
children,
|
|
11
|
+
title = "File Upload"
|
|
12
|
+
}) => {
|
|
13
|
+
return createPortal(
|
|
14
|
+
/* @__PURE__ */ React__default.createElement(
|
|
15
|
+
Modal$1,
|
|
16
|
+
{
|
|
17
|
+
open,
|
|
18
|
+
onClose,
|
|
19
|
+
className: "flex-col w-[70%] h-[50%] bg-secondary-xlight rounded-mili"
|
|
20
|
+
},
|
|
21
|
+
/* @__PURE__ */ React__default.createElement("div", { className: "flex w-full items-center justify-between mb-deca" }, /* @__PURE__ */ React__default.createElement("div", null), /* @__PURE__ */ React__default.createElement("h2", { className: "text-deca font-semibold" }, title), /* @__PURE__ */ React__default.createElement(
|
|
22
|
+
"button",
|
|
23
|
+
{
|
|
24
|
+
className: button({ size: "square" }),
|
|
25
|
+
onClick: onClose,
|
|
26
|
+
"data-testid": "close-button"
|
|
27
|
+
},
|
|
28
|
+
/* @__PURE__ */ React__default.createElement(MdClose, { size: 20 })
|
|
29
|
+
)),
|
|
30
|
+
/* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col md:flex-row w-full h-full max-h-[85%] gap-deca" }, children)
|
|
31
|
+
),
|
|
32
|
+
document.body
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { Modal };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { Modal } from './Modal.js';
|
|
3
|
+
import { Dropzone } from './Dropzone.js';
|
|
4
|
+
import { Files } from './Files.js';
|
|
5
|
+
|
|
6
|
+
const Root = ({
|
|
7
|
+
open,
|
|
8
|
+
onClose,
|
|
9
|
+
files,
|
|
10
|
+
onDelete,
|
|
11
|
+
dropzoneProps,
|
|
12
|
+
selectFileText,
|
|
13
|
+
dropText,
|
|
14
|
+
buttonText,
|
|
15
|
+
uploadProgressText,
|
|
16
|
+
titleModal
|
|
17
|
+
}) => {
|
|
18
|
+
return /* @__PURE__ */ React__default.createElement(Modal, { onClose, open, title: titleModal }, /* @__PURE__ */ React__default.createElement(
|
|
19
|
+
Dropzone,
|
|
20
|
+
{
|
|
21
|
+
dropzoneProps,
|
|
22
|
+
selectFileText,
|
|
23
|
+
dropText,
|
|
24
|
+
buttonText
|
|
25
|
+
}
|
|
26
|
+
), /* @__PURE__ */ React__default.createElement(
|
|
27
|
+
Files,
|
|
28
|
+
{
|
|
29
|
+
files,
|
|
30
|
+
onDelete,
|
|
31
|
+
uploadProgressText
|
|
32
|
+
}
|
|
33
|
+
));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { Root };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { FaRegFileLines } from 'react-icons/fa6';
|
|
3
|
+
import { button } from '@tecsinapse/cortex-core';
|
|
4
|
+
import { MdClose } from 'react-icons/md';
|
|
5
|
+
import { ProgressBar } from '../ProgressBar/ProgressBar.js';
|
|
6
|
+
|
|
7
|
+
const File = ({ file, index, onDelete }) => {
|
|
8
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col", key: index }, /* @__PURE__ */ React__default.createElement("div", { className: "flex items-center justify-between border rounded-t-mili shadow p-mili" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex gap-centi" }, file.file && file.file.type.startsWith("image/") ? /* @__PURE__ */ React__default.createElement(
|
|
9
|
+
"img",
|
|
10
|
+
{
|
|
11
|
+
src: URL.createObjectURL(file.file),
|
|
12
|
+
alt: "Preview",
|
|
13
|
+
className: "w-tera h-tera rounded-mili"
|
|
14
|
+
}
|
|
15
|
+
) : /* @__PURE__ */ React__default.createElement("span", { className: "border-2 text-kilo text-primary-medium w-tera h-tera flex items-center justify-center rounded-mili" }, /* @__PURE__ */ React__default.createElement(FaRegFileLines, null)), /* @__PURE__ */ React__default.createElement("div", { className: "flex-col" }, /* @__PURE__ */ React__default.createElement("p", { className: "font-semibold truncate max-w-[200px]" }, file.file.name), /* @__PURE__ */ React__default.createElement("p", { className: "text-sm text-gray-500" }, (file.file.size / 1024).toFixed(2), " KB"))), file.status === "success" && /* @__PURE__ */ React__default.createElement(
|
|
16
|
+
"button",
|
|
17
|
+
{
|
|
18
|
+
onClick: () => onDelete(index),
|
|
19
|
+
"data-testid": "remove-button",
|
|
20
|
+
className: button({
|
|
21
|
+
className: " bg-inherit border-2 border-primary-light text-primary-light",
|
|
22
|
+
size: "small"
|
|
23
|
+
})
|
|
24
|
+
},
|
|
25
|
+
/* @__PURE__ */ React__default.createElement(MdClose, { size: 20 })
|
|
26
|
+
)), /* @__PURE__ */ React__default.createElement(ProgressBar, { intentProgress: file.status, type: "infinite" }));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { File };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var FileStatus = /* @__PURE__ */ ((FileStatus2) => {
|
|
2
|
+
FileStatus2["SUCCESS"] = "success";
|
|
3
|
+
FileStatus2["ERROR"] = "error";
|
|
4
|
+
FileStatus2["UPLOADING"] = "uploading";
|
|
5
|
+
return FileStatus2;
|
|
6
|
+
})(FileStatus || {});
|
|
7
|
+
const AcceptSpecificMap = {
|
|
8
|
+
APPLICATION: [
|
|
9
|
+
"application/pdf",
|
|
10
|
+
"application/zip",
|
|
11
|
+
"application/msword",
|
|
12
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
13
|
+
"application/vnd.ms-excel",
|
|
14
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
15
|
+
"application/vnd.ms-powerpoint",
|
|
16
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
17
|
+
"application/x-rar-compressed",
|
|
18
|
+
"application/x-7z-compressed",
|
|
19
|
+
"application/json",
|
|
20
|
+
"application/xml",
|
|
21
|
+
"application/rtf",
|
|
22
|
+
"application/x-tar",
|
|
23
|
+
"application/x-httpd-php",
|
|
24
|
+
"application/octet-stream"
|
|
25
|
+
],
|
|
26
|
+
IMAGE: [
|
|
27
|
+
"image/jpeg",
|
|
28
|
+
"image/png",
|
|
29
|
+
"image/gif",
|
|
30
|
+
"image/bmp",
|
|
31
|
+
"image/svg+xml",
|
|
32
|
+
"image/tiff",
|
|
33
|
+
"image/webp",
|
|
34
|
+
"image/x-icon"
|
|
35
|
+
],
|
|
36
|
+
VIDEO: [
|
|
37
|
+
"video/mp4",
|
|
38
|
+
"video/mpeg",
|
|
39
|
+
"video/quicktime",
|
|
40
|
+
"video/x-msvideo",
|
|
41
|
+
"video/x-ms-wmv",
|
|
42
|
+
"video/webm",
|
|
43
|
+
"video/ogg",
|
|
44
|
+
"video/x-flv"
|
|
45
|
+
],
|
|
46
|
+
AUDIO: [
|
|
47
|
+
"audio/mpeg",
|
|
48
|
+
"audio/wav",
|
|
49
|
+
"audio/ogg",
|
|
50
|
+
"audio/x-aac",
|
|
51
|
+
"audio/flac",
|
|
52
|
+
"audio/mp4",
|
|
53
|
+
"audio/aac",
|
|
54
|
+
"audio/webm"
|
|
55
|
+
],
|
|
56
|
+
TEXT: [
|
|
57
|
+
"text/plain",
|
|
58
|
+
"text/csv",
|
|
59
|
+
"text/html",
|
|
60
|
+
"text/css",
|
|
61
|
+
"text/xml",
|
|
62
|
+
"text/javascript",
|
|
63
|
+
"text/markdown"
|
|
64
|
+
]
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export { AcceptSpecificMap, FileStatus };
|