@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.
Files changed (84) hide show
  1. package/dist/alert.cjs +68 -46
  2. package/dist/alert.js +69 -46
  3. package/dist/avatar.cjs +49 -47
  4. package/dist/avatar.js +52 -49
  5. package/dist/badge.cjs +82 -49
  6. package/dist/badge.js +83 -50
  7. package/dist/checkbox.cjs +42 -75
  8. package/dist/checkbox.js +43 -76
  9. package/dist/chrome.cjs +3 -7
  10. package/dist/chrome.js +3 -7
  11. package/dist/close-button.cjs +3 -7
  12. package/dist/close-button.js +3 -7
  13. package/dist/dialog.cjs +3 -7
  14. package/dist/dialog.js +3 -7
  15. package/dist/drawer.cjs +3 -7
  16. package/dist/drawer.js +3 -7
  17. package/dist/empty-state.cjs +13 -13
  18. package/dist/empty-state.js +13 -13
  19. package/dist/expiration-selector.cjs +58 -63
  20. package/dist/expiration-selector.js +58 -63
  21. package/dist/greeks-display.cjs +48 -39
  22. package/dist/greeks-display.js +48 -39
  23. package/dist/index.cjs +1053 -888
  24. package/dist/index.js +1054 -889
  25. package/dist/input-group.cjs +36 -19
  26. package/dist/input-group.js +37 -19
  27. package/dist/option-chain.cjs +89 -67
  28. package/dist/option-chain.js +89 -67
  29. package/dist/option-position.cjs +88 -85
  30. package/dist/option-position.js +88 -85
  31. package/dist/pin-input.cjs +30 -29
  32. package/dist/pin-input.js +30 -29
  33. package/dist/pnl-diagram.cjs +20 -20
  34. package/dist/pnl-diagram.js +20 -20
  35. package/dist/popover.cjs +3 -7
  36. package/dist/popover.js +3 -7
  37. package/dist/progress-circle.cjs +40 -22
  38. package/dist/progress-circle.d.cts +5 -5
  39. package/dist/progress-circle.d.ts +5 -5
  40. package/dist/progress-circle.js +41 -22
  41. package/dist/progress.cjs +15 -22
  42. package/dist/progress.d.cts +6 -6
  43. package/dist/progress.d.ts +6 -6
  44. package/dist/progress.js +15 -22
  45. package/dist/radio.cjs +35 -68
  46. package/dist/radio.d.cts +18 -18
  47. package/dist/radio.d.ts +18 -18
  48. package/dist/radio.js +36 -69
  49. package/dist/rating.cjs +15 -17
  50. package/dist/rating.js +15 -17
  51. package/dist/slider.cjs +33 -50
  52. package/dist/slider.js +34 -51
  53. package/dist/strategy-builder.cjs +194 -115
  54. package/dist/strategy-builder.js +194 -115
  55. package/dist/switch.cjs +48 -55
  56. package/dist/switch.js +49 -56
  57. package/dist/tag.cjs +115 -69
  58. package/dist/tag.js +116 -69
  59. package/dist/tooltip.cjs +28 -17
  60. package/dist/tooltip.js +30 -18
  61. package/package.json +1 -1
  62. package/src/alert.tsx +78 -45
  63. package/src/avatar.tsx +54 -38
  64. package/src/badge.tsx +65 -44
  65. package/src/checkbox.tsx +70 -89
  66. package/src/close-button.tsx +3 -8
  67. package/src/empty-state.tsx +21 -17
  68. package/src/expiration-selector.tsx +84 -66
  69. package/src/greeks-display.tsx +59 -51
  70. package/src/input-group.tsx +38 -24
  71. package/src/option-chain.tsx +154 -104
  72. package/src/option-position.tsx +143 -114
  73. package/src/pin-input.tsx +37 -29
  74. package/src/pnl-diagram.tsx +36 -28
  75. package/src/progress-circle.tsx +52 -28
  76. package/src/progress.tsx +17 -21
  77. package/src/radio.tsx +56 -76
  78. package/src/rating.tsx +22 -20
  79. package/src/slider.tsx +43 -45
  80. package/src/strategy-builder.tsx +260 -162
  81. package/src/switch.tsx +63 -64
  82. package/src/tag.tsx +89 -51
  83. package/src/tooltip.tsx +21 -13
  84. 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
- import { cn } from './utils';
4
-
5
- // Inline star icons
6
- const StarFilledIcon = ({ className }: { readonly className?: string }) => (
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 = ({ className }: { readonly className?: string }) => (
12
- <svg className={ className } viewBox="0 0 20 20" fill="none" stroke="currentColor" xmlns="http://www.w3.org/2000/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
- <div ref={ ref } className={ cn('inline-flex items-center gap-1', className) } { ...rest }>
52
- <div className="inline-flex items-center" onMouseLeave={ handleMouseLeave }>
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
- <button
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
- className={ cn(
64
- 'inline-flex items-center justify-center w-5 h-5 text-current',
65
- readOnly ? 'cursor-default' : 'cursor-pointer',
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 className="w-5 h-5"/> : <StarOutlineIcon className="w-5 h-5"/> }
71
- </button>
72
+ { filled ? <StarFilledIcon/> : <StarOutlineIcon/> }
73
+ </View>
72
74
  );
73
75
  }) }
74
- </div>
75
- { label && <span className="text-sm">{ label }</span> }
76
- </div>
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
- <div className={ cn('flex flex-col gap-1', className) }>
71
+ <YStack className={ className } gap={ 4 }>
68
72
  { label && !showValue && (
69
- <label className="text-sm font-medium text-text-secondary">
73
+ <Text fontSize={ 14 } fontWeight="500" color={ MUTED }>
70
74
  { label }
71
- </label>
75
+ </Text>
72
76
  ) }
73
77
  { label && showValue && (
74
- <div className="flex items-center justify-between">
75
- <label className="text-sm font-medium text-text-secondary">
78
+ <XStack alignItems="center" justifyContent="space-between">
79
+ <Text fontSize={ 14 } fontWeight="500" color={ MUTED }>
76
80
  { label }
77
- </label>
78
- <span className="text-sm text-text-secondary">
81
+ </Text>
82
+ <Text fontSize={ 14 } color={ MUTED }>
79
83
  { (value ?? defaultValue ?? [])?.join(', ') }
80
- </span>
81
- </div>
84
+ </Text>
85
+ </XStack>
82
86
  ) }
83
87
 
84
88
  <GuiSlider
85
89
  ref={ ref as never }
86
- unstyled
87
- className={ cn(
88
- 'relative flex w-full touch-none select-none items-center',
89
- hasMarkLabel && 'mb-6',
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
- className={ cn(
118
- 'block h-5 w-5',
119
- 'rounded-full border-2 border-link-primary bg-white',
120
- 'shadow-sm transition-colors',
121
- 'hover:border-link-primary-hover',
122
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-link-primary focus-visible:ring-offset-2',
123
- 'disabled:pointer-events-none disabled:opacity-50',
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
- </div>
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
- <div className="relative w-full h-4">
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
- <div
153
- key={ index }
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
- <span className="mt-0.5 text-xs text-text-secondary whitespace-nowrap">
157
+ <Text marginTop={ 2 } fontSize={ 12 } color={ MUTED }>
160
158
  { mark.label }
161
- </span>
159
+ </Text>
162
160
  ) }
163
- </div>
161
+ </View>
164
162
  );
165
163
  }) }
166
- </div>
164
+ </View>
167
165
  );
168
166
  }