@particle-network/ui-react 0.7.0-beta.15 → 0.7.0-beta.17
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/UXButton/button-theme.js +8 -8
- package/dist/components/UXSimplePopover/simple-popover.d.ts +1 -1
- package/dist/components/UXSimplePopover/simple-popover.js +54 -13
- 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
|
@@ -33,10 +33,10 @@ const button_theme_button = tv({
|
|
|
33
33
|
text: 'bg-transparent min-w-0 w-auto h-auto px-0'
|
|
34
34
|
},
|
|
35
35
|
size: {
|
|
36
|
-
xs: 'gap-1 rounded-
|
|
37
|
-
sm: 'gap-1 rounded-
|
|
38
|
-
md: 'gap-1 rounded-
|
|
39
|
-
lg: 'gap-1 rounded-
|
|
36
|
+
xs: 'gap-1 rounded-[4px] !text-caption1 min-w-min font-medium [&>svg]:size-[14px]',
|
|
37
|
+
sm: 'gap-1 rounded-[6px] !text-body3 min-w-min font-medium [&>svg]:size-4',
|
|
38
|
+
md: 'gap-1 rounded-[6px] text-tiny min-w-min font-medium [&>svg]:size-[18px]',
|
|
39
|
+
lg: 'gap-1 rounded-[8px] text-sm min-w-min font-medium [&>svg]:size-5',
|
|
40
40
|
xl: 'gap-1 rounded-[10px] text-medium min-w-min font-medium [&>svg]:size-6',
|
|
41
41
|
auto: 'min-w-min rounded-[10px]'
|
|
42
42
|
},
|
|
@@ -492,22 +492,22 @@ const button_theme_button = tv({
|
|
|
492
492
|
{
|
|
493
493
|
isInGroup: true,
|
|
494
494
|
size: 'xs',
|
|
495
|
-
class: 'rounded-none first:rounded-s-
|
|
495
|
+
class: 'rounded-none first:rounded-s-[4px] last:rounded-e-[4px]'
|
|
496
496
|
},
|
|
497
497
|
{
|
|
498
498
|
isInGroup: true,
|
|
499
499
|
size: 'sm',
|
|
500
|
-
class: 'rounded-none first:rounded-s-
|
|
500
|
+
class: 'rounded-none first:rounded-s-[6px] last:rounded-e-[6px]'
|
|
501
501
|
},
|
|
502
502
|
{
|
|
503
503
|
isInGroup: true,
|
|
504
504
|
size: 'md',
|
|
505
|
-
class: 'rounded-none first:rounded-s-
|
|
505
|
+
class: 'rounded-none first:rounded-s-[6px] last:rounded-e-[6px]'
|
|
506
506
|
},
|
|
507
507
|
{
|
|
508
508
|
isInGroup: true,
|
|
509
509
|
size: 'lg',
|
|
510
|
-
class: 'rounded-none first:rounded-s-
|
|
510
|
+
class: 'rounded-none first:rounded-s-[8px] last:rounded-e-[8px]'
|
|
511
511
|
},
|
|
512
512
|
{
|
|
513
513
|
isInGroup: true,
|
|
@@ -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
|
|
@@ -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.17",
|
|
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/ui-shared": "0.6.0-beta.0",
|
|
62
|
+
"@particle-network/icons": "0.7.0-beta.6"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "rslib build",
|