@luxfi/ui 7.4.11 → 7.4.13
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/alert.cjs +68 -46
- package/dist/alert.js +69 -46
- package/dist/avatar.cjs +49 -47
- package/dist/avatar.js +52 -49
- package/dist/badge.cjs +82 -49
- package/dist/badge.js +83 -50
- package/dist/checkbox.cjs +42 -75
- package/dist/checkbox.js +43 -76
- package/dist/chrome.cjs +3 -7
- package/dist/chrome.js +3 -7
- package/dist/close-button.cjs +3 -7
- package/dist/close-button.js +3 -7
- package/dist/dialog.cjs +3 -7
- package/dist/dialog.js +3 -7
- package/dist/drawer.cjs +3 -7
- package/dist/drawer.js +3 -7
- package/dist/empty-state.cjs +13 -13
- package/dist/empty-state.js +13 -13
- package/dist/expiration-selector.cjs +58 -63
- package/dist/expiration-selector.js +58 -63
- package/dist/greeks-display.cjs +48 -39
- package/dist/greeks-display.js +48 -39
- package/dist/index.cjs +1053 -888
- package/dist/index.js +1054 -889
- package/dist/input-group.cjs +36 -19
- package/dist/input-group.js +37 -19
- package/dist/option-chain.cjs +89 -67
- package/dist/option-chain.js +89 -67
- package/dist/option-position.cjs +88 -85
- package/dist/option-position.js +88 -85
- package/dist/pin-input.cjs +30 -29
- package/dist/pin-input.js +30 -29
- package/dist/pnl-diagram.cjs +20 -20
- package/dist/pnl-diagram.js +20 -20
- package/dist/popover.cjs +3 -7
- package/dist/popover.js +3 -7
- package/dist/progress-circle.cjs +40 -22
- package/dist/progress-circle.d.cts +5 -5
- package/dist/progress-circle.d.ts +5 -5
- package/dist/progress-circle.js +41 -22
- package/dist/progress.cjs +15 -22
- package/dist/progress.d.cts +6 -6
- package/dist/progress.d.ts +6 -6
- package/dist/progress.js +15 -22
- package/dist/radio.cjs +35 -68
- package/dist/radio.d.cts +18 -18
- package/dist/radio.d.ts +18 -18
- package/dist/radio.js +36 -69
- package/dist/rating.cjs +15 -17
- package/dist/rating.js +15 -17
- package/dist/slider.cjs +33 -50
- package/dist/slider.js +34 -51
- package/dist/strategy-builder.cjs +194 -115
- package/dist/strategy-builder.js +194 -115
- package/dist/switch.cjs +48 -55
- package/dist/switch.js +49 -56
- package/dist/tag.cjs +115 -69
- package/dist/tag.js +116 -69
- package/dist/tooltip.cjs +28 -17
- package/dist/tooltip.js +30 -18
- package/package.json +1 -1
- package/src/alert.tsx +78 -45
- package/src/avatar.tsx +54 -38
- package/src/badge.tsx +65 -44
- package/src/checkbox.tsx +70 -89
- package/src/close-button.tsx +3 -8
- package/src/empty-state.tsx +21 -17
- package/src/expiration-selector.tsx +84 -66
- package/src/greeks-display.tsx +59 -51
- package/src/input-group.tsx +38 -24
- package/src/option-chain.tsx +154 -104
- package/src/option-position.tsx +143 -114
- package/src/pin-input.tsx +37 -29
- package/src/pnl-diagram.tsx +36 -28
- package/src/progress-circle.tsx +52 -28
- package/src/progress.tsx +17 -21
- package/src/radio.tsx +56 -76
- package/src/rating.tsx +22 -20
- package/src/slider.tsx +43 -45
- package/src/strategy-builder.tsx +260 -162
- package/src/switch.tsx +63 -64
- package/src/tag.tsx +89 -51
- package/src/tooltip.tsx +21 -13
- package/tokens.css +18 -0
package/src/rating.tsx
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { Text, View, XStack } from '@hanzo/gui';
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<svg className={ className } viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
4
|
+
// Inline star icons — fixed at the one size Rating ever draws them (20px, the
|
|
5
|
+
// star buttons' own width/height), so there is nothing left to parameterize.
|
|
6
|
+
const StarFilledIcon = () => (
|
|
7
|
+
<svg width={ 20 } height={ 20 } viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
8
8
|
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/>
|
|
9
9
|
</svg>
|
|
10
10
|
);
|
|
11
|
-
const StarOutlineIcon = (
|
|
12
|
-
<svg
|
|
11
|
+
const StarOutlineIcon = () => (
|
|
12
|
+
<svg width={ 20 } height={ 20 } viewBox="0 0 20 20" fill="none" stroke="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
13
13
|
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" strokeWidth="1.5"/>
|
|
14
14
|
</svg>
|
|
15
15
|
);
|
|
@@ -48,32 +48,34 @@ export const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
|
48
48
|
}, []);
|
|
49
49
|
|
|
50
50
|
return (
|
|
51
|
-
<
|
|
52
|
-
<
|
|
51
|
+
<XStack ref={ ref as never } display="inline-flex" alignItems="center" gap={ 4 } className={ className } { ...(rest as object) }>
|
|
52
|
+
<XStack display="inline-flex" alignItems="center" onMouseLeave={ handleMouseLeave }>
|
|
53
53
|
{ Array.from({ length: count }).map((_, index) => {
|
|
54
54
|
const filled = index < highlightedIndex;
|
|
55
55
|
const starIndex = index + 1;
|
|
56
56
|
|
|
57
57
|
return (
|
|
58
|
-
<
|
|
58
|
+
<View
|
|
59
59
|
key={ index }
|
|
60
|
-
type="button"
|
|
60
|
+
render={ <button type="button"/> }
|
|
61
61
|
tabIndex={ readOnly ? -1 : 0 }
|
|
62
62
|
aria-label={ `Rate ${ starIndex } of ${ count }` }
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
display="inline-flex"
|
|
64
|
+
alignItems="center"
|
|
65
|
+
justifyContent="center"
|
|
66
|
+
width={ 20 }
|
|
67
|
+
height={ 20 }
|
|
68
|
+
cursor={ readOnly ? 'default' : 'pointer' }
|
|
67
69
|
onClick={ handleClick(starIndex) }
|
|
68
70
|
onMouseEnter={ handleMouseEnter(index) }
|
|
69
71
|
>
|
|
70
|
-
{ filled ? <StarFilledIcon
|
|
71
|
-
</
|
|
72
|
+
{ filled ? <StarFilledIcon/> : <StarOutlineIcon/> }
|
|
73
|
+
</View>
|
|
72
74
|
);
|
|
73
75
|
}) }
|
|
74
|
-
</
|
|
75
|
-
{ label && <
|
|
76
|
-
</
|
|
76
|
+
</XStack>
|
|
77
|
+
{ label && <Text fontSize={ 14 }>{ label }</Text> }
|
|
78
|
+
</XStack>
|
|
77
79
|
);
|
|
78
80
|
},
|
|
79
81
|
);
|
package/src/slider.tsx
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { Slider as GuiSlider } from '@hanzo/gui';
|
|
1
|
+
import { Slider as GuiSlider, Text, View, XStack, YStack } from '@hanzo/gui';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
|
-
import { cn } from './utils';
|
|
5
|
-
|
|
6
4
|
export interface SliderProps {
|
|
7
5
|
readonly marks?: Array<number | { readonly value: number; readonly label: React.ReactNode }>;
|
|
8
6
|
readonly label?: React.ReactNode;
|
|
@@ -20,6 +18,12 @@ export interface SliderProps {
|
|
|
20
18
|
readonly className?: string;
|
|
21
19
|
}
|
|
22
20
|
|
|
21
|
+
const MUTED = 'var(--color-text-secondary)' as never;
|
|
22
|
+
const TRACK = 'var(--color-border-divider)' as never;
|
|
23
|
+
const ACTIVE = 'var(--color-link-primary)' as never;
|
|
24
|
+
const ACTIVE_HOVER = 'var(--color-link-primary-hover)' as never;
|
|
25
|
+
const WHITE = 'var(--color-white)' as never;
|
|
26
|
+
|
|
23
27
|
// gui's Slider: pointer, touch and keyboard from one implementation, with the
|
|
24
28
|
// drag handled as a pan gesture by the engine rather than by mouse events — so it
|
|
25
29
|
// works under a finger, not only under a cursor. `role=slider` and the arrow-key
|
|
@@ -64,30 +68,31 @@ export const Slider = React.forwardRef<HTMLSpanElement, SliderProps>(
|
|
|
64
68
|
}, [ onValueCommit ]);
|
|
65
69
|
|
|
66
70
|
return (
|
|
67
|
-
<
|
|
71
|
+
<YStack className={ className } gap={ 4 }>
|
|
68
72
|
{ label && !showValue && (
|
|
69
|
-
<
|
|
73
|
+
<Text fontSize={ 14 } fontWeight="500" color={ MUTED }>
|
|
70
74
|
{ label }
|
|
71
|
-
</
|
|
75
|
+
</Text>
|
|
72
76
|
) }
|
|
73
77
|
{ label && showValue && (
|
|
74
|
-
<
|
|
75
|
-
<
|
|
78
|
+
<XStack alignItems="center" justifyContent="space-between">
|
|
79
|
+
<Text fontSize={ 14 } fontWeight="500" color={ MUTED }>
|
|
76
80
|
{ label }
|
|
77
|
-
</
|
|
78
|
-
<
|
|
81
|
+
</Text>
|
|
82
|
+
<Text fontSize={ 14 } color={ MUTED }>
|
|
79
83
|
{ (value ?? defaultValue ?? [])?.join(', ') }
|
|
80
|
-
</
|
|
81
|
-
</
|
|
84
|
+
</Text>
|
|
85
|
+
</XStack>
|
|
82
86
|
) }
|
|
83
87
|
|
|
84
88
|
<GuiSlider
|
|
85
89
|
ref={ ref as never }
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
position="relative"
|
|
91
|
+
flexDirection="row"
|
|
92
|
+
width="100%"
|
|
93
|
+
userSelect="none"
|
|
94
|
+
alignItems="center"
|
|
95
|
+
marginBottom={ hasMarkLabel ? 24 : 0 }
|
|
91
96
|
value={ value }
|
|
92
97
|
defaultValue={ defaultValue }
|
|
93
98
|
min={ min }
|
|
@@ -99,14 +104,8 @@ export const Slider = React.forwardRef<HTMLSpanElement, SliderProps>(
|
|
|
99
104
|
onValueChange={ handleValueChange }
|
|
100
105
|
onSlideEnd={ handleSlideEnd }
|
|
101
106
|
>
|
|
102
|
-
<GuiSlider.Track
|
|
103
|
-
unstyled
|
|
104
|
-
className="relative grow h-1.5 rounded-full bg-border-divider"
|
|
105
|
-
>
|
|
106
|
-
<GuiSlider.TrackActive
|
|
107
|
-
unstyled
|
|
108
|
-
className="absolute h-full rounded-full bg-link-primary"
|
|
109
|
-
/>
|
|
107
|
+
<GuiSlider.Track unstyled position="relative" flexGrow={ 1 } height={ 6 } borderRadius={ 9999 } backgroundColor={ TRACK }>
|
|
108
|
+
<GuiSlider.TrackActive unstyled position="absolute" height="100%" borderRadius={ 9999 } backgroundColor={ ACTIVE }/>
|
|
110
109
|
</GuiSlider.Track>
|
|
111
110
|
|
|
112
111
|
{ resolvedValue?.map((_, index) => (
|
|
@@ -114,20 +113,23 @@ export const Slider = React.forwardRef<HTMLSpanElement, SliderProps>(
|
|
|
114
113
|
key={ index }
|
|
115
114
|
index={ index }
|
|
116
115
|
unstyled
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
116
|
+
width={ 20 }
|
|
117
|
+
height={ 20 }
|
|
118
|
+
borderRadius={ 9999 }
|
|
119
|
+
borderWidth={ 2 }
|
|
120
|
+
borderColor={ ACTIVE }
|
|
121
|
+
backgroundColor={ WHITE }
|
|
122
|
+
boxShadow="0 1px 2px 0 rgba(0,0,0,0.05)"
|
|
123
|
+
transition="quick"
|
|
124
|
+
hoverStyle={{ borderColor: ACTIVE_HOVER }}
|
|
125
|
+
focusStyle={{ outlineWidth: 2, outlineStyle: 'solid', outlineColor: ACTIVE, outlineOffset: 2 }}
|
|
126
|
+
disabledStyle={{ pointerEvents: 'none', opacity: 0.5 }}
|
|
125
127
|
/>
|
|
126
128
|
)) }
|
|
127
129
|
</GuiSlider>
|
|
128
130
|
|
|
129
131
|
<SliderMarks marks={ marks } min={ min } max={ max }/>
|
|
130
|
-
</
|
|
132
|
+
</YStack>
|
|
131
133
|
);
|
|
132
134
|
},
|
|
133
135
|
);
|
|
@@ -145,24 +147,20 @@ function SliderMarks(props: SliderMarksProps): React.ReactNode {
|
|
|
145
147
|
const range = max - min;
|
|
146
148
|
|
|
147
149
|
return (
|
|
148
|
-
<
|
|
150
|
+
<View position="relative" width="100%" height={ 16 }>
|
|
149
151
|
{ marks.map((mark, index) => {
|
|
150
152
|
const percent = ((mark.value - min) / range) * 100;
|
|
151
153
|
return (
|
|
152
|
-
<
|
|
153
|
-
|
|
154
|
-
className="absolute flex flex-col items-center -translate-x-1/2"
|
|
155
|
-
style={{ left: `${ percent }%` }}
|
|
156
|
-
>
|
|
157
|
-
<div className="h-1.5 w-0.5 bg-border-divider"/>
|
|
154
|
+
<View key={ index } position="absolute" left={ `${ percent }%` as never } alignItems="center">
|
|
155
|
+
<View width={ 2 } height={ 6 } backgroundColor={ TRACK }/>
|
|
158
156
|
{ mark.label != null && (
|
|
159
|
-
<
|
|
157
|
+
<Text marginTop={ 2 } fontSize={ 12 } color={ MUTED }>
|
|
160
158
|
{ mark.label }
|
|
161
|
-
</
|
|
159
|
+
</Text>
|
|
162
160
|
) }
|
|
163
|
-
</
|
|
161
|
+
</View>
|
|
164
162
|
);
|
|
165
163
|
}) }
|
|
166
|
-
</
|
|
164
|
+
</View>
|
|
167
165
|
);
|
|
168
166
|
}
|