bkui-vue 2.0.1-beta.37 → 2.0.1-beta.39

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.
@@ -1292,6 +1292,11 @@ var EThemes;
1292
1292
  EThemes["DRAGGABLE"] = "draggable";
1293
1293
  EThemes["PICTURE"] = "picture";
1294
1294
  })(EThemes || (EThemes = {}));
1295
+ var ETypes;
1296
+ (function (ETypes) {
1297
+ ETypes["FORMDATA"] = "formdata";
1298
+ ETypes["BINARY"] = "binary";
1299
+ })(ETypes || (ETypes = {}));
1295
1300
  var EUploadStatus;
1296
1301
  (function (EUploadStatus) {
1297
1302
  EUploadStatus["FAIL"] = "fail";
@@ -1299,6 +1304,7 @@ var EUploadStatus;
1299
1304
  EUploadStatus["SUCCESS"] = "success";
1300
1305
  EUploadStatus["UPLOADING"] = "uploading";
1301
1306
  })(EUploadStatus || (EUploadStatus = {}));
1307
+ ;
1302
1308
  ;// CONCATENATED MODULE: ../../packages/upload/src/props.ts
1303
1309
  /*
1304
1310
  * Tencent is pleased to support the open source community by making
@@ -1327,7 +1333,19 @@ var EUploadStatus;
1327
1333
  */
1328
1334
 
1329
1335
  var themes = [EThemes.BUTTON, EThemes.DRAGGABLE, EThemes.PICTURE];
