@particle-network/ui-react 0.5.1-beta.1 → 0.5.1-beta.3
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 +36 -0
- package/dist/components/UXColorPicker/color-fields.d.ts +3 -0
- package/dist/components/UXColorPicker/color-fields.js +142 -0
- package/dist/components/UXColorPicker/color-input.d.ts +7 -0
- package/dist/components/UXColorPicker/color-input.js +12 -0
- package/dist/components/UXColorPicker/color-picker.d.ts +3 -0
- package/dist/components/UXColorPicker/color-picker.js +222 -0
- package/dist/components/UXColorPicker/index.d.ts +5 -0
- package/dist/components/UXColorPicker/index.js +3 -0
- package/dist/components/UXColorPicker/types.d.ts +40 -0
- package/dist/components/UXColorPicker/types.js +0 -0
- package/dist/components/UXColorPicker/utils.d.ts +7 -0
- package/dist/components/UXColorPicker/utils.js +6 -0
- package/dist/components/UXCopy/index.js +1 -1
- package/dist/components/UXEmpty/index.js +1 -1
- package/dist/components/UXSlider/use-slider.d.ts +1 -1
- package/dist/components/UXThemeSwitch/theme-item.js +1 -1
- package/dist/components/UXThemeSwitch/theme-switch.js +1 -1
- package/dist/components/UXThemeSwitch/use-color-scheme.js +11 -8
- package/dist/components/UXThemeSwitch/use-theme-color.js +11 -7
- package/dist/components/UXThemeSwitch/use-theme-store.js +2 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/package.json +5 -4
|
@@ -618,31 +618,67 @@ const button_theme_button = tv({
|
|
|
618
618
|
},
|
|
619
619
|
{
|
|
620
620
|
isIconOnly: true,
|
|
621
|
+
variant: [
|
|
622
|
+
'solid',
|
|
623
|
+
'flat',
|
|
624
|
+
'light',
|
|
625
|
+
'bordered'
|
|
626
|
+
],
|
|
621
627
|
size: 'xs',
|
|
622
628
|
class: 'min-w-5 w-5 h-5'
|
|
623
629
|
},
|
|
624
630
|
{
|
|
625
631
|
isIconOnly: true,
|
|
632
|
+
variant: [
|
|
633
|
+
'solid',
|
|
634
|
+
'flat',
|
|
635
|
+
'light',
|
|
636
|
+
'bordered'
|
|
637
|
+
],
|
|
626
638
|
size: 'sm',
|
|
627
639
|
class: 'min-w-6 w-6 h-6'
|
|
628
640
|
},
|
|
629
641
|
{
|
|
630
642
|
isIconOnly: true,
|
|
643
|
+
variant: [
|
|
644
|
+
'solid',
|
|
645
|
+
'flat',
|
|
646
|
+
'light',
|
|
647
|
+
'bordered'
|
|
648
|
+
],
|
|
631
649
|
size: 'md',
|
|
632
650
|
class: 'min-w-[30px] w-[30px] h-[30px]'
|
|
633
651
|
},
|
|
634
652
|
{
|
|
635
653
|
isIconOnly: true,
|
|
654
|
+
variant: [
|
|
655
|
+
'solid',
|
|
656
|
+
'flat',
|
|
657
|
+
'light',
|
|
658
|
+
'bordered'
|
|
659
|
+
],
|
|
636
660
|
size: 'lg',
|
|
637
661
|
class: 'min-w-9 w-9 h-9'
|
|
638
662
|
},
|
|
639
663
|
{
|
|
640
664
|
isIconOnly: true,
|
|
665
|
+
variant: [
|
|
666
|
+
'solid',
|
|
667
|
+
'flat',
|
|
668
|
+
'light',
|
|
669
|
+
'bordered'
|
|
670
|
+
],
|
|
641
671
|
size: 'xl',
|
|
642
672
|
class: 'min-w-11 w-11 h-11'
|
|
643
673
|
},
|
|
644
674
|
{
|
|
645
675
|
isIconOnly: true,
|
|
676
|
+
variant: [
|
|
677
|
+
'solid',
|
|
678
|
+
'flat',
|
|
679
|
+
'light',
|
|
680
|
+
'bordered'
|
|
681
|
+
],
|
|
646
682
|
size: 'auto',
|
|
647
683
|
class: ''
|
|
648
684
|
},
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useState } from "react";
|
|
4
|
+
import { Switch3Icon } from "@particle-network/icons/web";
|
|
5
|
+
import { Flex, VStack } from "../layout/index.js";
|
|
6
|
+
import { Text } from "../typography/Text.js";
|
|
7
|
+
import { UXButton } from "../UXButton/index.js";
|
|
8
|
+
import { ColorInput } from "./color-input.js";
|
|
9
|
+
const ColorFields = ({ value, defaultValue, onChange })=>{
|
|
10
|
+
const [format, setFormat] = useState('hex');
|
|
11
|
+
const handleFormatToggle = useCallback(()=>{
|
|
12
|
+
const formats = [
|
|
13
|
+
'hex',
|
|
14
|
+
'rgb',
|
|
15
|
+
'hsl'
|
|
16
|
+
];
|
|
17
|
+
const currentIndex = formats.indexOf(format);
|
|
18
|
+
const nextIndex = (currentIndex + 1) % formats.length;
|
|
19
|
+
setFormat(formats[nextIndex]);
|
|
20
|
+
}, [
|
|
21
|
+
format
|
|
22
|
+
]);
|
|
23
|
+
return /*#__PURE__*/ jsxs(Flex, {
|
|
24
|
+
gap: "md",
|
|
25
|
+
children: [
|
|
26
|
+
'hex' === format && /*#__PURE__*/ jsxs(VStack, {
|
|
27
|
+
gap: 1,
|
|
28
|
+
className: "flex-1",
|
|
29
|
+
children: [
|
|
30
|
+
/*#__PURE__*/ jsx(ColorInput, {
|
|
31
|
+
className: "w-full",
|
|
32
|
+
defaultValue: defaultValue,
|
|
33
|
+
value: value,
|
|
34
|
+
onChange: onChange
|
|
35
|
+
}),
|
|
36
|
+
/*#__PURE__*/ jsx(Text, {
|
|
37
|
+
color: "secondary",
|
|
38
|
+
align: "center",
|
|
39
|
+
children: "HEX"
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
}),
|
|
43
|
+
'rgb' === format && /*#__PURE__*/ jsxs("div", {
|
|
44
|
+
className: "grid flex-1 grid-cols-3 gap-1",
|
|
45
|
+
children: [
|
|
46
|
+
/*#__PURE__*/ jsx(ColorInput, {
|
|
47
|
+
channel: "red",
|
|
48
|
+
className: "w-full",
|
|
49
|
+
colorSpace: "rgb",
|
|
50
|
+
defaultValue: defaultValue,
|
|
51
|
+
value: value,
|
|
52
|
+
onChange: onChange
|
|
53
|
+
}),
|
|
54
|
+
/*#__PURE__*/ jsx(ColorInput, {
|
|
55
|
+
channel: "green",
|
|
56
|
+
className: "w-full",
|
|
57
|
+
colorSpace: "rgb",
|
|
58
|
+
defaultValue: defaultValue,
|
|
59
|
+
value: value,
|
|
60
|
+
onChange: onChange
|
|
61
|
+
}),
|
|
62
|
+
/*#__PURE__*/ jsx(ColorInput, {
|
|
63
|
+
channel: "blue",
|
|
64
|
+
className: "w-full",
|
|
65
|
+
colorSpace: "rgb",
|
|
66
|
+
defaultValue: defaultValue,
|
|
67
|
+
value: value,
|
|
68
|
+
onChange: onChange
|
|
69
|
+
}),
|
|
70
|
+
/*#__PURE__*/ jsx(Text, {
|
|
71
|
+
color: "secondary",
|
|
72
|
+
align: "center",
|
|
73
|
+
children: "R"
|
|
74
|
+
}),
|
|
75
|
+
/*#__PURE__*/ jsx(Text, {
|
|
76
|
+
color: "secondary",
|
|
77
|
+
align: "center",
|
|
78
|
+
children: "G"
|
|
79
|
+
}),
|
|
80
|
+
/*#__PURE__*/ jsx(Text, {
|
|
81
|
+
color: "secondary",
|
|
82
|
+
align: "center",
|
|
83
|
+
children: "B"
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
}),
|
|
87
|
+
'hsl' === format && /*#__PURE__*/ jsxs("div", {
|
|
88
|
+
className: "grid flex-1 grid-cols-3 gap-1",
|
|
89
|
+
children: [
|
|
90
|
+
/*#__PURE__*/ jsx(ColorInput, {
|
|
91
|
+
channel: "hue",
|
|
92
|
+
className: "w-full",
|
|
93
|
+
colorSpace: "hsl",
|
|
94
|
+
defaultValue: defaultValue,
|
|
95
|
+
value: value,
|
|
96
|
+
onChange: onChange
|
|
97
|
+
}),
|
|
98
|
+
/*#__PURE__*/ jsx(ColorInput, {
|
|
99
|
+
channel: "saturation",
|
|
100
|
+
className: "w-full",
|
|
101
|
+
colorSpace: "hsl",
|
|
102
|
+
defaultValue: defaultValue,
|
|
103
|
+
value: value,
|
|
104
|
+
onChange: onChange
|
|
105
|
+
}),
|
|
106
|
+
/*#__PURE__*/ jsx(ColorInput, {
|
|
107
|
+
channel: "lightness",
|
|
108
|
+
className: "w-full",
|
|
109
|
+
colorSpace: "hsl",
|
|
110
|
+
defaultValue: defaultValue,
|
|
111
|
+
value: value,
|
|
112
|
+
onChange: onChange
|
|
113
|
+
}),
|
|
114
|
+
/*#__PURE__*/ jsx(Text, {
|
|
115
|
+
color: "secondary",
|
|
116
|
+
align: "center",
|
|
117
|
+
children: "H"
|
|
118
|
+
}),
|
|
119
|
+
/*#__PURE__*/ jsx(Text, {
|
|
120
|
+
color: "secondary",
|
|
121
|
+
align: "center",
|
|
122
|
+
children: "S"
|
|
123
|
+
}),
|
|
124
|
+
/*#__PURE__*/ jsx(Text, {
|
|
125
|
+
color: "secondary",
|
|
126
|
+
align: "center",
|
|
127
|
+
children: "L"
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
}),
|
|
131
|
+
/*#__PURE__*/ jsx(UXButton, {
|
|
132
|
+
isIconOnly: true,
|
|
133
|
+
className: "shrink-0",
|
|
134
|
+
variant: "light",
|
|
135
|
+
onPress: handleFormatToggle,
|
|
136
|
+
children: /*#__PURE__*/ jsx(Switch3Icon, {})
|
|
137
|
+
})
|
|
138
|
+
]
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
ColorFields.displayName = 'ColorInputFields';
|
|
142
|
+
export { ColorFields };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { ColorField, Input } from "react-aria-components";
|
|
4
|
+
import { cn } from "@heroui/theme";
|
|
5
|
+
const inputClassName = 'w-full h-[30px] rounded-small border-none bg-background-200 px-2.5 text-tiny text-foreground focus:outline-none focus:ring-1 focus:ring-foreground text-center';
|
|
6
|
+
const ColorInput = (props)=>/*#__PURE__*/ jsx(ColorField, {
|
|
7
|
+
...props,
|
|
8
|
+
children: /*#__PURE__*/ jsx(Input, {
|
|
9
|
+
className: cn(inputClassName, props.inputClassName)
|
|
10
|
+
})
|
|
11
|
+
});
|
|
12
|
+
export { ColorInput };
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { ColorArea, ColorPicker, ColorSlider, ColorSwatch, ColorThumb, SliderTrack, parseColor } from "react-aria-components";
|
|
5
|
+
import { cn } from "@heroui/theme";
|
|
6
|
+
import ColorPickerIcon from "@particle-network/icons/web/ColorPickerIcon";
|
|
7
|
+
import RefreshCcwIcon from "@particle-network/icons/web/RefreshCcwIcon";
|
|
8
|
+
import { HStack } from "../layout/index.js";
|
|
9
|
+
import { UXButton } from "../UXButton/index.js";
|
|
10
|
+
import { UXPopover, UXPopoverContent, UXPopoverTrigger } from "../UXPopover/index.js";
|
|
11
|
+
import { ColorFields } from "./color-fields.js";
|
|
12
|
+
import { ColorInput } from "./color-input.js";
|
|
13
|
+
import { normalizeColor } from "./utils.js";
|
|
14
|
+
const UXColorPicker = ({ className, value, defaultValue, onChange, onChangeEnd, onValueChange, onValueChangeEnd, isDisabled, placement = 'bottom-start' })=>{
|
|
15
|
+
const isControlled = void 0 !== value;
|
|
16
|
+
const [pickerKey, setPickerKey] = useState(0);
|
|
17
|
+
const [isInputFocused, setIsInputFocused] = useState(false);
|
|
18
|
+
const getInitialColor = ()=>{
|
|
19
|
+
if (isControlled && value) return normalizeColor(value);
|
|
20
|
+
if (defaultValue) return normalizeColor(defaultValue);
|
|
21
|
+
return parseColor('#000000');
|
|
22
|
+
};
|
|
23
|
+
const initialColorRef = useRef(getInitialColor());
|
|
24
|
+
const [internalColor, setInternalColor] = useState(()=>{
|
|
25
|
+
if (isControlled) {
|
|
26
|
+
if (value) return normalizeColor(value);
|
|
27
|
+
}
|
|
28
|
+
if (defaultValue) return normalizeColor(defaultValue);
|
|
29
|
+
return parseColor('#000000');
|
|
30
|
+
});
|
|
31
|
+
const currentColor = useMemo(()=>{
|
|
32
|
+
if (isControlled && value) return normalizeColor(value);
|
|
33
|
+
return internalColor;
|
|
34
|
+
}, [
|
|
35
|
+
value,
|
|
36
|
+
internalColor,
|
|
37
|
+
isControlled
|
|
38
|
+
]);
|
|
39
|
+
useEffect(()=>{
|
|
40
|
+
const initialColor = getInitialColor();
|
|
41
|
+
initialColorRef.current = initialColor;
|
|
42
|
+
}, []);
|
|
43
|
+
useEffect(()=>{
|
|
44
|
+
if (!isControlled && defaultValue) {
|
|
45
|
+
const newColor = normalizeColor(defaultValue);
|
|
46
|
+
setInternalColor(newColor);
|
|
47
|
+
}
|
|
48
|
+
}, [
|
|
49
|
+
defaultValue,
|
|
50
|
+
isControlled
|
|
51
|
+
]);
|
|
52
|
+
useEffect(()=>{
|
|
53
|
+
if (isControlled && value) {
|
|
54
|
+
const newColor = normalizeColor(value);
|
|
55
|
+
setInternalColor(newColor);
|
|
56
|
+
}
|
|
57
|
+
}, [
|
|
58
|
+
value,
|
|
59
|
+
isControlled
|
|
60
|
+
]);
|
|
61
|
+
const handleChange = useCallback((color)=>{
|
|
62
|
+
if (color) {
|
|
63
|
+
setInternalColor(color);
|
|
64
|
+
onChange?.(color);
|
|
65
|
+
onValueChange?.(color.toString('hex'));
|
|
66
|
+
}
|
|
67
|
+
}, [
|
|
68
|
+
onChange,
|
|
69
|
+
onValueChange,
|
|
70
|
+
isControlled
|
|
71
|
+
]);
|
|
72
|
+
const handleEyedropper = useCallback(()=>{
|
|
73
|
+
if ('EyeDropper' in window) {
|
|
74
|
+
const eyeDropper = new window.EyeDropper();
|
|
75
|
+
eyeDropper.open().then((result)=>{
|
|
76
|
+
try {
|
|
77
|
+
const newColor = parseColor(result.sRGBHex);
|
|
78
|
+
if (newColor) handleChange(newColor);
|
|
79
|
+
} catch {}
|
|
80
|
+
}).catch(()=>{});
|
|
81
|
+
} else console.warn('EyeDropper API is not supported in this browser');
|
|
82
|
+
}, [
|
|
83
|
+
handleChange
|
|
84
|
+
]);
|
|
85
|
+
const handleChangeEnd = useCallback((color)=>{
|
|
86
|
+
if (color) {
|
|
87
|
+
onChangeEnd?.(color);
|
|
88
|
+
onValueChangeEnd?.(color.toString('hex'));
|
|
89
|
+
}
|
|
90
|
+
}, [
|
|
91
|
+
onChangeEnd,
|
|
92
|
+
onValueChangeEnd
|
|
93
|
+
]);
|
|
94
|
+
const hasChanged = useMemo(()=>{
|
|
95
|
+
const initialHex = initialColorRef.current.toString('hex');
|
|
96
|
+
const currentHex = currentColor.toString('hex');
|
|
97
|
+
return initialHex !== currentHex;
|
|
98
|
+
}, [
|
|
99
|
+
currentColor
|
|
100
|
+
]);
|
|
101
|
+
const handleReset = ()=>{
|
|
102
|
+
const resetColor = initialColorRef.current;
|
|
103
|
+
if (!isControlled) {
|
|
104
|
+
setInternalColor(resetColor);
|
|
105
|
+
setPickerKey((prev)=>prev + 1);
|
|
106
|
+
}
|
|
107
|
+
onChange?.(resetColor);
|
|
108
|
+
onValueChange?.(resetColor.toString('hex'));
|
|
109
|
+
onChangeEnd?.(resetColor);
|
|
110
|
+
onValueChangeEnd?.(resetColor.toString('hex'));
|
|
111
|
+
};
|
|
112
|
+
const handleColorFieldsChange = useCallback((color)=>{
|
|
113
|
+
if (!color) return;
|
|
114
|
+
handleChange(color);
|
|
115
|
+
handleChangeEnd(color);
|
|
116
|
+
}, [
|
|
117
|
+
handleChange,
|
|
118
|
+
handleChangeEnd
|
|
119
|
+
]);
|
|
120
|
+
return /*#__PURE__*/ jsx(ColorPicker, {
|
|
121
|
+
value: value,
|
|
122
|
+
defaultValue: !isControlled && pickerKey > 0 ? internalColor : defaultValue,
|
|
123
|
+
onChange: handleChange,
|
|
124
|
+
children: /*#__PURE__*/ jsxs(HStack, {
|
|
125
|
+
gap: 2,
|
|
126
|
+
className: cn('rounded-small bg-background-200 px-md h-[30px] w-[8.5rem]', isDisabled && 'opacity-disabled', isInputFocused && 'ring-foreground ring-1', className),
|
|
127
|
+
children: [
|
|
128
|
+
/*#__PURE__*/ jsxs(UXPopover, {
|
|
129
|
+
placement: placement,
|
|
130
|
+
children: [
|
|
131
|
+
/*#__PURE__*/ jsx(UXPopoverTrigger, {
|
|
132
|
+
children: /*#__PURE__*/ jsx(UXButton, {
|
|
133
|
+
size: "auto",
|
|
134
|
+
isDisabled: isDisabled,
|
|
135
|
+
children: /*#__PURE__*/ jsx(ColorSwatch, {
|
|
136
|
+
className: "h-4 w-4 rounded-sm border-none"
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
}),
|
|
140
|
+
/*#__PURE__*/ jsx(UXPopoverContent, {
|
|
141
|
+
className: "p-3",
|
|
142
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
143
|
+
className: cn('flex w-[240px] flex-col gap-3'),
|
|
144
|
+
children: [
|
|
145
|
+
/*#__PURE__*/ jsx(ColorArea, {
|
|
146
|
+
colorSpace: "hsb",
|
|
147
|
+
xChannel: "saturation",
|
|
148
|
+
yChannel: "brightness",
|
|
149
|
+
className: "aspect-square w-full overflow-hidden rounded-lg",
|
|
150
|
+
onChangeEnd: handleChangeEnd,
|
|
151
|
+
children: /*#__PURE__*/ jsx(ColorThumb, {
|
|
152
|
+
className: "border-1 h-2 w-2 rounded-full border-white shadow-[0_0_0_0.5px_black,inset_0_0_0_0.5px_black]"
|
|
153
|
+
})
|
|
154
|
+
}),
|
|
155
|
+
/*#__PURE__*/ jsxs(HStack, {
|
|
156
|
+
gap: "md",
|
|
157
|
+
items: "center",
|
|
158
|
+
children: [
|
|
159
|
+
'EyeDropper' in window && /*#__PURE__*/ jsx(UXButton, {
|
|
160
|
+
isIconOnly: true,
|
|
161
|
+
"aria-label": "Pick color from screen",
|
|
162
|
+
size: "sm",
|
|
163
|
+
variant: "light",
|
|
164
|
+
color: "secondary",
|
|
165
|
+
onPress: handleEyedropper,
|
|
166
|
+
children: /*#__PURE__*/ jsx(ColorPickerIcon, {})
|
|
167
|
+
}),
|
|
168
|
+
/*#__PURE__*/ jsx(ColorSwatch, {
|
|
169
|
+
className: "h-6 w-6 shrink-0 rounded-full"
|
|
170
|
+
}),
|
|
171
|
+
/*#__PURE__*/ jsx(ColorSlider, {
|
|
172
|
+
channel: "hue",
|
|
173
|
+
className: "min-w-0 flex-1",
|
|
174
|
+
colorSpace: "hsl",
|
|
175
|
+
orientation: "horizontal",
|
|
176
|
+
onChangeEnd: handleChangeEnd,
|
|
177
|
+
children: /*#__PURE__*/ jsx(SliderTrack, {
|
|
178
|
+
className: "h-3 rounded-full",
|
|
179
|
+
children: /*#__PURE__*/ jsx(ColorThumb, {
|
|
180
|
+
className: "top-[50%] z-10 h-4 w-4 rounded-full border-2 border-white"
|
|
181
|
+
})
|
|
182
|
+
})
|
|
183
|
+
})
|
|
184
|
+
]
|
|
185
|
+
}),
|
|
186
|
+
/*#__PURE__*/ jsx(ColorFields, {
|
|
187
|
+
defaultValue: !isControlled && pickerKey > 0 ? internalColor : defaultValue,
|
|
188
|
+
value: value,
|
|
189
|
+
onChange: handleColorFieldsChange
|
|
190
|
+
})
|
|
191
|
+
]
|
|
192
|
+
})
|
|
193
|
+
})
|
|
194
|
+
]
|
|
195
|
+
}),
|
|
196
|
+
/*#__PURE__*/ jsx(ColorInput, {
|
|
197
|
+
isDisabled: isDisabled,
|
|
198
|
+
inputClassName: "focus:ring-0 px-0 text-left flex-1",
|
|
199
|
+
value: value,
|
|
200
|
+
defaultValue: !isControlled && pickerKey > 0 ? internalColor : defaultValue,
|
|
201
|
+
onChange: (color)=>handleChange(color),
|
|
202
|
+
onFocus: ()=>setIsInputFocused(true),
|
|
203
|
+
onBlur: ()=>setIsInputFocused(false)
|
|
204
|
+
}),
|
|
205
|
+
hasChanged ? /*#__PURE__*/ jsx(UXButton, {
|
|
206
|
+
isIconOnly: true,
|
|
207
|
+
"aria-label": "Reset color",
|
|
208
|
+
isDisabled: isDisabled,
|
|
209
|
+
size: "sm",
|
|
210
|
+
variant: "light",
|
|
211
|
+
color: "secondary",
|
|
212
|
+
onPress: handleReset,
|
|
213
|
+
children: /*#__PURE__*/ jsx(RefreshCcwIcon, {})
|
|
214
|
+
}) : /*#__PURE__*/ jsx("div", {
|
|
215
|
+
className: "size-4 shrink-0"
|
|
216
|
+
})
|
|
217
|
+
]
|
|
218
|
+
})
|
|
219
|
+
}, isControlled ? void 0 : pickerKey);
|
|
220
|
+
};
|
|
221
|
+
UXColorPicker.displayName = 'UXColorPicker';
|
|
222
|
+
export { UXColorPicker };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Color } from 'react-stately';
|
|
2
|
+
import type { UXPopoverProps } from '../UXPopover';
|
|
3
|
+
export interface UXColorPickerProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
/**
|
|
6
|
+
* 颜色值(受控)
|
|
7
|
+
*/
|
|
8
|
+
value?: string | Color;
|
|
9
|
+
/**
|
|
10
|
+
* 默认颜色值(非受控)
|
|
11
|
+
*/
|
|
12
|
+
defaultValue?: string | Color;
|
|
13
|
+
/**
|
|
14
|
+
* 颜色变化回调(拖拽时调用)
|
|
15
|
+
*/
|
|
16
|
+
onChange?: (color: Color) => void;
|
|
17
|
+
/**
|
|
18
|
+
* 颜色变化结束回调(释放时调用)
|
|
19
|
+
*/
|
|
20
|
+
onChangeEnd?: (color: Color) => void;
|
|
21
|
+
/**
|
|
22
|
+
* HEX 格式颜色变化回调(拖拽时调用)
|
|
23
|
+
*/
|
|
24
|
+
onValueChange?: (color: string) => void;
|
|
25
|
+
/**
|
|
26
|
+
* HEX 格式颜色变化结束回调(释放时调用)
|
|
27
|
+
*/
|
|
28
|
+
onValueChangeEnd?: (color: string) => void;
|
|
29
|
+
/**
|
|
30
|
+
* 是否禁用
|
|
31
|
+
*/
|
|
32
|
+
isDisabled?: boolean;
|
|
33
|
+
placement?: UXPopoverProps['placement'];
|
|
34
|
+
}
|
|
35
|
+
export interface ColorFieldsProps extends Pick<UXColorPickerProps, 'value' | 'defaultValue'> {
|
|
36
|
+
/**
|
|
37
|
+
* 颜色变化回调
|
|
38
|
+
*/
|
|
39
|
+
onChange?: (color: Color | null) => void;
|
|
40
|
+
}
|
|
File without changes
|
|
@@ -39,7 +39,7 @@ const Address = ({ children, copyText = children, tooltipContent = children, sta
|
|
|
39
39
|
toastText: `${i18n.copy.address}${children}`,
|
|
40
40
|
...props,
|
|
41
41
|
children: /*#__PURE__*/ jsxs("div", {
|
|
42
|
-
className: "flex items-center gap-1 hover:opacity-70
|
|
42
|
+
className: "text-body2 flex items-center gap-1 font-medium hover:opacity-70",
|
|
43
43
|
children: [
|
|
44
44
|
startContent,
|
|
45
45
|
shortAddress(children),
|
|
@@ -134,7 +134,7 @@ interface Props extends HTMLHeroUIProps {
|
|
|
134
134
|
export type UseSliderProps = Omit<Props, keyof ValueBase<SliderValue>> & AriaSliderProps & SliderVariantProps;
|
|
135
135
|
export declare function useSlider(originalProps: UseSliderProps): {
|
|
136
136
|
Component: import("@heroui/system-rsc").As<any>;
|
|
137
|
-
state: import("
|
|
137
|
+
state: import("react-stately").SliderState;
|
|
138
138
|
value: any;
|
|
139
139
|
domRef: React.RefObject<HTMLElement>;
|
|
140
140
|
label: React.ReactNode;
|
|
@@ -13,7 +13,7 @@ const ThemeItem = ({ id, zhName, enName, isSelected, onClick })=>{
|
|
|
13
13
|
onClick: onClick,
|
|
14
14
|
children: [
|
|
15
15
|
/*#__PURE__*/ jsx("div", {
|
|
16
|
-
className: cn('rounded-medium border-2
|
|
16
|
+
className: cn('rounded-medium border-2 transition-all duration-300 hover:scale-105', 'h-[59px] w-[100px] md:h-[71px] md:w-[120px]', isSelected ? 'border-primary' : 'border-transparent'),
|
|
17
17
|
children: /*#__PURE__*/ jsxs("svg", {
|
|
18
18
|
xmlns: "http://www.w3.org/2000/svg",
|
|
19
19
|
viewBox: "0 0 120 71",
|
|
@@ -137,7 +137,7 @@ const UXThemeSwitchModal = ({ as = 'modal', omitThemes = [], backdrop, isOpen, o
|
|
|
137
137
|
placement: "bottom",
|
|
138
138
|
children: /*#__PURE__*/ jsxs(Text, {
|
|
139
139
|
color: "secondary",
|
|
140
|
-
className: "flex-1
|
|
140
|
+
className: "flex-1 cursor-pointer truncate",
|
|
141
141
|
children: [
|
|
142
142
|
example.title,
|
|
143
143
|
": ",
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useThemeStore } from "./use-theme-store.js";
|
|
2
3
|
const useColorScheme = ()=>{
|
|
3
|
-
const {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const { colorScheme } = useThemeStore((state)=>state.theme);
|
|
5
|
+
const scheme = useMemo(()=>({
|
|
6
|
+
colorScheme,
|
|
7
|
+
isDark: 'dark' === colorScheme,
|
|
8
|
+
isLight: 'light' === colorScheme
|
|
9
|
+
}), [
|
|
10
|
+
colorScheme
|
|
11
|
+
]);
|
|
12
|
+
return scheme;
|
|
10
13
|
};
|
|
11
14
|
export { useColorScheme };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useThemeStore } from "./use-theme-store.js";
|
|
2
3
|
const useThemeColor = ()=>{
|
|
3
|
-
const {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const { colorVariables } = useThemeStore((state)=>state.theme);
|
|
5
|
+
const themeColor = useMemo(()=>({
|
|
6
|
+
...colorVariables,
|
|
7
|
+
transparent: 'transparent',
|
|
8
|
+
white: '#FFFFFF'
|
|
9
|
+
}), [
|
|
10
|
+
colorVariables
|
|
11
|
+
]);
|
|
12
|
+
return themeColor;
|
|
9
13
|
};
|
|
10
14
|
export { useThemeColor };
|
|
@@ -19,7 +19,8 @@ const useThemeStore = create()(persist((set)=>({
|
|
|
19
19
|
fontName
|
|
20
20
|
})
|
|
21
21
|
}), {
|
|
22
|
-
name: 'ux-theme
|
|
22
|
+
name: 'ux-preferences-theme',
|
|
23
|
+
version: 1,
|
|
23
24
|
storage: createJSONStorage(()=>'undefined' != typeof window ? window.localStorage : {}),
|
|
24
25
|
partialize: (state)=>({
|
|
25
26
|
theme: state.theme,
|
package/dist/components/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./UXButton/index.js";
|
|
|
6
6
|
export * from "./UXCalendar/index.js";
|
|
7
7
|
export * from "./UXCheckbox/index.js";
|
|
8
8
|
export * from "./UXChip/index.js";
|
|
9
|
+
export * from "./UXColorPicker/index.js";
|
|
9
10
|
export * from "./UXCopy/index.js";
|
|
10
11
|
export * from "./UXDatePicker/index.js";
|
|
11
12
|
export * from "./UXDateRangePicker/index.js";
|
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.3",
|
|
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",
|
|
@@ -48,8 +48,9 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"ahooks": "^3.9.4",
|
|
50
50
|
"copy-to-clipboard": "^3.3.3",
|
|
51
|
+
"react-aria-components": "^1.14.0",
|
|
51
52
|
"zustand": "^5.0.8",
|
|
52
|
-
"@particle-network/icons": "0.5.0",
|
|
53
|
+
"@particle-network/icons": "0.5.1-beta.0",
|
|
53
54
|
"@particle-network/ui-shared": "0.4.0"
|
|
54
55
|
},
|
|
55
56
|
"scripts": {
|