@luxfi/ui 7.4.10 → 7.4.12
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/accordion.cjs +107 -166
- package/dist/accordion.d.cts +18 -51
- package/dist/accordion.d.ts +18 -51
- package/dist/accordion.js +109 -166
- package/dist/alert.cjs +68 -46
- package/dist/alert.js +69 -46
- package/dist/avatar.cjs +49 -46
- package/dist/avatar.js +52 -48
- 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 +196 -386
- package/dist/chrome.js +198 -386
- package/dist/close-button.cjs +3 -7
- package/dist/close-button.js +3 -7
- package/dist/collapsible.cjs +35 -26
- package/dist/collapsible.d.cts +2 -1
- package/dist/collapsible.d.ts +2 -1
- package/dist/collapsible.js +34 -24
- package/dist/dialog.cjs +3 -7
- package/dist/dialog.d.cts +1 -1
- package/dist/dialog.d.ts +1 -1
- package/dist/dialog.js +3 -7
- package/dist/drawer.cjs +95 -122
- package/dist/drawer.d.cts +43 -10
- package/dist/drawer.d.ts +43 -10
- package/dist/drawer.js +97 -122
- 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/field.cjs +60 -109
- package/dist/field.d.cts +0 -1
- package/dist/field.d.ts +0 -1
- package/dist/field.js +61 -109
- package/dist/greeks-display.cjs +48 -39
- package/dist/greeks-display.js +48 -39
- package/dist/heading.cjs +10 -17
- package/dist/heading.d.cts +0 -2
- package/dist/heading.d.ts +0 -2
- package/dist/heading.js +10 -17
- package/dist/icon-button.cjs +82 -82
- package/dist/icon-button.d.cts +16 -12
- package/dist/icon-button.d.ts +16 -12
- package/dist/icon-button.js +82 -82
- package/dist/index.cjs +1812 -2105
- package/dist/index.d.cts +1 -5
- package/dist/index.d.ts +1 -5
- package/dist/index.js +1814 -2100
- package/dist/input-group.cjs +11 -12
- package/dist/input-group.js +11 -12
- package/dist/input.cjs +27 -27
- package/dist/input.d.cts +21 -1
- package/dist/input.d.ts +21 -1
- package/dist/input.js +25 -28
- package/dist/menu.cjs +160 -271
- package/dist/menu.d.cts +41 -57
- package/dist/menu.d.ts +41 -57
- package/dist/menu.js +161 -251
- 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/pnl-diagram.cjs +20 -20
- package/dist/pnl-diagram.js +20 -20
- package/dist/popover.cjs +4 -8
- package/dist/popover.js +4 -8
- 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 -67
- package/dist/radio.d.cts +18 -18
- package/dist/radio.d.ts +18 -18
- package/dist/radio.js +36 -68
- package/dist/select.cjs +40 -39
- package/dist/select.d.cts +35 -4
- package/dist/select.d.ts +35 -4
- package/dist/select.js +40 -38
- package/dist/separator.cjs +8 -33
- package/dist/separator.js +8 -33
- package/dist/slider.cjs +33 -49
- package/dist/slider.js +34 -50
- package/dist/switch.cjs +48 -55
- package/dist/switch.js +49 -56
- package/dist/tabs.cjs +108 -197
- package/dist/tabs.d.cts +16 -60
- package/dist/tabs.d.ts +16 -60
- package/dist/tabs.js +109 -196
- package/dist/tag.cjs +112 -69
- package/dist/tag.js +113 -69
- package/dist/textarea.cjs +56 -27
- package/dist/textarea.js +57 -28
- package/dist/toaster.cjs +97 -79
- package/dist/toaster.d.cts +7 -8
- package/dist/toaster.d.ts +7 -8
- package/dist/toaster.js +78 -80
- package/dist/tooltip.cjs +28 -17
- package/dist/tooltip.js +30 -18
- package/package.json +2 -16
- package/src/accordion.tsx +173 -227
- package/src/alert.tsx +78 -45
- package/src/avatar.tsx +54 -37
- package/src/badge.tsx +65 -44
- package/src/checkbox.tsx +70 -89
- package/src/close-button.tsx +3 -8
- package/src/collapsible.tsx +55 -52
- package/src/drawer.tsx +123 -115
- package/src/empty-state.tsx +21 -17
- package/src/expiration-selector.tsx +84 -66
- package/src/field.tsx +68 -124
- package/src/greeks-display.tsx +59 -51
- package/src/heading.tsx +22 -26
- package/src/icon-button.tsx +134 -141
- package/src/ink.tsx +37 -0
- package/src/input-group.tsx +59 -36
- package/src/input.tsx +41 -32
- package/src/menu.tsx +224 -397
- package/src/option-chain.tsx +154 -104
- package/src/option-position.tsx +136 -114
- package/src/pin-input.tsx +37 -29
- package/src/pnl-diagram.tsx +36 -28
- package/src/popover.tsx +1 -1
- package/src/progress.tsx +17 -21
- package/src/radio.tsx +56 -75
- package/src/select.tsx +80 -59
- package/src/separator.tsx +13 -34
- package/src/slider.tsx +43 -44
- package/src/strategy-builder.tsx +245 -156
- package/src/switch.tsx +63 -64
- package/src/tabs.tsx +166 -296
- package/src/tag.tsx +89 -51
- package/src/textarea.tsx +19 -29
- package/src/toaster.tsx +118 -86
- package/src/tooltip.tsx +21 -13
- package/tokens.css +79 -0
package/dist/option-position.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,13 +25,11 @@ 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 formatDate(date) {
|
|
33
29
|
const d = new Date(date);
|
|
34
30
|
return d.toLocaleDateString("en-US", { month: "short", day: "numeric" });
|
|
35
31
|
}
|
|
32
|
+
var MONO = { fontFamily: "monospace" };
|
|
36
33
|
var OptionPositionCard = React__namespace.forwardRef(
|
|
37
34
|
function OptionPositionCard2(props, ref) {
|
|
38
35
|
const {
|
|
@@ -46,64 +43,76 @@ var OptionPositionCard = React__namespace.forwardRef(
|
|
|
46
43
|
const isLong = position.quantity > 0;
|
|
47
44
|
const isCall = position.type === "call";
|
|
48
45
|
const isProfitable = position.pnl >= 0;
|
|
46
|
+
const pnlColor = isProfitable ? "var(--color-status-good)" : "var(--color-status-bad)";
|
|
49
47
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
50
|
-
|
|
48
|
+
gui.YStack,
|
|
51
49
|
{
|
|
52
50
|
ref,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
),
|
|
51
|
+
gap: 8,
|
|
52
|
+
borderRadius: 8,
|
|
53
|
+
borderWidth: 1,
|
|
54
|
+
borderColor: "var(--color-border-divider)",
|
|
55
|
+
backgroundColor: "var(--card)",
|
|
56
|
+
padding: 12,
|
|
57
|
+
className,
|
|
57
58
|
...rest,
|
|
58
59
|
children: [
|
|
59
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
60
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { alignItems: "center", justifyContent: "space-between", children: [
|
|
61
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.XStack, { alignItems: "center", gap: 8, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
62
|
+
gui.XStack,
|
|
63
|
+
{
|
|
64
|
+
alignItems: "center",
|
|
65
|
+
gap: 4,
|
|
66
|
+
borderRadius: 4,
|
|
67
|
+
paddingHorizontal: 6,
|
|
68
|
+
paddingVertical: 2,
|
|
69
|
+
backgroundColor: isCall ? "var(--secondary)" : "var(--muted)",
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 12, fontWeight: "600", color: isCall ? "var(--foreground)" : "var(--muted-foreground)", children: position.underlying }),
|
|
72
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 12, fontWeight: "600", style: MONO, fontVariant: ["tabular-nums"], color: isCall ? "var(--foreground)" : "var(--muted-foreground)", children: position.strike }),
|
|
73
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 12, fontWeight: "600", textTransform: "uppercase", color: isCall ? "var(--foreground)" : "var(--muted-foreground)", children: position.type === "call" ? "C" : "P" }),
|
|
74
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 12, fontWeight: "400", color: "var(--color-text-secondary)", children: formatDate(position.expiration) })
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
) }),
|
|
78
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
79
|
+
gui.Text,
|
|
80
|
+
{
|
|
81
|
+
fontSize: 12,
|
|
82
|
+
fontWeight: "600",
|
|
83
|
+
style: MONO,
|
|
84
|
+
fontVariant: ["tabular-nums"],
|
|
85
|
+
color: isLong ? "var(--color-status-good)" : "var(--color-status-bad)",
|
|
86
|
+
children: [
|
|
87
|
+
isLong ? "+" : "",
|
|
88
|
+
position.quantity
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
)
|
|
77
92
|
] }),
|
|
78
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
79
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
80
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
81
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
93
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { gap: 12, children: [
|
|
94
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { flex: 1, gap: 2, children: [
|
|
95
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 10, textTransform: "uppercase", letterSpacing: 0.5, color: "var(--color-text-secondary)", children: "Avg Cost" }),
|
|
96
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.Text, { fontSize: 12, style: MONO, fontVariant: ["tabular-nums"], color: "var(--color-text-primary)", children: [
|
|
82
97
|
"$",
|
|
83
98
|
position.avgCost.toFixed(2)
|
|
84
99
|
] })
|
|
85
100
|
] }),
|
|
86
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
87
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
88
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
101
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { flex: 1, gap: 2, children: [
|
|
102
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 10, textTransform: "uppercase", letterSpacing: 0.5, color: "var(--color-text-secondary)", children: "Value" }),
|
|
103
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.Text, { fontSize: 12, style: MONO, fontVariant: ["tabular-nums"], color: "var(--color-text-primary)", children: [
|
|
89
104
|
"$",
|
|
90
105
|
position.currentValue.toFixed(2)
|
|
91
106
|
] })
|
|
92
107
|
] }),
|
|
93
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
94
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
95
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
96
|
-
/* @__PURE__ */ jsxRuntime.jsxs("
|
|
97
|
-
"font-mono tabular-nums text-xs font-semibold",
|
|
98
|
-
isProfitable ? "text-emerald-400" : "text-red-400"
|
|
99
|
-
), children: [
|
|
108
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { flex: 1, gap: 2, alignItems: "flex-end", children: [
|
|
109
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 10, textTransform: "uppercase", letterSpacing: 0.5, color: "var(--color-text-secondary)", children: "P/L" }),
|
|
110
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { alignItems: "center", gap: 4, children: [
|
|
111
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.Text, { fontSize: 12, fontWeight: "600", style: MONO, fontVariant: ["tabular-nums"], color: pnlColor, children: [
|
|
100
112
|
isProfitable ? "+" : "",
|
|
101
113
|
position.pnl.toFixed(2)
|
|
102
114
|
] }),
|
|
103
|
-
/* @__PURE__ */ jsxRuntime.jsxs("
|
|
104
|
-
"font-mono tabular-nums text-[10px]",
|
|
105
|
-
isProfitable ? "text-emerald-500/70" : "text-red-500/70"
|
|
106
|
-
), children: [
|
|
115
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.Text, { fontSize: 10, style: MONO, fontVariant: ["tabular-nums"], color: pnlColor, opacity: 0.7, children: [
|
|
107
116
|
"(",
|
|
108
117
|
isProfitable ? "+" : "",
|
|
109
118
|
position.pnlPercent.toFixed(1),
|
|
@@ -112,53 +121,47 @@ var OptionPositionCard = React__namespace.forwardRef(
|
|
|
112
121
|
] })
|
|
113
122
|
] })
|
|
114
123
|
] }),
|
|
115
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
116
|
-
/* @__PURE__ */ jsxRuntime.jsx(GreekPill, { label: "\u0394", value: position.greeks.delta, color: "
|
|
117
|
-
/* @__PURE__ */ jsxRuntime.jsx(GreekPill, { label: "\u0393", value: position.greeks.gamma, color: "
|
|
118
|
-
/* @__PURE__ */ jsxRuntime.jsx(GreekPill, { label: "\u0398", value: position.greeks.theta, color: "
|
|
119
|
-
/* @__PURE__ */ jsxRuntime.jsx(GreekPill, { label: "\u03BD", value: position.greeks.vega, color: "
|
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { alignItems: "center", gap: 12, borderTopWidth: 1, borderColor: "var(--color-border-divider)", paddingTop: 8, children: [
|
|
125
|
+
/* @__PURE__ */ jsxRuntime.jsx(GreekPill, { label: "\u0394", value: position.greeks.delta, color: "var(--foreground)" }),
|
|
126
|
+
/* @__PURE__ */ jsxRuntime.jsx(GreekPill, { label: "\u0393", value: position.greeks.gamma, color: "var(--chart-1)" }),
|
|
127
|
+
/* @__PURE__ */ jsxRuntime.jsx(GreekPill, { label: "\u0398", value: position.greeks.theta, color: "var(--chart-4)" }),
|
|
128
|
+
/* @__PURE__ */ jsxRuntime.jsx(GreekPill, { label: "\u03BD", value: position.greeks.vega, color: "var(--chart-2)" })
|
|
120
129
|
] }),
|
|
121
|
-
(onClose || onExercise || onRoll) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
122
|
-
onClose && /* @__PURE__ */ jsxRuntime.jsx(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
type: "button",
|
|
126
|
-
onClick: () => onClose(position),
|
|
127
|
-
className: "flex-1 rounded-md bg-zinc-800 px-2 py-1 text-xs font-medium text-zinc-300 hover:bg-zinc-700 hover:text-zinc-100 transition-colors",
|
|
128
|
-
children: "Close"
|
|
129
|
-
}
|
|
130
|
-
),
|
|
131
|
-
onExercise && /* @__PURE__ */ jsxRuntime.jsx(
|
|
132
|
-
"button",
|
|
133
|
-
{
|
|
134
|
-
type: "button",
|
|
135
|
-
onClick: () => onExercise(position),
|
|
136
|
-
className: "flex-1 rounded-md bg-zinc-800 px-2 py-1 text-xs font-medium text-zinc-300 hover:bg-zinc-700 hover:text-zinc-100 transition-colors",
|
|
137
|
-
children: "Exercise"
|
|
138
|
-
}
|
|
139
|
-
),
|
|
140
|
-
onRoll && /* @__PURE__ */ jsxRuntime.jsx(
|
|
141
|
-
"button",
|
|
142
|
-
{
|
|
143
|
-
type: "button",
|
|
144
|
-
onClick: () => onRoll(position),
|
|
145
|
-
className: "flex-1 rounded-md bg-zinc-800 px-2 py-1 text-xs font-medium text-zinc-300 hover:bg-zinc-700 hover:text-zinc-100 transition-colors",
|
|
146
|
-
children: "Roll"
|
|
147
|
-
}
|
|
148
|
-
)
|
|
130
|
+
(onClose || onExercise || onRoll) && /* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { alignItems: "center", gap: 8, borderTopWidth: 1, borderColor: "var(--color-border-divider)", paddingTop: 8, children: [
|
|
131
|
+
onClose && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { onClick: () => onClose(position), children: "Close" }),
|
|
132
|
+
onExercise && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { onClick: () => onExercise(position), children: "Exercise" }),
|
|
133
|
+
onRoll && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { onClick: () => onRoll(position), children: "Roll" })
|
|
149
134
|
] })
|
|
150
135
|
]
|
|
151
136
|
}
|
|
152
137
|
);
|
|
153
138
|
}
|
|
154
139
|
);
|
|
140
|
+
function ActionButton({ onClick, children }) {
|
|
141
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
142
|
+
gui.XStack,
|
|
143
|
+
{
|
|
144
|
+
unstyled: true,
|
|
145
|
+
render: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button" }),
|
|
146
|
+
onClick,
|
|
147
|
+
flex: 1,
|
|
148
|
+
alignItems: "center",
|
|
149
|
+
justifyContent: "center",
|
|
150
|
+
borderRadius: 6,
|
|
151
|
+
borderWidth: 0,
|
|
152
|
+
paddingHorizontal: 8,
|
|
153
|
+
paddingVertical: 4,
|
|
154
|
+
backgroundColor: "var(--color-button-subtle-bg)",
|
|
155
|
+
cursor: "pointer",
|
|
156
|
+
hoverStyle: { color: "var(--color-hover)" },
|
|
157
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 12, fontWeight: "500", color: "var(--color-button-subtle-fg)", children })
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
155
161
|
function GreekPill({ label, value, color }) {
|
|
156
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
157
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
158
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
159
|
-
"font-mono tabular-nums text-[11px]",
|
|
160
|
-
value < 0 ? "text-red-400" : "text-zinc-400"
|
|
161
|
-
), children: value.toFixed(4) })
|
|
162
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { alignItems: "center", gap: 4, children: [
|
|
163
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 10, fontWeight: "600", color, children: label }),
|
|
164
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 11, style: MONO, fontVariant: ["tabular-nums"], color: value < 0 ? "var(--color-status-bad)" : "var(--color-text-secondary)", children: value.toFixed(4) })
|
|
162
165
|
] });
|
|
163
166
|
}
|
|
164
167
|
|
package/dist/option-position.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { YStack, XStack, 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 { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
5
|
|
|
7
|
-
function cn(...inputs) {
|
|
8
|
-
return twMerge(clsx(inputs));
|
|
9
|
-
}
|
|
10
6
|
function formatDate(date) {
|
|
11
7
|
const d = new Date(date);
|
|
12
8
|
return d.toLocaleDateString("en-US", { month: "short", day: "numeric" });
|
|
13
9
|
}
|
|
10
|
+
var MONO = { fontFamily: "monospace" };
|
|
14
11
|
var OptionPositionCard = React.forwardRef(
|
|
15
12
|
function OptionPositionCard2(props, ref) {
|
|
16
13
|
const {
|
|
@@ -24,64 +21,76 @@ var OptionPositionCard = React.forwardRef(
|
|
|
24
21
|
const isLong = position.quantity > 0;
|
|
25
22
|
const isCall = position.type === "call";
|
|
26
23
|
const isProfitable = position.pnl >= 0;
|
|
24
|
+
const pnlColor = isProfitable ? "var(--color-status-good)" : "var(--color-status-bad)";
|
|
27
25
|
return /* @__PURE__ */ jsxs(
|
|
28
|
-
|
|
26
|
+
YStack,
|
|
29
27
|
{
|
|
30
28
|
ref,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
),
|
|
29
|
+
gap: 8,
|
|
30
|
+
borderRadius: 8,
|
|
31
|
+
borderWidth: 1,
|
|
32
|
+
borderColor: "var(--color-border-divider)",
|
|
33
|
+
backgroundColor: "var(--card)",
|
|
34
|
+
padding: 12,
|
|
35
|
+
className,
|
|
35
36
|
...rest,
|
|
36
37
|
children: [
|
|
37
|
-
/* @__PURE__ */ jsxs(
|
|
38
|
-
/* @__PURE__ */ jsx(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
38
|
+
/* @__PURE__ */ jsxs(XStack, { alignItems: "center", justifyContent: "space-between", children: [
|
|
39
|
+
/* @__PURE__ */ jsx(XStack, { alignItems: "center", gap: 8, children: /* @__PURE__ */ jsxs(
|
|
40
|
+
XStack,
|
|
41
|
+
{
|
|
42
|
+
alignItems: "center",
|
|
43
|
+
gap: 4,
|
|
44
|
+
borderRadius: 4,
|
|
45
|
+
paddingHorizontal: 6,
|
|
46
|
+
paddingVertical: 2,
|
|
47
|
+
backgroundColor: isCall ? "var(--secondary)" : "var(--muted)",
|
|
48
|
+
children: [
|
|
49
|
+
/* @__PURE__ */ jsx(Text, { fontSize: 12, fontWeight: "600", color: isCall ? "var(--foreground)" : "var(--muted-foreground)", children: position.underlying }),
|
|
50
|
+
/* @__PURE__ */ jsx(Text, { fontSize: 12, fontWeight: "600", style: MONO, fontVariant: ["tabular-nums"], color: isCall ? "var(--foreground)" : "var(--muted-foreground)", children: position.strike }),
|
|
51
|
+
/* @__PURE__ */ jsx(Text, { fontSize: 12, fontWeight: "600", textTransform: "uppercase", color: isCall ? "var(--foreground)" : "var(--muted-foreground)", children: position.type === "call" ? "C" : "P" }),
|
|
52
|
+
/* @__PURE__ */ jsx(Text, { fontSize: 12, fontWeight: "400", color: "var(--color-text-secondary)", children: formatDate(position.expiration) })
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
) }),
|
|
56
|
+
/* @__PURE__ */ jsxs(
|
|
57
|
+
Text,
|
|
58
|
+
{
|
|
59
|
+
fontSize: 12,
|
|
60
|
+
fontWeight: "600",
|
|
61
|
+
style: MONO,
|
|
62
|
+
fontVariant: ["tabular-nums"],
|
|
63
|
+
color: isLong ? "var(--color-status-good)" : "var(--color-status-bad)",
|
|
64
|
+
children: [
|
|
65
|
+
isLong ? "+" : "",
|
|
66
|
+
position.quantity
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
)
|
|
55
70
|
] }),
|
|
56
|
-
/* @__PURE__ */ jsxs(
|
|
57
|
-
/* @__PURE__ */ jsxs(
|
|
58
|
-
/* @__PURE__ */ jsx(
|
|
59
|
-
/* @__PURE__ */ jsxs(
|
|
71
|
+
/* @__PURE__ */ jsxs(XStack, { gap: 12, children: [
|
|
72
|
+
/* @__PURE__ */ jsxs(YStack, { flex: 1, gap: 2, children: [
|
|
73
|
+
/* @__PURE__ */ jsx(Text, { fontSize: 10, textTransform: "uppercase", letterSpacing: 0.5, color: "var(--color-text-secondary)", children: "Avg Cost" }),
|
|
74
|
+
/* @__PURE__ */ jsxs(Text, { fontSize: 12, style: MONO, fontVariant: ["tabular-nums"], color: "var(--color-text-primary)", children: [
|
|
60
75
|
"$",
|
|
61
76
|
position.avgCost.toFixed(2)
|
|
62
77
|
] })
|
|
63
78
|
] }),
|
|
64
|
-
/* @__PURE__ */ jsxs(
|
|
65
|
-
/* @__PURE__ */ jsx(
|
|
66
|
-
/* @__PURE__ */ jsxs(
|
|
79
|
+
/* @__PURE__ */ jsxs(YStack, { flex: 1, gap: 2, children: [
|
|
80
|
+
/* @__PURE__ */ jsx(Text, { fontSize: 10, textTransform: "uppercase", letterSpacing: 0.5, color: "var(--color-text-secondary)", children: "Value" }),
|
|
81
|
+
/* @__PURE__ */ jsxs(Text, { fontSize: 12, style: MONO, fontVariant: ["tabular-nums"], color: "var(--color-text-primary)", children: [
|
|
67
82
|
"$",
|
|
68
83
|
position.currentValue.toFixed(2)
|
|
69
84
|
] })
|
|
70
85
|
] }),
|
|
71
|
-
/* @__PURE__ */ jsxs(
|
|
72
|
-
/* @__PURE__ */ jsx(
|
|
73
|
-
/* @__PURE__ */ jsxs(
|
|
74
|
-
/* @__PURE__ */ jsxs("
|
|
75
|
-
"font-mono tabular-nums text-xs font-semibold",
|
|
76
|
-
isProfitable ? "text-emerald-400" : "text-red-400"
|
|
77
|
-
), children: [
|
|
86
|
+
/* @__PURE__ */ jsxs(YStack, { flex: 1, gap: 2, alignItems: "flex-end", children: [
|
|
87
|
+
/* @__PURE__ */ jsx(Text, { fontSize: 10, textTransform: "uppercase", letterSpacing: 0.5, color: "var(--color-text-secondary)", children: "P/L" }),
|
|
88
|
+
/* @__PURE__ */ jsxs(XStack, { alignItems: "center", gap: 4, children: [
|
|
89
|
+
/* @__PURE__ */ jsxs(Text, { fontSize: 12, fontWeight: "600", style: MONO, fontVariant: ["tabular-nums"], color: pnlColor, children: [
|
|
78
90
|
isProfitable ? "+" : "",
|
|
79
91
|
position.pnl.toFixed(2)
|
|
80
92
|
] }),
|
|
81
|
-
/* @__PURE__ */ jsxs("
|
|
82
|
-
"font-mono tabular-nums text-[10px]",
|
|
83
|
-
isProfitable ? "text-emerald-500/70" : "text-red-500/70"
|
|
84
|
-
), children: [
|
|
93
|
+
/* @__PURE__ */ jsxs(Text, { fontSize: 10, style: MONO, fontVariant: ["tabular-nums"], color: pnlColor, opacity: 0.7, children: [
|
|
85
94
|
"(",
|
|
86
95
|
isProfitable ? "+" : "",
|
|
87
96
|
position.pnlPercent.toFixed(1),
|
|
@@ -90,53 +99,47 @@ var OptionPositionCard = React.forwardRef(
|
|
|
90
99
|
] })
|
|
91
100
|
] })
|
|
92
101
|
] }),
|
|
93
|
-
/* @__PURE__ */ jsxs(
|
|
94
|
-
/* @__PURE__ */ jsx(GreekPill, { label: "\u0394", value: position.greeks.delta, color: "
|
|
95
|
-
/* @__PURE__ */ jsx(GreekPill, { label: "\u0393", value: position.greeks.gamma, color: "
|
|
96
|
-
/* @__PURE__ */ jsx(GreekPill, { label: "\u0398", value: position.greeks.theta, color: "
|
|
97
|
-
/* @__PURE__ */ jsx(GreekPill, { label: "\u03BD", value: position.greeks.vega, color: "
|
|
102
|
+
/* @__PURE__ */ jsxs(XStack, { alignItems: "center", gap: 12, borderTopWidth: 1, borderColor: "var(--color-border-divider)", paddingTop: 8, children: [
|
|
103
|
+
/* @__PURE__ */ jsx(GreekPill, { label: "\u0394", value: position.greeks.delta, color: "var(--foreground)" }),
|
|
104
|
+
/* @__PURE__ */ jsx(GreekPill, { label: "\u0393", value: position.greeks.gamma, color: "var(--chart-1)" }),
|
|
105
|
+
/* @__PURE__ */ jsx(GreekPill, { label: "\u0398", value: position.greeks.theta, color: "var(--chart-4)" }),
|
|
106
|
+
/* @__PURE__ */ jsx(GreekPill, { label: "\u03BD", value: position.greeks.vega, color: "var(--chart-2)" })
|
|
98
107
|
] }),
|
|
99
|
-
(onClose || onExercise || onRoll) && /* @__PURE__ */ jsxs(
|
|
100
|
-
onClose && /* @__PURE__ */ jsx(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
type: "button",
|
|
104
|
-
onClick: () => onClose(position),
|
|
105
|
-
className: "flex-1 rounded-md bg-zinc-800 px-2 py-1 text-xs font-medium text-zinc-300 hover:bg-zinc-700 hover:text-zinc-100 transition-colors",
|
|
106
|
-
children: "Close"
|
|
107
|
-
}
|
|
108
|
-
),
|
|
109
|
-
onExercise && /* @__PURE__ */ jsx(
|
|
110
|
-
"button",
|
|
111
|
-
{
|
|
112
|
-
type: "button",
|
|
113
|
-
onClick: () => onExercise(position),
|
|
114
|
-
className: "flex-1 rounded-md bg-zinc-800 px-2 py-1 text-xs font-medium text-zinc-300 hover:bg-zinc-700 hover:text-zinc-100 transition-colors",
|
|
115
|
-
children: "Exercise"
|
|
116
|
-
}
|
|
117
|
-
),
|
|
118
|
-
onRoll && /* @__PURE__ */ jsx(
|
|
119
|
-
"button",
|
|
120
|
-
{
|
|
121
|
-
type: "button",
|
|
122
|
-
onClick: () => onRoll(position),
|
|
123
|
-
className: "flex-1 rounded-md bg-zinc-800 px-2 py-1 text-xs font-medium text-zinc-300 hover:bg-zinc-700 hover:text-zinc-100 transition-colors",
|
|
124
|
-
children: "Roll"
|
|
125
|
-
}
|
|
126
|
-
)
|
|
108
|
+
(onClose || onExercise || onRoll) && /* @__PURE__ */ jsxs(XStack, { alignItems: "center", gap: 8, borderTopWidth: 1, borderColor: "var(--color-border-divider)", paddingTop: 8, children: [
|
|
109
|
+
onClose && /* @__PURE__ */ jsx(ActionButton, { onClick: () => onClose(position), children: "Close" }),
|
|
110
|
+
onExercise && /* @__PURE__ */ jsx(ActionButton, { onClick: () => onExercise(position), children: "Exercise" }),
|
|
111
|
+
onRoll && /* @__PURE__ */ jsx(ActionButton, { onClick: () => onRoll(position), children: "Roll" })
|
|
127
112
|
] })
|
|
128
113
|
]
|
|
129
114
|
}
|
|
130
115
|
);
|
|
131
116
|
}
|
|
132
117
|
);
|
|
118
|
+
function ActionButton({ onClick, children }) {
|
|
119
|
+
return /* @__PURE__ */ jsx(
|
|
120
|
+
XStack,
|
|
121
|
+
{
|
|
122
|
+
unstyled: true,
|
|
123
|
+
render: /* @__PURE__ */ jsx("button", { type: "button" }),
|
|
124
|
+
onClick,
|
|
125
|
+
flex: 1,
|
|
126
|
+
alignItems: "center",
|
|
127
|
+
justifyContent: "center",
|
|
128
|
+
borderRadius: 6,
|
|
129
|
+
borderWidth: 0,
|
|
130
|
+
paddingHorizontal: 8,
|
|
131
|
+
paddingVertical: 4,
|
|
132
|
+
backgroundColor: "var(--color-button-subtle-bg)",
|
|
133
|
+
cursor: "pointer",
|
|
134
|
+
hoverStyle: { color: "var(--color-hover)" },
|
|
135
|
+
children: /* @__PURE__ */ jsx(Text, { fontSize: 12, fontWeight: "500", color: "var(--color-button-subtle-fg)", children })
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
}
|
|
133
139
|
function GreekPill({ label, value, color }) {
|
|
134
|
-
return /* @__PURE__ */ jsxs(
|
|
135
|
-
/* @__PURE__ */ jsx(
|
|
136
|
-
/* @__PURE__ */ jsx("
|
|
137
|
-
"font-mono tabular-nums text-[11px]",
|
|
138
|
-
value < 0 ? "text-red-400" : "text-zinc-400"
|
|
139
|
-
), children: value.toFixed(4) })
|
|
140
|
+
return /* @__PURE__ */ jsxs(XStack, { alignItems: "center", gap: 4, children: [
|
|
141
|
+
/* @__PURE__ */ jsx(Text, { fontSize: 10, fontWeight: "600", color, children: label }),
|
|
142
|
+
/* @__PURE__ */ jsx(Text, { fontSize: 11, style: MONO, fontVariant: ["tabular-nums"], color: value < 0 ? "var(--color-status-bad)" : "var(--color-text-secondary)", children: value.toFixed(4) })
|
|
140
143
|
] });
|
|
141
144
|
}
|
|
142
145
|
|
package/dist/pnl-diagram.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 calcLegPnl(leg, price, multiplier) {
|
|
33
29
|
const premium = leg.premium ?? 0;
|
|
34
30
|
let intrinsic;
|
|
@@ -160,19 +156,21 @@ var PnlDiagram = React__namespace.forwardRef(
|
|
|
160
156
|
chartH
|
|
161
157
|
);
|
|
162
158
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
163
|
-
|
|
159
|
+
gui.View,
|
|
164
160
|
{
|
|
165
161
|
ref,
|
|
166
|
-
|
|
162
|
+
unstyled: true,
|
|
163
|
+
width: "100%",
|
|
164
|
+
className,
|
|
167
165
|
...rest,
|
|
168
166
|
children: [
|
|
169
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
167
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.View, { unstyled: true, ref: containerRef, width: "100%", height: "100%", minHeight: 200, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
170
168
|
"svg",
|
|
171
169
|
{
|
|
172
170
|
width,
|
|
173
171
|
height,
|
|
174
172
|
viewBox: `0 0 ${width} ${height}`,
|
|
175
|
-
|
|
173
|
+
style: { userSelect: "none" },
|
|
176
174
|
onMouseMove: handleMouseMove,
|
|
177
175
|
onMouseLeave: handleMouseLeave,
|
|
178
176
|
children: [
|
|
@@ -411,16 +409,18 @@ var PnlDiagram = React__namespace.forwardRef(
|
|
|
411
409
|
]
|
|
412
410
|
}
|
|
413
411
|
) }),
|
|
414
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
415
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
416
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
417
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
412
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { flexWrap: "wrap", alignItems: "center", gap: 16, paddingHorizontal: 8, paddingTop: 4, children: [
|
|
413
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { alignItems: "center", gap: 6, children: [
|
|
414
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.View, { height: 2, width: 16, borderRadius: 4, backgroundColor: "var(--color-gray-200)" }),
|
|
415
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 10, color: "var(--color-text-secondary)", children: "Combined" })
|
|
418
416
|
] }),
|
|
419
|
-
legs.map((leg, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
417
|
+
legs.map((leg, i) => /* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { alignItems: "center", gap: 6, children: [
|
|
420
418
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
421
|
-
|
|
419
|
+
gui.View,
|
|
422
420
|
{
|
|
423
|
-
|
|
421
|
+
height: 2,
|
|
422
|
+
width: 16,
|
|
423
|
+
borderRadius: 4,
|
|
424
424
|
style: {
|
|
425
425
|
backgroundColor: LEG_COLORS[i % LEG_COLORS.length],
|
|
426
426
|
opacity: 0.6,
|
|
@@ -428,7 +428,7 @@ var PnlDiagram = React__namespace.forwardRef(
|
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
430
|
),
|
|
431
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
431
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.Text, { fontSize: 10, color: "var(--color-text-secondary)", children: [
|
|
432
432
|
leg.action === "buy" ? "B" : "S",
|
|
433
433
|
" ",
|
|
434
434
|
leg.quantity,
|
|
@@ -438,9 +438,9 @@ var PnlDiagram = React__namespace.forwardRef(
|
|
|
438
438
|
leg.type === "call" ? "C" : "P"
|
|
439
439
|
] })
|
|
440
440
|
] }, i)),
|
|
441
|
-
breakevens.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
442
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
443
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
441
|
+
breakevens.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { alignItems: "center", gap: 6, children: [
|
|
442
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.View, { width: 6, height: 6, borderRadius: 9999, style: { background: BREAKEVEN_COLOR } }),
|
|
443
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.Text, { fontSize: 10, color: "var(--color-text-secondary)", children: [
|
|
444
444
|
"BE: ",
|
|
445
445
|
breakevens.map((b) => b.toFixed(1)).join(", ")
|
|
446
446
|
] })
|