@keyblade/pro-components 1.12.10 → 1.12.12

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,8 +1,8 @@
1
- import { Form as r } from "@arco-design/web-vue";
2
- import o from "./pro-date-range-picker.vue.js";
3
- const n = Object.assign(o, {
1
+ import { Form as o, DatePicker as t } from "@arco-design/web-vue";
2
+ import r from "./pro-date-range-picker.vue.js";
3
+ const n = Object.assign(r, {
4
4
  install: (e) => {
5
- e.use(r), e.component("KbProDateRangePicker", o);
5
+ e.use(o), e.use(t), e.component("KbProDateRangePicker", r);
6
6
  }
7
7
  });
8
8
  export {
@@ -48,7 +48,7 @@ type __VLS_Props = {
48
48
  onError?: (fileItem: FileItem) => void;
49
49
  /** 文件超出个数限制时的钩子 */
50
50
  onExceed?: (fileList: FileItem[], files: File[]) => void;
51
- /** 上传文件之前的钩子,参数为上传的文件,若返回 false 或者返回 Promise 且被 reject,则停止上传。*/
51
+ /** 上传文件之前的钩子,参数为上传的文件,若返回 false 或者返回 Promise 且被 reject,则停止上传。 */
52
52
  onBeforeUpload?: (file: File) => boolean | Promise<any>;
53
53
  /** 内置上传文件之前开始 */
54
54
  onInnerBeforeUploadStart?: (file: File, index: number, type: EImageUploadInnerBeforeUploadStep) => void;
@@ -69,7 +69,58 @@ type __VLS_Props = {
69
69
  type __VLS_PublicProps = {
70
70
  modelValue: FileItem[];
71
71
  } & __VLS_Props;
72
- declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {
72
+ declare function __VLS_template(): {
73
+ attrs: Partial<{}>;
74
+ slots: {
75
+ image?(_: {
76
+ fileItem: any;
77
+ }): any;
78
+ 'upload-button'?(_: {}): any;
79
+ };
80
+ refs: {
81
+ uploadInsRef: unknown;
82
+ cropperInsRef: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
83
+ file: File;
84
+ index: number;
85
+ options: ImageUploadCropOptions;
86
+ }> & Readonly<{
87
+ onCancel?: (() => any) | undefined;
88
+ onConfirm?: ((value: File) => any) | undefined;
89
+ onImgLoad?: ((value: File) => any) | undefined;
90
+ onReUpload?: ((index: number) => any) | undefined;
91
+ }>, {
92
+ cropperInsRef: import('vue').Ref<any, any>;
93
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
94
+ cancel: () => any;
95
+ confirm: (value: File) => any;
96
+ imgLoad: (value: File) => any;
97
+ reUpload: (index: number) => any;
98
+ }, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
99
+ cropperInsRef: any;
100
+ }, any, import('vue').ComponentProvideOptions, {
101
+ P: {};
102
+ B: {};
103
+ D: {};
104
+ C: {};
105
+ M: {};
106
+ Defaults: {};
107
+ }, Readonly<{
108
+ file: File;
109
+ index: number;
110
+ options: ImageUploadCropOptions;
111
+ }> & Readonly<{
112
+ onCancel?: (() => any) | undefined;
113
+ onConfirm?: ((value: File) => any) | undefined;
114
+ onImgLoad?: ((value: File) => any) | undefined;
115
+ onReUpload?: ((index: number) => any) | undefined;
116
+ }>, {
117
+ cropperInsRef: import('vue').Ref<any, any>;
118
+ }, {}, {}, {}, {}> | null;
119
+ };
120
+ rootEl: HTMLDivElement;
121
+ };
122
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
123
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps, {
73
124
  uploadInsRef: import('vue').Ref<import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
74
125
  fileList?: unknown;
75
126
  defaultFileList?: unknown;
@@ -600,4 +651,10 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {
600
651
  cropperInsRef: import('vue').Ref<any, any>;
601
652
  }, {}, {}, {}, {}> | null;
602
653
  }, HTMLDivElement>;
654
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
603
655
  export default _default;
656
+ type __VLS_WithTemplateSlots<T, S> = T & {
657
+ new (): {
658
+ $slots: S;
659
+ };
660
+ };
@@ -1,20 +1,20 @@
1
- import { defineComponent as se, mergeModels as G, useModel as ce, ref as m, computed as M, watch as J, resolveComponent as fe, createElementBlock as ve, openBlock as K, createVNode as me, createBlock as ge, createCommentVNode as pe, normalizeClass as he } from "vue";
1
+ import { defineComponent as fe, mergeModels as G, useModel as ve, ref as m, computed as M, watch as J, resolveComponent as me, createElementBlock as ge, openBlock as K, createVNode as pe, createBlock as he, createCommentVNode as Ie, normalizeClass as xe, withCtx as X, renderSlot as Y } 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 Ie from "./cropper.vue.js";
7
- import { defaultImageUploadCheckOptions as xe, defaultImageUploadCompressorOptions as Ue, defaultImageUploadCropOptions as Ce, oneTravelImageCheckAndTransform as ye, oneTravelImageCompressor as Be } from "@keyblade/one-travel";
8
- const Ee = "keyblade-pro-image-upload";
9
- var X, Y, Z;
10
- const Fe = /* @__PURE__ */ se({
6
+ import Ue from "./cropper.vue.js";
7
+ import { defaultImageUploadCheckOptions as Ce, defaultImageUploadCompressorOptions as ye, defaultImageUploadCropOptions as Be, oneTravelImageCheckAndTransform as we, oneTravelImageCompressor as Ee } from "@keyblade/one-travel";
8
+ const Me = "keyblade-pro-image-upload";
9
+ var Z, A, R;
10
+ const je = /* @__PURE__ */ fe({
11
11
  __name: "image-upload",
12
12
  props: /* @__PURE__ */ G({
13
13
  action: {},
14
14
  handlerResponse: {},
15
15
  headers: {},
16
16
  data: {},
17
- name: { default: (X = U) == null ? void 0 : X.name },
17
+ name: { default: (Z = U) == null ? void 0 : Z.name },
18
18
  tip: {},
19
19
  accept: { default: () => {
20
20
  var C;
@@ -23,8 +23,8 @@ const Fe = /* @__PURE__ */ se({
23
23
  multiple: { type: Boolean, default: U.multiple },
24
24
  singleLimit: { default: U.singleLimit },
25
25
  limit: {},
26
- disabled: { type: Boolean, default: (Y = U) == null ? void 0 : Y.disabled },
27
- hideInnerBeforeUploadLoading: { type: Boolean, default: (Z = U) == null ? void 0 : Z.hideInnerBeforeUploadLoading },
26
+ disabled: { type: Boolean, default: (A = U) == null ? void 0 : A.disabled },
27
+ hideInnerBeforeUploadLoading: { type: Boolean, default: (R = U) == null ? void 0 : R.hideInnerBeforeUploadLoading },
28
28
  checkOptions: {},
29
29
  compressorOptions: {},
30
30
  cropOptions: {},
@@ -39,75 +39,75 @@ const Fe = /* @__PURE__ */ se({
39
39
  modelModifiers: {}
40
40
  }),
41
41
  emits: /* @__PURE__ */ G(["cropperImgLoad"], ["update:modelValue"]),
42
- setup(C, { expose: A, emit: R }) {
43
- const i = ce(C, "modelValue"), e = C, _ = R, S = m(), O = m(), p = m(), h = m(
42
+ setup(C, { expose: _, emit: ee }) {
43
+ const r = ve(C, "modelValue"), e = C, ae = ee, b = m(), O = m(), p = m(), h = m(
44
44
  []
45
- ), n = m(), c = m(), s = m(), ee = M(() => e.accept.map((a) => `.${a}`).join(",")), f = M(() => L([e.checkOptions, xe]) || {}), y = M(() => L([e.compressorOptions, Ue]) || {}), B = M(() => L([e.cropOptions, Ce]) || {}), ae = (a) => {
46
- var t, r, d, u;
47
- const l = (u = (d = (r = (t = S.value) == null ? void 0 : t.$el) == null ? void 0 : r.querySelector) == null ? void 0 : d.call(r, "input")) == null ? void 0 : u.files;
45
+ ), n = m(), c = m(), s = m(), le = M(() => e.accept.map((a) => `.${a}`).join(",")), f = M(() => L([e.checkOptions, Ce]) || {}), y = M(() => L([e.compressorOptions, ye]) || {}), B = M(() => L([e.cropOptions, Be]) || {}), oe = (a) => {
46
+ var t, i, d, u;
47
+ const l = (u = (d = (i = (t = b.value) == null ? void 0 : t.$el) == null ? void 0 : i.querySelector) == null ? void 0 : d.call(i, "input")) == null ? void 0 : u.files;
48
48
  return l && l.length > 0 && (s.value = {
49
49
  selectCount: l.length
50
- }), 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, w) => {
50
+ }), 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 (w, E) => {
51
51
  try {
52
- E(await ie(a));
52
+ w(await ue(a));
53
53
  } catch {
54
- w();
54
+ E();
55
55
  } finally {
56
56
  $();
57
57
  }
58
58
  });
59
- }, le = async (a) => {
60
- const l = i.value.findIndex((t) => t.uid === a.uid);
61
- return i.value.splice(l, 1), i.value = [...i.value], !1;
62
- }, oe = (a, l) => {
63
- e != null && e.onExceed ? e == null || e.onExceed(a, l) : (g.error(`单次最多可选择${(e == null ? void 0 : e.limit) || 1}张图片`), i.value = a);
64
59
  }, ne = async (a) => {
60
+ const l = r.value.findIndex((t) => t.uid === a.uid);
61
+ return r.value.splice(l, 1), r.value = [...r.value], !1;
62
+ }, te = (a, l) => {
63
+ e != null && e.onExceed ? e == null || e.onExceed(a, l) : (g.error(`单次最多可选择${(e == null ? void 0 : e.limit) || 1}张图片`), r.value = a);
64
+ }, ie = async (a) => {
65
65
  if (e != null && e.onSuccess)
66
66
  e == null || e.onSuccess(a);
67
67
  else {
68
68
  if (!(e != null && e.handlerResponse))
69
69
  return;
70
- const l = await e.handlerResponse(a.response), t = i.value.findIndex((r) => r.uid === a.uid);
71
- l.success ? i.value[t] = {
72
- ...i.value[t],
70
+ const l = await e.handlerResponse(a.response), t = r.value.findIndex((i) => i.uid === a.uid);
71
+ l.success ? r.value[t] = {
72
+ ...r.value[t],
73
73
  ...l
74
- } : i.value.splice(t, 1);
74
+ } : r.value.splice(t, 1);
75
75
  }
76
- }, te = (a) => {
76
+ }, re = (a) => {
77
77
  e != null && e.onError ? e == null || e.onError(a) : setTimeout(() => {
78
- const l = i.value.findIndex((t) => t.uid === a.uid);
79
- i.value.splice(l, 1);
78
+ const l = r.value.findIndex((t) => t.uid === a.uid);
79
+ r.value.splice(l, 1);
80
80
  });
81
- }, ie = (a) => new Promise((l, t) => {
81
+ }, ue = (a) => new Promise((l, t) => {
82
82
  h.value.push({ file: a, resolve: l, reject: t }), h.value.length === 1 && !n.value && $();
83
83
  }), $ = () => {
84
84
  n.value === void 0 ? n.value = 0 : n.value + 1 >= h.value.length ? (n.value = void 0, h.value = []) : n.value += 1;
85
- }, re = () => {
85
+ }, de = () => {
86
86
  var a;
87
87
  (a = p.value) == null || a.reject();
88
- }, ue = (a) => {
88
+ }, se = (a) => {
89
89
  var l;
90
90
  (l = p.value) == null || l.resolve(a);
91
- }, de = (a) => {
92
- _("cropperImgLoad", a);
91
+ }, ce = (a) => {
92
+ ae("cropperImgLoad", a);
93
93
  };
94
94
  J(n, async () => {
95
- var E, w, b, k, F, z, j, Q, V, W, H, N, P, T, q, D;
95
+ var w, E, S, k, F, z, j, Q, V, W, H, N, P, T, q, D;
96
96
  if (n.value === void 0 || h.value.length === 0)
97
97
  return;
98
- const a = h.value[n.value], { file: l, resolve: t, reject: r } = a;
98
+ const a = h.value[n.value], { file: l, resolve: t, reject: i } = a;
99
99
  let d = l.name, u = l;
100
- if ((E = f.value) != null && E.enable) {
100
+ if ((w = f.value) != null && w.enable) {
101
101
  c.value = {
102
102
  loading: !0,
103
103
  text: `第${n.value + 1}张图片检测中,请稍等`
104
- }, (w = e == null ? void 0 : e.onInnerBeforeUploadStart) == null || w.call(
104
+ }, (E = e == null ? void 0 : e.onInnerBeforeUploadStart) == null || E.call(
105
105
  e,
106
106
  l,
107
107
  n.value,
108
108
  v.check
109
109
  );
110
- const o = await ye(l, l.name, {
110
+ const o = await we(l, l.name, {
111
111
  imageMaxSize: f.value.maxSize,
112
112
  imageAllowedType: f.value.allowedType,
113
113
  imageMinWidth: f.value.minWidth,
@@ -115,7 +115,7 @@ const Fe = /* @__PURE__ */ se({
115
115
  imageMaxWidth: f.value.maxWidth,
116
116
  imageMaxHeight: f.value.maxHeight
117
117
  });
118
- if (c.value = void 0, (b = e == null ? void 0 : e.onInnerBeforeUploadEnd) == null || b.call(
118
+ if (c.value = void 0, (S = e == null ? void 0 : e.onInnerBeforeUploadEnd) == null || S.call(
119
119
  e,
120
120
  l,
121
121
  n.value,
@@ -126,7 +126,7 @@ const Fe = /* @__PURE__ */ se({
126
126
  errorMessage: o == null ? void 0 : o.errorMessage
127
127
  }
128
128
  ), !o.success)
129
- return (k = f.value) != null && k.showErrorMessage && g.error((o == null ? void 0 : o.errorMessage) || "图片校验及转换失败"), r();
129
+ return (k = f.value) != null && k.showErrorMessage && g.error((o == null ? void 0 : o.errorMessage) || "图片校验及转换失败"), i();
130
130
  if (o != null && o.hasTransform) {
131
131
  const x = d == null ? void 0 : d.split(".");
132
132
  x.pop(), d = `${x.join(",")}.jpg`, u = new File([o.file], d, {
@@ -167,7 +167,7 @@ const Fe = /* @__PURE__ */ se({
167
167
  },
168
168
  errorMessage: "图片剪裁失败"
169
169
  }
170
- ), (W = B.value) != null && W.showErrorMessage && g.error("图片剪裁失败"), r();
170
+ ), (W = B.value) != null && W.showErrorMessage && g.error("图片剪裁失败"), i();
171
171
  } finally {
172
172
  p.value = void 0;
173
173
  }
@@ -182,7 +182,7 @@ const Fe = /* @__PURE__ */ se({
182
182
  n.value,
183
183
  v.compress
184
184
  );
185
- const o = await Be(u, {
185
+ const o = await Ee(u, {
186
186
  maxSize: y.value.maxSize,
187
187
  size: y.value.size,
188
188
  excludeAllowedTypes: (P = y.value.excludeAllowedTypes) == null ? void 0 : P.map((x) => `image/${x}`)
@@ -200,7 +200,7 @@ const Fe = /* @__PURE__ */ se({
200
200
  errorMessage: o == null ? void 0 : o.errorMessage
201
201
  }
202
202
  ), !o.success)
203
- return (q = y.value) != null && q.showErrorMessage && g.error((o == null ? void 0 : o.errorMessage) || "图片压缩失败"), r();
203
+ return (q = y.value) != null && q.showErrorMessage && g.error((o == null ? void 0 : o.errorMessage) || "图片压缩失败"), i();
204
204
  u = new File([o.file], d, {
205
205
  type: o.file.type
206
206
  });
@@ -226,50 +226,58 @@ const Fe = /* @__PURE__ */ se({
226
226
  duration: 0
227
227
  }) : (a = I == null ? void 0 : I.close) == null || a.call(I);
228
228
  }
229
- ), A({
230
- uploadInsRef: S,
229
+ ), _({
230
+ uploadInsRef: b,
231
231
  cropperInsRef: O
232
232
  }), (a, l) => {
233
- const t = fe("a-upload");
234
- return K(), ve("div", null, [
235
- me(t, {
236
- class: he([`${Ee}-upload`]),
233
+ const t = me("a-upload");
234
+ return K(), ge("div", null, [
235
+ pe(t, {
236
+ class: xe([`${Me}-upload`]),
237
237
  ref_key: "uploadInsRef",
238
- ref: S,
238
+ ref: b,
239
239
  "list-type": "picture-card",
240
240
  tip: a.tip || "上传",
241
241
  "image-preview": "",
242
- "file-list": i.value,
243
- "onUpdate:fileList": l[0] || (l[0] = (r) => i.value = r),
242
+ "file-list": r.value,
243
+ "onUpdate:fileList": l[0] || (l[0] = (i) => r.value = i),
244
244
  action: a.action,
245
245
  headers: a.headers,
246
246
  data: a.data,
247
247
  name: a.name,
248
- accept: ee.value,
248
+ accept: le.value,
249
249
  multiple: a.multiple,
250
250
  limit: a.limit,
251
251
  disabled: a.disabled,
252
- "on-before-upload": ae,
253
- "on-before-remove": le,
254
- onExceedLimit: oe,
255
- onSuccess: ne,
256
- onError: te
257
- }, null, 8, ["class", "tip", "file-list", "action", "headers", "data", "name", "accept", "multiple", "limit", "disabled"]),
258
- p.value && n.value !== void 0 ? (K(), ge(Ie, {
252
+ "on-before-upload": oe,
253
+ "on-before-remove": ne,
254
+ onExceedLimit: te,
255
+ onSuccess: ie,
256
+ onError: re
257
+ }, {
258
+ image: X(({ fileItem: i }) => [
259
+ Y(a.$slots, "image", { fileItem: i })
260
+ ]),
261
+ "upload-button": X(() => [
262
+ Y(a.$slots, "upload-button")
263
+ ]),
264
+ _: 3
265
+ }, 8, ["class", "tip", "file-list", "action", "headers", "data", "name", "accept", "multiple", "limit", "disabled"]),
266
+ p.value && n.value !== void 0 ? (K(), he(Ue, {
259
267
  key: 0,
260
268
  ref_key: "cropperInsRef",
261
269
  ref: O,
262
270
  file: p.value.file,
263
271
  index: n.value,
264
272
  options: B.value,
265
- onCancel: re,
266
- onConfirm: ue,
267
- onImgLoad: de
268
- }, null, 8, ["file", "index", "options"])) : pe("", !0)
273
+ onCancel: de,
274
+ onConfirm: se,
275
+ onImgLoad: ce
276
+ }, null, 8, ["file", "index", "options"])) : Ie("", !0)
269
277
  ]);
270
278
  };
271
279
  }
272
280
  });
273
281
  export {
274
- Fe as default
282
+ je as default
275
283
  };
@@ -1639,7 +1639,14 @@ declare const ProImageUpload: {
1639
1639
  singleLimit: number;
1640
1640
  disabled: boolean;
1641
1641
  hideInnerBeforeUploadLoading: boolean;
1642
- }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & {
1642
+ }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
1643
+ $slots: {
1644
+ image?(_: {
1645
+ fileItem: any;
1646
+ }): any;
1647
+ 'upload-button'?(_: {}): any;
1648
+ };
1649
+ }) & {
1643
1650
  install: (app: App) => void;
1644
1651
  };
1645
1652
  export * from './types';
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.12.10",
5
+ "version": "1.12.12",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",
@@ -25,6 +25,7 @@
25
25
  "@vueuse/core": "^10.7.0",
26
26
  "vue-cropper": "^1.1.4",
27
27
  "vue-global-config": "^0.6.3",
28
+ "dayjs": "^1.11.18",
28
29
  "@keyblade/one-travel": "^3.0.0"
29
30
  },
30
31
  "peerDependencies": {