@tecsinapse/cortex-react 1.5.2 → 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/cjs/provider/SnackbarProvider.js +5 -2
- package/dist/cjs/service/SnackbarSonner.js +7 -3
- 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/esm/provider/SnackbarProvider.js +5 -2
- package/dist/esm/service/SnackbarSonner.js +7 -3
- package/dist/types/components/Popover/Context.d.ts +4 -1
- package/dist/types/hooks/useFloatingLogic.d.ts +2 -0
- package/dist/types/provider/SnackbarProvider.d.ts +3 -1
- package/dist/types/service/ISnackbar.d.ts +2 -1
- package/dist/types/service/SnackbarSonner.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
|
|
|
@@ -5,8 +5,11 @@ var sonner = require('sonner');
|
|
|
5
5
|
var SnackbarSonner = require('../service/SnackbarSonner.js');
|
|
6
6
|
|
|
7
7
|
const SnackbarContext = React.createContext(null);
|
|
8
|
-
const SnackbarProvider = ({
|
|
9
|
-
|
|
8
|
+
const SnackbarProvider = ({
|
|
9
|
+
children,
|
|
10
|
+
options
|
|
11
|
+
}) => {
|
|
12
|
+
const snackbar = new SnackbarSonner.SnackbarSonner(options);
|
|
10
13
|
return /* @__PURE__ */ React.createElement(SnackbarContext.Provider, { value: { snackbar } }, children, /* @__PURE__ */ React.createElement(sonner.Toaster, null));
|
|
11
14
|
};
|
|
12
15
|
const useSnackbar = () => {
|
|
@@ -5,10 +5,14 @@ var sonner = require('sonner');
|
|
|
5
5
|
var DefaultSnack = require('../components/Snackbar/DefaultSnack.js');
|
|
6
6
|
|
|
7
7
|
class SnackbarSonner {
|
|
8
|
+
_options;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this._options = { ...options, duration: options?.duration ?? 5e3 };
|
|
11
|
+
}
|
|
8
12
|
custom(Component, options) {
|
|
9
13
|
return sonner.toast.custom(() => Component, {
|
|
10
|
-
...
|
|
11
|
-
|
|
14
|
+
...this._options,
|
|
15
|
+
...options
|
|
12
16
|
});
|
|
13
17
|
}
|
|
14
18
|
show(type, message, options) {
|
|
@@ -23,7 +27,7 @@ class SnackbarSonner {
|
|
|
23
27
|
}
|
|
24
28
|
);
|
|
25
29
|
},
|
|
26
|
-
{ ...
|
|
30
|
+
{ ...this._options, ...options }
|
|
27
31
|
);
|
|
28
32
|
}
|
|
29
33
|
}
|
|
@@ -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
|
|
|
@@ -3,8 +3,11 @@ import { Toaster } from 'sonner';
|
|
|
3
3
|
import { SnackbarSonner } from '../service/SnackbarSonner.js';
|
|
4
4
|
|
|
5
5
|
const SnackbarContext = createContext(null);
|
|
6
|
-
const SnackbarProvider = ({
|
|
7
|
-
|
|
6
|
+
const SnackbarProvider = ({
|
|
7
|
+
children,
|
|
8
|
+
options
|
|
9
|
+
}) => {
|
|
10
|
+
const snackbar = new SnackbarSonner(options);
|
|
8
11
|
return /* @__PURE__ */ React__default.createElement(SnackbarContext.Provider, { value: { snackbar } }, children, /* @__PURE__ */ React__default.createElement(Toaster, null));
|
|
9
12
|
};
|
|
10
13
|
const useSnackbar = () => {
|
|
@@ -3,10 +3,14 @@ import { toast } from 'sonner';
|
|
|
3
3
|
import { DefaultSnack } from '../components/Snackbar/DefaultSnack.js';
|
|
4
4
|
|
|
5
5
|
class SnackbarSonner {
|
|
6
|
+
_options;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this._options = { ...options, duration: options?.duration ?? 5e3 };
|
|
9
|
+
}
|
|
6
10
|
custom(Component, options) {
|
|
7
11
|
return toast.custom(() => Component, {
|
|
8
|
-
...
|
|
9
|
-
|
|
12
|
+
...this._options,
|
|
13
|
+
...options
|
|
10
14
|
});
|
|
11
15
|
}
|
|
12
16
|
show(type, message, options) {
|
|
@@ -21,7 +25,7 @@ class SnackbarSonner {
|
|
|
21
25
|
}
|
|
22
26
|
);
|
|
23
27
|
},
|
|
24
|
-
{ ...
|
|
28
|
+
{ ...this._options, ...options }
|
|
25
29
|
);
|
|
26
30
|
}
|
|
27
31
|
}
|
|
@@ -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 {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { type ExternalToast } from 'sonner';
|
|
2
3
|
import { SnackbarSonner } from '../service/SnackbarSonner';
|
|
3
4
|
interface SnackbarProviderProps {
|
|
4
5
|
snackbar: SnackbarSonner;
|
|
5
6
|
}
|
|
6
|
-
export declare const SnackbarProvider: ({ children }: {
|
|
7
|
+
export declare const SnackbarProvider: ({ children, options, }: {
|
|
7
8
|
children: ReactNode;
|
|
9
|
+
options?: ExternalToast;
|
|
8
10
|
}) => JSX.Element;
|
|
9
11
|
export declare const useSnackbar: () => SnackbarProviderProps;
|
|
10
12
|
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
1
|
import { SnackbarVariants } from '@tecsinapse/cortex-core';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
3
|
export type TypeSnack = SnackbarVariants['intent'];
|
|
4
4
|
export interface ISnackbar<T> {
|
|
5
|
+
_options?: T;
|
|
5
6
|
show(type: TypeSnack, message: string, options?: T): any;
|
|
6
7
|
custom(component: ReactElement, options?: T): any;
|
|
7
8
|
}
|
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import { ExternalToast } from 'sonner';
|
|
3
3
|
import { ISnackbar, TypeSnack } from './ISnackbar';
|
|
4
4
|
export declare class SnackbarSonner implements ISnackbar<ExternalToast> {
|
|
5
|
+
_options?: ExternalToast;
|
|
6
|
+
constructor(options?: ExternalToast);
|
|
5
7
|
custom(Component: React.ReactElement, options?: ExternalToast): string | number;
|
|
6
8
|
show(type: TypeSnack, message: string, options?: Omit<ExternalToast, 'className' | 'style'>): string | number;
|
|
7
9
|
}
|
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
|
}
|