@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/accordion.js
CHANGED
|
@@ -1,186 +1,129 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
2
|
+
import { Accordion, Text, XStack, View } from '@hanzo/gui';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import { Children, createElement } from 'react';
|
|
5
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
6
|
|
|
8
7
|
// src/accordion.tsx
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
children
|
|
56
|
-
}
|
|
57
|
-
);
|
|
8
|
+
var ink = (children, Wrap = Text, props = {}) => {
|
|
9
|
+
let hasText = false;
|
|
10
|
+
Children.forEach(children, (child) => {
|
|
11
|
+
if (typeof child === "string" || typeof child === "number") hasText = true;
|
|
12
|
+
});
|
|
13
|
+
if (!hasText) return children;
|
|
14
|
+
return Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? createElement(Wrap, props, child) : child);
|
|
15
|
+
};
|
|
16
|
+
var IndicatorIcon = () => /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { d: "M7.5 15L12.5 10L7.5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
17
|
+
var BAR = "var(--color-text-primary)";
|
|
18
|
+
var Indicator = ({ open, variant }) => variant === "faq" ? /* @__PURE__ */ jsxs(XStack, { width: 12, height: 12, flexShrink: 0, alignItems: "center", justifyContent: "center", position: "relative", children: [
|
|
19
|
+
/* @__PURE__ */ jsx(View, { position: "absolute", width: "100%", height: 2, borderRadius: 2, backgroundColor: BAR }),
|
|
20
|
+
/* @__PURE__ */ jsx(
|
|
21
|
+
View,
|
|
22
|
+
{
|
|
23
|
+
position: "absolute",
|
|
24
|
+
width: 2,
|
|
25
|
+
height: "100%",
|
|
26
|
+
borderRadius: 2,
|
|
27
|
+
backgroundColor: BAR,
|
|
28
|
+
rotate: open ? "90deg" : "0deg"
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
] }) : /* @__PURE__ */ jsx(XStack, { flexShrink: 0, alignItems: "center", rotate: open ? "270deg" : "180deg", children: /* @__PURE__ */ jsx(IndicatorIcon, {}) });
|
|
32
|
+
var Variant = React.createContext(void 0);
|
|
33
|
+
var AccordionRoot = ({
|
|
34
|
+
value,
|
|
35
|
+
defaultValue,
|
|
36
|
+
onValueChange,
|
|
37
|
+
variant,
|
|
38
|
+
size,
|
|
39
|
+
children,
|
|
40
|
+
...rest
|
|
41
|
+
}) => /* @__PURE__ */ jsx(Variant.Provider, { value: variant, children: /* @__PURE__ */ jsx(
|
|
42
|
+
Accordion,
|
|
43
|
+
{
|
|
44
|
+
unstyled: true,
|
|
45
|
+
type: "multiple",
|
|
46
|
+
width: "100%",
|
|
47
|
+
value,
|
|
48
|
+
defaultValue,
|
|
49
|
+
onValueChange: onValueChange ? (next) => onValueChange({ value: next }) : void 0,
|
|
50
|
+
"data-variant": variant,
|
|
51
|
+
"data-size": size,
|
|
52
|
+
...rest,
|
|
53
|
+
children
|
|
58
54
|
}
|
|
59
|
-
);
|
|
60
|
-
var AccordionItem =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
className: cn(
|
|
68
|
-
"border-b border-[var(--color-border-divider)]",
|
|
69
|
-
className
|
|
70
|
-
),
|
|
71
|
-
...rest
|
|
72
|
-
}
|
|
73
|
-
);
|
|
55
|
+
) });
|
|
56
|
+
var AccordionItem = (props) => /* @__PURE__ */ jsx(
|
|
57
|
+
Accordion.Item,
|
|
58
|
+
{
|
|
59
|
+
unstyled: true,
|
|
60
|
+
borderBottomWidth: 1,
|
|
61
|
+
borderColor: "var(--color-border-divider)",
|
|
62
|
+
...props
|
|
74
63
|
}
|
|
75
64
|
);
|
|
76
|
-
var AccordionItemTrigger =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
textAlign: _textAlign,
|
|
89
|
-
cursor: _cursor,
|
|
90
|
-
display: _display,
|
|
91
|
-
alignItems: _alignItems,
|
|
92
|
-
columnGap: _columnGap,
|
|
93
|
-
...rest
|
|
94
|
-
} = props;
|
|
95
|
-
const indicatorPlacement = variant === "faq" ? "start" : indicatorPlacementProp ?? "end";
|
|
96
|
-
const indicator = variant === "faq" ? /* @__PURE__ */ jsx(
|
|
97
|
-
"span",
|
|
98
|
-
{
|
|
99
|
-
className: cn(
|
|
100
|
-
"relative inline-block h-3 w-3 shrink-0",
|
|
101
|
-
// horizontal bar (always visible)
|
|
102
|
-
"before:absolute before:left-0 before:top-1/2 before:block before:h-[2px] before:w-full before:-translate-y-1/2 before:rounded-[2px] before:bg-current",
|
|
103
|
-
// vertical bar (rotates to 0 when open)
|
|
104
|
-
"after:absolute after:left-1/2 after:top-0 after:block after:h-full after:w-[2px]",
|
|
105
|
-
"after:-translate-x-1/2 after:rounded-[2px] after:bg-current",
|
|
106
|
-
"after:transition-transform after:duration-200 after:ease-in-out",
|
|
107
|
-
// When parent trigger has data-state="open", rotate vertical bar
|
|
108
|
-
"group-data-[state=open]/trigger:after:rotate-90"
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
) : /* @__PURE__ */ jsx(
|
|
112
|
-
"span",
|
|
113
|
-
{
|
|
114
|
-
className: cn(
|
|
115
|
-
"inline-flex shrink-0 transition-transform duration-200",
|
|
116
|
-
"rotate-180",
|
|
117
|
-
"group-data-[state=open]/trigger:rotate-[270deg]"
|
|
118
|
-
),
|
|
119
|
-
children: /* @__PURE__ */ jsx(IndicatorIcon, { className: "h-5 w-5" })
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
|
-
return /* @__PURE__ */ jsx(AccordionPrimitive.Header, { asChild: true, children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
|
|
123
|
-
AccordionPrimitive.Trigger,
|
|
65
|
+
var AccordionItemTrigger = ({
|
|
66
|
+
children,
|
|
67
|
+
indicatorPlacement: placementProp,
|
|
68
|
+
variant: variantProp,
|
|
69
|
+
noIndicator,
|
|
70
|
+
headingLevel = 3,
|
|
71
|
+
...rest
|
|
72
|
+
}) => {
|
|
73
|
+
const variant = variantProp ?? React.useContext(Variant);
|
|
74
|
+
const placement = variant === "faq" ? "start" : placementProp ?? "end";
|
|
75
|
+
return /* @__PURE__ */ jsx(Accordion.Header, { unstyled: true, render: `h${headingLevel}`, "aria-level": headingLevel, display: "flex", width: "100%", children: /* @__PURE__ */ jsx(
|
|
76
|
+
Accordion.Trigger,
|
|
124
77
|
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
78
|
+
unstyled: true,
|
|
79
|
+
type: "button",
|
|
80
|
+
width: "100%",
|
|
81
|
+
flexDirection: "row",
|
|
82
|
+
alignItems: "center",
|
|
83
|
+
gap: 8,
|
|
84
|
+
paddingVertical: 12,
|
|
85
|
+
paddingHorizontal: 0,
|
|
86
|
+
borderWidth: 0,
|
|
87
|
+
backgroundColor: "transparent",
|
|
88
|
+
cursor: "pointer",
|
|
89
|
+
className: "lux-accordion-trigger",
|
|
132
90
|
...rest,
|
|
133
|
-
children: [
|
|
134
|
-
|
|
135
|
-
children,
|
|
136
|
-
|
|
137
|
-
]
|
|
91
|
+
children: (({ open }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
92
|
+
placement === "start" && !noIndicator && /* @__PURE__ */ jsx(Indicator, { open, variant }),
|
|
93
|
+
ink(children, void 0, { color: "inherit", textAlign: "left" }),
|
|
94
|
+
placement === "end" && !noIndicator && /* @__PURE__ */ jsx(Indicator, { open, variant })
|
|
95
|
+
] }))
|
|
138
96
|
}
|
|
139
|
-
) })
|
|
140
|
-
}
|
|
141
|
-
var AccordionItemContent =
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
),
|
|
153
|
-
...rest,
|
|
154
|
-
children: /* @__PURE__ */ jsx("div", { className: "pb-3", children })
|
|
155
|
-
}
|
|
156
|
-
);
|
|
157
|
-
});
|
|
97
|
+
) });
|
|
98
|
+
};
|
|
99
|
+
var AccordionItemContent = ({ children, ...rest }) => /* @__PURE__ */ jsx(
|
|
100
|
+
Accordion.Content,
|
|
101
|
+
{
|
|
102
|
+
unstyled: true,
|
|
103
|
+
overflow: "hidden",
|
|
104
|
+
paddingBottom: 12,
|
|
105
|
+
backgroundColor: "transparent",
|
|
106
|
+
...rest,
|
|
107
|
+
children: ink(children, void 0, { color: "var(--color-text-primary)" })
|
|
108
|
+
}
|
|
109
|
+
);
|
|
158
110
|
function useAccordion(items) {
|
|
159
111
|
const [value, setValue] = React.useState([]);
|
|
160
|
-
const onValueChange = React.useCallback(({ value:
|
|
161
|
-
setValue(
|
|
112
|
+
const onValueChange = React.useCallback(({ value: next }) => {
|
|
113
|
+
setValue(next);
|
|
162
114
|
}, []);
|
|
163
115
|
const scrollToItemFromUrl = React.useCallback(() => {
|
|
164
116
|
const hash = window.location.hash.replace("#", "");
|
|
165
|
-
if (!hash)
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
117
|
+
if (!hash) return;
|
|
168
118
|
const itemToScroll = items.find((item) => item.id === hash);
|
|
169
|
-
if (itemToScroll)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
el.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
173
|
-
}
|
|
174
|
-
setValue([itemToScroll.id]);
|
|
175
|
-
}
|
|
119
|
+
if (!itemToScroll) return;
|
|
120
|
+
document.getElementById(itemToScroll.id)?.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
121
|
+
setValue([itemToScroll.id]);
|
|
176
122
|
}, [items]);
|
|
177
|
-
return React.useMemo(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
scrollToItemFromUrl
|
|
182
|
-
};
|
|
183
|
-
}, [value, onValueChange, scrollToItemFromUrl]);
|
|
123
|
+
return React.useMemo(
|
|
124
|
+
() => ({ value, onValueChange, scrollToItemFromUrl }),
|
|
125
|
+
[value, onValueChange, scrollToItemFromUrl]
|
|
126
|
+
);
|
|
184
127
|
}
|
|
185
128
|
|
|
186
129
|
export { AccordionItem, AccordionItemContent, AccordionItemTrigger, AccordionRoot, useAccordion };
|
package/dist/alert.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
var gui = require('@hanzo/gui');
|
|
4
5
|
var React2 = require('react');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
7
|
var clsx = require('clsx');
|
|
6
8
|
var tailwindMerge = require('tailwind-merge');
|
|
7
|
-
var gui = require('@hanzo/gui');
|
|
8
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
9
9
|
|
|
10
10
|
function _interopNamespace(e) {
|
|
11
11
|
if (e && e.__esModule) return e;
|
|
@@ -28,9 +28,6 @@ function _interopNamespace(e) {
|
|
|
28
28
|
var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
|
29
29
|
|
|
30
30
|
// src/alert.tsx
|
|
31
|
-
function cn(...inputs) {
|
|
32
|
-
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
33
|
-
}
|
|
34
31
|
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";
|
|
35
32
|
var CloseButtonFrame = gui.styled(gui.View, {
|
|
36
33
|
name: "LuxCloseButton",
|
|
@@ -61,23 +58,19 @@ var CloseButtonFrame = gui.styled(gui.View, {
|
|
|
61
58
|
}
|
|
62
59
|
}
|
|
63
60
|
});
|
|
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
61
|
var CloseButton = React2__namespace.forwardRef(function CloseButton2(props, ref) {
|
|
70
62
|
const { variant: _variant, size: _size, className, children, ...rest } = props;
|
|
71
63
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
72
64
|
CloseButtonFrame,
|
|
73
65
|
{
|
|
74
66
|
ref,
|
|
75
|
-
className
|
|
67
|
+
className,
|
|
76
68
|
...rest,
|
|
77
69
|
children: children ?? /* @__PURE__ */ jsxRuntime.jsx(
|
|
78
70
|
"svg",
|
|
79
71
|
{
|
|
80
|
-
|
|
72
|
+
width: 20,
|
|
73
|
+
height: 20,
|
|
81
74
|
viewBox: "0 0 20 20",
|
|
82
75
|
fill: "none",
|
|
83
76
|
"aria-hidden": "true",
|
|
@@ -93,6 +86,17 @@ var CloseButton = React2__namespace.forwardRef(function CloseButton2(props, ref)
|
|
|
93
86
|
}
|
|
94
87
|
);
|
|
95
88
|
});
|
|
89
|
+
var ink = (children, Wrap = gui.Text, props = {}) => {
|
|
90
|
+
let hasText = false;
|
|
91
|
+
React2.Children.forEach(children, (child) => {
|
|
92
|
+
if (typeof child === "string" || typeof child === "number") hasText = true;
|
|
93
|
+
});
|
|
94
|
+
if (!hasText) return children;
|
|
95
|
+
return React2.Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? React2.createElement(Wrap, props, child) : child);
|
|
96
|
+
};
|
|
97
|
+
function cn(...inputs) {
|
|
98
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
99
|
+
}
|
|
96
100
|
var SHIM_PROPS = [
|
|
97
101
|
"w",
|
|
98
102
|
"h",
|
|
@@ -276,22 +280,30 @@ React2__namespace.forwardRef(
|
|
|
276
280
|
)) });
|
|
277
281
|
}
|
|
278
282
|
);
|
|
279
|
-
var IndicatorIcon = (
|
|
280
|
-
var ALERT_BASE =
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
283
|
+
var IndicatorIcon = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { width: 20, height: 20, viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.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" }) });
|
|
284
|
+
var ALERT_BASE = {
|
|
285
|
+
width: "100%",
|
|
286
|
+
position: "relative",
|
|
287
|
+
alignItems: "flex-start",
|
|
288
|
+
borderRadius: 4,
|
|
289
|
+
gap: 8,
|
|
290
|
+
paddingVertical: 8
|
|
291
|
+
};
|
|
292
|
+
var ALERT_FG = "var(--color-alert-fg)";
|
|
293
|
+
var STATUS_BG = {
|
|
294
|
+
info: "var(--color-alert-bg-info)",
|
|
295
|
+
warning: "var(--color-alert-bg-warning)",
|
|
296
|
+
warning_table: "var(--color-alert-bg-warning-table)",
|
|
297
|
+
success: "var(--color-alert-bg-success)",
|
|
298
|
+
error: "var(--color-alert-bg-error)"
|
|
287
299
|
};
|
|
288
|
-
var
|
|
289
|
-
sm:
|
|
290
|
-
md:
|
|
300
|
+
var SIZE = {
|
|
301
|
+
sm: { paddingHorizontal: 8, fontSize: 12 },
|
|
302
|
+
md: { paddingHorizontal: 12, fontSize: 16 }
|
|
291
303
|
};
|
|
292
|
-
var
|
|
293
|
-
sm:
|
|
294
|
-
md:
|
|
304
|
+
var INDICATOR_SIZE = {
|
|
305
|
+
sm: { marginVertical: 0 },
|
|
306
|
+
md: { marginVertical: 2 }
|
|
295
307
|
};
|
|
296
308
|
var Alert = React2__namespace.forwardRef(
|
|
297
309
|
function Alert2(props, ref) {
|
|
@@ -320,7 +332,8 @@ var Alert = React2__namespace.forwardRef(
|
|
|
320
332
|
const alertStyle = Object.keys(shimStyle).length > 0 ? shimStyle : void 0;
|
|
321
333
|
const [isOpen, setIsOpen] = React2__namespace.useState(true);
|
|
322
334
|
const resolvedSize = size ?? "md";
|
|
323
|
-
const
|
|
335
|
+
const fontSize = SIZE[resolvedSize].fontSize;
|
|
336
|
+
const defaultIcon = /* @__PURE__ */ jsxRuntime.jsx(IndicatorIcon, {});
|
|
324
337
|
const iconElement = (() => {
|
|
325
338
|
if (startElement !== void 0) {
|
|
326
339
|
return startElement;
|
|
@@ -328,10 +341,20 @@ var Alert = React2__namespace.forwardRef(
|
|
|
328
341
|
if (!showIcon && icon === void 0) {
|
|
329
342
|
return null;
|
|
330
343
|
}
|
|
331
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
344
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
345
|
+
gui.XStack,
|
|
346
|
+
{
|
|
347
|
+
alignItems: "center",
|
|
348
|
+
justifyContent: "center",
|
|
349
|
+
flexShrink: 0,
|
|
350
|
+
width: 20,
|
|
351
|
+
height: 20,
|
|
352
|
+
...INDICATOR_SIZE[resolvedSize],
|
|
353
|
+
className: "lux-icon",
|
|
354
|
+
style: { color: ALERT_FG },
|
|
355
|
+
children: icon || defaultIcon
|
|
356
|
+
}
|
|
357
|
+
);
|
|
335
358
|
})();
|
|
336
359
|
const handleClose = React2__namespace.useCallback(() => {
|
|
337
360
|
setIsOpen(false);
|
|
@@ -360,35 +383,34 @@ var Alert = React2__namespace.forwardRef(
|
|
|
360
383
|
...descRowGap !== void 0 ? { rowGap: typeof descRowGap === "number" ? `${descRowGap * 4}px` : descRowGap } : {},
|
|
361
384
|
...descColumnGap !== void 0 ? { columnGap: typeof descColumnGap === "number" ? `${descColumnGap * 4}px` : descColumnGap } : {}
|
|
362
385
|
};
|
|
386
|
+
const ContentFrame = inline ? gui.XStack : gui.YStack;
|
|
363
387
|
return /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { loading, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
364
|
-
|
|
388
|
+
gui.XStack,
|
|
365
389
|
{
|
|
366
390
|
ref,
|
|
367
|
-
|
|
391
|
+
...ALERT_BASE,
|
|
392
|
+
paddingHorizontal: SIZE[resolvedSize].paddingHorizontal,
|
|
393
|
+
backgroundColor: STATUS_BG[status],
|
|
394
|
+
className,
|
|
368
395
|
style: alertStyle,
|
|
369
396
|
...alertRest,
|
|
370
397
|
children: [
|
|
371
398
|
iconElement,
|
|
372
|
-
children ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
373
|
-
title && /* @__PURE__ */ jsxRuntime.jsx(
|
|
399
|
+
children ? /* @__PURE__ */ jsxRuntime.jsxs(ContentFrame, { flex: 1, alignItems: inline ? "center" : void 0, children: [
|
|
400
|
+
title && /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontWeight: "600", fontSize, color: ALERT_FG, children: title }),
|
|
374
401
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
375
|
-
|
|
402
|
+
gui.XStack,
|
|
376
403
|
{
|
|
377
|
-
|
|
404
|
+
flexWrap: "wrap",
|
|
405
|
+
className: descClassName,
|
|
378
406
|
style: Object.keys(descStyle).length > 0 ? descStyle : void 0,
|
|
379
407
|
...descRest,
|
|
380
|
-
children
|
|
408
|
+
children: ink(children, void 0, { fontSize, color: ALERT_FG })
|
|
381
409
|
}
|
|
382
410
|
)
|
|
383
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
411
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { flex: 1, fontWeight: "600", fontSize, color: ALERT_FG, children: title }),
|
|
384
412
|
endElement,
|
|
385
|
-
closable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
386
|
-
CloseButton,
|
|
387
|
-
{
|
|
388
|
-
className: "relative self-start",
|
|
389
|
-
onClick: handleClose
|
|
390
|
-
}
|
|
391
|
-
)
|
|
413
|
+
closable && /* @__PURE__ */ jsxRuntime.jsx(gui.View, { position: "relative", alignSelf: "flex-start", children: /* @__PURE__ */ jsxRuntime.jsx(CloseButton, { onClick: handleClose }) })
|
|
392
414
|
]
|
|
393
415
|
}
|
|
394
416
|
) });
|