@tecsinapse/cortex-react 1.5.3 → 1.5.4
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/DatePicker/Content.js +0 -12
- package/dist/cjs/components/Popover/Content.js +14 -3
- package/dist/cjs/components/Select/Content.js +0 -12
- package/dist/cjs/hooks/useFloatingLogic.js +15 -2
- package/dist/esm/components/DatePicker/Content.js +0 -12
- package/dist/esm/components/Popover/Content.js +14 -3
- package/dist/esm/components/Select/Content.js +0 -12
- package/dist/esm/hooks/useFloatingLogic.js +16 -3
- package/dist/types/components/Popover/Context.d.ts +4 -1
- package/dist/types/hooks/useFloatingLogic.d.ts +2 -0
- package/package.json +2 -2
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
require('@internationalized/date');
|
|
5
|
-
require('react-aria');
|
|
6
|
-
require('react-stately');
|
|
7
|
-
require('@floating-ui/react');
|
|
8
|
-
require('currency.js');
|
|
9
|
-
var useOutsideClickListener = require('../../hooks/useOutsideClickListener.js');
|
|
10
|
-
var Context = require('../Popover/Context.js');
|
|
11
4
|
|
|
12
5
|
const Content = ({ children }) => {
|
|
13
|
-
const { setIsOpen } = Context.usePopoverContext();
|
|
14
6
|
const ref = React.useRef(null);
|
|
15
|
-
useOutsideClickListener.useOutsideClickListener({
|
|
16
|
-
ref,
|
|
17
|
-
onClickOutside: () => setIsOpen(false)
|
|
18
|
-
});
|
|
19
7
|
return /* @__PURE__ */ React.createElement("div", { ref }, children);
|
|
20
8
|
};
|
|
21
9
|
|
|
@@ -3,16 +3,27 @@
|
|
|
3
3
|
var clsx = require('clsx');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var Context = require('./Context.js');
|
|
6
|
+
var react = require('@floating-ui/react');
|
|
6
7
|
|
|
7
8
|
const PopoverContent = ({
|
|
8
9
|
children,
|
|
9
10
|
className
|
|
10
11
|
}) => {
|
|
11
|
-
const {
|
|
12
|
-
|
|
12
|
+
const {
|
|
13
|
+
isOpen,
|
|
14
|
+
x,
|
|
15
|
+
y,
|
|
16
|
+
strategy,
|
|
17
|
+
floatingStyles,
|
|
18
|
+
refs,
|
|
19
|
+
getFloatingProps,
|
|
20
|
+
context
|
|
21
|
+
} = Context.usePopoverContext();
|
|
22
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, isOpen && /* @__PURE__ */ React.createElement(react.FloatingFocusManager, { context, modal: true }, /* @__PURE__ */ React.createElement(
|
|
13
23
|
"div",
|
|
14
24
|
{
|
|
15
25
|
ref: refs.setFloating,
|
|
26
|
+
...getFloatingProps(),
|
|
16
27
|
className: clsx(
|
|
17
28
|
"border border-gray-200 bg-black p-[0px] rounded-md shadow-lg z-popover",
|
|
18
29
|
className
|
|
@@ -25,7 +36,7 @@ const PopoverContent = ({
|
|
|
25
36
|
}
|
|
26
37
|
},
|
|
27
38
|
children
|
|
28
|
-
)
|
|
39
|
+
)));
|
|
29
40
|
};
|
|
30
41
|
|
|
31
42
|
exports.PopoverContent = PopoverContent;
|
|
@@ -2,21 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var clsx = require('clsx');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
require('@internationalized/date');
|
|
6
|
-
require('react-aria');
|
|
7
|
-
require('react-stately');
|
|
8
|
-
require('@floating-ui/react');
|
|
9
|
-
require('currency.js');
|
|
10
|
-
var useOutsideClickListener = require('../../hooks/useOutsideClickListener.js');
|
|
11
|
-
var Context = require('../Popover/Context.js');
|
|
12
5
|
|
|
13
6
|
const Content = ({ children, className }) => {
|
|
14
|
-
const { setIsOpen } = Context.usePopoverContext();
|
|
15
7
|
const ref = React.useRef(null);
|
|
16
|
-
useOutsideClickListener.useOutsideClickListener({
|
|
17
|
-
ref,
|
|
18
|
-
onClickOutside: () => setIsOpen(false)
|
|
19
|
-
});
|
|
20
8
|
return /* @__PURE__ */ React.createElement("div", { className: clsx("w-full relative", className), ref }, children);
|
|
21
9
|
};
|
|
22
10
|
|
|
@@ -13,6 +13,8 @@ const useFloatingLogic = ({
|
|
|
13
13
|
{
|
|
14
14
|
placement,
|
|
15
15
|
whileElementsMounted: react.autoUpdate,
|
|
16
|
+
open: isOpen,
|
|
17
|
+
onOpenChange: setIsOpen,
|
|
16
18
|
middleware: [
|
|
17
19
|
react.offset(10),
|
|
18
20
|
react.flip({
|
|
@@ -24,6 +26,14 @@ const useFloatingLogic = ({
|
|
|
24
26
|
]
|
|
25
27
|
}
|
|
26
28
|
);
|
|
29
|
+
const click = react.useClick(context);
|
|
30
|
+
const dismiss = react.useDismiss(context);
|
|
31
|
+
const role = react.useRole(context);
|
|
32
|
+
const { getReferenceProps, getFloatingProps } = react.useInteractions([
|
|
33
|
+
click,
|
|
34
|
+
dismiss,
|
|
35
|
+
role
|
|
36
|
+
]);
|
|
27
37
|
React.useEffect(() => {
|
|
28
38
|
if (isOpen) update();
|
|
29
39
|
}, [isOpen, update]);
|
|
@@ -35,7 +45,8 @@ const useFloatingLogic = ({
|
|
|
35
45
|
},
|
|
36
46
|
...trigger === "click" && {
|
|
37
47
|
onClick: () => setIsOpen((prev) => !prev)
|
|
38
|
-
}
|
|
48
|
+
},
|
|
49
|
+
...getReferenceProps()
|
|
39
50
|
};
|
|
40
51
|
return {
|
|
41
52
|
isOpen,
|
|
@@ -46,7 +57,9 @@ const useFloatingLogic = ({
|
|
|
46
57
|
refs,
|
|
47
58
|
context,
|
|
48
59
|
floatingStyles,
|
|
49
|
-
triggerProps
|
|
60
|
+
triggerProps,
|
|
61
|
+
getReferenceProps,
|
|
62
|
+
getFloatingProps
|
|
50
63
|
};
|
|
51
64
|
};
|
|
52
65
|
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import React__default, { useRef } from 'react';
|
|
2
|
-
import '@internationalized/date';
|
|
3
|
-
import 'react-aria';
|
|
4
|
-
import 'react-stately';
|
|
5
|
-
import '@floating-ui/react';
|
|
6
|
-
import 'currency.js';
|
|
7
|
-
import { useOutsideClickListener } from '../../hooks/useOutsideClickListener.js';
|
|
8
|
-
import { usePopoverContext } from '../Popover/Context.js';
|
|
9
2
|
|
|
10
3
|
const Content = ({ children }) => {
|
|
11
|
-
const { setIsOpen } = usePopoverContext();
|
|
12
4
|
const ref = useRef(null);
|
|
13
|
-
useOutsideClickListener({
|
|
14
|
-
ref,
|
|
15
|
-
onClickOutside: () => setIsOpen(false)
|
|
16
|
-
});
|
|
17
5
|
return /* @__PURE__ */ React__default.createElement("div", { ref }, children);
|
|
18
6
|
};
|
|
19
7
|
|
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { usePopoverContext } from './Context.js';
|
|
4
|
+
import { FloatingFocusManager } from '@floating-ui/react';
|
|
4
5
|
|
|
5
6
|
const PopoverContent = ({
|
|
6
7
|
children,
|
|
7
8
|
className
|
|
8
9
|
}) => {
|
|
9
|
-
const {
|
|
10
|
-
|
|
10
|
+
const {
|
|
11
|
+
isOpen,
|
|
12
|
+
x,
|
|
13
|
+
y,
|
|
14
|
+
strategy,
|
|
15
|
+
floatingStyles,
|
|
16
|
+
refs,
|
|
17
|
+
getFloatingProps,
|
|
18
|
+
context
|
|
19
|
+
} = usePopoverContext();
|
|
20
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, isOpen && /* @__PURE__ */ React__default.createElement(FloatingFocusManager, { context, modal: true }, /* @__PURE__ */ React__default.createElement(
|
|
11
21
|
"div",
|
|
12
22
|
{
|
|
13
23
|
ref: refs.setFloating,
|
|
24
|
+
...getFloatingProps(),
|
|
14
25
|
className: clsx(
|
|
15
26
|
"border border-gray-200 bg-black p-[0px] rounded-md shadow-lg z-popover",
|
|
16
27
|
className
|
|
@@ -23,7 +34,7 @@ const PopoverContent = ({
|
|
|
23
34
|
}
|
|
24
35
|
},
|
|
25
36
|
children
|
|
26
|
-
)
|
|
37
|
+
)));
|
|
27
38
|
};
|
|
28
39
|
|
|
29
40
|
export { PopoverContent };
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
import React__default, { useRef } from 'react';
|
|
3
|
-
import '@internationalized/date';
|
|
4
|
-
import 'react-aria';
|
|
5
|
-
import 'react-stately';
|
|
6
|
-
import '@floating-ui/react';
|
|
7
|
-
import 'currency.js';
|
|
8
|
-
import { useOutsideClickListener } from '../../hooks/useOutsideClickListener.js';
|
|
9
|
-
import { usePopoverContext } from '../Popover/Context.js';
|
|
10
3
|
|
|
11
4
|
const Content = ({ children, className }) => {
|
|
12
|
-
const { setIsOpen } = usePopoverContext();
|
|
13
5
|
const ref = useRef(null);
|
|
14
|
-
useOutsideClickListener({
|
|
15
|
-
ref,
|
|
16
|
-
onClickOutside: () => setIsOpen(false)
|
|
17
|
-
});
|
|
18
6
|
return /* @__PURE__ */ React__default.createElement("div", { className: clsx("w-full relative", className), ref }, children);
|
|
19
7
|
};
|
|
20
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
|
-
import { useFloating, autoUpdate, offset, flip, shift, arrow } from '@floating-ui/react';
|
|
2
|
+
import { useFloating, autoUpdate, offset, flip, shift, arrow, useClick, useDismiss, useRole, useInteractions } from '@floating-ui/react';
|
|
3
3
|
|
|
4
4
|
const useFloatingLogic = ({
|
|
5
5
|
placement,
|
|
@@ -11,6 +11,8 @@ const useFloatingLogic = ({
|
|
|
11
11
|
{
|
|
12
12
|
placement,
|
|
13
13
|
whileElementsMounted: autoUpdate,
|
|
14
|
+
open: isOpen,
|
|
15
|
+
onOpenChange: setIsOpen,
|
|
14
16
|
middleware: [
|
|
15
17
|
offset(10),
|
|
16
18
|
flip({
|
|
@@ -22,6 +24,14 @@ const useFloatingLogic = ({
|
|
|
22
24
|
]
|
|
23
25
|
}
|
|
24
26
|
);
|
|
27
|
+
const click = useClick(context);
|
|
28
|
+
const dismiss = useDismiss(context);
|
|
29
|
+
const role = useRole(context);
|
|
30
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
31
|
+
click,
|
|
32
|
+
dismiss,
|
|
33
|
+
role
|
|
34
|
+
]);
|
|
25
35
|
useEffect(() => {
|
|
26
36
|
if (isOpen) update();
|
|
27
37
|
}, [isOpen, update]);
|
|
@@ -33,7 +43,8 @@ const useFloatingLogic = ({
|
|
|
33
43
|
},
|
|
34
44
|
...trigger === "click" && {
|
|
35
45
|
onClick: () => setIsOpen((prev) => !prev)
|
|
36
|
-
}
|
|
46
|
+
},
|
|
47
|
+
...getReferenceProps()
|
|
37
48
|
};
|
|
38
49
|
return {
|
|
39
50
|
isOpen,
|
|
@@ -44,7 +55,9 @@ const useFloatingLogic = ({
|
|
|
44
55
|
refs,
|
|
45
56
|
context,
|
|
46
57
|
floatingStyles,
|
|
47
|
-
triggerProps
|
|
58
|
+
triggerProps,
|
|
59
|
+
getReferenceProps,
|
|
60
|
+
getFloatingProps
|
|
48
61
|
};
|
|
49
62
|
};
|
|
50
63
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Placement } from '@floating-ui/react';
|
|
2
|
+
import { FloatingContext, Placement, UseInteractionsReturn } from '@floating-ui/react';
|
|
3
3
|
interface ContextProps {
|
|
4
4
|
triggerProps?: any;
|
|
5
5
|
refs?: any;
|
|
@@ -12,6 +12,9 @@ interface ContextProps {
|
|
|
12
12
|
placement?: Placement;
|
|
13
13
|
setPlacement?: React.Dispatch<React.SetStateAction<Placement | undefined>>;
|
|
14
14
|
setTrigger?: React.Dispatch<React.SetStateAction<'hover' | 'click'>>;
|
|
15
|
+
getReferenceProps: UseInteractionsReturn['getReferenceProps'];
|
|
16
|
+
getFloatingProps: UseInteractionsReturn['getFloatingProps'];
|
|
17
|
+
context: FloatingContext;
|
|
15
18
|
}
|
|
16
19
|
export declare const Context: React.Context<ContextProps | undefined>;
|
|
17
20
|
export declare const usePopoverContext: () => ContextProps;
|
|
@@ -42,5 +42,7 @@ export declare const useFloatingLogic: ({ placement, trigger, arrowRef, }: Float
|
|
|
42
42
|
onMouseLeave?: (() => void) | undefined;
|
|
43
43
|
ref: ((node: import("@floating-ui/react-dom").ReferenceType | null) => void) & ((node: import("@floating-ui/react").ReferenceType | null) => void);
|
|
44
44
|
};
|
|
45
|
+
getReferenceProps: (userProps?: import("react").HTMLProps<Element> | undefined) => Record<string, unknown>;
|
|
46
|
+
getFloatingProps: (userProps?: import("react").HTMLProps<HTMLElement> | undefined) => Record<string, unknown>;
|
|
45
47
|
};
|
|
46
48
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/cortex-react",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.4",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"react-dom": ">=18.0.0",
|
|
46
46
|
"tailwind": ">=3.3.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "331072b5da891409d0d7bd89df4a86e4d77dd8b8"
|
|
49
49
|
}
|