@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/pin-input.js
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { XStack, Input } 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
6
|
// src/pin-input.tsx
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
var BOX = {
|
|
8
|
+
width: 40,
|
|
9
|
+
height: 40,
|
|
10
|
+
textAlign: "center",
|
|
11
|
+
fontSize: 14,
|
|
12
|
+
fontWeight: 500,
|
|
13
|
+
borderRadius: 6,
|
|
14
|
+
borderWidth: 2,
|
|
15
|
+
borderStyle: "solid",
|
|
16
|
+
outlineWidth: 0,
|
|
17
|
+
backgroundColor: "var(--color-input-bg)",
|
|
18
|
+
color: "var(--color-input-fg)",
|
|
19
|
+
borderColor: "var(--color-input-border)",
|
|
20
|
+
hoverStyle: { borderColor: "var(--color-input-border-hover)" },
|
|
21
|
+
focusStyle: {
|
|
22
|
+
borderColor: "var(--color-input-border-focus)",
|
|
23
|
+
boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)"
|
|
24
|
+
},
|
|
25
|
+
disabledStyle: { opacity: 0.4 }
|
|
26
|
+
};
|
|
25
27
|
var PinInput = React.forwardRef(
|
|
26
28
|
function PinInput2(props, ref) {
|
|
27
29
|
const {
|
|
@@ -113,8 +115,8 @@ var PinInput = React.forwardRef(
|
|
|
113
115
|
const onKeyDownAtIndex = React.useCallback((index) => (e) => {
|
|
114
116
|
handleKeyDown(index, e);
|
|
115
117
|
}, [handleKeyDown]);
|
|
116
|
-
const
|
|
117
|
-
return /* @__PURE__ */ jsxs(
|
|
118
|
+
const boxBackground = bgColor ? `var(--color-${bgColor.replace(/\./g, "-")})` : BOX.backgroundColor;
|
|
119
|
+
return /* @__PURE__ */ jsxs(XStack, { ref: rootRef, alignItems: "center", gap: attached ? 0 : 8, className, children: [
|
|
118
120
|
/* @__PURE__ */ jsx(
|
|
119
121
|
"input",
|
|
120
122
|
{
|
|
@@ -126,9 +128,10 @@ var PinInput = React.forwardRef(
|
|
|
126
128
|
}
|
|
127
129
|
),
|
|
128
130
|
Array.from({ length: count }).map((_, index) => /* @__PURE__ */ jsx(
|
|
129
|
-
|
|
131
|
+
Input,
|
|
130
132
|
{
|
|
131
133
|
ref: setInputRef(index),
|
|
134
|
+
unstyled: true,
|
|
132
135
|
type: "text",
|
|
133
136
|
inputMode: "numeric",
|
|
134
137
|
autoComplete: otp ? "one-time-code" : "off",
|
|
@@ -137,14 +140,12 @@ var PinInput = React.forwardRef(
|
|
|
137
140
|
placeholder,
|
|
138
141
|
disabled,
|
|
139
142
|
"aria-invalid": invalid || void 0,
|
|
143
|
+
"data-invalid": invalid || void 0,
|
|
140
144
|
value: values[index] || "",
|
|
141
|
-
className:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
attached && index > 0 && "-ml-0.5"
|
|
146
|
-
),
|
|
147
|
-
style: bgStyle,
|
|
145
|
+
className: "lux-control",
|
|
146
|
+
...BOX,
|
|
147
|
+
backgroundColor: boxBackground,
|
|
148
|
+
marginLeft: attached && index > 0 ? -2 : void 0,
|
|
148
149
|
onInput: onInputAtIndex(index),
|
|
149
150
|
onKeyDown: onKeyDownAtIndex(index),
|
|
150
151
|
onPaste: handlePaste,
|
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
|
] })
|
package/dist/pnl-diagram.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { View, 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, Fragment } from 'react/jsx-runtime';
|
|
6
5
|
|
|
7
|
-
function cn(...inputs) {
|
|
8
|
-
return twMerge(clsx(inputs));
|
|
9
|
-
}
|
|
10
6
|
function calcLegPnl(leg, price, multiplier) {
|
|
11
7
|
const premium = leg.premium ?? 0;
|
|
12
8
|
let intrinsic;
|
|
@@ -138,19 +134,21 @@ var PnlDiagram = React.forwardRef(
|
|
|
138
134
|
chartH
|
|
139
135
|
);
|
|
140
136
|
return /* @__PURE__ */ jsxs(
|
|
141
|
-
|
|
137
|
+
View,
|
|
142
138
|
{
|
|
143
139
|
ref,
|
|
144
|
-
|
|
140
|
+
unstyled: true,
|
|
141
|
+
width: "100%",
|
|
142
|
+
className,
|
|
145
143
|
...rest,
|
|
146
144
|
children: [
|
|
147
|
-
/* @__PURE__ */ jsx(
|
|
145
|
+
/* @__PURE__ */ jsx(View, { unstyled: true, ref: containerRef, width: "100%", height: "100%", minHeight: 200, children: /* @__PURE__ */ jsxs(
|
|
148
146
|
"svg",
|
|
149
147
|
{
|
|
150
148
|
width,
|
|
151
149
|
height,
|
|
152
150
|
viewBox: `0 0 ${width} ${height}`,
|
|
153
|
-
|
|
151
|
+
style: { userSelect: "none" },
|
|
154
152
|
onMouseMove: handleMouseMove,
|
|
155
153
|
onMouseLeave: handleMouseLeave,
|
|
156
154
|
children: [
|
|
@@ -389,16 +387,18 @@ var PnlDiagram = React.forwardRef(
|
|
|
389
387
|
]
|
|
390
388
|
}
|
|
391
389
|
) }),
|
|
392
|
-
/* @__PURE__ */ jsxs(
|
|
393
|
-
/* @__PURE__ */ jsxs(
|
|
394
|
-
/* @__PURE__ */ jsx(
|
|
395
|
-
/* @__PURE__ */ jsx(
|
|
390
|
+
/* @__PURE__ */ jsxs(XStack, { flexWrap: "wrap", alignItems: "center", gap: 16, paddingHorizontal: 8, paddingTop: 4, children: [
|
|
391
|
+
/* @__PURE__ */ jsxs(XStack, { alignItems: "center", gap: 6, children: [
|
|
392
|
+
/* @__PURE__ */ jsx(View, { height: 2, width: 16, borderRadius: 4, backgroundColor: "var(--color-gray-200)" }),
|
|
393
|
+
/* @__PURE__ */ jsx(Text, { fontSize: 10, color: "var(--color-text-secondary)", children: "Combined" })
|
|
396
394
|
] }),
|
|
397
|
-
legs.map((leg, i) => /* @__PURE__ */ jsxs(
|
|
395
|
+
legs.map((leg, i) => /* @__PURE__ */ jsxs(XStack, { alignItems: "center", gap: 6, children: [
|
|
398
396
|
/* @__PURE__ */ jsx(
|
|
399
|
-
|
|
397
|
+
View,
|
|
400
398
|
{
|
|
401
|
-
|
|
399
|
+
height: 2,
|
|
400
|
+
width: 16,
|
|
401
|
+
borderRadius: 4,
|
|
402
402
|
style: {
|
|
403
403
|
backgroundColor: LEG_COLORS[i % LEG_COLORS.length],
|
|
404
404
|
opacity: 0.6,
|
|
@@ -406,7 +406,7 @@ var PnlDiagram = React.forwardRef(
|
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
408
|
),
|
|
409
|
-
/* @__PURE__ */ jsxs(
|
|
409
|
+
/* @__PURE__ */ jsxs(Text, { fontSize: 10, color: "var(--color-text-secondary)", children: [
|
|
410
410
|
leg.action === "buy" ? "B" : "S",
|
|
411
411
|
" ",
|
|
412
412
|
leg.quantity,
|
|
@@ -416,9 +416,9 @@ var PnlDiagram = React.forwardRef(
|
|
|
416
416
|
leg.type === "call" ? "C" : "P"
|
|
417
417
|
] })
|
|
418
418
|
] }, i)),
|
|
419
|
-
breakevens.length > 0 && /* @__PURE__ */ jsxs(
|
|
420
|
-
/* @__PURE__ */ jsx(
|
|
421
|
-
/* @__PURE__ */ jsxs(
|
|
419
|
+
breakevens.length > 0 && /* @__PURE__ */ jsxs(XStack, { alignItems: "center", gap: 6, children: [
|
|
420
|
+
/* @__PURE__ */ jsx(View, { width: 6, height: 6, borderRadius: 9999, style: { background: BREAKEVEN_COLOR } }),
|
|
421
|
+
/* @__PURE__ */ jsxs(Text, { fontSize: 10, color: "var(--color-text-secondary)", children: [
|
|
422
422
|
"BE: ",
|
|
423
423
|
breakevens.map((b) => b.toFixed(1)).join(", ")
|
|
424
424
|
] })
|
package/dist/popover.cjs
CHANGED
|
@@ -61,23 +61,19 @@ var CloseButtonFrame = gui.styled(gui.View, {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
|
-
var CLOSE_BUTTON_CLASSES = [
|
|
65
|
-
"text-[var(--closeButton-fg,currentColor)]",
|
|
66
|
-
"hover:text-[var(--hover-color,currentColor)]",
|
|
67
|
-
"disabled:opacity-40"
|
|
68
|
-
].join(" ");
|
|
69
64
|
var CloseButton = React2__namespace.forwardRef(function CloseButton2(props, ref) {
|
|
70
65
|
const { variant: _variant, size: _size, className, children, ...rest } = props;
|
|
71
66
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
72
67
|
CloseButtonFrame,
|
|
73
68
|
{
|
|
74
69
|
ref,
|
|
75
|
-
className
|
|
70
|
+
className,
|
|
76
71
|
...rest,
|
|
77
72
|
children: children ?? /* @__PURE__ */ jsxRuntime.jsx(
|
|
78
73
|
"svg",
|
|
79
74
|
{
|
|
80
|
-
|
|
75
|
+
width: 20,
|
|
76
|
+
height: 20,
|
|
81
77
|
viewBox: "0 0 20 20",
|
|
82
78
|
fill: "none",
|
|
83
79
|
"aria-hidden": "true",
|
package/dist/popover.js
CHANGED
|
@@ -39,23 +39,19 @@ var CloseButtonFrame = styled(View, {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
var CLOSE_BUTTON_CLASSES = [
|
|
43
|
-
"text-[var(--closeButton-fg,currentColor)]",
|
|
44
|
-
"hover:text-[var(--hover-color,currentColor)]",
|
|
45
|
-
"disabled:opacity-40"
|
|
46
|
-
].join(" ");
|
|
47
42
|
var CloseButton = React2.forwardRef(function CloseButton2(props, ref) {
|
|
48
43
|
const { variant: _variant, size: _size, className, children, ...rest } = props;
|
|
49
44
|
return /* @__PURE__ */ jsx(
|
|
50
45
|
CloseButtonFrame,
|
|
51
46
|
{
|
|
52
47
|
ref,
|
|
53
|
-
className
|
|
48
|
+
className,
|
|
54
49
|
...rest,
|
|
55
50
|
children: children ?? /* @__PURE__ */ jsx(
|
|
56
51
|
"svg",
|
|
57
52
|
{
|
|
58
|
-
|
|
53
|
+
width: 20,
|
|
54
|
+
height: 20,
|
|
59
55
|
viewBox: "0 0 20 20",
|
|
60
56
|
fill: "none",
|
|
61
57
|
"aria-hidden": "true",
|
package/dist/progress-circle.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
var gui = require('@hanzo/gui');
|
|
4
5
|
var React = require('react');
|
|
5
6
|
var clsx = require('clsx');
|
|
6
7
|
var tailwindMerge = require('tailwind-merge');
|
|
@@ -27,15 +28,23 @@ function _interopNamespace(e) {
|
|
|
27
28
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
29
|
|
|
29
30
|
// src/progress-circle.tsx
|
|
31
|
+
var ink = (children, Wrap = gui.Text, props = {}) => {
|
|
32
|
+
let hasText = false;
|
|
33
|
+
React.Children.forEach(children, (child) => {
|
|
34
|
+
if (typeof child === "string" || typeof child === "number") hasText = true;
|
|
35
|
+
});
|
|
36
|
+
if (!hasText) return children;
|
|
37
|
+
return React.Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? React.createElement(Wrap, props, child) : child);
|
|
38
|
+
};
|
|
30
39
|
function cn(...inputs) {
|
|
31
40
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
32
41
|
}
|
|
33
42
|
var SIZE_MAP = {
|
|
34
|
-
xs: { size: 24, thickness: 4,
|
|
35
|
-
sm: { size: 32, thickness: 5,
|
|
36
|
-
md: { size: 40, thickness: 6,
|
|
37
|
-
lg: { size: 48, thickness: 7,
|
|
38
|
-
xl: { size: 64, thickness: 8,
|
|
43
|
+
xs: { size: 24, thickness: 4, fontSize: 10 },
|
|
44
|
+
sm: { size: 32, thickness: 5, fontSize: 10 },
|
|
45
|
+
md: { size: 40, thickness: 6, fontSize: 12 },
|
|
46
|
+
lg: { size: 48, thickness: 7, fontSize: 14 },
|
|
47
|
+
xl: { size: 64, thickness: 8, fontSize: 14 }
|
|
39
48
|
};
|
|
40
49
|
var Ctx = React__namespace.createContext({
|
|
41
50
|
value: 0,
|
|
@@ -56,16 +65,18 @@ var ProgressCircleRoot = React__namespace.forwardRef(function ProgressCircleRoot
|
|
|
56
65
|
[value, size, colorPalette]
|
|
57
66
|
);
|
|
58
67
|
return /* @__PURE__ */ jsxRuntime.jsx(Ctx.Provider, { value: ctx, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
59
|
-
|
|
68
|
+
gui.View,
|
|
60
69
|
{
|
|
61
70
|
ref,
|
|
62
71
|
role: "progressbar",
|
|
63
72
|
"aria-valuenow": value ?? void 0,
|
|
64
73
|
"aria-valuemin": 0,
|
|
65
74
|
"aria-valuemax": 100,
|
|
66
|
-
|
|
75
|
+
position: "relative",
|
|
76
|
+
style: { display: "inline-flex", fontSize: 14 },
|
|
77
|
+
className,
|
|
67
78
|
...rest,
|
|
68
|
-
children
|
|
79
|
+
children: ink(children)
|
|
69
80
|
}
|
|
70
81
|
) });
|
|
71
82
|
});
|
|
@@ -84,10 +95,7 @@ var ProgressCircleRing = React__namespace.forwardRef(function ProgressCircleRing
|
|
|
84
95
|
width: size,
|
|
85
96
|
height: size,
|
|
86
97
|
viewBox: `0 0 ${size} ${size}`,
|
|
87
|
-
className: cn(
|
|
88
|
-
value === null && "animate-spin",
|
|
89
|
-
className
|
|
90
|
-
),
|
|
98
|
+
className: value === null ? cn("lux-spin", className) : className,
|
|
91
99
|
...rest,
|
|
92
100
|
children: [
|
|
93
101
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -99,7 +107,7 @@ var ProgressCircleRing = React__namespace.forwardRef(function ProgressCircleRing
|
|
|
99
107
|
fill: "transparent",
|
|
100
108
|
strokeWidth: thickness,
|
|
101
109
|
stroke: trackColor ?? "currentColor",
|
|
102
|
-
|
|
110
|
+
opacity: !trackColor ? 0.2 : void 0
|
|
103
111
|
}
|
|
104
112
|
),
|
|
105
113
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -129,20 +137,30 @@ var ProgressCircleRing = React__namespace.forwardRef(function ProgressCircleRing
|
|
|
129
137
|
var ProgressCircleValueText = React__namespace.forwardRef(function ProgressCircleValueText2(props, ref) {
|
|
130
138
|
const { className, children, ...rest } = props;
|
|
131
139
|
const { value, size: sizeKey } = React__namespace.useContext(Ctx);
|
|
132
|
-
const {
|
|
140
|
+
const { fontSize } = SIZE_MAP[sizeKey];
|
|
133
141
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
134
|
-
|
|
142
|
+
gui.View,
|
|
135
143
|
{
|
|
136
144
|
ref,
|
|
137
145
|
"aria-live": "polite",
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
146
|
+
position: "absolute",
|
|
147
|
+
top: 0,
|
|
148
|
+
left: 0,
|
|
149
|
+
right: 0,
|
|
150
|
+
bottom: 0,
|
|
151
|
+
display: "flex",
|
|
152
|
+
alignItems: "center",
|
|
153
|
+
justifyContent: "center",
|
|
154
|
+
style: {
|
|
155
|
+
fontWeight: 500,
|
|
156
|
+
fontSize,
|
|
157
|
+
lineHeight: `${fontSize}px`,
|
|
158
|
+
letterSpacing: fontSize * -0.025,
|
|
159
|
+
fontVariantNumeric: "tabular-nums"
|
|
160
|
+
},
|
|
161
|
+
className,
|
|
144
162
|
...rest,
|
|
145
|
-
children: children ?? `${Math.round(value ?? 0)}%`
|
|
163
|
+
children: ink(children ?? `${Math.round(value ?? 0)}%`)
|
|
146
164
|
}
|
|
147
165
|
);
|
|
148
166
|
});
|
|
@@ -4,27 +4,27 @@ declare const SIZE_MAP: {
|
|
|
4
4
|
readonly xs: {
|
|
5
5
|
readonly size: 24;
|
|
6
6
|
readonly thickness: 4;
|
|
7
|
-
readonly
|
|
7
|
+
readonly fontSize: 10;
|
|
8
8
|
};
|
|
9
9
|
readonly sm: {
|
|
10
10
|
readonly size: 32;
|
|
11
11
|
readonly thickness: 5;
|
|
12
|
-
readonly
|
|
12
|
+
readonly fontSize: 10;
|
|
13
13
|
};
|
|
14
14
|
readonly md: {
|
|
15
15
|
readonly size: 40;
|
|
16
16
|
readonly thickness: 6;
|
|
17
|
-
readonly
|
|
17
|
+
readonly fontSize: 12;
|
|
18
18
|
};
|
|
19
19
|
readonly lg: {
|
|
20
20
|
readonly size: 48;
|
|
21
21
|
readonly thickness: 7;
|
|
22
|
-
readonly
|
|
22
|
+
readonly fontSize: 14;
|
|
23
23
|
};
|
|
24
24
|
readonly xl: {
|
|
25
25
|
readonly size: 64;
|
|
26
26
|
readonly thickness: 8;
|
|
27
|
-
readonly
|
|
27
|
+
readonly fontSize: 14;
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
type Size = keyof typeof SIZE_MAP;
|
|
@@ -4,27 +4,27 @@ declare const SIZE_MAP: {
|
|
|
4
4
|
readonly xs: {
|
|
5
5
|
readonly size: 24;
|
|
6
6
|
readonly thickness: 4;
|
|
7
|
-
readonly
|
|
7
|
+
readonly fontSize: 10;
|
|
8
8
|
};
|
|
9
9
|
readonly sm: {
|
|
10
10
|
readonly size: 32;
|
|
11
11
|
readonly thickness: 5;
|
|
12
|
-
readonly
|
|
12
|
+
readonly fontSize: 10;
|
|
13
13
|
};
|
|
14
14
|
readonly md: {
|
|
15
15
|
readonly size: 40;
|
|
16
16
|
readonly thickness: 6;
|
|
17
|
-
readonly
|
|
17
|
+
readonly fontSize: 12;
|
|
18
18
|
};
|
|
19
19
|
readonly lg: {
|
|
20
20
|
readonly size: 48;
|
|
21
21
|
readonly thickness: 7;
|
|
22
|
-
readonly
|
|
22
|
+
readonly fontSize: 14;
|
|
23
23
|
};
|
|
24
24
|
readonly xl: {
|
|
25
25
|
readonly size: 64;
|
|
26
26
|
readonly thickness: 8;
|
|
27
|
-
readonly
|
|
27
|
+
readonly fontSize: 14;
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
type Size = keyof typeof SIZE_MAP;
|
package/dist/progress-circle.js
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { View, Text } from '@hanzo/gui';
|
|
2
3
|
import * as React from 'react';
|
|
4
|
+
import { Children, createElement } from 'react';
|
|
3
5
|
import { clsx } from 'clsx';
|
|
4
6
|
import { twMerge } from 'tailwind-merge';
|
|
5
7
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
8
|
|
|
7
9
|
// src/progress-circle.tsx
|
|
10
|
+
var ink = (children, Wrap = Text, props = {}) => {
|
|
11
|
+
let hasText = false;
|
|
12
|
+
Children.forEach(children, (child) => {
|
|
13
|
+
if (typeof child === "string" || typeof child === "number") hasText = true;
|
|
14
|
+
});
|
|
15
|
+
if (!hasText) return children;
|
|
16
|
+
return Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? createElement(Wrap, props, child) : child);
|
|
17
|
+
};
|
|
8
18
|
function cn(...inputs) {
|
|
9
19
|
return twMerge(clsx(inputs));
|
|
10
20
|
}
|
|
11
21
|
var SIZE_MAP = {
|
|
12
|
-
xs: { size: 24, thickness: 4,
|
|
13
|
-
sm: { size: 32, thickness: 5,
|
|
14
|
-
md: { size: 40, thickness: 6,
|
|
15
|
-
lg: { size: 48, thickness: 7,
|
|
16
|
-
xl: { size: 64, thickness: 8,
|
|
22
|
+
xs: { size: 24, thickness: 4, fontSize: 10 },
|
|
23
|
+
sm: { size: 32, thickness: 5, fontSize: 10 },
|
|
24
|
+
md: { size: 40, thickness: 6, fontSize: 12 },
|
|
25
|
+
lg: { size: 48, thickness: 7, fontSize: 14 },
|
|
26
|
+
xl: { size: 64, thickness: 8, fontSize: 14 }
|
|
17
27
|
};
|
|
18
28
|
var Ctx = React.createContext({
|
|
19
29
|
value: 0,
|
|
@@ -34,16 +44,18 @@ var ProgressCircleRoot = React.forwardRef(function ProgressCircleRoot2(props, re
|
|
|
34
44
|
[value, size, colorPalette]
|
|
35
45
|
);
|
|
36
46
|
return /* @__PURE__ */ jsx(Ctx.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
|
|
37
|
-
|
|
47
|
+
View,
|
|
38
48
|
{
|
|
39
49
|
ref,
|
|
40
50
|
role: "progressbar",
|
|
41
51
|
"aria-valuenow": value ?? void 0,
|
|
42
52
|
"aria-valuemin": 0,
|
|
43
53
|
"aria-valuemax": 100,
|
|
44
|
-
|
|
54
|
+
position: "relative",
|
|
55
|
+
style: { display: "inline-flex", fontSize: 14 },
|
|
56
|
+
className,
|
|
45
57
|
...rest,
|
|
46
|
-
children
|
|
58
|
+
children: ink(children)
|
|
47
59
|
}
|
|
48
60
|
) });
|
|
49
61
|
});
|
|
@@ -62,10 +74,7 @@ var ProgressCircleRing = React.forwardRef(function ProgressCircleRing2(props, re
|
|
|
62
74
|
width: size,
|
|
63
75
|
height: size,
|
|
64
76
|
viewBox: `0 0 ${size} ${size}`,
|
|
65
|
-
className: cn(
|
|
66
|
-
value === null && "animate-spin",
|
|
67
|
-
className
|
|
68
|
-
),
|
|
77
|
+
className: value === null ? cn("lux-spin", className) : className,
|
|
69
78
|
...rest,
|
|
70
79
|
children: [
|
|
71
80
|
/* @__PURE__ */ jsx(
|
|
@@ -77,7 +86,7 @@ var ProgressCircleRing = React.forwardRef(function ProgressCircleRing2(props, re
|
|
|
77
86
|
fill: "transparent",
|
|
78
87
|
strokeWidth: thickness,
|
|
79
88
|
stroke: trackColor ?? "currentColor",
|
|
80
|
-
|
|
89
|
+
opacity: !trackColor ? 0.2 : void 0
|
|
81
90
|
}
|
|
82
91
|
),
|
|
83
92
|
/* @__PURE__ */ jsx(
|
|
@@ -107,20 +116,30 @@ var ProgressCircleRing = React.forwardRef(function ProgressCircleRing2(props, re
|
|
|
107
116
|
var ProgressCircleValueText = React.forwardRef(function ProgressCircleValueText2(props, ref) {
|
|
108
117
|
const { className, children, ...rest } = props;
|
|
109
118
|
const { value, size: sizeKey } = React.useContext(Ctx);
|
|
110
|
-
const {
|
|
119
|
+
const { fontSize } = SIZE_MAP[sizeKey];
|
|
111
120
|
return /* @__PURE__ */ jsx(
|
|
112
|
-
|
|
121
|
+
View,
|
|
113
122
|
{
|
|
114
123
|
ref,
|
|
115
124
|
"aria-live": "polite",
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
125
|
+
position: "absolute",
|
|
126
|
+
top: 0,
|
|
127
|
+
left: 0,
|
|
128
|
+
right: 0,
|
|
129
|
+
bottom: 0,
|
|
130
|
+
display: "flex",
|
|
131
|
+
alignItems: "center",
|
|
132
|
+
justifyContent: "center",
|
|
133
|
+
style: {
|
|
134
|
+
fontWeight: 500,
|
|
135
|
+
fontSize,
|
|
136
|
+
lineHeight: `${fontSize}px`,
|
|
137
|
+
letterSpacing: fontSize * -0.025,
|
|
138
|
+
fontVariantNumeric: "tabular-nums"
|
|
139
|
+
},
|
|
140
|
+
className,
|
|
122
141
|
...rest,
|
|
123
|
-
children: children ?? `${Math.round(value ?? 0)}%`
|
|
142
|
+
children: ink(children ?? `${Math.round(value ?? 0)}%`)
|
|
124
143
|
}
|
|
125
144
|
);
|
|
126
145
|
});
|