@tecsinapse/cortex-react 1.3.0-beta.1 → 1.3.0-beta.3
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/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/Popover/Popover.js +13 -0
- package/dist/cjs/components/Popover/PopoverContent.js +28 -0
- package/dist/cjs/components/Popover/PopoverContext.js +29 -0
- package/dist/cjs/components/Popover/PopoverRoot.js +10 -0
- package/dist/cjs/components/Popover/PopoverTrigger.js +11 -0
- package/dist/cjs/components/RangeCalendar.js +1 -0
- package/dist/cjs/components/Select/GroupedOptions.js +32 -0
- package/dist/cjs/components/Select/Option.js +25 -0
- package/dist/cjs/components/Select/Options.js +29 -0
- package/dist/cjs/components/Select/Popover.js +13 -0
- package/dist/cjs/components/Select/Root.js +32 -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 +47 -0
- package/dist/cjs/hooks/useFloatingLogic.js +53 -0
- package/dist/cjs/hooks/useOutsideClickListener.js +22 -0
- package/dist/cjs/index.js +11 -9
- package/dist/cjs/service/SnackbarSonner.js +13 -2
- 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/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/Popover/Popover.js +11 -0
- package/dist/esm/components/Popover/PopoverContent.js +26 -0
- package/dist/esm/components/Popover/PopoverContext.js +26 -0
- package/dist/esm/components/Popover/PopoverRoot.js +8 -0
- package/dist/esm/components/Popover/PopoverTrigger.js +9 -0
- package/dist/esm/components/RangeCalendar.js +1 -0
- package/dist/esm/components/Select/GroupedOptions.js +30 -0
- package/dist/esm/components/Select/Option.js +23 -0
- package/dist/esm/components/Select/Options.js +27 -0
- package/dist/esm/components/Select/Popover.js +11 -0
- package/dist/esm/components/Select/Root.js +30 -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 +45 -0
- package/dist/esm/hooks/useFloatingLogic.js +51 -0
- package/dist/esm/hooks/useOutsideClickListener.js +20 -0
- package/dist/esm/index.js +6 -2
- package/dist/esm/service/SnackbarSonner.js +13 -2
- 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/Popover/Popover.d.ts +5 -0
- package/dist/types/components/Popover/PopoverContent.d.ts +7 -0
- package/dist/types/components/Popover/PopoverContext.d.ts +22 -0
- package/dist/types/components/Popover/PopoverRoot.d.ts +9 -0
- package/dist/types/components/Popover/PopoverTrigger.d.ts +6 -0
- package/dist/types/components/Popover/index.d.ts +3 -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 +10 -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 +10 -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/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/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/SearchInput.d.ts +0 -10
- package/dist/types/components/Select.d.ts +0 -27
- /package/dist/types/tests/{Input.test.d.ts → Input/Box.test.d.ts} +0 -0
- /package/dist/types/tests/{SearchInput.test.d.ts → Input/Face.test.d.ts} +0 -0
|
@@ -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
|
@@ -11,22 +11,26 @@ export { DefaultSnack } from './components/DefaultSnack.js';
|
|
|
11
11
|
export { Drawer } from './components/Drawer.js';
|
|
12
12
|
export { GroupButton } from './components/GroupButton.js';
|
|
13
13
|
export { Hint } from './components/Hint.js';
|
|
14
|
-
export {
|
|
14
|
+
export { Input } from './components/Input/index.js';
|
|
15
15
|
export { Modal } from './components/Modal.js';
|
|
16
16
|
export { ProgressBar } from './components/ProgressBar.js';
|
|
17
17
|
export { RangeCalendar } from './components/RangeCalendar.js';
|
|
18
|
-
export { Select } from './components/Select.js';
|
|
18
|
+
export { Select } from './components/Select/index.js';
|
|
19
19
|
export { Skeleton } from './components/Skeleton.js';
|
|
20
20
|
export { TCell, TFoot, THead, THeadCell, TRow, TRowHeader, Table, Td } from './components/Table.js';
|
|
21
21
|
export { Tag } from './components/Tag.js';
|
|
22
22
|
export { TextArea } from './components/TextArea.js';
|
|
23
23
|
export { TimeFieldInput } from './components/TimeFieldInput.js';
|
|
24
24
|
export { Toggle } from './components/Toggle.js';
|
|
25
|
+
import './components/Tooltip.js';
|
|
26
|
+
export { Popover } from './components/Popover/Popover.js';
|
|
25
27
|
export { useCalendar } from './hooks/useCalendar.js';
|
|
26
28
|
export { useCalendarCell } from './hooks/useCalendarCell.js';
|
|
27
29
|
export { useCalendarGrid } from './hooks/useCalendarGrid.js';
|
|
28
30
|
export { useDatePickerInput } from './hooks/useDatePickerInput.js';
|
|
29
31
|
export { useDateRangePickerInput } from './hooks/useDateRangePickerInput.js';
|
|
30
32
|
export { useDebouncedState } from './hooks/useDebouncedState.js';
|
|
33
|
+
export { useOutsideClickListener } from './hooks/useOutsideClickListener.js';
|
|
31
34
|
export { useRangeCalendar } from './hooks/useRangeCalendar.js';
|
|
35
|
+
export { useFloatingLogic } from './hooks/useFloatingLogic.js';
|
|
32
36
|
export { SnackbarSonner } from './service/SnackbarSonner.js';
|
|
@@ -9,11 +9,17 @@ import '../components/Card.js';
|
|
|
9
9
|
import '../components/Button.js';
|
|
10
10
|
import 'react-aria';
|
|
11
11
|
import 'react-stately';
|
|
12
|
+
import '@floating-ui/react';
|
|
12
13
|
import '../components/CalendarCell.js';
|
|
13
14
|
import '@tecsinapse/cortex-core';
|
|
14
15
|
import 'react-icons/fa';
|
|
15
16
|
import 'react-icons/lia';
|
|
16
|
-
import '../components/Input.js';
|
|
17
|
+
import '../components/Input/Box.js';
|
|
18
|
+
import '../components/Input/Face.js';
|
|
19
|
+
import '../components/Input/Left.js';
|
|
20
|
+
import '../components/Input/Right.js';
|
|
21
|
+
import '../components/Input/Root.js';
|
|
22
|
+
import '../components/Input/Search.js';
|
|
17
23
|
import { DefaultSnack } from '../components/DefaultSnack.js';
|
|
18
24
|
import '../components/GroupButton.js';
|
|
19
25
|
import '../components/Hint.js';
|
|
@@ -21,10 +27,15 @@ import '../components/Modal.js';
|
|
|
21
27
|
import '../styles/calendar-cell.js';
|
|
22
28
|
import '../styles/groupButton.js';
|
|
23
29
|
import '../styles/progressBar.js';
|
|
24
|
-
import '../components/Select.js';
|
|
30
|
+
import '../components/Select/GroupedOptions.js';
|
|
31
|
+
import '../components/Select/context.js';
|
|
32
|
+
import '../components/Select/Popover.js';
|
|
33
|
+
import '../components/Select/Trigger.js';
|
|
25
34
|
import '../components/Tag.js';
|
|
26
35
|
import '../components/TextArea.js';
|
|
27
36
|
import '../components/Toggle.js';
|
|
37
|
+
import '../components/Tooltip.js';
|
|
38
|
+
import '../components/Popover/PopoverContext.js';
|
|
28
39
|
|
|
29
40
|
class SnackbarSonner {
|
|
30
41
|
custom(Component, options) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const Input: {
|
|
2
|
+
Root: import("react").ForwardRefExoticComponent<import("./types").InputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
3
|
+
Face: import("react").ForwardRefExoticComponent<import("./types").InputFaceProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
4
|
+
Box: import("react").ForwardRefExoticComponent<import("./types").InputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
5
|
+
Left: import("react").ForwardRefExoticComponent<import("./types").InputLeftProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
6
|
+
Right: import("react").ForwardRefExoticComponent<import("./types").InputRightProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
7
|
+
Search: import("react").ForwardRefExoticComponent<import("./types").InputSearchProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
8
|
+
};
|
|
9
|
+
export * from './types';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InputBaseVariants } from '@tecsinapse/cortex-core';
|
|
2
|
+
export interface InputPropsBase {
|
|
3
|
+
variants?: InputBaseVariants;
|
|
4
|
+
label?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement>, InputPropsBase {
|
|
7
|
+
}
|
|
8
|
+
export interface InputFaceProps extends React.HTMLAttributes<HTMLDivElement>, Pick<InputPropsBase, 'variants'> {
|
|
9
|
+
}
|
|
10
|
+
export interface InputLeftProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface InputRightProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface InputSearchProps extends InputProps {
|
|
19
|
+
bounceTimeout?: number;
|
|
20
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { Placement } from '@floating-ui/react';
|
|
3
|
+
interface PopoverContextProps {
|
|
4
|
+
triggerProps?: any;
|
|
5
|
+
refs?: any;
|
|
6
|
+
isOpen?: boolean;
|
|
7
|
+
x?: number;
|
|
8
|
+
y?: number;
|
|
9
|
+
strategy?: 'absolute' | 'fixed';
|
|
10
|
+
floatingStyles?: React.CSSProperties;
|
|
11
|
+
placement?: Placement;
|
|
12
|
+
setPlacement?: React.Dispatch<React.SetStateAction<Placement | undefined>>;
|
|
13
|
+
setTrigger?: React.Dispatch<React.SetStateAction<'hover' | 'click'>>;
|
|
14
|
+
}
|
|
15
|
+
export declare const usePopoverContext: () => PopoverContextProps;
|
|
16
|
+
interface PopoverProviderProps {
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
placement?: Placement;
|
|
19
|
+
trigger?: 'hover' | 'click';
|
|
20
|
+
}
|
|
21
|
+
export declare const PopoverProvider: ({ children, placement, trigger, }: PopoverProviderProps) => JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Placement } from '@floating-ui/react';
|
|
3
|
+
export interface PopoverRootProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
placement?: Placement;
|
|
6
|
+
trigger?: 'hover' | 'click';
|
|
7
|
+
}
|
|
8
|
+
declare const PopoverRoot: ({ children, placement, trigger }: PopoverRootProps) => JSX.Element;
|
|
9
|
+
export default PopoverRoot;
|
|
@@ -0,0 +1,6 @@
|
|
|
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;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface SelectGroupedOptionsProps<T> {
|
|
2
|
+
onSelect: (value: T) => void;
|
|
3
|
+
options?: Map<string, T[]>;
|
|
4
|
+
groupedLabelExtractor: (value: string) => string;
|
|
5
|
+
}
|
|
6
|
+
export declare const SelectGroupedOptions: <T>({ onSelect, groupedLabelExtractor, options, }: SelectGroupedOptionsProps<T>) => JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface SelectRootProps<T> {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
value?: T;
|
|
5
|
+
keyExtractor: (value: T) => string;
|
|
6
|
+
labelExtractor: (value: T) => string;
|
|
7
|
+
}
|
|
8
|
+
export declare const SelectRoot: <T>({ children, value, keyExtractor, labelExtractor, }: SelectRootProps<T>) => JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
interface SelectContextProps<T> {
|
|
3
|
+
value?: T;
|
|
4
|
+
open?: boolean;
|
|
5
|
+
setOpen?: Dispatch<SetStateAction<boolean>>;
|
|
6
|
+
keyExtractor: (value: T) => string;
|
|
7
|
+
labelExtractor: (value: T) => string;
|
|
8
|
+
}
|
|
9
|
+
export declare const SelectContext: import("react").Context<SelectContextProps<any>>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const Select: {
|
|
2
|
+
Root: <T>({ children, value, keyExtractor, labelExtractor, }: import("./Root").SelectRootProps<T>) => JSX.Element;
|
|
3
|
+
Trigger: ({ label, disabled }: import("./Trigger").SelectTriggerProps) => JSX.Element;
|
|
4
|
+
Popover: ({ children }: import("./Popover").SelectPopoverProps) => JSX.Element;
|
|
5
|
+
Options: <T_1>({ onSelect, options, }: import("./Options").SelectOptionsProps<T_1>) => JSX.Element;
|
|
6
|
+
GroupedOptions: <T_2>({ onSelect, groupedLabelExtractor, options, }: import("./GroupedOptions").SelectGroupedOptionsProps<T_2>) => JSX.Element;
|
|
7
|
+
Option: <T_3>({ onSelectOption, option, }: import("./Option").SelectOptionProps<T_3>) => JSX.Element;
|
|
8
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Placement } from '@floating-ui/react';
|
|
3
|
+
interface TooltipProps {
|
|
4
|
+
children: React.ReactElement;
|
|
5
|
+
text: string;
|
|
6
|
+
trigger?: 'hover' | 'click';
|
|
7
|
+
placement?: Placement;
|
|
8
|
+
width?: number;
|
|
9
|
+
height?: number;
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
}
|
|
12
|
+
declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
export default Tooltip;
|
|
@@ -15,10 +15,19 @@ export * from './Input';
|
|
|
15
15
|
export * from './Modal';
|
|
16
16
|
export * from './ProgressBar';
|
|
17
17
|
export * from './RangeCalendar';
|
|
18
|
-
export
|
|
18
|
+
export * from './Select';
|
|
19
19
|
export * from './Skeleton';
|
|
20
20
|
export * from './Table';
|
|
21
21
|
export * from './Tag';
|
|
22
22
|
export * from './TextArea';
|
|
23
23
|
export * from './TimeFieldInput';
|
|
24
24
|
export * from './Toggle';
|
|
25
|
+
export * from './Table';
|
|
26
|
+
export * from './Drawer';
|
|
27
|
+
export * from './Breadcrumbs';
|
|
28
|
+
export * from './Avatar';
|
|
29
|
+
export * from './Skeleton';
|
|
30
|
+
export * from './ProgressBar';
|
|
31
|
+
export * from './GroupButton';
|
|
32
|
+
export * from './Tooltip';
|
|
33
|
+
export * from './Popover/Popover';
|
|
@@ -4,4 +4,6 @@ export * from './useCalendarGrid';
|
|
|
4
4
|
export * from './useDatePickerInput';
|
|
5
5
|
export * from './useDateRangePickerInput';
|
|
6
6
|
export * from './useDebouncedState';
|
|
7
|
+
export * from './useOutsideClickListener';
|
|
7
8
|
export * from './useRangeCalendar';
|
|
9
|
+
export * from './useFloatingLogic';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { Placement } from '@floating-ui/react';
|
|
3
|
+
interface FloatingLogicProps {
|
|
4
|
+
placement?: Placement;
|
|
5
|
+
trigger?: 'hover' | 'click';
|
|
6
|
+
arrowRef?: RefObject<SVGSVGElement>;
|
|
7
|
+
}
|
|
8
|
+
export declare const useFloatingLogic: ({ placement, trigger, arrowRef, }: FloatingLogicProps) => {
|
|
9
|
+
isOpen: boolean;
|
|
10
|
+
setIsOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
strategy: import("@floating-ui/utils").Strategy;
|
|
14
|
+
refs: {
|
|
15
|
+
reference: import("react").MutableRefObject<import("@floating-ui/react-dom").ReferenceType | null>;
|
|
16
|
+
floating: import("react").MutableRefObject<HTMLElement | null>;
|
|
17
|
+
setReference: (node: import("@floating-ui/react-dom").ReferenceType | null) => void;
|
|
18
|
+
setFloating: (node: HTMLElement | null) => void;
|
|
19
|
+
} & import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
20
|
+
context: {
|
|
21
|
+
placement: Placement;
|
|
22
|
+
strategy: import("@floating-ui/utils").Strategy;
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
26
|
+
isPositioned: boolean;
|
|
27
|
+
update: () => void;
|
|
28
|
+
floatingStyles: import("react").CSSProperties;
|
|
29
|
+
open: boolean;
|
|
30
|
+
onOpenChange: (open: boolean, event?: Event | undefined, reason?: import("@floating-ui/react").OpenChangeReason | undefined) => void;
|
|
31
|
+
events: import("@floating-ui/react").FloatingEvents;
|
|
32
|
+
dataRef: import("react").MutableRefObject<import("@floating-ui/react").ContextData>;
|
|
33
|
+
nodeId: string | undefined;
|
|
34
|
+
floatingId: string;
|
|
35
|
+
refs: import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
36
|
+
elements: import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
|
37
|
+
};
|
|
38
|
+
floatingStyles: import("react").CSSProperties;
|
|
39
|
+
triggerProps: {
|
|
40
|
+
onClick?: (() => void) | undefined;
|
|
41
|
+
onMouseEnter?: (() => void) | undefined;
|
|
42
|
+
onMouseLeave?: (() => void) | undefined;
|
|
43
|
+
ref: ((node: import("@floating-ui/react-dom").ReferenceType | null) => void) & ((node: import("@floating-ui/react").ReferenceType | null) => void);
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
interface useOutsideClickListenerProps {
|
|
3
|
+
ref: MutableRefObject<any>;
|
|
4
|
+
onClickOutside?: () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const useOutsideClickListener: ({ ref, onClickOutside, }: useOutsideClickListenerProps) => void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
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.3",
|
|
4
4
|
"description": "React components based in @tecsinapse/cortex-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -18,12 +18,15 @@
|
|
|
18
18
|
"test:watch": "jest --watch"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@
|
|
21
|
+
"@floating-ui/react": "^0.26.18",
|
|
22
|
+
"@internationalized/date": "*",
|
|
23
|
+
"@tecsinapse/cortex-core": "0.3.0-beta.1",
|
|
22
24
|
"clsx": "*",
|
|
23
25
|
"react-aria": "^3.33.1",
|
|
24
26
|
"react-icons": "^5.2.1",
|
|
25
27
|
"react-stately": "^3.31.1",
|
|
26
|
-
"sonner": "^1.5.0"
|
|
28
|
+
"sonner": "^1.5.0",
|
|
29
|
+
"tailwind-merge": "*"
|
|
27
30
|
},
|
|
28
31
|
"repository": {
|
|
29
32
|
"type": "git",
|
|
@@ -39,5 +42,5 @@
|
|
|
39
42
|
"react-dom": ">=18.0.0",
|
|
40
43
|
"tailwind": ">=3.3.0"
|
|
41
44
|
},
|
|
42
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "6cfddfd6db49be4dcf6dc53f192e659566bce3b3"
|
|
43
46
|
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var cortexCore = require('@tecsinapse/cortex-core');
|
|
4
|
-
var clsx = require('clsx');
|
|
5
|
-
var React = require('react');
|
|
6
|
-
|
|
7
|
-
const getValidChildren = (children) => {
|
|
8
|
-
return React.Children.toArray(children).filter(
|
|
9
|
-
(el) => React.isValidElement(el)
|
|
10
|
-
);
|
|
11
|
-
};
|
|
12
|
-
const Box = React.forwardRef(
|
|
13
|
-
({ id, name, variants, label, placeholder, className, ...rest }, ref) => {
|
|
14
|
-
return /* @__PURE__ */ React.createElement("div", { className: "flex w-full flex-col" }, /* @__PURE__ */ React.createElement(
|
|
15
|
-
"input",
|
|
16
|
-
{
|
|
17
|
-
id: id ?? name,
|
|
18
|
-
name,
|
|
19
|
-
placeholder: placeholder ?? " ",
|
|
20
|
-
className: clsx.clsx(cortexCore.inputBox(placeholder, label, className)),
|
|
21
|
-
...rest,
|
|
22
|
-
ref,
|
|
23
|
-
"data-testid": "input-input"
|
|
24
|
-
}
|
|
25
|
-
), /* @__PURE__ */ React.createElement(
|
|
26
|
-
"label",
|
|
27
|
-
{
|
|
28
|
-
htmlFor: id ?? name,
|
|
29
|
-
className: cortexCore.labelStyle({ intent: variants?.intent, placeholder }),
|
|
30
|
-
"data-testid": "input-label"
|
|
31
|
-
},
|
|
32
|
-
label
|
|
33
|
-
));
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
const Face = React.forwardRef(
|
|
37
|
-
({ children, variants, className, ...rest }, ref) => {
|
|
38
|
-
const clones = getValidChildren(children).map((el) => {
|
|
39
|
-
return React.cloneElement(el, { ...el.props, variants });
|
|
40
|
-
});
|
|
41
|
-
return /* @__PURE__ */ React.createElement(
|
|
42
|
-
"div",
|
|
43
|
-
{
|
|
44
|
-
...rest,
|
|
45
|
-
className: clsx.clsx(cortexCore.input(variants), className),
|
|
46
|
-
id: "input-face",
|
|
47
|
-
ref
|
|
48
|
-
},
|
|
49
|
-
clones
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
const Root = React.forwardRef(
|
|
54
|
-
({ variants, className, ...rest }, ref) => {
|
|
55
|
-
return /* @__PURE__ */ React.createElement(Face, { variants, className }, /* @__PURE__ */ React.createElement(Box, { ...rest, ref }));
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
const Left = React.forwardRef(
|
|
59
|
-
({ children, className, ...rest }, ref) => {
|
|
60
|
-
return /* @__PURE__ */ React.createElement("div", { className: clsx.clsx(className, "mr-2.5"), ...rest, ref }, children);
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
const Right = React.forwardRef(
|
|
64
|
-
({ children, className, ...rest }, ref) => {
|
|
65
|
-
return /* @__PURE__ */ React.createElement("div", { className: clsx.clsx(className, "ml-2.5"), ...rest, ref }, children);
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
const Input = {
|
|
69
|
-
Root,
|
|
70
|
-
Face,
|
|
71
|
-
Box,
|
|
72
|
-
Left,
|
|
73
|
-
Right
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
exports.Box = Box;
|
|
77
|
-
exports.Face = Face;
|
|
78
|
-
exports.Input = Input;
|
|
79
|
-
exports.Left = Left;
|
|
80
|
-
exports.Right = Right;
|
|
81
|
-
exports.Root = Root;
|