@tecsinapse/cortex-react 1.3.0-beta.0 → 1.3.0-beta.10
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.js +2 -0
- package/dist/cjs/components/CalendarCell.js +1 -0
- package/dist/cjs/components/CalendarGrid.js +1 -0
- package/dist/cjs/components/DateField.js +25 -0
- package/dist/cjs/components/DatePickerInput.js +49 -0
- package/dist/cjs/components/DatePickerInputBase.js +24 -0
- package/dist/cjs/components/DateRangePickerInput.js +63 -0
- package/dist/cjs/components/DateSegment.js +9 -1
- package/dist/cjs/components/Divider.js +10 -0
- package/dist/cjs/components/Input/Box.js +32 -0
- package/dist/cjs/components/Input/Face.js +30 -0
- package/dist/cjs/components/Input/Left.js +12 -0
- package/dist/cjs/components/Input/Right.js +12 -0
- package/dist/cjs/components/Input/Root.js +13 -0
- package/dist/cjs/components/Input/Search.js +25 -0
- package/dist/cjs/components/Input/index.js +19 -0
- package/dist/cjs/components/Masonry.js +49 -0
- package/dist/cjs/components/Menubar/Categories.js +10 -0
- package/dist/cjs/components/Menubar/Category.js +11 -0
- package/dist/cjs/components/Menubar/Dropdown.js +23 -0
- package/dist/cjs/components/Menubar/DropdownRoot.js +38 -0
- package/dist/cjs/components/Menubar/Header.js +26 -0
- package/dist/cjs/components/Menubar/IconControlSubItem.js +19 -0
- package/dist/cjs/components/Menubar/Item.js +22 -0
- package/dist/cjs/components/Menubar/ItemLink.js +18 -0
- package/dist/cjs/components/Menubar/Left.js +11 -0
- package/dist/cjs/components/Menubar/MostUsed.js +11 -0
- package/dist/cjs/components/Menubar/MostUsedItem.js +31 -0
- package/dist/cjs/components/Menubar/MostUsedList.js +58 -0
- package/dist/cjs/components/Menubar/Right.js +11 -0
- package/dist/cjs/components/Menubar/Root.js +11 -0
- package/dist/cjs/components/Menubar/Search.js +21 -0
- package/dist/cjs/components/Menubar/SubItem.js +20 -0
- package/dist/cjs/components/Menubar/index.js +33 -0
- package/dist/cjs/components/Popover/Content.js +31 -0
- package/dist/cjs/components/Popover/Context.js +15 -0
- package/dist/cjs/components/Popover/Provider.js +19 -0
- package/dist/cjs/components/Popover/Root.js +14 -0
- package/dist/cjs/components/Popover/Trigger.js +11 -0
- package/dist/cjs/components/Popover/index.js +15 -0
- package/dist/cjs/components/RangeCalendar.js +25 -32
- package/dist/cjs/components/Select/Content.js +27 -0
- package/dist/cjs/components/Select/GroupedOptions.js +34 -0
- package/dist/cjs/components/Select/Option.js +25 -0
- package/dist/cjs/components/Select/Options.js +31 -0
- package/dist/cjs/components/Select/Popover.js +10 -0
- package/dist/cjs/components/Select/Root.js +24 -0
- package/dist/cjs/components/Select/Trigger.js +28 -0
- package/dist/cjs/components/Select/context.js +10 -0
- package/dist/cjs/components/Select/index.js +19 -0
- package/dist/cjs/components/Table.js +2 -2
- package/dist/cjs/components/TimeFieldInput.js +2 -2
- package/dist/cjs/components/Tooltip.js +54 -0
- package/dist/cjs/components/utils.js +14 -0
- package/dist/cjs/hooks/useCalendar.js +3 -6
- package/dist/cjs/hooks/useDatePickerInput.js +31 -0
- package/dist/cjs/hooks/useDateRangePickerInput.js +33 -0
- package/dist/cjs/hooks/useFloatingLogic.js +53 -0
- package/dist/cjs/hooks/useOutsideClickListener.js +22 -0
- package/dist/cjs/hooks/useRangeCalendar.js +36 -0
- package/dist/cjs/index.js +30 -13
- package/dist/cjs/provider/MenubarProvider.js +22 -0
- package/dist/cjs/provider/SnackbarProvider.js +51 -0
- package/dist/cjs/service/SnackbarSonner.js +25 -3
- package/dist/cjs/styles/calendar-cell.js +3 -3
- package/dist/cjs/styles/menubar.js +62 -0
- package/dist/esm/components/Calendar.js +2 -0
- package/dist/esm/components/CalendarCell.js +1 -0
- package/dist/esm/components/CalendarGrid.js +1 -0
- package/dist/esm/components/DateField.js +23 -0
- package/dist/esm/components/DatePickerInput.js +47 -0
- package/dist/esm/components/DatePickerInputBase.js +22 -0
- package/dist/esm/components/DateRangePickerInput.js +61 -0
- package/dist/esm/components/DateSegment.js +9 -1
- package/dist/esm/components/Divider.js +8 -0
- package/dist/esm/components/Input/Box.js +30 -0
- package/dist/esm/components/Input/Face.js +28 -0
- package/dist/esm/components/Input/Left.js +10 -0
- package/dist/esm/components/Input/Right.js +10 -0
- package/dist/esm/components/Input/Root.js +11 -0
- package/dist/esm/components/Input/Search.js +23 -0
- package/dist/esm/components/Input/index.js +17 -0
- package/dist/esm/components/Masonry.js +47 -0
- package/dist/esm/components/Menubar/Categories.js +8 -0
- package/dist/esm/components/Menubar/Category.js +9 -0
- package/dist/esm/components/Menubar/Dropdown.js +21 -0
- package/dist/esm/components/Menubar/DropdownRoot.js +36 -0
- package/dist/esm/components/Menubar/Header.js +24 -0
- package/dist/esm/components/Menubar/IconControlSubItem.js +17 -0
- package/dist/esm/components/Menubar/Item.js +20 -0
- package/dist/esm/components/Menubar/ItemLink.js +16 -0
- package/dist/esm/components/Menubar/Left.js +9 -0
- package/dist/esm/components/Menubar/MostUsed.js +9 -0
- package/dist/esm/components/Menubar/MostUsedItem.js +29 -0
- package/dist/esm/components/Menubar/MostUsedList.js +56 -0
- package/dist/esm/components/Menubar/Right.js +9 -0
- package/dist/esm/components/Menubar/Root.js +9 -0
- package/dist/esm/components/Menubar/Search.js +19 -0
- package/dist/esm/components/Menubar/SubItem.js +18 -0
- package/dist/esm/components/Menubar/index.js +31 -0
- package/dist/esm/components/Popover/Content.js +29 -0
- package/dist/esm/components/Popover/Context.js +12 -0
- package/dist/esm/components/Popover/Provider.js +17 -0
- package/dist/esm/components/Popover/Root.js +12 -0
- package/dist/esm/components/Popover/Trigger.js +9 -0
- package/dist/esm/components/Popover/index.js +13 -0
- package/dist/esm/components/RangeCalendar.js +25 -32
- package/dist/esm/components/Select/Content.js +25 -0
- package/dist/esm/components/Select/GroupedOptions.js +32 -0
- package/dist/esm/components/Select/Option.js +23 -0
- package/dist/esm/components/Select/Options.js +29 -0
- package/dist/esm/components/Select/Popover.js +8 -0
- package/dist/esm/components/Select/Root.js +22 -0
- package/dist/esm/components/Select/Trigger.js +26 -0
- package/dist/esm/components/Select/context.js +8 -0
- package/dist/esm/components/Select/index.js +17 -0
- package/dist/esm/components/Table.js +2 -2
- package/dist/esm/components/TimeFieldInput.js +1 -1
- package/dist/esm/components/Tooltip.js +49 -0
- package/dist/esm/components/utils.js +13 -1
- package/dist/esm/hooks/useCalendar.js +4 -7
- package/dist/esm/hooks/useDatePickerInput.js +29 -0
- package/dist/esm/hooks/useDateRangePickerInput.js +31 -0
- package/dist/esm/hooks/useFloatingLogic.js +51 -0
- package/dist/esm/hooks/useOutsideClickListener.js +20 -0
- package/dist/esm/hooks/useRangeCalendar.js +34 -0
- package/dist/esm/index.js +15 -4
- package/dist/esm/provider/MenubarProvider.js +19 -0
- package/dist/esm/provider/SnackbarProvider.js +49 -0
- package/dist/esm/service/SnackbarSonner.js +25 -3
- package/dist/esm/styles/calendar-cell.js +3 -3
- package/dist/esm/styles/menubar.js +54 -0
- package/dist/types/components/Calendar.d.ts +1 -1
- package/dist/types/components/Card.d.ts +3 -4
- 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/Divider.d.ts +5 -0
- package/dist/types/components/Input/Box.d.ts +3 -0
- package/dist/types/components/Input/Face.d.ts +3 -0
- package/dist/types/components/Input/Left.d.ts +3 -0
- package/dist/types/components/Input/Right.d.ts +3 -0
- package/dist/types/components/Input/Root.d.ts +3 -0
- package/dist/types/components/Input/Search.d.ts +3 -0
- package/dist/types/components/Input/index.d.ts +9 -0
- package/dist/types/components/Input/types.d.ts +20 -0
- package/dist/types/components/Masonry.d.ts +7 -0
- package/dist/types/components/Menubar/Categories.d.ts +3 -0
- package/dist/types/components/Menubar/Category.d.ts +8 -0
- package/dist/types/components/Menubar/Dropdown.d.ts +3 -0
- package/dist/types/components/Menubar/DropdownRoot.d.ts +17 -0
- package/dist/types/components/Menubar/Header.d.ts +6 -0
- package/dist/types/components/Menubar/IconControlSubItem.d.ts +6 -0
- package/dist/types/components/Menubar/Item.d.ts +10 -0
- package/dist/types/components/Menubar/ItemLink.d.ts +8 -0
- package/dist/types/components/Menubar/Left.d.ts +3 -0
- package/dist/types/components/Menubar/MostUsed.d.ts +8 -0
- package/dist/types/components/Menubar/MostUsedItem.d.ts +8 -0
- package/dist/types/components/Menubar/MostUsedList.d.ts +3 -0
- package/dist/types/components/Menubar/Right.d.ts +3 -0
- package/dist/types/components/Menubar/Root.d.ts +6 -0
- package/dist/types/components/Menubar/Search.d.ts +3 -0
- package/dist/types/components/Menubar/SubItem.d.ts +6 -0
- package/dist/types/components/Menubar/index.d.ts +15 -0
- package/dist/types/components/Menubar/interface.d.ts +4 -0
- package/dist/types/components/Popover/Content.d.ts +6 -0
- package/dist/types/components/Popover/Context.d.ts +18 -0
- package/dist/types/components/Popover/Provider.d.ts +8 -0
- package/dist/types/components/Popover/Root.d.ts +8 -0
- package/dist/types/components/Popover/Trigger.d.ts +5 -0
- package/dist/types/components/Popover/index.d.ts +6 -0
- package/dist/types/components/RangeCalendar.d.ts +1 -1
- package/dist/types/components/SearchInput.d.ts +0 -10
- package/dist/types/components/Select/Content.d.ts +9 -0
- package/dist/types/components/Select/GroupedOptions.d.ts +6 -0
- package/dist/types/components/Select/Option.d.ts +5 -0
- package/dist/types/components/Select/Options.d.ts +5 -0
- package/dist/types/components/Select/Popover.d.ts +5 -0
- package/dist/types/components/Select/Root.d.ts +8 -0
- package/dist/types/components/Select/Trigger.d.ts +5 -0
- package/dist/types/components/Select/context.d.ts +7 -0
- package/dist/types/components/Select/index.d.ts +8 -0
- package/dist/types/components/Tooltip.d.ts +13 -0
- package/dist/types/components/index.d.ts +8 -2
- package/dist/types/components/utils.d.ts +3 -0
- package/dist/types/hooks/index.d.ts +5 -0
- package/dist/types/hooks/useCalendar.d.ts +1 -1
- package/dist/types/hooks/useDatePickerInput.d.ts +10 -0
- package/dist/types/hooks/useDateRangePickerInput.d.ts +12 -0
- package/dist/types/hooks/useFloatingLogic.d.ts +46 -0
- package/dist/types/hooks/useOutsideClickListener.d.ts +7 -0
- package/dist/types/hooks/useRangeCalendar.d.ts +12 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/provider/MenubarProvider.d.ts +8 -0
- package/dist/types/provider/index.d.ts +2 -0
- package/dist/types/styles/menubar.d.ts +346 -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/Divider.test.d.ts +1 -0
- package/dist/types/tests/Input/Box.test.d.ts +1 -0
- package/dist/types/tests/Input/Face.test.d.ts +1 -0
- package/dist/types/tests/Input/Left.test.d.ts +1 -0
- package/dist/types/tests/Input/Right.test.d.ts +1 -0
- package/dist/types/tests/Input/Root.test.d.ts +1 -0
- package/dist/types/tests/Input/Search.test.d.ts +1 -0
- package/dist/types/tests/Menubar/Categories.test.d.ts +1 -0
- package/dist/types/tests/Menubar/Category.test.d.ts +1 -0
- package/dist/types/tests/Menubar/Dropdown.test.d.ts +1 -0
- package/dist/types/tests/Menubar/DropdownRoot.test.d.ts +1 -0
- package/dist/types/tests/Menubar/Header.test.d.ts +1 -0
- package/dist/types/tests/Menubar/HeaderLeft.test.d.ts +1 -0
- package/dist/types/tests/Menubar/HeaderRigth.test.d.ts +1 -0
- package/dist/types/tests/Menubar/Item.test.d.ts +1 -0
- package/dist/types/tests/Menubar/MostUsed.test.d.ts +1 -0
- package/dist/types/tests/Menubar/MostUsedItem.test.d.ts +1 -0
- package/dist/types/tests/Menubar/MostUsedList.test.d.ts +1 -0
- package/dist/types/tests/Menubar/Root.test.d.ts +1 -0
- package/dist/types/tests/Menubar/SubItem.test.d.ts +1 -0
- package/dist/types/tests/Popover.test.d.ts +1 -0
- package/dist/types/tests/RangeCalendar.test.d.ts +1 -0
- package/dist/types/tests/Tooltip.test.d.ts +1 -0
- package/dist/types/tests/useOutsideClickListener.test.d.ts +1 -0
- package/package.json +7 -4
- package/dist/cjs/components/Input.js +0 -81
- package/dist/cjs/components/SearchInput.js +0 -82
- package/dist/cjs/components/Select.js +0 -101
- package/dist/esm/components/Input.js +0 -74
- package/dist/esm/components/SearchInput.js +0 -80
- package/dist/esm/components/Select.js +0 -96
- package/dist/types/components/Input.d.ts +0 -34
- package/dist/types/components/Select.d.ts +0 -27
- /package/dist/types/tests/{Input.test.d.ts → DateField.test.d.ts} +0 -0
- /package/dist/types/tests/{SearchInput.test.d.ts → DatePickerInput.test.d.ts} +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { usePopoverContext } from './Context.js';
|
|
4
|
+
|
|
5
|
+
const PopoverContent = ({
|
|
6
|
+
children,
|
|
7
|
+
className
|
|
8
|
+
}) => {
|
|
9
|
+
const { isOpen, x, y, strategy, floatingStyles, refs } = usePopoverContext();
|
|
10
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, isOpen ? /* @__PURE__ */ React.createElement(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
ref: refs.setFloating,
|
|
14
|
+
className: clsx(
|
|
15
|
+
"border border-gray-200 bg-black p-4 rounded-md shadow-lg z-50",
|
|
16
|
+
className
|
|
17
|
+
),
|
|
18
|
+
style: {
|
|
19
|
+
position: strategy,
|
|
20
|
+
top: y ?? 0,
|
|
21
|
+
left: x ?? 0,
|
|
22
|
+
...floatingStyles
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
children
|
|
26
|
+
) : /* @__PURE__ */ React.createElement(React.Fragment, null));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { PopoverContent };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const Context = createContext(void 0);
|
|
4
|
+
const usePopoverContext = () => {
|
|
5
|
+
const context = useContext(Context);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error("usePopoverContext must be used within a PopoverProvider");
|
|
8
|
+
}
|
|
9
|
+
return context;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { Context, usePopoverContext };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@internationalized/date';
|
|
3
|
+
import 'react-aria';
|
|
4
|
+
import 'react-stately';
|
|
5
|
+
import { useFloatingLogic } from '../../hooks/useFloatingLogic.js';
|
|
6
|
+
import { Context } from './Context.js';
|
|
7
|
+
|
|
8
|
+
const PopoverProvider = ({
|
|
9
|
+
children,
|
|
10
|
+
placement,
|
|
11
|
+
trigger
|
|
12
|
+
}) => {
|
|
13
|
+
const floatingLogic = useFloatingLogic({ placement, trigger });
|
|
14
|
+
return /* @__PURE__ */ React.createElement(Context.Provider, { value: { ...floatingLogic } }, children);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { PopoverProvider };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover } from './index.js';
|
|
3
|
+
|
|
4
|
+
const PopoverRoot = ({
|
|
5
|
+
children,
|
|
6
|
+
placement,
|
|
7
|
+
trigger
|
|
8
|
+
}) => {
|
|
9
|
+
return /* @__PURE__ */ React.createElement(Popover.Provider, { placement, trigger }, children);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { PopoverRoot };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PopoverRoot } from './Root.js';
|
|
2
|
+
import { PopoverTrigger } from './Trigger.js';
|
|
3
|
+
import { PopoverContent } from './Content.js';
|
|
4
|
+
import { PopoverProvider } from './Provider.js';
|
|
5
|
+
|
|
6
|
+
const Popover = {
|
|
7
|
+
Root: PopoverRoot,
|
|
8
|
+
Trigger: PopoverTrigger,
|
|
9
|
+
Content: PopoverContent,
|
|
10
|
+
Provider: PopoverProvider
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { Popover };
|
|
@@ -1,42 +1,35 @@
|
|
|
1
|
-
import { createCalendar, CalendarDate, getLocalTimeZone } from '@internationalized/date';
|
|
2
1
|
import React from 'react';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import '@internationalized/date';
|
|
3
|
+
import 'react-aria';
|
|
4
|
+
import 'react-stately';
|
|
5
|
+
import { useRangeCalendar } from '../hooks/useRangeCalendar.js';
|
|
6
|
+
import '@floating-ui/react';
|
|
5
7
|
import { CalendarGrid } from './CalendarGrid.js';
|
|
6
8
|
import { CalendarHeader } from './CalendarHeader.js';
|
|
7
9
|
|
|
8
10
|
const RangeCalendar = ({ value, onChange }) => {
|
|
9
|
-
const {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
createCalendar,
|
|
13
|
-
defaultValue: {
|
|
14
|
-
start: new CalendarDate(
|
|
15
|
-
value.start.getFullYear(),
|
|
16
|
-
value.start.getMonth(),
|
|
17
|
-
value.start.getDate()
|
|
18
|
-
),
|
|
19
|
-
end: new CalendarDate(
|
|
20
|
-
value.end.getFullYear(),
|
|
21
|
-
value.end.getMonth(),
|
|
22
|
-
value.end.getDate()
|
|
23
|
-
)
|
|
24
|
-
},
|
|
25
|
-
onChange: (value2) => onChange({
|
|
26
|
-
start: value2.start.toDate(getLocalTimeZone()),
|
|
27
|
-
end: value2.end.toDate(getLocalTimeZone())
|
|
28
|
-
})
|
|
11
|
+
const { calendarProps, state, title, ref } = useRangeCalendar({
|
|
12
|
+
value,
|
|
13
|
+
onChange
|
|
29
14
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return /* @__PURE__ */ React.createElement("div", { ...calendarProps, className: "calendar", ref }, /* @__PURE__ */ React.createElement(
|
|
33
|
-
CalendarHeader,
|
|
15
|
+
return /* @__PURE__ */ React.createElement(
|
|
16
|
+
"div",
|
|
34
17
|
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
18
|
+
...calendarProps,
|
|
19
|
+
className: "calendar",
|
|
20
|
+
ref,
|
|
21
|
+
"data-testid": "calendar-range-div"
|
|
22
|
+
},
|
|
23
|
+
/* @__PURE__ */ React.createElement(
|
|
24
|
+
CalendarHeader,
|
|
25
|
+
{
|
|
26
|
+
onClickPrevButton: () => state.focusPreviousPage(),
|
|
27
|
+
onClickNextButton: () => state.focusNextPage(),
|
|
28
|
+
title
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
/* @__PURE__ */ React.createElement(CalendarGrid, { state })
|
|
32
|
+
);
|
|
40
33
|
};
|
|
41
34
|
|
|
42
35
|
export { RangeCalendar };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import '@internationalized/date';
|
|
3
|
+
import 'react-aria';
|
|
4
|
+
import 'react-stately';
|
|
5
|
+
import { useOutsideClickListener } from '../../hooks/useOutsideClickListener.js';
|
|
6
|
+
import '@floating-ui/react';
|
|
7
|
+
import { usePopoverContext } from '../Popover/Context.js';
|
|
8
|
+
import { SelectContext } from './context.js';
|
|
9
|
+
|
|
10
|
+
const Content = ({
|
|
11
|
+
children,
|
|
12
|
+
keyExtractor,
|
|
13
|
+
labelExtractor,
|
|
14
|
+
value
|
|
15
|
+
}) => {
|
|
16
|
+
const { setIsOpen } = usePopoverContext();
|
|
17
|
+
const ref = useRef(null);
|
|
18
|
+
useOutsideClickListener({
|
|
19
|
+
ref,
|
|
20
|
+
onClickOutside: () => setIsOpen(false)
|
|
21
|
+
});
|
|
22
|
+
return /* @__PURE__ */ React.createElement(SelectContext.Provider, { value: { value, keyExtractor, labelExtractor } }, /* @__PURE__ */ React.createElement("div", { className: "w-full relative bg-white", ref }, children));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { Content as default };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { selectVariants } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React, { useContext, useCallback } from 'react';
|
|
3
|
+
import { Select } from './index.js';
|
|
4
|
+
import { SelectContext } from './context.js';
|
|
5
|
+
import { usePopoverContext } from '../Popover/Context.js';
|
|
6
|
+
|
|
7
|
+
const { groupedTitle, containerGrouped } = selectVariants();
|
|
8
|
+
const SelectGroupedOptions = ({
|
|
9
|
+
onSelect,
|
|
10
|
+
groupedLabelExtractor,
|
|
11
|
+
options
|
|
12
|
+
}) => {
|
|
13
|
+
const { keyExtractor } = useContext(SelectContext);
|
|
14
|
+
const { setIsOpen } = usePopoverContext();
|
|
15
|
+
const handleSelect = useCallback(
|
|
16
|
+
(option) => {
|
|
17
|
+
onSelect(option);
|
|
18
|
+
setIsOpen?.(false);
|
|
19
|
+
},
|
|
20
|
+
[onSelect]
|
|
21
|
+
);
|
|
22
|
+
return /* @__PURE__ */ React.createElement("ul", { role: "select", className: containerGrouped() }, [...options ?? []].map(([key, value]) => /* @__PURE__ */ React.createElement("div", { key }, /* @__PURE__ */ React.createElement("span", { className: groupedTitle() }, groupedLabelExtractor?.(key)), value.map((option) => /* @__PURE__ */ React.createElement(
|
|
23
|
+
Select.Option,
|
|
24
|
+
{
|
|
25
|
+
option,
|
|
26
|
+
key: keyExtractor(option),
|
|
27
|
+
onSelectOption: handleSelect
|
|
28
|
+
}
|
|
29
|
+
)))));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { SelectGroupedOptions };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { option } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import { SelectContext } from './context.js';
|
|
4
|
+
|
|
5
|
+
const SelectOption = ({
|
|
6
|
+
onSelectOption,
|
|
7
|
+
option: option$1
|
|
8
|
+
}) => {
|
|
9
|
+
const { keyExtractor, labelExtractor, value } = useContext(SelectContext);
|
|
10
|
+
return /* @__PURE__ */ React.createElement(
|
|
11
|
+
"li",
|
|
12
|
+
{
|
|
13
|
+
onClick: () => onSelectOption(option$1),
|
|
14
|
+
className: option({
|
|
15
|
+
selected: value && keyExtractor(value) === keyExtractor(option$1)
|
|
16
|
+
}),
|
|
17
|
+
role: "option"
|
|
18
|
+
},
|
|
19
|
+
labelExtractor(option$1)
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { SelectOption };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { useContext, useCallback } from 'react';
|
|
2
|
+
import { SelectContext } from './context.js';
|
|
3
|
+
import { Select } from './index.js';
|
|
4
|
+
import { usePopoverContext } from '../Popover/Context.js';
|
|
5
|
+
|
|
6
|
+
const SelectOptions = ({
|
|
7
|
+
onSelect,
|
|
8
|
+
options
|
|
9
|
+
}) => {
|
|
10
|
+
const { keyExtractor } = useContext(SelectContext);
|
|
11
|
+
const { setIsOpen } = usePopoverContext();
|
|
12
|
+
const handleSelect = useCallback(
|
|
13
|
+
(option) => {
|
|
14
|
+
onSelect(option);
|
|
15
|
+
setIsOpen?.(false);
|
|
16
|
+
},
|
|
17
|
+
[onSelect]
|
|
18
|
+
);
|
|
19
|
+
return /* @__PURE__ */ React.createElement("ul", { role: "select", className: "list-none" }, (options ?? []).map((option) => /* @__PURE__ */ React.createElement(
|
|
20
|
+
Select.Option,
|
|
21
|
+
{
|
|
22
|
+
option,
|
|
23
|
+
key: keyExtractor(option),
|
|
24
|
+
onSelectOption: handleSelect
|
|
25
|
+
}
|
|
26
|
+
)));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { SelectOptions };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover } from '../Popover/index.js';
|
|
3
|
+
|
|
4
|
+
const SelectPopover = ({ children }) => {
|
|
5
|
+
return /* @__PURE__ */ React.createElement(Popover.Content, { className: "bg-white max-h-[30vh] w-full overflow-y-scroll gap-y-mili flex flex-col" }, children);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { SelectPopover };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Content from './Content.js';
|
|
3
|
+
import { Popover } from '../Popover/index.js';
|
|
4
|
+
|
|
5
|
+
const SelectRoot = ({
|
|
6
|
+
children,
|
|
7
|
+
value,
|
|
8
|
+
keyExtractor,
|
|
9
|
+
labelExtractor
|
|
10
|
+
}) => {
|
|
11
|
+
return /* @__PURE__ */ React.createElement(Popover.Provider, null, /* @__PURE__ */ React.createElement(Popover.Root, { placement: "bottom", trigger: "click" }, /* @__PURE__ */ React.createElement(
|
|
12
|
+
Content,
|
|
13
|
+
{
|
|
14
|
+
keyExtractor,
|
|
15
|
+
labelExtractor,
|
|
16
|
+
value
|
|
17
|
+
},
|
|
18
|
+
children
|
|
19
|
+
)));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { SelectRoot };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { selectVariants } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React, { useContext, useMemo } from 'react';
|
|
3
|
+
import { IoChevronDownOutline } from 'react-icons/io5';
|
|
4
|
+
import { SelectContext } from './context.js';
|
|
5
|
+
import { Popover } from '../Popover/index.js';
|
|
6
|
+
|
|
7
|
+
const { button } = selectVariants();
|
|
8
|
+
const SelectTrigger = ({ label, disabled }) => {
|
|
9
|
+
const { value, labelExtractor } = useContext(SelectContext);
|
|
10
|
+
const placeholder = useMemo(
|
|
11
|
+
() => value ? labelExtractor(value) : label,
|
|
12
|
+
[label, value]
|
|
13
|
+
);
|
|
14
|
+
return /* @__PURE__ */ React.createElement(Popover.Trigger, null, /* @__PURE__ */ React.createElement(
|
|
15
|
+
"button",
|
|
16
|
+
{
|
|
17
|
+
className: button({ disabled }),
|
|
18
|
+
disabled,
|
|
19
|
+
role: "button"
|
|
20
|
+
},
|
|
21
|
+
/* @__PURE__ */ React.createElement("span", { "data-testid": "select-placeholder" }, placeholder),
|
|
22
|
+
/* @__PURE__ */ React.createElement(IoChevronDownOutline, null)
|
|
23
|
+
));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { SelectTrigger };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SelectGroupedOptions } from './GroupedOptions.js';
|
|
2
|
+
import { SelectOption } from './Option.js';
|
|
3
|
+
import { SelectOptions } from './Options.js';
|
|
4
|
+
import { SelectPopover } from './Popover.js';
|
|
5
|
+
import { SelectRoot } from './Root.js';
|
|
6
|
+
import { SelectTrigger } from './Trigger.js';
|
|
7
|
+
|
|
8
|
+
const Select = {
|
|
9
|
+
Root: SelectRoot,
|
|
10
|
+
Trigger: SelectTrigger,
|
|
11
|
+
Popover: SelectPopover,
|
|
12
|
+
Options: SelectOptions,
|
|
13
|
+
GroupedOptions: SelectGroupedOptions,
|
|
14
|
+
Option: SelectOption
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { Select };
|
|
@@ -1,5 +1,5 @@
|
|
|
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,
|
|
@@ -37,6 +37,6 @@ const Table = ({
|
|
|
37
37
|
const Td = ({
|
|
38
38
|
children,
|
|
39
39
|
...rest
|
|
40
|
-
}) => /* @__PURE__ */ React.createElement("td", {
|
|
40
|
+
}) => /* @__PURE__ */ React.createElement("td", { "data-testid": "td", ...rest }, children);
|
|
41
41
|
|
|
42
42
|
export { TCell, TFoot, THead, THeadCell, TRow, TRowHeader, Table, Td };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { forwardRef, useRef } from 'react';
|
|
2
|
+
import { FloatingArrow } from '@floating-ui/react';
|
|
3
|
+
import '@internationalized/date';
|
|
4
|
+
import 'react-aria';
|
|
5
|
+
import 'react-stately';
|
|
6
|
+
import { useFloatingLogic } from '../hooks/useFloatingLogic.js';
|
|
7
|
+
|
|
8
|
+
const Tooltip = forwardRef(
|
|
9
|
+
(props, ref) => {
|
|
10
|
+
const {
|
|
11
|
+
children,
|
|
12
|
+
text,
|
|
13
|
+
trigger = "hover",
|
|
14
|
+
placement = "top",
|
|
15
|
+
width,
|
|
16
|
+
height
|
|
17
|
+
} = props;
|
|
18
|
+
const arrowRef = useRef(null);
|
|
19
|
+
const {
|
|
20
|
+
isOpen,
|
|
21
|
+
triggerProps,
|
|
22
|
+
x,
|
|
23
|
+
y,
|
|
24
|
+
strategy,
|
|
25
|
+
refs,
|
|
26
|
+
context,
|
|
27
|
+
floatingStyles
|
|
28
|
+
} = useFloatingLogic({ placement, arrowRef, trigger });
|
|
29
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, React.cloneElement(children, triggerProps), isOpen ? /* @__PURE__ */ React.createElement(
|
|
30
|
+
"div",
|
|
31
|
+
{
|
|
32
|
+
ref: ref || refs.setFloating,
|
|
33
|
+
className: "bg-black text-white p-2 rounded z-50 shadow-md text-justify",
|
|
34
|
+
style: {
|
|
35
|
+
position: strategy,
|
|
36
|
+
top: y ?? 0,
|
|
37
|
+
left: x ?? 0,
|
|
38
|
+
width,
|
|
39
|
+
height,
|
|
40
|
+
...floatingStyles
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
text,
|
|
44
|
+
/* @__PURE__ */ React.createElement(FloatingArrow, { ref: arrowRef, context, fill: "black" })
|
|
45
|
+
) : /* @__PURE__ */ React.createElement(React.Fragment, null));
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export { Tooltip, Tooltip as default };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CalendarDate, getLocalTimeZone } from '@internationalized/date';
|
|
2
|
+
|
|
1
3
|
const getNameInitials = (name) => {
|
|
2
4
|
const nameSplit = name.split(" ");
|
|
3
5
|
const length = nameSplit.length;
|
|
@@ -6,5 +8,15 @@ const getNameInitials = (name) => {
|
|
|
6
8
|
}
|
|
7
9
|
return name[0];
|
|
8
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
|
+
};
|
|
9
21
|
|
|
10
|
-
export { getNameInitials };
|
|
22
|
+
export { calendarDateToDate, dateToCalendarDate, getNameInitials };
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { createCalendar
|
|
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 '../components/utils.js';
|
|
4
5
|
|
|
5
6
|
const useCalendar = ({ value, onChange }) => {
|
|
6
7
|
const { locale } = useLocale();
|
|
7
8
|
const state = useCalendarState({
|
|
8
9
|
locale,
|
|
9
10
|
createCalendar,
|
|
10
|
-
defaultValue:
|
|
11
|
-
|
|
12
|
-
value.getMonth(),
|
|
13
|
-
value.getDate()
|
|
14
|
-
),
|
|
15
|
-
onChange: (value2) => onChange(value2.toDate(getLocalTimeZone()))
|
|
11
|
+
defaultValue: dateToCalendarDate(value),
|
|
12
|
+
onChange: (value2) => onChange(calendarDateToDate(value2))
|
|
16
13
|
});
|
|
17
14
|
const { calendarProps, title } = useCalendar$1({}, state);
|
|
18
15
|
return {
|
|
@@ -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,51 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { useFloating, autoUpdate, offset, flip, shift, arrow } from '@floating-ui/react';
|
|
3
|
+
|
|
4
|
+
const useFloatingLogic = ({
|
|
5
|
+
placement,
|
|
6
|
+
trigger,
|
|
7
|
+
arrowRef
|
|
8
|
+
}) => {
|
|
9
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
10
|
+
const { x, y, strategy, refs, update, context, floatingStyles } = useFloating(
|
|
11
|
+
{
|
|
12
|
+
placement,
|
|
13
|
+
whileElementsMounted: autoUpdate,
|
|
14
|
+
middleware: [
|
|
15
|
+
offset(10),
|
|
16
|
+
flip({
|
|
17
|
+
flipAlignment: true,
|
|
18
|
+
fallbackPlacements: ["right", "bottom", "left", "top"]
|
|
19
|
+
}),
|
|
20
|
+
shift(),
|
|
21
|
+
...arrowRef ? [arrow({ element: arrowRef })] : []
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (isOpen) update();
|
|
27
|
+
}, [isOpen, update]);
|
|
28
|
+
const triggerProps = {
|
|
29
|
+
ref: refs.setReference,
|
|
30
|
+
...trigger === "hover" && {
|
|
31
|
+
onMouseEnter: () => setIsOpen(true),
|
|
32
|
+
onMouseLeave: () => setIsOpen(false)
|
|
33
|
+
},
|
|
34
|
+
...trigger === "click" && {
|
|
35
|
+
onClick: () => setIsOpen((prev) => !prev)
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
isOpen,
|
|
40
|
+
setIsOpen,
|
|
41
|
+
x,
|
|
42
|
+
y,
|
|
43
|
+
strategy,
|
|
44
|
+
refs,
|
|
45
|
+
context,
|
|
46
|
+
floatingStyles,
|
|
47
|
+
triggerProps
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { useFloatingLogic };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useCallback, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const useOutsideClickListener = ({
|
|
4
|
+
ref,
|
|
5
|
+
onClickOutside
|
|
6
|
+
}) => {
|
|
7
|
+
const handleClickOutside = useCallback((event) => {
|
|
8
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
9
|
+
onClickOutside?.();
|
|
10
|
+
}
|
|
11
|
+
}, []);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
document.addEventListener("click", handleClickOutside, true);
|
|
14
|
+
return () => {
|
|
15
|
+
document.removeEventListener("click", handleClickOutside, true);
|
|
16
|
+
};
|
|
17
|
+
}, [handleClickOutside]);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { useOutsideClickListener };
|
|
@@ -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 };
|