ant-design-x-vue 1.2.0 → 1.2.1

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.
@@ -1465,18 +1465,16 @@ const Et = 1, dn = /* @__PURE__ */ Nt({
1465
1465
  name: "AXAttachmentsFileList",
1466
1466
  __name: "FileList",
1467
1467
  props: {
1468
- prefixCls: null,
1469
- items: null,
1470
- onRemove: {
1471
- type: Function
1472
- },
1473
- overflow: null,
1474
- upload: null,
1475
- imageProps: null,
1476
- listClassName: null,
1477
- listStyle: null,
1478
- itemClassName: null,
1479
- itemStyle: null
1468
+ prefixCls: {},
1469
+ items: {},
1470
+ onRemove: {},
1471
+ overflow: {},
1472
+ upload: {},
1473
+ imageProps: {},
1474
+ listClassName: {},
1475
+ listStyle: {},
1476
+ itemClassName: {},
1477
+ itemStyle: {}
1480
1478
  },
1481
1479
  setup(t) {
1482
1480
  const e = be(() => `${t.prefixCls}-list`), r = me("file-list-container"), [n, a] = I(!1), i = xe();
@@ -1,8 +1,8 @@
1
1
  import { defineComponent as a, mergeDefaults as r, createVNode as l, mergeProps as s } from "vue";
2
2
  import { a as i, c as u } from "../../attachments/Attachments2.mjs";
3
3
  import c from "./ActionButton/index.mjs";
4
- import m from "../StopLoading.mjs";
5
- import { useActionButtonContextInject as d } from "./ActionButton/context.mjs";
4
+ import d from "../StopLoading.mjs";
5
+ import { useActionButtonContextInject as m } from "./ActionButton/context.mjs";
6
6
  import { theme as p } from "ant-design-vue";
7
7
  const x = /* @__PURE__ */ a({
8
8
  name: "AXSenderLoadingButton",
@@ -27,11 +27,11 @@ const x = /* @__PURE__ */ a({
27
27
  }, {
28
28
  type: "primary",
29
29
  shape: "circle",
30
- icon: null,
30
+ icon: void 0,
31
31
  disabled: void 0
32
32
  }),
33
33
  setup(e) {
34
- const o = i(e, ["type", "shape", "icon", "disabled"]), n = d(), {
34
+ const o = i(e, ["type", "shape", "icon", "disabled"]), n = m(), {
35
35
  token: t
36
36
  } = p.useToken();
37
37
  return () => l(c, s({
@@ -47,7 +47,7 @@ const x = /* @__PURE__ */ a({
47
47
  class: u(`${n.value.prefixCls}-loading-button`),
48
48
  action: "onCancel"
49
49
  }), {
50
- default: () => [l(m, {
50
+ default: () => [l(d, {
51
51
  className: `${n.value.prefixCls}-loading-icon`
52
52
  }, null)]
53
53
  });
@@ -1,33 +1,41 @@
1
1
  import r from "../../_util/hooks/use-state.mjs";
2
- import { computed as t, toValue as x } from "vue";
3
- const b = (d, c, m) => {
4
- const n = t(() => {
5
- const a = x(d);
6
- let e = {
2
+ import { computed as p, toValue as u, watch as c } from "vue";
3
+ const b = (t, f, m) => {
4
+ const n = p(() => {
5
+ const e = u(t);
6
+ let a = {
7
7
  expandedKeys: [],
8
8
  onExpand: () => {
9
9
  }
10
10
  };
11
- return a ? (typeof a == "object" && (e = { ...e, ...a }), {
11
+ return e ? (typeof e == "object" && (a = { ...a, ...e }), {
12
12
  enableCollapse: !0,
13
- customizeExpandedKeys: e.expandedKeys,
14
- customizeOnExpand: e.onExpand
13
+ customizeExpandedKeys: a.expandedKeys,
14
+ customizeOnExpand: a.onExpand
15
15
  }) : {
16
16
  enableCollapse: !1,
17
- customizeExpandedKeys: e.expandedKeys,
18
- customizeOnExpand: e.onExpand
17
+ customizeExpandedKeys: a.expandedKeys,
18
+ customizeOnExpand: a.onExpand
19
19
  };
20
- }), [s, p] = r(n.value.customizeExpandedKeys), u = (a) => {
21
- var l, o;
20
+ }), [s, o] = r(n.value.customizeExpandedKeys), i = (e) => {
21
+ var l, d;
22
22
  if (!n.value.enableCollapse)
23
23
  return;
24
- const e = s.value.includes(a) ? s.value.filter((i) => i !== a) : [...s.value, a];
25
- (o = (l = n.value).customizeOnExpand) == null || o.call(l, e), p(e);
24
+ const a = s.value.includes(e) ? s.value.filter((x) => x !== e) : [...s.value, e];
25
+ (d = (l = n.value).customizeOnExpand) == null || d.call(l, a), typeof u(t) != "object" && o(a);
26
26
  };
27
- return [
28
- t(() => n.value.enableCollapse),
27
+ return c(
28
+ n,
29
+ (e) => {
30
+ o(e.customizeExpandedKeys);
31
+ },
32
+ {
33
+ deep: 1
34
+ }
35
+ ), [
36
+ p(() => n.value.enableCollapse),
29
37
  s,
30
- u
38
+ i
31
39
  // collapseMotion,
32
40
  ];
33
41
  };
@@ -1,49 +1,56 @@
1
- import h from "../x-request/x-request.mjs";
2
- import { computed as p } from "vue";
3
- let u = 0;
4
- class q {
5
- constructor(s) {
6
- this.requestingMap = {}, this.request = (e, o) => {
7
- const { request: n } = this.config, { onUpdate: a, onSuccess: c, onError: g } = o, t = u;
8
- u += 1, this.requestingMap[t] = !0, n == null || n(e, {
9
- // Status should be unique.
10
- // One get success or error should not get more message
11
- onUpdate: (i) => {
12
- this.requestingMap[t] && a(i);
1
+ import p from "../x-request/x-request.mjs";
2
+ import { computed as f, ref as q } from "vue";
3
+ let a = 0;
4
+ class d {
5
+ constructor(i) {
6
+ this.requestingMap = q({}), this.request = (s, o, g) => {
7
+ const { request: n } = this.config, { onUpdate: c, onSuccess: h, onError: l, onStream: u } = o, e = a;
8
+ a += 1, this.requestingMap.value[e] = !0, n == null || n(
9
+ s,
10
+ {
11
+ onStream: (t) => {
12
+ this.requestingMap.value[e] && (u == null || u(t));
13
+ },
14
+ // Status should be unique.
15
+ // One get success or error should not get more message
16
+ onUpdate: (t) => {
17
+ this.requestingMap.value[e] && c(t);
18
+ },
19
+ onSuccess: (t) => {
20
+ this.requestingMap.value[e] && (h(t), this.finishRequest(e));
21
+ },
22
+ onError: (t) => {
23
+ this.requestingMap.value[e] && (l(t), this.finishRequest(e));
24
+ }
13
25
  },
14
- onSuccess: (i) => {
15
- this.requestingMap[t] && (c(i), this.finishRequest(t));
16
- },
17
- onError: (i) => {
18
- this.requestingMap[t] && (g(i), this.finishRequest(t));
19
- }
20
- });
21
- }, this.config = s;
26
+ g
27
+ );
28
+ }, this.config = i;
22
29
  }
23
- finishRequest(s) {
24
- delete this.requestingMap[s];
30
+ finishRequest(i) {
31
+ delete this.requestingMap.value[i];
25
32
  }
26
33
  isRequesting() {
27
- return Object.keys(this.requestingMap).length > 0;
34
+ return Object.keys(this.requestingMap.value).length > 0;
28
35
  }
29
36
  }
30
- function l(r) {
31
- const { request: s, ...e } = r;
37
+ function v(r) {
38
+ const { request: i, ...s } = r;
32
39
  return [
33
- p(
34
- () => new q({
40
+ f(
41
+ () => new d({
35
42
  // @ts-expect-error
36
- request: s || h({
37
- baseURL: e.baseURL,
38
- model: e.model,
39
- dangerouslyApiKey: e.dangerouslyApiKey
43
+ request: i || p({
44
+ baseURL: s.baseURL,
45
+ model: s.model,
46
+ dangerouslyApiKey: s.dangerouslyApiKey
40
47
  }).create,
41
- ...e
48
+ ...s
42
49
  })
43
50
  )
44
51
  ];
45
52
  }
46
53
  export {
47
- q as XAgent,
48
- l as default
54
+ d as XAgent,
55
+ v as default
49
56
  };
@@ -1,97 +1,126 @@
1
- import { ref as k, computed as b } from "vue";
2
- import A from "./useSyncState.mjs";
3
- import { useEventCallback as P } from "../_util/hooks/use-event-callback.mjs";
4
- function $(l) {
5
- return Array.isArray(l) ? l : [l];
1
+ import { ref as F, computed as $ } from "vue";
2
+ import I from "./useSyncState.mjs";
3
+ import { useEventCallback as T } from "../_util/hooks/use-event-callback.mjs";
4
+ function W(i) {
5
+ return Array.isArray(i) ? i : [i];
6
6
  }
7
- function F(l) {
8
- const { defaultMessages: v, agent: p, requestFallback: d, requestPlaceholder: c, parser: h } = l, M = k(0), w = b(() => (v || []).map((r, e) => ({
9
- id: `default_${e}`,
7
+ function U(i) {
8
+ const {
9
+ defaultMessages: q,
10
+ agent: b,
11
+ requestFallback: d,
12
+ requestPlaceholder: f,
13
+ parser: v,
14
+ transformMessage: R,
15
+ transformStream: A,
16
+ resolveAbortController: h
17
+ } = i, w = F(0), _ = $(() => (q || []).map((s, t) => ({
18
+ id: `default_${t}`,
10
19
  status: "local",
11
- ...r
12
- }))), [g, u] = A(w.value, () => {
13
- }), f = (r, e) => {
20
+ ...s
21
+ }))), [m, g] = I(_.value, () => {
22
+ }), M = (s, t) => {
14
23
  const o = {
15
- id: `msg_${M.value}`,
16
- message: r,
17
- status: e
24
+ id: `msg_${w.value}`,
25
+ message: s,
26
+ status: t
18
27
  };
19
- return M.value += 1, o;
20
- }, E = b(() => {
21
- const r = [];
22
- return g.value.forEach((e) => {
23
- const o = h ? h(e.message) : e.message, i = $(o);
24
- i.forEach((a, t) => {
25
- let s = e.id;
26
- i.length > 1 && (s = `${s}_${t}`), r.push({
27
- id: s,
28
- message: a,
29
- status: e.status
28
+ return w.value += 1, o;
29
+ }, x = $(() => {
30
+ const s = [];
31
+ return m.value.forEach((t) => {
32
+ const o = v ? v(t.message) : t.message, u = W(o);
33
+ u.forEach((l, p) => {
34
+ let e = t.id;
35
+ u.length > 1 && (e = `${e}_${p}`), s.push({
36
+ id: e,
37
+ message: l,
38
+ status: t.status
30
39
  });
31
40
  });
32
- }), r;
33
- }), y = (r) => r.filter((e) => e.status !== "loading" && e.status !== "error").map((e) => e.message), q = () => y(g.value);
41
+ }), s;
42
+ }), E = (s) => s.filter((t) => t.status !== "loading" && t.status !== "error").map((t) => t.message), S = () => E(m.value), k = (s) => typeof R == "function" ? R(s) : s.currentMessage;
34
43
  return {
35
- onRequest: P((r) => {
36
- if (!p)
44
+ onRequest: T((s) => {
45
+ if (!b)
37
46
  throw new Error(
38
47
  "The agent parameter is required when using the onRequest method in an agent generated by useXAgent."
39
48
  );
40
- let e = null;
41
- u((a) => {
42
- let t = [...a, f(r, "local")];
43
- if (c) {
44
- let s;
45
- typeof c == "function" ? s = c(r, {
46
- messages: y(t)
47
- }) : s = c;
48
- const n = f(s, "loading");
49
- e = n.id, t = [...t, n];
49
+ let t = null, o, u = {};
50
+ if (typeof s == "object" && (s != null && s.message)) {
51
+ const { message: e, ...r } = s;
52
+ o = e, u = r;
53
+ } else
54
+ o = s;
55
+ g((e) => {
56
+ let r = [...e, M(o, "local")];
57
+ if (f) {
58
+ let a;
59
+ typeof f == "function" ? a = f(o, {
60
+ messages: E(r)
61
+ }) : a = f;
62
+ const n = M(a, "loading");
63
+ t = n.id, r = [...r, n];
50
64
  }
51
- return t;
65
+ return r;
52
66
  });
53
- let o = null;
54
- const i = (a, t) => {
55
- let s = g.value.find((n) => n.id === o);
56
- return s ? u((n) => n.map((m) => m.id === o ? {
57
- ...m,
58
- message: a,
59
- status: t
60
- } : m)) : (s = f(a, t), u((n) => [...n.filter((R) => R.id !== e), s]), o = s.id), s;
67
+ let l = null;
68
+ const p = (e, r) => {
69
+ let a = m.value.find((n) => n.id === l);
70
+ return a ? g((n) => n.map((c) => {
71
+ if (c.id === l) {
72
+ const y = k({
73
+ originMessage: c.message,
74
+ currentMessage: e,
75
+ status: r
76
+ });
77
+ return {
78
+ ...c,
79
+ message: y,
80
+ status: r
81
+ };
82
+ }
83
+ return c;
84
+ })) : (k({ currentMessage: e, status: r }), a = M(e, r), g((n) => [...n.filter((y) => y.id !== t), a]), l = a.id), a;
61
85
  };
62
- p.request(
86
+ b.request(
63
87
  {
64
- message: r,
65
- messages: q()
88
+ message: o,
89
+ messages: S(),
90
+ ...u
66
91
  },
67
92
  {
68
- onUpdate: (a) => {
69
- i(a, "loading");
93
+ onUpdate: (e) => {
94
+ p(e, "loading");
70
95
  },
71
- onSuccess: (a) => {
72
- i(a, "success");
96
+ onSuccess: (e) => {
97
+ p(e, "success");
73
98
  },
74
- onError: async (a) => {
99
+ onError: async (e) => {
75
100
  if (d) {
76
- let t;
77
- typeof d == "function" ? t = await d(r, {
78
- error: a,
79
- messages: q()
80
- }) : t = d, u((s) => [
81
- ...s.filter((n) => n.id !== e && n.id !== o),
82
- f(t, "error")
101
+ let r;
102
+ typeof d == "function" ? r = await d(o, {
103
+ error: e,
104
+ messages: S()
105
+ }) : r = d, g((a) => [
106
+ ...a.filter((n) => n.id !== t && n.id !== l),
107
+ M(r, "error")
83
108
  ]);
84
109
  } else
85
- u((t) => t.filter((s) => s.id !== e && s.id !== o));
110
+ g((r) => r.filter((a) => a.id !== t && a.id !== l));
111
+ },
112
+ onStream: (e) => {
113
+ h == null || h(e);
86
114
  }
87
- }
115
+ },
116
+ A
88
117
  );
89
118
  }),
90
- messages: g,
91
- parsedMessages: E,
92
- setMessages: u
119
+ messages: m,
120
+ parsedMessages: x,
121
+ setMessages: g
93
122
  };
94
123
  }
95
124
  export {
96
- F as default
125
+ U as default
97
126
  };
@@ -1,83 +1,85 @@
1
- import f from "../x-stream/x-stream.mjs";
2
- import y from "./x-fetch.mjs";
3
- const d = class d {
4
- constructor(n) {
5
- this.create = async (s, e, r) => {
6
- var o;
7
- const i = {
1
+ import y from "../x-stream/x-stream.mjs";
2
+ import R from "./x-fetch.mjs";
3
+ const s = class s {
4
+ constructor(t) {
5
+ this.create = async (h, e, o) => {
6
+ var i, u;
7
+ const n = new AbortController(), r = {
8
8
  method: "POST",
9
9
  body: JSON.stringify({
10
10
  model: this.model,
11
- ...s
11
+ ...h
12
12
  }),
13
- headers: this.defaultHeaders
13
+ headers: this.defaultHeaders,
14
+ signal: n.signal
14
15
  };
16
+ (i = e == null ? void 0 : e.onStream) == null || i.call(e, n);
15
17
  try {
16
- const t = await y(this.baseURL, {
18
+ const d = await R(this.baseURL, {
17
19
  fetch: this.customOptions.fetch,
18
- ...i
20
+ ...r
19
21
  });
20
- if (r) {
21
- await this.customResponseHandler(t, e, r);
22
+ if (o) {
23
+ await this.customResponseHandler(d, e, o);
22
24
  return;
23
25
  }
24
- const h = t.headers.get("content-type") || "";
25
- switch (h.split(";")[0].trim()) {
26
+ const p = d.headers.get("content-type") || "";
27
+ switch (p.split(";")[0].trim()) {
26
28
  /** SSE */
27
29
  case "text/event-stream":
28
- await this.sseResponseHandler(t, e);
30
+ await this.sseResponseHandler(d, e);
29
31
  break;
30
32
  /** JSON */
31
33
  case "application/json":
32
- await this.jsonResponseHandler(t, e);
34
+ await this.jsonResponseHandler(d, e);
33
35
  break;
34
36
  default:
35
- throw new Error(`The response content-type: ${h} is not support!`);
37
+ throw new Error(`The response content-type: ${p} is not support!`);
36
38
  }
37
- } catch (t) {
38
- const h = t instanceof Error ? t : new Error("Unknown error!");
39
- throw (o = e == null ? void 0 : e.onError) == null || o.call(e, h), h;
39
+ } catch (d) {
40
+ const p = d instanceof Error ? d : new Error("Unknown error!");
41
+ throw (u = e == null ? void 0 : e.onError) == null || u.call(e, p), p;
40
42
  }
41
- }, this.customResponseHandler = async (s, e, r) => {
42
- var o, t;
43
- const i = [];
44
- for await (const h of f({
45
- readableStream: s.body,
46
- transformStream: r
43
+ }, this.customResponseHandler = async (h, e, o) => {
44
+ var r, i;
45
+ const n = [];
46
+ for await (const u of y({
47
+ readableStream: h.body,
48
+ transformStream: o
47
49
  }))
48
- i.push(h), (o = e == null ? void 0 : e.onUpdate) == null || o.call(e, h);
49
- (t = e == null ? void 0 : e.onSuccess) == null || t.call(e, i);
50
- }, this.sseResponseHandler = async (s, e) => {
51
- var i, o;
52
- const r = [];
53
- for await (const t of f({
54
- readableStream: s.body
50
+ n.push(u), (r = e == null ? void 0 : e.onUpdate) == null || r.call(e, u);
51
+ (i = e == null ? void 0 : e.onSuccess) == null || i.call(e, n);
52
+ }, this.sseResponseHandler = async (h, e) => {
53
+ var n, r;
54
+ const o = [];
55
+ for await (const i of y({
56
+ readableStream: h.body
55
57
  }))
56
- r.push(t), (i = e == null ? void 0 : e.onUpdate) == null || i.call(e, t);
57
- (o = e == null ? void 0 : e.onSuccess) == null || o.call(e, r);
58
- }, this.jsonResponseHandler = async (s, e) => {
59
- var i, o;
60
- const r = await s.json();
61
- (i = e == null ? void 0 : e.onUpdate) == null || i.call(e, r), (o = e == null ? void 0 : e.onSuccess) == null || o.call(e, [r]);
58
+ o.push(i), (n = e == null ? void 0 : e.onUpdate) == null || n.call(e, i);
59
+ (r = e == null ? void 0 : e.onSuccess) == null || r.call(e, o);
60
+ }, this.jsonResponseHandler = async (h, e) => {
61
+ var n, r;
62
+ const o = await h.json();
63
+ (n = e == null ? void 0 : e.onUpdate) == null || n.call(e, o), (r = e == null ? void 0 : e.onSuccess) == null || r.call(e, [o]);
62
64
  };
63
- const { baseURL: u, model: w, dangerouslyApiKey: R, ...m } = n;
64
- this.baseURL = n.baseURL, this.model = n.model, this.defaultHeaders = {
65
+ const { baseURL: f, model: U, dangerouslyApiKey: g, ...w } = t;
66
+ this.baseURL = t.baseURL, this.model = t.model, this.defaultHeaders = {
65
67
  "Content-Type": "application/json",
66
- ...n.dangerouslyApiKey && {
67
- Authorization: n.dangerouslyApiKey
68
+ ...t.dangerouslyApiKey && {
69
+ Authorization: t.dangerouslyApiKey
68
70
  }
69
- }, this.customOptions = m;
71
+ }, this.customOptions = w;
70
72
  }
71
- static init(n) {
72
- if (!n.baseURL || typeof n.baseURL != "string")
73
+ static init(t) {
74
+ if (!t.baseURL || typeof t.baseURL != "string")
73
75
  throw new Error("The baseURL is not valid!");
74
- const u = n.fetch || n.baseURL;
75
- return d.instanceBuffer.has(u) || d.instanceBuffer.set(u, new d(n)), d.instanceBuffer.get(u);
76
+ const f = t.fetch || t.baseURL;
77
+ return s.instanceBuffer.has(f) || s.instanceBuffer.set(f, new s(t)), s.instanceBuffer.get(f);
76
78
  }
77
79
  };
78
- d.instanceBuffer = /* @__PURE__ */ new Map();
79
- let p = d;
80
- const g = p.init;
80
+ s.instanceBuffer = /* @__PURE__ */ new Map();
81
+ let m = s;
82
+ const T = m.init;
81
83
  export {
82
- g as default
84
+ T as default
83
85
  };