@gpustack/core-ui 1.0.2 → 1.0.4

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, autoBgColor: h, preview: g = !0, loadingSize: _ = "default" } = e, v = E.useRef(null), [y, b] = E.useState({
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
- }), x = E.useMemo(() => o ? {
1534
+ }), S = E.useMemo(() => o ? {
1535
1535
  width: "100%",
1536
1536
  height: "100%"
1537
- } : {}, [o, y]), S = N(() => {
1537
+ } : {}, [o, b]), C = N(() => {
1538
1538
  r?.(e);
1539
- }, [r, e]), C = N((t) => {
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 === y.width && d === y.height || b({
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
- ]), w = E.useCallback(async () => {}, []), T = (e, t) => {
1552
+ ]), T = E.useCallback(async () => {}, []), D = (e, t) => {
1553
1553
  t.stopPropagation(), n(e);
1554
1554
  };
1555
1555
  return /* @__PURE__ */ H(oi, {
1556
- onResize: C,
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": h,
1560
+ "auto-bg-color": g,
1561
1561
  "auto-size": i,
1562
1562
  loading: o
1563
1563
  }),
1564
- children: [h && /* @__PURE__ */ H("div", {
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: { ...x },
1570
- ref: v,
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: S,
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: { objectFit: "cover" },
1603
- preview: g,
1602
+ style: {
1603
+ objectFit: "cover",
1604
+ ...h?.image
1605
+ },
1606
+ preview: _,
1604
1607
  autoSize: i,
1605
1608
  src: f,
1606
- width: y.width || "100%",
1607
- height: y.height || 100,
1608
- onLoad: w
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) => T(a, 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 u = o(), d = z(null), f = N((e) => new Promise((t) => {
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
- }), []), p = N((e) => new Promise((t, n) => {
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
- }), []), m = R(() => (0, Z.debounce)((t) => {
2175
+ }), []), y = (0, Z.debounce)((t) => {
2170
2176
  e(t);
2171
- }, 300), [e, u]), h = N(async (e) => {
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 p(e.originFileObj), { rawWidth: n, rawHeight: r } = await f(t);
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 && m(n.filter((e) => e.url).map((e) => ({
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
- }, [m, p]);
2193
+ }, [
2194
+ y,
2195
+ v,
2196
+ d,
2197
+ f
2198
+ ]);
2186
2199
  return /* @__PURE__ */ H(V, { children: H(n ? Ft.Dragger : Ft, {
2187
- ref: d,
2200
+ ref: h,
2188
2201
  accept: c,
2189
2202
  multiple: t,
2190
2203
  action: "/",
2191
2204
  fileList: [],
2192
- beforeUpload: (e) => !1,
2193
- onChange: h,
2205
+ beforeUpload: (e) => g(e) ? !1 : Ft.LIST_IGNORE,
2206
+ onChange: b,
2194
2207
  children: i ?? /* @__PURE__ */ H(q, {
2195
- title: s ?? u.formatMessage({ id: "playground.img.upload" }),
2208
+ title: s ?? m.formatMessage({ id: "playground.img.upload" }),
2196
2209
  children: /* @__PURE__ */ H(W, {
2197
2210
  disabled: r,
2198
2211
  size: l,
@@ -5390,36 +5403,39 @@ var jo = ({ height: e, title: t }) => /* @__PURE__ */ U("div", {
5390
5403
  children: /* @__PURE__ */ H(pt, { image: pt.PRESENTED_IMAGE_SIMPLE })
5391
5404
  })]
5392
5405
  }), Mo = M((e) => {
5393
- let { seriesData: t, xAxisData: n, height: r, width: i, labelFormatter: a, legendData: o, title: s } = e, { barItemConfig: c, grid: l, legend: u, title: d, tooltip: f, xAxis: p, yAxis: m } = Ao(), h = R(() => {
5406
+ let { seriesData: t, xAxisData: n, height: r, width: i, labelFormatter: a, legendData: o, title: s, stack: c = "total" } = e, { barItemConfig: l, grid: u, legend: d, title: f, tooltip: p, xAxis: m, yAxis: h } = Ao(), g = R(() => {
5394
5407
  let e = {
5395
5408
  title: { text: "" },
5396
- grid: l,
5397
- tooltip: { ...f },
5409
+ grid: u,
5410
+ tooltip: { ...p },
5398
5411
  xAxis: {
5399
- ...p,
5412
+ ...m,
5400
5413
  axisLabel: {
5401
- ...p.axisLabel,
5414
+ ...m.axisLabel,
5402
5415
  formatter: a
5403
5416
  },
5404
5417
  data: []
5405
5418
  },
5406
- yAxis: m,
5419
+ yAxis: h,
5407
5420
  legend: {
5408
- ...u,
5421
+ ...d,
5409
5422
  data: []
5410
5423
  },
5411
5424
  series: []
5412
- }, r = Z.default.map(t, (e) => ({
5413
- ...e,
5414
- ...c,
5415
- stack: "total",
5416
- itemStyle: { color: e.color }
5417
- }));
5425
+ }, r = Z.default.map(t, (e) => {
5426
+ let { stack: t, ...n } = e, r = t ?? c;
5427
+ return {
5428
+ ...n,
5429
+ ...l,
5430
+ ...r === !1 ? {} : { stack: r },
5431
+ itemStyle: { color: e.color }
5432
+ };
5433
+ });
5418
5434
  return {
5419
5435
  ...e,
5420
5436
  animation: !1,
5421
5437
  title: {
5422
- ...d,
5438
+ ...f,
5423
5439
  text: s
5424
5440
  },
5425
5441
  yAxis: { ...e.yAxis },
@@ -5434,16 +5450,17 @@ var jo = ({ height: e, title: t }) => /* @__PURE__ */ U("div", {
5434
5450
  n,
5435
5451
  s,
5436
5452
  a,
5437
- f,
5438
- l,
5439
5453
  p,
5440
- m,
5441
5454
  u,
5455
+ m,
5456
+ h,
5457
+ d,
5458
+ l,
5442
5459
  c
5443
5460
  ]);
5444
5461
  return /* @__PURE__ */ H(V, { children: t.length ? /* @__PURE__ */ H(Oo, {
5445
5462
  height: r,
5446
- options: h,
5463
+ options: g,
5447
5464
  width: i || "100%"
5448
5465
  }) : /* @__PURE__ */ H(jo, {
5449
5466
  height: r,
@@ -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;
@@ -26,6 +26,7 @@ export interface ChartProps {
26
26
  smooth?: boolean;
27
27
  color?: string;
28
28
  yAxisName?: string;
29
+ stack?: string | false;
29
30
  gaugeConfig?: {
30
31
  radius?: string;
31
32
  center?: 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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gpustack/core-ui",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "**/*.css",