@tecsinapse/cortex-react 1.2.2 → 1.3.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/BaseSnackbar.js +13 -0
- package/dist/cjs/components/BreadcrumbItem.js +2 -1
- package/dist/cjs/components/Breadcrumbs.js +1 -1
- package/dist/cjs/components/Button.js +10 -1
- package/dist/cjs/components/Calendar.js +23 -0
- package/dist/cjs/components/CalendarCell.js +51 -0
- package/dist/cjs/components/CalendarGrid.js +23 -0
- package/dist/cjs/components/CalendarGridBodyRows.js +12 -0
- package/dist/cjs/components/CalendarGridHeaderRow.js +12 -0
- package/dist/cjs/components/CalendarHeader.js +40 -0
- package/dist/cjs/components/Card.js +1 -1
- package/dist/cjs/components/DateField.js +25 -0
- package/dist/cjs/components/DatePickerInput.js +48 -0
- package/dist/cjs/components/DatePickerInputBase.js +24 -0
- package/dist/cjs/components/DateRangePickerInput.js +62 -0
- package/dist/cjs/components/DateSegment.js +20 -0
- package/dist/cjs/components/DefaultSnack.js +27 -0
- package/dist/cjs/components/Drawer.js +3 -1
- package/dist/cjs/components/GroupButton.js +43 -0
- package/dist/cjs/components/Input.js +5 -3
- package/dist/cjs/components/Modal.js +6 -13
- package/dist/cjs/components/ProgressBar.js +71 -0
- package/dist/cjs/components/RangeCalendar.js +36 -0
- package/dist/cjs/components/SearchInput.js +21 -10
- package/dist/cjs/components/Select.js +4 -4
- package/dist/cjs/components/Skeleton.js +4 -1
- package/dist/cjs/components/Table.js +9 -15
- package/dist/cjs/components/TextArea.js +2 -0
- package/dist/cjs/components/TimeField.js +12 -0
- package/dist/cjs/components/TimeFieldInput.js +22 -0
- package/dist/cjs/components/Toggle.js +17 -9
- package/dist/cjs/components/utils.js +19 -4
- package/dist/cjs/hooks/useCalendar.js +24 -0
- package/dist/cjs/hooks/useCalendarCell.js +35 -0
- package/dist/cjs/hooks/useCalendarGrid.js +14 -0
- package/dist/cjs/hooks/useDatePickerInput.js +31 -0
- package/dist/cjs/hooks/useDateRangePickerInput.js +33 -0
- package/dist/cjs/hooks/useRangeCalendar.js +36 -0
- package/dist/cjs/hooks/useTimeField.js +32 -0
- package/dist/cjs/index.js +47 -16
- package/dist/cjs/service/SnackbarSonner.js +55 -0
- package/dist/cjs/styles/calendar-cell.js +40 -0
- package/dist/cjs/styles/groupButton.js +16 -0
- package/dist/cjs/styles/progressBar.js +21 -0
- package/dist/esm/components/Avatar.js +4 -3
- package/dist/esm/components/BaseSnackbar.js +11 -0
- package/dist/esm/components/BreadcrumbItem.js +2 -1
- package/dist/esm/components/Breadcrumbs.js +1 -1
- package/dist/esm/components/Button.js +10 -1
- package/dist/esm/components/Calendar.js +21 -0
- package/dist/esm/components/CalendarCell.js +49 -0
- package/dist/esm/components/CalendarGrid.js +21 -0
- package/dist/esm/components/CalendarGridBodyRows.js +10 -0
- package/dist/esm/components/CalendarGridHeaderRow.js +10 -0
- package/dist/esm/components/CalendarHeader.js +38 -0
- package/dist/esm/components/Card.js +1 -1
- package/dist/esm/components/DateField.js +23 -0
- package/dist/esm/components/DatePickerInput.js +46 -0
- package/dist/esm/components/DatePickerInputBase.js +22 -0
- package/dist/esm/components/DateRangePickerInput.js +60 -0
- package/dist/esm/components/DateSegment.js +18 -0
- package/dist/esm/components/DefaultSnack.js +25 -0
- package/dist/esm/components/Drawer.js +3 -1
- package/dist/esm/components/GroupButton.js +41 -0
- package/dist/esm/components/Input.js +5 -3
- package/dist/esm/components/Modal.js +6 -13
- package/dist/esm/components/ProgressBar.js +69 -0
- package/dist/esm/components/RangeCalendar.js +34 -0
- package/dist/esm/components/SearchInput.js +21 -10
- package/dist/esm/components/Select.js +4 -4
- package/dist/esm/components/Skeleton.js +4 -1
- package/dist/esm/components/Table.js +10 -15
- package/dist/esm/components/TextArea.js +2 -0
- package/dist/esm/components/TimeField.js +10 -0
- package/dist/esm/components/TimeFieldInput.js +20 -0
- package/dist/esm/components/Toggle.js +17 -9
- package/dist/esm/components/utils.js +17 -4
- package/dist/esm/hooks/useCalendar.js +22 -0
- package/dist/esm/hooks/useCalendarCell.js +33 -0
- package/dist/esm/hooks/useCalendarGrid.js +12 -0
- package/dist/esm/hooks/useDatePickerInput.js +29 -0
- package/dist/esm/hooks/useDateRangePickerInput.js +31 -0
- package/dist/esm/hooks/useRangeCalendar.js +34 -0
- package/dist/esm/hooks/useTimeField.js +30 -0
- package/dist/esm/index.js +23 -7
- package/dist/esm/service/SnackbarSonner.js +53 -0
- package/dist/esm/styles/calendar-cell.js +38 -0
- package/dist/esm/styles/groupButton.js +14 -0
- package/dist/esm/styles/progressBar.js +19 -0
- package/dist/types/components/BaseSnackbar.d.ts +9 -0
- package/dist/types/components/BreadcrumbItem.d.ts +1 -3
- package/dist/types/components/Calendar.d.ts +6 -0
- package/dist/types/components/CalendarCell.d.ts +8 -0
- package/dist/types/components/CalendarGrid.d.ts +6 -0
- package/dist/types/components/CalendarGridBodyRows.d.ts +6 -0
- package/dist/types/components/CalendarGridHeaderRow.d.ts +5 -0
- package/dist/types/components/CalendarHeader.d.ts +6 -0
- package/dist/types/components/DateField.d.ts +5 -0
- package/dist/types/components/DatePickerInput.d.ts +6 -0
- package/dist/types/components/DatePickerInputBase.d.ts +8 -0
- package/dist/types/components/DateRangePickerInput.d.ts +7 -0
- package/dist/types/components/DateSegment.d.ts +7 -0
- package/dist/types/components/DefaultSnack.d.ts +6 -0
- package/dist/types/components/Drawer.d.ts +1 -1
- package/dist/types/components/GroupButton.d.ts +19 -0
- package/dist/types/components/Input.d.ts +2 -2
- package/dist/types/components/Modal.d.ts +2 -2
- package/dist/types/components/ProgressBar.d.ts +9 -0
- package/dist/types/components/RangeCalendar.d.ts +10 -0
- package/dist/types/components/SearchInput.d.ts +0 -1
- package/dist/types/components/Select.d.ts +0 -1
- package/dist/types/components/Skeleton.d.ts +4 -2
- package/dist/types/components/Table.d.ts +0 -1
- package/dist/types/components/TimeField.d.ts +7 -0
- package/dist/types/components/TimeFieldInput.d.ts +10 -0
- package/dist/types/components/index.d.ts +15 -7
- package/dist/types/components/utils.d.ts +4 -1
- package/dist/types/hooks/index.d.ts +6 -0
- package/dist/types/hooks/useCalendar.d.ts +10 -0
- package/dist/types/hooks/useCalendarCell.d.ts +18 -0
- package/dist/types/hooks/useCalendarGrid.d.ts +10 -0
- package/dist/types/hooks/useDatePickerInput.d.ts +10 -0
- package/dist/types/hooks/useDateRangePickerInput.d.ts +12 -0
- package/dist/types/hooks/useRangeCalendar.d.ts +12 -0
- package/dist/types/hooks/useTimeField.d.ts +7 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/provider/SnackbarProvider.d.ts +10 -0
- package/dist/types/service/ISnackbar.d.ts +7 -0
- package/dist/types/service/SnackbarSonner.d.ts +7 -0
- package/dist/types/service/index.d.ts +2 -0
- package/dist/types/styles/calendar-cell.d.ts +199 -0
- package/dist/types/styles/groupButton.d.ts +77 -0
- package/dist/types/styles/index.d.ts +3 -0
- package/dist/types/styles/progressBar.d.ts +78 -0
- package/dist/types/tests/Avatar.test.d.ts +1 -0
- package/dist/types/tests/Badge.test.d.ts +1 -0
- package/dist/types/tests/BreadcrumbItem.test.d.ts +1 -0
- package/dist/types/tests/Breadcrumbs.test.d.ts +1 -0
- package/dist/types/tests/Button.test.d.ts +1 -0
- package/dist/types/tests/Calendar.test.d.ts +1 -0
- package/dist/types/tests/CalendarCell.test.d.ts +1 -0
- package/dist/types/tests/CalendarGridBodyRows.test.d.ts +1 -0
- package/dist/types/tests/CalendarGridHeaderRow.test.d.ts +1 -0
- package/dist/types/tests/CalendarHeader.test.d.ts +1 -0
- package/dist/types/tests/Card.test.d.ts +1 -0
- package/dist/types/tests/DateField.test.d.ts +1 -0
- package/dist/types/tests/DatePickerInput.test.d.ts +1 -0
- package/dist/types/tests/DatePickerInputBase.test.d.ts +1 -0
- package/dist/types/tests/DateRangePickerInput.test.d.ts +1 -0
- package/dist/types/tests/DateSegment.test.d.ts +1 -0
- package/dist/types/tests/DefaultSnack.test.d.ts +1 -0
- package/dist/types/tests/Drawer.test.d.ts +1 -0
- package/dist/types/tests/GroupButton.test.d.ts +1 -0
- package/dist/types/tests/Hint.test.d.ts +1 -0
- package/dist/types/tests/Input.test.d.ts +1 -0
- package/dist/types/tests/Modal.test.d.ts +1 -0
- package/dist/types/tests/ProgressBar.test.d.ts +1 -0
- package/dist/types/tests/RangeCalendar.test.d.ts +1 -0
- package/dist/types/tests/SearchInput.test.d.ts +1 -0
- package/dist/types/tests/Select.test.d.ts +1 -0
- package/dist/types/tests/Skeleton.test.d.ts +1 -0
- package/dist/types/tests/Snackbar.test.d.ts +1 -0
- package/dist/types/tests/Table.test.d.ts +1 -0
- package/dist/types/tests/Tag.test.d.ts +1 -0
- package/dist/types/tests/TextArea.test.d.ts +1 -0
- package/dist/types/tests/TimeField.test.d.ts +1 -0
- package/dist/types/tests/TimeFieldInput.test.d.ts +1 -0
- package/dist/types/tests/Toggle.test.d.ts +1 -0
- package/dist/types/tests/useCalendarCell.test.d.ts +1 -0
- package/dist/types/tests/useDebouncedState.test.d.ts +1 -0
- package/dist/types/tests/utils.test.d.ts +1 -0
- package/package.json +10 -5
- package/dist/cjs/components/Snackbar.js +0 -18
- package/dist/esm/components/Snackbar.js +0 -16
- package/dist/types/components/Snackbar.d.ts +0 -9
|
@@ -3,21 +3,14 @@ import { overlay, modal } from '@tecsinapse/cortex-core';
|
|
|
3
3
|
|
|
4
4
|
const Modal = forwardRef((props, ref) => {
|
|
5
5
|
const { open, onClose, children, className } = props;
|
|
6
|
-
return /* @__PURE__ */ React.createElement(
|
|
6
|
+
return /* @__PURE__ */ React.createElement("div", { ref, ...props }, /* @__PURE__ */ React.createElement(
|
|
7
7
|
"div",
|
|
8
8
|
{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
{
|
|
15
|
-
className: overlay({ show: open }),
|
|
16
|
-
onClick: onClose
|
|
17
|
-
}
|
|
18
|
-
),
|
|
19
|
-
/* @__PURE__ */ React.createElement("dialog", { className: modal({ open, className }) }, children)
|
|
20
|
-
);
|
|
9
|
+
"data-testid": "overlay",
|
|
10
|
+
className: overlay({ show: open }),
|
|
11
|
+
onClick: onClose
|
|
12
|
+
}
|
|
13
|
+
), /* @__PURE__ */ React.createElement("dialog", { "data-testid": "modal", className: modal({ open, className }) }, children));
|
|
21
14
|
});
|
|
22
15
|
|
|
23
16
|
export { Modal };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import React, { useState, useEffect, useCallback } from 'react';
|
|
3
|
+
import '../styles/calendar-cell.js';
|
|
4
|
+
import '../styles/groupButton.js';
|
|
5
|
+
import { progressBarFilled } from '../styles/progressBar.js';
|
|
6
|
+
|
|
7
|
+
const ProgressBar = ({
|
|
8
|
+
segments: _segments = 1,
|
|
9
|
+
valueMin = 0,
|
|
10
|
+
valueMax = 100,
|
|
11
|
+
valueCurrent = 50,
|
|
12
|
+
intentProgress = "default",
|
|
13
|
+
animated = true
|
|
14
|
+
}) => {
|
|
15
|
+
const [displayedValue, setDisplayedValue] = useState(0);
|
|
16
|
+
const [showAnimation, setShowAnimation] = useState(true);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const timeout = setTimeout(() => {
|
|
19
|
+
if (valueCurrent < displayedValue) {
|
|
20
|
+
setShowAnimation(false);
|
|
21
|
+
}
|
|
22
|
+
if (animated && valueCurrent > displayedValue) setShowAnimation(true);
|
|
23
|
+
setDisplayedValue(valueCurrent);
|
|
24
|
+
}, 0);
|
|
25
|
+
return () => clearTimeout(timeout);
|
|
26
|
+
}, [valueCurrent]);
|
|
27
|
+
const progressStyle = useCallback(
|
|
28
|
+
(width, index) => {
|
|
29
|
+
return {
|
|
30
|
+
width: `${width}%`,
|
|
31
|
+
transitionDelay: `${showAnimation ? `${index * 1e3}ms` : `0ms`}`
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
[showAnimation]
|
|
35
|
+
);
|
|
36
|
+
const totalProgress = (displayedValue - valueMin) / (valueMax - valueMin) * 100;
|
|
37
|
+
const segments = Math.max(1, _segments);
|
|
38
|
+
const lengthSeg = 100 / Math.max(segments);
|
|
39
|
+
const items = [...Array(segments).keys()];
|
|
40
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex gap-x-nano flex-row" }, items.map((_, index) => {
|
|
41
|
+
const max = lengthSeg * (index + 1);
|
|
42
|
+
const min = lengthSeg * index;
|
|
43
|
+
const minmax = (totalProgress - min) / (max - min);
|
|
44
|
+
const width = (minmax > 1 ? 1 : minmax < 0 ? 0 : minmax) * 100;
|
|
45
|
+
return /* @__PURE__ */ React.createElement(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
"data-testid": "progress-bar",
|
|
49
|
+
key: index,
|
|
50
|
+
className: clsx(
|
|
51
|
+
"h-[0.5rem] bg-secondary-light flex flex-1 first:rounded-l-pill last:rounded-r-pill"
|
|
52
|
+
)
|
|
53
|
+
},
|
|
54
|
+
/* @__PURE__ */ React.createElement(
|
|
55
|
+
"div",
|
|
56
|
+
{
|
|
57
|
+
"data-testid": "div-segment-filled",
|
|
58
|
+
style: progressStyle(width, index),
|
|
59
|
+
className: progressBarFilled({
|
|
60
|
+
intentProgress,
|
|
61
|
+
showAnimation
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
}));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export { ProgressBar };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@internationalized/date';
|
|
3
|
+
import 'react-aria';
|
|
4
|
+
import 'react-stately';
|
|
5
|
+
import { useRangeCalendar } from '../hooks/useRangeCalendar.js';
|
|
6
|
+
import { CalendarGrid } from './CalendarGrid.js';
|
|
7
|
+
import { CalendarHeader } from './CalendarHeader.js';
|
|
8
|
+
|
|
9
|
+
const RangeCalendar = ({ value, onChange }) => {
|
|
10
|
+
const { calendarProps, state, title, ref } = useRangeCalendar({
|
|
11
|
+
value,
|
|
12
|
+
onChange
|
|
13
|
+
});
|
|
14
|
+
return /* @__PURE__ */ React.createElement(
|
|
15
|
+
"div",
|
|
16
|
+
{
|
|
17
|
+
...calendarProps,
|
|
18
|
+
className: "calendar",
|
|
19
|
+
ref,
|
|
20
|
+
"data-testid": "calendar-range-div"
|
|
21
|
+
},
|
|
22
|
+
/* @__PURE__ */ React.createElement(
|
|
23
|
+
CalendarHeader,
|
|
24
|
+
{
|
|
25
|
+
onClickPrevButton: () => state.focusPreviousPage(),
|
|
26
|
+
onClickNextButton: () => state.focusNextPage(),
|
|
27
|
+
title
|
|
28
|
+
}
|
|
29
|
+
),
|
|
30
|
+
/* @__PURE__ */ React.createElement(CalendarGrid, { state })
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { RangeCalendar };
|
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import 'clsx';
|
|
3
|
+
import '@internationalized/date';
|
|
2
4
|
import './Badge.js';
|
|
3
|
-
import
|
|
5
|
+
import './BaseSnackbar.js';
|
|
6
|
+
import 'react-icons/md';
|
|
4
7
|
import './Card.js';
|
|
5
|
-
import './
|
|
8
|
+
import { Button } from './Button.js';
|
|
9
|
+
import 'react-aria';
|
|
10
|
+
import 'react-stately';
|
|
11
|
+
import { useDebouncedState } from '../hooks/useDebouncedState.js';
|
|
12
|
+
import './CalendarCell.js';
|
|
13
|
+
import '@tecsinapse/cortex-core';
|
|
14
|
+
import 'react-icons/fa';
|
|
15
|
+
import 'react-icons/lia';
|
|
6
16
|
import { Input } from './Input.js';
|
|
17
|
+
import 'react-icons/io';
|
|
18
|
+
import './GroupButton.js';
|
|
19
|
+
import './Hint.js';
|
|
7
20
|
import './Modal.js';
|
|
21
|
+
import '../styles/calendar-cell.js';
|
|
22
|
+
import '../styles/groupButton.js';
|
|
23
|
+
import '../styles/progressBar.js';
|
|
8
24
|
import './Select.js';
|
|
9
|
-
import './Snackbar.js';
|
|
10
25
|
import './Tag.js';
|
|
11
|
-
import './Toggle.js';
|
|
12
26
|
import './TextArea.js';
|
|
13
|
-
import '
|
|
14
|
-
import 'react-icons/md';
|
|
15
|
-
import 'clsx';
|
|
27
|
+
import './Toggle.js';
|
|
16
28
|
import { AiOutlineLoading } from 'react-icons/ai';
|
|
17
29
|
import { IoSearchOutline } from 'react-icons/io5';
|
|
18
|
-
import { useDebouncedState } from '../hooks/useDebouncedState.js';
|
|
19
30
|
|
|
20
31
|
const inputFace = "bg-white w-full";
|
|
21
32
|
const inputLeft = "flex items-center";
|
|
@@ -43,7 +54,7 @@ const SearchInput = ({
|
|
|
43
54
|
onClick(searchInput);
|
|
44
55
|
}
|
|
45
56
|
};
|
|
46
|
-
return /* @__PURE__ */ React.createElement("div", { className: "flex flex-row w-full space-x-mili" }, /* @__PURE__ */ React.createElement(Input.Face, { variants: { className: inputFace } }, !onClick && /* @__PURE__ */ React.createElement(Input.Left, { className: inputLeft }, /* @__PURE__ */ React.createElement(IoSearchOutline,
|
|
57
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex flex-row w-full space-x-mili" }, /* @__PURE__ */ React.createElement(Input.Face, { variants: { className: inputFace } }, !onClick && /* @__PURE__ */ React.createElement(Input.Left, { className: inputLeft }, /* @__PURE__ */ React.createElement(IoSearchOutline, { "data-testid": "icon-search-left" })), /* @__PURE__ */ React.createElement(
|
|
47
58
|
Input.Box,
|
|
48
59
|
{
|
|
49
60
|
placeholder,
|
|
@@ -63,7 +74,7 @@ const SearchInput = ({
|
|
|
63
74
|
onClick: () => onClick(searchInput),
|
|
64
75
|
disabled: !searchInput || isSubmitting
|
|
65
76
|
},
|
|
66
|
-
isSubmitting ? /* @__PURE__ */ React.createElement("div", { className: "animate-spin" }, /* @__PURE__ */ React.createElement(AiOutlineLoading,
|
|
77
|
+
isSubmitting ? /* @__PURE__ */ React.createElement("div", { className: "animate-spin" }, /* @__PURE__ */ React.createElement(AiOutlineLoading, { "data-testid": "icon-loading" })) : /* @__PURE__ */ React.createElement(IoSearchOutline, { "data-testid": "icon-search-button" })
|
|
67
78
|
));
|
|
68
79
|
};
|
|
69
80
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { selectVariants, option } from '@tecsinapse/cortex-core';
|
|
2
2
|
import React, { useState, useMemo, useRef, useCallback, useEffect } from 'react';
|
|
3
|
-
import { Hint } from './Hint.js';
|
|
4
|
-
import { IoChevronDownOutline } from 'react-icons/io5';
|
|
5
3
|
import { IoIosCloseCircleOutline } from 'react-icons/io';
|
|
4
|
+
import { IoChevronDownOutline } from 'react-icons/io5';
|
|
5
|
+
import { Hint } from './Hint.js';
|
|
6
6
|
import SearchInput from './SearchInput.js';
|
|
7
7
|
|
|
8
8
|
const { button, dropdown, groupedTitle, containerGrouped, hintBody } = selectVariants();
|
|
@@ -64,7 +64,7 @@ const Select = (props) => {
|
|
|
64
64
|
onClick: () => setOpen((prevState) => !prevState),
|
|
65
65
|
disabled
|
|
66
66
|
},
|
|
67
|
-
/* @__PURE__ */ React.createElement("span",
|
|
67
|
+
/* @__PURE__ */ React.createElement("span", { "data-testid": "select-placeholder" }, placeholder),
|
|
68
68
|
/* @__PURE__ */ React.createElement(IoChevronDownOutline, null)
|
|
69
69
|
), /* @__PURE__ */ React.createElement(
|
|
70
70
|
"ul",
|
|
@@ -89,7 +89,7 @@ const Select = (props) => {
|
|
|
89
89
|
intent: variant
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
|
-
/* @__PURE__ */ React.createElement("div", { className: hintBody() }, variant === "error" ? /* @__PURE__ */ React.createElement(IoIosCloseCircleOutline,
|
|
92
|
+
/* @__PURE__ */ React.createElement("div", { className: hintBody() }, variant === "error" ? /* @__PURE__ */ React.createElement(IoIosCloseCircleOutline, { "data-testid": "select-hint-error-icon" }) : /* @__PURE__ */ React.createElement(React.Fragment, null), /* @__PURE__ */ React.createElement("span", null, hint))
|
|
93
93
|
));
|
|
94
94
|
};
|
|
95
95
|
|
|
@@ -3,14 +3,17 @@ import React from 'react';
|
|
|
3
3
|
|
|
4
4
|
const Skeleton = ({
|
|
5
5
|
className,
|
|
6
|
+
children,
|
|
6
7
|
...rest
|
|
7
8
|
}) => {
|
|
8
9
|
return /* @__PURE__ */ React.createElement(
|
|
9
10
|
"div",
|
|
10
11
|
{
|
|
11
12
|
...rest,
|
|
13
|
+
"data-testid": "skeleton",
|
|
12
14
|
className: clsx("animate-pulse bg-secondary-light", className)
|
|
13
|
-
}
|
|
15
|
+
},
|
|
16
|
+
children
|
|
14
17
|
);
|
|
15
18
|
};
|
|
16
19
|
|
|
@@ -1,47 +1,42 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { tHead, tRow, tHeadCell, hr, tCell, tFoot, tRoot } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React from 'react';
|
|
3
3
|
|
|
4
4
|
const THead = ({
|
|
5
5
|
children,
|
|
6
6
|
className,
|
|
7
7
|
...rest
|
|
8
|
-
}) => /* @__PURE__ */ React.createElement("thead", { className: tHead({ className }), ...rest }, children);
|
|
8
|
+
}) => /* @__PURE__ */ React.createElement("thead", { className: tHead({ className }), "data-testid": "thead", ...rest }, children);
|
|
9
9
|
const TRow = ({
|
|
10
10
|
children,
|
|
11
11
|
className,
|
|
12
12
|
...rest
|
|
13
|
-
}) => /* @__PURE__ */ React.createElement("tr", { className: tRow({ className }), ...rest }, children);
|
|
13
|
+
}) => /* @__PURE__ */ React.createElement("tr", { className: tRow({ className }), "data-testid": "trow", ...rest }, children);
|
|
14
14
|
const THeadCell = ({
|
|
15
15
|
children,
|
|
16
16
|
className,
|
|
17
17
|
...rest
|
|
18
|
-
}) => /* @__PURE__ */ React.createElement("th", { className: tHeadCell({ className }), ...rest }, children);
|
|
18
|
+
}) => /* @__PURE__ */ React.createElement("th", { className: tHeadCell({ className }), "data-testid": "thead-cell", ...rest }, children);
|
|
19
19
|
const TRowHeader = ({
|
|
20
20
|
children
|
|
21
|
-
}) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("tr", { className: tRow() }, children), /* @__PURE__ */ React.createElement("tr", { className: tRow() }, /* @__PURE__ */ React.createElement("td", { colSpan: 99 }, /* @__PURE__ */ React.createElement("hr", { className: hr() }))));
|
|
21
|
+
}) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("tr", { className: tRow(), "data-testid": "trow-header" }, children), /* @__PURE__ */ React.createElement("tr", { className: tRow() }, /* @__PURE__ */ React.createElement("td", { colSpan: 99 }, /* @__PURE__ */ React.createElement("hr", { className: hr() }))));
|
|
22
22
|
const TCell = ({
|
|
23
23
|
children,
|
|
24
24
|
className,
|
|
25
25
|
...rest
|
|
26
|
-
}) => /* @__PURE__ */ React.createElement("td", { className: tCell({ className }), ...rest }, children);
|
|
26
|
+
}) => /* @__PURE__ */ React.createElement("td", { className: tCell({ className }), "data-testid": "tcell", ...rest }, children);
|
|
27
27
|
const TFoot = ({
|
|
28
28
|
children,
|
|
29
29
|
className,
|
|
30
30
|
...rest
|
|
31
|
-
}) => /* @__PURE__ */ React.createElement("tfoot", { className: tFoot({ className }), ...rest }, children);
|
|
31
|
+
}) => /* @__PURE__ */ React.createElement("tfoot", { className: tFoot({ className }), "data-testid": "tfoot", ...rest }, children);
|
|
32
32
|
const Table = ({
|
|
33
33
|
children,
|
|
34
34
|
className,
|
|
35
35
|
...rest
|
|
36
|
-
}) => /* @__PURE__ */ React.createElement("table", { className: tRoot({ className }), ...rest }, children);
|
|
37
|
-
const Hr = ({
|
|
38
|
-
children,
|
|
39
|
-
className,
|
|
40
|
-
...rest
|
|
41
|
-
}) => /* @__PURE__ */ React.createElement("hr", { className: hr({ className }), ...rest }, children);
|
|
36
|
+
}) => /* @__PURE__ */ React.createElement("table", { className: tRoot({ className }), "data-testid": "table", ...rest }, children);
|
|
42
37
|
const Td = ({
|
|
43
38
|
children,
|
|
44
39
|
...rest
|
|
45
|
-
}) => /* @__PURE__ */ React.createElement("td", { ...rest }, children);
|
|
40
|
+
}) => /* @__PURE__ */ React.createElement("td", { "data-testid": "td", ...rest }, children);
|
|
46
41
|
|
|
47
|
-
export {
|
|
42
|
+
export { TCell, TFoot, THead, THeadCell, TRow, TRowHeader, Table, Td };
|
|
@@ -12,6 +12,7 @@ const Box = React.forwardRef(
|
|
|
12
12
|
return /* @__PURE__ */ React.createElement("div", { className: "flex w-full flex-col" }, /* @__PURE__ */ React.createElement(
|
|
13
13
|
"textarea",
|
|
14
14
|
{
|
|
15
|
+
"data-testid": "textarea-box",
|
|
15
16
|
ref,
|
|
16
17
|
id: id ?? name,
|
|
17
18
|
name,
|
|
@@ -46,6 +47,7 @@ const Face = React.forwardRef(
|
|
|
46
47
|
{
|
|
47
48
|
ref,
|
|
48
49
|
className: clsx(input(variants), className),
|
|
50
|
+
"data-testid": "textarea-face",
|
|
49
51
|
id: "textarea-face",
|
|
50
52
|
...rest
|
|
51
53
|
},
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DateSegment } from './DateSegment.js';
|
|
3
|
+
import { useTimeField } from '../hooks/useTimeField.js';
|
|
4
|
+
|
|
5
|
+
const TimeField = (props) => {
|
|
6
|
+
const { fieldProps, ref, state } = useTimeField(props);
|
|
7
|
+
return /* @__PURE__ */ React.createElement("div", { ...fieldProps, ref, className: "flex flex-row" }, state.segments.map((segment, i) => /* @__PURE__ */ React.createElement(DateSegment, { key: i, segment, state })));
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { TimeField as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Input } from './Input.js';
|
|
3
|
+
import { labelStyle, inputBox } from '@tecsinapse/cortex-core';
|
|
4
|
+
import TimeField from './TimeField.js';
|
|
5
|
+
|
|
6
|
+
const TimeFieldInput = (props) => {
|
|
7
|
+
const { onChange, value, label, variants } = props;
|
|
8
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
9
|
+
Input.Face,
|
|
10
|
+
{
|
|
11
|
+
variants,
|
|
12
|
+
className: "flex flex-row",
|
|
13
|
+
"data-testid": "time-field-input"
|
|
14
|
+
},
|
|
15
|
+
/* @__PURE__ */ React.createElement("span", { className: labelStyle({}) }, label),
|
|
16
|
+
/* @__PURE__ */ React.createElement("div", { className: inputBox("", label) }, /* @__PURE__ */ React.createElement(TimeField, { onChange, value }))
|
|
17
|
+
));
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { TimeFieldInput };
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
1
|
import { styleLabelElement, styleInputElement, toggle } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
3
|
|
|
4
4
|
const Toggle = forwardRef((props, ref) => {
|
|
5
|
-
return /* @__PURE__ */ React.createElement(
|
|
6
|
-
"
|
|
5
|
+
return /* @__PURE__ */ React.createElement(
|
|
6
|
+
"div",
|
|
7
7
|
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
className: "flex flex-row items-center gap-x-centi",
|
|
9
|
+
"data-testid": "toggle-div"
|
|
10
|
+
},
|
|
11
|
+
/* @__PURE__ */ React.createElement("label", { className: styleLabelElement() }, /* @__PURE__ */ React.createElement(
|
|
12
|
+
"input",
|
|
13
|
+
{
|
|
14
|
+
type: "checkbox",
|
|
15
|
+
className: styleInputElement(),
|
|
16
|
+
ref,
|
|
17
|
+
"data-testid": "toggle-input",
|
|
18
|
+
...props
|
|
19
|
+
}
|
|
20
|
+
), /* @__PURE__ */ React.createElement("div", { className: toggle() }))
|
|
21
|
+
);
|
|
14
22
|
});
|
|
15
23
|
|
|
16
24
|
export { Toggle };
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import { CalendarDate, getLocalTimeZone } from '@internationalized/date';
|
|
2
|
+
|
|
3
|
+
const getNameInitials = (name) => {
|
|
2
4
|
const nameSplit = name.split(" ");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
const length = nameSplit.length;
|
|
6
|
+
if (length > 1) {
|
|
7
|
+
return `${nameSplit[0][0]}${nameSplit[length - 1][0]}`;
|
|
5
8
|
}
|
|
6
9
|
return name[0];
|
|
7
10
|
};
|
|
11
|
+
const dateToCalendarDate = (value) => {
|
|
12
|
+
return new CalendarDate(
|
|
13
|
+
value?.getFullYear() ?? (/* @__PURE__ */ new Date()).getFullYear(),
|
|
14
|
+
value?.getMonth() ? value.getMonth() + 1 : (/* @__PURE__ */ new Date()).getMonth() + 1,
|
|
15
|
+
value?.getDate() ?? (/* @__PURE__ */ new Date()).getDate()
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
const calendarDateToDate = (value) => {
|
|
19
|
+
return value.toDate(getLocalTimeZone());
|
|
20
|
+
};
|
|
8
21
|
|
|
9
|
-
export {
|
|
22
|
+
export { calendarDateToDate, dateToCalendarDate, getNameInitials };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createCalendar } from '@internationalized/date';
|
|
2
|
+
import { useLocale, useCalendar as useCalendar$1 } from 'react-aria';
|
|
3
|
+
import { useCalendarState } from 'react-stately';
|
|
4
|
+
import { dateToCalendarDate, calendarDateToDate } from '../components/utils.js';
|
|
5
|
+
|
|
6
|
+
const useCalendar = ({ value, onChange }) => {
|
|
7
|
+
const { locale } = useLocale();
|
|
8
|
+
const state = useCalendarState({
|
|
9
|
+
locale,
|
|
10
|
+
createCalendar,
|
|
11
|
+
defaultValue: dateToCalendarDate(value),
|
|
12
|
+
onChange: (value2) => onChange(calendarDateToDate(value2))
|
|
13
|
+
});
|
|
14
|
+
const { calendarProps, title } = useCalendar$1({}, state);
|
|
15
|
+
return {
|
|
16
|
+
calendarProps,
|
|
17
|
+
title,
|
|
18
|
+
state
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { useCalendar };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isSameDay } from '@internationalized/date';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { useCalendarCell as useCalendarCell$1 } from 'react-aria';
|
|
4
|
+
|
|
5
|
+
const useCalendarCell = ({ state, date }) => {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const {
|
|
8
|
+
cellProps,
|
|
9
|
+
buttonProps,
|
|
10
|
+
isSelected,
|
|
11
|
+
isOutsideVisibleRange,
|
|
12
|
+
formattedDate
|
|
13
|
+
} = useCalendarCell$1({ date }, state, ref);
|
|
14
|
+
const rangeStateHighlitedRange = state?.highlightedRange;
|
|
15
|
+
const isSameDayStart = rangeStateHighlitedRange ? isSameDay(date, state?.highlightedRange?.start) : void 0;
|
|
16
|
+
const isSameDayEnd = rangeStateHighlitedRange ? isSameDay(date, state?.highlightedRange?.end) : void 0;
|
|
17
|
+
const isSelectionStart = isSameDayStart && !isSameDayEnd;
|
|
18
|
+
const isSelectionEnd = isSameDayEnd && !isSameDayStart;
|
|
19
|
+
const inRange = date > rangeStateHighlitedRange?.start && date < rangeStateHighlitedRange?.end;
|
|
20
|
+
return {
|
|
21
|
+
ref,
|
|
22
|
+
cellProps,
|
|
23
|
+
buttonProps,
|
|
24
|
+
isSelected,
|
|
25
|
+
isOutsideVisibleRange,
|
|
26
|
+
formattedDate,
|
|
27
|
+
isSelectionStart,
|
|
28
|
+
isSelectionEnd,
|
|
29
|
+
inRange
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { useCalendarCell };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useCalendarGrid as useCalendarGrid$1 } from 'react-aria';
|
|
2
|
+
|
|
3
|
+
const useCalendarGrid = ({ state }) => {
|
|
4
|
+
const { gridProps, headerProps, weekDays } = useCalendarGrid$1({}, state);
|
|
5
|
+
return {
|
|
6
|
+
gridProps,
|
|
7
|
+
headerProps,
|
|
8
|
+
weekDays
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { useCalendarGrid };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { useDatePicker } from 'react-aria';
|
|
3
|
+
import { useDatePickerState } from 'react-stately';
|
|
4
|
+
import { dateToCalendarDate, calendarDateToDate } from '../components/utils.js';
|
|
5
|
+
|
|
6
|
+
const useDatePickerInput = ({
|
|
7
|
+
value,
|
|
8
|
+
onChange
|
|
9
|
+
}) => {
|
|
10
|
+
const state = useDatePickerState({
|
|
11
|
+
defaultValue: dateToCalendarDate(value),
|
|
12
|
+
onChange: (value2) => {
|
|
13
|
+
onChange(calendarDateToDate(value2));
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
const ref = useRef(null);
|
|
17
|
+
const { fieldProps } = useDatePicker(
|
|
18
|
+
{ "aria-label": "date-picker-field" },
|
|
19
|
+
state,
|
|
20
|
+
ref
|
|
21
|
+
);
|
|
22
|
+
return {
|
|
23
|
+
fieldProps,
|
|
24
|
+
state,
|
|
25
|
+
ref
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { useDatePickerInput };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { useDateRangePicker } from 'react-aria';
|
|
3
|
+
import { useDateRangePickerState } from 'react-stately';
|
|
4
|
+
import { dateToCalendarDate, calendarDateToDate } from '../components/utils.js';
|
|
5
|
+
|
|
6
|
+
const useDateRangePickerInput = ({
|
|
7
|
+
value,
|
|
8
|
+
onChange
|
|
9
|
+
}) => {
|
|
10
|
+
const state = useDateRangePickerState({
|
|
11
|
+
defaultValue: {
|
|
12
|
+
start: dateToCalendarDate(value?.start),
|
|
13
|
+
end: dateToCalendarDate(value?.end)
|
|
14
|
+
},
|
|
15
|
+
onChange: (value2) => {
|
|
16
|
+
onChange({
|
|
17
|
+
start: calendarDateToDate(value2.start),
|
|
18
|
+
end: calendarDateToDate(value2.end)
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const ref = useRef(null);
|
|
23
|
+
const { startFieldProps, endFieldProps } = useDateRangePicker(
|
|
24
|
+
{ "aria-label": "date-range-picker-field" },
|
|
25
|
+
state,
|
|
26
|
+
ref
|
|
27
|
+
);
|
|
28
|
+
return { startFieldProps, endFieldProps, state, ref };
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { useDateRangePickerInput };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createCalendar } from '@internationalized/date';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { useLocale, useRangeCalendar as useRangeCalendar$1 } from 'react-aria';
|
|
4
|
+
import { useRangeCalendarState } from 'react-stately';
|
|
5
|
+
import { dateToCalendarDate, calendarDateToDate } from '../components/utils.js';
|
|
6
|
+
|
|
7
|
+
const useRangeCalendar = ({
|
|
8
|
+
value,
|
|
9
|
+
onChange
|
|
10
|
+
}) => {
|
|
11
|
+
const { locale } = useLocale();
|
|
12
|
+
const state = useRangeCalendarState({
|
|
13
|
+
locale,
|
|
14
|
+
createCalendar,
|
|
15
|
+
defaultValue: {
|
|
16
|
+
start: dateToCalendarDate(value?.start),
|
|
17
|
+
end: dateToCalendarDate(value?.end)
|
|
18
|
+
},
|
|
19
|
+
onChange: (value2) => onChange({
|
|
20
|
+
start: calendarDateToDate(value2.start),
|
|
21
|
+
end: calendarDateToDate(value2.end)
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
const ref = useRef(null);
|
|
25
|
+
const { calendarProps, title } = useRangeCalendar$1({}, state, ref);
|
|
26
|
+
return {
|
|
27
|
+
calendarProps,
|
|
28
|
+
title,
|
|
29
|
+
state,
|
|
30
|
+
ref
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { useRangeCalendar };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useLocale, useTimeField as useTimeField$1 } from 'react-aria';
|
|
3
|
+
import { useTimeFieldState } from 'react-stately';
|
|
4
|
+
import { Time } from '@internationalized/date';
|
|
5
|
+
|
|
6
|
+
const useTimeField = (props) => {
|
|
7
|
+
const { value, onChange } = props;
|
|
8
|
+
const { locale } = useLocale();
|
|
9
|
+
const state = useTimeFieldState({
|
|
10
|
+
value: new Time(value?.hour, value?.minute),
|
|
11
|
+
onChange: (timeValue) => onChange({ hour: timeValue.hour, minute: timeValue.minute }),
|
|
12
|
+
locale
|
|
13
|
+
});
|
|
14
|
+
const ref = React.useRef(null);
|
|
15
|
+
const { fieldProps } = useTimeField$1(
|
|
16
|
+
{
|
|
17
|
+
"aria-label": "time-field",
|
|
18
|
+
hourCycle: 24
|
|
19
|
+
},
|
|
20
|
+
state,
|
|
21
|
+
ref
|
|
22
|
+
);
|
|
23
|
+
return {
|
|
24
|
+
fieldProps,
|
|
25
|
+
ref,
|
|
26
|
+
state
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { useTimeField };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
|
+
export { Avatar } from './components/Avatar.js';
|
|
1
2
|
export { Badge, BadgeAnchor } from './components/Badge.js';
|
|
3
|
+
export { BaseSnackbar } from './components/BaseSnackbar.js';
|
|
4
|
+
export { Breadcrumbs } from './components/Breadcrumbs.js';
|
|
2
5
|
export { Button } from './components/Button.js';
|
|
6
|
+
export { Calendar } from './components/Calendar.js';
|
|
3
7
|
export { Card } from './components/Card.js';
|
|
8
|
+
export { DatePickerInput } from './components/DatePickerInput.js';
|
|
9
|
+
export { DateRangePickerInput } from './components/DateRangePickerInput.js';
|
|
10
|
+
export { DefaultSnack } from './components/DefaultSnack.js';
|
|
11
|
+
export { Drawer } from './components/Drawer.js';
|
|
12
|
+
export { GroupButton } from './components/GroupButton.js';
|
|
4
13
|
export { Hint } from './components/Hint.js';
|
|
5
14
|
export { Box, Face, Input, Left, Right, Root } from './components/Input.js';
|
|
6
15
|
export { Modal } from './components/Modal.js';
|
|
16
|
+
export { ProgressBar } from './components/ProgressBar.js';
|
|
17
|
+
export { RangeCalendar } from './components/RangeCalendar.js';
|
|
7
18
|
export { Select } from './components/Select.js';
|
|
8
|
-
export {
|
|
19
|
+
export { Skeleton } from './components/Skeleton.js';
|
|
20
|
+
export { TCell, TFoot, THead, THeadCell, TRow, TRowHeader, Table, Td } from './components/Table.js';
|
|
9
21
|
export { Tag } from './components/Tag.js';
|
|
10
|
-
export { Toggle } from './components/Toggle.js';
|
|
11
22
|
export { TextArea } from './components/TextArea.js';
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
23
|
+
export { TimeFieldInput } from './components/TimeFieldInput.js';
|
|
24
|
+
export { Toggle } from './components/Toggle.js';
|
|
25
|
+
export { useCalendar } from './hooks/useCalendar.js';
|
|
26
|
+
export { useCalendarCell } from './hooks/useCalendarCell.js';
|
|
27
|
+
export { useCalendarGrid } from './hooks/useCalendarGrid.js';
|
|
28
|
+
export { useDatePickerInput } from './hooks/useDatePickerInput.js';
|
|
29
|
+
export { useDateRangePickerInput } from './hooks/useDateRangePickerInput.js';
|
|
30
|
+
export { useDebouncedState } from './hooks/useDebouncedState.js';
|
|
31
|
+
export { useRangeCalendar } from './hooks/useRangeCalendar.js';
|
|
32
|
+
export { SnackbarSonner } from './service/SnackbarSonner.js';
|