@gpustack/core-ui 1.0.2 → 1.0.3
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/index.es.js
CHANGED
|
@@ -1528,20 +1528,20 @@ process.env.NODE_ENV !== "production" && (oi.displayName = "ResizeObserver"), oi
|
|
|
1528
1528
|
//#endregion
|
|
1529
1529
|
//#region src/lib/components/auto-image/single-image.tsx
|
|
1530
1530
|
var si = (e) => {
|
|
1531
|
-
let { editable: t, onDelete: n, onClick: r, autoSize: i, uid: a, loading: o, width: s, height: c, progress: l, maxHeight: u, maxWidth: d, dataUrl: f = "", label: p, style: m,
|
|
1531
|
+
let { editable: t, onDelete: n, onClick: r, autoSize: i, uid: a, loading: o, width: s, height: c, progress: l, maxHeight: u, maxWidth: d, dataUrl: f = "", label: p, style: m, styles: h, autoBgColor: g, preview: _ = !0, loadingSize: v = "default" } = e, y = E.useRef(null), [b, x] = E.useState({
|
|
1532
1532
|
width: s,
|
|
1533
1533
|
height: c
|
|
1534
|
-
}),
|
|
1534
|
+
}), S = E.useMemo(() => o ? {
|
|
1535
1535
|
width: "100%",
|
|
1536
1536
|
height: "100%"
|
|
1537
|
-
} : {}, [o,
|
|
1537
|
+
} : {}, [o, b]), C = N(() => {
|
|
1538
1538
|
r?.(e);
|
|
1539
|
-
}, [r, e]),
|
|
1539
|
+
}, [r, e]), w = N((t) => {
|
|
1540
1540
|
if (!i || !t.width || !t.height) return;
|
|
1541
1541
|
let { width: n, height: r } = t, { width: a, height: o } = e;
|
|
1542
1542
|
if (!a || !o) return;
|
|
1543
1543
|
let s = n / a, c = r / o, l = Math.min(s, c, 1), u = a * l, d = o * l;
|
|
1544
|
-
u ===
|
|
1544
|
+
u === b.width && d === b.height || x({
|
|
1545
1545
|
width: u,
|
|
1546
1546
|
height: d
|
|
1547
1547
|
});
|
|
@@ -1549,25 +1549,25 @@ var si = (e) => {
|
|
|
1549
1549
|
i,
|
|
1550
1550
|
e.width,
|
|
1551
1551
|
e.height
|
|
1552
|
-
]),
|
|
1552
|
+
]), T = E.useCallback(async () => {}, []), D = (e, t) => {
|
|
1553
1553
|
t.stopPropagation(), n(e);
|
|
1554
1554
|
};
|
|
1555
1555
|
return /* @__PURE__ */ H(oi, {
|
|
1556
|
-
onResize:
|
|
1556
|
+
onResize: w,
|
|
1557
1557
|
children: /* @__PURE__ */ U("div", {
|
|
1558
1558
|
style: { ...m },
|
|
1559
1559
|
className: (0, Y.default)("single-image", {
|
|
1560
|
-
"auto-bg-color":
|
|
1560
|
+
"auto-bg-color": g,
|
|
1561
1561
|
"auto-size": i,
|
|
1562
1562
|
loading: o
|
|
1563
1563
|
}),
|
|
1564
|
-
children: [
|
|
1564
|
+
children: [g && /* @__PURE__ */ H("div", {
|
|
1565
1565
|
className: "mask",
|
|
1566
1566
|
style: { background: `url(${f}) center center / cover no-repeat` }
|
|
1567
1567
|
}), /* @__PURE__ */ U("span", {
|
|
1568
1568
|
className: "thumb-img",
|
|
1569
|
-
style: { ...
|
|
1570
|
-
ref:
|
|
1569
|
+
style: { ...S },
|
|
1570
|
+
ref: y,
|
|
1571
1571
|
children: [/* @__PURE__ */ U(V, { children: [p && /* @__PURE__ */ H("div", {
|
|
1572
1572
|
className: "label",
|
|
1573
1573
|
children: p
|
|
@@ -1592,20 +1592,23 @@ var si = (e) => {
|
|
|
1592
1592
|
})
|
|
1593
1593
|
})
|
|
1594
1594
|
}) : /* @__PURE__ */ U("span", {
|
|
1595
|
-
onClick:
|
|
1595
|
+
onClick: C,
|
|
1596
1596
|
className: "img",
|
|
1597
1597
|
style: {
|
|
1598
1598
|
maxHeight: `min(${u}, 100%)`,
|
|
1599
1599
|
maxWidth: `min(${d}, 100%)`
|
|
1600
1600
|
},
|
|
1601
1601
|
children: [/* @__PURE__ */ H(En, {
|
|
1602
|
-
style: {
|
|
1603
|
-
|
|
1602
|
+
style: {
|
|
1603
|
+
objectFit: "cover",
|
|
1604
|
+
...h?.image
|
|
1605
|
+
},
|
|
1606
|
+
preview: _,
|
|
1604
1607
|
autoSize: i,
|
|
1605
1608
|
src: f,
|
|
1606
|
-
width:
|
|
1607
|
-
height:
|
|
1608
|
-
onLoad:
|
|
1609
|
+
width: b.width || "100%",
|
|
1610
|
+
height: b.height || 100,
|
|
1611
|
+
onLoad: T
|
|
1609
1612
|
}), l && l < 100 && /* @__PURE__ */ H("span", {
|
|
1610
1613
|
className: "small-progress-wrap",
|
|
1611
1614
|
children: /* @__PURE__ */ H(xt, {
|
|
@@ -1626,7 +1629,7 @@ var si = (e) => {
|
|
|
1626
1629
|
})]
|
|
1627
1630
|
})] }), t && /* @__PURE__ */ H("span", {
|
|
1628
1631
|
className: "del",
|
|
1629
|
-
onClick: (e) =>
|
|
1632
|
+
onClick: (e) => D(a, e),
|
|
1630
1633
|
children: /* @__PURE__ */ H(ce, {})
|
|
1631
1634
|
})]
|
|
1632
1635
|
})]
|
|
@@ -2149,8 +2152,11 @@ var wi = (e) => {
|
|
|
2149
2152
|
"image/png",
|
|
2150
2153
|
"image/jpg",
|
|
2151
2154
|
"image/jpeg"
|
|
2152
|
-
], Ei = ({ handleUpdateImgList: e, multiple: t = !0, drag: n = !1, disabled: r = !1, children: i, icon: a, title: s, accept: c = Ti.join(","), size: l = "small" }) => {
|
|
2153
|
-
let
|
|
2155
|
+
], Ei = ({ handleUpdateImgList: e, multiple: t = !0, drag: n = !1, disabled: r = !1, children: i, icon: a, title: s, accept: c = Ti.join(","), size: l = "small", maxSize: u, width: d, height: f, verifySize: p = !1 }) => {
|
|
2156
|
+
let m = o(), h = z(null), g = N((e) => {
|
|
2157
|
+
let t = c.split(",").map((e) => e.trim());
|
|
2158
|
+
return t.includes(e.type) ? u !== void 0 && e.size > u * 1024 ? (It.error(m.formatMessage({ id: "common.file.size.limit" }, { size: `${u}KB` })), !1) : !0 : (It.error(m.formatMessage({ id: "common.file.format.limit" }, { formats: t.join(", ") })), !1);
|
|
2159
|
+
}, [c, u]), _ = N((e) => new Promise((t) => {
|
|
2154
2160
|
let n = new Image();
|
|
2155
2161
|
n.onload = () => {
|
|
2156
2162
|
t({
|
|
@@ -2163,36 +2169,43 @@ var wi = (e) => {
|
|
|
2163
2169
|
rawHeight: 0
|
|
2164
2170
|
});
|
|
2165
2171
|
}, n.src = e;
|
|
2166
|
-
}), []),
|
|
2172
|
+
}), []), v = N((e) => new Promise((t, n) => {
|
|
2167
2173
|
let r = new FileReader();
|
|
2168
2174
|
r.readAsDataURL(e), r.onload = () => t(r.result), r.onerror = (e) => n(e);
|
|
2169
|
-
}), []),
|
|
2175
|
+
}), []), y = (0, Z.debounce)((t) => {
|
|
2170
2176
|
e(t);
|
|
2171
|
-
}, 300),
|
|
2177
|
+
}, 300), b = N(async (e) => {
|
|
2172
2178
|
let { fileList: t } = e, n = await Promise.all(t.map(async (e) => {
|
|
2173
2179
|
if (e.originFileObj && !e.url) {
|
|
2174
|
-
let t = await
|
|
2180
|
+
let t = await v(e.originFileObj), { rawWidth: n, rawHeight: r } = await _(t);
|
|
2181
|
+
if (d !== void 0 && n !== d && p) return It.error(m.formatMessage({ id: "common.image.limit.width" }, { width: `${d}px` })), null;
|
|
2182
|
+
if (f !== void 0 && r !== f && p) return It.error(m.formatMessage({ id: "common.image.limit.height" }, { height: `${f}px` })), null;
|
|
2175
2183
|
e.url = t, e.rawWidth = n, e.rawHeight = r;
|
|
2176
2184
|
}
|
|
2177
2185
|
return e;
|
|
2178
2186
|
}));
|
|
2179
|
-
n.length > 0 &&
|
|
2187
|
+
n.length > 0 && y(n.filter((e) => e?.url).map((e) => ({
|
|
2180
2188
|
dataUrl: e.url,
|
|
2181
2189
|
uid: e.uid,
|
|
2182
2190
|
rawWidth: e.rawWidth,
|
|
2183
2191
|
rawHeight: e.rawHeight
|
|
2184
2192
|
})));
|
|
2185
|
-
}, [
|
|
2193
|
+
}, [
|
|
2194
|
+
y,
|
|
2195
|
+
v,
|
|
2196
|
+
d,
|
|
2197
|
+
f
|
|
2198
|
+
]);
|
|
2186
2199
|
return /* @__PURE__ */ H(V, { children: H(n ? Ft.Dragger : Ft, {
|
|
2187
|
-
ref:
|
|
2200
|
+
ref: h,
|
|
2188
2201
|
accept: c,
|
|
2189
2202
|
multiple: t,
|
|
2190
2203
|
action: "/",
|
|
2191
2204
|
fileList: [],
|
|
2192
|
-
beforeUpload: (e) => !1,
|
|
2193
|
-
onChange:
|
|
2205
|
+
beforeUpload: (e) => g(e) ? !1 : Ft.LIST_IGNORE,
|
|
2206
|
+
onChange: b,
|
|
2194
2207
|
children: i ?? /* @__PURE__ */ H(q, {
|
|
2195
|
-
title: s ??
|
|
2208
|
+
title: s ?? m.formatMessage({ id: "playground.img.upload" }),
|
|
2196
2209
|
children: /* @__PURE__ */ H(W, {
|
|
2197
2210
|
disabled: r,
|
|
2198
2211
|
size: l,
|
|
@@ -17,6 +17,9 @@ interface SingleImageProps {
|
|
|
17
17
|
autoBgColor?: boolean;
|
|
18
18
|
editable?: boolean;
|
|
19
19
|
style?: React.CSSProperties;
|
|
20
|
+
styles?: {
|
|
21
|
+
image?: React.CSSProperties;
|
|
22
|
+
};
|
|
20
23
|
loadingSize?: ProgressProps['size'];
|
|
21
24
|
progressType?: 'line' | 'circle' | 'dashboard';
|
|
22
25
|
progressColor?: string;
|
|
@@ -2,6 +2,8 @@ import { default as React } from 'react';
|
|
|
2
2
|
interface UploadImgProps {
|
|
3
3
|
size?: 'small' | 'middle' | 'large';
|
|
4
4
|
height?: number;
|
|
5
|
+
width?: number;
|
|
6
|
+
verifySize?: boolean;
|
|
5
7
|
multiple?: boolean;
|
|
6
8
|
drag?: boolean;
|
|
7
9
|
disabled?: boolean;
|
|
@@ -9,6 +11,8 @@ interface UploadImgProps {
|
|
|
9
11
|
accept?: string;
|
|
10
12
|
icon?: React.ReactNode;
|
|
11
13
|
title?: React.ReactNode;
|
|
14
|
+
/** Max file size in KB */
|
|
15
|
+
maxSize?: number;
|
|
12
16
|
handleUpdateImgList: (imgList: {
|
|
13
17
|
dataUrl: string;
|
|
14
18
|
uid: number | string;
|