@keyblade/pro-components 1.13.3 → 1.13.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.
@@ -1,31 +1,31 @@
1
- import { defineComponent as ge, mergeModels as J, useSlots as pe, useModel as he, ref as m, computed as w, watch as K, resolveComponent as Ie, createElementBlock as xe, openBlock as X, createVNode as Ue, createBlock as ye, createCommentVNode as Ce, normalizeClass as Be, createSlots as we, withCtx as Y, unref as Z, renderSlot as A } from "vue";
1
+ import { defineComponent as he, mergeModels as Y, useSlots as Ie, useModel as xe, ref as m, computed as w, watch as Z, resolveComponent as Ue, createElementBlock as Ce, openBlock as N, createVNode as ye, createBlock as Be, createCommentVNode as we, normalizeClass as Ee, createSlots as Me, withCtx as A, unref as R, renderSlot as _ } from "vue";
2
2
  import { Message as g } from "@arco-design/web-vue";
3
3
  import { conclude as L } from "vue-global-config";
4
4
  import { EImageUploadInnerBeforeUploadStep as v } from "./types.js";
5
5
  import { defaultImageUploadOptions as U } from "./constant.js";
6
- import Ee from "./cropper.vue.js";
7
- import { defaultImageUploadCheckOptions as Me, defaultImageUploadCompressorOptions as Se, defaultImageUploadCropOptions as be, oneTravelImageCheckAndTransform as Le, oneTravelImageCompressor as Oe } from "@keyblade/one-travel";
8
- const $e = "keyblade-pro-image-upload";
9
- var R, _, ee;
10
- const He = /* @__PURE__ */ ge({
6
+ import Se from "./cropper.vue.js";
7
+ import { defaultImageUploadCheckOptions as be, defaultImageUploadCompressorOptions as Le, defaultImageUploadCropOptions as Oe, oneTravelImageCheckAndTransform as $e, oneTravelImageCompressor as ke } from "@keyblade/one-travel";
8
+ const ze = "keyblade-pro-image-upload";
9
+ var ee, ae, le;
10
+ const qe = /* @__PURE__ */ he({
11
11
  __name: "image-upload",
12
- props: /* @__PURE__ */ J({
12
+ props: /* @__PURE__ */ Y({
13
13
  action: {},
14
14
  handlerResponse: {},
15
15
  headers: {},
16
16
  data: {},
17
- name: { default: (R = U) == null ? void 0 : R.name },
17
+ name: { default: (ee = U) == null ? void 0 : ee.name },
18
18
  tip: {},
19
19
  accept: { default: () => {
20
- var y;
21
- return ((y = U) == null ? void 0 : y.accept) || [];
20
+ var C;
21
+ return ((C = U) == null ? void 0 : C.accept) || [];
22
22
  } },
23
23
  multiple: { type: Boolean, default: U.multiple },
24
24
  singleLimit: { default: U.singleLimit },
25
25
  limit: {},
26
26
  exceedTip: {},
27
- disabled: { type: Boolean, default: (_ = U) == null ? void 0 : _.disabled },
28
- hideInnerBeforeUploadLoading: { type: Boolean, default: (ee = U) == null ? void 0 : ee.hideInnerBeforeUploadLoading },
27
+ disabled: { type: Boolean, default: (ae = U) == null ? void 0 : ae.disabled },
28
+ hideInnerBeforeUploadLoading: { type: Boolean, default: (le = U) == null ? void 0 : le.hideInnerBeforeUploadLoading },
29
29
  checkOptions: {},
30
30
  compressorOptions: {},
31
31
  cropOptions: {},
@@ -39,63 +39,63 @@ const He = /* @__PURE__ */ ge({
39
39
  modelValue: { required: !0 },
40
40
  modelModifiers: {}
41
41
  }),
42
- emits: /* @__PURE__ */ J(["cropperImgLoad"], ["update:modelValue"]),
43
- setup(y, { expose: ae, emit: le }) {
44
- const O = pe(), r = he(y, "modelValue"), e = y, oe = le, S = m(), $ = m(), p = m(), h = m([]), n = m(), c = m(), s = m(), ne = w(() => e.accept.map((a) => `.${a}`).join(",")), f = w(() => L([e.checkOptions, Me]) || {}), C = w(() => L([e.compressorOptions, Se]) || {}), B = w(() => L([e.cropOptions, be]) || {}), te = (a) => {
45
- var t, u, d, i;
46
- const l = (i = (d = (u = (t = S.value) == null ? void 0 : t.$el) == null ? void 0 : u.querySelector) == null ? void 0 : d.call(u, "input")) == null ? void 0 : i.files;
42
+ emits: /* @__PURE__ */ Y(["cropperImgLoad"], ["update:modelValue"]),
43
+ setup(C, { expose: oe, emit: ne }) {
44
+ const O = Ie(), u = xe(C, "modelValue"), e = C, te = ne, S = m(), $ = m(), p = m(), h = m([]), n = m(), c = m(), s = m(), ie = w(() => e.accept.map((a) => `.${a}`).join(",")), f = w(() => L([e.checkOptions, be]) || {}), y = w(() => L([e.compressorOptions, Le]) || {}), B = w(() => L([e.cropOptions, Oe]) || {}), re = (a) => {
45
+ var i, d, t, r;
46
+ const l = (r = (t = (d = (i = S.value) == null ? void 0 : i.$el) == null ? void 0 : d.querySelector) == null ? void 0 : t.call(d, "input")) == null ? void 0 : r.files;
47
47
  return l && l.length > 0 && (s.value = {
48
48
  selectCount: l.length
49
49
  }), e != null && e.onBeforeUpload ? e == null ? void 0 : e.onBeforeUpload(a) : s.value && (e != null && e.singleLimit) && s.value.selectCount > (e == null ? void 0 : e.singleLimit) ? (s.value.handleIndex === void 0 ? (s.value.handleIndex = 0, g.clear(), g.error(`单次最多可选择${e == null ? void 0 : e.singleLimit}张图片`)) : s.value.handleIndex += 1, s.value.handleIndex === s.value.selectCount - 1 && (s.value = void 0), !1) : new Promise(async (E, M) => {
50
50
  try {
51
- E(await se(a));
51
+ E(await fe(a));
52
52
  } catch {
53
53
  M();
54
54
  } finally {
55
55
  k();
56
56
  }
57
57
  });
58
- }, ie = async (a) => {
59
- const l = r.value.findIndex((t) => t.uid === a.uid);
60
- return r.value.splice(l, 1), r.value = [...r.value], !1;
61
- }, re = (a, l) => {
62
- e != null && e.onExceed ? e == null || e.onExceed(a, l) : (g.error(e.exceedTip ?? `超过数量上限,最多上传${(e == null ? void 0 : e.limit) || 1}张`), r.value = a);
63
58
  }, ue = async (a) => {
59
+ const l = u.value.findIndex((i) => i.uid === a.uid);
60
+ return u.value.splice(l, 1), u.value = [...u.value], !1;
61
+ }, de = (a, l) => {
62
+ e != null && e.onExceed ? e == null || e.onExceed(a, l) : (g.error(e.exceedTip ?? `超过数量上限,最多上传${(e == null ? void 0 : e.limit) || 1}张`), u.value = a);
63
+ }, se = async (a) => {
64
64
  if (e != null && e.onSuccess)
65
65
  e == null || e.onSuccess(a);
66
66
  else {
67
67
  if (!(e != null && e.handlerResponse))
68
68
  return;
69
- const l = await e.handlerResponse(a.response), t = r.value.findIndex((u) => u.uid === a.uid);
70
- l.success ? r.value[t] = {
71
- ...r.value[t],
69
+ const l = await e.handlerResponse(a.response), i = u.value.findIndex((d) => d.uid === a.uid);
70
+ l.success ? u.value[i] = {
71
+ ...u.value[i],
72
72
  ...l
73
- } : r.value.splice(t, 1);
73
+ } : u.value.splice(i, 1);
74
74
  }
75
- }, de = (a) => {
75
+ }, ce = (a) => {
76
76
  e != null && e.onError ? e == null || e.onError(a) : setTimeout(() => {
77
- const l = r.value.findIndex((t) => t.uid === a.uid);
78
- r.value.splice(l, 1);
77
+ const l = u.value.findIndex((i) => i.uid === a.uid);
78
+ u.value.splice(l, 1);
79
79
  });
80
- }, se = (a) => new Promise((l, t) => {
81
- h.value.push({ file: a, resolve: l, reject: t }), h.value.length === 1 && !n.value && k();
80
+ }, fe = (a) => new Promise((l, i) => {
81
+ h.value.push({ file: a, resolve: l, reject: i }), h.value.length === 1 && !n.value && k();
82
82
  }), k = () => {
83
83
  n.value === void 0 ? n.value = 0 : n.value + 1 >= h.value.length ? (n.value = void 0, h.value = []) : n.value += 1;
84
- }, ce = () => {
84
+ }, ve = () => {
85
85
  var a;
86
86
  (a = p.value) == null || a.reject();
87
- }, fe = (a) => {
87
+ }, me = (a) => {
88
88
  var l;
89
89
  (l = p.value) == null || l.resolve(a);
90
- }, ve = (a) => {
91
- oe("cropperImgLoad", a);
90
+ }, ge = (a) => {
91
+ te("cropperImgLoad", a);
92
92
  };
93
- K(n, async () => {
94
- var E, M, b, F, z, j, Q, T, V, W, H, N, P, q, D, G;
93
+ Z(n, async () => {
94
+ var E, M, b, z, j, Q, T, V, W, F, H, P, q, D, G, J, K, X;
95
95
  if (n.value === void 0 || h.value.length === 0)
96
96
  return;
97
- const a = h.value[n.value], { file: l, resolve: t, reject: u } = a;
98
- let d = l.name, i = l;
97
+ const a = h.value[n.value], { file: l, resolve: i, reject: d } = a;
98
+ let t = l.name, r = l;
99
99
  if ((E = f.value) != null && E.enable) {
100
100
  c.value = {
101
101
  loading: !0,
@@ -106,7 +106,7 @@ const He = /* @__PURE__ */ ge({
106
106
  n.value,
107
107
  v.check
108
108
  );
109
- const o = await Le(l, l.name, {
109
+ const o = await $e(l, l.name, {
110
110
  imageMaxSize: f.value.maxSize,
111
111
  imageAllowedType: f.value.allowedType,
112
112
  imageMinWidth: f.value.minWidth,
@@ -125,26 +125,26 @@ const He = /* @__PURE__ */ ge({
125
125
  errorMessage: o == null ? void 0 : o.errorMessage
126
126
  }
127
127
  ), !o.success)
128
- return (F = f.value) != null && F.showErrorMessage && g.error((o == null ? void 0 : o.errorMessage) || "图片校验及转换失败"), u();
128
+ return (z = f.value) != null && z.showErrorMessage && g.error((o == null ? void 0 : o.errorMessage) || "图片校验及转换失败"), d();
129
129
  if (o != null && o.hasTransform) {
130
- const x = d == null ? void 0 : d.split(".");
131
- x.pop(), d = `${x.join(",")}.jpg`, i = new File([o.file], d, {
130
+ const x = t == null ? void 0 : t.split(".");
131
+ x.pop(), t = `${x.join(",")}.jpg`, r = new File([o.file], t, {
132
132
  type: o.file.type
133
133
  });
134
134
  } else
135
- i = o.file;
135
+ r = o.file;
136
136
  }
137
- if ((z = B.value) != null && z.enable && !d.endsWith(".gif")) {
138
- (j = e == null ? void 0 : e.onInnerBeforeUploadStart) == null || j.call(
137
+ if ((j = B.value) != null && j.enable && !((T = (Q = t == null ? void 0 : t.toLocaleLowerCase) == null ? void 0 : Q.call(t)) != null && T.endsWith(".gif"))) {
138
+ (V = e == null ? void 0 : e.onInnerBeforeUploadStart) == null || V.call(
139
139
  e,
140
140
  l,
141
141
  n.value,
142
142
  v.crop
143
143
  );
144
144
  try {
145
- (Q = B.value) != null && Q.customCrop ? i = await B.value.customCrop(i) : i = await new Promise((o, x) => {
146
- p.value = { file: i, resolve: o, reject: x };
147
- }), (T = e == null ? void 0 : e.onInnerBeforeUploadEnd) == null || T.call(
145
+ (W = B.value) != null && W.customCrop ? r = await B.value.customCrop(r) : r = await new Promise((o, x) => {
146
+ p.value = { file: r, resolve: o, reject: x };
147
+ }), (F = e == null ? void 0 : e.onInnerBeforeUploadEnd) == null || F.call(
148
148
  e,
149
149
  l,
150
150
  n.value,
@@ -154,7 +154,7 @@ const He = /* @__PURE__ */ ge({
154
154
  }
155
155
  );
156
156
  } catch {
157
- return (V = e == null ? void 0 : e.onInnerBeforeUploadEnd) == null || V.call(
157
+ return (H = e == null ? void 0 : e.onInnerBeforeUploadEnd) == null || H.call(
158
158
  e,
159
159
  l,
160
160
  n.value,
@@ -166,27 +166,27 @@ const He = /* @__PURE__ */ ge({
166
166
  },
167
167
  errorMessage: "图片剪裁失败"
168
168
  }
169
- ), (W = B.value) != null && W.showErrorMessage && g.error("图片剪裁失败"), u();
169
+ ), (P = B.value) != null && P.showErrorMessage && g.error("图片剪裁失败"), d();
170
170
  } finally {
171
171
  p.value = void 0;
172
172
  }
173
173
  }
174
- if ((H = C.value) != null && H.enable) {
174
+ if ((q = y.value) != null && q.enable) {
175
175
  c.value = {
176
176
  loading: !0,
177
177
  text: `第${n.value + 1}张图片处理中,请稍等`
178
- }, (N = e == null ? void 0 : e.onInnerBeforeUploadStart) == null || N.call(
178
+ }, (D = e == null ? void 0 : e.onInnerBeforeUploadStart) == null || D.call(
179
179
  e,
180
180
  l,
181
181
  n.value,
182
182
  v.compress
183
183
  );
184
- const o = await Oe(i, {
185
- maxSize: C.value.maxSize,
186
- size: C.value.size,
187
- excludeAllowedTypes: (P = C.value.excludeAllowedTypes) == null ? void 0 : P.map((x) => `image/${x}`)
184
+ const o = await ke(r, {
185
+ maxSize: y.value.maxSize,
186
+ size: y.value.size,
187
+ excludeAllowedTypes: (G = y.value.excludeAllowedTypes) == null ? void 0 : G.map((x) => `${x}`)
188
188
  });
189
- if (c.value = void 0, (q = e == null ? void 0 : e.onInnerBeforeUploadEnd) == null || q.call(
189
+ if (c.value = void 0, (J = e == null ? void 0 : e.onInnerBeforeUploadEnd) == null || J.call(
190
190
  e,
191
191
  l,
192
192
  n.value,
@@ -199,12 +199,12 @@ const He = /* @__PURE__ */ ge({
199
199
  errorMessage: o == null ? void 0 : o.errorMessage
200
200
  }
201
201
  ), !o.success)
202
- return (D = C.value) != null && D.showErrorMessage && g.error((o == null ? void 0 : o.errorMessage) || "图片压缩失败"), u();
203
- i = new File([o.file], d, {
202
+ return (K = y.value) != null && K.showErrorMessage && g.error((o == null ? void 0 : o.errorMessage) || "图片压缩失败"), d();
203
+ r = new File([o.file], t, {
204
204
  type: o.file.type
205
205
  });
206
206
  }
207
- c.value = void 0, (G = e == null ? void 0 : e.onInnerBeforeUploadEnd) == null || G.call(
207
+ c.value = void 0, (X = e == null ? void 0 : e.onInnerBeforeUploadEnd) == null || X.call(
208
208
  e,
209
209
  l,
210
210
  n.value,
@@ -212,10 +212,10 @@ const He = /* @__PURE__ */ ge({
212
212
  {
213
213
  success: !0
214
214
  }
215
- ), t(i);
215
+ ), i(r);
216
216
  });
217
217
  let I;
218
- K(
218
+ Z(
219
219
  () => c.value,
220
220
  () => {
221
221
  var a;
@@ -226,68 +226,68 @@ const He = /* @__PURE__ */ ge({
226
226
  }) : (a = I == null ? void 0 : I.close) == null || a.call(I);
227
227
  }
228
228
  );
229
- const me = w(() => r.value.every((a) => a.status && ["done", "error"].includes(a.status)));
230
- return ae({
229
+ const pe = w(() => u.value.every((a) => a.status && ["done", "error"].includes(a.status)));
230
+ return oe({
231
231
  uploadInsRef: S,
232
232
  cropperInsRef: $,
233
- isUploadComplete: me
233
+ isUploadComplete: pe
234
234
  }), (a, l) => {
235
- var u, d;
236
- const t = Ie("a-upload");
237
- return X(), xe("div", null, [
238
- Ue(t, {
239
- class: Be([`${$e}-upload`]),
235
+ var d, t;
236
+ const i = Ue("a-upload");
237
+ return N(), Ce("div", null, [
238
+ ye(i, {
239
+ class: Ee([`${ze}-upload`]),
240
240
  ref_key: "uploadInsRef",
241
241
  ref: S,
242
242
  "list-type": "picture-card",
243
243
  tip: a.tip || "上传",
244
244
  "image-preview": "",
245
- "file-list": r.value,
246
- "onUpdate:fileList": l[0] || (l[0] = (i) => r.value = i),
245
+ "file-list": u.value,
246
+ "onUpdate:fileList": l[0] || (l[0] = (r) => u.value = r),
247
247
  action: a.action,
248
248
  headers: a.headers,
249
249
  data: a.data,
250
250
  name: a.name,
251
- accept: ne.value,
251
+ accept: ie.value,
252
252
  multiple: a.multiple,
253
253
  limit: a.limit,
254
254
  disabled: a.disabled,
255
- "on-before-upload": te,
256
- "on-before-remove": ie,
257
- onExceedLimit: re,
258
- onSuccess: ue,
259
- onError: de
260
- }, we({ _: 2 }, [
261
- (u = Z(O)) != null && u.image ? {
255
+ "on-before-upload": re,
256
+ "on-before-remove": ue,
257
+ onExceedLimit: de,
258
+ onSuccess: se,
259
+ onError: ce
260
+ }, Me({ _: 2 }, [
261
+ (d = R(O)) != null && d.image ? {
262
262
  name: "image",
263
- fn: Y(({ fileItem: i }) => [
264
- A(a.$slots, "image", { fileItem: i })
263
+ fn: A(({ fileItem: r }) => [
264
+ _(a.$slots, "image", { fileItem: r })
265
265
  ]),
266
266
  key: "0"
267
267
  } : void 0,
268
- (d = Z(O)) != null && d["upload-button"] ? {
268
+ (t = R(O)) != null && t["upload-button"] ? {
269
269
  name: "upload-button",
270
- fn: Y(() => [
271
- A(a.$slots, "upload-button")
270
+ fn: A(() => [
271
+ _(a.$slots, "upload-button")
272
272
  ]),
273
273
  key: "1"
274
274
  } : void 0
275
275
  ]), 1032, ["class", "tip", "file-list", "action", "headers", "data", "name", "accept", "multiple", "limit", "disabled"]),
276
- p.value && n.value !== void 0 ? (X(), ye(Ee, {
276
+ p.value && n.value !== void 0 ? (N(), Be(Se, {
277
277
  key: 0,
278
278
  ref_key: "cropperInsRef",
279
279
  ref: $,
280
280
  file: p.value.file,
281
281
  index: n.value,
282
282
  options: B.value,
283
- onCancel: ce,
284
- onConfirm: fe,
285
- onImgLoad: ve
286
- }, null, 8, ["file", "index", "options"])) : Ce("", !0)
283
+ onCancel: ve,
284
+ onConfirm: me,
285
+ onImgLoad: ge
286
+ }, null, 8, ["file", "index", "options"])) : we("", !0)
287
287
  ]);
288
288
  };
289
289
  }
290
290
  });
291
291
  export {
292
- He as default
292
+ qe as default
293
293
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@keyblade/pro-components",
3
3
  "description": "KeyBlade Pro Components",
4
4
  "author": "yangshuai <704807396@qq.com>",
5
- "version": "1.13.3",
5
+ "version": "1.13.5",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",
@@ -26,7 +26,7 @@
26
26
  "vue-cropper": "^1.1.4",
27
27
  "vue-global-config": "^0.6.3",
28
28
  "dayjs": "^1.11.18",
29
- "@keyblade/one-travel": "^3.0.1"
29
+ "@keyblade/one-travel": "^3.0.3"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "vue": "^3.4.27"