@tecsinapse/cortex-react 1.3.0-beta.1 → 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 +1 -0
- package/dist/cjs/components/CalendarCell.js +1 -0
- package/dist/cjs/components/CalendarGrid.js +1 -0
- package/dist/cjs/components/DatePickerInput.js +1 -0
- package/dist/cjs/components/DatePickerInputBase.js +2 -2
- package/dist/cjs/components/DateRangePickerInput.js +1 -0
- 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 +1 -0
- 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/TimeFieldInput.js +2 -2
- package/dist/cjs/components/Tooltip.js +54 -0
- package/dist/cjs/hooks/useFloatingLogic.js +53 -0
- package/dist/cjs/hooks/useOutsideClickListener.js +22 -0
- package/dist/cjs/index.js +16 -9
- package/dist/cjs/provider/MenubarProvider.js +22 -0
- package/dist/cjs/provider/SnackbarProvider.js +51 -0
- package/dist/cjs/service/SnackbarSonner.js +23 -2
- package/dist/cjs/styles/menubar.js +62 -0
- package/dist/esm/components/Calendar.js +1 -0
- package/dist/esm/components/CalendarCell.js +1 -0
- package/dist/esm/components/CalendarGrid.js +1 -0
- package/dist/esm/components/DatePickerInput.js +1 -0
- package/dist/esm/components/DatePickerInputBase.js +1 -1
- package/dist/esm/components/DateRangePickerInput.js +1 -0
- 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 +1 -0
- 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/TimeFieldInput.js +1 -1
- package/dist/esm/components/Tooltip.js +49 -0
- package/dist/esm/hooks/useFloatingLogic.js +51 -0
- package/dist/esm/hooks/useOutsideClickListener.js +20 -0
- package/dist/esm/index.js +8 -2
- package/dist/esm/provider/MenubarProvider.js +19 -0
- package/dist/esm/provider/SnackbarProvider.js +49 -0
- package/dist/esm/service/SnackbarSonner.js +23 -2
- package/dist/esm/styles/menubar.js +54 -0
- package/dist/types/components/Card.d.ts +3 -4
- 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/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 +5 -1
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/useFloatingLogic.d.ts +46 -0
- package/dist/types/hooks/useOutsideClickListener.d.ts +7 -0
- 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/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/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 -83
- package/dist/cjs/components/Select.js +0 -101
- package/dist/esm/components/Input.js +0 -74
- package/dist/esm/components/SearchInput.js +0 -81
- 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 → Divider.test.d.ts} +0 -0
- /package/dist/types/tests/{SearchInput.test.d.ts → Input/Box.test.d.ts} +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import 'clsx';
|
|
3
|
+
import '@internationalized/date';
|
|
4
|
+
import '../Badge.js';
|
|
5
|
+
import '../BaseSnackbar.js';
|
|
6
|
+
import 'react-icons/md';
|
|
7
|
+
import '../Card.js';
|
|
8
|
+
import '../Button.js';
|
|
9
|
+
import 'react-aria';
|
|
10
|
+
import 'react-stately';
|
|
11
|
+
import '@floating-ui/react';
|
|
12
|
+
import '../CalendarCell.js';
|
|
13
|
+
import '@tecsinapse/cortex-core';
|
|
14
|
+
import 'react-icons/fa';
|
|
15
|
+
import 'react-icons/lia';
|
|
16
|
+
import '../Input/Box.js';
|
|
17
|
+
import '../Input/Face.js';
|
|
18
|
+
import '../Input/Left.js';
|
|
19
|
+
import '../Input/Right.js';
|
|
20
|
+
import '../Input/Root.js';
|
|
21
|
+
import '../Input/Search.js';
|
|
22
|
+
import 'react-icons/io';
|
|
23
|
+
import '../GroupButton.js';
|
|
24
|
+
import '../Hint.js';
|
|
25
|
+
import { Menubar } from './index.js';
|
|
26
|
+
import '../Modal.js';
|
|
27
|
+
import '../Popover/Context.js';
|
|
28
|
+
import '../../styles/calendar-cell.js';
|
|
29
|
+
import '../../styles/groupButton.js';
|
|
30
|
+
import '../../styles/progressBar.js';
|
|
31
|
+
import '../Select/GroupedOptions.js';
|
|
32
|
+
import '../Select/context.js';
|
|
33
|
+
import '../Select/Trigger.js';
|
|
34
|
+
import '../Tag.js';
|
|
35
|
+
import '../TextArea.js';
|
|
36
|
+
import '../Toggle.js';
|
|
37
|
+
import '../Tooltip.js';
|
|
38
|
+
|
|
39
|
+
const MostUsedList = ({ mostUsed }) => {
|
|
40
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, (mostUsed ?? []).map((item, index) => {
|
|
41
|
+
const { title, category, ...rest } = item;
|
|
42
|
+
if (index > 3)
|
|
43
|
+
return /* @__PURE__ */ React.createElement(Fragment, { key: `${title}-${category}` });
|
|
44
|
+
return /* @__PURE__ */ React.createElement(
|
|
45
|
+
Menubar.MostUsedItem,
|
|
46
|
+
{
|
|
47
|
+
key: `${title}-${category}`,
|
|
48
|
+
title,
|
|
49
|
+
category,
|
|
50
|
+
...rest
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export { MostUsedList as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { menubar } from '../../styles/menubar.js';
|
|
3
|
+
|
|
4
|
+
const { right } = menubar();
|
|
5
|
+
const Right = ({ children, ...rest }) => {
|
|
6
|
+
return /* @__PURE__ */ React.createElement("div", { className: right(), "data-testid": "header-right-menubar", ...rest }, children);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { Right as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MenubarProvider } from '../../provider/MenubarProvider.js';
|
|
3
|
+
import '../../provider/SnackbarProvider.js';
|
|
4
|
+
|
|
5
|
+
const Root = ({ children, ...rest }) => {
|
|
6
|
+
return /* @__PURE__ */ React.createElement(MenubarProvider, null, /* @__PURE__ */ React.createElement("div", { ...rest }, children));
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { Root as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Input } from '../Input/index.js';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { animate } from '../../styles/menubar.js';
|
|
5
|
+
import { useMenubar } from '../../provider/MenubarProvider.js';
|
|
6
|
+
import '../../provider/SnackbarProvider.js';
|
|
7
|
+
|
|
8
|
+
const Search = (props) => {
|
|
9
|
+
const [show] = useMenubar();
|
|
10
|
+
return /* @__PURE__ */ React.createElement(
|
|
11
|
+
Input.Search,
|
|
12
|
+
{
|
|
13
|
+
...props,
|
|
14
|
+
className: clsx("mr-tera flex-1", animate({ show }))
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { Search as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { subItem } from '../../styles/menubar.js';
|
|
3
|
+
import ItemLink from './ItemLink.js';
|
|
4
|
+
|
|
5
|
+
const { container } = subItem();
|
|
6
|
+
const SubItem = ({ children, href, className, ...rest }) => {
|
|
7
|
+
return /* @__PURE__ */ React.createElement(ItemLink, { href }, /* @__PURE__ */ React.createElement(
|
|
8
|
+
"div",
|
|
9
|
+
{
|
|
10
|
+
...rest,
|
|
11
|
+
"data-testid": "sub-item-menubar",
|
|
12
|
+
className: container({ className })
|
|
13
|
+
},
|
|
14
|
+
children
|
|
15
|
+
));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { SubItem as default };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import Root from './Root.js';
|
|
2
|
+
import Left from './Left.js';
|
|
3
|
+
import Search from './Search.js';
|
|
4
|
+
import Right from './Right.js';
|
|
5
|
+
import Dropdown from './Dropdown.js';
|
|
6
|
+
import MostUsed from './MostUsed.js';
|
|
7
|
+
import MostUsedItem from './MostUsedItem.js';
|
|
8
|
+
import Header from './Header.js';
|
|
9
|
+
import Category from './Category.js';
|
|
10
|
+
import Item from './Item.js';
|
|
11
|
+
import Categories from './Categories.js';
|
|
12
|
+
import SubItem from './SubItem.js';
|
|
13
|
+
import DropdownRoot from './DropdownRoot.js';
|
|
14
|
+
|
|
15
|
+
const Menubar = {
|
|
16
|
+
Root,
|
|
17
|
+
Header,
|
|
18
|
+
HeaderLeft: Left,
|
|
19
|
+
Search,
|
|
20
|
+
HeaderRight: Right,
|
|
21
|
+
Dropdown,
|
|
22
|
+
MostUsed,
|
|
23
|
+
MostUsedItem,
|
|
24
|
+
Category,
|
|
25
|
+
Categories,
|
|
26
|
+
Item,
|
|
27
|
+
SubItem,
|
|
28
|
+
DropdownRoot
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { Menubar };
|
|
@@ -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 };
|
|
@@ -3,6 +3,7 @@ import '@internationalized/date';
|
|
|
3
3
|
import 'react-aria';
|
|
4
4
|
import 'react-stately';
|
|
5
5
|
import { useRangeCalendar } from '../hooks/useRangeCalendar.js';
|
|
6
|
+
import '@floating-ui/react';
|
|
6
7
|
import { CalendarGrid } from './CalendarGrid.js';
|
|
7
8
|
import { CalendarHeader } from './CalendarHeader.js';
|
|
8
9
|
|
|
@@ -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 };
|
|
@@ -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 };
|
|
@@ -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 };
|
package/dist/esm/index.js
CHANGED
|
@@ -8,25 +8,31 @@ export { Card } from './components/Card.js';
|
|
|
8
8
|
export { DatePickerInput } from './components/DatePickerInput.js';
|
|
9
9
|
export { DateRangePickerInput } from './components/DateRangePickerInput.js';
|
|
10
10
|
export { DefaultSnack } from './components/DefaultSnack.js';
|
|
11
|
+
export { Divider } from './components/Divider.js';
|
|
11
12
|
export { Drawer } from './components/Drawer.js';
|
|
12
13
|
export { GroupButton } from './components/GroupButton.js';
|
|
13
14
|
export { Hint } from './components/Hint.js';
|
|
14
|
-
export {
|
|
15
|
+
export { Input } from './components/Input/index.js';
|
|
16
|
+
export { Menubar } from './components/Menubar/index.js';
|
|
15
17
|
export { Modal } from './components/Modal.js';
|
|
18
|
+
export { Popover } from './components/Popover/index.js';
|
|
16
19
|
export { ProgressBar } from './components/ProgressBar.js';
|
|
17
20
|
export { RangeCalendar } from './components/RangeCalendar.js';
|
|
18
|
-
export { Select } from './components/Select.js';
|
|
21
|
+
export { Select } from './components/Select/index.js';
|
|
19
22
|
export { Skeleton } from './components/Skeleton.js';
|
|
20
23
|
export { TCell, TFoot, THead, THeadCell, TRow, TRowHeader, Table, Td } from './components/Table.js';
|
|
21
24
|
export { Tag } from './components/Tag.js';
|
|
22
25
|
export { TextArea } from './components/TextArea.js';
|
|
23
26
|
export { TimeFieldInput } from './components/TimeFieldInput.js';
|
|
24
27
|
export { Toggle } from './components/Toggle.js';
|
|
28
|
+
export { Tooltip } from './components/Tooltip.js';
|
|
25
29
|
export { useCalendar } from './hooks/useCalendar.js';
|
|
26
30
|
export { useCalendarCell } from './hooks/useCalendarCell.js';
|
|
27
31
|
export { useCalendarGrid } from './hooks/useCalendarGrid.js';
|
|
28
32
|
export { useDatePickerInput } from './hooks/useDatePickerInput.js';
|
|
29
33
|
export { useDateRangePickerInput } from './hooks/useDateRangePickerInput.js';
|
|
30
34
|
export { useDebouncedState } from './hooks/useDebouncedState.js';
|
|
35
|
+
export { useOutsideClickListener } from './hooks/useOutsideClickListener.js';
|
|
31
36
|
export { useRangeCalendar } from './hooks/useRangeCalendar.js';
|
|
37
|
+
export { useFloatingLogic } from './hooks/useFloatingLogic.js';
|
|
32
38
|
export { SnackbarSonner } from './service/SnackbarSonner.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const MenubarContext = createContext({
|
|
4
|
+
show: false,
|
|
5
|
+
setShow: () => void 0
|
|
6
|
+
});
|
|
7
|
+
const MenubarProvider = ({ children }) => {
|
|
8
|
+
const [show, setShow] = React.useState(false);
|
|
9
|
+
return /* @__PURE__ */ React.createElement(MenubarContext.Provider, { value: { show, setShow } }, children);
|
|
10
|
+
};
|
|
11
|
+
const useMenubar = () => {
|
|
12
|
+
const context = useContext(MenubarContext);
|
|
13
|
+
if (!context) {
|
|
14
|
+
throw new Error("useSnackbar must be used within a SnackbarProvider");
|
|
15
|
+
}
|
|
16
|
+
return [context.show, context.setShow];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { MenubarProvider, useMenubar };
|