@particle-network/ui-react 0.5.1-beta.17 → 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
|
|
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__*/
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@particle-network/ui-react",
|
|
3
|
-
"version": "0.5.1-beta.
|
|
3
|
+
"version": "0.5.1-beta.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@rslib/core": "^0.12.3",
|
|
39
39
|
"@types/react": "^19.1.10",
|
|
40
40
|
"react": "^19.1.0",
|
|
41
|
-
"@particle-network/
|
|
42
|
-
"@particle-network/
|
|
41
|
+
"@particle-network/eslint-config": "0.3.0",
|
|
42
|
+
"@particle-network/lintstaged-config": "0.1.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": ">=16.9.0",
|