@particle-network/ui-react 0.3.0 → 0.3.2-beta.0
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 +1 -1
- package/dist/components/UXDatePicker/index.js +1 -1
- package/dist/components/UXDropdown/dropdown-item.js +1 -1
- package/dist/components/UXDropdown/dropdown.js +1 -1
- package/dist/components/UXEmpty/index.d.ts +1 -1
- package/dist/components/UXHint/index.d.ts +1 -1
- package/dist/components/UXModal/index.js +12 -9
- package/dist/components/UXPopover/popover.extend.js +1 -1
- package/dist/components/UXSelect/index.js +1 -1
- package/dist/components/UXTooltip/tooltip.extend.js +1 -1
- package/dist/hooks/useKeyboard.d.ts +13 -0
- package/dist/hooks/useKeyboard.js +34 -0
- package/package.json +1 -1
|
@@ -29,7 +29,7 @@ const UXDatePicker = ({ classNames, ...props })=>/*#__PURE__*/ jsx(DatePicker, {
|
|
|
29
29
|
popoverProps: {
|
|
30
30
|
classNames: {
|
|
31
31
|
base: 'before:bg-content1 before:shadow-box',
|
|
32
|
-
content: 'bg-content1 text-foreground-300 shadow-box'
|
|
32
|
+
content: 'bg-content1 text-foreground-300 shadow-box antialiased'
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
timeInputProps: {
|
|
@@ -17,7 +17,7 @@ const classes = {
|
|
|
17
17
|
},
|
|
18
18
|
flat: {
|
|
19
19
|
base: '!outline-none min-h-8 px-md rounded-small text-foreground-300 !outline-none data-[selected=true]:text-foreground gap-1',
|
|
20
|
-
title: 'text-tiny font-medium',
|
|
20
|
+
title: 'text-tiny font-medium antialiased',
|
|
21
21
|
selectedIcon: '[&>svg>polyline]:stroke-[2.5]'
|
|
22
22
|
},
|
|
23
23
|
shadow: {
|
|
@@ -8,7 +8,7 @@ const UXDropdown = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
8
8
|
ref: ref,
|
|
9
9
|
classNames: {
|
|
10
10
|
content: [
|
|
11
|
-
'text-tiny p-2.5 text-foreground-300 rounded-medium no-scrollbar shadow-box',
|
|
11
|
+
'text-tiny p-2.5 text-foreground-300 rounded-medium no-scrollbar shadow-box antialiased',
|
|
12
12
|
content
|
|
13
13
|
],
|
|
14
14
|
...restClassNames
|
|
@@ -2,21 +2,24 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { Modal, ModalBody, ModalContent, ModalFooter, ModalHeader } from "@heroui/modal";
|
|
4
4
|
import { Center, Circle, Flex, Text, UXButton } from "../index.js";
|
|
5
|
+
import useKeyboard from "../../hooks/useKeyboard.js";
|
|
5
6
|
import { CloseIcon } from "../../icons/index.js";
|
|
6
7
|
const UXModal = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
7
|
-
const { title, footer, backdrop, scrollBehavior = 'inside', children, titleAlign = 'left', classNames, tip, ...restProps } = props;
|
|
8
|
+
const { size, title, footer, backdrop, scrollBehavior = 'inside', children, titleAlign = 'left', classNames, tip, ...restProps } = props;
|
|
9
|
+
const { isKeyboardVisible } = useKeyboard();
|
|
8
10
|
return /*#__PURE__*/ jsx(Modal, {
|
|
9
11
|
ref: ref,
|
|
10
12
|
backdrop: backdrop,
|
|
11
13
|
scrollBehavior: scrollBehavior,
|
|
14
|
+
size: size,
|
|
12
15
|
classNames: {
|
|
13
16
|
wrapper: [
|
|
14
17
|
'items-end md:items-center',
|
|
15
18
|
classNames?.wrapper
|
|
16
19
|
],
|
|
17
20
|
base: [
|
|
18
|
-
'py-6 gap-5 shadow-box',
|
|
19
|
-
'max-h-[
|
|
21
|
+
'py-6 gap-5 shadow-box m-0 max-md:rounded-b-none',
|
|
22
|
+
isKeyboardVisible && 'full' !== size ? "!max-h-[400px] !min-h-[400px] overflow-y-auto" : 'max-h-[calc(100vh-48px)]',
|
|
20
23
|
'md:max-h-[750px]',
|
|
21
24
|
classNames?.base
|
|
22
25
|
],
|
|
@@ -53,17 +56,17 @@ const UXModal = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
53
56
|
...restProps,
|
|
54
57
|
children: /*#__PURE__*/ jsxs(ModalContent, {
|
|
55
58
|
children: [
|
|
56
|
-
title
|
|
59
|
+
title && /*#__PURE__*/ jsx(ModalHeader, {
|
|
57
60
|
className: "capitalize",
|
|
58
61
|
children: title
|
|
59
|
-
})
|
|
62
|
+
}),
|
|
60
63
|
/*#__PURE__*/ jsx(ModalBody, {
|
|
61
64
|
children: children
|
|
62
65
|
}),
|
|
63
|
-
footer
|
|
66
|
+
footer && /*#__PURE__*/ jsx(ModalFooter, {
|
|
64
67
|
children: footer
|
|
65
|
-
})
|
|
66
|
-
tip
|
|
68
|
+
}),
|
|
69
|
+
tip && /*#__PURE__*/ jsx(ModalFooter, {
|
|
67
70
|
className: "-mt-md",
|
|
68
71
|
children: /*#__PURE__*/ jsxs(Flex, {
|
|
69
72
|
gap: 2,
|
|
@@ -81,7 +84,7 @@ const UXModal = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
81
84
|
})
|
|
82
85
|
]
|
|
83
86
|
})
|
|
84
|
-
})
|
|
87
|
+
})
|
|
85
88
|
]
|
|
86
89
|
})
|
|
87
90
|
});
|
|
@@ -16,7 +16,7 @@ const ExtendedPopover = extendVariants(Popover, {
|
|
|
16
16
|
color: {
|
|
17
17
|
default: {
|
|
18
18
|
base: 'before:bg-content1 before:shadow-box',
|
|
19
|
-
content: 'bg-content1 text-foreground-300 shadow-box text-tiny'
|
|
19
|
+
content: 'bg-content1 text-foreground-300 shadow-box text-tiny antialiased'
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
},
|
|
@@ -35,7 +35,7 @@ const UXSelect = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
35
35
|
},
|
|
36
36
|
itemClasses: {
|
|
37
37
|
base: '!outline-none min-h-8 px-md rounded-small text-foreground-300 !outline-none data-[hover=true]:bg-background-200 data-[selected=true]:text-foreground gap-1',
|
|
38
|
-
title: 'text-tiny font-medium',
|
|
38
|
+
title: 'text-tiny font-medium antialiased',
|
|
39
39
|
selectedIcon: '[&>svg>polyline]:stroke-[2.5]'
|
|
40
40
|
}
|
|
41
41
|
},
|
|
@@ -16,7 +16,7 @@ const ExtendedTooltip = extendVariants(Tooltip, {
|
|
|
16
16
|
color: {
|
|
17
17
|
default: {
|
|
18
18
|
base: 'before:bg-content1 before:shadow-box',
|
|
19
|
-
content: 'bg-content1 text-foreground-300 shadow-box text-tiny leading-1.4 break-words wrap-break-word'
|
|
19
|
+
content: 'bg-content1 text-foreground-300 shadow-box text-tiny leading-1.4 break-words wrap-break-word antialiased'
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
},
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description
|
|
3
|
+
* 尝试获取移动端虚拟键盘的高度。
|
|
4
|
+
* 该方法主要依赖监听视口高度变化,在移动端(尤其 iOS)键盘弹出时,
|
|
5
|
+
* window.innerHeight 或 window.visualViewport.height 会减小。
|
|
6
|
+
*
|
|
7
|
+
* @returns {number} 键盘高度(像素值),如果键盘未弹出或无法确定则返回 0。
|
|
8
|
+
*/
|
|
9
|
+
declare const useKeyboard: () => {
|
|
10
|
+
keyboardHeight: number;
|
|
11
|
+
isKeyboardVisible: boolean;
|
|
12
|
+
};
|
|
13
|
+
export default useKeyboard;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
const useKeyboard = ()=>{
|
|
3
|
+
const [initialViewportHeight, setInitialViewportHeight] = useState(0);
|
|
4
|
+
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
5
|
+
useEffect(()=>{
|
|
6
|
+
const setInitialHeight = ()=>{
|
|
7
|
+
const height = window.visualViewport ? window.visualViewport.height : window.innerHeight;
|
|
8
|
+
if (height > 0) setInitialViewportHeight((prevHeight)=>Math.max(prevHeight, height));
|
|
9
|
+
};
|
|
10
|
+
requestAnimationFrame(setInitialHeight);
|
|
11
|
+
window.addEventListener('focusin', setInitialHeight);
|
|
12
|
+
const handleViewportChange = ()=>{
|
|
13
|
+
const currentHeight = window.visualViewport ? window.visualViewport.height : window.innerHeight;
|
|
14
|
+
if (0 === initialViewportHeight) return;
|
|
15
|
+
const calculatedHeight = Math.max(0, initialViewportHeight - currentHeight);
|
|
16
|
+
calculatedHeight > 50 ? setKeyboardHeight(calculatedHeight) : setKeyboardHeight(0);
|
|
17
|
+
};
|
|
18
|
+
window.addEventListener('resize', handleViewportChange);
|
|
19
|
+
if (window.visualViewport) window.visualViewport.addEventListener('resize', handleViewportChange);
|
|
20
|
+
return ()=>{
|
|
21
|
+
window.removeEventListener('focusin', setInitialHeight);
|
|
22
|
+
window.removeEventListener('resize', handleViewportChange);
|
|
23
|
+
if (window.visualViewport) window.visualViewport.removeEventListener('resize', handleViewportChange);
|
|
24
|
+
};
|
|
25
|
+
}, [
|
|
26
|
+
initialViewportHeight
|
|
27
|
+
]);
|
|
28
|
+
return {
|
|
29
|
+
keyboardHeight,
|
|
30
|
+
isKeyboardVisible: keyboardHeight > 0
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const hooks_useKeyboard = useKeyboard;
|
|
34
|
+
export { hooks_useKeyboard as default };
|