@tecsinapse/cortex-react 1.3.0-beta.4 → 1.3.0-beta.6
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/Masonry.js +1 -0
- package/dist/cjs/components/Menubar/Dropdown.js +1 -1
- package/dist/cjs/components/Menubar/ItemLink.js +1 -1
- package/dist/cjs/components/Menubar/MostUsedList.js +4 -4
- package/dist/cjs/components/Popover/{PopoverContent.js → Content.js} +8 -5
- 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/Select/Content.js +27 -0
- package/dist/cjs/components/Select/GroupedOptions.js +4 -2
- package/dist/cjs/components/Select/Options.js +5 -3
- package/dist/cjs/components/Select/Popover.js +2 -5
- package/dist/cjs/components/Select/Root.js +9 -17
- package/dist/cjs/components/Select/Trigger.js +4 -4
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/provider/SnackbarProvider.js +2 -2
- package/dist/cjs/service/SnackbarSonner.js +2 -2
- package/dist/esm/components/Masonry.js +1 -0
- package/dist/esm/components/Menubar/Dropdown.js +1 -1
- package/dist/esm/components/Menubar/ItemLink.js +1 -1
- package/dist/esm/components/Menubar/MostUsedList.js +5 -5
- package/dist/esm/components/Popover/{PopoverContent.js → Content.js} +7 -4
- 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/{PopoverTrigger.js → Trigger.js} +2 -2
- package/dist/esm/components/Popover/index.js +13 -0
- package/dist/esm/components/Select/Content.js +25 -0
- package/dist/esm/components/Select/GroupedOptions.js +4 -2
- package/dist/esm/components/Select/Options.js +5 -3
- package/dist/esm/components/Select/Popover.js +3 -6
- package/dist/esm/components/Select/Root.js +10 -18
- package/dist/esm/components/Select/Trigger.js +4 -4
- package/dist/esm/index.js +1 -1
- package/dist/esm/provider/SnackbarProvider.js +2 -2
- package/dist/esm/service/SnackbarSonner.js +2 -2
- package/dist/types/components/Popover/Content.d.ts +6 -0
- package/dist/types/components/Popover/{PopoverContext.d.ts → Context.d.ts} +5 -9
- package/dist/types/components/Popover/Provider.d.ts +8 -0
- package/dist/types/components/Popover/{PopoverRoot.d.ts → Root.d.ts} +1 -2
- package/dist/types/components/Popover/Trigger.d.ts +5 -0
- package/dist/types/components/Popover/index.d.ts +6 -3
- package/dist/types/components/Select/Content.d.ts +9 -0
- package/dist/types/components/Select/context.d.ts +0 -3
- package/dist/types/components/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/components/Popover/Popover.js +0 -13
- package/dist/cjs/components/Popover/PopoverContext.js +0 -29
- package/dist/cjs/components/Popover/PopoverRoot.js +0 -10
- package/dist/cjs/components/Popover/PopoverTrigger.js +0 -11
- package/dist/esm/components/Popover/Popover.js +0 -11
- package/dist/esm/components/Popover/PopoverContext.js +0 -26
- package/dist/esm/components/Popover/PopoverRoot.js +0 -8
- package/dist/types/components/Popover/Popover.d.ts +0 -5
- package/dist/types/components/Popover/PopoverContent.d.ts +0 -7
- package/dist/types/components/Popover/PopoverTrigger.d.ts +0 -6
|
@@ -6,8 +6,8 @@ var clsx = require('clsx');
|
|
|
6
6
|
var MenubarProvider = require('../../provider/MenubarProvider.js');
|
|
7
7
|
require('../../provider/SnackbarProvider.js');
|
|
8
8
|
|
|
9
|
+
const { dropdown } = menubar.menubar();
|
|
9
10
|
const Dropdown = ({ children, ...rest }) => {
|
|
10
|
-
const { dropdown } = menubar.menubar();
|
|
11
11
|
const [show] = MenubarProvider.useMenubar();
|
|
12
12
|
return /* @__PURE__ */ React.createElement(
|
|
13
13
|
"div",
|
|
@@ -30,23 +30,23 @@ require('../../styles/groupButton.js');
|
|
|
30
30
|
require('../../styles/progressBar.js');
|
|
31
31
|
require('../Select/GroupedOptions.js');
|
|
32
32
|
require('../Select/context.js');
|
|
33
|
-
require('../
|
|
33
|
+
require('../Popover/Context.js');
|
|
34
34
|
require('../Select/Trigger.js');
|
|
35
35
|
require('../Tag.js');
|
|
36
36
|
require('../TextArea.js');
|
|
37
37
|
require('../Toggle.js');
|
|
38
38
|
require('../Tooltip.js');
|
|
39
|
-
require('../Popover/PopoverContext.js');
|
|
40
39
|
var index = require('./index.js');
|
|
41
40
|
|
|
42
41
|
const MostUsedList = ({ mostUsed }) => {
|
|
43
42
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, (mostUsed ?? []).map((item, index$1) => {
|
|
44
43
|
const { title, category, ...rest } = item;
|
|
45
|
-
if (index$1 > 3)
|
|
44
|
+
if (index$1 > 3)
|
|
45
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, { key: `${title}-${category}` });
|
|
46
46
|
return /* @__PURE__ */ React.createElement(
|
|
47
47
|
index.Menubar.MostUsedItem,
|
|
48
48
|
{
|
|
49
|
-
key: title
|
|
49
|
+
key: `${title}-${category}`,
|
|
50
50
|
title,
|
|
51
51
|
category,
|
|
52
52
|
...rest
|
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var clsx = require('clsx');
|
|
5
|
-
var
|
|
5
|
+
var Context = require('./Context.js');
|
|
6
6
|
|
|
7
|
-
const PopoverContent = ({
|
|
8
|
-
|
|
7
|
+
const PopoverContent = ({
|
|
8
|
+
children,
|
|
9
|
+
className
|
|
10
|
+
}) => {
|
|
11
|
+
const { isOpen, x, y, strategy, floatingStyles, refs } = Context.usePopoverContext();
|
|
9
12
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, isOpen ? /* @__PURE__ */ React.createElement(
|
|
10
13
|
"div",
|
|
11
14
|
{
|
|
12
15
|
ref: refs.setFloating,
|
|
13
16
|
className: clsx(
|
|
14
|
-
"border border-gray-200 bg-black
|
|
17
|
+
"border border-gray-200 bg-black p-4 rounded-md shadow-lg z-50",
|
|
15
18
|
className
|
|
16
19
|
),
|
|
17
20
|
style: {
|
|
@@ -25,4 +28,4 @@ const PopoverContent = ({ children, className }) => {
|
|
|
25
28
|
) : /* @__PURE__ */ React.createElement(React.Fragment, null));
|
|
26
29
|
};
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
exports.PopoverContent = PopoverContent;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
const Context = React.createContext(void 0);
|
|
6
|
+
const usePopoverContext = () => {
|
|
7
|
+
const context = React.useContext(Context);
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error("usePopoverContext must be used within a PopoverProvider");
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.Context = Context;
|
|
15
|
+
exports.usePopoverContext = usePopoverContext;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
require('@internationalized/date');
|
|
5
|
+
require('react-aria');
|
|
6
|
+
require('react-stately');
|
|
7
|
+
var useFloatingLogic = require('../../hooks/useFloatingLogic.js');
|
|
8
|
+
var Context = require('./Context.js');
|
|
9
|
+
|
|
10
|
+
const PopoverProvider = ({
|
|
11
|
+
children,
|
|
12
|
+
placement,
|
|
13
|
+
trigger
|
|
14
|
+
}) => {
|
|
15
|
+
const floatingLogic = useFloatingLogic.useFloatingLogic({ placement, trigger });
|
|
16
|
+
return /* @__PURE__ */ React.createElement(Context.Context.Provider, { value: { ...floatingLogic } }, children);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.PopoverProvider = PopoverProvider;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var index = require('./index.js');
|
|
5
|
+
|
|
6
|
+
const PopoverRoot = ({
|
|
7
|
+
children,
|
|
8
|
+
placement,
|
|
9
|
+
trigger
|
|
10
|
+
}) => {
|
|
11
|
+
return /* @__PURE__ */ React.createElement(index.Popover.Provider, { placement, trigger }, children);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.PopoverRoot = PopoverRoot;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var Context = require('./Context.js');
|
|
5
|
+
|
|
6
|
+
const PopoverTrigger = ({ children }) => {
|
|
7
|
+
const { triggerProps } = Context.usePopoverContext();
|
|
8
|
+
return React.cloneElement(children, triggerProps);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.PopoverTrigger = PopoverTrigger;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Root = require('./Root.js');
|
|
4
|
+
var Trigger = require('./Trigger.js');
|
|
5
|
+
var Content = require('./Content.js');
|
|
6
|
+
var Provider = require('./Provider.js');
|
|
7
|
+
|
|
8
|
+
const Popover = {
|
|
9
|
+
Root: Root.PopoverRoot,
|
|
10
|
+
Trigger: Trigger.PopoverTrigger,
|
|
11
|
+
Content: Content.PopoverContent,
|
|
12
|
+
Provider: Provider.PopoverProvider
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.Popover = Popover;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
require('@internationalized/date');
|
|
5
|
+
require('react-aria');
|
|
6
|
+
require('react-stately');
|
|
7
|
+
var useOutsideClickListener = require('../../hooks/useOutsideClickListener.js');
|
|
8
|
+
require('@floating-ui/react');
|
|
9
|
+
var Context = require('../Popover/Context.js');
|
|
10
|
+
var context = require('./context.js');
|
|
11
|
+
|
|
12
|
+
const Content = ({
|
|
13
|
+
children,
|
|
14
|
+
keyExtractor,
|
|
15
|
+
labelExtractor,
|
|
16
|
+
value
|
|
17
|
+
}) => {
|
|
18
|
+
const { setIsOpen } = Context.usePopoverContext();
|
|
19
|
+
const ref = React.useRef(null);
|
|
20
|
+
useOutsideClickListener.useOutsideClickListener({
|
|
21
|
+
ref,
|
|
22
|
+
onClickOutside: () => setIsOpen(false)
|
|
23
|
+
});
|
|
24
|
+
return /* @__PURE__ */ React.createElement(context.SelectContext.Provider, { value: { value, keyExtractor, labelExtractor } }, /* @__PURE__ */ React.createElement("div", { className: "w-full relative bg-white", ref }, children));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports = Content;
|
|
@@ -4,6 +4,7 @@ var cortexCore = require('@tecsinapse/cortex-core');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var index = require('./index.js');
|
|
6
6
|
var context = require('./context.js');
|
|
7
|
+
var Context = require('../Popover/Context.js');
|
|
7
8
|
|
|
8
9
|
const { groupedTitle, containerGrouped } = cortexCore.selectVariants();
|
|
9
10
|
const SelectGroupedOptions = ({
|
|
@@ -11,11 +12,12 @@ const SelectGroupedOptions = ({
|
|
|
11
12
|
groupedLabelExtractor,
|
|
12
13
|
options
|
|
13
14
|
}) => {
|
|
14
|
-
const {
|
|
15
|
+
const { keyExtractor } = React.useContext(context.SelectContext);
|
|
16
|
+
const { setIsOpen } = Context.usePopoverContext();
|
|
15
17
|
const handleSelect = React.useCallback(
|
|
16
18
|
(option) => {
|
|
17
19
|
onSelect(option);
|
|
18
|
-
|
|
20
|
+
setIsOpen?.(false);
|
|
19
21
|
},
|
|
20
22
|
[onSelect]
|
|
21
23
|
);
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var index = require('./index.js');
|
|
5
4
|
var context = require('./context.js');
|
|
5
|
+
var index = require('./index.js');
|
|
6
|
+
var Context = require('../Popover/Context.js');
|
|
6
7
|
|
|
7
8
|
const SelectOptions = ({
|
|
8
9
|
onSelect,
|
|
9
10
|
options
|
|
10
11
|
}) => {
|
|
11
|
-
const {
|
|
12
|
+
const { keyExtractor } = React.useContext(context.SelectContext);
|
|
13
|
+
const { setIsOpen } = Context.usePopoverContext();
|
|
12
14
|
const handleSelect = React.useCallback(
|
|
13
15
|
(option) => {
|
|
14
16
|
onSelect(option);
|
|
15
|
-
|
|
17
|
+
setIsOpen?.(false);
|
|
16
18
|
},
|
|
17
19
|
[onSelect]
|
|
18
20
|
);
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var cortexCore = require('@tecsinapse/cortex-core');
|
|
4
3
|
var React = require('react');
|
|
5
|
-
var
|
|
4
|
+
var index = require('../Popover/index.js');
|
|
6
5
|
|
|
7
|
-
const { dropdown } = cortexCore.selectVariants();
|
|
8
6
|
const SelectPopover = ({ children }) => {
|
|
9
|
-
|
|
10
|
-
return /* @__PURE__ */ React.createElement("div", { className: dropdown({ open }), "data-testid": "select-popover" }, children);
|
|
7
|
+
return /* @__PURE__ */ React.createElement(index.Popover.Content, { className: "bg-white max-h-[30vh] w-full overflow-y-scroll gap-y-mili flex flex-col" }, children);
|
|
11
8
|
};
|
|
12
9
|
|
|
13
10
|
exports.SelectPopover = SelectPopover;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
require('
|
|
5
|
-
require('
|
|
6
|
-
require('react-stately');
|
|
7
|
-
var useOutsideClickListener = require('../../hooks/useOutsideClickListener.js');
|
|
8
|
-
require('@floating-ui/react');
|
|
9
|
-
var context = require('./context.js');
|
|
4
|
+
var Content = require('./Content.js');
|
|
5
|
+
var index = require('../Popover/index.js');
|
|
10
6
|
|
|
11
7
|
const SelectRoot = ({
|
|
12
8
|
children,
|
|
@@ -14,19 +10,15 @@ const SelectRoot = ({
|
|
|
14
10
|
keyExtractor,
|
|
15
11
|
labelExtractor
|
|
16
12
|
}) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
useOutsideClickListener.useOutsideClickListener({
|
|
20
|
-
ref,
|
|
21
|
-
onClickOutside: () => setOpen?.(false)
|
|
22
|
-
});
|
|
23
|
-
return /* @__PURE__ */ React.createElement(
|
|
24
|
-
context.SelectContext.Provider,
|
|
13
|
+
return /* @__PURE__ */ React.createElement(index.Popover.Provider, null, /* @__PURE__ */ React.createElement(index.Popover.Root, { placement: "bottom", trigger: "click" }, /* @__PURE__ */ React.createElement(
|
|
14
|
+
Content,
|
|
25
15
|
{
|
|
26
|
-
|
|
16
|
+
keyExtractor,
|
|
17
|
+
labelExtractor,
|
|
18
|
+
value
|
|
27
19
|
},
|
|
28
|
-
|
|
29
|
-
);
|
|
20
|
+
children
|
|
21
|
+
)));
|
|
30
22
|
};
|
|
31
23
|
|
|
32
24
|
exports.SelectRoot = SelectRoot;
|
|
@@ -4,25 +4,25 @@ var cortexCore = require('@tecsinapse/cortex-core');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var io5 = require('react-icons/io5');
|
|
6
6
|
var context = require('./context.js');
|
|
7
|
+
var index = require('../Popover/index.js');
|
|
7
8
|
|
|
8
9
|
const { button } = cortexCore.selectVariants();
|
|
9
10
|
const SelectTrigger = ({ label, disabled }) => {
|
|
10
|
-
const { value,
|
|
11
|
+
const { value, labelExtractor } = React.useContext(context.SelectContext);
|
|
11
12
|
const placeholder = React.useMemo(
|
|
12
13
|
() => value ? labelExtractor(value) : label,
|
|
13
14
|
[label, value]
|
|
14
15
|
);
|
|
15
|
-
return /* @__PURE__ */ React.createElement(
|
|
16
|
+
return /* @__PURE__ */ React.createElement(index.Popover.Trigger, null, /* @__PURE__ */ React.createElement(
|
|
16
17
|
"button",
|
|
17
18
|
{
|
|
18
19
|
className: button({ disabled }),
|
|
19
|
-
onClick: () => setOpen?.(!open),
|
|
20
20
|
disabled,
|
|
21
21
|
role: "button"
|
|
22
22
|
},
|
|
23
23
|
/* @__PURE__ */ React.createElement("span", { "data-testid": "select-placeholder" }, placeholder),
|
|
24
24
|
/* @__PURE__ */ React.createElement(io5.IoChevronDownOutline, null)
|
|
25
|
-
);
|
|
25
|
+
));
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
exports.SelectTrigger = SelectTrigger;
|
package/dist/cjs/index.js
CHANGED
|
@@ -25,8 +25,8 @@ var TextArea = require('./components/TextArea.js');
|
|
|
25
25
|
var TimeFieldInput = require('./components/TimeFieldInput.js');
|
|
26
26
|
var Toggle = require('./components/Toggle.js');
|
|
27
27
|
require('./components/Tooltip.js');
|
|
28
|
-
var
|
|
29
|
-
var index$
|
|
28
|
+
var index$2 = require('./components/Popover/index.js');
|
|
29
|
+
var index$3 = require('./components/Menubar/index.js');
|
|
30
30
|
var useCalendar = require('./hooks/useCalendar.js');
|
|
31
31
|
var useCalendarCell = require('./hooks/useCalendarCell.js');
|
|
32
32
|
var useCalendarGrid = require('./hooks/useCalendarGrid.js');
|
|
@@ -72,8 +72,8 @@ exports.Tag = Tag.Tag;
|
|
|
72
72
|
exports.TextArea = TextArea.TextArea;
|
|
73
73
|
exports.TimeFieldInput = TimeFieldInput.TimeFieldInput;
|
|
74
74
|
exports.Toggle = Toggle.Toggle;
|
|
75
|
-
exports.Popover =
|
|
76
|
-
exports.Menubar = index$
|
|
75
|
+
exports.Popover = index$2.Popover;
|
|
76
|
+
exports.Menubar = index$3.Menubar;
|
|
77
77
|
exports.useCalendar = useCalendar.useCalendar;
|
|
78
78
|
exports.useCalendarCell = useCalendarCell.useCalendarCell;
|
|
79
79
|
exports.useCalendarGrid = useCalendarGrid.useCalendarGrid;
|
|
@@ -31,17 +31,17 @@ require('../styles/groupButton.js');
|
|
|
31
31
|
require('../styles/progressBar.js');
|
|
32
32
|
require('../components/Select/GroupedOptions.js');
|
|
33
33
|
require('../components/Select/context.js');
|
|
34
|
-
require('../components/
|
|
34
|
+
require('../components/Popover/Context.js');
|
|
35
35
|
require('../components/Select/Trigger.js');
|
|
36
36
|
require('../components/Tag.js');
|
|
37
37
|
require('../components/TextArea.js');
|
|
38
38
|
require('../components/Toggle.js');
|
|
39
39
|
require('../components/Tooltip.js');
|
|
40
|
-
require('../components/Popover/PopoverContext.js');
|
|
41
40
|
require('./MenubarProvider.js');
|
|
42
41
|
require('../components/Menubar/Left.js');
|
|
43
42
|
require('../styles/menubar.js');
|
|
44
43
|
require('../components/Menubar/Right.js');
|
|
44
|
+
require('../components/Menubar/Dropdown.js');
|
|
45
45
|
require('../components/Menubar/MostUsed.js');
|
|
46
46
|
require('../components/Menubar/MostUsedItem.js');
|
|
47
47
|
require('../components/Menubar/Header.js');
|
|
@@ -31,18 +31,18 @@ require('../styles/groupButton.js');
|
|
|
31
31
|
require('../styles/progressBar.js');
|
|
32
32
|
require('../components/Select/GroupedOptions.js');
|
|
33
33
|
require('../components/Select/context.js');
|
|
34
|
-
require('../components/
|
|
34
|
+
require('../components/Popover/Context.js');
|
|
35
35
|
require('../components/Select/Trigger.js');
|
|
36
36
|
require('../components/Tag.js');
|
|
37
37
|
require('../components/TextArea.js');
|
|
38
38
|
require('../components/Toggle.js');
|
|
39
39
|
require('../components/Tooltip.js');
|
|
40
|
-
require('../components/Popover/PopoverContext.js');
|
|
41
40
|
require('../provider/MenubarProvider.js');
|
|
42
41
|
require('../provider/SnackbarProvider.js');
|
|
43
42
|
require('../components/Menubar/Left.js');
|
|
44
43
|
require('../styles/menubar.js');
|
|
45
44
|
require('../components/Menubar/Right.js');
|
|
45
|
+
require('../components/Menubar/Dropdown.js');
|
|
46
46
|
require('../components/Menubar/MostUsed.js');
|
|
47
47
|
require('../components/Menubar/MostUsedItem.js');
|
|
48
48
|
require('../components/Menubar/Header.js');
|
|
@@ -4,8 +4,8 @@ import clsx from 'clsx';
|
|
|
4
4
|
import { useMenubar } from '../../provider/MenubarProvider.js';
|
|
5
5
|
import '../../provider/SnackbarProvider.js';
|
|
6
6
|
|
|
7
|
+
const { dropdown } = menubar();
|
|
7
8
|
const Dropdown = ({ children, ...rest }) => {
|
|
8
|
-
const { dropdown } = menubar();
|
|
9
9
|
const [show] = useMenubar();
|
|
10
10
|
return /* @__PURE__ */ React.createElement(
|
|
11
11
|
"div",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
2
|
import 'clsx';
|
|
3
3
|
import '@internationalized/date';
|
|
4
4
|
import '../Badge.js';
|
|
@@ -28,23 +28,23 @@ import '../../styles/groupButton.js';
|
|
|
28
28
|
import '../../styles/progressBar.js';
|
|
29
29
|
import '../Select/GroupedOptions.js';
|
|
30
30
|
import '../Select/context.js';
|
|
31
|
-
import '../
|
|
31
|
+
import '../Popover/Context.js';
|
|
32
32
|
import '../Select/Trigger.js';
|
|
33
33
|
import '../Tag.js';
|
|
34
34
|
import '../TextArea.js';
|
|
35
35
|
import '../Toggle.js';
|
|
36
36
|
import '../Tooltip.js';
|
|
37
|
-
import '../Popover/PopoverContext.js';
|
|
38
37
|
import { Menubar } from './index.js';
|
|
39
38
|
|
|
40
39
|
const MostUsedList = ({ mostUsed }) => {
|
|
41
40
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, (mostUsed ?? []).map((item, index) => {
|
|
42
41
|
const { title, category, ...rest } = item;
|
|
43
|
-
if (index > 3)
|
|
42
|
+
if (index > 3)
|
|
43
|
+
return /* @__PURE__ */ React.createElement(Fragment, { key: `${title}-${category}` });
|
|
44
44
|
return /* @__PURE__ */ React.createElement(
|
|
45
45
|
Menubar.MostUsedItem,
|
|
46
46
|
{
|
|
47
|
-
key: title
|
|
47
|
+
key: `${title}-${category}`,
|
|
48
48
|
title,
|
|
49
49
|
category,
|
|
50
50
|
...rest
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import { usePopoverContext } from './
|
|
3
|
+
import { usePopoverContext } from './Context.js';
|
|
4
4
|
|
|
5
|
-
const PopoverContent = ({
|
|
5
|
+
const PopoverContent = ({
|
|
6
|
+
children,
|
|
7
|
+
className
|
|
8
|
+
}) => {
|
|
6
9
|
const { isOpen, x, y, strategy, floatingStyles, refs } = usePopoverContext();
|
|
7
10
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, isOpen ? /* @__PURE__ */ React.createElement(
|
|
8
11
|
"div",
|
|
9
12
|
{
|
|
10
13
|
ref: refs.setFloating,
|
|
11
14
|
className: clsx(
|
|
12
|
-
"border border-gray-200 bg-black
|
|
15
|
+
"border border-gray-200 bg-black p-4 rounded-md shadow-lg z-50",
|
|
13
16
|
className
|
|
14
17
|
),
|
|
15
18
|
style: {
|
|
@@ -23,4 +26,4 @@ const PopoverContent = ({ children, className }) => {
|
|
|
23
26
|
) : /* @__PURE__ */ React.createElement(React.Fragment, null));
|
|
24
27
|
};
|
|
25
28
|
|
|
26
|
-
export { PopoverContent
|
|
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 };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { usePopoverContext } from './
|
|
2
|
+
import { usePopoverContext } from './Context.js';
|
|
3
3
|
|
|
4
4
|
const PopoverTrigger = ({ children }) => {
|
|
5
5
|
const { triggerProps } = usePopoverContext();
|
|
6
6
|
return React.cloneElement(children, triggerProps);
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
export { PopoverTrigger
|
|
9
|
+
export { PopoverTrigger };
|
|
@@ -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 };
|
|
@@ -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 };
|
|
@@ -2,6 +2,7 @@ import { selectVariants } from '@tecsinapse/cortex-core';
|
|
|
2
2
|
import React, { useContext, useCallback } from 'react';
|
|
3
3
|
import { Select } from './index.js';
|
|
4
4
|
import { SelectContext } from './context.js';
|
|
5
|
+
import { usePopoverContext } from '../Popover/Context.js';
|
|
5
6
|
|
|
6
7
|
const { groupedTitle, containerGrouped } = selectVariants();
|
|
7
8
|
const SelectGroupedOptions = ({
|
|
@@ -9,11 +10,12 @@ const SelectGroupedOptions = ({
|
|
|
9
10
|
groupedLabelExtractor,
|
|
10
11
|
options
|
|
11
12
|
}) => {
|
|
12
|
-
const {
|
|
13
|
+
const { keyExtractor } = useContext(SelectContext);
|
|
14
|
+
const { setIsOpen } = usePopoverContext();
|
|
13
15
|
const handleSelect = useCallback(
|
|
14
16
|
(option) => {
|
|
15
17
|
onSelect(option);
|
|
16
|
-
|
|
18
|
+
setIsOpen?.(false);
|
|
17
19
|
},
|
|
18
20
|
[onSelect]
|
|
19
21
|
);
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import React, { useContext, useCallback } from 'react';
|
|
2
|
-
import { Select } from './index.js';
|
|
3
2
|
import { SelectContext } from './context.js';
|
|
3
|
+
import { Select } from './index.js';
|
|
4
|
+
import { usePopoverContext } from '../Popover/Context.js';
|
|
4
5
|
|
|
5
6
|
const SelectOptions = ({
|
|
6
7
|
onSelect,
|
|
7
8
|
options
|
|
8
9
|
}) => {
|
|
9
|
-
const {
|
|
10
|
+
const { keyExtractor } = useContext(SelectContext);
|
|
11
|
+
const { setIsOpen } = usePopoverContext();
|
|
10
12
|
const handleSelect = useCallback(
|
|
11
13
|
(option) => {
|
|
12
14
|
onSelect(option);
|
|
13
|
-
|
|
15
|
+
setIsOpen?.(false);
|
|
14
16
|
},
|
|
15
17
|
[onSelect]
|
|
16
18
|
);
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { SelectContext } from './context.js';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popover } from '../Popover/index.js';
|
|
4
3
|
|
|
5
|
-
const { dropdown } = selectVariants();
|
|
6
4
|
const SelectPopover = ({ children }) => {
|
|
7
|
-
|
|
8
|
-
return /* @__PURE__ */ React.createElement("div", { className: dropdown({ open }), "data-testid": "select-popover" }, 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);
|
|
9
6
|
};
|
|
10
7
|
|
|
11
8
|
export { SelectPopover };
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import '
|
|
3
|
-
import '
|
|
4
|
-
import 'react-stately';
|
|
5
|
-
import { useOutsideClickListener } from '../../hooks/useOutsideClickListener.js';
|
|
6
|
-
import '@floating-ui/react';
|
|
7
|
-
import { SelectContext } from './context.js';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Content from './Content.js';
|
|
3
|
+
import { Popover } from '../Popover/index.js';
|
|
8
4
|
|
|
9
5
|
const SelectRoot = ({
|
|
10
6
|
children,
|
|
@@ -12,19 +8,15 @@ const SelectRoot = ({
|
|
|
12
8
|
keyExtractor,
|
|
13
9
|
labelExtractor
|
|
14
10
|
}) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
useOutsideClickListener({
|
|
18
|
-
ref,
|
|
19
|
-
onClickOutside: () => setOpen?.(false)
|
|
20
|
-
});
|
|
21
|
-
return /* @__PURE__ */ React.createElement(
|
|
22
|
-
SelectContext.Provider,
|
|
11
|
+
return /* @__PURE__ */ React.createElement(Popover.Provider, null, /* @__PURE__ */ React.createElement(Popover.Root, { placement: "bottom", trigger: "click" }, /* @__PURE__ */ React.createElement(
|
|
12
|
+
Content,
|
|
23
13
|
{
|
|
24
|
-
|
|
14
|
+
keyExtractor,
|
|
15
|
+
labelExtractor,
|
|
16
|
+
value
|
|
25
17
|
},
|
|
26
|
-
|
|
27
|
-
);
|
|
18
|
+
children
|
|
19
|
+
)));
|
|
28
20
|
};
|
|
29
21
|
|
|
30
22
|
export { SelectRoot };
|
|
@@ -2,25 +2,25 @@ import { selectVariants } from '@tecsinapse/cortex-core';
|
|
|
2
2
|
import React, { useContext, useMemo } from 'react';
|
|
3
3
|
import { IoChevronDownOutline } from 'react-icons/io5';
|
|
4
4
|
import { SelectContext } from './context.js';
|
|
5
|
+
import { Popover } from '../Popover/index.js';
|
|
5
6
|
|
|
6
7
|
const { button } = selectVariants();
|
|
7
8
|
const SelectTrigger = ({ label, disabled }) => {
|
|
8
|
-
const { value,
|
|
9
|
+
const { value, labelExtractor } = useContext(SelectContext);
|
|
9
10
|
const placeholder = useMemo(
|
|
10
11
|
() => value ? labelExtractor(value) : label,
|
|
11
12
|
[label, value]
|
|
12
13
|
);
|
|
13
|
-
return /* @__PURE__ */ React.createElement(
|
|
14
|
+
return /* @__PURE__ */ React.createElement(Popover.Trigger, null, /* @__PURE__ */ React.createElement(
|
|
14
15
|
"button",
|
|
15
16
|
{
|
|
16
17
|
className: button({ disabled }),
|
|
17
|
-
onClick: () => setOpen?.(!open),
|
|
18
18
|
disabled,
|
|
19
19
|
role: "button"
|
|
20
20
|
},
|
|
21
21
|
/* @__PURE__ */ React.createElement("span", { "data-testid": "select-placeholder" }, placeholder),
|
|
22
22
|
/* @__PURE__ */ React.createElement(IoChevronDownOutline, null)
|
|
23
|
-
);
|
|
23
|
+
));
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export { SelectTrigger };
|
package/dist/esm/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export { TextArea } from './components/TextArea.js';
|
|
|
23
23
|
export { TimeFieldInput } from './components/TimeFieldInput.js';
|
|
24
24
|
export { Toggle } from './components/Toggle.js';
|
|
25
25
|
import './components/Tooltip.js';
|
|
26
|
-
export { Popover } from './components/Popover/
|
|
26
|
+
export { Popover } from './components/Popover/index.js';
|
|
27
27
|
export { Menubar } from './components/Menubar/index.js';
|
|
28
28
|
export { useCalendar } from './hooks/useCalendar.js';
|
|
29
29
|
export { useCalendarCell } from './hooks/useCalendarCell.js';
|
|
@@ -29,17 +29,17 @@ import '../styles/groupButton.js';
|
|
|
29
29
|
import '../styles/progressBar.js';
|
|
30
30
|
import '../components/Select/GroupedOptions.js';
|
|
31
31
|
import '../components/Select/context.js';
|
|
32
|
-
import '../components/
|
|
32
|
+
import '../components/Popover/Context.js';
|
|
33
33
|
import '../components/Select/Trigger.js';
|
|
34
34
|
import '../components/Tag.js';
|
|
35
35
|
import '../components/TextArea.js';
|
|
36
36
|
import '../components/Toggle.js';
|
|
37
37
|
import '../components/Tooltip.js';
|
|
38
|
-
import '../components/Popover/PopoverContext.js';
|
|
39
38
|
import './MenubarProvider.js';
|
|
40
39
|
import '../components/Menubar/Left.js';
|
|
41
40
|
import '../styles/menubar.js';
|
|
42
41
|
import '../components/Menubar/Right.js';
|
|
42
|
+
import '../components/Menubar/Dropdown.js';
|
|
43
43
|
import '../components/Menubar/MostUsed.js';
|
|
44
44
|
import '../components/Menubar/MostUsedItem.js';
|
|
45
45
|
import '../components/Menubar/Header.js';
|
|
@@ -29,18 +29,18 @@ import '../styles/groupButton.js';
|
|
|
29
29
|
import '../styles/progressBar.js';
|
|
30
30
|
import '../components/Select/GroupedOptions.js';
|
|
31
31
|
import '../components/Select/context.js';
|
|
32
|
-
import '../components/
|
|
32
|
+
import '../components/Popover/Context.js';
|
|
33
33
|
import '../components/Select/Trigger.js';
|
|
34
34
|
import '../components/Tag.js';
|
|
35
35
|
import '../components/TextArea.js';
|
|
36
36
|
import '../components/Toggle.js';
|
|
37
37
|
import '../components/Tooltip.js';
|
|
38
|
-
import '../components/Popover/PopoverContext.js';
|
|
39
38
|
import '../provider/MenubarProvider.js';
|
|
40
39
|
import '../provider/SnackbarProvider.js';
|
|
41
40
|
import '../components/Menubar/Left.js';
|
|
42
41
|
import '../styles/menubar.js';
|
|
43
42
|
import '../components/Menubar/Right.js';
|
|
43
|
+
import '../components/Menubar/Dropdown.js';
|
|
44
44
|
import '../components/Menubar/MostUsed.js';
|
|
45
45
|
import '../components/Menubar/MostUsedItem.js';
|
|
46
46
|
import '../components/Menubar/Header.js';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { Placement } from '@floating-ui/react';
|
|
3
|
-
interface
|
|
3
|
+
interface ContextProps {
|
|
4
4
|
triggerProps?: any;
|
|
5
5
|
refs?: any;
|
|
6
6
|
isOpen?: boolean;
|
|
7
|
+
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
7
8
|
x?: number;
|
|
8
9
|
y?: number;
|
|
9
10
|
strategy?: 'absolute' | 'fixed';
|
|
@@ -12,11 +13,6 @@ interface PopoverContextProps {
|
|
|
12
13
|
setPlacement?: React.Dispatch<React.SetStateAction<Placement | undefined>>;
|
|
13
14
|
setTrigger?: React.Dispatch<React.SetStateAction<'hover' | 'click'>>;
|
|
14
15
|
}
|
|
15
|
-
export declare const
|
|
16
|
-
|
|
17
|
-
children: ReactNode;
|
|
18
|
-
placement?: Placement;
|
|
19
|
-
trigger?: 'hover' | 'click';
|
|
20
|
-
}
|
|
21
|
-
export declare const PopoverProvider: ({ children, placement, trigger, }: PopoverProviderProps) => JSX.Element;
|
|
16
|
+
export declare const Context: React.Context<ContextProps | undefined>;
|
|
17
|
+
export declare const usePopoverContext: () => ContextProps;
|
|
22
18
|
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Placement } from '@floating-ui/react';
|
|
3
|
+
export interface PopoverProviderProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
placement?: Placement;
|
|
6
|
+
trigger?: 'hover' | 'click';
|
|
7
|
+
}
|
|
8
|
+
export declare const PopoverProvider: ({ children, placement, trigger, }: PopoverProviderProps) => JSX.Element;
|
|
@@ -5,5 +5,4 @@ export interface PopoverRootProps {
|
|
|
5
5
|
placement?: Placement;
|
|
6
6
|
trigger?: 'hover' | 'click';
|
|
7
7
|
}
|
|
8
|
-
declare const PopoverRoot: ({ children, placement, trigger }: PopoverRootProps) => JSX.Element;
|
|
9
|
-
export default PopoverRoot;
|
|
8
|
+
export declare const PopoverRoot: ({ children, placement, trigger, }: PopoverRootProps) => JSX.Element;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const Popover: {
|
|
2
|
+
Root: ({ children, placement, trigger, }: import("./Root").PopoverRootProps) => JSX.Element;
|
|
3
|
+
Trigger: ({ children }: import("./Trigger").PopoverTriggerProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
4
|
+
Content: ({ children, className, }: import("./Content").PopoverContentProps) => JSX.Element;
|
|
5
|
+
Provider: ({ children, placement, trigger, }: import("./Provider").PopoverProviderProps) => JSX.Element;
|
|
6
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface ContentProps<T> {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
keyExtractor: (value: T) => string;
|
|
5
|
+
labelExtractor: (value: T) => string;
|
|
6
|
+
value?: T;
|
|
7
|
+
}
|
|
8
|
+
declare const Content: <T>({ children, keyExtractor, labelExtractor, value, }: ContentProps<T>) => JSX.Element;
|
|
9
|
+
export default Content;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "1.3.0-beta.
|
|
3
|
+
"version": "1.3.0-beta.6",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"react-dom": ">=18.0.0",
|
|
43
43
|
"tailwind": ">=3.3.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "c45d44c53d32b39febf7f65f2b54692681d677c3"
|
|
46
46
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var PopoverRoot = require('./PopoverRoot.js');
|
|
4
|
-
var PopoverTrigger = require('./PopoverTrigger.js');
|
|
5
|
-
var PopoverContent = require('./PopoverContent.js');
|
|
6
|
-
|
|
7
|
-
const Popover = {
|
|
8
|
-
Root: PopoverRoot,
|
|
9
|
-
Trigger: PopoverTrigger,
|
|
10
|
-
Content: PopoverContent
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
exports.Popover = Popover;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
require('@internationalized/date');
|
|
5
|
-
require('react-aria');
|
|
6
|
-
require('react-stately');
|
|
7
|
-
var useFloatingLogic = require('../../hooks/useFloatingLogic.js');
|
|
8
|
-
|
|
9
|
-
const PopoverContext = React.createContext(
|
|
10
|
-
void 0
|
|
11
|
-
);
|
|
12
|
-
const usePopoverContext = () => {
|
|
13
|
-
const context = React.useContext(PopoverContext);
|
|
14
|
-
if (!context) {
|
|
15
|
-
throw new Error("usePopoverContext must be used within a PopoverProvider");
|
|
16
|
-
}
|
|
17
|
-
return context;
|
|
18
|
-
};
|
|
19
|
-
const PopoverProvider = ({
|
|
20
|
-
children,
|
|
21
|
-
placement,
|
|
22
|
-
trigger
|
|
23
|
-
}) => {
|
|
24
|
-
const floatingLogic = useFloatingLogic.useFloatingLogic({ placement, trigger });
|
|
25
|
-
return /* @__PURE__ */ React.createElement(PopoverContext.Provider, { value: { ...floatingLogic } }, children);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
exports.PopoverProvider = PopoverProvider;
|
|
29
|
-
exports.usePopoverContext = usePopoverContext;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var PopoverContext = require('./PopoverContext.js');
|
|
5
|
-
|
|
6
|
-
const PopoverRoot = ({ children, placement, trigger }) => {
|
|
7
|
-
return /* @__PURE__ */ React.createElement(PopoverContext.PopoverProvider, { placement, trigger }, children);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
module.exports = PopoverRoot;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var PopoverContext = require('./PopoverContext.js');
|
|
5
|
-
|
|
6
|
-
const PopoverTrigger = ({ children }) => {
|
|
7
|
-
const { triggerProps } = PopoverContext.usePopoverContext();
|
|
8
|
-
return React.cloneElement(children, triggerProps);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
module.exports = PopoverTrigger;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import PopoverRoot from './PopoverRoot.js';
|
|
2
|
-
import PopoverTrigger from './PopoverTrigger.js';
|
|
3
|
-
import PopoverContent from './PopoverContent.js';
|
|
4
|
-
|
|
5
|
-
const Popover = {
|
|
6
|
-
Root: PopoverRoot,
|
|
7
|
-
Trigger: PopoverTrigger,
|
|
8
|
-
Content: PopoverContent
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export { Popover };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useContext } from 'react';
|
|
2
|
-
import '@internationalized/date';
|
|
3
|
-
import 'react-aria';
|
|
4
|
-
import 'react-stately';
|
|
5
|
-
import { useFloatingLogic } from '../../hooks/useFloatingLogic.js';
|
|
6
|
-
|
|
7
|
-
const PopoverContext = createContext(
|
|
8
|
-
void 0
|
|
9
|
-
);
|
|
10
|
-
const usePopoverContext = () => {
|
|
11
|
-
const context = useContext(PopoverContext);
|
|
12
|
-
if (!context) {
|
|
13
|
-
throw new Error("usePopoverContext must be used within a PopoverProvider");
|
|
14
|
-
}
|
|
15
|
-
return context;
|
|
16
|
-
};
|
|
17
|
-
const PopoverProvider = ({
|
|
18
|
-
children,
|
|
19
|
-
placement,
|
|
20
|
-
trigger
|
|
21
|
-
}) => {
|
|
22
|
-
const floatingLogic = useFloatingLogic({ placement, trigger });
|
|
23
|
-
return /* @__PURE__ */ React.createElement(PopoverContext.Provider, { value: { ...floatingLogic } }, children);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export { PopoverProvider, usePopoverContext };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { PopoverProvider } from './PopoverContext.js';
|
|
3
|
-
|
|
4
|
-
const PopoverRoot = ({ children, placement, trigger }) => {
|
|
5
|
-
return /* @__PURE__ */ React.createElement(PopoverProvider, { placement, trigger }, children);
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export { PopoverRoot as default };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const Popover: {
|
|
2
|
-
Root: ({ children, placement, trigger }: import("./PopoverRoot").PopoverRootProps) => JSX.Element;
|
|
3
|
-
Trigger: ({ children }: import("./PopoverTrigger").PopoverTriggerProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
4
|
-
Content: ({ children, className }: import("./PopoverContent").PopoverContentProps) => JSX.Element;
|
|
5
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface PopoverTriggerProps {
|
|
3
|
-
children: React.ReactElement;
|
|
4
|
-
}
|
|
5
|
-
declare const PopoverTrigger: ({ children }: PopoverTriggerProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
6
|
-
export default PopoverTrigger;
|