@luxfi/ui 7.4.11 → 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/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 +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 +756 -703
- package/dist/index.js +757 -704
- 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 +3 -7
- package/dist/popover.js +3 -7
- 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/slider.cjs +33 -49
- package/dist/slider.js +34 -50
- package/dist/switch.cjs +48 -55
- package/dist/switch.js +49 -56
- package/dist/tag.cjs +112 -69
- package/dist/tag.js +113 -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 -37
- 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 +136 -114
- package/src/pin-input.tsx +37 -29
- package/src/pnl-diagram.tsx +36 -28
- package/src/progress.tsx +17 -21
- package/src/radio.tsx +56 -75
- package/src/slider.tsx +43 -44
- package/src/strategy-builder.tsx +245 -156
- 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/tag.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { styled, View, TooltipGroup, Tooltip as Tooltip$1, Text, XStack } from '@hanzo/gui';
|
|
2
3
|
import * as React4 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, TooltipGroup, Tooltip as Tooltip$1 } from '@hanzo/gui';
|
|
6
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
8
|
import { useClickAway } from '@uidotdev/usehooks';
|
|
8
9
|
|
|
9
10
|
// src/tag.tsx
|
|
10
|
-
function cn(...inputs) {
|
|
11
|
-
return twMerge(clsx(inputs));
|
|
12
|
-
}
|
|
13
11
|
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";
|
|
14
12
|
var CloseButtonFrame = styled(View, {
|
|
15
13
|
name: "LuxCloseButton",
|
|
@@ -40,23 +38,19 @@ var CloseButtonFrame = styled(View, {
|
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
});
|
|
43
|
-
var CLOSE_BUTTON_CLASSES = [
|
|
44
|
-
"text-[var(--closeButton-fg,currentColor)]",
|
|
45
|
-
"hover:text-[var(--hover-color,currentColor)]",
|
|
46
|
-
"disabled:opacity-40"
|
|
47
|
-
].join(" ");
|
|
48
41
|
var CloseButton = React4.forwardRef(function CloseButton2(props, ref) {
|
|
49
42
|
const { variant: _variant, size: _size, className, children, ...rest } = props;
|
|
50
43
|
return /* @__PURE__ */ jsx(
|
|
51
44
|
CloseButtonFrame,
|
|
52
45
|
{
|
|
53
46
|
ref,
|
|
54
|
-
className
|
|
47
|
+
className,
|
|
55
48
|
...rest,
|
|
56
49
|
children: children ?? /* @__PURE__ */ jsx(
|
|
57
50
|
"svg",
|
|
58
51
|
{
|
|
59
|
-
|
|
52
|
+
width: 20,
|
|
53
|
+
height: 20,
|
|
60
54
|
viewBox: "0 0 20 20",
|
|
61
55
|
fill: "none",
|
|
62
56
|
"aria-hidden": "true",
|
|
@@ -72,6 +66,9 @@ var CloseButton = React4.forwardRef(function CloseButton2(props, ref) {
|
|
|
72
66
|
}
|
|
73
67
|
);
|
|
74
68
|
});
|
|
69
|
+
function cn(...inputs) {
|
|
70
|
+
return twMerge(clsx(inputs));
|
|
71
|
+
}
|
|
75
72
|
var SHIM_PROPS = [
|
|
76
73
|
"w",
|
|
77
74
|
"h",
|
|
@@ -255,6 +252,14 @@ React4.forwardRef(
|
|
|
255
252
|
)) });
|
|
256
253
|
}
|
|
257
254
|
);
|
|
255
|
+
var ink = (children, Wrap = Text, props = {}) => {
|
|
256
|
+
let hasText = false;
|
|
257
|
+
Children.forEach(children, (child) => {
|
|
258
|
+
if (typeof child === "string" || typeof child === "number") hasText = true;
|
|
259
|
+
});
|
|
260
|
+
if (!hasText) return children;
|
|
261
|
+
return Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? createElement(Wrap, props, child) : child);
|
|
262
|
+
};
|
|
258
263
|
var TOUCH_PX = 1024;
|
|
259
264
|
function useBelow(px) {
|
|
260
265
|
const [below, setBelow] = React4.useState(false);
|
|
@@ -359,14 +364,21 @@ var Tooltip = React4.forwardRef(
|
|
|
359
364
|
{
|
|
360
365
|
ref,
|
|
361
366
|
unstyled: true,
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
367
|
+
zIndex: 9999,
|
|
368
|
+
overflow: "hidden",
|
|
369
|
+
borderRadius: 8,
|
|
370
|
+
paddingHorizontal: 12,
|
|
371
|
+
paddingVertical: 8,
|
|
372
|
+
maxWidth: isPopover ? 384 : 320,
|
|
373
|
+
backgroundColor: isPopover ? "var(--color-popover-bg)" : "var(--color-tooltip-bg)",
|
|
374
|
+
transition: "quick",
|
|
375
|
+
enterStyle: { opacity: 0, scale: 0.95 },
|
|
376
|
+
exitStyle: { opacity: 0, scale: 0.95 },
|
|
377
|
+
...isPopover ? {
|
|
378
|
+
borderWidth: 1,
|
|
379
|
+
borderColor: "var(--color-border-divider)",
|
|
380
|
+
shadowColor: "var(--shadow-popover)"
|
|
381
|
+
} : {},
|
|
370
382
|
onClick: interactive ? handleContentClick : void 0,
|
|
371
383
|
...selected ? { "data-selected": true } : {},
|
|
372
384
|
...contentProps,
|
|
@@ -375,12 +387,13 @@ var Tooltip = React4.forwardRef(
|
|
|
375
387
|
Tooltip$1.Arrow,
|
|
376
388
|
{
|
|
377
389
|
unstyled: true,
|
|
378
|
-
|
|
379
|
-
isPopover ? "fill-[var(--color-popover-bg)]" : "fill-[var(--color-tooltip-bg)]"
|
|
380
|
-
)
|
|
390
|
+
backgroundColor: isPopover ? "var(--color-popover-bg)" : "var(--color-tooltip-bg)"
|
|
381
391
|
}
|
|
382
392
|
),
|
|
383
|
-
content
|
|
393
|
+
ink(content, void 0, {
|
|
394
|
+
fontSize: 14,
|
|
395
|
+
color: isPopover ? "var(--color-text-primary)" : "var(--color-tooltip-fg)"
|
|
396
|
+
})
|
|
384
397
|
]
|
|
385
398
|
}
|
|
386
399
|
)
|
|
@@ -393,25 +406,24 @@ var nbsp = String.fromCharCode(160);
|
|
|
393
406
|
function TruncatedTextTooltip({ label, children }) {
|
|
394
407
|
return /* @__PURE__ */ jsx(Tooltip, { content: label, positioning: { placement: "top" }, children });
|
|
395
408
|
}
|
|
396
|
-
var
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
select: "cursor-pointer bg-[var(--color-tag-select-bg)] text-[var(--color-tag-select-fg)] hover:text-[var(--color-hover)] hover:opacity-76"
|
|
409
|
+
var TAG_VARIANT = {
|
|
410
|
+
subtle: { backgroundColor: "var(--color-tag-subtle-bg)" },
|
|
411
|
+
clickable: { backgroundColor: "var(--color-tag-clickable-bg)", cursor: "pointer", hoverStyle: { opacity: 0.76 } },
|
|
412
|
+
filter: { backgroundColor: "var(--color-tag-filter-bg)" },
|
|
413
|
+
select: { backgroundColor: "var(--color-tag-select-bg)", cursor: "pointer", hoverStyle: { opacity: 0.76 } }
|
|
402
414
|
};
|
|
403
|
-
var
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
415
|
+
var TAG_VARIANT_FG = {
|
|
416
|
+
subtle: "var(--color-tag-subtle-fg)",
|
|
417
|
+
clickable: "var(--color-tag-clickable-fg)",
|
|
418
|
+
filter: void 0,
|
|
419
|
+
select: "var(--color-tag-select-fg)"
|
|
407
420
|
};
|
|
408
|
-
var
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
var TAG_DISABLED_CLASSES = "opacity-40 pointer-events-none cursor-not-allowed";
|
|
421
|
+
var TAG_SIZE = {
|
|
422
|
+
sm: { paddingHorizontal: 4, paddingVertical: 2, minHeight: 20, gap: 4 },
|
|
423
|
+
md: { paddingHorizontal: 4, paddingVertical: 2, minHeight: 24, gap: 4 },
|
|
424
|
+
lg: { paddingHorizontal: 6, paddingVertical: 6, minHeight: 32, minWidth: 32, gap: 4 }
|
|
425
|
+
};
|
|
426
|
+
var TAG_SIZE_FONT = { sm: 12, md: 14, lg: 14 };
|
|
415
427
|
var Tag = React4.forwardRef(
|
|
416
428
|
function Tag2(props, ref) {
|
|
417
429
|
const {
|
|
@@ -431,46 +443,78 @@ var Tag = React4.forwardRef(
|
|
|
431
443
|
className,
|
|
432
444
|
...rest
|
|
433
445
|
} = props;
|
|
434
|
-
const
|
|
446
|
+
const resolvedVariant = variant ?? "subtle";
|
|
447
|
+
const resolvedSize = size ?? "md";
|
|
448
|
+
const isSelected = Boolean(selected) && !loading;
|
|
449
|
+
const backgroundColor = isSelected ? "var(--color-tag-select-selected-bg)" : TAG_VARIANT[resolvedVariant].backgroundColor;
|
|
450
|
+
const color = isSelected ? "var(--color-tag-select-selected-fg)" : TAG_VARIANT_FG[resolvedVariant];
|
|
451
|
+
const hoverStyle = isSelected ? { opacity: 0.76 } : TAG_VARIANT[resolvedVariant].hoverStyle;
|
|
452
|
+
const textHoverColor = !isSelected && resolvedVariant === "select" ? "var(--color-hover)" : void 0;
|
|
453
|
+
const labelElement = label ? /* @__PURE__ */ jsxs(Text, { fontSize: TAG_SIZE_FONT[resolvedSize], fontWeight: "500", color: "var(--color-text-secondary)", children: [
|
|
435
454
|
label,
|
|
436
455
|
":",
|
|
437
456
|
nbsp
|
|
438
457
|
] }) : null;
|
|
439
|
-
const labelSpan = /* @__PURE__ */ jsxs(
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
458
|
+
const labelSpan = /* @__PURE__ */ jsxs(
|
|
459
|
+
Text,
|
|
460
|
+
{
|
|
461
|
+
overflow: "hidden",
|
|
462
|
+
textOverflow: "ellipsis",
|
|
463
|
+
whiteSpace: "nowrap",
|
|
464
|
+
fontWeight: "500",
|
|
465
|
+
fontSize: TAG_SIZE_FONT[resolvedSize],
|
|
466
|
+
color,
|
|
467
|
+
hoverStyle: textHoverColor ? { color: textHoverColor } : void 0,
|
|
468
|
+
children: [
|
|
469
|
+
labelElement,
|
|
470
|
+
children
|
|
471
|
+
]
|
|
472
|
+
}
|
|
473
|
+
);
|
|
443
474
|
const contentElement = truncated ? /* @__PURE__ */ jsx(TruncatedTextTooltip, { label: children, children: labelSpan }) : labelSpan;
|
|
444
475
|
return /* @__PURE__ */ jsx(Skeleton, { loading, asChild: true, children: /* @__PURE__ */ jsxs(
|
|
445
|
-
|
|
476
|
+
XStack,
|
|
446
477
|
{
|
|
447
478
|
ref,
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
479
|
+
render: /* @__PURE__ */ jsx("span", {}),
|
|
480
|
+
display: "inline-flex",
|
|
481
|
+
alignItems: "center",
|
|
482
|
+
verticalAlign: "top",
|
|
483
|
+
maxWidth: "100%",
|
|
484
|
+
userSelect: "text",
|
|
485
|
+
...TAG_SIZE[resolvedSize],
|
|
486
|
+
backgroundColor,
|
|
487
|
+
hoverStyle,
|
|
488
|
+
focusVisibleStyle: {
|
|
489
|
+
outlineWidth: 2,
|
|
490
|
+
outlineOffset: 2,
|
|
491
|
+
outlineColor: "var(--color-gray-500)",
|
|
492
|
+
outlineStyle: "solid"
|
|
493
|
+
},
|
|
494
|
+
cursor: disabled ? "not-allowed" : TAG_VARIANT[resolvedVariant].cursor,
|
|
495
|
+
...disabled ? { opacity: 0.4, pointerEvents: "none" } : {},
|
|
496
|
+
...isSelected && { "data-selected": true },
|
|
457
497
|
...disabled && { "data-disabled": true },
|
|
498
|
+
className,
|
|
458
499
|
...rest,
|
|
459
500
|
children: [
|
|
460
|
-
startElement && /* @__PURE__ */ jsx(
|
|
501
|
+
startElement && /* @__PURE__ */ jsx(XStack, { flexShrink: 0, alignItems: "center", justifyContent: "center", children: startElement }),
|
|
461
502
|
contentElement,
|
|
462
|
-
endElement &&
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
503
|
+
endElement && (() => {
|
|
504
|
+
const { className: endClassName, ...endElementRest } = endElementProps ?? {};
|
|
505
|
+
return /* @__PURE__ */ jsx(
|
|
506
|
+
XStack,
|
|
507
|
+
{
|
|
508
|
+
...endElementRest,
|
|
509
|
+
flexShrink: 0,
|
|
510
|
+
alignItems: "center",
|
|
511
|
+
justifyContent: "center",
|
|
512
|
+
className: endClassName,
|
|
513
|
+
children: endElement
|
|
514
|
+
}
|
|
515
|
+
);
|
|
516
|
+
})(),
|
|
517
|
+
closable && /* @__PURE__ */ jsx(XStack, { flexShrink: 0, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsx(CloseButton, { onClick: onClose }) })
|
|
474
518
|
]
|
|
475
519
|
}
|
|
476
520
|
) });
|
package/dist/tooltip.cjs
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
var gui = require('@hanzo/gui');
|
|
5
5
|
var usehooks = require('@uidotdev/usehooks');
|
|
6
6
|
var React2 = require('react');
|
|
7
|
-
var clsx = require('clsx');
|
|
8
|
-
var tailwindMerge = require('tailwind-merge');
|
|
9
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
10
8
|
|
|
11
9
|
function _interopNamespace(e) {
|
|
@@ -29,6 +27,14 @@ function _interopNamespace(e) {
|
|
|
29
27
|
var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
|
30
28
|
|
|
31
29
|
// src/tooltip.tsx
|
|
30
|
+
var ink = (children, Wrap = gui.Text, props = {}) => {
|
|
31
|
+
let hasText = false;
|
|
32
|
+
React2.Children.forEach(children, (child) => {
|
|
33
|
+
if (typeof child === "string" || typeof child === "number") hasText = true;
|
|
34
|
+
});
|
|
35
|
+
if (!hasText) return children;
|
|
36
|
+
return React2.Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? React2.createElement(Wrap, props, child) : child);
|
|
37
|
+
};
|
|
32
38
|
var TOUCH_PX = 1024;
|
|
33
39
|
function useBelow(px) {
|
|
34
40
|
const [below, setBelow] = React2__namespace.useState(false);
|
|
@@ -42,9 +48,6 @@ function useBelow(px) {
|
|
|
42
48
|
return below;
|
|
43
49
|
}
|
|
44
50
|
var useIsTouch = () => useBelow(TOUCH_PX);
|
|
45
|
-
function cn(...inputs) {
|
|
46
|
-
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
47
|
-
}
|
|
48
51
|
function mapPlacement(p) {
|
|
49
52
|
if (!p) return void 0;
|
|
50
53
|
return p;
|
|
@@ -136,14 +139,21 @@ var Tooltip = React2__namespace.forwardRef(
|
|
|
136
139
|
{
|
|
137
140
|
ref,
|
|
138
141
|
unstyled: true,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
zIndex: 9999,
|
|
143
|
+
overflow: "hidden",
|
|
144
|
+
borderRadius: 8,
|
|
145
|
+
paddingHorizontal: 12,
|
|
146
|
+
paddingVertical: 8,
|
|
147
|
+
maxWidth: isPopover ? 384 : 320,
|
|
148
|
+
backgroundColor: isPopover ? "var(--color-popover-bg)" : "var(--color-tooltip-bg)",
|
|
149
|
+
transition: "quick",
|
|
150
|
+
enterStyle: { opacity: 0, scale: 0.95 },
|
|
151
|
+
exitStyle: { opacity: 0, scale: 0.95 },
|
|
152
|
+
...isPopover ? {
|
|
153
|
+
borderWidth: 1,
|
|
154
|
+
borderColor: "var(--color-border-divider)",
|
|
155
|
+
shadowColor: "var(--shadow-popover)"
|
|
156
|
+
} : {},
|
|
147
157
|
onClick: interactive ? handleContentClick : void 0,
|
|
148
158
|
...selected ? { "data-selected": true } : {},
|
|
149
159
|
...contentProps,
|
|
@@ -152,12 +162,13 @@ var Tooltip = React2__namespace.forwardRef(
|
|
|
152
162
|
gui.Tooltip.Arrow,
|
|
153
163
|
{
|
|
154
164
|
unstyled: true,
|
|
155
|
-
|
|
156
|
-
isPopover ? "fill-[var(--color-popover-bg)]" : "fill-[var(--color-tooltip-bg)]"
|
|
157
|
-
)
|
|
165
|
+
backgroundColor: isPopover ? "var(--color-popover-bg)" : "var(--color-tooltip-bg)"
|
|
158
166
|
}
|
|
159
167
|
),
|
|
160
|
-
content
|
|
168
|
+
ink(content, void 0, {
|
|
169
|
+
fontSize: 14,
|
|
170
|
+
color: isPopover ? "var(--color-text-primary)" : "var(--color-tooltip-fg)"
|
|
171
|
+
})
|
|
161
172
|
]
|
|
162
173
|
}
|
|
163
174
|
)
|
package/dist/tooltip.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { TooltipGroup, Tooltip as Tooltip$1 } from '@hanzo/gui';
|
|
2
|
+
import { TooltipGroup, Tooltip as Tooltip$1, Text } from '@hanzo/gui';
|
|
3
3
|
import { useClickAway } from '@uidotdev/usehooks';
|
|
4
4
|
import * as React2 from 'react';
|
|
5
|
-
import {
|
|
6
|
-
import { twMerge } from 'tailwind-merge';
|
|
5
|
+
import { Children, createElement } from 'react';
|
|
7
6
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
7
|
|
|
9
8
|
// src/tooltip.tsx
|
|
9
|
+
var ink = (children, Wrap = Text, props = {}) => {
|
|
10
|
+
let hasText = false;
|
|
11
|
+
Children.forEach(children, (child) => {
|
|
12
|
+
if (typeof child === "string" || typeof child === "number") hasText = true;
|
|
13
|
+
});
|
|
14
|
+
if (!hasText) return children;
|
|
15
|
+
return Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? createElement(Wrap, props, child) : child);
|
|
16
|
+
};
|
|
10
17
|
var TOUCH_PX = 1024;
|
|
11
18
|
function useBelow(px) {
|
|
12
19
|
const [below, setBelow] = React2.useState(false);
|
|
@@ -20,9 +27,6 @@ function useBelow(px) {
|
|
|
20
27
|
return below;
|
|
21
28
|
}
|
|
22
29
|
var useIsTouch = () => useBelow(TOUCH_PX);
|
|
23
|
-
function cn(...inputs) {
|
|
24
|
-
return twMerge(clsx(inputs));
|
|
25
|
-
}
|
|
26
30
|
function mapPlacement(p) {
|
|
27
31
|
if (!p) return void 0;
|
|
28
32
|
return p;
|
|
@@ -114,14 +118,21 @@ var Tooltip = React2.forwardRef(
|
|
|
114
118
|
{
|
|
115
119
|
ref,
|
|
116
120
|
unstyled: true,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
zIndex: 9999,
|
|
122
|
+
overflow: "hidden",
|
|
123
|
+
borderRadius: 8,
|
|
124
|
+
paddingHorizontal: 12,
|
|
125
|
+
paddingVertical: 8,
|
|
126
|
+
maxWidth: isPopover ? 384 : 320,
|
|
127
|
+
backgroundColor: isPopover ? "var(--color-popover-bg)" : "var(--color-tooltip-bg)",
|
|
128
|
+
transition: "quick",
|
|
129
|
+
enterStyle: { opacity: 0, scale: 0.95 },
|
|
130
|
+
exitStyle: { opacity: 0, scale: 0.95 },
|
|
131
|
+
...isPopover ? {
|
|
132
|
+
borderWidth: 1,
|
|
133
|
+
borderColor: "var(--color-border-divider)",
|
|
134
|
+
shadowColor: "var(--shadow-popover)"
|
|
135
|
+
} : {},
|
|
125
136
|
onClick: interactive ? handleContentClick : void 0,
|
|
126
137
|
...selected ? { "data-selected": true } : {},
|
|
127
138
|
...contentProps,
|
|
@@ -130,12 +141,13 @@ var Tooltip = React2.forwardRef(
|
|
|
130
141
|
Tooltip$1.Arrow,
|
|
131
142
|
{
|
|
132
143
|
unstyled: true,
|
|
133
|
-
|
|
134
|
-
isPopover ? "fill-[var(--color-popover-bg)]" : "fill-[var(--color-tooltip-bg)]"
|
|
135
|
-
)
|
|
144
|
+
backgroundColor: isPopover ? "var(--color-popover-bg)" : "var(--color-tooltip-bg)"
|
|
136
145
|
}
|
|
137
146
|
),
|
|
138
|
-
content
|
|
147
|
+
ink(content, void 0, {
|
|
148
|
+
fontSize: 14,
|
|
149
|
+
color: isPopover ? "var(--color-text-primary)" : "var(--color-tooltip-fg)"
|
|
150
|
+
})
|
|
139
151
|
]
|
|
140
152
|
}
|
|
141
153
|
)
|
package/package.json
CHANGED
package/src/alert.tsx
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { Text, View, XStack, YStack } from '@hanzo/gui';
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
|
|
3
|
-
import { cn } from './utils';
|
|
4
|
-
|
|
5
4
|
// Inline info icon (filled circle with i)
|
|
6
|
-
const IndicatorIcon = (
|
|
7
|
-
<svg
|
|
5
|
+
const IndicatorIcon = () => (
|
|
6
|
+
<svg width={ 20 } height={ 20 } viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
8
7
|
<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"/>
|
|
9
8
|
</svg>
|
|
10
9
|
);
|
|
11
10
|
|
|
12
11
|
import { CloseButton } from './close-button';
|
|
12
|
+
import { ink } from './ink';
|
|
13
13
|
import { Skeleton } from './skeleton';
|
|
14
14
|
|
|
15
15
|
/* ------------------------------------------------------------------ */
|
|
@@ -19,27 +19,38 @@ import { Skeleton } from './skeleton';
|
|
|
19
19
|
type AlertStatus = 'info' | 'warning' | 'warning_table' | 'success' | 'error';
|
|
20
20
|
|
|
21
21
|
/* ------------------------------------------------------------------ */
|
|
22
|
-
/*
|
|
22
|
+
/* Style maps (replaced CVA) */
|
|
23
23
|
/* ------------------------------------------------------------------ */
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
/** The frame every alert shares, regardless of status or size. */
|
|
26
|
+
const ALERT_BASE = {
|
|
27
|
+
width: '100%',
|
|
28
|
+
position: 'relative',
|
|
29
|
+
alignItems: 'flex-start',
|
|
30
|
+
borderRadius: 4,
|
|
31
|
+
gap: 8,
|
|
32
|
+
paddingVertical: 8,
|
|
33
|
+
} as const;
|
|
34
|
+
|
|
35
|
+
/** Foreground is constant across every status — only the background moves. */
|
|
36
|
+
const ALERT_FG = 'var(--color-alert-fg)' as never;
|
|
37
|
+
|
|
38
|
+
const STATUS_BG: Record<AlertStatus, string> = {
|
|
39
|
+
info: 'var(--color-alert-bg-info)',
|
|
40
|
+
warning: 'var(--color-alert-bg-warning)',
|
|
41
|
+
warning_table: 'var(--color-alert-bg-warning-table)',
|
|
42
|
+
success: 'var(--color-alert-bg-success)',
|
|
43
|
+
error: 'var(--color-alert-bg-error)',
|
|
33
44
|
};
|
|
34
45
|
|
|
35
|
-
const
|
|
36
|
-
sm:
|
|
37
|
-
md:
|
|
46
|
+
const SIZE: Record<'sm' | 'md', { paddingHorizontal: number; fontSize: number }> = {
|
|
47
|
+
sm: { paddingHorizontal: 8, fontSize: 12 },
|
|
48
|
+
md: { paddingHorizontal: 12, fontSize: 16 },
|
|
38
49
|
};
|
|
39
50
|
|
|
40
|
-
const
|
|
41
|
-
sm:
|
|
42
|
-
md:
|
|
51
|
+
const INDICATOR_SIZE: Record<'sm' | 'md', { marginVertical: number }> = {
|
|
52
|
+
sm: { marginVertical: 0 },
|
|
53
|
+
md: { marginVertical: 2 },
|
|
43
54
|
};
|
|
44
55
|
|
|
45
56
|
/* ------------------------------------------------------------------ */
|
|
@@ -107,10 +118,9 @@ export const Alert = React.forwardRef<HTMLDivElement, AlertProps>(
|
|
|
107
118
|
const [ isOpen, setIsOpen ] = React.useState(true);
|
|
108
119
|
|
|
109
120
|
const resolvedSize = size ?? 'md';
|
|
121
|
+
const fontSize = SIZE[resolvedSize].fontSize;
|
|
110
122
|
|
|
111
|
-
const defaultIcon =
|
|
112
|
-
<IndicatorIcon className="w-5 h-5"/>
|
|
113
|
-
);
|
|
123
|
+
const defaultIcon = <IndicatorIcon/>;
|
|
114
124
|
|
|
115
125
|
const iconElement = (() => {
|
|
116
126
|
if (startElement !== undefined) {
|
|
@@ -122,12 +132,23 @@ export const Alert = React.forwardRef<HTMLDivElement, AlertProps>(
|
|
|
122
132
|
}
|
|
123
133
|
|
|
124
134
|
return (
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
<XStack
|
|
136
|
+
alignItems="center"
|
|
137
|
+
justifyContent="center"
|
|
138
|
+
flexShrink={ 0 }
|
|
139
|
+
width={ 20 }
|
|
140
|
+
height={ 20 }
|
|
141
|
+
{ ...INDICATOR_SIZE[resolvedSize] }
|
|
142
|
+
// The default icon and a caller's custom `icon` both use
|
|
143
|
+
// `fill="currentColor"`; `.lux-icon` (tokens.css) is the existing
|
|
144
|
+
// descendant-selector rule that sizes an arbitrary child svg to the
|
|
145
|
+
// box (20px default) instead of its own intrinsic size — no prop
|
|
146
|
+
// reaches a child element, so this is shared, not reinvented here.
|
|
147
|
+
className="lux-icon"
|
|
148
|
+
style={{ color: ALERT_FG }}
|
|
149
|
+
>
|
|
129
150
|
{ icon || defaultIcon }
|
|
130
|
-
</
|
|
151
|
+
</XStack>
|
|
131
152
|
);
|
|
132
153
|
})();
|
|
133
154
|
|
|
@@ -156,37 +177,49 @@ export const Alert = React.forwardRef<HTMLDivElement, AlertProps>(
|
|
|
156
177
|
...(descColumnGap !== undefined ? { columnGap: typeof descColumnGap === 'number' ? `${ descColumnGap * 4 }px` : descColumnGap } : {}),
|
|
157
178
|
};
|
|
158
179
|
|
|
180
|
+
// Row when inline (text sits beside the title), column otherwise.
|
|
181
|
+
const ContentFrame = inline ? XStack : YStack;
|
|
182
|
+
|
|
159
183
|
return (
|
|
160
184
|
<Skeleton loading={ loading }>
|
|
161
|
-
<
|
|
162
|
-
ref={ ref }
|
|
163
|
-
|
|
185
|
+
<XStack
|
|
186
|
+
ref={ ref as never }
|
|
187
|
+
{ ...ALERT_BASE }
|
|
188
|
+
paddingHorizontal={ SIZE[resolvedSize].paddingHorizontal }
|
|
189
|
+
backgroundColor={ STATUS_BG[status] as never }
|
|
190
|
+
className={ className }
|
|
164
191
|
style={ alertStyle }
|
|
165
|
-
{ ...alertRest }
|
|
192
|
+
{ ...(alertRest as object) }
|
|
166
193
|
>
|
|
167
194
|
{ iconElement }
|
|
168
195
|
{ children ? (
|
|
169
|
-
<
|
|
170
|
-
{ title &&
|
|
171
|
-
|
|
172
|
-
|
|
196
|
+
<ContentFrame flex={ 1 } alignItems={ inline ? 'center' : undefined }>
|
|
197
|
+
{ title && (
|
|
198
|
+
<Text fontWeight="600" fontSize={ fontSize } color={ ALERT_FG }>
|
|
199
|
+
{ title }
|
|
200
|
+
</Text>
|
|
201
|
+
) }
|
|
202
|
+
<XStack
|
|
203
|
+
flexWrap="wrap"
|
|
204
|
+
className={ descClassName }
|
|
173
205
|
style={ Object.keys(descStyle).length > 0 ? descStyle : undefined }
|
|
174
|
-
{ ...descRest }
|
|
206
|
+
{ ...(descRest as object) }
|
|
175
207
|
>
|
|
176
|
-
{ children }
|
|
177
|
-
</
|
|
178
|
-
</
|
|
208
|
+
{ ink(children, undefined, { fontSize, color: ALERT_FG }) }
|
|
209
|
+
</XStack>
|
|
210
|
+
</ContentFrame>
|
|
179
211
|
) : (
|
|
180
|
-
<
|
|
212
|
+
<Text flex={ 1 } fontWeight="600" fontSize={ fontSize } color={ ALERT_FG }>
|
|
213
|
+
{ title }
|
|
214
|
+
</Text>
|
|
181
215
|
) }
|
|
182
216
|
{ endElement }
|
|
183
217
|
{ closable && (
|
|
184
|
-
<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
/>
|
|
218
|
+
<View position="relative" alignSelf="flex-start">
|
|
219
|
+
<CloseButton onClick={ handleClose }/>
|
|
220
|
+
</View>
|
|
188
221
|
) }
|
|
189
|
-
</
|
|
222
|
+
</XStack>
|
|
190
223
|
</Skeleton>
|
|
191
224
|
);
|
|
192
225
|
},
|