vant-vtk 1.0.3 → 1.0.5

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.
Files changed (43) hide show
  1. package/dist/es/Area.js +193 -0
  2. package/dist/es/Area.js.map +1 -0
  3. package/dist/es/Radio.css +1 -0
  4. package/dist/es/Radio.js +79 -0
  5. package/dist/es/Radio.js.map +1 -0
  6. package/dist/es/Uploader.css +1 -0
  7. package/dist/es/Uploader.js +128 -0
  8. package/dist/es/Uploader.js.map +1 -0
  9. package/dist/es/_plugin-vue_export-helper-CHgC5LLL.js +10 -0
  10. package/dist/es/_plugin-vue_export-helper-CHgC5LLL.js.map +1 -0
  11. package/dist/es/checkbox.css +1 -0
  12. package/dist/es/checkbox.js +86 -0
  13. package/dist/es/checkbox.js.map +1 -0
  14. package/dist/es/index.js +35 -0
  15. package/dist/es/index.js.map +1 -0
  16. package/dist/es/preview.css +1 -0
  17. package/dist/es/preview.js +192 -0
  18. package/dist/es/preview.js.map +1 -0
  19. package/dist/lib/Area.js +2 -0
  20. package/dist/lib/Area.js.map +1 -0
  21. package/dist/lib/Radio.css +1 -0
  22. package/dist/lib/Radio.js +2 -0
  23. package/dist/lib/Radio.js.map +1 -0
  24. package/dist/lib/Uploader.css +1 -0
  25. package/dist/lib/Uploader.js +2 -0
  26. package/dist/lib/Uploader.js.map +1 -0
  27. package/dist/lib/_plugin-vue_export-helper-BHFhmbuH.cjs +2 -0
  28. package/dist/lib/_plugin-vue_export-helper-BHFhmbuH.cjs.map +1 -0
  29. package/dist/lib/checkbox.css +1 -0
  30. package/dist/lib/checkbox.js +2 -0
  31. package/dist/lib/checkbox.js.map +1 -0
  32. package/dist/lib/index.js +2 -0
  33. package/dist/lib/index.js.map +1 -0
  34. package/dist/lib/preview.css +1 -0
  35. package/dist/lib/preview.js +2 -0
  36. package/dist/lib/preview.js.map +1 -0
  37. package/dist/style.css +1 -1
  38. package/dist/vant-vtk.es.js +349 -337
  39. package/dist/vant-vtk.es.js.map +1 -1
  40. package/dist/vant-vtk.umd.js +1 -1
  41. package/dist/vant-vtk.umd.js.map +1 -1
  42. package/package.json +1 -1
  43. package/types/index.d.ts +1 -0
