@luxfi/ui 7.4.12 → 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/avatar.cjs +0 -1
- package/dist/avatar.js +0 -1
- package/dist/index.cjs +320 -208
- package/dist/index.js +320 -208
- package/dist/input-group.cjs +36 -19
- package/dist/input-group.js +37 -19
- package/dist/pin-input.cjs +30 -29
- package/dist/pin-input.js +30 -29
- 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/radio.cjs +0 -1
- package/dist/radio.js +0 -1
- package/dist/rating.cjs +15 -17
- package/dist/rating.js +15 -17
- package/dist/slider.cjs +0 -1
- package/dist/slider.js +0 -1
- package/dist/strategy-builder.cjs +194 -115
- package/dist/strategy-builder.js +194 -115
- package/dist/tag.cjs +18 -15
- package/dist/tag.js +18 -15
- package/package.json +1 -1
- package/src/avatar.tsx +1 -2
- package/src/expiration-selector.tsx +6 -6
- package/src/input-group.tsx +2 -2
- package/src/option-position.tsx +9 -2
- package/src/progress-circle.tsx +52 -28
- package/src/radio.tsx +0 -1
- package/src/rating.tsx +22 -20
- package/src/slider.tsx +0 -1
- package/src/strategy-builder.tsx +51 -42
|
@@ -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 findATM(strikes, spot) {
|
|
33
29
|
if (strikes.length === 0) return spot;
|
|
34
30
|
return strikes.reduce(
|
|
@@ -137,84 +133,145 @@ var STRATEGY_PRESETS = [
|
|
|
137
133
|
]
|
|
138
134
|
}
|
|
139
135
|
];
|
|
136
|
+
var MONO = "monospace";
|
|
137
|
+
var CONTROL_BOX = {
|
|
138
|
+
backgroundColor: "var(--color-input-bg)",
|
|
139
|
+
borderWidth: 1,
|
|
140
|
+
borderColor: "var(--color-input-border)",
|
|
141
|
+
outlineWidth: 0,
|
|
142
|
+
focusStyle: { borderColor: "var(--color-input-border-focus)" }
|
|
143
|
+
};
|
|
144
|
+
var CONTROL_INK = { color: "var(--color-input-fg)" };
|
|
140
145
|
function LegRow({ leg, index, strikes, expirations, removable, onChange, onRemove }) {
|
|
141
146
|
const update = (patch) => {
|
|
142
147
|
onChange(index, { ...leg, ...patch });
|
|
143
148
|
};
|
|
144
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
"
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
150
|
+
gui.XStack,
|
|
151
|
+
{
|
|
152
|
+
alignItems: "center",
|
|
153
|
+
gap: 8,
|
|
154
|
+
borderRadius: 6,
|
|
155
|
+
backgroundColor: "var(--color-tag-subtle-bg)",
|
|
156
|
+
paddingHorizontal: 8,
|
|
157
|
+
paddingVertical: 6,
|
|
158
|
+
children: [
|
|
159
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 10, style: { fontFamily: MONO }, flexShrink: 0, width: 16, color: "var(--color-text-secondary)", children: index + 1 }),
|
|
160
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
161
|
+
gui.XStack,
|
|
162
|
+
{
|
|
163
|
+
unstyled: true,
|
|
164
|
+
render: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button" }),
|
|
165
|
+
onClick: () => update({ action: leg.action === "buy" ? "sell" : "buy" }),
|
|
166
|
+
paddingHorizontal: 8,
|
|
167
|
+
paddingVertical: 2,
|
|
168
|
+
borderRadius: 4,
|
|
169
|
+
borderWidth: 0,
|
|
170
|
+
cursor: "pointer",
|
|
171
|
+
transition: "quick",
|
|
172
|
+
backgroundColor: leg.action === "buy" ? "color-mix(in srgb, var(--color-status-good) 20%, transparent)" : "color-mix(in srgb, var(--color-status-bad) 20%, transparent)",
|
|
173
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 12, fontWeight: "600", color: leg.action === "buy" ? "var(--color-status-good)" : "var(--color-status-bad)", children: leg.action === "buy" ? "BUY" : "SELL" })
|
|
174
|
+
}
|
|
153
175
|
),
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
176
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
177
|
+
gui.XStack,
|
|
178
|
+
{
|
|
179
|
+
unstyled: true,
|
|
180
|
+
render: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button" }),
|
|
181
|
+
onClick: () => update({ type: leg.type === "call" ? "put" : "call" }),
|
|
182
|
+
paddingHorizontal: 8,
|
|
183
|
+
paddingVertical: 2,
|
|
184
|
+
borderRadius: 4,
|
|
185
|
+
borderWidth: 0,
|
|
186
|
+
cursor: "pointer",
|
|
187
|
+
transition: "quick",
|
|
188
|
+
backgroundColor: leg.type === "call" ? "var(--secondary)" : "var(--muted)",
|
|
189
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 12, fontWeight: "500", color: leg.type === "call" ? "var(--foreground)" : "var(--muted-foreground)", children: leg.type === "call" ? "CALL" : "PUT" })
|
|
190
|
+
}
|
|
166
191
|
),
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
192
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
193
|
+
gui.View,
|
|
194
|
+
{
|
|
195
|
+
unstyled: true,
|
|
196
|
+
render: /* @__PURE__ */ jsxRuntime.jsx("select", { value: leg.strike, onChange: (e) => update({ strike: Number(e.target.value) }) }),
|
|
197
|
+
...CONTROL_BOX,
|
|
198
|
+
borderRadius: 4,
|
|
199
|
+
paddingHorizontal: 6,
|
|
200
|
+
paddingVertical: 2,
|
|
201
|
+
minWidth: 72,
|
|
202
|
+
style: { ...CONTROL_INK, fontFamily: MONO, fontSize: 12 },
|
|
203
|
+
children: strikes.map((s) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: s, children: s.toFixed(2) }, s))
|
|
204
|
+
}
|
|
205
|
+
),
|
|
206
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
207
|
+
gui.View,
|
|
208
|
+
{
|
|
209
|
+
unstyled: true,
|
|
210
|
+
render: /* @__PURE__ */ jsxRuntime.jsx("select", { value: leg.expiration, onChange: (e) => update({ expiration: e.target.value }) }),
|
|
211
|
+
...CONTROL_BOX,
|
|
212
|
+
borderRadius: 4,
|
|
213
|
+
paddingHorizontal: 6,
|
|
214
|
+
paddingVertical: 2,
|
|
215
|
+
minWidth: 80,
|
|
216
|
+
style: { ...CONTROL_INK, fontSize: 12 },
|
|
217
|
+
children: expirations.map((exp) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: exp, children: exp }, exp))
|
|
218
|
+
}
|
|
219
|
+
),
|
|
220
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
221
|
+
gui.View,
|
|
222
|
+
{
|
|
223
|
+
unstyled: true,
|
|
224
|
+
render: /* @__PURE__ */ jsxRuntime.jsx(
|
|
225
|
+
"input",
|
|
226
|
+
{
|
|
227
|
+
type: "number",
|
|
228
|
+
min: 1,
|
|
229
|
+
max: 999,
|
|
230
|
+
value: leg.quantity,
|
|
231
|
+
onChange: (e) => update({ quantity: Math.max(1, parseInt(e.target.value, 10) || 1) })
|
|
232
|
+
}
|
|
233
|
+
),
|
|
234
|
+
...CONTROL_BOX,
|
|
235
|
+
borderRadius: 4,
|
|
236
|
+
paddingHorizontal: 6,
|
|
237
|
+
paddingVertical: 2,
|
|
238
|
+
width: 48,
|
|
239
|
+
style: { ...CONTROL_INK, fontFamily: MONO, fontSize: 12, textAlign: "center" }
|
|
240
|
+
}
|
|
241
|
+
),
|
|
242
|
+
leg.premium !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
243
|
+
gui.Text,
|
|
244
|
+
{
|
|
245
|
+
fontSize: 12,
|
|
246
|
+
style: { fontFamily: MONO },
|
|
247
|
+
fontVariant: ["tabular-nums"],
|
|
248
|
+
marginLeft: "auto",
|
|
249
|
+
color: leg.premium >= 0 ? "var(--color-status-good)" : "var(--color-status-bad)",
|
|
250
|
+
children: [
|
|
251
|
+
leg.premium >= 0 ? "+" : "",
|
|
252
|
+
leg.premium.toFixed(2)
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
),
|
|
256
|
+
removable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
257
|
+
gui.XStack,
|
|
258
|
+
{
|
|
259
|
+
unstyled: true,
|
|
260
|
+
render: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", "aria-label": "Remove leg" }),
|
|
261
|
+
onClick: () => onRemove(index),
|
|
262
|
+
marginLeft: "auto",
|
|
263
|
+
padding: 2,
|
|
264
|
+
borderWidth: 0,
|
|
265
|
+
cursor: "pointer",
|
|
266
|
+
transition: "quick",
|
|
267
|
+
style: { color: "var(--color-text-secondary)" },
|
|
268
|
+
hoverStyle: { opacity: 0.7 },
|
|
269
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: 14, height: 14, viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) })
|
|
270
|
+
}
|
|
271
|
+
)
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
);
|
|
218
275
|
}
|
|
219
276
|
var StrategyBuilder = React__namespace.forwardRef(
|
|
220
277
|
function StrategyBuilder2(props, ref) {
|
|
@@ -284,37 +341,46 @@ var StrategyBuilder = React__namespace.forwardRef(
|
|
|
284
341
|
});
|
|
285
342
|
}, [onSubmit, strategyType, legs, netPremium]);
|
|
286
343
|
const currentPreset = STRATEGY_PRESETS.find((p) => p.value === strategyType);
|
|
344
|
+
const netColor = netPremium > 0 ? "var(--color-status-good)" : netPremium < 0 ? "var(--color-status-bad)" : "var(--color-text-secondary)";
|
|
287
345
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
288
|
-
|
|
346
|
+
gui.YStack,
|
|
289
347
|
{
|
|
290
348
|
ref,
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
),
|
|
349
|
+
gap: 12,
|
|
350
|
+
borderRadius: 8,
|
|
351
|
+
borderWidth: 1,
|
|
352
|
+
borderColor: "var(--color-border-divider)",
|
|
353
|
+
backgroundColor: "var(--card)",
|
|
354
|
+
padding: 12,
|
|
355
|
+
className,
|
|
295
356
|
...rest,
|
|
296
357
|
children: [
|
|
297
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
298
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
299
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
300
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
358
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { alignItems: "center", justifyContent: "space-between", gap: 12, children: [
|
|
359
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { alignItems: "center", gap: 8, children: [
|
|
360
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 12, fontWeight: "600", textTransform: "uppercase", letterSpacing: 0.6, color: "var(--color-text-secondary)", children: "Strategy" }),
|
|
361
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 14, fontWeight: "500", color: "var(--color-text-primary)", children: underlying })
|
|
301
362
|
] }),
|
|
302
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
363
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.Text, { fontSize: 10, color: "var(--color-text-secondary)", children: [
|
|
303
364
|
"Spot: ",
|
|
304
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
365
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { style: { fontFamily: MONO }, fontVariant: ["tabular-nums"], color: "var(--color-text-primary)", children: spotPrice.toFixed(2) })
|
|
305
366
|
] })
|
|
306
367
|
] }),
|
|
307
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
308
|
-
|
|
368
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.XStack, { alignItems: "center", gap: 8, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
369
|
+
gui.View,
|
|
309
370
|
{
|
|
310
|
-
|
|
311
|
-
onChange: handleStrategyChange,
|
|
312
|
-
|
|
371
|
+
unstyled: true,
|
|
372
|
+
render: /* @__PURE__ */ jsxRuntime.jsx("select", { value: strategyType, onChange: handleStrategyChange }),
|
|
373
|
+
flex: 1,
|
|
374
|
+
...CONTROL_BOX,
|
|
375
|
+
borderRadius: 6,
|
|
376
|
+
paddingHorizontal: 10,
|
|
377
|
+
paddingVertical: 6,
|
|
378
|
+
style: { ...CONTROL_INK, fontSize: 14 },
|
|
313
379
|
children: STRATEGY_PRESETS.map((preset) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: preset.value, children: preset.label }, preset.value))
|
|
314
380
|
}
|
|
315
381
|
) }),
|
|
316
|
-
currentPreset && /* @__PURE__ */ jsxRuntime.jsx(
|
|
317
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
382
|
+
currentPreset && /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 11, marginTop: -4, color: "var(--color-text-secondary)", children: currentPreset.description }),
|
|
383
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { gap: 6, children: legs.map((leg, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
318
384
|
LegRow,
|
|
319
385
|
{
|
|
320
386
|
leg,
|
|
@@ -328,40 +394,53 @@ var StrategyBuilder = React__namespace.forwardRef(
|
|
|
328
394
|
i
|
|
329
395
|
)) }),
|
|
330
396
|
strategyType === "custom" && legs.length < 4 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
331
|
-
|
|
397
|
+
gui.XStack,
|
|
332
398
|
{
|
|
333
|
-
|
|
399
|
+
unstyled: true,
|
|
400
|
+
render: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button" }),
|
|
334
401
|
onClick: handleAddLeg,
|
|
335
|
-
|
|
402
|
+
alignItems: "center",
|
|
403
|
+
justifyContent: "center",
|
|
404
|
+
gap: 4,
|
|
405
|
+
borderRadius: 6,
|
|
406
|
+
borderWidth: 1,
|
|
407
|
+
paddingVertical: 4,
|
|
408
|
+
cursor: "pointer",
|
|
409
|
+
transition: "quick",
|
|
410
|
+
borderColor: "var(--color-border-divider)",
|
|
411
|
+
hoverStyle: { borderColor: "var(--color-hover)" },
|
|
412
|
+
style: { color: "var(--color-text-secondary)", borderStyle: "dashed" },
|
|
336
413
|
children: [
|
|
337
|
-
/* @__PURE__ */ jsxRuntime.jsx("svg", {
|
|
338
|
-
"Add Leg"
|
|
414
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: 12, height: 12, viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 5v14M5 12h14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }),
|
|
415
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 12, color: "var(--color-text-secondary)", children: "Add Leg" })
|
|
339
416
|
]
|
|
340
417
|
}
|
|
341
418
|
),
|
|
342
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
343
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
344
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
345
|
-
/* @__PURE__ */ jsxRuntime.jsxs("
|
|
346
|
-
"font-mono tabular-nums text-sm font-semibold",
|
|
347
|
-
netPremium > 0 ? "text-emerald-400" : netPremium < 0 ? "text-red-400" : "text-zinc-400"
|
|
348
|
-
), children: [
|
|
419
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { alignItems: "center", justifyContent: "space-between", paddingTop: 4, borderTopWidth: 1, borderColor: "var(--color-border-divider)", children: [
|
|
420
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { alignItems: "center", gap: 8, children: [
|
|
421
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 12, color: "var(--color-text-secondary)", children: "Net:" }),
|
|
422
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.Text, { fontSize: 14, fontWeight: "600", style: { fontFamily: MONO }, fontVariant: ["tabular-nums"], color: netColor, children: [
|
|
349
423
|
netPremium > 0 ? "Credit " : netPremium < 0 ? "Debit " : "",
|
|
350
424
|
netPremium !== 0 ? `$${Math.abs(netPremium).toFixed(2)}` : "-"
|
|
351
425
|
] })
|
|
352
426
|
] }),
|
|
353
427
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
354
|
-
|
|
428
|
+
gui.XStack,
|
|
355
429
|
{
|
|
356
|
-
|
|
430
|
+
unstyled: true,
|
|
431
|
+
render: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button" }),
|
|
357
432
|
onClick: handleSubmit,
|
|
358
433
|
disabled: legs.length === 0,
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
434
|
+
paddingHorizontal: 16,
|
|
435
|
+
paddingVertical: 6,
|
|
436
|
+
borderRadius: 6,
|
|
437
|
+
borderWidth: 0,
|
|
438
|
+
cursor: "pointer",
|
|
439
|
+
transition: "quick",
|
|
440
|
+
backgroundColor: "var(--color-button-solid-bg)",
|
|
441
|
+
hoverStyle: { backgroundColor: "var(--color-hover)" },
|
|
442
|
+
disabledStyle: { opacity: 0.4, cursor: "not-allowed" },
|
|
443
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: 12, fontWeight: "600", color: "var(--color-button-solid-text)", children: "Review Order" })
|
|
365
444
|
}
|
|
366
445
|
)
|
|
367
446
|
] })
|