1336
+ var types = [ETypes.FORMDATA, ETypes.BINARY];
1330
1337
  /* harmony default export */ const props = ({
1338
+ type: {
1339
+ type: String,
1340
+ "default": 'formdata',
1341
+ validator: function validator(val) {
1342
+ if (!val || types.includes(val)) {
1343
+ return true;
1344
+ }
1345
+ console.error("invalid type, ".concat(val, ", the type must be one of \u3010").concat(types.join(' | '), "\u3011"));
1346
+ return false;
1347
+ }
1348
+ },
1331
1349
  theme: {
1332
1350
  type: String,
1333
1351
  "default": 'draggable',
@@ -2052,7 +2070,9 @@ var ajaxUpload = function ajaxUpload(option) {
2052
2070
  throw new Error('XMLHttpRequest is undefined');
2053
2071
  }
2054
2072
  var xhr = new XMLHttpRequest();
2055
- var action = option.action;
2073
+ var action = option.action,
2074
+ type = option.type;
2075
+ var isFormdata = type === 'formdata';
2056
2076
  if (xhr.upload) {
2057
2077
  xhr.upload.addEventListener('progress', function (event) {
2058
2078
  var progressEvent = event;
@@ -2061,7 +2081,7 @@ var ajaxUpload = function ajaxUpload(option) {
2061
2081
  });
2062
2082
  }
2063
2083
  var formData = new FormData();
2064
- if (option.data) {
2084
+ if (isFormdata && option.data) {
2065
2085
  var appendData = option.data;
2066
2086
  if (!Array.isArray(appendData)) {
2067
2087
  appendData = [appendData];
@@ -2075,7 +2095,7 @@ var ajaxUpload = function ajaxUpload(option) {
2075
2095
  }
2076
2096
  });
2077
2097
  }
2078
- if (option.formDataAttributes) {
2098
+ if (isFormdata && option.formDataAttributes) {
2079
2099
  var _appendData = option.formDataAttributes;
2080
2100
  if (!Array.isArray(_appendData)) {
2081
2101
  _appendData = [_appendData];
@@ -2084,7 +2104,9 @@ var ajaxUpload = function ajaxUpload(option) {
2084
2104
  if (Array.isArray(item.value)) formData.append.apply(formData, [item.name].concat(_toConsumableArray(item.value)));else formData.append(item.name, item.value);
2085
2105
  });
2086
2106
  }
2087
- formData.append(option.filename, option.file, option.file.name);
2107
+ if (isFormdata) {
2108
+ formData.append(option.filename, option.file, option.file.name);
2109
+ }
2088
2110
  xhr.addEventListener('error', function () {
2089
2111
  option.onError(new Error('An error occurred during upload'));
2090
2112
  });
@@ -2128,7 +2150,7 @@ var ajaxUpload = function ajaxUpload(option) {
2128
2150
  xhr.setRequestHeader(key, String(value));
2129
2151
  }
2130
2152
  }
2131
- xhr.send(formData);
2153
+ xhr.send(isFormdata ? formData : option.file);
2132
2154
  return xhr;
2133
2155
  };
2134
2156
  // 该方法用于在不同的浏览器使用不同的方式
@@ -2733,7 +2755,8 @@ function upload_arrayLikeToArray(arr, len) { if (len == null || len > arr.length
2733
2755
  return _upload.apply(this, arguments);
2734
2756
  }
2735
2757
  function send(file, sendFiles) {
2736
- var headers = props.headers,
2758
+ var type = props.type,
2759
+ headers = props.headers,
2737
2760
  header = props.header,
2738
2761
  data = props.data,
2739
2762
  formDataAttributes = props.formDataAttributes,
@@ -2747,6 +2770,7 @@ function upload_arrayLikeToArray(arr, len) { if (len == null || len > arr.length
2747
2770
  customRequest = props.customRequest;
2748
2771
  var uid = file.uid;
2749
2772
  var options = {
2773
+ type: type,
2750
2774
  headers: headers,
2751
2775
  header: header,
2752
2776
  withCredentials: withCredentials,
@@ -1,6 +1,11 @@
1
- import { APIResponse, EThemes, ExtraFormData, FormDataAttr, HeaderDataAttr, MaxSize, UploadFile, UploadRawFile, UploadRequestHandler } from './upload.type';
1
+ import { APIResponse, EThemes, ETypes, ExtraFormData, FormDataAttr, HeaderDataAttr, MaxSize, UploadFile, UploadRawFile, UploadRequestHandler } from './upload.type';
2
2
  import type { PropType } from 'vue';
3
3
  declare const _default: {
4
+ type: {
5
+ type: PropType<"formdata" | "binary">;
6
+ default: "formdata" | "binary";
7
+ validator: (val: ETypes) => boolean;
8
+ };
4
9
  theme: {
5
10
  type: PropType<"button" | "picture" | "draggable">;
6
11
  default: "button" | "picture" | "draggable";
@@ -1,5 +1,10 @@
1
1
  import { APIResponse, EThemes, UploadFile, UploadRawFile } from './upload.type';
2
2
  declare const _default: import("vue").DefineComponent<{
3
+ type: {
4
+ type: import("vue").PropType<"formdata" | "binary">;
5
+ default: "formdata" | "binary";
6
+ validator: (val: import("./upload.type").ETypes) => boolean;
7
+ };
3
8
  theme: {
4
9
  type: import("vue").PropType<"button" | "picture" | "draggable">;
5
10
  default: "button" | "picture" | "draggable";
@@ -110,6 +115,11 @@ declare const _default: import("vue").DefineComponent<{
110
115
  default: number;
111
116
  };
112
117
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("done" | "error" | "progress" | "delete" | "success" | "exceed")[], "done" | "error" | "progress" | "delete" | "success" | "exceed", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
118
+ type: {
119
+ type: import("vue").PropType<"formdata" | "binary">;
120
+ default: "formdata" | "binary";
121
+ validator: (val: import("./upload.type").ETypes) => boolean;
122
+ };
113
123
  theme: {
114
124
  type: import("vue").PropType<"button" | "picture" | "draggable">;
115
125
  default: "button" | "picture" | "draggable";
@@ -228,6 +238,7 @@ declare const _default: import("vue").DefineComponent<{
228
238
  onExceed?: (...args: any[]) => any;
229
239
  }, {
230
240
  name: string;
241
+ type: "formdata" | "binary";
231
242
  data: import("./upload.type").ExtraFormData | import("./upload.type").ExtraFormData[];
232
243
  header: import("./upload.type").HeaderDataAttr | import("./upload.type").HeaderDataAttr[];
233
244
  extCls: string;
@@ -7,6 +7,11 @@ export declare const enum EThemes {
7
7
  PICTURE = "picture"
8
8
  }
9
9
  export type Theme = Lowercase<keyof typeof EThemes>;
10
+ export declare const enum ETypes {
11
+ FORMDATA = "formdata",
12
+ BINARY = "binary"
13
+ }
14
+ export type Type = Lowercase<keyof typeof ETypes>;
10
15
  export declare const enum EUploadStatus {
11
16
  FAIL = "fail",
12
17
  NEW = "new",
@@ -56,11 +61,12 @@ export type UploadProps = ExtractPropTypes<typeof uploadProps>;
56
61
  export interface UploadRequestOptions {
57
62
  action: string;
58
63
  method: string;
64
+ type: Type;
59
65
  data?: ExtraFormData | ExtraFormData[];
60
66
  formDataAttributes?: FormDataAttr | FormDataAttr[];
61
67
  filename: string;
62
68
  file: File;
63
- headers?: Headers | Record<string, null | number | string | undefined>;
69
+ headers?: Headers | Record<string, string | number | null | undefined>;
64
70
  header?: HeaderDataAttr | HeaderDataAttr[];
65
71
  withCredentials: boolean;
66
72
  sliceUrl: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkui-vue",
3
- "version": "2.0.1-beta.37",
3
+ "version": "2.0.1-beta.39",
4
4
  "workspaces": [
5
5
  "packages/**",
6
6
  "scripts/cli",