@gpustack/core-ui 1.0.23 → 1.0.24

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";
@@ -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;
@@ -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.24",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "**/*.css",