@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/dist/progress.cjs
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
var gui = require('@hanzo/gui');
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var clsx = require('clsx');
|
|
7
|
-
var tailwindMerge = require('tailwind-merge');
|
|
8
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
7
|
|
|
10
8
|
function _interopNamespace(e) {
|
|
@@ -28,14 +26,11 @@ function _interopNamespace(e) {
|
|
|
28
26
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
29
27
|
|
|
30
28
|
// src/progress.tsx
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
md: "h-2",
|
|
37
|
-
lg: "h-3",
|
|
38
|
-
xl: "h-4"
|
|
29
|
+
var SIZE = {
|
|
30
|
+
sm: 4,
|
|
31
|
+
md: 8,
|
|
32
|
+
lg: 12,
|
|
33
|
+
xl: 16
|
|
39
34
|
};
|
|
40
35
|
function normalizeValue(value, min, max) {
|
|
41
36
|
if (value == null) return 0;
|
|
@@ -51,7 +46,6 @@ var Progress = React__namespace.forwardRef(
|
|
|
51
46
|
size = "md",
|
|
52
47
|
color,
|
|
53
48
|
trackProps,
|
|
54
|
-
className,
|
|
55
49
|
style,
|
|
56
50
|
w,
|
|
57
51
|
flex,
|
|
@@ -70,6 +64,7 @@ var Progress = React__namespace.forwardRef(
|
|
|
70
64
|
}
|
|
71
65
|
};
|
|
72
66
|
const rootStyle = {
|
|
67
|
+
position: "relative",
|
|
73
68
|
...style,
|
|
74
69
|
...w !== void 0 && { width: w === "full" ? "100%" : w },
|
|
75
70
|
...flex !== void 0 && { flex }
|
|
@@ -78,7 +73,6 @@ var Progress = React__namespace.forwardRef(
|
|
|
78
73
|
"div",
|
|
79
74
|
{
|
|
80
75
|
ref,
|
|
81
|
-
className: cn("relative", className),
|
|
82
76
|
style: rootStyle,
|
|
83
77
|
...rest,
|
|
84
78
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -87,22 +81,21 @@ var Progress = React__namespace.forwardRef(
|
|
|
87
81
|
value: percent,
|
|
88
82
|
max: 100,
|
|
89
83
|
unstyled: true,
|
|
90
|
-
className:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
),
|
|
84
|
+
className: trackProps?.className,
|
|
85
|
+
width: "100%",
|
|
86
|
+
overflow: "hidden",
|
|
87
|
+
borderRadius: 9999,
|
|
88
|
+
height: SIZE[size],
|
|
89
|
+
backgroundColor: "var(--color-progress-track)",
|
|
96
90
|
style: trackStyle,
|
|
97
91
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
98
92
|
gui.Progress.Indicator,
|
|
99
93
|
{
|
|
100
94
|
unstyled: true,
|
|
101
95
|
transition: "slow",
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
),
|
|
96
|
+
height: "100%",
|
|
97
|
+
borderRadius: 9999,
|
|
98
|
+
backgroundColor: color ? void 0 : "var(--color-progress-indicator)",
|
|
106
99
|
style: {
|
|
107
100
|
...color && { backgroundColor: `var(--color-${color.replace(".", "-")}, ${color})` }
|
|
108
101
|
}
|
package/dist/progress.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
declare const
|
|
4
|
-
readonly sm:
|
|
5
|
-
readonly md:
|
|
6
|
-
readonly lg:
|
|
7
|
-
readonly xl:
|
|
3
|
+
declare const SIZE: {
|
|
4
|
+
readonly sm: 4;
|
|
5
|
+
readonly md: 8;
|
|
6
|
+
readonly lg: 12;
|
|
7
|
+
readonly xl: 16;
|
|
8
8
|
};
|
|
9
|
-
type Size = keyof typeof
|
|
9
|
+
type Size = keyof typeof SIZE;
|
|
10
10
|
interface TrackProps {
|
|
11
11
|
readonly borderStartRadius?: number | string;
|
|
12
12
|
readonly borderEndRadius?: number | string;
|
package/dist/progress.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
declare const
|
|
4
|
-
readonly sm:
|
|
5
|
-
readonly md:
|
|
6
|
-
readonly lg:
|
|
7
|
-
readonly xl:
|
|
3
|
+
declare const SIZE: {
|
|
4
|
+
readonly sm: 4;
|
|
5
|
+
readonly md: 8;
|
|
6
|
+
readonly lg: 12;
|
|
7
|
+
readonly xl: 16;
|
|
8
8
|
};
|
|
9
|
-
type Size = keyof typeof
|
|
9
|
+
type Size = keyof typeof SIZE;
|
|
10
10
|
interface TrackProps {
|
|
11
11
|
readonly borderStartRadius?: number | string;
|
|
12
12
|
readonly borderEndRadius?: number | string;
|
package/dist/progress.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Progress as Progress$1 } from '@hanzo/gui';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { clsx } from 'clsx';
|
|
5
|
-
import { twMerge } from 'tailwind-merge';
|
|
6
4
|
import { jsx } from 'react/jsx-runtime';
|
|
7
5
|
|
|
8
6
|
// src/progress.tsx
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
md: "h-2",
|
|
15
|
-
lg: "h-3",
|
|
16
|
-
xl: "h-4"
|
|
7
|
+
var SIZE = {
|
|
8
|
+
sm: 4,
|
|
9
|
+
md: 8,
|
|
10
|
+
lg: 12,
|
|
11
|
+
xl: 16
|
|
17
12
|
};
|
|
18
13
|
function normalizeValue(value, min, max) {
|
|
19
14
|
if (value == null) return 0;
|
|
@@ -29,7 +24,6 @@ var Progress = React.forwardRef(
|
|
|
29
24
|
size = "md",
|
|
30
25
|
color,
|
|
31
26
|
trackProps,
|
|
32
|
-
className,
|
|
33
27
|
style,
|
|
34
28
|
w,
|
|
35
29
|
flex,
|
|
@@ -48,6 +42,7 @@ var Progress = React.forwardRef(
|
|
|
48
42
|
}
|
|
49
43
|
};
|
|
50
44
|
const rootStyle = {
|
|
45
|
+
position: "relative",
|
|
51
46
|
...style,
|
|
52
47
|
...w !== void 0 && { width: w === "full" ? "100%" : w },
|
|
53
48
|
...flex !== void 0 && { flex }
|
|
@@ -56,7 +51,6 @@ var Progress = React.forwardRef(
|
|
|
56
51
|
"div",
|
|
57
52
|
{
|
|
58
53
|
ref,
|
|
59
|
-
className: cn("relative", className),
|
|
60
54
|
style: rootStyle,
|
|
61
55
|
...rest,
|
|
62
56
|
children: /* @__PURE__ */ jsx(
|
|
@@ -65,22 +59,21 @@ var Progress = React.forwardRef(
|
|
|
65
59
|
value: percent,
|
|
66
60
|
max: 100,
|
|
67
61
|
unstyled: true,
|
|
68
|
-
className:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
),
|
|
62
|
+
className: trackProps?.className,
|
|
63
|
+
width: "100%",
|
|
64
|
+
overflow: "hidden",
|
|
65
|
+
borderRadius: 9999,
|
|
66
|
+
height: SIZE[size],
|
|
67
|
+
backgroundColor: "var(--color-progress-track)",
|
|
74
68
|
style: trackStyle,
|
|
75
69
|
children: /* @__PURE__ */ jsx(
|
|
76
70
|
Progress$1.Indicator,
|
|
77
71
|
{
|
|
78
72
|
unstyled: true,
|
|
79
73
|
transition: "slow",
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
),
|
|
74
|
+
height: "100%",
|
|
75
|
+
borderRadius: 9999,
|
|
76
|
+
backgroundColor: color ? void 0 : "var(--color-progress-indicator)",
|
|
84
77
|
style: {
|
|
85
78
|
...color && { backgroundColor: `var(--color-${color.replace(".", "-")}, ${color})` }
|
|
86
79
|
}
|
package/dist/radio.cjs
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
var gui = require('@hanzo/gui');
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var clsx = require('clsx');
|
|
7
|
-
var tailwindMerge = require('tailwind-merge');
|
|
8
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
7
|
|
|
10
8
|
function _interopNamespace(e) {
|
|
@@ -28,35 +26,15 @@ function _interopNamespace(e) {
|
|
|
28
26
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
29
27
|
|
|
30
28
|
// src/radio.tsx
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
root: "gap-1.5",
|
|
37
|
-
control: "h-3 w-3",
|
|
38
|
-
indicator: "h-1.5 w-1.5",
|
|
39
|
-
label: "text-xs"
|
|
40
|
-
},
|
|
41
|
-
sm: {
|
|
42
|
-
root: "gap-1.5",
|
|
43
|
-
control: "h-3.5 w-3.5",
|
|
44
|
-
indicator: "h-1.5 w-1.5",
|
|
45
|
-
label: "text-xs"
|
|
46
|
-
},
|
|
47
|
-
md: {
|
|
48
|
-
root: "gap-2",
|
|
49
|
-
control: "h-4 w-4",
|
|
50
|
-
indicator: "h-2 w-2",
|
|
51
|
-
label: "text-sm"
|
|
52
|
-
},
|
|
53
|
-
lg: {
|
|
54
|
-
root: "gap-2.5",
|
|
55
|
-
control: "h-5 w-5",
|
|
56
|
-
indicator: "h-2.5 w-2.5",
|
|
57
|
-
label: "text-base"
|
|
58
|
-
}
|
|
29
|
+
var SIZE = {
|
|
30
|
+
xs: { rootGap: 6, control: 12, indicator: 6, label: 12 },
|
|
31
|
+
sm: { rootGap: 6, control: 14, indicator: 6, label: 12 },
|
|
32
|
+
md: { rootGap: 8, control: 16, indicator: 8, label: 14 },
|
|
33
|
+
lg: { rootGap: 10, control: 20, indicator: 10, label: 16 }
|
|
59
34
|
};
|
|
35
|
+
var INK = "var(--color-text-primary)";
|
|
36
|
+
var RESTING_BORDER = "var(--color-input-border)";
|
|
37
|
+
var OUTLINE = "var(--color-gray-500)";
|
|
60
38
|
var RadioSizeContext = React__namespace.createContext("md");
|
|
61
39
|
var RadioGroupBase = React__namespace.forwardRef(
|
|
62
40
|
function RadioGroup(props, ref) {
|
|
@@ -73,7 +51,6 @@ var RadioGroupBase = React__namespace.forwardRef(
|
|
|
73
51
|
value,
|
|
74
52
|
onValueChange,
|
|
75
53
|
size = "md",
|
|
76
|
-
className,
|
|
77
54
|
...rest
|
|
78
55
|
} = props;
|
|
79
56
|
const handleValueChange = React__namespace.useCallback(
|
|
@@ -87,7 +64,6 @@ var RadioGroupBase = React__namespace.forwardRef(
|
|
|
87
64
|
gui.RadioGroup,
|
|
88
65
|
{
|
|
89
66
|
ref,
|
|
90
|
-
unstyled: true,
|
|
91
67
|
name,
|
|
92
68
|
required,
|
|
93
69
|
disabled: disabled || readOnly,
|
|
@@ -95,11 +71,9 @@ var RadioGroupBase = React__namespace.forwardRef(
|
|
|
95
71
|
defaultValue,
|
|
96
72
|
value: value ?? void 0,
|
|
97
73
|
onValueChange: handleValueChange,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
className
|
|
102
|
-
),
|
|
74
|
+
display: "flex",
|
|
75
|
+
flexDirection: orientation === "vertical" ? "column" : "row",
|
|
76
|
+
gap: orientation === "vertical" ? 12 : 24,
|
|
103
77
|
...rest,
|
|
104
78
|
children
|
|
105
79
|
}
|
|
@@ -111,19 +85,20 @@ var NOOP = () => {
|
|
|
111
85
|
};
|
|
112
86
|
var RadioBase = React__namespace.forwardRef(
|
|
113
87
|
function Radio(props, ref) {
|
|
114
|
-
const { children, inputProps, rootRef, value, disabled,
|
|
88
|
+
const { children, inputProps, rootRef, value, disabled, ...rest } = props;
|
|
115
89
|
const size = React__namespace.useContext(RadioSizeContext);
|
|
116
|
-
const
|
|
90
|
+
const s = SIZE[size];
|
|
117
91
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
118
|
-
|
|
92
|
+
gui.Label,
|
|
119
93
|
{
|
|
120
94
|
ref: rootRef,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
95
|
+
unstyled: true,
|
|
96
|
+
flexDirection: "row",
|
|
97
|
+
alignItems: "center",
|
|
98
|
+
gap: s.rootGap,
|
|
99
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
100
|
+
userSelect: "none",
|
|
101
|
+
opacity: disabled ? 0.5 : 1,
|
|
127
102
|
"data-disabled": disabled || void 0,
|
|
128
103
|
...rest,
|
|
129
104
|
children: [
|
|
@@ -133,32 +108,24 @@ var RadioBase = React__namespace.forwardRef(
|
|
|
133
108
|
unstyled: true,
|
|
134
109
|
value,
|
|
135
110
|
disabled,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
unstyled: true,
|
|
148
|
-
className: cn(
|
|
149
|
-
"block rounded-full bg-gray-800 dark:bg-white",
|
|
150
|
-
sizeClasses.indicator
|
|
151
|
-
)
|
|
152
|
-
}
|
|
153
|
-
)
|
|
111
|
+
flexShrink: 0,
|
|
112
|
+
alignItems: "center",
|
|
113
|
+
justifyContent: "center",
|
|
114
|
+
width: s.control,
|
|
115
|
+
height: s.control,
|
|
116
|
+
borderRadius: 9999,
|
|
117
|
+
borderWidth: 2,
|
|
118
|
+
borderColor: RESTING_BORDER,
|
|
119
|
+
transition: "quicker",
|
|
120
|
+
focusStyle: { outlineWidth: 2, outlineStyle: "solid", outlineColor: OUTLINE, outlineOffset: 2 },
|
|
121
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(gui.RadioGroup.Indicator, { unstyled: true, borderRadius: 9999, width: s.indicator, height: s.indicator, backgroundColor: INK })
|
|
154
122
|
}
|
|
155
123
|
),
|
|
156
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.VisuallyHidden, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
157
125
|
"input",
|
|
158
126
|
{
|
|
159
127
|
ref,
|
|
160
128
|
type: "radio",
|
|
161
|
-
className: "sr-only",
|
|
162
129
|
value,
|
|
163
130
|
disabled,
|
|
164
131
|
tabIndex: -1,
|
|
@@ -166,8 +133,8 @@ var RadioBase = React__namespace.forwardRef(
|
|
|
166
133
|
onChange: NOOP,
|
|
167
134
|
...inputProps
|
|
168
135
|
}
|
|
169
|
-
),
|
|
170
|
-
children != null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
136
|
+
) }),
|
|
137
|
+
children != null && /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: s.label, children })
|
|
171
138
|
]
|
|
172
139
|
}
|
|
173
140
|
);
|
package/dist/radio.d.cts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
declare const
|
|
3
|
+
declare const SIZE: {
|
|
4
4
|
readonly xs: {
|
|
5
|
-
readonly
|
|
6
|
-
readonly control:
|
|
7
|
-
readonly indicator:
|
|
8
|
-
readonly label:
|
|
5
|
+
readonly rootGap: 6;
|
|
6
|
+
readonly control: 12;
|
|
7
|
+
readonly indicator: 6;
|
|
8
|
+
readonly label: 12;
|
|
9
9
|
};
|
|
10
10
|
readonly sm: {
|
|
11
|
-
readonly
|
|
12
|
-
readonly control:
|
|
13
|
-
readonly indicator:
|
|
14
|
-
readonly label:
|
|
11
|
+
readonly rootGap: 6;
|
|
12
|
+
readonly control: 14;
|
|
13
|
+
readonly indicator: 6;
|
|
14
|
+
readonly label: 12;
|
|
15
15
|
};
|
|
16
16
|
readonly md: {
|
|
17
|
-
readonly
|
|
18
|
-
readonly control:
|
|
19
|
-
readonly indicator:
|
|
20
|
-
readonly label:
|
|
17
|
+
readonly rootGap: 8;
|
|
18
|
+
readonly control: 16;
|
|
19
|
+
readonly indicator: 8;
|
|
20
|
+
readonly label: 14;
|
|
21
21
|
};
|
|
22
22
|
readonly lg: {
|
|
23
|
-
readonly
|
|
24
|
-
readonly control:
|
|
25
|
-
readonly indicator:
|
|
26
|
-
readonly label:
|
|
23
|
+
readonly rootGap: 10;
|
|
24
|
+
readonly control: 20;
|
|
25
|
+
readonly indicator: 10;
|
|
26
|
+
readonly label: 16;
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
|
-
type RadioSize = keyof typeof
|
|
29
|
+
type RadioSize = keyof typeof SIZE;
|
|
30
30
|
interface RadioGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'dir'> {
|
|
31
31
|
name?: string;
|
|
32
32
|
required?: boolean;
|
package/dist/radio.d.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
declare const
|
|
3
|
+
declare const SIZE: {
|
|
4
4
|
readonly xs: {
|
|
5
|
-
readonly
|
|
6
|
-
readonly control:
|
|
7
|
-
readonly indicator:
|
|
8
|
-
readonly label:
|
|
5
|
+
readonly rootGap: 6;
|
|
6
|
+
readonly control: 12;
|
|
7
|
+
readonly indicator: 6;
|
|
8
|
+
readonly label: 12;
|
|
9
9
|
};
|
|
10
10
|
readonly sm: {
|
|
11
|
-
readonly
|
|
12
|
-
readonly control:
|
|
13
|
-
readonly indicator:
|
|
14
|
-
readonly label:
|
|
11
|
+
readonly rootGap: 6;
|
|
12
|
+
readonly control: 14;
|
|
13
|
+
readonly indicator: 6;
|
|
14
|
+
readonly label: 12;
|
|
15
15
|
};
|
|
16
16
|
readonly md: {
|
|
17
|
-
readonly
|
|
18
|
-
readonly control:
|
|
19
|
-
readonly indicator:
|
|
20
|
-
readonly label:
|
|
17
|
+
readonly rootGap: 8;
|
|
18
|
+
readonly control: 16;
|
|
19
|
+
readonly indicator: 8;
|
|
20
|
+
readonly label: 14;
|
|
21
21
|
};
|
|
22
22
|
readonly lg: {
|
|
23
|
-
readonly
|
|
24
|
-
readonly control:
|
|
25
|
-
readonly indicator:
|
|
26
|
-
readonly label:
|
|
23
|
+
readonly rootGap: 10;
|
|
24
|
+
readonly control: 20;
|
|
25
|
+
readonly indicator: 10;
|
|
26
|
+
readonly label: 16;
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
|
-
type RadioSize = keyof typeof
|
|
29
|
+
type RadioSize = keyof typeof SIZE;
|
|
30
30
|
interface RadioGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'dir'> {
|
|
31
31
|
name?: string;
|
|
32
32
|
required?: boolean;
|
package/dist/radio.js
CHANGED
|
@@ -1,40 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { RadioGroup } from '@hanzo/gui';
|
|
2
|
+
import { RadioGroup, Label, VisuallyHidden, Text } from '@hanzo/gui';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { clsx } from 'clsx';
|
|
5
|
-
import { twMerge } from 'tailwind-merge';
|
|
6
4
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
5
|
|
|
8
6
|
// src/radio.tsx
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
root: "gap-1.5",
|
|
15
|
-
control: "h-3 w-3",
|
|
16
|
-
indicator: "h-1.5 w-1.5",
|
|
17
|
-
label: "text-xs"
|
|
18
|
-
},
|
|
19
|
-
sm: {
|
|
20
|
-
root: "gap-1.5",
|
|
21
|
-
control: "h-3.5 w-3.5",
|
|
22
|
-
indicator: "h-1.5 w-1.5",
|
|
23
|
-
label: "text-xs"
|
|
24
|
-
},
|
|
25
|
-
md: {
|
|
26
|
-
root: "gap-2",
|
|
27
|
-
control: "h-4 w-4",
|
|
28
|
-
indicator: "h-2 w-2",
|
|
29
|
-
label: "text-sm"
|
|
30
|
-
},
|
|
31
|
-
lg: {
|
|
32
|
-
root: "gap-2.5",
|
|
33
|
-
control: "h-5 w-5",
|
|
34
|
-
indicator: "h-2.5 w-2.5",
|
|
35
|
-
label: "text-base"
|
|
36
|
-
}
|
|
7
|
+
var SIZE = {
|
|
8
|
+
xs: { rootGap: 6, control: 12, indicator: 6, label: 12 },
|
|
9
|
+
sm: { rootGap: 6, control: 14, indicator: 6, label: 12 },
|
|
10
|
+
md: { rootGap: 8, control: 16, indicator: 8, label: 14 },
|
|
11
|
+
lg: { rootGap: 10, control: 20, indicator: 10, label: 16 }
|
|
37
12
|
};
|
|
13
|
+
var INK = "var(--color-text-primary)";
|
|
14
|
+
var RESTING_BORDER = "var(--color-input-border)";
|
|
15
|
+
var OUTLINE = "var(--color-gray-500)";
|
|
38
16
|
var RadioSizeContext = React.createContext("md");
|
|
39
17
|
var RadioGroupBase = React.forwardRef(
|
|
40
18
|
function RadioGroup$1(props, ref) {
|
|
@@ -51,7 +29,6 @@ var RadioGroupBase = React.forwardRef(
|
|
|
51
29
|
value,
|
|
52
30
|
onValueChange,
|
|
53
31
|
size = "md",
|
|
54
|
-
className,
|
|
55
32
|
...rest
|
|
56
33
|
} = props;
|
|
57
34
|
const handleValueChange = React.useCallback(
|
|
@@ -65,7 +42,6 @@ var RadioGroupBase = React.forwardRef(
|
|
|
65
42
|
RadioGroup,
|
|
66
43
|
{
|
|
67
44
|
ref,
|
|
68
|
-
unstyled: true,
|
|
69
45
|
name,
|
|
70
46
|
required,
|
|
71
47
|
disabled: disabled || readOnly,
|
|
@@ -73,11 +49,9 @@ var RadioGroupBase = React.forwardRef(
|
|
|
73
49
|
defaultValue,
|
|
74
50
|
value: value ?? void 0,
|
|
75
51
|
onValueChange: handleValueChange,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
className
|
|
80
|
-
),
|
|
52
|
+
display: "flex",
|
|
53
|
+
flexDirection: orientation === "vertical" ? "column" : "row",
|
|
54
|
+
gap: orientation === "vertical" ? 12 : 24,
|
|
81
55
|
...rest,
|
|
82
56
|
children
|
|
83
57
|
}
|
|
@@ -89,19 +63,20 @@ var NOOP = () => {
|
|
|
89
63
|
};
|
|
90
64
|
var RadioBase = React.forwardRef(
|
|
91
65
|
function Radio(props, ref) {
|
|
92
|
-
const { children, inputProps, rootRef, value, disabled,
|
|
66
|
+
const { children, inputProps, rootRef, value, disabled, ...rest } = props;
|
|
93
67
|
const size = React.useContext(RadioSizeContext);
|
|
94
|
-
const
|
|
68
|
+
const s = SIZE[size];
|
|
95
69
|
return /* @__PURE__ */ jsxs(
|
|
96
|
-
|
|
70
|
+
Label,
|
|
97
71
|
{
|
|
98
72
|
ref: rootRef,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
73
|
+
unstyled: true,
|
|
74
|
+
flexDirection: "row",
|
|
75
|
+
alignItems: "center",
|
|
76
|
+
gap: s.rootGap,
|
|
77
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
78
|
+
userSelect: "none",
|
|
79
|
+
opacity: disabled ? 0.5 : 1,
|
|
105
80
|
"data-disabled": disabled || void 0,
|
|
106
81
|
...rest,
|
|
107
82
|
children: [
|
|
@@ -111,32 +86,24 @@ var RadioBase = React.forwardRef(
|
|
|
111
86
|
unstyled: true,
|
|
112
87
|
value,
|
|
113
88
|
disabled,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
unstyled: true,
|
|
126
|
-
className: cn(
|
|
127
|
-
"block rounded-full bg-gray-800 dark:bg-white",
|
|
128
|
-
sizeClasses.indicator
|
|
129
|
-
)
|
|
130
|
-
}
|
|
131
|
-
)
|
|
89
|
+
flexShrink: 0,
|
|
90
|
+
alignItems: "center",
|
|
91
|
+
justifyContent: "center",
|
|
92
|
+
width: s.control,
|
|
93
|
+
height: s.control,
|
|
94
|
+
borderRadius: 9999,
|
|
95
|
+
borderWidth: 2,
|
|
96
|
+
borderColor: RESTING_BORDER,
|
|
97
|
+
transition: "quicker",
|
|
98
|
+
focusStyle: { outlineWidth: 2, outlineStyle: "solid", outlineColor: OUTLINE, outlineOffset: 2 },
|
|
99
|
+
children: /* @__PURE__ */ jsx(RadioGroup.Indicator, { unstyled: true, borderRadius: 9999, width: s.indicator, height: s.indicator, backgroundColor: INK })
|
|
132
100
|
}
|
|
133
101
|
),
|
|
134
|
-
/* @__PURE__ */ jsx(
|
|
102
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx(
|
|
135
103
|
"input",
|
|
136
104
|
{
|
|
137
105
|
ref,
|
|
138
106
|
type: "radio",
|
|
139
|
-
className: "sr-only",
|
|
140
107
|
value,
|
|
141
108
|
disabled,
|
|
142
109
|
tabIndex: -1,
|
|
@@ -144,8 +111,8 @@ var RadioBase = React.forwardRef(
|
|
|
144
111
|
onChange: NOOP,
|
|
145
112
|
...inputProps
|
|
146
113
|
}
|
|
147
|
-
),
|
|
148
|
-
children != null && /* @__PURE__ */ jsx(
|
|
114
|
+
) }),
|
|
115
|
+
children != null && /* @__PURE__ */ jsx(Text, { fontSize: s.label, children })
|
|
149
116
|
]
|
|
150
117
|
}
|
|
151
118
|
);
|