@particle-network/ui-react 0.5.1-beta.16 → 0.5.1-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.
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
4
4
  import { ColorArea, ColorPicker, ColorSlider, ColorSwatch, ColorThumb, SliderTrack, parseColor } from "react-aria-components";
5
5
  import ColorPickerIcon from "@particle-network/icons/web/ColorPickerIcon";
@@ -12,7 +12,7 @@ import { useThemeColor } from "../UXThemeSwitch/index.js";
12
12
  import { ColorFields } from "./color-fields.js";
13
13
  import { ColorInput } from "./color-input.js";
14
14
  import { normalizeColor } from "./utils.js";
15
- const UXColorPicker = ({ className, isDisabled, placement = 'bottom-start', value, defaultValue, onChange, onChangeEnd, onValueChange, onValueChangeEnd, isChanged, onReset })=>{
15
+ const UXColorPicker = ({ className, isDisabled, isIconOnly, placement = 'bottom-start', value, defaultValue, onChange, onChangeEnd, onValueChange, onValueChangeEnd, isChanged, onReset })=>{
16
16
  const colors = useThemeColor();
17
17
  const isControlled = void 0 !== value;
18
18
  const [pickerKey, setPickerKey] = useState(0);
@@ -134,7 +134,7 @@ const UXColorPicker = ({ className, isDisabled, placement = 'bottom-start', valu
134
134
  onChange: handleChange,
135
135
  children: /*#__PURE__*/ jsxs(HStack, {
136
136
  gap: 2,
137
- className: cn('rounded-small bg-background-200 px-md h-[30px] w-[8.5rem]', isDisabled && 'opacity-disabled', isInputFocused && 'ring-foreground ring-1', className),
137
+ className: cn(!isIconOnly && 'px-md rounded-small bg-background-200 h-[30px] w-[8.5rem]', isDisabled && 'opacity-disabled', isInputFocused && 'ring-foreground ring-1', className),
138
138
  children: [
139
139
  /*#__PURE__*/ jsxs(UXPopover, {
140
140
  placement: placement,
@@ -207,26 +207,30 @@ const UXColorPicker = ({ className, isDisabled, placement = 'bottom-start', valu
207
207
  })
208
208
  ]
209
209
  }),
210
- /*#__PURE__*/ jsx(ColorInput, {
211
- isDisabled: isDisabled,
212
- inputClassName: "focus:ring-0 px-0 text-left flex-1 relative bg-transparent",
213
- value: currentColor,
214
- defaultValue: !isControlled && pickerKey > 0 ? internalColor : defaultValue,
215
- onChange: handleColorFieldsChange,
216
- onFocus: ()=>setIsInputFocused(true),
217
- onBlur: ()=>setIsInputFocused(false)
218
- }),
219
- hasChanged ? /*#__PURE__*/ jsx(UXButton, {
220
- isIconOnly: true,
221
- "aria-label": "Reset color",
222
- isDisabled: isDisabled,
223
- size: "sm",
224
- variant: "light",
225
- color: "secondary",
226
- onPress: handleReset,
227
- children: /*#__PURE__*/ jsx(RefreshCcwIcon, {})
228
- }) : /*#__PURE__*/ jsx("div", {
229
- className: "size-4 shrink-0"
210
+ !isIconOnly && /*#__PURE__*/ jsxs(Fragment, {
211
+ children: [
212
+ /*#__PURE__*/ jsx(ColorInput, {
213
+ isDisabled: isDisabled,
214
+ inputClassName: "focus:ring-0 px-0 text-left flex-1 relative bg-transparent",
215
+ value: currentColor,
216
+ defaultValue: !isControlled && pickerKey > 0 ? internalColor : defaultValue,
217
+ onChange: handleColorFieldsChange,
218
+ onFocus: ()=>setIsInputFocused(true),
219
+ onBlur: ()=>setIsInputFocused(false)
220
+ }),
221
+ hasChanged ? /*#__PURE__*/ jsx(UXButton, {
222
+ isIconOnly: true,
223
+ "aria-label": "Reset color",
224
+ isDisabled: isDisabled,
225
+ size: "sm",
226
+ variant: "light",
227
+ color: "secondary",
228
+ onPress: handleReset,
229
+ children: /*#__PURE__*/ jsx(RefreshCcwIcon, {})
230
+ }) : /*#__PURE__*/ jsx("div", {
231
+ className: "size-4 shrink-0"
232
+ })
233
+ ]
230
234
  })
231
235
  ]
232
236
  })
@@ -42,6 +42,10 @@ export interface UXColorPickerProps {
42
42
  * Popover 位置
43
43
  */
44
44
  placement?: UXPopoverProps['placement'];
45
+ /**
46
+ * 是否只显示图标
47
+ */
48
+ isIconOnly?: boolean;
45
49
  }
46
50
  export interface ColorFieldsProps extends Pick<UXColorPickerProps, 'value' | 'defaultValue'> {
47
51
  /**
@@ -34,18 +34,24 @@ const getIcon = (type)=>{
34
34
  };
35
35
  const show = (props)=>{
36
36
  const { type = 'info', hideCloseButton, icon, variant, classNames, title, description, ...toastProps } = props ?? {};
37
- const { base, description: descriptionClassName, icon: iconClassName, loadingComponent, content, closeButton, ...restClassNames } = classNames ?? {};
37
+ const { base, title: titleClassName, description: descriptionClassName, icon: iconClassName, loadingComponent, content, closeButton, ...restClassNames } = classNames ?? {};
38
38
  return addToast({
39
39
  classNames: {
40
40
  base: [
41
- 'bg-cursor rounded-xl px-3.5 py-3 shadow-none border-none !w-fit max-w-[90vw] md:max-w-[400px] m-0',
41
+ 'dark:bg-cursor bg-white rounded-xl px-3.5 shadow-none min-h-11 border-none !w-fit max-w-[90vw] md:max-w-[400px] m-0',
42
42
  !hideCloseButton && 'pr-12',
43
43
  'flat' === variant && 'success' === type && 'bg-[#0E3728]',
44
44
  'flat' === variant && 'error' === type && 'bg-[#501D1D]',
45
45
  base
46
46
  ],
47
+ title: [
48
+ 'text-cursor-foreground text-xs font-medium leading-4 !whitespace-normal me-0 pt-xs line-clamp-2',
49
+ hasLongWord(title) && 'break-all',
50
+ 'flat' === variant && 'text-white',
51
+ titleClassName
52
+ ],
47
53
  description: [
48
- 'text-cursor-foreground text-xs font-medium me-0 leading-4 line-clamp-4',
54
+ 'text-secondary !text-body3 me-0 leading-4',
49
55
  'flat' === variant && 'text-white',
50
56
  hasLongWord(description) && 'break-all',
51
57
  descriptionClassName
@@ -90,22 +96,22 @@ const show = (props)=>{
90
96
  const toast = {
91
97
  info: (message, props)=>show({
92
98
  type: 'info',
93
- description: message,
99
+ title: message,
94
100
  ...props
95
101
  }),
96
102
  success: (message, props)=>show({
97
103
  type: 'success',
98
- description: message,
104
+ title: message,
99
105
  ...props
100
106
  }),
101
107
  error: (message, props)=>show({
102
108
  type: 'error',
103
- description: message,
109
+ title: message,
104
110
  ...props
105
111
  }),
106
112
  loading: (message, props)=>show({
107
113
  type: 'loading',
108
- description: message,
114
+ title: message,
109
115
  ...props
110
116
  }),
111
117
  show,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@particle-network/ui-react",
3
- "version": "0.5.1-beta.16",
3
+ "version": "0.5.1-beta.18",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -52,8 +52,8 @@
52
52
  "react-aria-components": "^1.14.0",
53
53
  "values.js": "^2.1.1",
54
54
  "zustand": "^5.0.8",
55
- "@particle-network/icons": "0.5.1-beta.6",
56
- "@particle-network/ui-shared": "0.4.1-beta.5"
55
+ "@particle-network/ui-shared": "0.4.1-beta.5",
56
+ "@particle-network/icons": "0.5.1-beta.6"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "rslib build",