@particle-network/ui-react 0.5.1-beta.8 → 0.6.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/ProgressWrapper/index.js +2 -3
- package/dist/components/UXAutocomplete/index.js +1 -2
- package/dist/components/UXCheckbox/checkbox.extend.js +15 -12
- package/dist/components/UXColorPicker/color-input.js +1 -1
- package/dist/components/UXColorPicker/color-picker.js +43 -31
- package/dist/components/UXColorPicker/types.d.ts +4 -0
- package/dist/components/UXCopy/index.js +1 -1
- package/dist/components/UXEmpty/index.js +1 -1
- package/dist/components/UXHint/index.js +2 -2
- package/dist/components/UXModal/index.d.ts +1 -1
- package/dist/components/UXRangeInput/index.d.ts +42 -0
- package/dist/components/UXRangeInput/index.js +94 -0
- package/dist/components/UXSlider/use-slider.js +1 -1
- package/dist/components/UXSpinner/spinner.js +1 -1
- package/dist/components/UXSwitch/switch.extend.js +6 -6
- package/dist/components/UXThemeSwitch/custom-theme-config.d.ts +4 -1
- package/dist/components/UXThemeSwitch/custom-theme-config.js +8 -7
- package/dist/components/UXThemeSwitch/index.d.ts +2 -2
- package/dist/components/UXThemeSwitch/index.js +2 -2
- package/dist/components/UXThemeSwitch/theme-item.js +6 -7
- package/dist/components/UXThemeSwitch/theme-switch.d.ts +8 -1
- package/dist/components/UXThemeSwitch/theme-switch.js +12 -18
- package/dist/components/UXThemeSwitch/use-theme.d.ts +2 -1
- package/dist/components/UXThemeSwitch/use-theme.js +4 -9
- package/dist/components/UXThemeSwitch/utils.js +52 -15
- package/dist/components/UXToast/index.d.ts +1 -1
- package/dist/components/UXToast/index.js +22 -10
- package/dist/components/UXTooltip/index.js +4 -12
- package/dist/components/WrapText/index.d.ts +6 -0
- package/dist/components/WrapText/index.js +15 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/layout/Box/box-theme.d.ts +36 -18
- package/dist/components/layout/Box/box-theme.js +25 -19
- package/dist/components/layout/Box/box.js +14 -5
- package/dist/components/layout/Square.js +2 -4
- package/dist/components/typography/Text.js +18 -8
- package/dist/components/typography/Text.type.d.ts +1 -0
- package/dist/hooks/useI18n.d.ts +18 -10
- package/dist/hooks/useI18n.js +18 -10
- package/dist/utils/cn.d.ts +2 -0
- package/dist/utils/cn.js +250 -0
- package/dist/utils/common.d.ts +4 -0
- package/dist/utils/common.js +13 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +2 -1
- package/package.json +5 -5
- package/tailwind-preset.js +18 -18
- package/dist/components/UXThemeSwitch/use-color-scheme.d.ts +0 -5
- package/dist/components/UXThemeSwitch/use-color-scheme.js +0 -14
- package/dist/components/UXThemeSwitch/use-theme-color.d.ts +0 -1
- package/dist/components/UXThemeSwitch/use-theme-color.js +0 -6
- package/dist/components/UXThemeSwitch/use-theme-store.d.ts +0 -46
- package/dist/components/UXThemeSwitch/use-theme-store.js +0 -36
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo, useRef } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import { radiusMap } from "@particle-network/ui-shared";
|
|
4
|
+
import { radiusMap, useThemeColor } from "@particle-network/ui-shared";
|
|
6
5
|
import { useSize } from "ahooks";
|
|
6
|
+
import { cn } from "../../utils/index.js";
|
|
7
7
|
import { Center } from "../layout/index.js";
|
|
8
|
-
import { useThemeColor } from "../UXThemeSwitch/use-theme-color.js";
|
|
9
8
|
const ProgressWrapper = ({ className, value = 0, width, height, radius = 'sm', strokeWidth = 1, color = 'primary', children, svgClassName, ...restProps })=>{
|
|
10
9
|
const uxColors = useThemeColor();
|
|
11
10
|
const autoLayout = !width && !height;
|
|
@@ -3,10 +3,9 @@ import "react";
|
|
|
3
3
|
import { Autocomplete, AutocompleteItem, AutocompleteSection } from "@heroui/autocomplete";
|
|
4
4
|
import ChevronDownIcon from "@particle-network/icons/web/ChevronDownIcon";
|
|
5
5
|
const UXAutocomplete = (props)=>{
|
|
6
|
-
const {
|
|
6
|
+
const { classNames = {}, radius = 'sm', labelPlacement = 'outside-top', ...restProps } = props;
|
|
7
7
|
const { base, popoverContent, selectorButton, endContentWrapper, clearButton, listboxWrapper } = classNames;
|
|
8
8
|
return /*#__PURE__*/ jsx(Autocomplete, {
|
|
9
|
-
fullWidth: fullWidth,
|
|
10
9
|
classNames: {
|
|
11
10
|
base: [
|
|
12
11
|
'ux-base',
|
|
@@ -27,34 +27,37 @@ const ExtendedCheckbox = extendVariants(Checkbox, {
|
|
|
27
27
|
},
|
|
28
28
|
size: {
|
|
29
29
|
sm: {
|
|
30
|
+
base: 'gap-1.5',
|
|
30
31
|
wrapper: [
|
|
31
32
|
'w-3.5 h-3.5 me-0',
|
|
32
33
|
'rounded-[calc(theme(borderRadius.medium)*0.2)]',
|
|
33
34
|
'before:rounded-[calc(theme(borderRadius.medium)*0.2)] before:border-secondary before:border-1',
|
|
34
35
|
'after:rounded-[calc(theme(borderRadius.medium)*0.2)]'
|
|
35
36
|
],
|
|
36
|
-
label: '!text-
|
|
37
|
-
icon: 'h-2
|
|
37
|
+
label: '!text-body2 font-medium',
|
|
38
|
+
icon: 'h-2'
|
|
38
39
|
},
|
|
39
40
|
md: {
|
|
41
|
+
base: 'gap-2',
|
|
40
42
|
wrapper: [
|
|
41
43
|
'w-4 h-4 me-0',
|
|
42
|
-
'rounded-[calc(theme(borderRadius.medium)*0.
|
|
43
|
-
'before:rounded-[calc(theme(borderRadius.medium)*0.
|
|
44
|
-
'after:rounded-[calc(theme(borderRadius.medium)*0.
|
|
44
|
+
'rounded-[calc(theme(borderRadius.medium)*0.3)]',
|
|
45
|
+
'before:rounded-[calc(theme(borderRadius.medium)*0.3)] before:border-secondary before:border-1.5',
|
|
46
|
+
'after:rounded-[calc(theme(borderRadius.medium)*0.3)]'
|
|
45
47
|
],
|
|
46
48
|
label: '!text-body2 font-medium',
|
|
47
|
-
icon: 'h-
|
|
49
|
+
icon: 'h-2.5'
|
|
48
50
|
},
|
|
49
51
|
lg: {
|
|
52
|
+
base: 'gap-2',
|
|
50
53
|
wrapper: [
|
|
51
54
|
'w-[18px] h-[18px] me-0',
|
|
52
|
-
'rounded-[calc(theme(borderRadius.medium)*0.
|
|
53
|
-
'before:rounded-[calc(theme(borderRadius.medium)*0.
|
|
54
|
-
'after:rounded-[calc(theme(borderRadius.medium)*0.
|
|
55
|
+
'rounded-[calc(theme(borderRadius.medium)*0.4)]',
|
|
56
|
+
'before:rounded-[calc(theme(borderRadius.medium)*0.4)] before:border-secondary before:border-1.5',
|
|
57
|
+
'after:rounded-[calc(theme(borderRadius.medium)*0.4)]'
|
|
55
58
|
],
|
|
56
59
|
label: '!text-body1 font-medium',
|
|
57
|
-
icon: 'h-3
|
|
60
|
+
icon: 'h-3'
|
|
58
61
|
}
|
|
59
62
|
},
|
|
60
63
|
radius: {
|
|
@@ -144,10 +147,10 @@ const ExtendedCheckbox = extendVariants(Checkbox, {
|
|
|
144
147
|
},
|
|
145
148
|
labelPlacement: {
|
|
146
149
|
left: {
|
|
147
|
-
base: 'flex-row-reverse
|
|
150
|
+
base: 'flex-row-reverse'
|
|
148
151
|
},
|
|
149
152
|
right: {
|
|
150
|
-
base: 'flex-row
|
|
153
|
+
base: 'flex-row'
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
156
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import { ColorField, Input } from "react-aria-components";
|
|
4
|
-
import { cn } from "
|
|
4
|
+
import { cn } from "../../utils/index.js";
|
|
5
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
6
|
const ColorInput = (props)=>/*#__PURE__*/ jsx(ColorField, {
|
|
7
7
|
...props,
|
|
@@ -1,10 +1,10 @@
|
|
|
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
|
-
import { cn } from "@heroui/theme";
|
|
6
5
|
import ColorPickerIcon from "@particle-network/icons/web/ColorPickerIcon";
|
|
7
6
|
import RefreshCcwIcon from "@particle-network/icons/web/RefreshCcwIcon";
|
|
7
|
+
import { cn } from "../../utils/index.js";
|
|
8
8
|
import { HStack } from "../layout/index.js";
|
|
9
9
|
import { UXButton } from "../UXButton/index.js";
|
|
10
10
|
import { UXPopover, UXPopoverContent, UXPopoverTrigger } from "../UXPopover/index.js";
|
|
@@ -12,11 +12,12 @@ 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 })=>{
|
|
16
|
-
const
|
|
15
|
+
const UXColorPicker = ({ className, isDisabled, isIconOnly, placement = 'bottom-start', value, defaultValue, onChange, onChangeEnd, onValueChange, onValueChangeEnd, isChanged, onReset })=>{
|
|
16
|
+
const colors = useThemeColor();
|
|
17
17
|
const isControlled = void 0 !== value;
|
|
18
18
|
const [pickerKey, setPickerKey] = useState(0);
|
|
19
19
|
const [isInputFocused, setIsInputFocused] = useState(false);
|
|
20
|
+
const [isInteracting, setIsInteracting] = useState(false);
|
|
20
21
|
const getInitialColor = ()=>{
|
|
21
22
|
if (isControlled && value) return normalizeColor(value);
|
|
22
23
|
if (defaultValue) return normalizeColor(defaultValue);
|
|
@@ -31,12 +32,13 @@ const UXColorPicker = ({ className, isDisabled, placement = 'bottom-start', valu
|
|
|
31
32
|
return parseColor('#000000');
|
|
32
33
|
});
|
|
33
34
|
const currentColor = useMemo(()=>{
|
|
34
|
-
if (isControlled && value) return normalizeColor(value);
|
|
35
|
+
if (isControlled && value && !isInteracting) return normalizeColor(value);
|
|
35
36
|
return internalColor;
|
|
36
37
|
}, [
|
|
37
38
|
value,
|
|
38
39
|
internalColor,
|
|
39
|
-
isControlled
|
|
40
|
+
isControlled,
|
|
41
|
+
isInteracting
|
|
40
42
|
]);
|
|
41
43
|
useEffect(()=>{
|
|
42
44
|
const initialColor = getInitialColor();
|
|
@@ -62,7 +64,10 @@ const UXColorPicker = ({ className, isDisabled, placement = 'bottom-start', valu
|
|
|
62
64
|
]);
|
|
63
65
|
const handleChange = useCallback((color)=>{
|
|
64
66
|
if (color) {
|
|
65
|
-
|
|
67
|
+
if (isControlled) {
|
|
68
|
+
setInternalColor(color);
|
|
69
|
+
setIsInteracting(true);
|
|
70
|
+
} else setInternalColor(color);
|
|
66
71
|
onChange?.(color);
|
|
67
72
|
onValueChange?.(color.toString('hex'));
|
|
68
73
|
}
|
|
@@ -86,6 +91,7 @@ const UXColorPicker = ({ className, isDisabled, placement = 'bottom-start', valu
|
|
|
86
91
|
]);
|
|
87
92
|
const handleChangeEnd = useCallback((color)=>{
|
|
88
93
|
if (color) {
|
|
94
|
+
setIsInteracting(false);
|
|
89
95
|
onChangeEnd?.(color);
|
|
90
96
|
onValueChangeEnd?.(color.toString('hex'));
|
|
91
97
|
}
|
|
@@ -123,12 +129,12 @@ const UXColorPicker = ({ className, isDisabled, placement = 'bottom-start', valu
|
|
|
123
129
|
handleChangeEnd
|
|
124
130
|
]);
|
|
125
131
|
return /*#__PURE__*/ jsx(ColorPicker, {
|
|
126
|
-
value:
|
|
132
|
+
value: currentColor,
|
|
127
133
|
defaultValue: !isControlled && pickerKey > 0 ? internalColor : defaultValue,
|
|
128
134
|
onChange: handleChange,
|
|
129
135
|
children: /*#__PURE__*/ jsxs(HStack, {
|
|
130
136
|
gap: 2,
|
|
131
|
-
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),
|
|
132
138
|
children: [
|
|
133
139
|
/*#__PURE__*/ jsxs(UXPopover, {
|
|
134
140
|
placement: placement,
|
|
@@ -139,7 +145,7 @@ const UXColorPicker = ({ className, isDisabled, placement = 'bottom-start', valu
|
|
|
139
145
|
size: "auto",
|
|
140
146
|
isDisabled: isDisabled,
|
|
141
147
|
children: /*#__PURE__*/ jsx(ColorSwatch, {
|
|
142
|
-
className: cn('h-4 w-4 rounded-[4px]', internalColor.toString('hex') === bg200 && 'border-foreground/10 border')
|
|
148
|
+
className: cn('h-4 w-4 rounded-[4px]', internalColor.toString('hex') === colors.bg200 && 'border-foreground/10 border')
|
|
143
149
|
})
|
|
144
150
|
})
|
|
145
151
|
}),
|
|
@@ -153,6 +159,7 @@ const UXColorPicker = ({ className, isDisabled, placement = 'bottom-start', valu
|
|
|
153
159
|
xChannel: "saturation",
|
|
154
160
|
yChannel: "brightness",
|
|
155
161
|
className: "aspect-square w-full overflow-hidden rounded-lg",
|
|
162
|
+
onChange: handleChange,
|
|
156
163
|
onChangeEnd: handleChangeEnd,
|
|
157
164
|
children: /*#__PURE__*/ jsx(ColorThumb, {
|
|
158
165
|
className: "h-4 w-4 rounded-full border-2 border-white shadow-[0_2px_4px_rgba(0,0,0,0.2)]"
|
|
@@ -179,6 +186,7 @@ const UXColorPicker = ({ className, isDisabled, placement = 'bottom-start', valu
|
|
|
179
186
|
className: "min-w-0 flex-1",
|
|
180
187
|
colorSpace: "hsl",
|
|
181
188
|
orientation: "horizontal",
|
|
189
|
+
onChange: handleChange,
|
|
182
190
|
onChangeEnd: handleChangeEnd,
|
|
183
191
|
children: /*#__PURE__*/ jsx(SliderTrack, {
|
|
184
192
|
className: "h-3 rounded-full",
|
|
@@ -191,7 +199,7 @@ const UXColorPicker = ({ className, isDisabled, placement = 'bottom-start', valu
|
|
|
191
199
|
}),
|
|
192
200
|
/*#__PURE__*/ jsx(ColorFields, {
|
|
193
201
|
defaultValue: !isControlled && pickerKey > 0 ? internalColor : defaultValue,
|
|
194
|
-
value:
|
|
202
|
+
value: currentColor,
|
|
195
203
|
onChange: handleColorFieldsChange
|
|
196
204
|
})
|
|
197
205
|
]
|
|
@@ -199,26 +207,30 @@ const UXColorPicker = ({ className, isDisabled, placement = 'bottom-start', valu
|
|
|
199
207
|
})
|
|
200
208
|
]
|
|
201
209
|
}),
|
|
202
|
-
/*#__PURE__*/
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
+
]
|
|
222
234
|
})
|
|
223
235
|
]
|
|
224
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
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import react from "react";
|
|
3
|
-
import { cn } from "@heroui/theme";
|
|
4
3
|
import CopyIcon from "@particle-network/icons/web/CopyIcon";
|
|
5
4
|
import copy_to_clipboard from "copy-to-clipboard";
|
|
6
5
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
6
|
+
import { cn } from "../../utils/index.js";
|
|
7
7
|
import { toast } from "../UXToast/index.js";
|
|
8
8
|
import { UXTooltip } from "../UXTooltip/index.js";
|
|
9
9
|
import { shortAddress } from "./utils.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import { forwardRef } from "@heroui/system";
|
|
4
|
-
import { cn } from "@heroui/theme";
|
|
5
4
|
import EmptyIcon from "@particle-network/icons/web/EmptyIcon";
|
|
6
5
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
6
|
+
import { cn } from "../../utils/index.js";
|
|
7
7
|
import { VStack } from "../layout/index.js";
|
|
8
8
|
import { Text } from "../typography/Text.js";
|
|
9
9
|
const UXEmpty = forwardRef((props, ref)=>{
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { cn } from "@heroui/theme";
|
|
4
3
|
import CircleQuestionIcon from "@particle-network/icons/web/CircleQuestionIcon";
|
|
5
4
|
import { Center, UXPopover, UXPopoverContent, UXPopoverTrigger, UXTooltip } from "../index.js";
|
|
5
|
+
import { cn } from "../../utils/index.js";
|
|
6
6
|
const UXHint = (props)=>{
|
|
7
7
|
const { content, children, buttonClassName, iconClassName, triggerType = 'hover', ...restProps } = props;
|
|
8
8
|
const renderTriggerContent = ()=>/*#__PURE__*/ jsx(Center, {
|
|
9
|
-
className: cn('
|
|
9
|
+
className: cn('min-h-4 min-w-4 cursor-pointer', buttonClassName),
|
|
10
10
|
children: /*#__PURE__*/ jsx(CircleQuestionIcon, {
|
|
11
11
|
size: 14,
|
|
12
12
|
className: iconClassName
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type ModalProps } from '@heroui/modal';
|
|
3
|
-
export type UXModalProps = Omit<ModalProps, 'closeButton'> & {
|
|
3
|
+
export type UXModalProps = Omit<ModalProps, 'closeButton' | 'title'> & {
|
|
4
4
|
title?: React.ReactNode;
|
|
5
5
|
footer?: React.ReactNode;
|
|
6
6
|
tip?: React.ReactNode;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type UXNumberInputProps } from '../UXNumberInput';
|
|
3
|
+
export interface UXRangeInputValue {
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
}
|
|
7
|
+
export type UXRangeInputProps = Omit<UXNumberInputProps, 'value' | 'defaultValue' | 'onValueChange' | 'minValue' | 'maxValue'> & {
|
|
8
|
+
asFragment?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The current value of the range input (controlled)
|
|
11
|
+
*/
|
|
12
|
+
value?: UXRangeInputValue;
|
|
13
|
+
/**
|
|
14
|
+
* The default value of the range input (uncontrolled)
|
|
15
|
+
*/
|
|
16
|
+
defaultValue?: UXRangeInputValue;
|
|
17
|
+
/**
|
|
18
|
+
* The minimum value allowed for both inputs
|
|
19
|
+
*/
|
|
20
|
+
minValue?: number;
|
|
21
|
+
/**
|
|
22
|
+
* The maximum value allowed for both inputs
|
|
23
|
+
*/
|
|
24
|
+
maxValue?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Props for the minimum input
|
|
27
|
+
*/
|
|
28
|
+
minInputProps?: Partial<UXNumberInputProps>;
|
|
29
|
+
/**
|
|
30
|
+
* Props for the maximum input
|
|
31
|
+
*/
|
|
32
|
+
maxInputProps?: Partial<UXNumberInputProps>;
|
|
33
|
+
/**
|
|
34
|
+
* Separator between the two inputs
|
|
35
|
+
*/
|
|
36
|
+
separator?: React.ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* Callback fired when the value changes
|
|
39
|
+
*/
|
|
40
|
+
onValueChange?: (value: UXRangeInputValue) => void;
|
|
41
|
+
};
|
|
42
|
+
export declare const UXRangeInput: React.FC<UXRangeInputProps>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import react, { Fragment, useCallback, useMemo } from "react";
|
|
3
|
+
import { useI18n } from "../../hooks/index.js";
|
|
4
|
+
import { HStack } from "../layout/index.js";
|
|
5
|
+
import { UXNumberInput } from "../UXNumberInput/index.js";
|
|
6
|
+
const UXRangeInput = (props)=>{
|
|
7
|
+
const { asFragment, value, defaultValue, onValueChange, minValue, maxValue, minInputProps = {}, maxInputProps = {}, separator = '', className, ...restProps } = props;
|
|
8
|
+
const i18n = useI18n();
|
|
9
|
+
const [internalValue, setInternalValue] = react.useState(defaultValue || {
|
|
10
|
+
min: void 0,
|
|
11
|
+
max: void 0
|
|
12
|
+
});
|
|
13
|
+
const currentValue = void 0 !== value ? value : internalValue;
|
|
14
|
+
const handleMinChange = useCallback((newMin)=>{
|
|
15
|
+
const minValue = isNaN(newMin) ? 0 : newMin;
|
|
16
|
+
const newValue = {
|
|
17
|
+
min: minValue,
|
|
18
|
+
max: currentValue.max
|
|
19
|
+
};
|
|
20
|
+
if (void 0 !== currentValue.max && !isNaN(currentValue.max) && minValue > currentValue.max) newValue.max = minValue;
|
|
21
|
+
if (void 0 === value) setInternalValue(newValue);
|
|
22
|
+
onValueChange?.(newValue);
|
|
23
|
+
}, [
|
|
24
|
+
currentValue.max,
|
|
25
|
+
value,
|
|
26
|
+
onValueChange
|
|
27
|
+
]);
|
|
28
|
+
const handleMaxChange = useCallback((newMax)=>{
|
|
29
|
+
const maxValue = isNaN(newMax) ? 0 : newMax;
|
|
30
|
+
const newValue = {
|
|
31
|
+
min: currentValue.min,
|
|
32
|
+
max: maxValue
|
|
33
|
+
};
|
|
34
|
+
if (void 0 !== currentValue.min && !isNaN(currentValue.min) && maxValue < currentValue.min) newValue.min = maxValue;
|
|
35
|
+
if (void 0 === value) setInternalValue(newValue);
|
|
36
|
+
onValueChange?.(newValue);
|
|
37
|
+
}, [
|
|
38
|
+
currentValue.min,
|
|
39
|
+
value,
|
|
40
|
+
onValueChange
|
|
41
|
+
]);
|
|
42
|
+
const minInputMaxValue = useMemo(()=>{
|
|
43
|
+
if (void 0 !== currentValue.max && !isNaN(currentValue.max)) return currentValue.max;
|
|
44
|
+
return maxValue;
|
|
45
|
+
}, [
|
|
46
|
+
currentValue.max,
|
|
47
|
+
maxValue
|
|
48
|
+
]);
|
|
49
|
+
const maxInputMinValue = useMemo(()=>{
|
|
50
|
+
if (void 0 !== currentValue.min && !isNaN(currentValue.min)) return currentValue.min;
|
|
51
|
+
return minValue;
|
|
52
|
+
}, [
|
|
53
|
+
currentValue.min,
|
|
54
|
+
minValue
|
|
55
|
+
]);
|
|
56
|
+
const Wrapper = asFragment ? Fragment : HStack;
|
|
57
|
+
return /*#__PURE__*/ jsxs(Wrapper, {
|
|
58
|
+
gap: 2,
|
|
59
|
+
className: className,
|
|
60
|
+
children: [
|
|
61
|
+
/*#__PURE__*/ jsx(UXNumberInput, {
|
|
62
|
+
startContent: /*#__PURE__*/ jsx("span", {
|
|
63
|
+
className: "shrink-0",
|
|
64
|
+
"aria-hidden": "true",
|
|
65
|
+
children: i18n.rangeInput.min
|
|
66
|
+
}),
|
|
67
|
+
textAlign: "right",
|
|
68
|
+
...restProps,
|
|
69
|
+
...minInputProps,
|
|
70
|
+
value: currentValue.min,
|
|
71
|
+
minValue: minValue,
|
|
72
|
+
maxValue: minInputMaxValue,
|
|
73
|
+
onValueChange: handleMinChange
|
|
74
|
+
}),
|
|
75
|
+
separator,
|
|
76
|
+
/*#__PURE__*/ jsx(UXNumberInput, {
|
|
77
|
+
startContent: /*#__PURE__*/ jsx("span", {
|
|
78
|
+
className: "shrink-0",
|
|
79
|
+
"aria-hidden": "true",
|
|
80
|
+
children: i18n.rangeInput.max
|
|
81
|
+
}),
|
|
82
|
+
textAlign: "right",
|
|
83
|
+
...restProps,
|
|
84
|
+
...maxInputProps,
|
|
85
|
+
value: currentValue.max,
|
|
86
|
+
minValue: maxInputMinValue,
|
|
87
|
+
maxValue: maxValue,
|
|
88
|
+
onValueChange: handleMaxChange
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
UXRangeInput.displayName = 'UX.RangeInput';
|
|
94
|
+
export { UXRangeInput };
|
|
@@ -2,11 +2,11 @@ import { useCallback, useMemo, useRef } from "react";
|
|
|
2
2
|
import { filterDOMProps, useDOMRef } from "@heroui/react-utils";
|
|
3
3
|
import { mergeProps, objectToDeps, warn } from "@heroui/shared-utils";
|
|
4
4
|
import { mapPropsVariants, useProviderContext } from "@heroui/system";
|
|
5
|
-
import { cn } from "@heroui/theme";
|
|
6
5
|
import { useLocale, useNumberFormatter } from "@react-aria/i18n";
|
|
7
6
|
import { useHover } from "@react-aria/interactions";
|
|
8
7
|
import { useSlider } from "@react-aria/slider";
|
|
9
8
|
import { useSliderState } from "@react-stately/slider";
|
|
9
|
+
import { cn } from "../../utils/index.js";
|
|
10
10
|
import { slider } from "./slider-theme.js";
|
|
11
11
|
function use_slider_useSlider(originalProps) {
|
|
12
12
|
const globalContext = useProviderContext();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
|
-
import { cn } from "
|
|
3
|
+
import { cn } from "../../utils/index.js";
|
|
4
4
|
import { Square } from "../layout/index.js";
|
|
5
5
|
import { SpinnerIcon } from "./SpinnerIcon.js";
|
|
6
6
|
const UXSpinner = ({ size = 18, duration = 400, className, iconClassName, style, ...restProps })=>{
|
|
@@ -48,9 +48,9 @@ const ExtendedSwitch = extendVariants(Switch, {
|
|
|
48
48
|
},
|
|
49
49
|
size: {
|
|
50
50
|
sm: {
|
|
51
|
-
wrapper: 'w-5 h-3 px-0.5',
|
|
51
|
+
wrapper: 'w-5 h-3 px-0.5 bg-cursor',
|
|
52
52
|
thumb: [
|
|
53
|
-
'w-2 h-2 text-tiny',
|
|
53
|
+
'w-2 h-2 text-tiny shadow-none',
|
|
54
54
|
'group-data-[selected=true]:ms-2'
|
|
55
55
|
],
|
|
56
56
|
endContent: 'text-tiny',
|
|
@@ -58,9 +58,9 @@ const ExtendedSwitch = extendVariants(Switch, {
|
|
|
58
58
|
label: 'text-body3 font-medium ms-sm'
|
|
59
59
|
},
|
|
60
60
|
md: {
|
|
61
|
-
wrapper: 'w-6 h-3.5 px-[3px]',
|
|
61
|
+
wrapper: 'w-6 h-3.5 px-[3px] bg-cursor',
|
|
62
62
|
thumb: [
|
|
63
|
-
'w-2.5 h-2.5 text-small',
|
|
63
|
+
'w-2.5 h-2.5 text-small shadow-none',
|
|
64
64
|
'group-data-[selected=true]:ms-2'
|
|
65
65
|
],
|
|
66
66
|
endContent: 'text-small',
|
|
@@ -68,9 +68,9 @@ const ExtendedSwitch = extendVariants(Switch, {
|
|
|
68
68
|
label: 'text-body3 font-medium ms-sm'
|
|
69
69
|
},
|
|
70
70
|
lg: {
|
|
71
|
-
wrapper: 'w-[34px] h-5 px-[3px]',
|
|
71
|
+
wrapper: 'w-[34px] h-5 px-[3px] bg-cursor',
|
|
72
72
|
thumb: [
|
|
73
|
-
'w-3.5 h-3.5 text-medium',
|
|
73
|
+
'w-3.5 h-3.5 text-medium shadow-none',
|
|
74
74
|
'group-data-[selected=true]:ms-3.5'
|
|
75
75
|
],
|
|
76
76
|
endContent: 'text-medium',
|
|
@@ -17,10 +17,10 @@ const COLOR_CATEGORIES = {
|
|
|
17
17
|
'bearish'
|
|
18
18
|
],
|
|
19
19
|
background: [
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
20
|
+
'bgDefault',
|
|
21
|
+
'bg400',
|
|
22
|
+
'bg300',
|
|
23
|
+
'bg200',
|
|
24
24
|
'cursor',
|
|
25
25
|
'overlay',
|
|
26
26
|
'divider'
|
|
@@ -46,7 +46,7 @@ const COLOR_CATEGORIES = {
|
|
|
46
46
|
'blue'
|
|
47
47
|
]
|
|
48
48
|
};
|
|
49
|
-
const CustomThemeConfig = ()=>{
|
|
49
|
+
const CustomThemeConfig = ({ colorChangeMode = 'dragEnd' })=>{
|
|
50
50
|
const { lang } = useLang();
|
|
51
51
|
const i18n = useI18n();
|
|
52
52
|
const { theme, setTheme, setCustomTheme } = useTheme();
|
|
@@ -102,9 +102,10 @@ const CustomThemeConfig = ()=>{
|
|
|
102
102
|
children: label
|
|
103
103
|
}),
|
|
104
104
|
/*#__PURE__*/ jsx(UXColorPicker, {
|
|
105
|
-
|
|
105
|
+
defaultValue: value,
|
|
106
106
|
isChanged: isCustomized,
|
|
107
|
-
onValueChange: (newValue)=>handleColorChange(color, newValue),
|
|
107
|
+
onValueChange: 'drag' === colorChangeMode ? (newValue)=>handleColorChange(color, newValue) : void 0,
|
|
108
|
+
onValueChangeEnd: 'dragEnd' === colorChangeMode ? (newValue)=>handleColorChange(color, newValue) : void 0,
|
|
108
109
|
onReset: ()=>handleColorChange(color, baseTheme.colorVariables[color])
|
|
109
110
|
})
|
|
110
111
|
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import { useColorScheme, useThemeColor, useThemeStore } from '@particle-network/ui-shared';
|
|
1
2
|
export * from './theme-switch';
|
|
2
|
-
export * from './use-color-scheme';
|
|
3
3
|
export * from './use-theme';
|
|
4
|
-
export
|
|
4
|
+
export { useColorScheme, useThemeColor, useThemeStore };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import { useColorScheme, useThemeColor, useThemeStore } from "@particle-network/ui-shared";
|
|
1
2
|
export * from "./theme-switch.js";
|
|
2
|
-
export * from "./use-color-scheme.js";
|
|
3
3
|
export * from "./use-theme.js";
|
|
4
|
-
export
|
|
4
|
+
export { useColorScheme, useThemeColor, useThemeStore };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { cn } from "@heroui/theme";
|
|
4
3
|
import { useLang } from "../../hooks/index.js";
|
|
4
|
+
import { cn } from "../../utils/index.js";
|
|
5
5
|
import { VStack } from "../layout/index.js";
|
|
6
6
|
import { Text } from "../typography/Text.js";
|
|
7
7
|
import { useTheme } from "./use-theme.js";
|
|
@@ -57,7 +57,7 @@ const ThemeItem = ({ id, zhName, enName, isSelected, onClick })=>{
|
|
|
57
57
|
fill: "currentColor",
|
|
58
58
|
className: "text-background",
|
|
59
59
|
style: {
|
|
60
|
-
color: 'custom' === id ? customColors
|
|
60
|
+
color: 'custom' === id ? customColors.bgDefault : void 0
|
|
61
61
|
}
|
|
62
62
|
})
|
|
63
63
|
}),
|
|
@@ -72,7 +72,7 @@ const ThemeItem = ({ id, zhName, enName, isSelected, onClick })=>{
|
|
|
72
72
|
fill: "currentColor",
|
|
73
73
|
className: "text-background",
|
|
74
74
|
style: {
|
|
75
|
-
color: 'custom' === id ? customColors
|
|
75
|
+
color: 'custom' === id ? customColors.bgDefault : void 0
|
|
76
76
|
}
|
|
77
77
|
})
|
|
78
78
|
}),
|
|
@@ -162,8 +162,7 @@ const ThemeItem = ({ id, zhName, enName, isSelected, onClick })=>{
|
|
|
162
162
|
'custom' === id ? /*#__PURE__*/ jsxs(Fragment, {
|
|
163
163
|
children: [
|
|
164
164
|
/*#__PURE__*/ jsx("g", {
|
|
165
|
-
|
|
166
|
-
"data-figma-skip-parse": "true",
|
|
165
|
+
clipPath: "url(#paint0_angular_48986_280686_clip_path)",
|
|
167
166
|
children: /*#__PURE__*/ jsx("g", {
|
|
168
167
|
transform: "matrix(0 0.011 -0.011 0 39 51)",
|
|
169
168
|
children: /*#__PURE__*/ jsx("foreignObject", {
|
|
@@ -188,7 +187,7 @@ const ThemeItem = ({ id, zhName, enName, isSelected, onClick })=>{
|
|
|
188
187
|
r: "10.7583",
|
|
189
188
|
"data-figma-gradient-fill": '{"type":"GRADIENT_ANGULAR","stops":[{"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"position":0.0},{"color":{"r":1.0,"g":0.52295231819152832,"b":0.0,"a":1.0},"position":0.15000000596046448},{"color":{"r":0.74555355310440063,"g":1.0,"b":0.0,"a":1.0},"position":0.32499998807907104},{"color":{"r":0.029410807415843010,"g":0.88352936506271362,"b":1.0,"a":1.0},"position":0.55500000715255737},{"color":{"r":0.14000000059604645,"g":0.0,"b":1.0,"a":1.0},"position":0.78500002622604370},{"color":{"r":0.67999994754791260,"g":0.0,"b":1.0,"a":1.0},"position":1.0}],"stopsVar":[{"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"position":0.0},{"color":{"r":1.0,"g":0.52295231819152832,"b":0.0,"a":1.0},"position":0.15000000596046448},{"color":{"r":0.74555355310440063,"g":1.0,"b":0.0,"a":1.0},"position":0.32499998807907104},{"color":{"r":0.029410807415843010,"g":0.88352936506271362,"b":1.0,"a":1.0},"position":0.55500000715255737},{"color":{"r":0.14000000059604645,"g":0.0,"b":1.0,"a":1.0},"position":0.78500002622604370},{"color":{"r":0.67999994754791260,"g":0.0,"b":1.0,"a":1.0},"position":1.0}],"transform":{"m00":1.3471115643134642e-15,"m01":-22.0,"m02":50.0,"m10":22.0,"m11":1.3471115643134642e-15,"m12":40.0},"opacity":1.0,"blendMode":"NORMAL","visible":true}',
|
|
190
189
|
stroke: "#8B8EA1",
|
|
191
|
-
|
|
190
|
+
strokeWidth: "0.483303"
|
|
192
191
|
}),
|
|
193
192
|
/*#__PURE__*/ jsx("defs", {
|
|
194
193
|
children: /*#__PURE__*/ jsx("clipPath", {
|
|
@@ -197,7 +196,7 @@ const ThemeItem = ({ id, zhName, enName, isSelected, onClick })=>{
|
|
|
197
196
|
cx: "39",
|
|
198
197
|
cy: "51",
|
|
199
198
|
r: "10.7583",
|
|
200
|
-
|
|
199
|
+
strokeWidth: "0.483303"
|
|
201
200
|
})
|
|
202
201
|
})
|
|
203
202
|
})
|