@@ -1,12 +1,12 @@
1
- import { computed as $, resolveComponent as V, openBlock as k, createBlock as L, normalizeProps as J, guardReactiveProps as K, withCtx as S, createVNode as x, createElementBlock as P, Fragment as W, renderList as Q, createTextVNode as T, toDisplayString as w, ref as C, watch as z, mergeProps as X, createElementVNode as A, unref as Z, createCommentVNode as O } from "vue";
2
- import { showLoadingToast as H, closeToast as ee, showToast as M } from "vant";
3
- import ae from "vue-pdf-embed";
4
- const q = (n, h) => {
5
- const r = n.__vccOpts || n;
6
- for (const [c, m] of h)
7
- r[c] = m;
8
- return r;
9
- }, te = /* @__PURE__ */ Object.assign({
1
+ import { computed as R, resolveComponent as V, openBlock as C, createBlock as z, normalizeProps as Y, guardReactiveProps as Z, withCtx as A, createVNode as x, createElementBlock as D, Fragment as K, renderList as O, createTextVNode as F, toDisplayString as T, inject as ee, getCurrentInstance as ae, ref as S, watch as I, mergeProps as te, createElementVNode as $, unref as le, createCommentVNode as ne } from "vue";
2
+ import { showLoadingToast as X, closeToast as re, showToast as H } from "vant";
3
+ import oe from "vue-pdf-embed";
4
+ const J = (l, d) => {
5
+ const n = l.__vccOpts || l;
6
+ for (const [_, c] of d)
7
+ n[_] = c;
8
+ return n;
9
+ }, se = /* @__PURE__ */ Object.assign({
10
10
  name: "VtkCheckbox"
11
11
  }, {
12
12
  __name: "index",
@@ -25,7 +25,7 @@ const q = (n, h) => {
25
25
  valueType: {
26
26
  type: String,
27
27
  default: "array",
28
- validator: (n) => ["string", "array", "object"].includes(n)
28
+ validator: (l) => ["string", "array", "object"].includes(l)
29
29
  },
30
30
  // 当 valueType 为 string 时的分隔符
31
31
  separator: {
@@ -34,42 +34,42 @@ const q = (n, h) => {
34
34
  }
35
35
  },
36
36
  emits: ["update:modelValue", "change"],
37
- setup(n, { emit: h }) {
38
- const r = n, c = h, m = $(() => Array.isArray(r.options) ? r.options : typeof r.options == "string" && r.options ? r.options.split("/").filter(Boolean).map((t) => {
39
- const [o, s] = t.split(":");
37
+ setup(l, { emit: d }) {
38
+ const n = l, _ = d, c = R(() => Array.isArray(n.options) ? n.options : typeof n.options == "string" && n.options ? n.options.split("/").filter(Boolean).map((r) => {
39
+ const [t, s] = r.split(":");
40
40
  return {
41
- text: s || o,
42
- value: o
41
+ text: s || t,
42
+ value: t
43
43
  };
44
- }) : []), i = $({
44
+ }) : []), p = R({
45
45
  get: () => {
46
- const t = r.modelValue;
47
- if (!t) return [];
48
- let o = [];
49
- return r.valueType === "string" ? o = typeof t == "string" ? t.split(r.separator).filter(Boolean) : [] : r.valueType === "object" ? o = Array.isArray(t) ? t.map((s) => (s == null ? void 0 : s.value) ?? s) : [] : o = Array.isArray(t) ? t : [], o.map(String);
46
+ const r = n.modelValue;
47
+ if (!r) return [];
48
+ let t = [];
49
+ return n.valueType === "string" ? t = typeof r == "string" ? r.split(n.separator).filter(Boolean) : [] : n.valueType === "object" ? t = Array.isArray(r) ? r.map((s) => (s == null ? void 0 : s.value) ?? s) : [] : t = Array.isArray(r) ? r : [], t.map(String);
50
50
  },
51
- set: (t) => {
52
- let o;
53
- r.valueType === "string" ? o = t.join(r.separator) : r.valueType === "object" ? o = m.value.filter((s) => t.includes(String(s.value))) : o = t.map((s) => isNaN(Number(s)) ? s : Array.isArray(r.modelValue) && typeof r.modelValue[0] == "number" ? Number(s) : s), c("update:modelValue", o), c("change", o);
51
+ set: (r) => {
52
+ let t;
53
+ n.valueType === "string" ? t = r.join(n.separator) : n.valueType === "object" ? t = c.value.filter((s) => r.includes(String(s.value))) : t = r.map((s) => isNaN(Number(s)) ? s : Array.isArray(n.modelValue) && typeof n.modelValue[0] == "number" ? Number(s) : s), _("update:modelValue", t), _("change", t);
54
54
  }
55
55
  });
56
- return (t, o) => {
57
- const s = V("van-checkbox"), y = V("van-checkbox-group"), v = V("van-field");
58
- return k(), L(v, J(K(t.$attrs)), {
59
- input: S(() => [
60
- x(y, {
61
- modelValue: i.value,
62
- "onUpdate:modelValue": o[0] || (o[0] = (g) => i.value = g),
56
+ return (r, t) => {
57
+ const s = V("van-checkbox"), f = V("van-checkbox-group"), h = V("van-field");
58
+ return C(), z(h, Y(Z(r.$attrs)), {
59
+ input: A(() => [
60
+ x(f, {
61
+ modelValue: p.value,
62
+ "onUpdate:modelValue": t[0] || (t[0] = (g) => p.value = g),
63
63
  direction: "horizontal"
64
64
  }, {
65
- default: S(() => [
66
- (k(!0), P(W, null, Q(m.value, (g) => (k(), L(s, {
65
+ default: A(() => [
66
+ (C(!0), D(K, null, O(c.value, (g) => (C(), z(s, {
67
67
  key: String(g.value),
68
68
  name: String(g.value),
69
69
  shape: "square"
70
70
  }, {
71
- default: S(() => [
72
- T(w(g.text), 1)
71
+ default: A(() => [
72
+ F(T(g.text), 1)
73
73
  ]),
74
74
  _: 2
75
75
  }, 1032, ["name"]))), 128))
@@ -81,11 +81,11 @@ const q = (n, h) => {
81
81
  }, 16);
82
82
  };
83
83
  }
84
- }), F = /* @__PURE__ */ q(te, [["__scopeId", "data-v-eb64e8a9"]]);
85
- F.install = (n) => {
86
- n.component(F.name || "VtkCheckbox", F);
84
+ }), B = /* @__PURE__ */ J(se, [["__scopeId", "data-v-eb64e8a9"]]);
85
+ B.install = (l) => {
86
+ l.component(B.name || "VtkCheckbox", B);
87
87
  };
88
- const I = /* @__PURE__ */ Object.assign({
88
+ const E = /* @__PURE__ */ Object.assign({
89
89
  name: "VtkArea"
90
90
  }, {
91
91
  __name: "index",
@@ -104,7 +104,7 @@ const I = /* @__PURE__ */ Object.assign({
104
104
  valueType: {
105
105
  type: String,
106
106
  default: "code",
107
- validator: (n) => ["code", "codes", "object"].includes(n)
107
+ validator: (l) => ["code", "codes", "object"].includes(l)
108
108
  },
109
109
  // 显示分隔符
110
110
  separator: {
@@ -130,137 +130,143 @@ const I = /* @__PURE__ */ Object.assign({
130
130
  displayMode: {
131
131
  type: String,
132
132
  default: "full",
133
- validator: (n) => ["full", "last"].includes(n)
133
+ validator: (l) => ["full", "last"].includes(l)
134
134
  }
135
135
  },
136
136
  emits: ["update:modelValue", "change", "finish"],
137
- setup(n, { expose: h, emit: r }) {
138
- const c = n, m = r, i = C(!1), t = C(""), o = C([]), s = C(""), y = C(!1), v = C([]), g = {
137
+ setup(l, { expose: d, emit: n }) {
138
+ var y;
139
+ const _ = ee("vant-vtk:request", null), c = (y = ae()) == null ? void 0 : y.appContext.config.globalProperties, p = (c == null ? void 0 : c.$vtkRequest) || (c == null ? void 0 : c.$request), r = () => {
140
+ const e = _ || p;
141
+ if (!e)
142
+ throw new Error("VantVtk request 未配置");
143
+ return e;
144
+ }, t = l, s = n, f = S(!1), h = S(""), g = S([]), b = S(""), q = S(!1), w = S([]), U = {
139
145
  text: "areaName",
140
146
  value: "areaCode",
141
147
  children: "children"
142
148
  };
143
- z(
144
- () => c.modelValue,
145
- (a) => {
146
- a || (s.value = "", t.value = "", v.value = []);
149
+ I(
150
+ () => t.modelValue,
151
+ (e) => {
152
+ e || (b.value = "", h.value = "", w.value = []);
147
153
  },
148
154
  { immediate: !0 }
149
155
  );
150
- const N = () => {
151
- i.value = !0, o.value.length === 0 && U();
152
- }, U = async () => {
153
- if (!y.value) {
154
- y.value = !0;
156
+ const j = () => {
157
+ f.value = !0, g.value.length === 0 && P();
158
+ }, P = async () => {
159
+ if (!q.value) {
160
+ q.value = !0;
155
161
  try {
156
- const a = c.defaultAreaCode, e = await Request.getForm(`dict/area/show/${a}`);
157
- if (e.data) {
158
- const l = {
159
- areaCode: e.data.areaCode,
160
- areaName: e.data.areaName,
161
- areaLeve: e.data.areaLeve,
162
- children: e.data.areaLeve < c.maxLevel ? [] : void 0
162
+ const e = t.defaultAreaCode, o = await r().getForm(`dict/area/show/${e}`);
163
+ if (o.data) {
164
+ const i = {
165
+ areaCode: o.data.areaCode,
166
+ areaName: o.data.areaName,
167
+ areaLeve: o.data.areaLeve,
168
+ children: o.data.areaLeve < t.maxLevel ? [] : void 0
163
169
  };
164
- o.value = [l];
170
+ g.value = [i];
165
171
  }
166
- } catch (a) {
167
- console.error("加载初始地区失败:", a);
172
+ } catch (e) {
173
+ console.error("加载初始地区失败:", e);
168
174
  } finally {
169
- y.value = !1;
175
+ q.value = !1;
170
176
  }
171
177
  }
172
- }, u = async (a) => {
173
- if (!a._loading) {
174
- a._loading = !0;
178
+ }, m = async (e) => {
179
+ if (!e._loading) {
180
+ e._loading = !0;
175
181
  try {
176
- const e = await Request.getForm(`dict/area/next/${a.areaCode}`);
177
- e.data && e.data.length > 0 ? (e.data.forEach((l) => {
178
- l.areaLeve < c.maxLevel && (l.children = []);
179
- }), a.children = e.data) : delete a.children;
180
- } catch (e) {
181
- console.error("加载下级地区失败:", e);
182
+ const o = await r().getForm(`dict/area/next/${e.areaCode}`);
183
+ o.data && o.data.length > 0 ? (o.data.forEach((i) => {
184
+ i.areaLeve < t.maxLevel && (i.children = []);
185
+ }), e.children = o.data) : delete e.children;
186
+ } catch (o) {
187
+ console.error("加载下级地区失败:", o);
182
188
  } finally {
183
- a._loading = !1;
189
+ e._loading = !1;
184
190
  }
185
191
  }
186
- }, d = ({ value: a, selectedOptions: e, tabIndex: l }) => {
187
- const p = e[l];
188
- p && p.areaLeve < c.maxLevel && Array.isArray(p.children) && p.children.length === 0 && u(p), m("change", { value: a, selectedOptions: e, tabIndex: l });
189
- }, f = ({ selectedOptions: a }) => {
190
- var l, p, j, b, E;
191
- c.displayMode === "last" ? s.value = ((l = a[a.length - 1]) == null ? void 0 : l.areaName) || "" : s.value = a.map((_) => _.areaName).join(c.separator), v.value = a.map((_) => ({
192
- areaCode: _.areaCode,
193
- areaName: _.areaName,
194
- areaLeve: _.areaLeve
192
+ }, a = ({ value: e, selectedOptions: o, tabIndex: i }) => {
193
+ const v = o[i];
194
+ v && v.areaLeve < t.maxLevel && Array.isArray(v.children) && v.children.length === 0 && m(v), s("change", { value: e, selectedOptions: o, tabIndex: i });
195
+ }, u = ({ selectedOptions: e }) => {
196
+ var i, v, L, N, Q;
197
+ t.displayMode === "last" ? b.value = ((i = e[e.length - 1]) == null ? void 0 : i.areaName) || "" : b.value = e.map((k) => k.areaName).join(t.separator), w.value = e.map((k) => ({
198
+ areaCode: k.areaCode,
199
+ areaName: k.areaName,
200
+ areaLeve: k.areaLeve
195
201
  }));
196
- let e;
197
- switch (c.valueType) {
202
+ let o;
203
+ switch (t.valueType) {
198
204
  case "code":
199
- e = ((p = a[a.length - 1]) == null ? void 0 : p.areaCode) || "";
205
+ o = ((v = e[e.length - 1]) == null ? void 0 : v.areaCode) || "";
200
206
  break;
201
207
  case "codes":
202
- e = a.map((_) => _.areaCode);
208
+ o = e.map((k) => k.areaCode);
203
209
  break;
204
210
  case "object":
205
- e = {
206
- codes: a.map((_) => _.areaCode),
207
- names: a.map((_) => _.areaName),
208
- fullName: a.map((_) => _.areaName).join(c.separator),
209
- lastCode: ((j = a[a.length - 1]) == null ? void 0 : j.areaCode) || "",
210
- lastLevel: (b = a[a.length - 1]) == null ? void 0 : b.areaLeve,
211
- options: v.value
211
+ o = {
212
+ codes: e.map((k) => k.areaCode),
213
+ names: e.map((k) => k.areaName),
214
+ fullName: e.map((k) => k.areaName).join(t.separator),
215
+ lastCode: ((L = e[e.length - 1]) == null ? void 0 : L.areaCode) || "",
216
+ lastLevel: (N = e[e.length - 1]) == null ? void 0 : N.areaLeve,
217
+ options: w.value
212
218
  };
213
219
  break;
214
220
  default:
215
- e = ((E = a[a.length - 1]) == null ? void 0 : E.areaCode) || "";
221
+ o = ((Q = e[e.length - 1]) == null ? void 0 : Q.areaCode) || "";
216
222
  }
217
- m("update:modelValue", e), m("finish", { selectedOptions: a, value: e }), i.value = !1;
223
+ s("update:modelValue", o), s("finish", { selectedOptions: e, value: o }), f.value = !1;
218
224
  };
219
- return h({
225
+ return d({
220
226
  // 获取当前选中的完整数据
221
- getSelectedData: () => v.value,
227
+ getSelectedData: () => w.value,
222
228
  // 获取显示值
223
- getDisplayValue: () => s.value,
229
+ getDisplayValue: () => b.value,
224
230
  // 重置选择
225
231
  reset: () => {
226
- s.value = "", t.value = "", v.value = [], m("update:modelValue", c.valueType === "codes" ? [] : c.valueType === "object" ? null : "");
232
+ b.value = "", h.value = "", w.value = [], s("update:modelValue", t.valueType === "codes" ? [] : t.valueType === "object" ? null : "");
227
233
  },
228
234
  // 打开选择器
229
235
  open: () => {
230
- N();
236
+ j();
231
237
  },
232
238
  // 关闭选择器
233
239
  close: () => {
234
- i.value = !1;
240
+ f.value = !1;
235
241
  }
236
- }), (a, e) => {
237
- const l = V("van-field"), p = V("van-cascader"), j = V("van-popup");
238
- return k(), P(W, null, [
239
- x(l, X({
240
- modelValue: s.value,
241
- "onUpdate:modelValue": e[0] || (e[0] = (b) => s.value = b),
242
+ }), (e, o) => {
243
+ const i = V("van-field"), v = V("van-cascader"), L = V("van-popup");
244
+ return C(), D(K, null, [
245
+ x(i, te({
246
+ modelValue: b.value,
247
+ "onUpdate:modelValue": o[0] || (o[0] = (N) => b.value = N),
242
248
  "is-link": "",
243
249
  readonly: ""
244
- }, a.$attrs, {
245
- placeholder: n.placeholder,
246
- onClick: N
250
+ }, e.$attrs, {
251
+ placeholder: l.placeholder,
252
+ onClick: j
247
253
  }), null, 16, ["modelValue", "placeholder"]),
248
- x(j, {
249
- show: i.value,
250
- "onUpdate:show": e[3] || (e[3] = (b) => i.value = b),
254
+ x(L, {
255
+ show: f.value,
256
+ "onUpdate:show": o[3] || (o[3] = (N) => f.value = N),
251
257
  round: "",
252
258
  position: "bottom"
253
259
  }, {
254
- default: S(() => [
255
- x(p, {
256
- modelValue: t.value,
257
- "onUpdate:modelValue": e[1] || (e[1] = (b) => t.value = b),
258
- title: n.title,
259
- options: o.value,
260
- "field-names": g,
261
- onClose: e[2] || (e[2] = (b) => i.value = !1),
262
- onFinish: f,
263
- onChange: d
260
+ default: A(() => [
261
+ x(v, {
262
+ modelValue: h.value,
263
+ "onUpdate:modelValue": o[1] || (o[1] = (N) => h.value = N),
264
+ title: l.title,
265
+ options: g.value,
266
+ "field-names": U,
267
+ onClose: o[2] || (o[2] = (N) => f.value = !1),
268
+ onFinish: u,
269
+ onChange: a
264
270
  }, null, 8, ["modelValue", "title", "options"])
265
271
  ]),
266
272
  _: 1
@@ -269,10 +275,10 @@ const I = /* @__PURE__ */ Object.assign({
269
275
  };
270
276
  }
271
277
  });
272
- I.install = (n) => {
273
- n.component(I.name || "VtkArea", I);
278
+ E.install = (l, d = {}) => {
279
+ d != null && d.request && (l.provide("vant-vtk:request", d.request), l.config.globalProperties.$vtkRequest = d.request), l.component(E.name || "VtkArea", E);
274
280
  };
275
- const le = /* @__PURE__ */ Object.assign({
281
+ const ue = /* @__PURE__ */ Object.assign({
276
282
  name: "VtkRadio"
277
283
  }, {
278
284
  __name: "index",
@@ -291,44 +297,44 @@ const le = /* @__PURE__ */ Object.assign({
291
297
  valueType: {
292
298
  type: String,
293
299
  default: "string",
294
- validator: (n) => ["string", "object"].includes(n)
300
+ validator: (l) => ["string", "object"].includes(l)
295
301
  }
296
302
  },
297
303
  emits: ["update:modelValue", "change"],
298
- setup(n, { emit: h }) {
299
- const r = n, c = h, m = $(() => Array.isArray(r.options) ? r.options : typeof r.options == "string" && r.options ? r.options.split("/").filter(Boolean).map((t) => {
300
- const [o, s] = t.split(":");
304
+ setup(l, { emit: d }) {
305
+ const n = l, _ = d, c = R(() => Array.isArray(n.options) ? n.options : typeof n.options == "string" && n.options ? n.options.split("/").filter(Boolean).map((r) => {
306
+ const [t, s] = r.split(":");
301
307
  return {
302
- text: s || o,
303
- value: o
308
+ text: s || t,
309
+ value: t
304
310
  };
305
- }) : []), i = $({
311
+ }) : []), p = R({
306
312
  get: () => {
307
- const t = r.modelValue;
308
- return t == null ? "" : r.valueType === "object" && t && typeof t == "object" ? String(t.value ?? "") : String(t);
313
+ const r = n.modelValue;
314
+ return r == null ? "" : n.valueType === "object" && r && typeof r == "object" ? String(r.value ?? "") : String(r);
309
315
  },
310
- set: (t) => {
311
- var y;
312
- let o = t;
313
- typeof (r.valueType === "object" ? (y = r.modelValue) == null ? void 0 : y.value : r.modelValue) == "number" && !isNaN(Number(t)) && (o = Number(t)), r.valueType === "object" && (o = m.value.find((v) => String(v.value) === String(t)) || null), c("update:modelValue", o), c("change", o);
316
+ set: (r) => {
317
+ var f;
318
+ let t = r;
319
+ typeof (n.valueType === "object" ? (f = n.modelValue) == null ? void 0 : f.value : n.modelValue) == "number" && !isNaN(Number(r)) && (t = Number(r)), n.valueType === "object" && (t = c.value.find((h) => String(h.value) === String(r)) || null), _("update:modelValue", t), _("change", t);
314
320
  }
315
321
  });
316
- return (t, o) => {
317
- const s = V("van-radio"), y = V("van-radio-group"), v = V("van-field");
318
- return k(), L(v, J(K(t.$attrs)), {
319
- input: S(() => [
320
- x(y, {
321
- modelValue: i.value,
322
- "onUpdate:modelValue": o[0] || (o[0] = (g) => i.value = g),
322
+ return (r, t) => {
323
+ const s = V("van-radio"), f = V("van-radio-group"), h = V("van-field");
324
+ return C(), z(h, Y(Z(r.$attrs)), {
325
+ input: A(() => [
326
+ x(f, {
327
+ modelValue: p.value,
328
+ "onUpdate:modelValue": t[0] || (t[0] = (g) => p.value = g),
323
329
  direction: "horizontal"
324
330
  }, {
325
- default: S(() => [
326
- (k(!0), P(W, null, Q(m.value, (g) => (k(), L(s, {
331
+ default: A(() => [
332
+ (C(!0), D(K, null, O(c.value, (g) => (C(), z(s, {
327
333
  key: String(g.value),
328
334
  name: String(g.value)
329
335
  }, {
330
- default: S(() => [
331
- T(w(g.text), 1)
336
+ default: A(() => [
337
+ F(T(g.text), 1)
332
338
  ]),
333
339
  _: 2
334
340
  }, 1032, ["name"]))), 128))
@@ -340,11 +346,11 @@ const le = /* @__PURE__ */ Object.assign({
340
346
  }, 16);
341
347
  };
342
348
  }
343
- }), R = /* @__PURE__ */ q(le, [["__scopeId", "data-v-3482e335"]]);
344
- R.install = (n) => {
345
- n.component(R.name || "VtkRadio", R);
349
+ }), M = /* @__PURE__ */ J(ue, [["__scopeId", "data-v-3482e335"]]);
350
+ M.install = (l) => {
351
+ l.component(M.name || "VtkRadio", M);
346
352
  };
347
- const ne = /* @__PURE__ */ Object.assign({
353
+ const ie = /* @__PURE__ */ Object.assign({
348
354
  name: "VtkUploader",
349
355
  inheritAttrs: !1
350
356
  }, {
@@ -359,7 +365,7 @@ const ne = /* @__PURE__ */ Object.assign({
359
365
  valueType: {
360
366
  type: String,
361
367
  default: "array",
362
- validator: (n) => ["string", "array"].includes(n)
368
+ validator: (l) => ["string", "array"].includes(l)
363
369
  },
364
370
  /** 单个文件最大大小(字节),默认10MB */
365
371
  maxSize: {
@@ -383,106 +389,112 @@ const ne = /* @__PURE__ */ Object.assign({
383
389
  }
384
390
  },
385
391
  emits: ["update:modelValue", "change", "success", "error"],
386
- setup(n, { expose: h, emit: r }) {
387
- const c = n, m = r, i = C([]), t = (u) => {
388
- if (!u) return [];
389
- let d = [];
390
- return typeof u == "string" ? d = u.split(",").filter((f) => f.trim()) : Array.isArray(u) && (d = u.filter((f) => f)), d.map((f) => ({
391
- url: f,
392
+ setup(l, { expose: d, emit: n }) {
393
+ var m;
394
+ const _ = ee("vant-vtk:request", null), c = (m = ae()) == null ? void 0 : m.appContext.config.globalProperties, p = (c == null ? void 0 : c.$vtkRequest) || (c == null ? void 0 : c.$request), r = () => {
395
+ const a = _ || p;
396
+ if (!a)
397
+ throw new Error("VantVtk request 未配置");
398
+ return a;
399
+ }, t = l, s = n, f = S([]), h = (a) => {
400
+ if (!a) return [];
401
+ let u = [];
402
+ return typeof a == "string" ? u = a.split(",").filter((y) => y.trim()) : Array.isArray(a) && (u = a.filter((y) => y)), u.map((y) => ({
403
+ url: y,
392
404
  status: "done",
393
405
  message: ""
394
406
  }));
395
- }, o = () => i.value.filter((u) => u.status === "done" && u.url).map((u) => u.url), s = (u) => c.valueType === "string" ? u.join(",") : u, y = () => {
396
- const u = o(), d = s(u);
397
- m("update:modelValue", d), m("change", d);
407
+ }, g = () => f.value.filter((a) => a.status === "done" && a.url).map((a) => a.url), b = (a) => t.valueType === "string" ? a.join(",") : a, q = () => {
408
+ const a = g(), u = b(a);
409
+ s("update:modelValue", u), s("change", u);
398
410
  };
399
- z(
400
- () => c.modelValue,
401
- (u) => {
402
- const d = o().join(","), f = Array.isArray(u) ? u.join(",") : u || "";
403
- d !== f && (i.value = t(u));
411
+ I(
412
+ () => t.modelValue,
413
+ (a) => {
414
+ const u = g().join(","), y = Array.isArray(a) ? a.join(",") : a || "";
415
+ u !== y && (f.value = h(a));
404
416
  },
405
417
  { immediate: !0 }
406
418
  );
407
- const v = (u) => {
408
- const d = Array.isArray(u) ? u : [u];
409
- for (const f of d)
410
- if (f.size > c.maxSize) {
411
- const a = (c.maxSize / 1024 / 1024).toFixed(1);
412
- return M(`文件大小不能超过${a}MB`), !1;
419
+ const w = (a) => {
420
+ const u = Array.isArray(a) ? a : [a];
421
+ for (const y of u)
422
+ if (y.size > t.maxSize) {
423
+ const e = (t.maxSize / 1024 / 1024).toFixed(1);
424
+ return H(`文件大小不能超过${e}MB`), !1;
413
425
  }
414
426
  return !0;
415
- }, g = async (u) => {
416
- var f, a, e, l;
417
- const d = new FormData();
418
- d.append(c.fieldName, u.file);
427
+ }, U = async (a) => {
428
+ var y, e, o, i;
429
+ const u = new FormData();
430
+ u.append(t.fieldName, a.file);
419
431
  try {
420
- const p = await Request.imp(c.uploadUrl, d);
421
- return (f = p.meta) != null && f.success ? { success: !0, url: ((a = p.data) == null ? void 0 : a.url) || ((e = p.data) == null ? void 0 : e.path) || p.data } : { success: !1, message: ((l = p.meta) == null ? void 0 : l.message) || "上传失败" };
422
- } catch (p) {
423
- return { success: !1, message: p.message || "上传失败" };
432
+ const v = await r().imp(t.uploadUrl, u);
433
+ return (y = v.meta) != null && y.success ? { success: !0, url: ((e = v.data) == null ? void 0 : e.url) || ((o = v.data) == null ? void 0 : o.path) || v.data } : { success: !1, message: ((i = v.meta) == null ? void 0 : i.message) || "上传失败" };
434
+ } catch (v) {
435
+ return { success: !1, message: v.message || "上传失败" };
424
436
  }
425
- }, N = async (u) => {
426
- const d = Array.isArray(u) ? u : [u];
427
- d.length > 1 && H({
428
- message: `正在上传 0/${d.length}`,
437
+ }, j = async (a) => {
438
+ const u = Array.isArray(a) ? a : [a];
439
+ u.length > 1 && X({
440
+ message: `正在上传 0/${u.length}`,
429
441
  forbidClick: !0,
430
442
  duration: 0
431
443
  });
432
- let f = 0, a = 0;
433
- for (let e = 0; e < d.length; e++) {
434
- const l = d[e];
435
- l.status = "uploading", l.message = "上传中...", d.length > 1 && H({
436
- message: `正在上传 ${e + 1}/${d.length}`,
444
+ let y = 0, e = 0;
445
+ for (let o = 0; o < u.length; o++) {
446
+ const i = u[o];
447
+ i.status = "uploading", i.message = "上传中...", u.length > 1 && X({
448
+ message: `正在上传 ${o + 1}/${u.length}`,
437
449
  forbidClick: !0,
438
450
  duration: 0
439
451
  });
440
- const p = await g(l);
441
- p.success ? (l.status = "done", l.message = "", l.url = p.url, f++, m("success", { file: l, url: p.url })) : (l.status = "failed", l.message = p.message, a++, m("error", { file: l, message: p.message }));
452
+ const v = await U(i);
453
+ v.success ? (i.status = "done", i.message = "", i.url = v.url, y++, s("success", { file: i, url: v.url })) : (i.status = "failed", i.message = v.message, e++, s("error", { file: i, message: v.message }));
442
454
  }
443
- ee(), d.length > 1 ? a === 0 ? M(`${f}个文件上传成功`) : M(`${f}个成功,${a}个失败`) : a > 0 && M(d[0].message || "上传失败"), y();
444
- }, U = () => {
455
+ re(), u.length > 1 ? e === 0 ? H(`${y}个文件上传成功`) : H(`${y}个成功,${e}个失败`) : e > 0 && H(u[0].message || "上传失败"), q();
456
+ }, P = () => {
445
457
  setTimeout(() => {
446
- y();
458
+ q();
447
459
  }, 0);
448
460
  };
449
- return h({
461
+ return d({
450
462
  /** 获取已上传的URL列表 */
451
- getUrls: o,
463
+ getUrls: g,
452
464
  /** 清空文件列表 */
453
465
  clear: () => {
454
- i.value = [], y();
466
+ f.value = [], q();
455
467
  },
456
468
  /** 获取文件列表 */
457
- getFileList: () => i.value
458
- }), (u, d) => {
459
- const f = V("van-uploader");
460
- return k(), L(f, X({
461
- modelValue: i.value,
462
- "onUpdate:modelValue": d[0] || (d[0] = (a) => i.value = a)
463
- }, u.$attrs, {
464
- "max-size": n.maxSize,
465
- accept: n.accept,
466
- "before-read": v,
467
- "after-read": N,
468
- onDelete: U
469
+ getFileList: () => f.value
470
+ }), (a, u) => {
471
+ const y = V("van-uploader");
472
+ return C(), z(y, te({
473
+ modelValue: f.value,
474
+ "onUpdate:modelValue": u[0] || (u[0] = (e) => f.value = e)
475
+ }, a.$attrs, {
476
+ "max-size": l.maxSize,
477
+ accept: l.accept,
478
+ "before-read": w,
479
+ "after-read": j,
480
+ onDelete: P
469
481
  }), null, 16, ["modelValue", "max-size", "accept"]);
470
482
  };
471
483
  }
472
- }), D = /* @__PURE__ */ q(ne, [["__scopeId", "data-v-2ccc0da3"]]);
473
- D.install = (n) => {
474
- n.component(D.name || "VtkUploader", D);
484
+ }), W = /* @__PURE__ */ J(ie, [["__scopeId", "data-v-620ae5d0"]]);
485
+ W.install = (l, d = {}) => {
486
+ d != null && d.request && (l.provide("vant-vtk:request", d.request), l.config.globalProperties.$vtkRequest = d.request), l.component(W.name || "VtkUploader", W);
475
487
  };
476
- const oe = { class: "file-preview-container" }, re = { class: "file-header" }, se = { class: "file-title" }, ue = { class: "file-content" }, ie = {
488
+ const de = { class: "file-preview-container" }, ce = { class: "file-header" }, me = { class: "file-title" }, ve = { class: "file-content" }, fe = {
477
489
  key: 0,
478
490
  class: "image-preview"
479
- }, de = { class: "image-footer" }, ce = { class: "file-info" }, pe = {
491
+ }, pe = { class: "image-footer" }, ge = { class: "file-info" }, ye = {
480
492
  key: 1,
481
493
  class: "pdf-preview"
482
- }, me = {
494
+ }, he = {
483
495
  key: 1,
484
496
  class: "pdf-placeholder"
485
- }, fe = { class: "pdf-footer" }, ve = { class: "page-info" }, ge = { class: "footer" }, ye = /* @__PURE__ */ Object.assign({
497
+ }, _e = { class: "pdf-footer" }, Ve = { class: "page-info" }, be = { class: "footer" }, ke = /* @__PURE__ */ Object.assign({
486
498
  name: "VtkPreview"
487
499
  }, {
488
500
  __name: "index",
@@ -501,145 +513,145 @@ const oe = { class: "file-preview-container" }, re = { class: "file-header" }, s
501
513
  }
502
514
  },
503
515
  emits: ["update:modelValue", "close"],
504
- setup(n, { emit: h }) {
505
- const r = n, c = h, m = C(r.modelValue), i = C(r.startIndex), t = C(1), o = C(null), s = C(0), y = $(() => r.files.map((e, l) => {
506
- if (typeof e == "string") {
507
- const p = e.toLowerCase().endsWith(".pdf");
516
+ setup(l, { emit: d }) {
517
+ const n = l, _ = d, c = S(n.modelValue), p = S(n.startIndex), r = S(1), t = S(null), s = S(0), f = R(() => n.files.map((m, a) => {
518
+ if (typeof m == "string") {
519
+ const u = m.toLowerCase().endsWith(".pdf");
508
520
  return {
509
- name: p ? `文档${l + 1}.pdf` : `图片${l + 1}`,
510
- url: e,
511
- type: p ? "pdf" : "image"
521
+ name: u ? `文档${a + 1}.pdf` : `图片${a + 1}`,
522
+ url: m,
523
+ type: u ? "pdf" : "image"
512
524
  };
513
525
  }
514
- return e;
515
- })), v = $(() => y.value[i.value] || null), g = $(() => {
516
- if (!v.value) return null;
517
- const e = v.value.url || v.value;
518
- return typeof e == "string" ? e.toLowerCase().endsWith(".pdf") ? "pdf" : "image" : v.value.type || "image";
526
+ return m;
527
+ })), h = R(() => f.value[p.value] || null), g = R(() => {
528
+ if (!h.value) return null;
529
+ const m = h.value.url || h.value;
530
+ return typeof m == "string" ? m.toLowerCase().endsWith(".pdf") ? "pdf" : "image" : h.value.type || "image";
519
531
  });
520
- z(
521
- () => r.modelValue,
522
- (e) => {
523
- m.value = e, e && y.value.length > 0 && (i.value = r.startIndex, N());
532
+ I(
533
+ () => n.modelValue,
534
+ (m) => {
535
+ c.value = m, m && f.value.length > 0 && (p.value = n.startIndex, b());
524
536
  }
525
- ), z(
526
- () => r.startIndex,
527
- (e) => {
528
- i.value = e, N();
537
+ ), I(
538
+ () => n.startIndex,
539
+ (m) => {
540
+ p.value = m, b();
529
541
  }
530
- ), z(m, (e) => {
531
- c("update:modelValue", e), e || a();
532
- }), z(i, () => {
533
- t.value = 1, s.value = 0, N();
542
+ ), I(c, (m) => {
543
+ _("update:modelValue", m), m || P();
544
+ }), I(p, () => {
545
+ r.value = 1, s.value = 0, b();
534
546
  });
535
- const N = () => {
536
- const e = v.value;
537
- e && (g.value === "pdf" ? o.value = e.url || e : o.value = null);
538
- }, U = (e) => {
539
- s.value = e.numPages || 0;
540
- }, u = () => {
547
+ const b = () => {
548
+ const m = h.value;
549
+ m && (g.value === "pdf" ? t.value = m.url || m : t.value = null);
550
+ }, q = (m) => {
551
+ s.value = m.numPages || 0;
552
+ }, w = () => {
541
553
  console.log("PDF rendered successfully");
542
- }, d = () => {
543
- i.value > 0 && i.value--;
544
- }, f = () => {
545
- i.value < y.value.length - 1 && i.value++;
546
- }, a = () => {
547
- m.value = !1, o.value = null, t.value = 1, s.value = 0, c("close");
554
+ }, U = () => {
555
+ p.value > 0 && p.value--;
556
+ }, j = () => {
557
+ p.value < f.value.length - 1 && p.value++;
558
+ }, P = () => {
559
+ c.value = !1, t.value = null, r.value = 1, s.value = 0, _("close");
548
560
  };
549
- return (e, l) => {
550
- const p = V("van-icon"), j = V("van-image"), b = V("van-button"), E = V("van-popup");
551
- return k(), L(E, {
552
- show: m.value,
553
- "onUpdate:show": l[2] || (l[2] = (_) => m.value = _),
561
+ return (m, a) => {
562
+ const u = V("van-icon"), y = V("van-image"), e = V("van-button"), o = V("van-popup");
563
+ return C(), z(o, {
564
+ show: c.value,
565
+ "onUpdate:show": a[2] || (a[2] = (i) => c.value = i),
554
566
  position: "bottom",
555
567
  style: { height: "100vh" }
556
568
  }, {
557
- default: S(() => {
558
- var _, G;
569
+ default: A(() => {
570
+ var i, v;
559
571
  return [
560
- A("div", oe, [
561
- A("div", re, [
562
- A("div", se, w(((_ = v.value) == null ? void 0 : _.name) || "文件预览"), 1),
563
- x(p, {
572
+ $("div", de, [
573
+ $("div", ce, [
574
+ $("div", me, T(((i = h.value) == null ? void 0 : i.name) || "文件预览"), 1),
575
+ x(u, {
564
576
  name: "cross",
565
577
  size: "20",
566
- onClick: a
578
+ onClick: P
567
579
  })
568
580
  ]),
569
- A("div", ue, [
570
- g.value === "image" ? (k(), P("div", ie, [
571
- x(j, {
572
- src: (G = v.value) == null ? void 0 : G.url,
581
+ $("div", ve, [
582
+ g.value === "image" ? (C(), D("div", fe, [
583
+ x(y, {
584
+ src: (v = h.value) == null ? void 0 : v.url,
573
585
  fit: "contain",
574
586
  class: "preview-image"
575
587
  }, null, 8, ["src"]),
576
- A("div", de, [
577
- x(b, {
588
+ $("div", pe, [
589
+ x(e, {
578
590
  size: "small",
579
- disabled: i.value <= 0,
580
- onClick: d
591
+ disabled: p.value <= 0,
592
+ onClick: U
581
593
  }, {
582
- default: S(() => [...l[3] || (l[3] = [
583
- T("上一个", -1)
594
+ default: A(() => [...a[3] || (a[3] = [
595
+ F("上一个", -1)
584
596
  ])]),
585
597
  _: 1
586
598
  }, 8, ["disabled"]),
587
- A("span", ce, w(i.value + 1) + " / " + w(n.files.length), 1),
588
- x(b, {
599
+ $("span", ge, T(p.value + 1) + " / " + T(l.files.length), 1),
600
+ x(e, {
589
601
  size: "small",
590
- disabled: i.value >= n.files.length - 1,
591
- onClick: f
602
+ disabled: p.value >= l.files.length - 1,
603
+ onClick: j
592
604
  }, {
593
- default: S(() => [...l[4] || (l[4] = [
594
- T("下一个", -1)
605
+ default: A(() => [...a[4] || (a[4] = [
606
+ F("下一个", -1)
595
607
  ])]),
596
608
  _: 1
597
609
  }, 8, ["disabled"])
598
610
  ])
599
- ])) : g.value === "pdf" ? (k(), P("div", pe, [
600
- o.value ? (k(), L(Z(ae), {
611
+ ])) : g.value === "pdf" ? (C(), D("div", ye, [
612
+ t.value ? (C(), z(le(oe), {
601
613
  key: 0,
602
- source: o.value,
603
- page: t.value,
614
+ source: t.value,
615
+ page: r.value,
604
616
  class: "pdf-embed-preview",
605
- onRendered: u,
606
- onLoaded: U
607
- }, null, 8, ["source", "page"])) : (k(), P("div", me, "请选择PDF文件")),
608
- A("div", fe, [
609
- x(b, {
617
+ onRendered: w,
618
+ onLoaded: q
619
+ }, null, 8, ["source", "page"])) : (C(), D("div", he, "请选择PDF文件")),
620
+ $("div", _e, [
621
+ x(e, {
610
622
  size: "small",
611
- disabled: t.value <= 1,
612
- onClick: l[0] || (l[0] = (Y) => t.value--)
623
+ disabled: r.value <= 1,
624
+ onClick: a[0] || (a[0] = (L) => r.value--)
613
625
  }, {
614
- default: S(() => [...l[5] || (l[5] = [
615
- T("上一页", -1)
626
+ default: A(() => [...a[5] || (a[5] = [
627
+ F("上一页", -1)
616
628
  ])]),
617
629
  _: 1
618
630
  }, 8, ["disabled"]),
619
- A("span", ve, "第 " + w(t.value) + " / " + w(s.value || "?") + " 页", 1),
620
- x(b, {
631
+ $("span", Ve, "第 " + T(r.value) + " / " + T(s.value || "?") + " 页", 1),
632
+ x(e, {
621
633
  size: "small",
622
- disabled: !o.value || t.value >= s.value,
623
- onClick: l[1] || (l[1] = (Y) => t.value++)
634
+ disabled: !t.value || r.value >= s.value,
635
+ onClick: a[1] || (a[1] = (L) => r.value++)
624
636
  }, {
625
- default: S(() => [...l[6] || (l[6] = [
626
- T("下一页", -1)
637
+ default: A(() => [...a[6] || (a[6] = [
638
+ F("下一页", -1)
627
639
  ])]),
628
640
  _: 1
629
641
  }, 8, ["disabled"])
630
642
  ])
631
- ])) : O("", !0),
632
- A("div", ge, [
633
- x(b, {
634
- disabled: i.value <= 0,
635
- onClick: d,
643
+ ])) : ne("", !0),
644
+ $("div", be, [
645
+ x(e, {
646
+ disabled: p.value <= 0,
647
+ onClick: U,
636
648
  icon: "arrow-left",
637
649
  type: "primary",
638
650
  round: ""
639
651
  }, null, 8, ["disabled"]),
640
- x(b, {
641
- disabled: i.value >= n.files.length - 1,
642
- onClick: f,
652
+ x(e, {
653
+ disabled: p.value >= l.files.length - 1,
654
+ onClick: j,
643
655
  icon: "arrow",
644
656
  type: "primary",
645
657
  round: ""
@@ -653,37 +665,37 @@ const oe = { class: "file-preview-container" }, re = { class: "file-header" }, s
653
665
  }, 8, ["show"]);
654
666
  };
655
667
  }
656
- }), B = /* @__PURE__ */ q(ye, [["__scopeId", "data-v-1ad2c749"]]);
657
- B.install = (n) => {
658
- n.component(B.name || "VtkPreview", B);
668
+ }), G = /* @__PURE__ */ J(ke, [["__scopeId", "data-v-1ad2c749"]]);
669
+ G.install = (l) => {
670
+ l.component(G.name || "VtkPreview", G);
659
671
  };
660
- const _e = [
661
- F,
662
- I,
663
- R,
664
- D,
665
- B
666
- ], he = (n) => {
667
- _e.forEach((h) => {
668
- h.install ? n.use(h) : h.name && n.component(h.name, h);
672
+ const xe = [
673
+ B,
674
+ E,
675
+ M,
676
+ W,
677
+ G
678
+ ], Ce = (l, d = {}) => {
679
+ d != null && d.request && (l.provide("vant-vtk:request", d.request), l.config.globalProperties.$vtkRequest = d.request), xe.forEach((n) => {
680
+ n.install ? l.use(n, d) : n.name && l.component(n.name, n);
669
681
  });
670
- }, ke = {
671
- install: he,
682
+ }, we = {
683
+ install: Ce,
672
684
  // 也导出所有组件,方便直接访问
673
- Checkbox: F,
674
- Area: I,
675
- Radio: R,
676
- Uploader: D,
677
- Preview: B
678
- }, Ce = "1.0.0";
685
+ Checkbox: B,
686
+ Area: E,
687
+ Radio: M,
688
+ Uploader: W,
689
+ Preview: G
690
+ }, Ne = "1.0.0";
679
691
  export {
680
- I as Area,
681
- F as Checkbox,
682
- B as Preview,
683
- R as Radio,
684
- D as Uploader,
685
- ke as default,
686
- he as install,
687
- Ce as version
692
+ E as Area,
693
+ B as Checkbox,
694
+ G as Preview,
695
+ M as Radio,
696
+ W as Uploader,
697
+ we as default,
698
+ Ce as install,
699
+ Ne as version
688
700
  };
689
701
  //# sourceMappingURL=vant-vtk.es.js.map