@particle-network/ui-react 0.7.0-beta.16 → 0.7.0-beta.18
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/components/UXSimplePopover/simple-popover.d.ts +1 -1
- package/dist/components/UXSimplePopover/simple-popover.js +54 -13
- package/dist/components/UXToast/index.d.ts +4 -1
- package/dist/components/UXToast/index.js +2 -2
- package/dist/components/layout/Box/box-theme.d.ts +2 -2
- package/dist/components/layout/Box/box-theme.js +1 -1
- package/dist/components/typography/text-theme.d.ts +2 -2
- package/dist/components/typography/text-theme.js +1 -1
- package/package.json +3 -3
|
@@ -19,7 +19,7 @@ export interface UXSimplePopoverProps {
|
|
|
19
19
|
closeDelay?: number;
|
|
20
20
|
/** Distance between popover and trigger (px) */
|
|
21
21
|
offset?: number;
|
|
22
|
-
/** ClassName for the trigger
|
|
22
|
+
/** ClassName for the trigger element and popover content */
|
|
23
23
|
classNames?: {
|
|
24
24
|
trigger?: string;
|
|
25
25
|
content?: string;
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useRef } from "react";
|
|
2
|
+
import react, { useCallback, useRef } from "react";
|
|
3
|
+
import { cn } from "../../utils/index.js";
|
|
3
4
|
import { useSimplePopoverContext } from "./provider.js";
|
|
4
5
|
const warnedRef = {
|
|
5
6
|
current: false
|
|
6
7
|
};
|
|
8
|
+
const warnedChildRef = {
|
|
9
|
+
current: false
|
|
10
|
+
};
|
|
11
|
+
function composeEventHandlers(original, next) {
|
|
12
|
+
return (event)=>{
|
|
13
|
+
original?.(event);
|
|
14
|
+
if (!event.defaultPrevented) next?.(event);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function isIntrinsicInteractiveElement(element) {
|
|
18
|
+
return 'string' == typeof element.type && [
|
|
19
|
+
'button',
|
|
20
|
+
'a',
|
|
21
|
+
'input',
|
|
22
|
+
'select',
|
|
23
|
+
'textarea',
|
|
24
|
+
'summary'
|
|
25
|
+
].includes(element.type);
|
|
26
|
+
}
|
|
7
27
|
const UXSimplePopover = ({ content, children, triggerType = 'hover', placement = 'top', size = 'md', offset = 8, delay = 300, closeDelay = 100, classNames })=>{
|
|
8
28
|
const ctx = useSimplePopoverContext();
|
|
9
|
-
const ref = useRef(null);
|
|
10
29
|
const contentRef = useRef(content);
|
|
11
30
|
contentRef.current = content;
|
|
12
31
|
const optionsRef = useRef({
|
|
@@ -26,8 +45,8 @@ const UXSimplePopover = ({ content, children, triggerType = 'hover', placement =
|
|
|
26
45
|
contentClassName: classNames?.content
|
|
27
46
|
};
|
|
28
47
|
const isClick = 'click' === triggerType;
|
|
29
|
-
const handleEnter = useCallback(()=>{
|
|
30
|
-
if (
|
|
48
|
+
const handleEnter = useCallback((e)=>{
|
|
49
|
+
if (ctx && !isClick) ctx.show(e.currentTarget, contentRef.current, optionsRef.current);
|
|
31
50
|
}, [
|
|
32
51
|
ctx,
|
|
33
52
|
isClick
|
|
@@ -38,14 +57,17 @@ const UXSimplePopover = ({ content, children, triggerType = 'hover', placement =
|
|
|
38
57
|
ctx,
|
|
39
58
|
isClick
|
|
40
59
|
]);
|
|
41
|
-
const handlePointerDown = useCallback(()=>{
|
|
42
|
-
if (
|
|
60
|
+
const handlePointerDown = useCallback((e)=>{
|
|
61
|
+
if (ctx && isClick) ctx.prepare(e.currentTarget, contentRef.current, optionsRef.current);
|
|
43
62
|
}, [
|
|
44
63
|
ctx,
|
|
45
64
|
isClick
|
|
46
65
|
]);
|
|
47
|
-
const handleClick = useCallback(()=>{
|
|
48
|
-
if (ctx && isClick)
|
|
66
|
+
const handleClick = useCallback((e)=>{
|
|
67
|
+
if (ctx && isClick) {
|
|
68
|
+
ctx.prepare(e.currentTarget, contentRef.current, optionsRef.current);
|
|
69
|
+
ctx.toggle();
|
|
70
|
+
}
|
|
49
71
|
}, [
|
|
50
72
|
ctx,
|
|
51
73
|
isClick
|
|
@@ -53,8 +75,8 @@ const UXSimplePopover = ({ content, children, triggerType = 'hover', placement =
|
|
|
53
75
|
const handleKeyDown = useCallback((e)=>{
|
|
54
76
|
if (isClick && ('Enter' === e.key || ' ' === e.key)) {
|
|
55
77
|
e.preventDefault();
|
|
56
|
-
if (
|
|
57
|
-
ctx.prepare(
|
|
78
|
+
if (ctx) {
|
|
79
|
+
ctx.prepare(e.currentTarget, contentRef.current, optionsRef.current);
|
|
58
80
|
ctx.toggle();
|
|
59
81
|
}
|
|
60
82
|
}
|
|
@@ -66,16 +88,35 @@ const UXSimplePopover = ({ content, children, triggerType = 'hover', placement =
|
|
|
66
88
|
warnedRef.current = true;
|
|
67
89
|
console.warn('[UXSimplePopover] must be used inside <UXSimplePopoverProvider>. Popover will not work.');
|
|
68
90
|
}
|
|
91
|
+
if (/*#__PURE__*/ react.isValidElement(children) && children.type !== react.Fragment) {
|
|
92
|
+
const child = children;
|
|
93
|
+
const interactiveElement = isIntrinsicInteractiveElement(child);
|
|
94
|
+
return /*#__PURE__*/ react.cloneElement(child, {
|
|
95
|
+
className: cn(child.props.className, classNames?.trigger),
|
|
96
|
+
onMouseEnter: composeEventHandlers(child.props.onMouseEnter, handleEnter),
|
|
97
|
+
onMouseLeave: composeEventHandlers(child.props.onMouseLeave, handleLeave),
|
|
98
|
+
...isClick ? {
|
|
99
|
+
role: child.props.role ?? (interactiveElement ? void 0 : 'button'),
|
|
100
|
+
tabIndex: child.props.tabIndex ?? (interactiveElement ? void 0 : 0),
|
|
101
|
+
onPointerDown: composeEventHandlers(child.props.onPointerDown, handlePointerDown),
|
|
102
|
+
onClick: composeEventHandlers(child.props.onClick, handleClick),
|
|
103
|
+
onKeyDown: composeEventHandlers(child.props.onKeyDown, handleKeyDown)
|
|
104
|
+
} : {}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (!warnedChildRef.current) {
|
|
108
|
+
warnedChildRef.current = true;
|
|
109
|
+
console.warn('[UXSimplePopover] children should be a single React element to avoid the fallback <span> wrapper.');
|
|
110
|
+
}
|
|
69
111
|
return /*#__PURE__*/ jsx("span", {
|
|
70
|
-
ref: ref,
|
|
71
112
|
className: classNames?.trigger,
|
|
72
113
|
onMouseEnter: handleEnter,
|
|
73
114
|
onMouseLeave: handleLeave,
|
|
74
115
|
...isClick ? {
|
|
75
116
|
role: 'button',
|
|
76
117
|
tabIndex: 0,
|
|
77
|
-
|
|
78
|
-
|
|
118
|
+
onPointerDown: handlePointerDown,
|
|
119
|
+
onClick: handleClick,
|
|
79
120
|
onKeyDown: handleKeyDown
|
|
80
121
|
} : {},
|
|
81
122
|
children: children
|
|
@@ -5,7 +5,10 @@ export type UXToastType = 'success' | 'error' | 'loading' | 'info';
|
|
|
5
5
|
export type UXToastProps = Partial<ToastProps> & {
|
|
6
6
|
type: UXToastType;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export interface UXToastProviderProps {
|
|
9
|
+
placement?: ToastProps['placement'];
|
|
10
|
+
}
|
|
11
|
+
export declare const UXToastProvider: ({ placement }: UXToastProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
12
|
export declare const toast: {
|
|
10
13
|
info: (message: ReactNode, props?: Partial<ToastProps>) => string | null;
|
|
11
14
|
success: (message: ReactNode, props?: Partial<ToastProps>) => string | null;
|
|
@@ -6,9 +6,9 @@ import CloseIcon from "@particle-network/icons/web/CloseIcon";
|
|
|
6
6
|
import { hasLongWord } from "../../utils/index.js";
|
|
7
7
|
import { UXSpinner } from "../UXSpinner/index.js";
|
|
8
8
|
import { WrapText } from "../WrapText/index.js";
|
|
9
|
-
const UXToastProvider = ()=>/*#__PURE__*/ jsx(ToastProvider, {
|
|
9
|
+
const UXToastProvider = ({ placement = 'top-center' })=>/*#__PURE__*/ jsx(ToastProvider, {
|
|
10
10
|
disableAnimation: true,
|
|
11
|
-
placement:
|
|
11
|
+
placement: placement,
|
|
12
12
|
maxVisibleToasts: 4,
|
|
13
13
|
toastProps: {
|
|
14
14
|
timeout: 4000
|
|
@@ -737,7 +737,7 @@ export declare const boxVariants: import("tailwind-variants").TVReturnType<{
|
|
|
737
737
|
center: string;
|
|
738
738
|
right: string;
|
|
739
739
|
};
|
|
740
|
-
}, undefined, "
|
|
740
|
+
}, undefined, "", {
|
|
741
741
|
position: {
|
|
742
742
|
static: string;
|
|
743
743
|
relative: string;
|
|
@@ -2209,5 +2209,5 @@ export declare const boxVariants: import("tailwind-variants").TVReturnType<{
|
|
|
2209
2209
|
center: string;
|
|
2210
2210
|
right: string;
|
|
2211
2211
|
};
|
|
2212
|
-
}, undefined, "
|
|
2212
|
+
}, undefined, "", unknown, unknown, undefined>>;
|
|
2213
2213
|
export type BoxVariants = VariantProps<typeof boxVariants>;
|
|
@@ -57,7 +57,7 @@ export declare const textVariants: import("tailwind-variants").TVReturnType<{
|
|
|
57
57
|
'1': string;
|
|
58
58
|
'1.4': string;
|
|
59
59
|
};
|
|
60
|
-
}, undefined, "
|
|
60
|
+
}, undefined, "", {
|
|
61
61
|
variant: {
|
|
62
62
|
h1: string;
|
|
63
63
|
h2: string;
|
|
@@ -175,4 +175,4 @@ export declare const textVariants: import("tailwind-variants").TVReturnType<{
|
|
|
175
175
|
'1': string;
|
|
176
176
|
'1.4': string;
|
|
177
177
|
};
|
|
178
|
-
}, undefined, "
|
|
178
|
+
}, undefined, "", unknown, unknown, undefined>>;
|
|
@@ -11,7 +11,7 @@ const body3 = 'text-[0.6875rem] leading-[1rem] font-normal';
|
|
|
11
11
|
const caption1Bold = 'text-[0.625rem] leading-[0.875rem] font-medium';
|
|
12
12
|
const caption1 = 'text-[0.625rem] leading-[0.875rem] font-normal';
|
|
13
13
|
const textVariants = tv({
|
|
14
|
-
base: '
|
|
14
|
+
base: '',
|
|
15
15
|
variants: {
|
|
16
16
|
variant: {
|
|
17
17
|
h1,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@particle-network/ui-react",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.0-beta.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"tailwind-variants": "^3.2.2",
|
|
59
59
|
"values.js": "^2.1.1",
|
|
60
60
|
"zustand": "^5.0.8",
|
|
61
|
-
"@particle-network/
|
|
62
|
-
"@particle-network/
|
|
61
|
+
"@particle-network/icons": "0.7.0-beta.6",
|
|
62
|
+
"@particle-network/ui-shared": "0.6.0-beta.0"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "rslib build",
|