@gpustack/core-ui 1.0.23 → 1.0.25

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.
@@ -1,6 +1,6 @@
1
1
  import { o as e, r as t, t as n } from "./rolldown-runtime-gEudmnaM.js";
2
2
  import { t as r } from "./lodash-DVkZQU_K.js";
3
- import { t as i } from "./highlight-code-gZJ7edZl.js";
3
+ import { t as i } from "./highlight-code-C8SfAI6k.js";
4
4
  import a, { Fragment as o, useCallback as s, useEffect as c, useMemo as l } from "react";
5
5
  import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
6
6
  import { EyeOutlined as p } from "@ant-design/icons";
@@ -25,6 +25,8 @@ interface SystemMessageProps {
25
25
  onChange: (e: any) => void;
26
26
  onPaste?: (e: any) => void;
27
27
  onDelete?: () => void;
28
+ actions?: React.ReactNode;
29
+ showUpload?: boolean;
28
30
  onSelect?: (data: {
29
31
  start: number;
30
32
  end: number;
@@ -0,0 +1,12 @@
1
+ export interface ImageURLInputProps {
2
+ /** Whether the invalid-url tooltip / error state is shown */
3
+ open?: boolean;
4
+ inputProps?: Record<string, any>;
5
+ /** Commit the typed url (fired on blur and on Enter) */
6
+ onSubmit: (e: any) => void;
7
+ /** Discard the url input */
8
+ onClose: (e?: any) => void;
9
+ onEscape: (e: any) => void;
10
+ }
11
+ declare const ImageURLInput: import('react').ForwardRefExoticComponent<ImageURLInputProps & import('react').RefAttributes<any>>;
12
+ export default ImageURLInput;
@@ -68,6 +68,7 @@ export { default as IconFont } from './icon-font';
68
68
  export { default as icons } from './icon-font/icons';
69
69
  export { default as ImageEditor } from './image-editor';
70
70
  export { processImage } from './image-editor/extract-image-colors';
71
+ export { default as ImageURLInput, type ImageURLInputProps } from './image-url-input';
71
72
  export { default as InfiniteScroller } from './infinite-scroller';
72
73
  export { default as InfiniteScrollerProvider } from './infinite-scroller/infinite-scroller-provider';
73
74
  export { useScrollerContext } from './infinite-scroller/use-scroller-context';
@@ -125,5 +126,6 @@ export { default as Transfer } from './transfer';
125
126
  export { default as TransitionWrapper } from './transition';
126
127
  export { default as UploadAudio } from './upload-audio';
127
128
  export { default as UploadImage } from './upload-image';
129
+ export { default as UploadImageButton, type UploadImageButtonProps } from './upload-image-button';
128
130
  export { default as ViewerEditor } from './viewer-editor';
129
131
  export { default as XTerminal } from './x-terminal';
@@ -0,0 +1,14 @@
1
+ import { default as React } from 'react';
2
+ export interface UploadImageButtonProps {
3
+ size?: 'small' | 'middle' | 'large';
4
+ onOpenChange?: (open: boolean) => void;
5
+ /** Receives images selected through the file picker */
6
+ onUpdateImgList: (list: {
7
+ uid: number | string;
8
+ dataUrl: string;
9
+ }[]) => void;
10
+ /** Switch the consumer into "add image from url" mode */
11
+ onAddFromUrl: () => void;
12
+ }
13
+ declare const UploadImageButton: React.FC<UploadImageButtonProps>;
14
+ export default UploadImageButton;
@@ -10,6 +10,9 @@ interface ViewerProps {
10
10
  placeholder?: string;
11
11
  variant?: 'bordered' | 'borderless';
12
12
  schema?: any;
13
+ onChange?: (value: string | undefined, event: any) => void;
14
+ onBlur?: () => void;
15
+ onFocus?: () => void;
13
16
  }
14
17
  declare const EditorInner: React.FC<ViewerProps>;
15
18
  export default EditorInner;
@@ -12,6 +12,9 @@ interface ViewerProps {
12
12
  schema?: any;
13
13
  isDarkTheme?: boolean;
14
14
  onUpload?: (content: string) => void;
15
+ onChange?: (value: string | undefined, event: any) => void;
16
+ onBlur?: () => void;
17
+ onFocus?: () => void;
15
18
  }
16
19
  declare const YamlEditor: React.FC<ViewerProps>;
17
20
  export default YamlEditor;
@@ -1,15 +1,27 @@
1
- declare const useAddImage: (options: {
2
- size?: "small" | "middle" | "large";
3
- inputProps?: Record<string, any>;
4
- handleUpdateImgList: (list: {
5
- uid: number | string;
6
- dataUrl: string;
7
- }[]) => void;
1
+ interface ImageItem {
2
+ uid: number | string;
3
+ dataUrl: string;
4
+ }
5
+ interface UseAddImageOptions {
6
+ handleUpdateImgList: (list: ImageItem[]) => void;
8
7
  updateUidCount: () => number | string;
9
- }) => {
8
+ }
9
+ /**
10
+ * Owns the interaction state for the "add image" flow (file picker dropdown +
11
+ * add-by-url input). It returns only state and handlers — render the UI with
12
+ * the `UploadImageButton` and `ImageURLInput` components, wiring these handlers
13
+ * to them. This keeps the logic reusable and lets the UI be memoized/composed
14
+ * by the consumer.
15
+ */
16
+ declare const useAddImage: (options: UseAddImageOptions) => {
10
17
  isFromUrl: boolean;
11
- ImageURLInput: import("react/jsx-runtime").JSX.Element | null;
12
18
  dropDownOpen: boolean;
13
- UploadImageButton: import("react/jsx-runtime").JSX.Element;
19
+ openImgTips: boolean;
20
+ inputImgRef: import('react').MutableRefObject<any>;
21
+ handleAddImgFromUrl: () => void;
22
+ handleInputImageUrl: (e: any) => Promise<void>;
23
+ handleClose: (e?: any) => void;
24
+ handleOnEscape: (e: any) => void;
25
+ handleOnOpenChange: (open: boolean) => void;
14
26
  };
15
27
  export default useAddImage;
@@ -28,7 +28,7 @@ export default function useOverlayScroller(data?: {
28
28
  initialize: (this: unknown, el: any) => any;
29
29
  instance: React.MutableRefObject<any>;
30
30
  scrollEventElement: React.MutableRefObject<any>;
31
- initialized: React.MutableRefObject<boolean>;
31
+ initialized: boolean;
32
32
  getScrollElementScrollableHeight: () => {
33
33
  scrollTop: any;
34
34
  scrollHeight: number;
@@ -12,7 +12,7 @@ import { yamlDefaults as v } from "monaco-yaml";
12
12
  //#region src/lib/components/yaml-editor/editor.tsx
13
13
  g.config({ monaco: _ });
14
14
  var y = "inmemory://model/config.yaml", b = n((e, n) => {
15
- let { value: s, height: c = 380, theme: u = "vs-dark", header: d, variant: f = "borderless", schema: p, placeholder: m } = e, g = a(null), _ = a(null), b = a(null), x = (e) => {
15
+ let { value: s, height: c = 380, theme: u = "vs-dark", header: d, variant: f = "borderless", schema: p, placeholder: m, onChange: g, onBlur: _, onFocus: b } = e, x = a(null), S = a(null), C = a(null), w = (e) => {
16
16
  let t = e.Uri.parse(y);
17
17
  v.setDiagnosticsOptions({
18
18
  validate: !1,
@@ -24,35 +24,39 @@ var y = "inmemory://model/config.yaml", b = n((e, n) => {
24
24
  schema: p
25
25
  }]
26
26
  });
27
- }, S = (e, t) => {
28
- g.current = e, _.current = t;
29
- }, C = () => {
30
- g.current && setTimeout(() => {
31
- g.current?.getAction?.("editor.action.formatDocument")?.run().then(() => {
27
+ }, T = (e, t) => {
28
+ x.current = e, S.current = t, e.onDidBlurEditorText?.(() => {
29
+ _?.();
30
+ }), e.onDidFocusEditorText?.(() => {
31
+ b?.();
32
+ });
33
+ }, E = () => {
34
+ x.current && setTimeout(() => {
35
+ x.current?.getAction?.("editor.action.formatDocument")?.run().then(() => {
32
36
  console.log("format success");
33
37
  });
34
38
  }, 100);
35
- }, w = () => {
36
- let e = g.current?.getModel()?.uri;
37
- return _.current?.editor.getModelMarkers({ resource: e });
39
+ }, D = () => {
40
+ let e = x.current?.getModel()?.uri;
41
+ return S.current?.editor.getModelMarkers({ resource: e });
38
42
  };
39
43
  return i(n, () => ({
40
44
  format: () => {
41
- C();
45
+ E();
42
46
  },
43
- getValue: () => g.current?.getValue?.(),
47
+ getValue: () => x.current?.getValue?.(),
44
48
  setValue: (e) => {
45
- g.current?.setValue?.(e);
49
+ x.current?.setValue?.(e);
46
50
  },
47
51
  dispose: () => {
48
- g.current?.dispose?.(), b.current?.dispose?.();
52
+ x.current?.dispose?.(), C.current?.dispose?.();
49
53
  },
50
54
  validate() {
51
- return w();
55
+ return D();
52
56
  },
53
- editor: g.current
57
+ editor: x.current
54
58
  })), r(() => {
55
- C();
59
+ E();
56
60
  }, [s]), /* @__PURE__ */ o(t, {
57
61
  header: d,
58
62
  variant: f,
@@ -76,8 +80,9 @@ var y = "inmemory://model/config.yaml", b = n((e, n) => {
76
80
  }
77
81
  },
78
82
  loading: /* @__PURE__ */ o(l, { style: { fontSize: 24 } }),
79
- beforeMount: x,
80
- onMount: S
83
+ beforeMount: w,
84
+ onMount: T,
85
+ onChange: g
81
86
  })
82
87
  });
83
88
  }), { Text: x } = d;
@@ -113,31 +118,31 @@ var S = m.div`
113
118
  background-color: var(--ant-color-fill-quaternary);
114
119
  border-radius: var(--ant-border-radius-lg) var(--ant-border-radius-lg) 0 0;
115
120
  `, T = n((t, n) => {
116
- let { value: l, height: d = 380, variant: m = "borderless", isDarkTheme: h, schema: g, placeholder: _, validateMessage: v, title: y, onUpload: x } = t, T = e(), E = a(null), D = (e) => {
117
- E.current?.setValue?.(e);
121
+ let { value: l, height: d = 380, variant: m = "borderless", isDarkTheme: h, schema: g, placeholder: _, validateMessage: v, title: y, onUpload: x, onChange: T, onBlur: E, onFocus: D } = t, O = e(), k = a(null), A = (e) => {
122
+ k.current?.setValue?.(e);
118
123
  };
119
124
  return i(n, () => ({
120
125
  format: () => {
121
- E.current?.format();
126
+ k.current?.format();
122
127
  },
123
- getValue: () => E.current?.getValue?.(),
128
+ getValue: () => k.current?.getValue?.(),
124
129
  setValue: (e) => {
125
- E.current?.setValue?.(e);
130
+ k.current?.setValue?.(e);
126
131
  },
127
132
  dispose: () => {
128
- E.current?.dispose?.();
133
+ k.current?.dispose?.();
129
134
  },
130
135
  validate() {
131
- return E.current?.validate();
136
+ return k.current?.validate();
132
137
  },
133
- editor: E.current
138
+ editor: k.current
134
139
  })), r(() => {
135
- E.current?.format();
140
+ k.current?.format();
136
141
  }, [l]), /* @__PURE__ */ s(S, {
137
142
  className: "yaml-editor-container",
138
143
  style: { minHeight: d },
139
144
  children: [/* @__PURE__ */ o(b, {
140
- ref: E,
145
+ ref: k,
141
146
  header: /* @__PURE__ */ s(w, { children: [/* @__PURE__ */ o("span", {
142
147
  className: "title",
143
148
  children: y || "YAML"
@@ -149,7 +154,7 @@ var S = m.div`
149
154
  let t = new FileReader();
150
155
  return t.onload = (e) => {
151
156
  let t = e.target?.result;
152
- typeof t == "string" ? (x?.(t), D(t)) : p.error("Failed to read file content!");
157
+ typeof t == "string" ? (x?.(t), A(t)) : p.error("Failed to read file content!");
153
158
  }, t.readAsText(e), !1;
154
159
  },
155
160
  showUploadList: !1,
@@ -158,7 +163,7 @@ var S = m.div`
158
163
  icon: /* @__PURE__ */ o(c, {}),
159
164
  type: "text",
160
165
  size: "small",
161
- children: T.formatMessage({ id: "common.button.import" })
166
+ children: O.formatMessage({ id: "common.button.import" })
162
167
  })
163
168
  })] }),
164
169
  variant: m,
@@ -166,7 +171,10 @@ var S = m.div`
166
171
  theme: h ? "vs-dark" : "light",
167
172
  value: l,
168
173
  placeholder: _,
169
- schema: g
174
+ schema: g,
175
+ onChange: T,
176
+ onBlur: E,
177
+ onFocus: D
170
178
  }), v && /* @__PURE__ */ o(C, {
171
179
  type: "danger",
172
180
  children: v
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gpustack/core-ui",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "**/*.css",