@particle-network/ui-react 0.7.0-beta.11 → 0.7.0-beta.13
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/UXHint/index.d.ts +6 -3
- package/dist/components/UXHint/index.js +9 -19
- package/dist/components/UXSimplePopover/simple-popover.d.ts +3 -1
- package/dist/components/UXSimplePopover/simple-popover.js +19 -2
- package/dist/components/UXThemeSwitch/theme-switch.js +6 -0
- package/dist/components/UXThemeSwitch/use-theme.js +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type
|
|
3
|
-
export
|
|
2
|
+
import { type SimplePopoverPlacement } from '..';
|
|
3
|
+
export interface UXHintProps {
|
|
4
|
+
content?: React.ReactNode;
|
|
5
|
+
children?: React.ReactNode;
|
|
4
6
|
triggerType?: 'hover' | 'click';
|
|
7
|
+
placement?: SimplePopoverPlacement;
|
|
5
8
|
buttonClassName?: string;
|
|
6
9
|
iconClassName?: string;
|
|
7
|
-
}
|
|
10
|
+
}
|
|
8
11
|
export declare const UXHint: React.FC<UXHintProps>;
|
|
@@ -1,31 +1,21 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import CircleQuestionIcon from "@particle-network/icons/web/CircleQuestionIcon";
|
|
4
|
-
import { Center,
|
|
4
|
+
import { Center, UXSimplePopover } from "../index.js";
|
|
5
5
|
import { cn } from "../../utils/index.js";
|
|
6
6
|
const UXHint = (props)=>{
|
|
7
|
-
const { content, children, buttonClassName, iconClassName, triggerType = 'hover',
|
|
8
|
-
|
|
7
|
+
const { content, children, buttonClassName, iconClassName, triggerType = 'hover', placement = 'top' } = props;
|
|
8
|
+
return /*#__PURE__*/ jsx(UXSimplePopover, {
|
|
9
|
+
content: content || children,
|
|
10
|
+
triggerType: triggerType,
|
|
11
|
+
placement: placement,
|
|
12
|
+
children: /*#__PURE__*/ jsx(Center, {
|
|
9
13
|
className: cn('min-h-4 min-w-4 cursor-pointer', buttonClassName),
|
|
10
14
|
children: /*#__PURE__*/ jsx(CircleQuestionIcon, {
|
|
11
15
|
size: 14,
|
|
12
16
|
className: iconClassName
|
|
13
17
|
})
|
|
14
|
-
})
|
|
15
|
-
if ('hover' === triggerType) return /*#__PURE__*/ jsx(UXTooltip, {
|
|
16
|
-
content: content || children,
|
|
17
|
-
...restProps,
|
|
18
|
-
children: renderTriggerContent()
|
|
19
|
-
});
|
|
20
|
-
return /*#__PURE__*/ jsxs(UXPopover, {
|
|
21
|
-
children: [
|
|
22
|
-
/*#__PURE__*/ jsx(UXPopoverTrigger, {
|
|
23
|
-
children: renderTriggerContent()
|
|
24
|
-
}),
|
|
25
|
-
/*#__PURE__*/ jsx(UXPopoverContent, {
|
|
26
|
-
children: content || children
|
|
27
|
-
})
|
|
28
|
-
]
|
|
18
|
+
})
|
|
29
19
|
});
|
|
30
20
|
};
|
|
31
21
|
UXHint.displayName = 'UX.Hint';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export type SimplePopoverPlacement = 'top' | 'bottom' | 'left' | 'right';
|
|
2
|
+
export type SimplePopoverPlacement = 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'left-top' | 'left-bottom' | 'right' | 'right-top' | 'right-bottom';
|
|
3
3
|
export type SimplePopoverTriggerType = 'click' | 'hover';
|
|
4
4
|
export interface UXSimplePopoverProps {
|
|
5
5
|
/** Popover content */
|
|
@@ -14,6 +14,8 @@ export interface UXSimplePopoverProps {
|
|
|
14
14
|
delay?: number;
|
|
15
15
|
/** Hover only: delay before closing (ms) */
|
|
16
16
|
closeDelay?: number;
|
|
17
|
+
/** Distance between popover and trigger (px) */
|
|
18
|
+
offset?: number;
|
|
17
19
|
/** ClassName for the trigger wrapper (when cloning a single child, applied to that child) */
|
|
18
20
|
classNames?: {
|
|
19
21
|
trigger?: string;
|
|
@@ -2,7 +2,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import react, { cloneElement, isValidElement, useCallback, useId, useRef } from "react";
|
|
3
3
|
import { cn } from "../../utils/index.js";
|
|
4
4
|
const UXSimplePopover = (props)=>{
|
|
5
|
-
const { content, children, triggerType = 'hover', placement = 'top', delay = 300, closeDelay = 100, classNames = {
|
|
5
|
+
const { content, children, triggerType = 'hover', placement = 'top', offset = 8, delay = 300, closeDelay = 100, classNames = {
|
|
6
6
|
trigger: '',
|
|
7
7
|
content: ''
|
|
8
8
|
} } = props;
|
|
@@ -54,9 +54,26 @@ const UXSimplePopover = (props)=>{
|
|
|
54
54
|
const triggerAnchorStyle = {
|
|
55
55
|
anchorName
|
|
56
56
|
};
|
|
57
|
+
const offsetMargin = {
|
|
58
|
+
top: {
|
|
59
|
+
marginBottom: offset
|
|
60
|
+
},
|
|
61
|
+
bottom: {
|
|
62
|
+
marginTop: offset
|
|
63
|
+
},
|
|
64
|
+
left: {
|
|
65
|
+
marginRight: offset
|
|
66
|
+
},
|
|
67
|
+
right: {
|
|
68
|
+
marginLeft: offset
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const primarySide = placement.split('-')[0];
|
|
57
72
|
const popoverAnchorStyle = {
|
|
58
73
|
positionAnchor: anchorName,
|
|
59
|
-
positionArea: placement
|
|
74
|
+
positionArea: placement.replace(/-/g, ' '),
|
|
75
|
+
positionTryFallbacks: 'flip-block, flip-inline, flip-block flip-inline',
|
|
76
|
+
...offsetMargin[primarySide]
|
|
60
77
|
};
|
|
61
78
|
const isClick = 'click' === triggerType;
|
|
62
79
|
const trigger = isClick ? /*#__PURE__*/ jsx("button", {
|
|
@@ -19,6 +19,7 @@ import { UXTooltip } from "../UXTooltip/index.js";
|
|
|
19
19
|
import { CustomThemeConfig } from "./custom-theme-config.js";
|
|
20
20
|
import { ThemeItem } from "./theme-item.js";
|
|
21
21
|
import { useTheme } from "./use-theme.js";
|
|
22
|
+
import { preloadFonts } from "./utils.js";
|
|
22
23
|
const FONT_EXAMPLES = [
|
|
23
24
|
{
|
|
24
25
|
title: 'Manrope',
|
|
@@ -40,6 +41,11 @@ const UXThemeSwitchModal = ({ as = 'modal', omitThemes = [], backdrop, isOpen, o
|
|
|
40
41
|
useEffect(()=>{
|
|
41
42
|
initTheme();
|
|
42
43
|
}, []);
|
|
44
|
+
useEffect(()=>{
|
|
45
|
+
if (isOpen) preloadFonts();
|
|
46
|
+
}, [
|
|
47
|
+
isOpen
|
|
48
|
+
]);
|
|
43
49
|
const Component = 'modal' === as ? UXModal : UXDrawer;
|
|
44
50
|
const themes = useMemo(()=>themeData.filter((theme)=>!omitThemes.includes(theme.id)), [
|
|
45
51
|
omitThemes
|