@luxfi/ui 6.1.3 → 7.1.0
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 +213 -0
- package/dist/accordion.d.cts +74 -0
- package/dist/accordion.d.ts +74 -0
- package/dist/accordion.js +186 -0
- package/dist/alert.cjs +430 -0
- package/dist/alert.d.cts +30 -0
- package/dist/alert.d.ts +30 -0
- package/dist/alert.js +408 -0
- package/dist/avatar.cjs +149 -0
- package/dist/avatar.d.cts +25 -0
- package/dist/avatar.d.ts +25 -0
- package/dist/avatar.js +125 -0
- package/dist/badge.cjs +452 -0
- package/dist/badge.d.cts +19 -0
- package/dist/badge.d.ts +19 -0
- package/dist/badge.js +431 -0
- package/dist/bank.cjs +272 -0
- package/dist/bank.d.cts +76 -0
- package/dist/bank.d.ts +76 -0
- package/dist/bank.js +258 -0
- package/dist/button.cjs +578 -0
- package/dist/button.d.cts +55 -0
- package/dist/button.d.ts +55 -0
- package/dist/button.js +553 -0
- package/dist/checkbox.cjs +265 -0
- package/dist/checkbox.d.cts +31 -0
- package/dist/checkbox.d.ts +31 -0
- package/dist/checkbox.js +241 -0
- package/dist/close-button.cjs +92 -0
- package/dist/close-button.d.cts +9 -0
- package/dist/close-button.d.ts +9 -0
- package/dist/close-button.js +70 -0
- package/dist/collapsible.cjs +555 -0
- package/dist/collapsible.d.cts +23 -0
- package/dist/collapsible.d.ts +23 -0
- package/dist/collapsible.js +532 -0
- package/dist/color-mode.cjs +96 -0
- package/dist/color-mode.d.cts +25 -0
- package/dist/color-mode.d.ts +25 -0
- package/dist/color-mode.js +72 -0
- package/dist/dialog.cjs +295 -0
- package/dist/dialog.d.cts +65 -0
- package/dist/dialog.d.ts +65 -0
- package/dist/dialog.js +263 -0
- package/dist/drawer.cjs +231 -0
- package/dist/drawer.d.cts +36 -0
- package/dist/drawer.d.ts +36 -0
- package/dist/drawer.js +199 -0
- package/dist/empty-state.cjs +93 -0
- package/dist/empty-state.d.cts +13 -0
- package/dist/empty-state.d.ts +13 -0
- package/dist/empty-state.js +71 -0
- package/dist/expiration-selector.cjs +138 -0
- package/dist/expiration-selector.d.cts +16 -0
- package/dist/expiration-selector.d.ts +16 -0
- package/dist/expiration-selector.js +116 -0
- package/dist/field.cjs +183 -0
- package/dist/field.d.cts +24 -0
- package/dist/field.d.ts +24 -0
- package/dist/field.js +160 -0
- package/dist/greeks-display.cjs +114 -0
- package/dist/greeks-display.d.cts +14 -0
- package/dist/greeks-display.d.ts +14 -0
- package/dist/greeks-display.js +92 -0
- package/dist/heading.cjs +41 -0
- package/dist/heading.d.cts +10 -0
- package/dist/heading.d.ts +10 -0
- package/dist/heading.js +35 -0
- package/dist/icon-button.cjs +367 -0
- package/dist/icon-button.d.cts +33 -0
- package/dist/icon-button.d.ts +33 -0
- package/dist/icon-button.js +345 -0
- package/dist/image.cjs +425 -0
- package/dist/image.d.cts +57 -0
- package/dist/image.d.ts +57 -0
- package/dist/image.js +404 -0
- package/dist/index.cjs +7220 -0
- package/dist/index.d.cts +55 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +7043 -0
- package/dist/input-group.cjs +155 -0
- package/dist/input-group.d.cts +17 -0
- package/dist/input-group.d.ts +17 -0
- package/dist/input-group.js +133 -0
- package/dist/input.cjs +65 -0
- package/dist/input.d.cts +11 -0
- package/dist/input.d.ts +11 -0
- package/dist/input.js +59 -0
- package/dist/link.cjs +483 -0
- package/dist/link.d.cts +37 -0
- package/dist/link.d.ts +37 -0
- package/dist/link.js +459 -0
- package/dist/menu.cjs +305 -0
- package/dist/menu.d.cts +84 -0
- package/dist/menu.d.ts +84 -0
- package/dist/menu.js +269 -0
- package/dist/option-chain.cjs +221 -0
- package/dist/option-chain.d.cts +37 -0
- package/dist/option-chain.d.ts +37 -0
- package/dist/option-chain.js +199 -0
- package/dist/option-position.cjs +164 -0
- package/dist/option-position.d.cts +29 -0
- package/dist/option-position.d.ts +29 -0
- package/dist/option-position.js +142 -0
- package/dist/pin-input.cjs +182 -0
- package/dist/pin-input.d.cts +25 -0
- package/dist/pin-input.d.ts +25 -0
- package/dist/pin-input.js +160 -0
- package/dist/pnl-diagram.cjs +453 -0
- package/dist/pnl-diagram.d.cts +11 -0
- package/dist/pnl-diagram.d.ts +11 -0
- package/dist/pnl-diagram.js +431 -0
- package/dist/popover.cjs +342 -0
- package/dist/popover.d.cts +73 -0
- package/dist/popover.d.ts +73 -0
- package/dist/popover.js +310 -0
- package/dist/progress-circle.cjs +152 -0
- package/dist/progress-circle.d.cts +47 -0
- package/dist/progress-circle.d.ts +47 -0
- package/dist/progress-circle.js +128 -0
- package/dist/progress.cjs +117 -0
- package/dist/progress.d.cts +28 -0
- package/dist/progress.d.ts +28 -0
- package/dist/progress.js +94 -0
- package/dist/provider.cjs +62 -0
- package/dist/provider.d.cts +7 -0
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +40 -0
- package/dist/radio.cjs +177 -0
- package/dist/radio.d.cts +53 -0
- package/dist/radio.d.ts +53 -0
- package/dist/radio.js +153 -0
- package/dist/rating.cjs +80 -0
- package/dist/rating.d.cts +14 -0
- package/dist/rating.d.ts +14 -0
- package/dist/rating.js +58 -0
- package/dist/select.cjs +644 -0
- package/dist/select.d.cts +130 -0
- package/dist/select.d.ts +130 -0
- package/dist/select.js +610 -0
- package/dist/separator.cjs +57 -0
- package/dist/separator.d.cts +13 -0
- package/dist/separator.d.ts +13 -0
- package/dist/separator.js +51 -0
- package/dist/skeleton.cjs +223 -0
- package/dist/skeleton.d.cts +60 -0
- package/dist/skeleton.d.ts +60 -0
- package/dist/skeleton.js +199 -0
- package/dist/slider.cjs +138 -0
- package/dist/slider.d.cts +24 -0
- package/dist/slider.d.ts +24 -0
- package/dist/slider.js +115 -0
- package/dist/strategy-builder.cjs +373 -0
- package/dist/strategy-builder.d.cts +26 -0
- package/dist/strategy-builder.d.ts +26 -0
- package/dist/strategy-builder.js +351 -0
- package/dist/switch.cjs +163 -0
- package/dist/switch.d.cts +27 -0
- package/dist/switch.d.ts +27 -0
- package/dist/switch.js +140 -0
- package/dist/table.cjs +897 -0
- package/dist/table.d.cts +107 -0
- package/dist/table.d.ts +107 -0
- package/dist/table.js +866 -0
- package/dist/tabs.cjs +240 -0
- package/dist/tabs.d.cts +78 -0
- package/dist/tabs.d.ts +78 -0
- package/dist/tabs.js +213 -0
- package/dist/tag.cjs +529 -0
- package/dist/tag.d.cts +21 -0
- package/dist/tag.d.ts +21 -0
- package/dist/tag.js +507 -0
- package/dist/textarea.cjs +65 -0
- package/dist/textarea.d.cts +11 -0
- package/dist/textarea.d.ts +11 -0
- package/dist/textarea.js +59 -0
- package/dist/toaster.cjs +99 -0
- package/dist/toaster.d.cts +29 -0
- package/dist/toaster.d.ts +29 -0
- package/dist/toaster.js +96 -0
- package/dist/tooltip.cjs +172 -0
- package/dist/tooltip.d.cts +38 -0
- package/dist/tooltip.d.ts +38 -0
- package/dist/tooltip.js +150 -0
- package/dist/utils.cjs +11 -0
- package/dist/utils.d.cts +5 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +9 -0
- package/package.json +284 -89
- package/src/accordion.tsx +285 -0
- package/src/alert.tsx +221 -0
- package/src/avatar.tsx +174 -0
- package/src/badge.tsx +147 -0
- package/src/bank.tsx +325 -0
- package/src/button.tsx +477 -0
- package/src/checkbox.tsx +307 -0
- package/src/close-button.tsx +77 -0
- package/src/collapsible.tsx +126 -0
- package/src/color-mode.tsx +125 -0
- package/src/dialog.tsx +346 -0
- package/src/drawer.tsx +186 -0
- package/src/empty-state.tsx +97 -0
- package/src/expiration-selector.tsx +163 -0
- package/src/field.tsx +202 -0
- package/src/greeks-display.tsx +138 -0
- package/src/heading.tsx +44 -0
- package/src/icon-button.tsx +217 -0
- package/src/image.tsx +280 -0
- package/src/index.ts +267 -138
- package/src/input-group.tsx +159 -0
- package/src/input.tsx +60 -0
- package/src/link.tsx +326 -0
- package/src/menu.tsx +471 -0
- package/src/option-chain.tsx +261 -0
- package/src/option-position.tsx +200 -0
- package/src/pin-input.tsx +187 -0
- package/src/pnl-diagram.tsx +458 -0
- package/src/popover.tsx +386 -0
- package/src/progress-circle.tsx +180 -0
- package/src/progress.tsx +109 -0
- package/src/provider.tsx +12 -0
- package/src/radio.tsx +175 -0
- package/src/rating.tsx +79 -0
- package/src/select.tsx +696 -0
- package/src/separator.tsx +59 -0
- package/src/skeleton.tsx +254 -0
- package/src/slider.tsx +152 -0
- package/src/strategy-builder.tsx +466 -0
- package/src/switch.tsx +158 -0
- package/src/table.tsx +621 -0
- package/src/tabs.tsx +354 -0
- package/src/tag.tsx +159 -0
- package/src/textarea.tsx +60 -0
- package/src/toaster.tsx +117 -0
- package/src/tokens.css +438 -0
- package/src/tooltip.tsx +191 -0
- package/src/utils/cn.ts +7 -0
- package/src/utils.ts +6 -0
- package/tokens.css +438 -0
- package/LICENSE +0 -122
- package/README.md +0 -109
package/dist/button.js
ADDED
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { styled, View } from '@hanzogui/core';
|
|
3
|
+
import * as React2 from 'react';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import { twMerge } from 'tailwind-merge';
|
|
6
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
// src/button.tsx
|
|
9
|
+
function cn(...inputs) {
|
|
10
|
+
return twMerge(clsx(inputs));
|
|
11
|
+
}
|
|
12
|
+
var SHIM_PROPS = [
|
|
13
|
+
"w",
|
|
14
|
+
"h",
|
|
15
|
+
"minW",
|
|
16
|
+
"maxW",
|
|
17
|
+
"display",
|
|
18
|
+
"flexGrow",
|
|
19
|
+
"flexShrink",
|
|
20
|
+
"flexBasis",
|
|
21
|
+
"fontWeight",
|
|
22
|
+
"textStyle",
|
|
23
|
+
"borderRadius",
|
|
24
|
+
"alignSelf",
|
|
25
|
+
"alignItems",
|
|
26
|
+
"justifyContent",
|
|
27
|
+
"color",
|
|
28
|
+
"mt",
|
|
29
|
+
"mb",
|
|
30
|
+
"ml",
|
|
31
|
+
"mr",
|
|
32
|
+
"height",
|
|
33
|
+
"overflow",
|
|
34
|
+
"whiteSpace",
|
|
35
|
+
"textOverflow",
|
|
36
|
+
"textTransform",
|
|
37
|
+
"gap",
|
|
38
|
+
"gridTemplateColumns",
|
|
39
|
+
"minWidth",
|
|
40
|
+
"boxSize",
|
|
41
|
+
"py",
|
|
42
|
+
"px",
|
|
43
|
+
"p",
|
|
44
|
+
"hideBelow",
|
|
45
|
+
"fontSize",
|
|
46
|
+
"flexWrap",
|
|
47
|
+
"wordBreak",
|
|
48
|
+
"lineHeight",
|
|
49
|
+
"marginRight",
|
|
50
|
+
"position",
|
|
51
|
+
"background"
|
|
52
|
+
];
|
|
53
|
+
var S = 4;
|
|
54
|
+
function dim(v) {
|
|
55
|
+
if (v == null) return void 0;
|
|
56
|
+
if (typeof v === "number") return `${v * S}px`;
|
|
57
|
+
if (typeof v === "string") return v;
|
|
58
|
+
if (typeof v === "object") {
|
|
59
|
+
const o = v;
|
|
60
|
+
return o.base ?? o.lg ?? o.xl ?? Object.values(o)[0];
|
|
61
|
+
}
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
function sp(v) {
|
|
65
|
+
if (v === void 0) return void 0;
|
|
66
|
+
return typeof v === "number" ? `${v * S}px` : v;
|
|
67
|
+
}
|
|
68
|
+
function shimToStyle(props) {
|
|
69
|
+
const s = {};
|
|
70
|
+
if (props.w !== void 0) s.width = dim(props.w);
|
|
71
|
+
if (props.h !== void 0) s.height = dim(props.h);
|
|
72
|
+
if (props.minW !== void 0) s.minWidth = dim(props.minW);
|
|
73
|
+
if (props.maxW !== void 0) s.maxWidth = dim(props.maxW);
|
|
74
|
+
if (props.display !== void 0) s.display = props.display;
|
|
75
|
+
if (props.flexGrow !== void 0) s.flexGrow = props.flexGrow;
|
|
76
|
+
if (props.flexShrink !== void 0) s.flexShrink = props.flexShrink;
|
|
77
|
+
if (props.flexBasis !== void 0) s.flexBasis = props.flexBasis;
|
|
78
|
+
if (props.fontWeight !== void 0) s.fontWeight = props.fontWeight;
|
|
79
|
+
if (props.borderRadius !== void 0) s.borderRadius = props.borderRadius;
|
|
80
|
+
if (props.alignSelf !== void 0) s.alignSelf = props.alignSelf;
|
|
81
|
+
if (props.alignItems !== void 0) s.alignItems = props.alignItems;
|
|
82
|
+
if (props.justifyContent !== void 0) s.justifyContent = props.justifyContent;
|
|
83
|
+
if (props.color !== void 0) s.color = props.color;
|
|
84
|
+
if (props.mt !== void 0) s.marginTop = sp(props.mt);
|
|
85
|
+
if (props.mb !== void 0) s.marginBottom = sp(props.mb);
|
|
86
|
+
if (props.ml !== void 0) s.marginLeft = sp(props.ml);
|
|
87
|
+
if (props.mr !== void 0) s.marginRight = sp(props.mr);
|
|
88
|
+
if (props.height !== void 0) s.height = props.height;
|
|
89
|
+
if (props.overflow !== void 0) s.overflow = props.overflow;
|
|
90
|
+
if (props.whiteSpace !== void 0) s.whiteSpace = props.whiteSpace;
|
|
91
|
+
if (props.textOverflow !== void 0) s.textOverflow = props.textOverflow;
|
|
92
|
+
if (props.textTransform !== void 0) s.textTransform = props.textTransform;
|
|
93
|
+
if (props.gap !== void 0) s.gap = sp(props.gap);
|
|
94
|
+
if (props.gridTemplateColumns !== void 0) s.gridTemplateColumns = props.gridTemplateColumns;
|
|
95
|
+
if (props.minWidth !== void 0) s.minWidth = props.minWidth;
|
|
96
|
+
if (props.boxSize !== void 0) {
|
|
97
|
+
const v = typeof props.boxSize === "number" ? `${props.boxSize * S}px` : props.boxSize;
|
|
98
|
+
s.width = v;
|
|
99
|
+
s.height = v;
|
|
100
|
+
}
|
|
101
|
+
if (props.py !== void 0) {
|
|
102
|
+
const v = sp(props.py);
|
|
103
|
+
s.paddingTop = v;
|
|
104
|
+
s.paddingBottom = v;
|
|
105
|
+
}
|
|
106
|
+
if (props.px !== void 0) {
|
|
107
|
+
const v = sp(props.px);
|
|
108
|
+
s.paddingLeft = v;
|
|
109
|
+
s.paddingRight = v;
|
|
110
|
+
}
|
|
111
|
+
if (props.p !== void 0) s.padding = sp(props.p);
|
|
112
|
+
if (props.fontSize !== void 0) s.fontSize = props.fontSize;
|
|
113
|
+
if (props.flexWrap !== void 0) s.flexWrap = props.flexWrap;
|
|
114
|
+
if (props.wordBreak !== void 0) s.wordBreak = props.wordBreak;
|
|
115
|
+
if (props.lineHeight !== void 0) s.lineHeight = props.lineHeight;
|
|
116
|
+
if (props.marginRight !== void 0) s.marginRight = props.marginRight;
|
|
117
|
+
if (props.position !== void 0) s.position = props.position;
|
|
118
|
+
if (props.background !== void 0) s.background = props.background;
|
|
119
|
+
return s;
|
|
120
|
+
}
|
|
121
|
+
function stripShims(props) {
|
|
122
|
+
const out = { ...props };
|
|
123
|
+
for (const k of SHIM_PROPS) delete out[k];
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
var SKELETON_CLASSES = [
|
|
127
|
+
"animate-skeleton-shimmer rounded-sm",
|
|
128
|
+
"bg-[linear-gradient(90deg,var(--color-skeleton-start)_0%,var(--color-skeleton-end)_50%,var(--color-skeleton-start)_100%)]",
|
|
129
|
+
"bg-[length:200%_100%]"
|
|
130
|
+
].join(" ");
|
|
131
|
+
var HIDE_BELOW_MAP = { lg: "lg:hidden", md: "md:hidden", sm: "sm:hidden" };
|
|
132
|
+
var Skeleton = React2.forwardRef(
|
|
133
|
+
function Skeleton2(props, ref) {
|
|
134
|
+
const { loading = false, asChild, className, children, style: styleProp, as: Component = "div", ...allRest } = props;
|
|
135
|
+
const shimStyle = shimToStyle(props);
|
|
136
|
+
const mergedStyle = Object.keys(shimStyle).length > 0 || styleProp ? { ...shimStyle, ...styleProp } : void 0;
|
|
137
|
+
const hideBelowClass = props.hideBelow ? HIDE_BELOW_MAP[props.hideBelow] : void 0;
|
|
138
|
+
const cls = hideBelowClass ? cn(className, hideBelowClass) : className;
|
|
139
|
+
const htmlRest = stripShims(allRest);
|
|
140
|
+
if (!loading) {
|
|
141
|
+
if (asChild && React2.isValidElement(children)) return children;
|
|
142
|
+
return /* @__PURE__ */ jsx(Component, { ref, className: cls, style: mergedStyle, ...htmlRest, children });
|
|
143
|
+
}
|
|
144
|
+
if (asChild && React2.isValidElement(children)) {
|
|
145
|
+
return /* @__PURE__ */ jsx(
|
|
146
|
+
Component,
|
|
147
|
+
{
|
|
148
|
+
ref,
|
|
149
|
+
"data-loading": true,
|
|
150
|
+
className: cn(SKELETON_CLASSES, "text-transparent [&_*]:invisible", cls),
|
|
151
|
+
style: mergedStyle,
|
|
152
|
+
...htmlRest,
|
|
153
|
+
children
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
return /* @__PURE__ */ jsx(
|
|
158
|
+
Component,
|
|
159
|
+
{
|
|
160
|
+
ref,
|
|
161
|
+
"data-loading": true,
|
|
162
|
+
className: cn(SKELETON_CLASSES, children ? "text-transparent [&_*]:invisible" : "min-h-5", cls),
|
|
163
|
+
style: mergedStyle,
|
|
164
|
+
...htmlRest,
|
|
165
|
+
children
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
React2.forwardRef(
|
|
171
|
+
function SkeletonCircle2(props, ref) {
|
|
172
|
+
const { size = 40, loading = true, className, ...rest } = props;
|
|
173
|
+
const dimension = typeof size === "number" ? `${size}px` : size;
|
|
174
|
+
return /* @__PURE__ */ jsx(
|
|
175
|
+
Skeleton,
|
|
176
|
+
{
|
|
177
|
+
ref,
|
|
178
|
+
loading,
|
|
179
|
+
className: cn("rounded-full shrink-0", className),
|
|
180
|
+
style: { width: dimension, height: dimension, ...rest.style },
|
|
181
|
+
...rest
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
React2.forwardRef(
|
|
187
|
+
function SkeletonText2(props, ref) {
|
|
188
|
+
const { noOfLines = 3, loading = true, className, ...rest } = props;
|
|
189
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cn("flex w-full flex-col gap-2", className), ...rest, children: Array.from({ length: noOfLines }).map((_, index) => /* @__PURE__ */ jsx(
|
|
190
|
+
Skeleton,
|
|
191
|
+
{
|
|
192
|
+
loading,
|
|
193
|
+
className: cn("h-4", index === noOfLines - 1 && "max-w-[80%]")
|
|
194
|
+
},
|
|
195
|
+
index
|
|
196
|
+
)) });
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
var SpinnerFrame = styled(View, {
|
|
200
|
+
name: "ButtonSpinner",
|
|
201
|
+
render: /* @__PURE__ */ jsx("span", {}),
|
|
202
|
+
width: 16,
|
|
203
|
+
height: 16,
|
|
204
|
+
borderRadius: 1e3,
|
|
205
|
+
borderWidth: 2,
|
|
206
|
+
borderColor: "currentColor",
|
|
207
|
+
borderBottomColor: "transparent",
|
|
208
|
+
borderLeftColor: "transparent"
|
|
209
|
+
});
|
|
210
|
+
function Spinner({ className }) {
|
|
211
|
+
return /* @__PURE__ */ jsx(
|
|
212
|
+
SpinnerFrame,
|
|
213
|
+
{
|
|
214
|
+
role: "status",
|
|
215
|
+
"aria-label": "Loading",
|
|
216
|
+
className: [
|
|
217
|
+
"animate-spin",
|
|
218
|
+
className
|
|
219
|
+
].filter(Boolean).join(" ")
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
var ButtonFrame = styled(View, {
|
|
224
|
+
name: "LuxButton",
|
|
225
|
+
render: /* @__PURE__ */ jsx("button", { type: "button" }),
|
|
226
|
+
role: "button",
|
|
227
|
+
tabIndex: 0,
|
|
228
|
+
cursor: "pointer",
|
|
229
|
+
userSelect: "none",
|
|
230
|
+
display: "inline-flex",
|
|
231
|
+
alignItems: "center",
|
|
232
|
+
justifyContent: "center",
|
|
233
|
+
gap: 0,
|
|
234
|
+
overflow: "hidden",
|
|
235
|
+
borderRadius: 6,
|
|
236
|
+
// Whitespace nowrap via className since hanzogui doesn't have a direct token
|
|
237
|
+
// Transition via className
|
|
238
|
+
variants: {
|
|
239
|
+
size: {
|
|
240
|
+
"2xs": { paddingHorizontal: 8, height: 20, minWidth: 20, fontSize: 12, borderRadius: 4, gap: 4 },
|
|
241
|
+
xs: { paddingHorizontal: 8, height: 24, minWidth: 24, fontSize: 14, borderRadius: 4, gap: 4 },
|
|
242
|
+
sm: { paddingHorizontal: 12, height: 32, minWidth: 32, fontSize: 14, borderRadius: 6, gap: 4 },
|
|
243
|
+
md: { paddingHorizontal: 12, height: 40, minWidth: 40, fontSize: 16, borderRadius: 6, gap: 8 }
|
|
244
|
+
},
|
|
245
|
+
disabled: {
|
|
246
|
+
true: {
|
|
247
|
+
opacity: 0.2,
|
|
248
|
+
cursor: "not-allowed",
|
|
249
|
+
pointerEvents: "none"
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
defaultVariants: {
|
|
254
|
+
size: "md"
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
var VARIANT_CLASSES = {
|
|
258
|
+
solid: [
|
|
259
|
+
"bg-[var(--color-button-solid-bg)] text-[var(--color-button-solid-text)]",
|
|
260
|
+
"hover:bg-[var(--color-hover)]",
|
|
261
|
+
"data-[expanded]:bg-[var(--color-hover)]"
|
|
262
|
+
].join(" "),
|
|
263
|
+
solid_danger: [
|
|
264
|
+
"bg-red-600 text-[var(--color-button-solid-text)]",
|
|
265
|
+
"hover:bg-red-500",
|
|
266
|
+
"data-[expanded]:bg-red-500"
|
|
267
|
+
].join(" "),
|
|
268
|
+
outline: [
|
|
269
|
+
"border-2 border-solid bg-transparent",
|
|
270
|
+
"text-[var(--color-button-outline-fg)] border-[var(--color-button-outline-fg)]",
|
|
271
|
+
"hover:bg-transparent hover:text-[var(--color-hover)] hover:border-[var(--color-hover)]"
|
|
272
|
+
].join(" "),
|
|
273
|
+
outline_danger: [
|
|
274
|
+
"border-2 border-solid bg-transparent",
|
|
275
|
+
"text-red-600 border-red-600",
|
|
276
|
+
"hover:bg-transparent hover:text-red-500 hover:border-red-500"
|
|
277
|
+
].join(" "),
|
|
278
|
+
dropdown: [
|
|
279
|
+
"border-2 border-solid bg-transparent",
|
|
280
|
+
"text-[var(--color-button-dropdown-fg)] border-[var(--color-button-dropdown-border)]",
|
|
281
|
+
"hover:bg-transparent hover:text-[var(--color-hover)] hover:border-[var(--color-hover)]",
|
|
282
|
+
"data-[expanded]:bg-transparent data-[expanded]:text-[var(--color-hover)] data-[expanded]:border-[var(--color-hover)]",
|
|
283
|
+
"data-[selected]:bg-[var(--color-selected-control-bg)] data-[selected]:text-[var(--color-selected-control-text)] data-[selected]:border-transparent",
|
|
284
|
+
"data-[selected]:hover:bg-[var(--color-selected-control-bg)]",
|
|
285
|
+
"data-[selected]:hover:text-[var(--color-hover)] data-[selected]:hover:border-transparent",
|
|
286
|
+
"data-[selected]:data-[expanded]:text-[var(--color-hover)]"
|
|
287
|
+
].join(" "),
|
|
288
|
+
header: [
|
|
289
|
+
"bg-transparent border-2 border-solid",
|
|
290
|
+
"text-[var(--color-button-header-fg)] border-[var(--color-button-header-border)]",
|
|
291
|
+
"hover:bg-transparent hover:text-[var(--color-hover)] hover:border-[var(--color-hover)]",
|
|
292
|
+
"data-[selected]:bg-[var(--color-button-header-bg-selected)]",
|
|
293
|
+
"data-[selected]:text-[var(--color-button-header-fg-selected)] data-[selected]:border-transparent data-[selected]:border-0",
|
|
294
|
+
"data-[selected]:hover:bg-[var(--color-button-header-bg-selected)] data-[selected]:hover:text-[var(--color-hover)]",
|
|
295
|
+
"data-[selected]:data-[expanded]:text-[var(--color-hover)]",
|
|
296
|
+
"data-[selected]:data-[highlighted]:bg-[var(--color-button-header-bg-highlighted)]",
|
|
297
|
+
"data-[selected]:data-[highlighted]:text-[var(--color-button-header-fg-highlighted)]",
|
|
298
|
+
"data-[selected]:data-[highlighted]:border-transparent data-[selected]:data-[highlighted]:border-0",
|
|
299
|
+
"data-[selected]:data-[highlighted]:hover:bg-[var(--color-button-header-bg-highlighted)]",
|
|
300
|
+
"data-[selected]:data-[highlighted]:hover:text-[var(--color-hover)]",
|
|
301
|
+
"data-[selected]:data-[highlighted]:data-[expanded]:text-[var(--color-hover)]"
|
|
302
|
+
].join(" "),
|
|
303
|
+
hero: [
|
|
304
|
+
"bg-[var(--color-button-hero-bg)] text-[var(--color-button-hero-fg)]",
|
|
305
|
+
"hover:bg-[var(--color-button-hero-bg-hover)] hover:text-[var(--color-button-hero-fg-hover)]",
|
|
306
|
+
"data-[selected]:bg-[var(--color-button-hero-bg-selected)] data-[selected]:text-[var(--color-button-hero-fg-selected)]",
|
|
307
|
+
"data-[selected]:hover:bg-[var(--color-button-hero-bg-selected)] data-[selected]:hover:text-[var(--color-hover)]",
|
|
308
|
+
"data-[selected]:data-[expanded]:text-[var(--color-hover)]"
|
|
309
|
+
].join(" "),
|
|
310
|
+
segmented: [
|
|
311
|
+
"bg-transparent border-2 border-solid rounded-none",
|
|
312
|
+
"text-[var(--color-button-segmented-fg)] border-[var(--color-selected-control-bg)]",
|
|
313
|
+
"hover:text-[var(--color-hover)]",
|
|
314
|
+
"data-[selected]:bg-[var(--color-selected-control-bg)] data-[selected]:text-[var(--color-selected-control-text)]",
|
|
315
|
+
"data-[selected]:hover:bg-[var(--color-selected-control-bg)] data-[selected]:hover:text-[var(--color-selected-control-text)]",
|
|
316
|
+
"[&:not(:last-child)]:border-r-0 data-[selected]:[&:not(:last-child)]:border-r-2",
|
|
317
|
+
"data-[selected]+*:border-l-0",
|
|
318
|
+
"first:rounded-l-md last:rounded-r-md"
|
|
319
|
+
].join(" "),
|
|
320
|
+
plain: "bg-transparent text-inherit border-none hover:bg-transparent",
|
|
321
|
+
subtle: [
|
|
322
|
+
"bg-[var(--color-button-subtle-bg)] text-[var(--color-button-subtle-fg)]",
|
|
323
|
+
"hover:bg-[var(--color-button-subtle-bg)] hover:text-[var(--color-hover)]",
|
|
324
|
+
"disabled:bg-[var(--color-button-subtle-bg)] disabled:text-[var(--color-button-subtle-fg)]"
|
|
325
|
+
].join(" "),
|
|
326
|
+
link: [
|
|
327
|
+
"bg-transparent text-[var(--color-link-primary)] border-none font-normal",
|
|
328
|
+
"px-0 h-auto",
|
|
329
|
+
"hover:bg-transparent hover:text-[var(--color-link-primary-hover)]",
|
|
330
|
+
"disabled:text-[var(--color-text-secondary)]"
|
|
331
|
+
].join(" "),
|
|
332
|
+
icon_secondary: [
|
|
333
|
+
"bg-transparent text-[var(--color-icon-secondary)] border-none",
|
|
334
|
+
"hover:text-[var(--color-hover)]",
|
|
335
|
+
"data-[selected]:bg-[var(--color-selected-control-bg)] data-[selected]:text-[var(--color-selected-control-text)]",
|
|
336
|
+
"data-[selected]:hover:bg-[var(--color-selected-control-bg)] data-[selected]:hover:text-[var(--color-hover)]",
|
|
337
|
+
"data-[selected]:data-[expanded]:text-[var(--color-hover)]",
|
|
338
|
+
"data-[expanded]:text-[var(--color-hover)]"
|
|
339
|
+
].join(" "),
|
|
340
|
+
icon_background: [
|
|
341
|
+
"bg-[var(--color-button-icon-background-bg)] text-[var(--color-icon-secondary)] border-none",
|
|
342
|
+
"hover:text-[var(--color-hover)]",
|
|
343
|
+
"data-[selected]:bg-[var(--color-selected-control-bg)] data-[selected]:text-[var(--color-selected-control-text)]",
|
|
344
|
+
"data-[selected]:hover:bg-[var(--color-selected-control-bg)] data-[selected]:hover:text-[var(--color-hover)]",
|
|
345
|
+
"data-[selected]:data-[expanded]:text-[var(--color-hover)]",
|
|
346
|
+
"data-[expanded]:text-[var(--color-hover)]"
|
|
347
|
+
].join(" "),
|
|
348
|
+
pagination: [
|
|
349
|
+
"border-2 border-solid bg-transparent",
|
|
350
|
+
"text-[var(--color-button-pagination-fg)] border-[var(--color-button-pagination-border)]",
|
|
351
|
+
"hover:bg-transparent hover:text-[var(--color-hover)] hover:border-[var(--color-hover)]",
|
|
352
|
+
"data-[selected]:bg-[var(--color-selected-control-bg)] data-[selected]:text-[var(--color-selected-control-text)] data-[selected]:border-transparent",
|
|
353
|
+
"data-[selected]:hover:bg-[var(--color-selected-control-bg)]",
|
|
354
|
+
"data-[selected]:hover:text-[var(--color-selected-control-text)] data-[selected]:hover:border-transparent"
|
|
355
|
+
].join(" ")
|
|
356
|
+
};
|
|
357
|
+
var BASE_CLASSES = "font-semibold whitespace-nowrap transition-colors duration-150";
|
|
358
|
+
var SP = 4;
|
|
359
|
+
function buildShimStyle(props) {
|
|
360
|
+
const s = { ...props.style };
|
|
361
|
+
if (props.mt !== void 0) s.marginTop = typeof props.mt === "number" ? `${props.mt * SP}px` : props.mt;
|
|
362
|
+
if (props.ml !== void 0) s.marginLeft = typeof props.ml === "number" ? `${props.ml * SP}px` : props.ml;
|
|
363
|
+
if (props.mr !== void 0) s.marginRight = typeof props.mr === "number" ? `${props.mr * SP}px` : props.mr;
|
|
364
|
+
if (props.px !== void 0) {
|
|
365
|
+
const v = typeof props.px === "number" ? `${props.px * SP}px` : props.px;
|
|
366
|
+
s.paddingLeft = v;
|
|
367
|
+
s.paddingRight = v;
|
|
368
|
+
}
|
|
369
|
+
if (props.py !== void 0) {
|
|
370
|
+
const v = typeof props.py === "number" ? `${props.py * SP}px` : props.py;
|
|
371
|
+
s.paddingTop = v;
|
|
372
|
+
s.paddingBottom = v;
|
|
373
|
+
}
|
|
374
|
+
if (props.fontWeight !== void 0) s.fontWeight = props.fontWeight;
|
|
375
|
+
if (props.gap !== void 0) s.gap = typeof props.gap === "number" ? `${props.gap * SP}px` : props.gap;
|
|
376
|
+
if (props.flexShrink !== void 0) s.flexShrink = props.flexShrink;
|
|
377
|
+
if (props.columnGap !== void 0) s.columnGap = typeof props.columnGap === "number" ? `${props.columnGap * SP}px` : props.columnGap;
|
|
378
|
+
if (props.gridColumn !== void 0) s.gridColumn = typeof props.gridColumn === "number" ? String(props.gridColumn) : props.gridColumn;
|
|
379
|
+
if (props.gridRow) s.gridRow = props.gridRow;
|
|
380
|
+
if (props.justifySelf) s.justifySelf = props.justifySelf;
|
|
381
|
+
if (props.alignSelf) s.alignSelf = props.alignSelf;
|
|
382
|
+
if (props.h) s.height = props.h;
|
|
383
|
+
if (props.w) s.width = props.w;
|
|
384
|
+
if (props.display) s.display = props.display;
|
|
385
|
+
if (props.borderBottomRightRadius !== void 0) s.borderBottomRightRadius = typeof props.borderBottomRightRadius === "number" ? `${props.borderBottomRightRadius}px` : props.borderBottomRightRadius;
|
|
386
|
+
if (props.borderTopRightRadius !== void 0) s.borderTopRightRadius = typeof props.borderTopRightRadius === "number" ? `${props.borderTopRightRadius}px` : props.borderTopRightRadius;
|
|
387
|
+
return Object.keys(s).length > 0 ? s : void 0;
|
|
388
|
+
}
|
|
389
|
+
var Button = React2.forwardRef(
|
|
390
|
+
function Button2(props, ref) {
|
|
391
|
+
const {
|
|
392
|
+
className,
|
|
393
|
+
variant = "solid",
|
|
394
|
+
size = "md",
|
|
395
|
+
asChild = false,
|
|
396
|
+
loading = false,
|
|
397
|
+
loadingText,
|
|
398
|
+
loadingSkeleton = false,
|
|
399
|
+
expanded,
|
|
400
|
+
selected,
|
|
401
|
+
highlighted,
|
|
402
|
+
disabled,
|
|
403
|
+
children,
|
|
404
|
+
style: styleProp,
|
|
405
|
+
// Strip Chakra style props
|
|
406
|
+
mt,
|
|
407
|
+
ml,
|
|
408
|
+
mr,
|
|
409
|
+
px,
|
|
410
|
+
py,
|
|
411
|
+
fontWeight,
|
|
412
|
+
gap,
|
|
413
|
+
flexShrink,
|
|
414
|
+
columnGap,
|
|
415
|
+
gridColumn,
|
|
416
|
+
gridRow,
|
|
417
|
+
justifySelf,
|
|
418
|
+
alignSelf,
|
|
419
|
+
textStyle: _textStyle,
|
|
420
|
+
h,
|
|
421
|
+
w,
|
|
422
|
+
display,
|
|
423
|
+
borderBottomRightRadius,
|
|
424
|
+
borderTopRightRadius,
|
|
425
|
+
...rest
|
|
426
|
+
} = props;
|
|
427
|
+
const mergedStyle = buildShimStyle({
|
|
428
|
+
style: styleProp,
|
|
429
|
+
mt,
|
|
430
|
+
ml,
|
|
431
|
+
mr,
|
|
432
|
+
px,
|
|
433
|
+
py,
|
|
434
|
+
fontWeight,
|
|
435
|
+
gap,
|
|
436
|
+
flexShrink,
|
|
437
|
+
columnGap,
|
|
438
|
+
gridColumn,
|
|
439
|
+
gridRow,
|
|
440
|
+
justifySelf,
|
|
441
|
+
alignSelf,
|
|
442
|
+
h,
|
|
443
|
+
w,
|
|
444
|
+
display,
|
|
445
|
+
borderBottomRightRadius,
|
|
446
|
+
borderTopRightRadius
|
|
447
|
+
});
|
|
448
|
+
const dataAttrs = {};
|
|
449
|
+
if (expanded) dataAttrs["data-expanded"] = true;
|
|
450
|
+
if (selected) dataAttrs["data-selected"] = true;
|
|
451
|
+
if (highlighted) dataAttrs["data-highlighted"] = true;
|
|
452
|
+
if (loadingSkeleton) dataAttrs["data-loading-skeleton"] = true;
|
|
453
|
+
const isDisabled = !loadingSkeleton && (loading || disabled);
|
|
454
|
+
const inner = loading ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
455
|
+
/* @__PURE__ */ jsx(Spinner, {}),
|
|
456
|
+
loadingText != null && /* @__PURE__ */ jsx("span", { style: { marginLeft: 8 }, children: loadingText })
|
|
457
|
+
] }) : children;
|
|
458
|
+
const variantClass = VARIANT_CLASSES[variant] ?? VARIANT_CLASSES.solid;
|
|
459
|
+
const combinedClassName = [BASE_CLASSES, variantClass, className].filter(Boolean).join(" ");
|
|
460
|
+
const button = /* @__PURE__ */ jsx(
|
|
461
|
+
ButtonFrame,
|
|
462
|
+
{
|
|
463
|
+
ref,
|
|
464
|
+
size,
|
|
465
|
+
disabled: isDisabled || void 0,
|
|
466
|
+
asChild: asChild || void 0,
|
|
467
|
+
className: combinedClassName,
|
|
468
|
+
style: mergedStyle,
|
|
469
|
+
...dataAttrs,
|
|
470
|
+
...rest,
|
|
471
|
+
children: inner
|
|
472
|
+
}
|
|
473
|
+
);
|
|
474
|
+
if (loadingSkeleton) {
|
|
475
|
+
return /* @__PURE__ */ jsx(Skeleton, { loading: loadingSkeleton, asChild: true, ref, children: button });
|
|
476
|
+
}
|
|
477
|
+
return button;
|
|
478
|
+
}
|
|
479
|
+
);
|
|
480
|
+
var SIZE_CLASSES = {
|
|
481
|
+
"2xs": "px-2 h-5 min-w-5 text-xs rounded-sm gap-1",
|
|
482
|
+
xs: "px-2 h-6 min-w-6 text-sm rounded-sm gap-1",
|
|
483
|
+
sm: "px-3 h-8 min-w-8 text-sm rounded-md gap-1",
|
|
484
|
+
md: "px-3 h-10 min-w-10 text-base rounded-md gap-2"
|
|
485
|
+
};
|
|
486
|
+
function buttonVariants(opts) {
|
|
487
|
+
const v = opts?.variant ?? "solid";
|
|
488
|
+
const s = opts?.size ?? "md";
|
|
489
|
+
return [BASE_CLASSES, VARIANT_CLASSES[v] ?? "", SIZE_CLASSES[s] ?? ""].filter(Boolean).join(" ");
|
|
490
|
+
}
|
|
491
|
+
var ButtonGroup = React2.forwardRef(
|
|
492
|
+
function ButtonGroup2(props, ref) {
|
|
493
|
+
const { className, ...rest } = props;
|
|
494
|
+
return /* @__PURE__ */ jsx(
|
|
495
|
+
"div",
|
|
496
|
+
{
|
|
497
|
+
ref,
|
|
498
|
+
className: ["inline-flex", className].filter(Boolean).join(" "),
|
|
499
|
+
role: "group",
|
|
500
|
+
...rest
|
|
501
|
+
}
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
);
|
|
505
|
+
var ButtonGroupRadio = React2.forwardRef(
|
|
506
|
+
function ButtonGroupRadio2(props, ref) {
|
|
507
|
+
const {
|
|
508
|
+
children,
|
|
509
|
+
onChange,
|
|
510
|
+
variant = "segmented",
|
|
511
|
+
defaultValue,
|
|
512
|
+
loading = false,
|
|
513
|
+
equalWidth = false,
|
|
514
|
+
className,
|
|
515
|
+
...rest
|
|
516
|
+
} = props;
|
|
517
|
+
const firstChildValue = React2.useMemo(() => {
|
|
518
|
+
const firstChild = Array.isArray(children) ? children[0] : void 0;
|
|
519
|
+
return typeof firstChild?.props.value === "string" ? firstChild.props.value : void 0;
|
|
520
|
+
}, [children]);
|
|
521
|
+
const [value, setValue] = React2.useState(defaultValue ?? firstChildValue);
|
|
522
|
+
const handleItemClick = React2.useCallback((event) => {
|
|
523
|
+
const v = event.currentTarget.value;
|
|
524
|
+
setValue(v);
|
|
525
|
+
onChange?.(v);
|
|
526
|
+
}, [onChange]);
|
|
527
|
+
const clonedChildren = React2.Children.map(children, (child) => {
|
|
528
|
+
return React2.cloneElement(child, {
|
|
529
|
+
onClick: handleItemClick,
|
|
530
|
+
selected: value === child.props.value,
|
|
531
|
+
variant
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
const childrenLength = React2.Children.count(children);
|
|
535
|
+
return /* @__PURE__ */ jsx(Skeleton, { loading, children: /* @__PURE__ */ jsx(
|
|
536
|
+
"div",
|
|
537
|
+
{
|
|
538
|
+
ref,
|
|
539
|
+
className: [
|
|
540
|
+
"inline-flex gap-0",
|
|
541
|
+
equalWidth ? "grid" : "",
|
|
542
|
+
className
|
|
543
|
+
].filter(Boolean).join(" "),
|
|
544
|
+
style: equalWidth ? { gridTemplateColumns: `repeat(${childrenLength}, 1fr)` } : void 0,
|
|
545
|
+
role: "group",
|
|
546
|
+
...rest,
|
|
547
|
+
children: clonedChildren
|
|
548
|
+
}
|
|
549
|
+
) });
|
|
550
|
+
}
|
|
551
|
+
);
|
|
552
|
+
|
|
553
|
+
export { Button, ButtonGroup, ButtonGroupRadio, buttonVariants };
|