@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.
@@ -15,7 +15,7 @@ const button_theme_button = tv({
15
15
  'whitespace-nowrap',
16
16
  'min-w-max',
17
17
  'font-normal',
18
- 'subpixel-antialiased',
18
+ 'antialiased',
19
19
  'overflow-hidden',
20
20
  'tap-highlight-transparent',
21
21
  'transform-gpu data-[pressed=true]:scale-[0.97]',
@@ -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
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { type IconProps } from '../../icons';
2
+ import { type IconProps } from '@/icons';
3
3
  import { type VStackProps } from '../layout';
4
4
  export interface UXEmptyProps extends VStackProps {
5
5
  iconProps?: IconProps;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { type UXTooltipProps } from '..';
2
+ import { type UXTooltipProps } from '@/components';
3
3
  export type UXHintProps = UXTooltipProps & {
4
4
  triggerType?: 'hover' | 'click';
5
5
  buttonClassName?: string;
@@ -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-[calc(100vh-48px)] max-md:m-0 max-md:rounded-b-none',
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 ? /*#__PURE__*/ jsx(ModalHeader, {
59
+ title && /*#__PURE__*/ jsx(ModalHeader, {
57
60
  className: "capitalize",
58
61
  children: title
59
- }) : null,
62
+ }),
60
63
  /*#__PURE__*/ jsx(ModalBody, {
61
64
  children: children
62
65
  }),
63
- footer ? /*#__PURE__*/ jsx(ModalFooter, {
66
+ footer && /*#__PURE__*/ jsx(ModalFooter, {
64
67
  children: footer
65
- }) : null,
66
- tip ? /*#__PURE__*/ jsx(ModalFooter, {
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
- }) : null
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@particle-network/ui-react",
3
- "version": "0.3.0",
3
+ "version": "0.3.2-beta.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {