@tecsinapse/cortex-react 1.6.0 → 1.7.0-beta.1
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/Avatar.js +3 -2
- 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 +6 -4
- package/dist/cjs/components/DatePicker/DateRangePickerInput.js +9 -7
- package/dist/cjs/components/Input/Mask.js +2 -0
- package/dist/cjs/components/Input/Search.js +2 -0
- package/dist/cjs/components/Input/index.js +2 -0
- package/dist/cjs/components/Input/masks.js +4 -2
- 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 +4 -2
- package/dist/cjs/components/Popover/Trigger.js +3 -2
- 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 +15 -10
- 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/useCalendar.js +4 -3
- package/dist/cjs/hooks/useDatePickerInput.js +3 -3
- package/dist/cjs/hooks/useDateRangePickerInput.js +5 -5
- package/dist/cjs/hooks/useFileUpload.js +85 -0
- package/dist/cjs/hooks/{useFloatingLogic.js → useFloatingElement.js} +8 -12
- package/dist/cjs/hooks/useNumberMask.js +3 -2
- package/dist/cjs/hooks/useRangeCalendar.js +5 -5
- package/dist/cjs/index.js +12 -3
- package/dist/cjs/provider/MenubarProvider.js +2 -0
- package/dist/cjs/styles/progressBar.js +32 -1
- package/dist/cjs/{components/utils.js → utils/date.js} +0 -14
- package/dist/cjs/utils/react.js +9 -0
- package/dist/cjs/utils/string.js +12 -0
- package/dist/esm/components/Avatar.js +2 -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 +5 -3
- package/dist/esm/components/DatePicker/DateRangePickerInput.js +5 -3
- package/dist/esm/components/Input/Mask.js +2 -0
- package/dist/esm/components/Input/Search.js +2 -0
- package/dist/esm/components/Input/index.js +2 -0
- package/dist/esm/components/Input/masks.js +3 -1
- 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 +4 -2
- package/dist/esm/components/Popover/Trigger.js +2 -1
- 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 +12 -7
- 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/useCalendar.js +2 -1
- package/dist/esm/hooks/useDatePickerInput.js +1 -1
- package/dist/esm/hooks/useDateRangePickerInput.js +1 -1
- package/dist/esm/hooks/useFileUpload.js +83 -0
- package/dist/esm/hooks/{useFloatingLogic.js → useFloatingElement.js} +8 -12
- package/dist/esm/hooks/useNumberMask.js +2 -1
- package/dist/esm/hooks/useRangeCalendar.js +1 -1
- package/dist/esm/index.js +6 -2
- package/dist/esm/provider/MenubarProvider.js +2 -0
- package/dist/esm/styles/progressBar.js +32 -2
- package/dist/esm/utils/date.js +14 -0
- package/dist/esm/utils/react.js +7 -0
- package/dist/esm/utils/string.js +10 -0
- 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/Tooltip.d.ts +2 -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 +2 -1
- package/dist/types/hooks/useFileUpload.d.ts +23 -0
- package/dist/types/hooks/{useFloatingLogic.d.ts → useFloatingElement.d.ts} +8 -6
- package/dist/types/styles/progressBar.d.ts +167 -0
- package/dist/types/utils/date.d.ts +3 -0
- package/dist/types/utils/index.d.ts +4 -1
- package/dist/types/utils/react.d.ts +2 -0
- package/dist/types/utils/string.d.ts +1 -0
- package/package.json +6 -4
- package/dist/cjs/components/ProgressBar.js +0 -71
- package/dist/esm/components/ProgressBar.js +0 -69
- package/dist/esm/components/utils.js +0 -26
- package/dist/types/components/utils.d.ts +0 -6
- /package/dist/cjs/utils/{extractNumbersFromString.js → extractors.js} +0 -0
- /package/dist/esm/utils/{extractNumbersFromString.js → extractors.js} +0 -0
- /package/dist/types/utils/{extractNumbersFromString.d.ts → extractors.d.ts} +0 -0
|
@@ -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';
|
|
@@ -2,8 +2,10 @@ import React__default from 'react';
|
|
|
2
2
|
import '@internationalized/date';
|
|
3
3
|
import 'react-aria';
|
|
4
4
|
import 'react-stately';
|
|
5
|
-
import {
|
|
5
|
+
import { useFloatingElement } from '../../hooks/useFloatingElement.js';
|
|
6
6
|
import 'currency.js';
|
|
7
|
+
import 'react-dropzone';
|
|
8
|
+
import 'uuid';
|
|
7
9
|
import { Context } from './Context.js';
|
|
8
10
|
|
|
9
11
|
const PopoverProvider = ({
|
|
@@ -11,7 +13,7 @@ const PopoverProvider = ({
|
|
|
11
13
|
placement,
|
|
12
14
|
trigger
|
|
13
15
|
}) => {
|
|
14
|
-
const floatingLogic =
|
|
16
|
+
const floatingLogic = useFloatingElement({ placement, trigger });
|
|
15
17
|
return /* @__PURE__ */ React__default.createElement(Context.Provider, { value: { ...floatingLogic } }, children);
|
|
16
18
|
};
|
|
17
19
|
|
|
@@ -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';
|
|
@@ -3,9 +3,11 @@ import React__default, { forwardRef, useRef } from 'react';
|
|
|
3
3
|
import '@internationalized/date';
|
|
4
4
|
import 'react-aria';
|
|
5
5
|
import 'react-stately';
|
|
6
|
-
import { cloneWithProps } from '
|
|
7
|
-
import {
|
|
6
|
+
import { cloneWithProps } from '../utils/react.js';
|
|
7
|
+
import { useFloatingElement } from '../hooks/useFloatingElement.js';
|
|
8
8
|
import 'currency.js';
|
|
9
|
+
import 'react-dropzone';
|
|
10
|
+
import 'uuid';
|
|
9
11
|
|
|
10
12
|
const Tooltip = forwardRef(
|
|
11
13
|
(props, ref) => {
|
|
@@ -15,7 +17,8 @@ const Tooltip = forwardRef(
|
|
|
15
17
|
trigger = "hover",
|
|
16
18
|
placement = "top",
|
|
17
19
|
width,
|
|
18
|
-
height
|
|
20
|
+
height,
|
|
21
|
+
delay = { open: 500, close: 0 }
|
|
19
22
|
} = props;
|
|
20
23
|
const arrowRef = useRef(null);
|
|
21
24
|
const {
|
|
@@ -26,8 +29,9 @@ const Tooltip = forwardRef(
|
|
|
26
29
|
strategy,
|
|
27
30
|
refs,
|
|
28
31
|
context,
|
|
29
|
-
floatingStyles
|
|
30
|
-
|
|
32
|
+
floatingStyles,
|
|
33
|
+
getFloatingProps
|
|
34
|
+
} = useFloatingElement({ placement, arrowRef, trigger, delay });
|
|
31
35
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, cloneWithProps(children, triggerProps), isOpen ? /* @__PURE__ */ React__default.createElement(
|
|
32
36
|
"div",
|
|
33
37
|
{
|
|
@@ -40,11 +44,12 @@ const Tooltip = forwardRef(
|
|
|
40
44
|
width,
|
|
41
45
|
height,
|
|
42
46
|
...floatingStyles
|
|
43
|
-
}
|
|
47
|
+
},
|
|
48
|
+
...getFloatingProps()
|
|
44
49
|
},
|
|
45
50
|
text,
|
|
46
51
|
/* @__PURE__ */ React__default.createElement(FloatingArrow, { ref: arrowRef, context, fill: "black" })
|
|
47
|
-
) :
|
|
52
|
+
) : null);
|
|
48
53
|
}
|
|
49
54
|
);
|
|
50
55
|
|
|
@@ -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 };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createCalendar } from '@internationalized/date';
|
|
2
2
|
import { useLocale, useCalendar as useCalendar$1 } from 'react-aria';
|
|
3
3
|
import { useCalendarState } from 'react-stately';
|
|
4
|
-
import { dateToCalendarDate, calendarDateToDate } from '../
|
|
4
|
+
import { dateToCalendarDate, calendarDateToDate } from '../utils/date.js';
|
|
5
|
+
import 'react';
|
|
5
6
|
|
|
6
7
|
const useCalendar = ({ value, onChange }) => {
|
|
7
8
|
const { locale } = useLocale();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
2
|
import { useDatePicker } from 'react-aria';
|
|
3
3
|
import { useDatePickerState } from 'react-stately';
|
|
4
|
-
import { dateToCalendarDate, calendarDateToDate } from '../
|
|
4
|
+
import { dateToCalendarDate, calendarDateToDate } from '../utils/date.js';
|
|
5
5
|
|
|
6
6
|
const useDatePickerInput = ({
|
|
7
7
|
value,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
2
|
import { useDateRangePicker } from 'react-aria';
|
|
3
3
|
import { useDateRangePickerState } from 'react-stately';
|
|
4
|
-
import { dateToCalendarDate, calendarDateToDate } from '../
|
|
4
|
+
import { dateToCalendarDate, calendarDateToDate } from '../utils/date.js';
|
|
5
5
|
|
|
6
6
|
const useDateRangePickerInput = ({
|
|
7
7
|
value,
|
|
@@ -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 };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { useFloating, autoUpdate, offset, flip, shift, arrow, useClick, useDismiss, useRole, useHover, useInteractions } from '@floating-ui/react';
|
|
1
2
|
import { useState, useEffect } from 'react';
|
|
2
|
-
import { useFloating, autoUpdate, offset, flip, shift, arrow, useClick, useDismiss, useRole, useInteractions } from '@floating-ui/react';
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const useFloatingElement = ({
|
|
5
5
|
placement,
|
|
6
6
|
trigger,
|
|
7
|
+
delay,
|
|
7
8
|
arrowRef
|
|
8
9
|
}) => {
|
|
9
10
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -24,26 +25,21 @@ const useFloatingLogic = ({
|
|
|
24
25
|
]
|
|
25
26
|
}
|
|
26
27
|
);
|
|
27
|
-
const click = useClick(context);
|
|
28
|
+
const click = useClick(context, { enabled: trigger === "click" });
|
|
28
29
|
const dismiss = useDismiss(context);
|
|
29
30
|
const role = useRole(context);
|
|
31
|
+
const hover = useHover(context, { enabled: trigger === "hover", delay });
|
|
30
32
|
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
31
33
|
click,
|
|
32
34
|
dismiss,
|
|
33
|
-
role
|
|
35
|
+
role,
|
|
36
|
+
hover
|
|
34
37
|
]);
|
|
35
38
|
useEffect(() => {
|
|
36
39
|
if (isOpen) update();
|
|
37
40
|
}, [isOpen, update]);
|
|
38
41
|
const triggerProps = {
|
|
39
42
|
ref: refs.setReference,
|
|
40
|
-
...trigger === "hover" && {
|
|
41
|
-
onMouseEnter: () => setIsOpen(true),
|
|
42
|
-
onMouseLeave: () => setIsOpen(false)
|
|
43
|
-
},
|
|
44
|
-
...trigger === "click" && {
|
|
45
|
-
onClick: () => setIsOpen((prev) => !prev)
|
|
46
|
-
},
|
|
47
43
|
...getReferenceProps()
|
|
48
44
|
};
|
|
49
45
|
return {
|
|
@@ -61,4 +57,4 @@ const useFloatingLogic = ({
|
|
|
61
57
|
};
|
|
62
58
|
};
|
|
63
59
|
|
|
64
|
-
export {
|
|
60
|
+
export { useFloatingElement };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import currency from 'currency.js';
|
|
2
2
|
import { useCallback, useState } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import '@internationalized/date';
|
|
4
|
+
import { extractNumbersFromString } from '../utils/extractors.js';
|
|
4
5
|
|
|
5
6
|
const DEFAULT_OPTIONS = {
|
|
6
7
|
symbol: "R$ ",
|
|
@@ -2,7 +2,7 @@ import { createCalendar } from '@internationalized/date';
|
|
|
2
2
|
import { useRef } from 'react';
|
|
3
3
|
import { useLocale, useRangeCalendar as useRangeCalendar$1 } from 'react-aria';
|
|
4
4
|
import { useRangeCalendarState } from 'react-stately';
|
|
5
|
-
import { dateToCalendarDate, calendarDateToDate } from '../
|
|
5
|
+
import { dateToCalendarDate, calendarDateToDate } from '../utils/date.js';
|
|
6
6
|
|
|
7
7
|
const useRangeCalendar = ({
|
|
8
8
|
value,
|