@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/image.js
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React2 from 'react';
|
|
3
|
+
import React2__default 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/image.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 CHAKRA_SPACING_SCALE = {
|
|
200
|
+
"0": "0px",
|
|
201
|
+
"1": "0.25rem",
|
|
202
|
+
"2": "0.5rem",
|
|
203
|
+
"3": "0.75rem",
|
|
204
|
+
"4": "1rem",
|
|
205
|
+
"5": "1.25rem",
|
|
206
|
+
"6": "1.5rem",
|
|
207
|
+
"7": "1.75rem",
|
|
208
|
+
"8": "2rem",
|
|
209
|
+
"10": "2.5rem",
|
|
210
|
+
"12": "3rem",
|
|
211
|
+
"14": "3.5rem",
|
|
212
|
+
"16": "4rem",
|
|
213
|
+
"20": "5rem"
|
|
214
|
+
};
|
|
215
|
+
var CHAKRA_RADII = {
|
|
216
|
+
none: "0",
|
|
217
|
+
sm: "0.125rem",
|
|
218
|
+
base: "0.25rem",
|
|
219
|
+
md: "0.375rem",
|
|
220
|
+
lg: "0.5rem",
|
|
221
|
+
xl: "0.75rem",
|
|
222
|
+
"2xl": "1rem",
|
|
223
|
+
"3xl": "1.5rem",
|
|
224
|
+
full: "9999px"
|
|
225
|
+
};
|
|
226
|
+
function resolveSize(value) {
|
|
227
|
+
if (value === void 0) return void 0;
|
|
228
|
+
if (typeof value === "number") return `${value}px`;
|
|
229
|
+
if (CHAKRA_SPACING_SCALE[value]) return CHAKRA_SPACING_SCALE[value];
|
|
230
|
+
return value;
|
|
231
|
+
}
|
|
232
|
+
function resolveRadius(value) {
|
|
233
|
+
if (value === void 0) return void 0;
|
|
234
|
+
if (typeof value === "number") return `${value}px`;
|
|
235
|
+
if (CHAKRA_RADII[value]) return CHAKRA_RADII[value];
|
|
236
|
+
return String(value);
|
|
237
|
+
}
|
|
238
|
+
function resolveSimple(value) {
|
|
239
|
+
if (value === void 0) return void 0;
|
|
240
|
+
return typeof value === "number" ? value : value;
|
|
241
|
+
}
|
|
242
|
+
function baseValue(val) {
|
|
243
|
+
if (val === void 0) return void 0;
|
|
244
|
+
if (typeof val === "object" && val !== null && ("base" in val || "md" in val || "lg" in val)) {
|
|
245
|
+
return val.base;
|
|
246
|
+
}
|
|
247
|
+
return val;
|
|
248
|
+
}
|
|
249
|
+
function buildStyle(props) {
|
|
250
|
+
const s = {};
|
|
251
|
+
const size = resolveSize(props.boxSize);
|
|
252
|
+
if (size) {
|
|
253
|
+
s.width = size;
|
|
254
|
+
s.height = size;
|
|
255
|
+
}
|
|
256
|
+
const w = resolveSize(props.width ?? baseValue(props.w));
|
|
257
|
+
if (w) s.width = w;
|
|
258
|
+
const hVal = baseValue(props.height ?? props.h);
|
|
259
|
+
const h = resolveSize(hVal);
|
|
260
|
+
if (h) s.height = h;
|
|
261
|
+
const maxW = resolveSize(props.maxW);
|
|
262
|
+
if (maxW) s.maxWidth = maxW;
|
|
263
|
+
const maxH = resolveSize(props.maxH);
|
|
264
|
+
if (maxH) s.maxHeight = maxH;
|
|
265
|
+
const minW = resolveSize(props.minW);
|
|
266
|
+
if (minW) s.minWidth = minW;
|
|
267
|
+
const br = resolveRadius(props.borderRadius);
|
|
268
|
+
if (br) s.borderRadius = br;
|
|
269
|
+
const mr = resolveSize(props.marginRight ?? props.mr);
|
|
270
|
+
if (mr) s.marginRight = mr;
|
|
271
|
+
const ml = resolveSize(props.ml);
|
|
272
|
+
if (ml) s.marginLeft = ml;
|
|
273
|
+
const mt = resolveSize(props.mt);
|
|
274
|
+
if (mt) s.marginTop = mt;
|
|
275
|
+
const mb = resolveSize(props.mb);
|
|
276
|
+
if (mb) s.marginBottom = mb;
|
|
277
|
+
const mx = resolveSize(props.mx);
|
|
278
|
+
if (mx) {
|
|
279
|
+
s.marginLeft = mx;
|
|
280
|
+
s.marginRight = mx;
|
|
281
|
+
}
|
|
282
|
+
const my = resolveSize(props.my);
|
|
283
|
+
if (my) {
|
|
284
|
+
s.marginTop = my;
|
|
285
|
+
s.marginBottom = my;
|
|
286
|
+
}
|
|
287
|
+
if (props.display !== void 0) s.display = String(props.display);
|
|
288
|
+
if (props.position !== void 0) s.position = String(props.position);
|
|
289
|
+
const top = resolveSimple(props.top);
|
|
290
|
+
if (top !== void 0) s.top = typeof top === "number" ? `${top}px` : top;
|
|
291
|
+
const leftVal = baseValue(props.left);
|
|
292
|
+
const left = resolveSimple(leftVal);
|
|
293
|
+
if (left !== void 0) s.left = typeof left === "number" ? `${left}px` : left;
|
|
294
|
+
const right = resolveSimple(props.right);
|
|
295
|
+
if (right !== void 0) s.right = typeof right === "number" ? `${right}px` : right;
|
|
296
|
+
const bottom = resolveSimple(props.bottom);
|
|
297
|
+
if (bottom !== void 0) s.bottom = typeof bottom === "number" ? `${bottom}px` : bottom;
|
|
298
|
+
if (props.zIndex !== void 0) s.zIndex = typeof props.zIndex === "number" ? props.zIndex : Number(props.zIndex) || void 0;
|
|
299
|
+
if (props.objectFit !== void 0) s.objectFit = String(props.objectFit);
|
|
300
|
+
if (props.objectPosition !== void 0) s.objectPosition = String(props.objectPosition);
|
|
301
|
+
if (props.flexShrink !== void 0) s.flexShrink = typeof props.flexShrink === "number" ? props.flexShrink : Number(props.flexShrink);
|
|
302
|
+
if (props.overflow !== void 0) s.overflow = String(props.overflow);
|
|
303
|
+
return s;
|
|
304
|
+
}
|
|
305
|
+
var STYLE_PROP_KEYS = /* @__PURE__ */ new Set([
|
|
306
|
+
"boxSize",
|
|
307
|
+
"borderRadius",
|
|
308
|
+
"width",
|
|
309
|
+
"w",
|
|
310
|
+
"height",
|
|
311
|
+
"h",
|
|
312
|
+
"maxW",
|
|
313
|
+
"maxH",
|
|
314
|
+
"minW",
|
|
315
|
+
"mr",
|
|
316
|
+
"mb",
|
|
317
|
+
"ml",
|
|
318
|
+
"mt",
|
|
319
|
+
"mx",
|
|
320
|
+
"my",
|
|
321
|
+
"marginRight",
|
|
322
|
+
"display",
|
|
323
|
+
"position",
|
|
324
|
+
"top",
|
|
325
|
+
"left",
|
|
326
|
+
"right",
|
|
327
|
+
"bottom",
|
|
328
|
+
"zIndex",
|
|
329
|
+
"objectFit",
|
|
330
|
+
"objectPosition",
|
|
331
|
+
"flexShrink",
|
|
332
|
+
"overflow"
|
|
333
|
+
]);
|
|
334
|
+
function extractStyleProps(props) {
|
|
335
|
+
const styleProps = {};
|
|
336
|
+
const rest = {};
|
|
337
|
+
for (const key in props) {
|
|
338
|
+
if (STYLE_PROP_KEYS.has(key)) {
|
|
339
|
+
styleProps[key] = props[key];
|
|
340
|
+
} else {
|
|
341
|
+
rest[key] = props[key];
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return { styleProps, rest };
|
|
345
|
+
}
|
|
346
|
+
var Image = React2__default.forwardRef(
|
|
347
|
+
function Image2(props, ref) {
|
|
348
|
+
const { fallback, src, onLoad, onError, skeletonWidth, skeletonHeight, alt, className, style: styleProp, ...allRest } = props;
|
|
349
|
+
const { styleProps, rest: extraProps } = extractStyleProps(allRest);
|
|
350
|
+
const [loading, setLoading] = React2__default.useState(true);
|
|
351
|
+
const [error, setError] = React2__default.useState(false);
|
|
352
|
+
const handleLoadError = React2__default.useCallback((event) => {
|
|
353
|
+
setError(true);
|
|
354
|
+
setLoading(false);
|
|
355
|
+
onError?.(event);
|
|
356
|
+
}, [onError]);
|
|
357
|
+
const handleLoadSuccess = React2__default.useCallback((event) => {
|
|
358
|
+
setLoading(false);
|
|
359
|
+
onLoad?.(event);
|
|
360
|
+
}, [onLoad]);
|
|
361
|
+
const passthroughProps = allRest;
|
|
362
|
+
if (!src && fallback) {
|
|
363
|
+
if (React2__default.isValidElement(fallback)) {
|
|
364
|
+
return React2__default.cloneElement(fallback, passthroughProps);
|
|
365
|
+
}
|
|
366
|
+
return fallback;
|
|
367
|
+
}
|
|
368
|
+
if (error) {
|
|
369
|
+
if (React2__default.isValidElement(fallback)) {
|
|
370
|
+
return React2__default.cloneElement(fallback, passthroughProps);
|
|
371
|
+
}
|
|
372
|
+
return fallback;
|
|
373
|
+
}
|
|
374
|
+
const skeletonProps = {
|
|
375
|
+
...passthroughProps,
|
|
376
|
+
...skeletonWidth !== void 0 && { width: skeletonWidth },
|
|
377
|
+
...skeletonHeight !== void 0 && { height: skeletonHeight }
|
|
378
|
+
};
|
|
379
|
+
const computedStyle = buildStyle(styleProps);
|
|
380
|
+
const mergedStyle = {
|
|
381
|
+
...computedStyle,
|
|
382
|
+
...styleProp,
|
|
383
|
+
display: loading ? "none" : computedStyle.display || styleProp?.display || "block"
|
|
384
|
+
};
|
|
385
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
386
|
+
loading && /* @__PURE__ */ jsx(Skeleton, { loading: true, ...skeletonProps }),
|
|
387
|
+
/* @__PURE__ */ jsx(
|
|
388
|
+
"img",
|
|
389
|
+
{
|
|
390
|
+
ref,
|
|
391
|
+
src,
|
|
392
|
+
alt: alt || "",
|
|
393
|
+
onError: handleLoadError,
|
|
394
|
+
onLoad: handleLoadSuccess,
|
|
395
|
+
className: cn(className),
|
|
396
|
+
style: mergedStyle,
|
|
397
|
+
...extraProps
|
|
398
|
+
}
|
|
399
|
+
)
|
|
400
|
+
] });
|
|
401
|
+
}
|
|
402
|
+
);
|
|
403
|
+
|
|
404
|
+
export { Image };
|