@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/input-group.cjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
var gui = require('@hanzo/gui');
|
|
4
5
|
var esToolkit = require('es-toolkit');
|
|
5
6
|
var React = require('react');
|
|
6
|
-
var clsx = require('clsx');
|
|
7
|
-
var tailwindMerge = require('tailwind-merge');
|
|
8
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
8
|
|
|
10
9
|
function _interopNamespace(e) {
|
|
@@ -28,9 +27,14 @@ function _interopNamespace(e) {
|
|
|
28
27
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
29
28
|
|
|
30
29
|
// src/input-group.tsx
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
var ink = (children, Wrap = gui.Text, props = {}) => {
|
|
31
|
+
let hasText = false;
|
|
32
|
+
React.Children.forEach(children, (child) => {
|
|
33
|
+
if (typeof child === "string" || typeof child === "number") hasText = true;
|
|
34
|
+
});
|
|
35
|
+
if (!hasText) return children;
|
|
36
|
+
return React.Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? React.createElement(Wrap, props, child) : child);
|
|
37
|
+
};
|
|
34
38
|
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
35
39
|
var InputGroup = React__namespace.forwardRef(
|
|
36
40
|
function InputGroup2(props, ref) {
|
|
@@ -99,22 +103,30 @@ var InputGroup = React__namespace.forwardRef(
|
|
|
99
103
|
const { className: startClassName, ...startRest } = startElementProps ?? {};
|
|
100
104
|
const { className: endClassName, ...endRest } = endElementProps ?? {};
|
|
101
105
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
102
|
-
|
|
106
|
+
gui.XStack,
|
|
103
107
|
{
|
|
104
108
|
ref: combinedRef,
|
|
105
|
-
|
|
109
|
+
position: "relative",
|
|
110
|
+
width: "100%",
|
|
111
|
+
alignItems: "center",
|
|
112
|
+
className,
|
|
106
113
|
...rest,
|
|
107
114
|
children: [
|
|
108
115
|
startElement && /* @__PURE__ */ jsxRuntime.jsx(
|
|
109
|
-
|
|
116
|
+
gui.XStack,
|
|
110
117
|
{
|
|
111
118
|
ref: startElementRef,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
119
|
+
position: "absolute",
|
|
120
|
+
top: 0,
|
|
121
|
+
bottom: 0,
|
|
122
|
+
left: 0,
|
|
123
|
+
zIndex: 1,
|
|
124
|
+
alignItems: "center",
|
|
125
|
+
pointerEvents: "none",
|
|
126
|
+
style: { color: "var(--color-icon-secondary)" },
|
|
127
|
+
className: startClassName,
|
|
116
128
|
...startRest,
|
|
117
|
-
children: startElement
|
|
129
|
+
children: ink(startElement)
|
|
118
130
|
}
|
|
119
131
|
),
|
|
120
132
|
React__namespace.Children.map(children, (child) => {
|
|
@@ -133,15 +145,20 @@ var InputGroup = React__namespace.forwardRef(
|
|
|
133
145
|
});
|
|
134
146
|
}),
|
|
135
147
|
endElement && /* @__PURE__ */ jsxRuntime.jsx(
|
|
136
|
-
|
|
148
|
+
gui.XStack,
|
|
137
149
|
{
|
|
138
150
|
ref: endElementRef,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
151
|
+
position: "absolute",
|
|
152
|
+
top: 0,
|
|
153
|
+
bottom: 0,
|
|
154
|
+
right: 0,
|
|
155
|
+
zIndex: 1,
|
|
156
|
+
alignItems: "center",
|
|
157
|
+
pointerEvents: "none",
|
|
158
|
+
style: { color: "var(--color-icon-secondary)" },
|
|
159
|
+
className: endClassName,
|
|
143
160
|
...endRest,
|
|
144
|
-
children: endElement
|
|
161
|
+
children: ink(endElement)
|
|
145
162
|
}
|
|
146
163
|
)
|
|
147
164
|
]
|
package/dist/input-group.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { XStack, Text } from '@hanzo/gui';
|
|
2
3
|
import { debounce } from 'es-toolkit';
|
|
3
4
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import { twMerge } from 'tailwind-merge';
|
|
5
|
+
import { Children, createElement } from 'react';
|
|
6
6
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
7
|
|
|
8
8
|
// src/input-group.tsx
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
var ink = (children, Wrap = Text, props = {}) => {
|
|
10
|
+
let hasText = false;
|
|
11
|
+
Children.forEach(children, (child) => {
|
|
12
|
+
if (typeof child === "string" || typeof child === "number") hasText = true;
|
|
13
|
+
});
|
|
14
|
+
if (!hasText) return children;
|
|
15
|
+
return Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? createElement(Wrap, props, child) : child);
|
|
16
|
+
};
|
|
12
17
|
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
13
18
|
var InputGroup = React.forwardRef(
|
|
14
19
|
function InputGroup2(props, ref) {
|
|
@@ -77,22 +82,30 @@ var InputGroup = React.forwardRef(
|
|
|
77
82
|
const { className: startClassName, ...startRest } = startElementProps ?? {};
|
|
78
83
|
const { className: endClassName, ...endRest } = endElementProps ?? {};
|
|
79
84
|
return /* @__PURE__ */ jsxs(
|
|
80
|
-
|
|
85
|
+
XStack,
|
|
81
86
|
{
|
|
82
87
|
ref: combinedRef,
|
|
83
|
-
|
|
88
|
+
position: "relative",
|
|
89
|
+
width: "100%",
|
|
90
|
+
alignItems: "center",
|
|
91
|
+
className,
|
|
84
92
|
...rest,
|
|
85
93
|
children: [
|
|
86
94
|
startElement && /* @__PURE__ */ jsx(
|
|
87
|
-
|
|
95
|
+
XStack,
|
|
88
96
|
{
|
|
89
97
|
ref: startElementRef,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
position: "absolute",
|
|
99
|
+
top: 0,
|
|
100
|
+
bottom: 0,
|
|
101
|
+
left: 0,
|
|
102
|
+
zIndex: 1,
|
|
103
|
+
alignItems: "center",
|
|
104
|
+
pointerEvents: "none",
|
|
105
|
+
style: { color: "var(--color-icon-secondary)" },
|
|
106
|
+
className: startClassName,
|
|
94
107
|
...startRest,
|
|
95
|
-
children: startElement
|
|
108
|
+
children: ink(startElement)
|
|
96
109
|
}
|
|
97
110
|
),
|
|
98
111
|
React.Children.map(children, (child) => {
|
|
@@ -111,15 +124,20 @@ var InputGroup = React.forwardRef(
|
|
|
111
124
|
});
|
|
112
125
|
}),
|
|
113
126
|
endElement && /* @__PURE__ */ jsx(
|
|
114
|
-
|
|
127
|
+
XStack,
|
|
115
128
|
{
|
|
116
129
|
ref: endElementRef,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
position: "absolute",
|
|
131
|
+
top: 0,
|
|
132
|
+
bottom: 0,
|
|
133
|
+
right: 0,
|
|
134
|
+
zIndex: 1,
|
|
135
|
+
alignItems: "center",
|
|
136
|
+
pointerEvents: "none",
|
|
137
|
+
style: { color: "var(--color-icon-secondary)" },
|
|
138
|
+
className: endClassName,
|
|
121
139
|
...endRest,
|
|
122
|
-
children: endElement
|
|
140
|
+
children: ink(endElement)
|
|
123
141
|
}
|
|
124
142
|
)
|
|
125
143
|
]
|
package/dist/option-chain.cjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
var gui = require('@hanzo/gui');
|
|
4
5
|
var React = require('react');
|
|
5
|
-
var clsx = require('clsx');
|
|
6
|
-
var tailwindMerge = require('tailwind-merge');
|
|
7
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
7
|
|
|
9
8
|
function _interopNamespace(e) {
|
|
@@ -26,9 +25,6 @@ function _interopNamespace(e) {
|
|
|
26
25
|
|
|
27
26
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
27
|
|
|
29
|
-
function cn(...inputs) {
|
|
30
|
-
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
31
|
-
}
|
|
32
28
|
function fmt(n, decimals = 2) {
|
|
33
29
|
if (n === void 0 || n === null) return "-";
|
|
34
30
|
return n.toFixed(decimals);
|
|
@@ -43,20 +39,55 @@ function fmtPct(n) {
|
|
|
43
39
|
if (n === void 0 || n === null) return "-";
|
|
44
40
|
return `${(n * 100).toFixed(1)}%`;
|
|
45
41
|
}
|
|
42
|
+
var justify = (align) => align === "right" ? "flex-end" : align === "left" ? "flex-start" : "center";
|
|
46
43
|
function QuoteCell({ value, highlight, align = "right", onClick, className }) {
|
|
47
44
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
48
|
-
|
|
45
|
+
gui.View,
|
|
49
46
|
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
align === "right" ? "text-right" : "text-left",
|
|
53
|
-
highlight && "text-zinc-100",
|
|
54
|
-
!highlight && "text-zinc-400",
|
|
55
|
-
onClick && "cursor-pointer hover:bg-zinc-700/50 transition-colors",
|
|
56
|
-
className
|
|
57
|
-
),
|
|
47
|
+
unstyled: true,
|
|
48
|
+
render: /* @__PURE__ */ jsxRuntime.jsx("td", {}),
|
|
58
49
|
onClick,
|
|
59
|
-
|
|
50
|
+
paddingHorizontal: 6,
|
|
51
|
+
paddingVertical: 4,
|
|
52
|
+
cursor: onClick ? "pointer" : void 0,
|
|
53
|
+
transition: "quick",
|
|
54
|
+
hoverStyle: onClick ? { backgroundColor: "var(--color-popover-item-hover)" } : void 0,
|
|
55
|
+
style: { display: "flex", alignItems: "center", justifyContent: justify(align) },
|
|
56
|
+
className,
|
|
57
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
58
|
+
gui.Text,
|
|
59
|
+
{
|
|
60
|
+
fontSize: 12,
|
|
61
|
+
style: { fontFamily: "monospace", whiteSpace: "nowrap" },
|
|
62
|
+
fontVariant: ["tabular-nums"],
|
|
63
|
+
color: highlight ? "var(--color-text-primary)" : "var(--color-text-secondary)",
|
|
64
|
+
children: value
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
function HeadCell({ children, colSpan, align = "center", size = "column", color }) {
|
|
71
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
72
|
+
gui.View,
|
|
73
|
+
{
|
|
74
|
+
unstyled: true,
|
|
75
|
+
render: colSpan ? /* @__PURE__ */ jsxRuntime.jsx("th", { colSpan }) : /* @__PURE__ */ jsxRuntime.jsx("th", {}),
|
|
76
|
+
paddingHorizontal: size === "group" ? 8 : 6,
|
|
77
|
+
paddingVertical: size === "group" ? 6 : 4,
|
|
78
|
+
style: { display: "flex", alignItems: "center", justifyContent: justify(align) },
|
|
79
|
+
children: children != null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
80
|
+
gui.Text,
|
|
81
|
+
{
|
|
82
|
+
fontSize: 10,
|
|
83
|
+
fontWeight: size === "group" ? "600" : "500",
|
|
84
|
+
textTransform: "uppercase",
|
|
85
|
+
letterSpacing: 0.5,
|
|
86
|
+
style: { whiteSpace: "nowrap" },
|
|
87
|
+
color: color ?? "var(--color-text-secondary)",
|
|
88
|
+
children
|
|
89
|
+
}
|
|
90
|
+
)
|
|
60
91
|
}
|
|
61
92
|
);
|
|
62
93
|
}
|
|
@@ -87,71 +118,51 @@ var OptionChain = React__namespace.forwardRef(
|
|
|
87
118
|
[onSelectContract]
|
|
88
119
|
);
|
|
89
120
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
90
|
-
|
|
121
|
+
gui.View,
|
|
91
122
|
{
|
|
92
123
|
ref,
|
|
93
|
-
|
|
124
|
+
unstyled: true,
|
|
125
|
+
width: "100%",
|
|
126
|
+
overflowX: "auto",
|
|
127
|
+
className,
|
|
94
128
|
...rest,
|
|
95
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("table", {
|
|
96
|
-
/* @__PURE__ */ jsxRuntime.jsxs("thead", { children: [
|
|
97
|
-
/* @__PURE__ */ jsxRuntime.jsxs("tr", {
|
|
98
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
colSpan: CALL_HEADERS.length,
|
|
102
|
-
className: "px-2 py-1.5 text-center text-[10px] font-semibold uppercase tracking-wider text-emerald-400",
|
|
103
|
-
children: "Calls"
|
|
104
|
-
}
|
|
105
|
-
),
|
|
106
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-2 py-1.5 text-center text-[10px] font-semibold uppercase tracking-wider text-zinc-500", children: "Strike" }),
|
|
107
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
108
|
-
"th",
|
|
109
|
-
{
|
|
110
|
-
colSpan: PUT_HEADERS.length,
|
|
111
|
-
className: "px-2 py-1.5 text-center text-[10px] font-semibold uppercase tracking-wider text-red-400",
|
|
112
|
-
children: "Puts"
|
|
113
|
-
}
|
|
114
|
-
)
|
|
129
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(gui.View, { unstyled: true, render: /* @__PURE__ */ jsxRuntime.jsx("table", {}), width: "100%", style: { borderCollapse: "collapse" }, children: [
|
|
130
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.View, { unstyled: true, render: /* @__PURE__ */ jsxRuntime.jsx("thead", {}), children: [
|
|
131
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.View, { unstyled: true, render: /* @__PURE__ */ jsxRuntime.jsx("tr", {}), borderBottomWidth: 1, borderColor: "var(--color-border-divider)", children: [
|
|
132
|
+
/* @__PURE__ */ jsxRuntime.jsx(HeadCell, { colSpan: CALL_HEADERS.length, size: "group", color: "var(--color-status-good)", children: "Calls" }),
|
|
133
|
+
/* @__PURE__ */ jsxRuntime.jsx(HeadCell, { size: "group", children: "Strike" }),
|
|
134
|
+
/* @__PURE__ */ jsxRuntime.jsx(HeadCell, { colSpan: PUT_HEADERS.length, size: "group", color: "var(--color-status-bad)", children: "Puts" })
|
|
115
135
|
] }),
|
|
116
|
-
/* @__PURE__ */ jsxRuntime.jsxs("tr", {
|
|
117
|
-
CALL_HEADERS.map((h) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
118
|
-
|
|
119
|
-
{
|
|
120
|
-
className: "px-1.5 py-1 text-right text-[10px] font-medium uppercase tracking-wider text-zinc-500",
|
|
121
|
-
children: h
|
|
122
|
-
},
|
|
123
|
-
`call-${h}`
|
|
124
|
-
)),
|
|
125
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-2 py-1 text-center text-[10px] font-medium uppercase tracking-wider text-zinc-500" }),
|
|
136
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.View, { unstyled: true, render: /* @__PURE__ */ jsxRuntime.jsx("tr", {}), borderBottomWidth: 1, borderColor: "var(--color-popover-item-hover)", children: [
|
|
137
|
+
CALL_HEADERS.map((h) => /* @__PURE__ */ jsxRuntime.jsx(HeadCell, { align: "right", children: h }, `call-${h}`)),
|
|
138
|
+
/* @__PURE__ */ jsxRuntime.jsx(HeadCell, {}),
|
|
126
139
|
PUT_HEADERS.map((h) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
127
|
-
|
|
140
|
+
HeadCell,
|
|
128
141
|
{
|
|
129
|
-
|
|
130
|
-
"px-1.5 py-1 text-[10px] font-medium uppercase tracking-wider text-zinc-500",
|
|
131
|
-
h === "Bid" || h === "Ask" || h === "Last" ? "text-left" : "text-right"
|
|
132
|
-
),
|
|
142
|
+
align: h === "Bid" || h === "Ask" || h === "Last" ? "left" : "right",
|
|
133
143
|
children: h
|
|
134
144
|
},
|
|
135
145
|
`put-${h}`
|
|
136
146
|
))
|
|
137
147
|
] })
|
|
138
148
|
] }),
|
|
139
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: strikes.map((row) => {
|
|
149
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.View, { unstyled: true, render: /* @__PURE__ */ jsxRuntime.jsx("tbody", {}), children: strikes.map((row) => {
|
|
140
150
|
const isATM = Math.abs(row.strike - spotPrice) <= (strikes.length > 1 ? Math.abs((strikes[1]?.strike ?? 0) - (strikes[0]?.strike ?? 0)) / 2 : 0.5);
|
|
141
151
|
const callITM = row.strike < spotPrice;
|
|
142
152
|
const putITM = row.strike > spotPrice;
|
|
143
153
|
const c = row.call;
|
|
144
154
|
const p = row.put;
|
|
155
|
+
const rowBg = isATM ? "var(--secondary)" : callITM ? "color-mix(in srgb, var(--color-status-good) 12%, transparent)" : putITM ? "color-mix(in srgb, var(--color-status-bad) 12%, transparent)" : "transparent";
|
|
145
156
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
146
|
-
|
|
157
|
+
gui.View,
|
|
147
158
|
{
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
),
|
|
159
|
+
unstyled: true,
|
|
160
|
+
render: /* @__PURE__ */ jsxRuntime.jsx("tr", {}),
|
|
161
|
+
borderBottomWidth: 1,
|
|
162
|
+
borderColor: "color-mix(in srgb, var(--color-border-divider) 50%, transparent)",
|
|
163
|
+
transition: "quick",
|
|
164
|
+
backgroundColor: rowBg,
|
|
165
|
+
hoverStyle: isATM || callITM || putITM ? void 0 : { backgroundColor: "var(--color-popover-item-hover)" },
|
|
155
166
|
children: [
|
|
156
167
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
157
168
|
QuoteCell,
|
|
@@ -175,13 +186,24 @@ var OptionChain = React__namespace.forwardRef(
|
|
|
175
186
|
/* @__PURE__ */ jsxRuntime.jsx(QuoteCell, { value: fmtPct(c?.iv) }),
|
|
176
187
|
/* @__PURE__ */ jsxRuntime.jsx(QuoteCell, { value: fmt(c?.delta, 3) }),
|
|
177
188
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
178
|
-
|
|
189
|
+
gui.View,
|
|
179
190
|
{
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
191
|
+
unstyled: true,
|
|
192
|
+
render: /* @__PURE__ */ jsxRuntime.jsx("td", {}),
|
|
193
|
+
paddingHorizontal: 8,
|
|
194
|
+
paddingVertical: 4,
|
|
195
|
+
style: { display: "flex", alignItems: "center", justifyContent: "center" },
|
|
196
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
197
|
+
gui.Text,
|
|
198
|
+
{
|
|
199
|
+
fontSize: 12,
|
|
200
|
+
fontWeight: "600",
|
|
201
|
+
style: { fontFamily: "monospace" },
|
|
202
|
+
fontVariant: ["tabular-nums"],
|
|
203
|
+
color: isATM ? "var(--foreground)" : "var(--muted-foreground)",
|
|
204
|
+
children: fmt(row.strike)
|
|
205
|
+
}
|
|
206
|
+
)
|
|
185
207
|
}
|
|
186
208
|
),
|
|
187
209
|
/* @__PURE__ */ jsxRuntime.jsx(QuoteCell, { value: fmt(p?.delta, 3), align: "right" }),
|
package/dist/option-chain.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { View, Text } from '@hanzo/gui';
|
|
2
3
|
import * as React from 'react';
|
|
3
|
-
import { clsx } from 'clsx';
|
|
4
|
-
import { twMerge } from 'tailwind-merge';
|
|
5
4
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
5
|
|
|
7
|
-
function cn(...inputs) {
|
|
8
|
-
return twMerge(clsx(inputs));
|
|
9
|
-
}
|
|
10
6
|
function fmt(n, decimals = 2) {
|
|
11
7
|
if (n === void 0 || n === null) return "-";
|
|
12
8
|
return n.toFixed(decimals);
|
|
@@ -21,20 +17,55 @@ function fmtPct(n) {
|
|
|
21
17
|
if (n === void 0 || n === null) return "-";
|
|
22
18
|
return `${(n * 100).toFixed(1)}%`;
|
|
23
19
|
}
|
|
20
|
+
var justify = (align) => align === "right" ? "flex-end" : align === "left" ? "flex-start" : "center";
|
|
24
21
|
function QuoteCell({ value, highlight, align = "right", onClick, className }) {
|
|
25
22
|
return /* @__PURE__ */ jsx(
|
|
26
|
-
|
|
23
|
+
View,
|
|
27
24
|
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
align === "right" ? "text-right" : "text-left",
|
|
31
|
-
highlight && "text-zinc-100",
|
|
32
|
-
!highlight && "text-zinc-400",
|
|
33
|
-
onClick && "cursor-pointer hover:bg-zinc-700/50 transition-colors",
|
|
34
|
-
className
|
|
35
|
-
),
|
|
25
|
+
unstyled: true,
|
|
26
|
+
render: /* @__PURE__ */ jsx("td", {}),
|
|
36
27
|
onClick,
|
|
37
|
-
|
|
28
|
+
paddingHorizontal: 6,
|
|
29
|
+
paddingVertical: 4,
|
|
30
|
+
cursor: onClick ? "pointer" : void 0,
|
|
31
|
+
transition: "quick",
|
|
32
|
+
hoverStyle: onClick ? { backgroundColor: "var(--color-popover-item-hover)" } : void 0,
|
|
33
|
+
style: { display: "flex", alignItems: "center", justifyContent: justify(align) },
|
|
34
|
+
className,
|
|
35
|
+
children: /* @__PURE__ */ jsx(
|
|
36
|
+
Text,
|
|
37
|
+
{
|
|
38
|
+
fontSize: 12,
|
|
39
|
+
style: { fontFamily: "monospace", whiteSpace: "nowrap" },
|
|
40
|
+
fontVariant: ["tabular-nums"],
|
|
41
|
+
color: highlight ? "var(--color-text-primary)" : "var(--color-text-secondary)",
|
|
42
|
+
children: value
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
function HeadCell({ children, colSpan, align = "center", size = "column", color }) {
|
|
49
|
+
return /* @__PURE__ */ jsx(
|
|
50
|
+
View,
|
|
51
|
+
{
|
|
52
|
+
unstyled: true,
|
|
53
|
+
render: colSpan ? /* @__PURE__ */ jsx("th", { colSpan }) : /* @__PURE__ */ jsx("th", {}),
|
|
54
|
+
paddingHorizontal: size === "group" ? 8 : 6,
|
|
55
|
+
paddingVertical: size === "group" ? 6 : 4,
|
|
56
|
+
style: { display: "flex", alignItems: "center", justifyContent: justify(align) },
|
|
57
|
+
children: children != null && /* @__PURE__ */ jsx(
|
|
58
|
+
Text,
|
|
59
|
+
{
|
|
60
|
+
fontSize: 10,
|
|
61
|
+
fontWeight: size === "group" ? "600" : "500",
|
|
62
|
+
textTransform: "uppercase",
|
|
63
|
+
letterSpacing: 0.5,
|
|
64
|
+
style: { whiteSpace: "nowrap" },
|
|
65
|
+
color: color ?? "var(--color-text-secondary)",
|
|
66
|
+
children
|
|
67
|
+
}
|
|
68
|
+
)
|
|
38
69
|
}
|
|
39
70
|
);
|
|
40
71
|
}
|
|
@@ -65,71 +96,51 @@ var OptionChain = React.forwardRef(
|
|
|
65
96
|
[onSelectContract]
|
|
66
97
|
);
|
|
67
98
|
return /* @__PURE__ */ jsx(
|
|
68
|
-
|
|
99
|
+
View,
|
|
69
100
|
{
|
|
70
101
|
ref,
|
|
71
|
-
|
|
102
|
+
unstyled: true,
|
|
103
|
+
width: "100%",
|
|
104
|
+
overflowX: "auto",
|
|
105
|
+
className,
|
|
72
106
|
...rest,
|
|
73
|
-
children: /* @__PURE__ */ jsxs("table", {
|
|
74
|
-
/* @__PURE__ */ jsxs("thead", { children: [
|
|
75
|
-
/* @__PURE__ */ jsxs("tr", {
|
|
76
|
-
/* @__PURE__ */ jsx(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
colSpan: CALL_HEADERS.length,
|
|
80
|
-
className: "px-2 py-1.5 text-center text-[10px] font-semibold uppercase tracking-wider text-emerald-400",
|
|
81
|
-
children: "Calls"
|
|
82
|
-
}
|
|
83
|
-
),
|
|
84
|
-
/* @__PURE__ */ jsx("th", { className: "px-2 py-1.5 text-center text-[10px] font-semibold uppercase tracking-wider text-zinc-500", children: "Strike" }),
|
|
85
|
-
/* @__PURE__ */ jsx(
|
|
86
|
-
"th",
|
|
87
|
-
{
|
|
88
|
-
colSpan: PUT_HEADERS.length,
|
|
89
|
-
className: "px-2 py-1.5 text-center text-[10px] font-semibold uppercase tracking-wider text-red-400",
|
|
90
|
-
children: "Puts"
|
|
91
|
-
}
|
|
92
|
-
)
|
|
107
|
+
children: /* @__PURE__ */ jsxs(View, { unstyled: true, render: /* @__PURE__ */ jsx("table", {}), width: "100%", style: { borderCollapse: "collapse" }, children: [
|
|
108
|
+
/* @__PURE__ */ jsxs(View, { unstyled: true, render: /* @__PURE__ */ jsx("thead", {}), children: [
|
|
109
|
+
/* @__PURE__ */ jsxs(View, { unstyled: true, render: /* @__PURE__ */ jsx("tr", {}), borderBottomWidth: 1, borderColor: "var(--color-border-divider)", children: [
|
|
110
|
+
/* @__PURE__ */ jsx(HeadCell, { colSpan: CALL_HEADERS.length, size: "group", color: "var(--color-status-good)", children: "Calls" }),
|
|
111
|
+
/* @__PURE__ */ jsx(HeadCell, { size: "group", children: "Strike" }),
|
|
112
|
+
/* @__PURE__ */ jsx(HeadCell, { colSpan: PUT_HEADERS.length, size: "group", color: "var(--color-status-bad)", children: "Puts" })
|
|
93
113
|
] }),
|
|
94
|
-
/* @__PURE__ */ jsxs("tr", {
|
|
95
|
-
CALL_HEADERS.map((h) => /* @__PURE__ */ jsx(
|
|
96
|
-
|
|
97
|
-
{
|
|
98
|
-
className: "px-1.5 py-1 text-right text-[10px] font-medium uppercase tracking-wider text-zinc-500",
|
|
99
|
-
children: h
|
|
100
|
-
},
|
|
101
|
-
`call-${h}`
|
|
102
|
-
)),
|
|
103
|
-
/* @__PURE__ */ jsx("th", { className: "px-2 py-1 text-center text-[10px] font-medium uppercase tracking-wider text-zinc-500" }),
|
|
114
|
+
/* @__PURE__ */ jsxs(View, { unstyled: true, render: /* @__PURE__ */ jsx("tr", {}), borderBottomWidth: 1, borderColor: "var(--color-popover-item-hover)", children: [
|
|
115
|
+
CALL_HEADERS.map((h) => /* @__PURE__ */ jsx(HeadCell, { align: "right", children: h }, `call-${h}`)),
|
|
116
|
+
/* @__PURE__ */ jsx(HeadCell, {}),
|
|
104
117
|
PUT_HEADERS.map((h) => /* @__PURE__ */ jsx(
|
|
105
|
-
|
|
118
|
+
HeadCell,
|
|
106
119
|
{
|
|
107
|
-
|
|
108
|
-
"px-1.5 py-1 text-[10px] font-medium uppercase tracking-wider text-zinc-500",
|
|
109
|
-
h === "Bid" || h === "Ask" || h === "Last" ? "text-left" : "text-right"
|
|
110
|
-
),
|
|
120
|
+
align: h === "Bid" || h === "Ask" || h === "Last" ? "left" : "right",
|
|
111
121
|
children: h
|
|
112
122
|
},
|
|
113
123
|
`put-${h}`
|
|
114
124
|
))
|
|
115
125
|
] })
|
|
116
126
|
] }),
|
|
117
|
-
/* @__PURE__ */ jsx("tbody", { children: strikes.map((row) => {
|
|
127
|
+
/* @__PURE__ */ jsx(View, { unstyled: true, render: /* @__PURE__ */ jsx("tbody", {}), children: strikes.map((row) => {
|
|
118
128
|
const isATM = Math.abs(row.strike - spotPrice) <= (strikes.length > 1 ? Math.abs((strikes[1]?.strike ?? 0) - (strikes[0]?.strike ?? 0)) / 2 : 0.5);
|
|
119
129
|
const callITM = row.strike < spotPrice;
|
|
120
130
|
const putITM = row.strike > spotPrice;
|
|
121
131
|
const c = row.call;
|
|
122
132
|
const p = row.put;
|
|
133
|
+
const rowBg = isATM ? "var(--secondary)" : callITM ? "color-mix(in srgb, var(--color-status-good) 12%, transparent)" : putITM ? "color-mix(in srgb, var(--color-status-bad) 12%, transparent)" : "transparent";
|
|
123
134
|
return /* @__PURE__ */ jsxs(
|
|
124
|
-
|
|
135
|
+
View,
|
|
125
136
|
{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
),
|
|
137
|
+
unstyled: true,
|
|
138
|
+
render: /* @__PURE__ */ jsx("tr", {}),
|
|
139
|
+
borderBottomWidth: 1,
|
|
140
|
+
borderColor: "color-mix(in srgb, var(--color-border-divider) 50%, transparent)",
|
|
141
|
+
transition: "quick",
|
|
142
|
+
backgroundColor: rowBg,
|
|
143
|
+
hoverStyle: isATM || callITM || putITM ? void 0 : { backgroundColor: "var(--color-popover-item-hover)" },
|
|
133
144
|
children: [
|
|
134
145
|
/* @__PURE__ */ jsx(
|
|
135
146
|
QuoteCell,
|
|
@@ -153,13 +164,24 @@ var OptionChain = React.forwardRef(
|
|
|
153
164
|
/* @__PURE__ */ jsx(QuoteCell, { value: fmtPct(c?.iv) }),
|
|
154
165
|
/* @__PURE__ */ jsx(QuoteCell, { value: fmt(c?.delta, 3) }),
|
|
155
166
|
/* @__PURE__ */ jsx(
|
|
156
|
-
|
|
167
|
+
View,
|
|
157
168
|
{
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
169
|
+
unstyled: true,
|
|
170
|
+
render: /* @__PURE__ */ jsx("td", {}),
|
|
171
|
+
paddingHorizontal: 8,
|
|
172
|
+
paddingVertical: 4,
|
|
173
|
+
style: { display: "flex", alignItems: "center", justifyContent: "center" },
|
|
174
|
+
children: /* @__PURE__ */ jsx(
|
|
175
|
+
Text,
|
|
176
|
+
{
|
|
177
|
+
fontSize: 12,
|
|
178
|
+
fontWeight: "600",
|
|
179
|
+
style: { fontFamily: "monospace" },
|
|
180
|
+
fontVariant: ["tabular-nums"],
|
|
181
|
+
color: isATM ? "var(--foreground)" : "var(--muted-foreground)",
|
|
182
|
+
children: fmt(row.strike)
|
|
183
|
+
}
|
|
184
|
+
)
|
|
163
185
|
}
|
|
164
186
|
),
|
|
165
187
|
/* @__PURE__ */ jsx(QuoteCell, { value: fmt(p?.delta, 3), align: "right" }),
|