@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/alert.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { styled, View, XStack, YStack, Text } from '@hanzo/gui';
|
|
2
3
|
import * as React2 from 'react';
|
|
4
|
+
import { Children, createElement } from 'react';
|
|
5
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
6
|
import { clsx } from 'clsx';
|
|
4
7
|
import { twMerge } from 'tailwind-merge';
|
|
5
|
-
import { styled, View } from '@hanzo/gui';
|
|
6
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
8
|
|
|
8
9
|
// src/alert.tsx
|
|
9
|
-
function cn(...inputs) {
|
|
10
|
-
return twMerge(clsx(inputs));
|
|
11
|
-
}
|
|
12
10
|
var CLOSE_ICON_PATH = "M9.44 8.035a.791.791 0 0 0 1.12 0l3.802-3.803a.791.791 0 0 1 1.119 0l.287.287a.79.79 0 0 1 0 1.119L11.965 9.44a.79.79 0 0 0 0 1.118l3.803 3.803a.791.791 0 0 1 0 1.119l-.287.287a.791.791 0 0 1-1.119 0l-3.803-3.803a.79.79 0 0 0-1.118 0l-3.803 3.803a.79.79 0 0 1-1.119 0l-.287-.287a.791.791 0 0 1 0-1.119l3.803-3.803a.791.791 0 0 0 0-1.118L4.232 5.638a.791.791 0 0 1 0-1.119l.287-.287a.791.791 0 0 1 1.119 0L9.44 8.035Z";
|
|
13
11
|
var CloseButtonFrame = styled(View, {
|
|
14
12
|
name: "LuxCloseButton",
|
|
@@ -39,23 +37,19 @@ var CloseButtonFrame = styled(View, {
|
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
});
|
|
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
40
|
var CloseButton = React2.forwardRef(function CloseButton2(props, ref) {
|
|
48
41
|
const { variant: _variant, size: _size, className, children, ...rest } = props;
|
|
49
42
|
return /* @__PURE__ */ jsx(
|
|
50
43
|
CloseButtonFrame,
|
|
51
44
|
{
|
|
52
45
|
ref,
|
|
53
|
-
className
|
|
46
|
+
className,
|
|
54
47
|
...rest,
|
|
55
48
|
children: children ?? /* @__PURE__ */ jsx(
|
|
56
49
|
"svg",
|
|
57
50
|
{
|
|
58
|
-
|
|
51
|
+
width: 20,
|
|
52
|
+
height: 20,
|
|
59
53
|
viewBox: "0 0 20 20",
|
|
60
54
|
fill: "none",
|
|
61
55
|
"aria-hidden": "true",
|
|
@@ -71,6 +65,17 @@ var CloseButton = React2.forwardRef(function CloseButton2(props, ref) {
|
|
|
71
65
|
}
|
|
72
66
|
);
|
|
73
67
|
});
|
|
68
|
+
var ink = (children, Wrap = Text, props = {}) => {
|
|
69
|
+
let hasText = false;
|
|
70
|
+
Children.forEach(children, (child) => {
|
|
71
|
+
if (typeof child === "string" || typeof child === "number") hasText = true;
|
|
72
|
+
});
|
|
73
|
+
if (!hasText) return children;
|
|
74
|
+
return Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? createElement(Wrap, props, child) : child);
|
|
75
|
+
};
|
|
76
|
+
function cn(...inputs) {
|
|
77
|
+
return twMerge(clsx(inputs));
|
|
78
|
+
}
|
|
74
79
|
var SHIM_PROPS = [
|
|
75
80
|
"w",
|
|
76
81
|
"h",
|
|
@@ -254,22 +259,30 @@ React2.forwardRef(
|
|
|
254
259
|
)) });
|
|
255
260
|
}
|
|
256
261
|
);
|
|
257
|
-
var IndicatorIcon = (
|
|
258
|
-
var ALERT_BASE =
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
262
|
+
var IndicatorIcon = () => /* @__PURE__ */ jsx("svg", { width: 20, height: 20, viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M10 18a8 8 0 100-16 8 8 0 000 16zm.75-11.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM9.25 10a.75.75 0 011.5 0v3a.75.75 0 01-1.5 0v-3z" }) });
|
|
263
|
+
var ALERT_BASE = {
|
|
264
|
+
width: "100%",
|
|
265
|
+
position: "relative",
|
|
266
|
+
alignItems: "flex-start",
|
|
267
|
+
borderRadius: 4,
|
|
268
|
+
gap: 8,
|
|
269
|
+
paddingVertical: 8
|
|
270
|
+
};
|
|
271
|
+
var ALERT_FG = "var(--color-alert-fg)";
|
|
272
|
+
var STATUS_BG = {
|
|
273
|
+
info: "var(--color-alert-bg-info)",
|
|
274
|
+
warning: "var(--color-alert-bg-warning)",
|
|
275
|
+
warning_table: "var(--color-alert-bg-warning-table)",
|
|
276
|
+
success: "var(--color-alert-bg-success)",
|
|
277
|
+
error: "var(--color-alert-bg-error)"
|
|
265
278
|
};
|
|
266
|
-
var
|
|
267
|
-
sm:
|
|
268
|
-
md:
|
|
279
|
+
var SIZE = {
|
|
280
|
+
sm: { paddingHorizontal: 8, fontSize: 12 },
|
|
281
|
+
md: { paddingHorizontal: 12, fontSize: 16 }
|
|
269
282
|
};
|
|
270
|
-
var
|
|
271
|
-
sm:
|
|
272
|
-
md:
|
|
283
|
+
var INDICATOR_SIZE = {
|
|
284
|
+
sm: { marginVertical: 0 },
|
|
285
|
+
md: { marginVertical: 2 }
|
|
273
286
|
};
|
|
274
287
|
var Alert = React2.forwardRef(
|
|
275
288
|
function Alert2(props, ref) {
|
|
@@ -298,7 +311,8 @@ var Alert = React2.forwardRef(
|
|
|
298
311
|
const alertStyle = Object.keys(shimStyle).length > 0 ? shimStyle : void 0;
|
|
299
312
|
const [isOpen, setIsOpen] = React2.useState(true);
|
|
300
313
|
const resolvedSize = size ?? "md";
|
|
301
|
-
const
|
|
314
|
+
const fontSize = SIZE[resolvedSize].fontSize;
|
|
315
|
+
const defaultIcon = /* @__PURE__ */ jsx(IndicatorIcon, {});
|
|
302
316
|
const iconElement = (() => {
|
|
303
317
|
if (startElement !== void 0) {
|
|
304
318
|
return startElement;
|
|
@@ -306,10 +320,20 @@ var Alert = React2.forwardRef(
|
|
|
306
320
|
if (!showIcon && icon === void 0) {
|
|
307
321
|
return null;
|
|
308
322
|
}
|
|
309
|
-
return /* @__PURE__ */ jsx(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
323
|
+
return /* @__PURE__ */ jsx(
|
|
324
|
+
XStack,
|
|
325
|
+
{
|
|
326
|
+
alignItems: "center",
|
|
327
|
+
justifyContent: "center",
|
|
328
|
+
flexShrink: 0,
|
|
329
|
+
width: 20,
|
|
330
|
+
height: 20,
|
|
331
|
+
...INDICATOR_SIZE[resolvedSize],
|
|
332
|
+
className: "lux-icon",
|
|
333
|
+
style: { color: ALERT_FG },
|
|
334
|
+
children: icon || defaultIcon
|
|
335
|
+
}
|
|
336
|
+
);
|
|
313
337
|
})();
|
|
314
338
|
const handleClose = React2.useCallback(() => {
|
|
315
339
|
setIsOpen(false);
|
|
@@ -338,35 +362,34 @@ var Alert = React2.forwardRef(
|
|
|
338
362
|
...descRowGap !== void 0 ? { rowGap: typeof descRowGap === "number" ? `${descRowGap * 4}px` : descRowGap } : {},
|
|
339
363
|
...descColumnGap !== void 0 ? { columnGap: typeof descColumnGap === "number" ? `${descColumnGap * 4}px` : descColumnGap } : {}
|
|
340
364
|
};
|
|
365
|
+
const ContentFrame = inline ? XStack : YStack;
|
|
341
366
|
return /* @__PURE__ */ jsx(Skeleton, { loading, children: /* @__PURE__ */ jsxs(
|
|
342
|
-
|
|
367
|
+
XStack,
|
|
343
368
|
{
|
|
344
369
|
ref,
|
|
345
|
-
|
|
370
|
+
...ALERT_BASE,
|
|
371
|
+
paddingHorizontal: SIZE[resolvedSize].paddingHorizontal,
|
|
372
|
+
backgroundColor: STATUS_BG[status],
|
|
373
|
+
className,
|
|
346
374
|
style: alertStyle,
|
|
347
375
|
...alertRest,
|
|
348
376
|
children: [
|
|
349
377
|
iconElement,
|
|
350
|
-
children ? /* @__PURE__ */ jsxs(
|
|
351
|
-
title && /* @__PURE__ */ jsx(
|
|
378
|
+
children ? /* @__PURE__ */ jsxs(ContentFrame, { flex: 1, alignItems: inline ? "center" : void 0, children: [
|
|
379
|
+
title && /* @__PURE__ */ jsx(Text, { fontWeight: "600", fontSize, color: ALERT_FG, children: title }),
|
|
352
380
|
/* @__PURE__ */ jsx(
|
|
353
|
-
|
|
381
|
+
XStack,
|
|
354
382
|
{
|
|
355
|
-
|
|
383
|
+
flexWrap: "wrap",
|
|
384
|
+
className: descClassName,
|
|
356
385
|
style: Object.keys(descStyle).length > 0 ? descStyle : void 0,
|
|
357
386
|
...descRest,
|
|
358
|
-
children
|
|
387
|
+
children: ink(children, void 0, { fontSize, color: ALERT_FG })
|
|
359
388
|
}
|
|
360
389
|
)
|
|
361
|
-
] }) : /* @__PURE__ */ jsx(
|
|
390
|
+
] }) : /* @__PURE__ */ jsx(Text, { flex: 1, fontWeight: "600", fontSize, color: ALERT_FG, children: title }),
|
|
362
391
|
endElement,
|
|
363
|
-
closable && /* @__PURE__ */ jsx(
|
|
364
|
-
CloseButton,
|
|
365
|
-
{
|
|
366
|
-
className: "relative self-start",
|
|
367
|
-
onClick: handleClose
|
|
368
|
-
}
|
|
369
|
-
)
|
|
392
|
+
closable && /* @__PURE__ */ jsx(View, { position: "relative", alignSelf: "flex-start", children: /* @__PURE__ */ jsx(CloseButton, { onClick: handleClose }) })
|
|
370
393
|
]
|
|
371
394
|
}
|
|
372
395
|
) });
|
package/dist/avatar.cjs
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
var gui = require('@hanzo/gui');
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var clsx = require('clsx');
|
|
7
|
-
var tailwindMerge = require('tailwind-merge');
|
|
8
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
7
|
|
|
10
8
|
function _interopNamespace(e) {
|
|
@@ -27,21 +25,32 @@ function _interopNamespace(e) {
|
|
|
27
25
|
|
|
28
26
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
var ink = (children, Wrap = gui.Text, props = {}) => {
|
|
29
|
+
let hasText = false;
|
|
30
|
+
React.Children.forEach(children, (child) => {
|
|
31
|
+
if (typeof child === "string" || typeof child === "number") hasText = true;
|
|
32
|
+
});
|
|
33
|
+
if (!hasText) return children;
|
|
34
|
+
return React.Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? React.createElement(Wrap, props, child) : child);
|
|
35
|
+
};
|
|
36
|
+
var SIZE = {
|
|
37
|
+
xs: { width: 24, height: 24, fontSize: 10 },
|
|
38
|
+
sm: { width: 32, height: 32, fontSize: 12 },
|
|
39
|
+
md: { width: 40, height: 40, fontSize: 14 },
|
|
40
|
+
lg: { width: 48, height: 48, fontSize: 16 },
|
|
41
|
+
xl: { width: 64, height: 64, fontSize: 18 },
|
|
42
|
+
"2xl": { width: 80, height: 80, fontSize: 20 }
|
|
40
43
|
};
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
var RING = "var(--color-bg-body)";
|
|
45
|
+
var VARIANT = {
|
|
46
|
+
solid: { backgroundColor: "var(--color-gray-500)", color: "var(--color-white)" },
|
|
47
|
+
subtle: { backgroundColor: "var(--color-badge-gray-bg)", color: "var(--color-badge-gray-fg)" },
|
|
48
|
+
outline: {
|
|
49
|
+
borderWidth: 2,
|
|
50
|
+
borderColor: "var(--color-input-border)",
|
|
51
|
+
backgroundColor: "transparent",
|
|
52
|
+
color: "var(--color-text-secondary)"
|
|
53
|
+
}
|
|
45
54
|
};
|
|
46
55
|
var DEFAULT_SIZE = "md";
|
|
47
56
|
var DEFAULT_VARIANT = "subtle";
|
|
@@ -60,7 +69,6 @@ var Avatar = React__namespace.forwardRef(
|
|
|
60
69
|
icon,
|
|
61
70
|
fallback,
|
|
62
71
|
children,
|
|
63
|
-
className,
|
|
64
72
|
size: sizeProp,
|
|
65
73
|
variant: variantProp,
|
|
66
74
|
borderless,
|
|
@@ -74,20 +82,26 @@ var Avatar = React__namespace.forwardRef(
|
|
|
74
82
|
{
|
|
75
83
|
ref,
|
|
76
84
|
unstyled: true,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
position: "relative",
|
|
86
|
+
display: "inline-flex",
|
|
87
|
+
flexShrink: 0,
|
|
88
|
+
alignItems: "center",
|
|
89
|
+
justifyContent: "center",
|
|
90
|
+
overflow: "hidden",
|
|
91
|
+
borderRadius: 9999,
|
|
92
|
+
...SIZE[size],
|
|
93
|
+
...VARIANT[variant],
|
|
94
|
+
boxShadow: isBorderless ? void 0 : `0 0 0 2px ${RING}`,
|
|
84
95
|
...rest,
|
|
85
96
|
children: [
|
|
86
97
|
/* @__PURE__ */ jsxRuntime.jsx(AvatarFallback, { name, icon, children: fallback }),
|
|
87
98
|
src != null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
88
99
|
gui.Avatar.Image,
|
|
89
100
|
{
|
|
90
|
-
|
|
101
|
+
width: "100%",
|
|
102
|
+
height: "100%",
|
|
103
|
+
borderRadius: 9999,
|
|
104
|
+
objectFit: "cover",
|
|
91
105
|
src,
|
|
92
106
|
srcSet,
|
|
93
107
|
loading,
|
|
@@ -102,22 +116,18 @@ var Avatar = React__namespace.forwardRef(
|
|
|
102
116
|
);
|
|
103
117
|
var AvatarFallback = React__namespace.forwardRef(
|
|
104
118
|
function AvatarFallback2(props, ref) {
|
|
105
|
-
const { name, icon, children,
|
|
106
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
119
|
+
const { name, icon, children, ...rest } = props;
|
|
120
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
107
121
|
gui.Avatar.Fallback,
|
|
108
122
|
{
|
|
109
123
|
ref,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
display: "flex",
|
|
125
|
+
width: "100%",
|
|
126
|
+
height: "100%",
|
|
127
|
+
alignItems: "center",
|
|
128
|
+
justifyContent: "center",
|
|
115
129
|
...rest,
|
|
116
|
-
children:
|
|
117
|
-
children,
|
|
118
|
-
name != null && children == null && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: getInitials(name) }),
|
|
119
|
-
name == null && children == null && icon
|
|
120
|
-
]
|
|
130
|
+
children: ink(children ?? (name != null ? getInitials(name) : icon), void 0, { fontWeight: "500" })
|
|
121
131
|
}
|
|
122
132
|
);
|
|
123
133
|
}
|
|
@@ -130,19 +140,12 @@ function getInitials(name) {
|
|
|
130
140
|
}
|
|
131
141
|
var AvatarGroup = React__namespace.forwardRef(
|
|
132
142
|
function AvatarGroup2(props, ref) {
|
|
133
|
-
const { size, variant, borderless,
|
|
143
|
+
const { size, variant, borderless, children, ...rest } = props;
|
|
134
144
|
const contextValue = React__namespace.useMemo(
|
|
135
145
|
() => ({ size, variant, borderless }),
|
|
136
146
|
[size, variant, borderless]
|
|
137
147
|
);
|
|
138
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AvatarGroupContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
139
|
-
"div",
|
|
140
|
-
{
|
|
141
|
-
ref,
|
|
142
|
-
className: cn("flex -space-x-3", className),
|
|
143
|
-
...rest
|
|
144
|
-
}
|
|
145
|
-
) });
|
|
148
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AvatarGroupContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(gui.XStack, { ref, ...rest, children: React__namespace.Children.map(children, (child, index) => index === 0 || !React__namespace.isValidElement(child) ? child : React__namespace.cloneElement(child, { marginLeft: -12 })) }) });
|
|
146
149
|
}
|
|
147
150
|
);
|
|
148
151
|
|
package/dist/avatar.js
CHANGED
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Avatar as Avatar$1 } from '@hanzo/gui';
|
|
2
|
+
import { Avatar as Avatar$1, Text, XStack } from '@hanzo/gui';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import { Children, createElement } from 'react';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
var ink = (children, Wrap = Text, props = {}) => {
|
|
8
|
+
let hasText = false;
|
|
9
|
+
Children.forEach(children, (child) => {
|
|
10
|
+
if (typeof child === "string" || typeof child === "number") hasText = true;
|
|
11
|
+
});
|
|
12
|
+
if (!hasText) return children;
|
|
13
|
+
return Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? createElement(Wrap, props, child) : child);
|
|
14
|
+
};
|
|
15
|
+
var SIZE = {
|
|
16
|
+
xs: { width: 24, height: 24, fontSize: 10 },
|
|
17
|
+
sm: { width: 32, height: 32, fontSize: 12 },
|
|
18
|
+
md: { width: 40, height: 40, fontSize: 14 },
|
|
19
|
+
lg: { width: 48, height: 48, fontSize: 16 },
|
|
20
|
+
xl: { width: 64, height: 64, fontSize: 18 },
|
|
21
|
+
"2xl": { width: 80, height: 80, fontSize: 20 }
|
|
18
22
|
};
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
var RING = "var(--color-bg-body)";
|
|
24
|
+
var VARIANT = {
|
|
25
|
+
solid: { backgroundColor: "var(--color-gray-500)", color: "var(--color-white)" },
|
|
26
|
+
subtle: { backgroundColor: "var(--color-badge-gray-bg)", color: "var(--color-badge-gray-fg)" },
|
|
27
|
+
outline: {
|
|
28
|
+
borderWidth: 2,
|
|
29
|
+
borderColor: "var(--color-input-border)",
|
|
30
|
+
backgroundColor: "transparent",
|
|
31
|
+
color: "var(--color-text-secondary)"
|
|
32
|
+
}
|
|
23
33
|
};
|
|
24
34
|
var DEFAULT_SIZE = "md";
|
|
25
35
|
var DEFAULT_VARIANT = "subtle";
|
|
@@ -38,7 +48,6 @@ var Avatar = React.forwardRef(
|
|
|
38
48
|
icon,
|
|
39
49
|
fallback,
|
|
40
50
|
children,
|
|
41
|
-
className,
|
|
42
51
|
size: sizeProp,
|
|
43
52
|
variant: variantProp,
|
|
44
53
|
borderless,
|
|
@@ -52,20 +61,26 @@ var Avatar = React.forwardRef(
|
|
|
52
61
|
{
|
|
53
62
|
ref,
|
|
54
63
|
unstyled: true,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
position: "relative",
|
|
65
|
+
display: "inline-flex",
|
|
66
|
+
flexShrink: 0,
|
|
67
|
+
alignItems: "center",
|
|
68
|
+
justifyContent: "center",
|
|
69
|
+
overflow: "hidden",
|
|
70
|
+
borderRadius: 9999,
|
|
71
|
+
...SIZE[size],
|
|
72
|
+
...VARIANT[variant],
|
|
73
|
+
boxShadow: isBorderless ? void 0 : `0 0 0 2px ${RING}`,
|
|
62
74
|
...rest,
|
|
63
75
|
children: [
|
|
64
76
|
/* @__PURE__ */ jsx(AvatarFallback, { name, icon, children: fallback }),
|
|
65
77
|
src != null && /* @__PURE__ */ jsx(
|
|
66
78
|
Avatar$1.Image,
|
|
67
79
|
{
|
|
68
|
-
|
|
80
|
+
width: "100%",
|
|
81
|
+
height: "100%",
|
|
82
|
+
borderRadius: 9999,
|
|
83
|
+
objectFit: "cover",
|
|
69
84
|
src,
|
|
70
85
|
srcSet,
|
|
71
86
|
loading,
|
|
@@ -80,22 +95,18 @@ var Avatar = React.forwardRef(
|
|
|
80
95
|
);
|
|
81
96
|
var AvatarFallback = React.forwardRef(
|
|
82
97
|
function AvatarFallback2(props, ref) {
|
|
83
|
-
const { name, icon, children,
|
|
84
|
-
return /* @__PURE__ */
|
|
98
|
+
const { name, icon, children, ...rest } = props;
|
|
99
|
+
return /* @__PURE__ */ jsx(
|
|
85
100
|
Avatar$1.Fallback,
|
|
86
101
|
{
|
|
87
102
|
ref,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
103
|
+
display: "flex",
|
|
104
|
+
width: "100%",
|
|
105
|
+
height: "100%",
|
|
106
|
+
alignItems: "center",
|
|
107
|
+
justifyContent: "center",
|
|
93
108
|
...rest,
|
|
94
|
-
children:
|
|
95
|
-
children,
|
|
96
|
-
name != null && children == null && /* @__PURE__ */ jsx(Fragment, { children: getInitials(name) }),
|
|
97
|
-
name == null && children == null && icon
|
|
98
|
-
]
|
|
109
|
+
children: ink(children ?? (name != null ? getInitials(name) : icon), void 0, { fontWeight: "500" })
|
|
99
110
|
}
|
|
100
111
|
);
|
|
101
112
|
}
|
|
@@ -108,19 +119,12 @@ function getInitials(name) {
|
|
|
108
119
|
}
|
|
109
120
|
var AvatarGroup = React.forwardRef(
|
|
110
121
|
function AvatarGroup2(props, ref) {
|
|
111
|
-
const { size, variant, borderless,
|
|
122
|
+
const { size, variant, borderless, children, ...rest } = props;
|
|
112
123
|
const contextValue = React.useMemo(
|
|
113
124
|
() => ({ size, variant, borderless }),
|
|
114
125
|
[size, variant, borderless]
|
|
115
126
|
);
|
|
116
|
-
return /* @__PURE__ */ jsx(AvatarGroupContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
117
|
-
"div",
|
|
118
|
-
{
|
|
119
|
-
ref,
|
|
120
|
-
className: cn("flex -space-x-3", className),
|
|
121
|
-
...rest
|
|
122
|
-
}
|
|
123
|
-
) });
|
|
127
|
+
return /* @__PURE__ */ jsx(AvatarGroupContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(XStack, { ref, ...rest, children: React.Children.map(children, (child, index) => index === 0 || !React.isValidElement(child) ? child : React.cloneElement(child, { marginLeft: -12 })) }) });
|
|
124
128
|
}
|
|
125
129
|
);
|
|
126
130
|
|