pro-design-vue 1.2.20 → 1.2.22

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 (63) hide show
  1. package/dist/index.css +1 -1
  2. package/dist/index.full.js +214 -52
  3. package/dist/index.full.min.js +6 -6
  4. package/dist/index.full.min.js.map +1 -1
  5. package/dist/index.full.min.mjs +8 -8
  6. package/dist/index.full.min.mjs.map +1 -1
  7. package/dist/index.full.mjs +215 -53
  8. package/es/components/form/src/components/FormGroup.d.ts +1 -0
  9. package/es/components/form/src/components/FormList.d.ts +1 -0
  10. package/es/components/form/src/components/FormListContainer.d.ts +1 -0
  11. package/es/components/form/src/components/FormListItem.d.ts +1 -0
  12. package/es/components/form/src/components/FormSet.d.ts +1 -0
  13. package/es/components/form/src/components/FormTitle.d.ts +10 -0
  14. package/es/components/form/src/fields/FieldUploadButton.d.ts +27 -4
  15. package/es/components/form/src/fields/FieldUploadDragger.d.ts +43 -19
  16. package/es/components/form/src/type.d.ts +1 -0
  17. package/es/index.d.ts +1 -0
  18. package/es/packages/components/drawer/src/drawer.vue2.mjs +12 -2
  19. package/es/packages/components/drawer/src/drawer.vue2.mjs.map +1 -1
  20. package/es/packages/components/form/src/components/FormItem.mjs +2 -1
  21. package/es/packages/components/form/src/components/FormItem.mjs.map +1 -1
  22. package/es/packages/components/form/src/components/FormTitle.mjs +8 -2
  23. package/es/packages/components/form/src/components/FormTitle.mjs.map +1 -1
  24. package/es/packages/components/form/src/fields/FieldUploadButton.mjs +104 -26
  25. package/es/packages/components/form/src/fields/FieldUploadButton.mjs.map +1 -1
  26. package/es/packages/components/form/src/fields/FieldUploadDragger.mjs +88 -25
  27. package/es/packages/components/form/src/fields/FieldUploadDragger.mjs.map +1 -1
  28. package/es/packages/components/form/src/utils/fieldPropsMap.mjs +4 -0
  29. package/es/packages/components/form/src/utils/fieldPropsMap.mjs.map +1 -1
  30. package/es/version.d.ts +1 -1
  31. package/es/version.mjs +1 -1
  32. package/es/version.mjs.map +1 -1
  33. package/lib/components/form/src/components/FormGroup.d.ts +1 -0
  34. package/lib/components/form/src/components/FormList.d.ts +1 -0
  35. package/lib/components/form/src/components/FormListContainer.d.ts +1 -0
  36. package/lib/components/form/src/components/FormListItem.d.ts +1 -0
  37. package/lib/components/form/src/components/FormSet.d.ts +1 -0
  38. package/lib/components/form/src/components/FormTitle.d.ts +10 -0
  39. package/lib/components/form/src/fields/FieldUploadButton.d.ts +27 -4
  40. package/lib/components/form/src/fields/FieldUploadDragger.d.ts +43 -19
  41. package/lib/components/form/src/type.d.ts +1 -0
  42. package/lib/index.d.ts +1 -0
  43. package/lib/packages/components/drawer/src/drawer.vue2.js +11 -1
  44. package/lib/packages/components/drawer/src/drawer.vue2.js.map +1 -1
  45. package/lib/packages/components/form/src/components/FormItem.js +2 -1
  46. package/lib/packages/components/form/src/components/FormItem.js.map +1 -1
  47. package/lib/packages/components/form/src/components/FormTitle.js +8 -2
  48. package/lib/packages/components/form/src/components/FormTitle.js.map +1 -1
  49. package/lib/packages/components/form/src/fields/FieldUploadButton.js +102 -24
  50. package/lib/packages/components/form/src/fields/FieldUploadButton.js.map +1 -1
  51. package/lib/packages/components/form/src/fields/FieldUploadDragger.js +86 -23
  52. package/lib/packages/components/form/src/fields/FieldUploadDragger.js.map +1 -1
  53. package/lib/packages/components/form/src/utils/fieldPropsMap.js +4 -0
  54. package/lib/packages/components/form/src/utils/fieldPropsMap.js.map +1 -1
  55. package/lib/version.d.ts +1 -1
  56. package/lib/version.js +1 -1
  57. package/lib/version.js.map +1 -1
  58. package/package.json +1 -1
  59. package/theme-chalk/index.css +1 -1
  60. package/theme-chalk/pro-drawer.css +1 -1
  61. package/theme-chalk/pro-form.css +1 -1
  62. package/theme-chalk/src/drawer.less +4 -0
  63. package/theme-chalk/src/form.less +12 -0
@@ -1,4 +1,4 @@
1
- /*! Pro Design Vue v1.2.20 */
1
+ /*! Pro Design Vue v1.2.22 */
2
2
 
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('ant-design-vue'), require('vue'), require('ant-design-vue/es/locale/zh_CN.js')) :
@@ -32,7 +32,7 @@
32
32
  const DEFAULT_NAMESPACE = "pro";
33
33
  const DEFAULT_LOCALE = "zh-CN";
34
34
 
35
- const version$1 = "1.2.20";
35
+ const version$1 = "1.2.22";
36
36
 
37
37
  const makeInstaller = (components = []) => {
38
38
  const install = (app) => {
@@ -13444,7 +13444,17 @@
13444
13444
  onClose: handleClose
13445
13445
  }), vue.createSlots({
13446
13446
  default: vue.withCtx(() => [
13447
- vue.renderSlot(_ctx.$slots, "default")
13447
+ vue.createElementVNode(
13448
+ "div",
13449
+ {
13450
+ class: vue.normalizeClass(`${vue.unref(prefixCls)}-body`)
13451
+ },
13452
+ [
13453
+ vue.renderSlot(_ctx.$slots, "default")
13454
+ ],
13455
+ 2
13456
+ /* CLASS */
13457
+ )
13448
13458
  ]),
13449
13459
  _: 2
13450
13460
  /* DYNAMIC */
@@ -16126,7 +16136,7 @@
16126
16136
  type: String,
16127
16137
  default: "file"
16128
16138
  },
16129
- max: {
16139
+ maxCount: {
16130
16140
  type: Number,
16131
16141
  default: void 0
16132
16142
  },
@@ -16144,25 +16154,31 @@
16144
16154
  },
16145
16155
  listType: {
16146
16156
  type: String,
16147
- default: "picture"
16148
- }
16157
+ default: "picture-card"
16158
+ },
16159
+ listIgnore: {
16160
+ type: Boolean,
16161
+ default: true
16162
+ },
16163
+ showUploadList: {
16164
+ type: [Boolean, Object],
16165
+ default: true
16166
+ },
16167
+ customRequest: Function,
16168
+ beforeUpload: Function
16149
16169
  },
16150
16170
  setup(props, {
16151
16171
  attrs
16152
16172
  }) {
16153
16173
  const intl = useIntl();
16154
16174
  const {
16175
+ prefixCls,
16155
16176
  formData
16156
16177
  } = useInjectForm();
16157
16178
  const formSlotsContext = useInjectSlots$1();
16158
- const value = vue.computed(() => {
16159
- var _a;
16160
- return (_a = props.fileList) != null ? _a : props.value;
16161
- });
16162
- const showUploadButton = vue.computed(() => {
16163
- var _a;
16164
- return props.max === void 0 || !value.value || ((_a = value.value) == null ? void 0 : _a.length) < props.max;
16165
- });
16179
+ const fileList = vue.ref([]);
16180
+ const formItemContext = antDesignVue.Form.useInjectFormItemContext();
16181
+ const baseClassName = vue.computed(() => `${prefixCls}-upload`);
16166
16182
  const isPictureCard = vue.computed(() => props.listType === "picture-card");
16167
16183
  const slotsGetter = vue.computed(() => {
16168
16184
  const temp = {};
@@ -16203,22 +16219,94 @@
16203
16219
  }
16204
16220
  return props.title || intl.getMessage("upload.button", "\u5355\u51FB\u4E0A\u4F20");
16205
16221
  });
16206
- const onChange = (info) => {
16222
+ const beforeUpload = async (file, fileList2) => {
16207
16223
  var _a;
16208
- (_a = props.onChange) == null ? void 0 : _a.call(props, info.fileList, info);
16224
+ const result = await ((_a = props.beforeUpload) == null ? void 0 : _a.call(props, file, fileList2));
16225
+ if (!result && props.listIgnore) {
16226
+ return antDesignVue.Upload.LIST_IGNORE;
16227
+ }
16228
+ return result;
16209
16229
  };
16210
- return () => vue.createVNode(antDesignVue.Upload, vue.mergeProps({
16211
- "fileList": value.value
16212
- }, attrs, {
16213
- "listType": props.listType,
16230
+ const customRequest = async (option) => {
16231
+ var _a, _b, _c;
16232
+ const formData2 = new FormData();
16233
+ formData2.append(props.name, option.file);
16234
+ const onUploadProgress = (e) => {
16235
+ var _a2;
16236
+ if (e.total > 0) {
16237
+ e.percent = e.loaded / e.total * 100;
16238
+ }
16239
+ (_a2 = option == null ? void 0 : option.onProgress) == null ? void 0 : _a2.call(option, e);
16240
+ };
16241
+ const {
16242
+ success,
16243
+ error,
16244
+ data
16245
+ } = (_a = await props.customRequest(formData2, onUploadProgress)) != null ? _a : {};
16246
+ if (success) {
16247
+ (_b = option.onSuccess) == null ? void 0 : _b.call(option, data);
16248
+ formItemContext.onFieldChange();
16249
+ } else {
16250
+ (_c = option.onError) == null ? void 0 : _c.call(option, error, data);
16251
+ }
16252
+ };
16253
+ const uploadProps = vue.computed(() => {
16254
+ const newProps = {
16255
+ ...attrs
16256
+ };
16257
+ if (props.customRequest) {
16258
+ newProps.customRequest = customRequest;
16259
+ }
16260
+ if (props.beforeUpload) {
16261
+ newProps.beforeUpload = beforeUpload;
16262
+ }
16263
+ return newProps;
16264
+ });
16265
+ vue.watch(() => props.value, (newValue) => {
16266
+ var _a;
16267
+ fileList.value = [...newValue == null ? void 0 : newValue.map((item) => ({
16268
+ ...item,
16269
+ name: item.name || item.url
16270
+ }))];
16271
+ if (!((_a = fileList.value) == null ? void 0 : _a.length)) {
16272
+ formItemContext.onFieldChange();
16273
+ }
16274
+ });
16275
+ const onUploadChange = (info) => {
16276
+ var _a;
16277
+ (_a = props.onChange) == null ? void 0 : _a.call(props, info.fileList.map((item) => {
16278
+ var _a2, _b, _c;
16279
+ return {
16280
+ ...item,
16281
+ name: item.name || ((_a2 = item.response) == null ? void 0 : _a2.name) || item.url || ((_b = item.response) == null ? void 0 : _b.url),
16282
+ url: ((_c = item.response) == null ? void 0 : _c.url) || item.url
16283
+ };
16284
+ }), info.file);
16285
+ };
16286
+ return () => vue.createVNode(antDesignVue.Upload, vue.mergeProps(uploadProps.value, {
16287
+ "class": {
16288
+ [`${baseClassName.value}-readonly`]: props.readonly
16289
+ },
16290
+ "fileList": fileList.value,
16291
+ "onUpdate:fileList": ($event) => fileList.value = $event,
16214
16292
  "name": props.name,
16215
- "onChange": onChange
16293
+ "maxCount": props.maxCount,
16294
+ "listType": props.listType,
16295
+ "showUploadList": props.readonly || props.showUploadList,
16296
+ "disabled": props.readonly || props.disabled,
16297
+ "style": attrs == null ? void 0 : attrs.style,
16298
+ "onChange": onUploadChange
16216
16299
  }), {
16217
- default: () => [showUploadButton.value && (isPictureCard.value ? vue.createVNode("span", null, [icon.value, title.value]) : vue.createVNode(antDesignVue.Button, vue.mergeProps({
16218
- "disabled": props.disabled
16219
- }, props.buttonProps), {
16220
- default: () => [icon.value, title.value]
16221
- }))],
16300
+ default: () => {
16301
+ var _a;
16302
+ return [isPictureCard.value ? props.maxCount !== void 0 && ((_a = fileList.value) == null ? void 0 : _a.length) < props.maxCount && vue.createVNode("div", null, [icon.value, vue.createVNode("div", {
16303
+ "style": "margin-top: 8px"
16304
+ }, [vue.createTextVNode(" "), title.value])]) : vue.createVNode(antDesignVue.Button, vue.mergeProps({
16305
+ "disabled": props.disabled
16306
+ }, props.buttonProps), {
16307
+ default: () => [icon.value, title.value]
16308
+ })];
16309
+ },
16222
16310
  ...slotsGetter.value
16223
16311
  });
16224
16312
  }
@@ -16274,29 +16362,30 @@
16274
16362
  fileList: {
16275
16363
  type: Array,
16276
16364
  default: void 0
16277
- }
16365
+ },
16366
+ listIgnore: {
16367
+ type: Boolean,
16368
+ default: true
16369
+ },
16370
+ showUploadList: {
16371
+ type: [Boolean, Object],
16372
+ default: true
16373
+ },
16374
+ customRequest: Function,
16375
+ beforeUpload: Function
16278
16376
  },
16279
16377
  setup(props, {
16280
16378
  attrs
16281
16379
  }) {
16282
- const {
16283
- token
16284
- } = antDesignVue.theme.useToken();
16285
16380
  const {
16286
16381
  prefixCls,
16287
16382
  formData
16288
16383
  } = useInjectForm();
16289
16384
  const intl = useIntl();
16290
16385
  const formSlotsContext = useInjectSlots$1();
16291
- const value = vue.computed(() => {
16292
- var _a;
16293
- return (_a = props.fileList) != null ? _a : props.value;
16294
- });
16386
+ const fileList = vue.ref([]);
16387
+ const formItemContext = antDesignVue.Form.useInjectFormItemContext();
16295
16388
  const baseClassName = vue.computed(() => `${prefixCls}-upload`);
16296
- const showUploadButton = vue.computed(() => {
16297
- var _a;
16298
- return props.max === void 0 || !value.value || ((_a = value.value) == null ? void 0 : _a.length) < props.max;
16299
- });
16300
16389
  const slotsGetter = vue.computed(() => {
16301
16390
  const temp = {};
16302
16391
  SLOT_NAMES$1.forEach((name) => {
@@ -16345,24 +16434,86 @@
16345
16434
  }
16346
16435
  return props.description || intl.getMessage("upload.dragger.hint", "\u652F\u6301\u5355\u6B21\u6216\u6279\u91CF\u4E0A\u4F20");
16347
16436
  });
16348
- const onChange = (info) => {
16437
+ const beforeUpload = async (file, fileList2) => {
16349
16438
  var _a;
16350
- (_a = props.onChange) == null ? void 0 : _a.call(props, info.fileList, info);
16439
+ const result = await ((_a = props.beforeUpload) == null ? void 0 : _a.call(props, file, fileList2));
16440
+ if (!result && props.listIgnore) {
16441
+ return antDesignVue.Upload.LIST_IGNORE;
16442
+ }
16443
+ return result;
16351
16444
  };
16352
- return () => vue.createVNode(antDesignVue.Upload.Dragger, vue.mergeProps({
16353
- "fileList": value.value
16354
- }, attrs, {
16355
- "name": props.name,
16356
- "style": {
16357
- ...attrs == null ? void 0 : attrs.style,
16358
- display: !showUploadButton.value ? "none" : void 0
16445
+ const customRequest = async (option) => {
16446
+ var _a, _b, _c;
16447
+ const formData2 = new FormData();
16448
+ formData2.append(props.name, option.file);
16449
+ const onUploadProgress = (e) => {
16450
+ var _a2;
16451
+ if (e.total > 0) {
16452
+ e.percent = e.loaded / e.total * 100;
16453
+ }
16454
+ (_a2 = option == null ? void 0 : option.onProgress) == null ? void 0 : _a2.call(option, e);
16455
+ };
16456
+ const {
16457
+ success,
16458
+ error,
16459
+ data
16460
+ } = (_a = await props.customRequest(formData2, onUploadProgress)) != null ? _a : {};
16461
+ if (success) {
16462
+ (_b = option.onSuccess) == null ? void 0 : _b.call(option, data);
16463
+ formItemContext.onFieldChange();
16464
+ } else {
16465
+ (_c = option.onError) == null ? void 0 : _c.call(option, error, data);
16466
+ }
16467
+ };
16468
+ const uploadProps = vue.computed(() => {
16469
+ const newProps = {
16470
+ ...attrs
16471
+ };
16472
+ if (props.customRequest) {
16473
+ newProps.customRequest = customRequest;
16474
+ }
16475
+ if (props.beforeUpload) {
16476
+ newProps.beforeUpload = beforeUpload;
16477
+ }
16478
+ return newProps;
16479
+ });
16480
+ vue.watch(() => props.value, (newValue) => {
16481
+ var _a;
16482
+ fileList.value = [...newValue == null ? void 0 : newValue.map((item) => ({
16483
+ ...item,
16484
+ name: item.name || item.url
16485
+ }))];
16486
+ if (!((_a = fileList.value) == null ? void 0 : _a.length)) {
16487
+ formItemContext.onFieldChange();
16488
+ }
16489
+ });
16490
+ const onUploadChange = (info) => {
16491
+ var _a;
16492
+ (_a = props.onChange) == null ? void 0 : _a.call(props, info.fileList.map((item) => {
16493
+ var _a2, _b, _c;
16494
+ return {
16495
+ ...item,
16496
+ name: item.name || ((_a2 = item.response) == null ? void 0 : _a2.name) || item.url || ((_b = item.response) == null ? void 0 : _b.url),
16497
+ url: ((_c = item.response) == null ? void 0 : _c.url) || item.url
16498
+ };
16499
+ }), info.file);
16500
+ };
16501
+ return () => vue.createVNode(antDesignVue.Upload.Dragger, vue.mergeProps(uploadProps.value, {
16502
+ "class": {
16503
+ [`${baseClassName.value}-readonly`]: props.readonly
16359
16504
  },
16360
- "onChange": onChange
16505
+ "fileList": fileList.value,
16506
+ "onUpdate:fileList": ($event) => fileList.value = $event,
16507
+ "name": props.name,
16508
+ "showUploadList": props.readonly || props.showUploadList,
16509
+ "disabled": props.readonly || props.disabled,
16510
+ "style": attrs == null ? void 0 : attrs.style,
16511
+ "onChange": onUploadChange
16361
16512
  }), {
16362
16513
  default: () => [vue.createVNode("p", {
16363
16514
  "class": `${baseClassName.value}-drag-icon`,
16364
16515
  "style": {
16365
- color: token.value.colorPrimary
16516
+ color: "hsl(var(--pro-primary))"
16366
16517
  }
16367
16518
  }, [icon.value]), vue.createVNode("p", {
16368
16519
  "class": `${baseClassName.value}-text`
@@ -36787,6 +36938,10 @@
36787
36938
  tooltip: {
36788
36939
  type: [String, Boolean],
36789
36940
  default: ""
36941
+ },
36942
+ readonly: {
36943
+ type: Boolean,
36944
+ default: false
36790
36945
  }
36791
36946
  },
36792
36947
  setup(props) {
@@ -36801,7 +36956,8 @@
36801
36956
  }, [vue.createVNode(RenderVNode$1, {
36802
36957
  "vnode": title.value,
36803
36958
  "props": {
36804
- formData: formData.value
36959
+ formData: formData.value,
36960
+ readonly: props.readonly
36805
36961
  }
36806
36962
  }, null)]), props.tooltip && vue.createVNode(antDesignVue.Tooltip, null, {
36807
36963
  default: () => [vue.createVNode(QuestionCircleOutlined, {
@@ -36811,7 +36967,8 @@
36811
36967
  title: () => props.tooltip === true ? vue.createVNode(RenderVNode$1, {
36812
36968
  "vnode": title.value,
36813
36969
  "props": {
36814
- formData: formData.value
36970
+ formData: formData.value,
36971
+ readonly: props.readonly
36815
36972
  }
36816
36973
  }, null) : props.tooltip
36817
36974
  })]);
@@ -38403,6 +38560,7 @@
38403
38560
  "data",
38404
38561
  "directory",
38405
38562
  "disabled",
38563
+ "listIgnore",
38406
38564
  "downloadIcon",
38407
38565
  "fileList",
38408
38566
  "headers",
@@ -38436,6 +38594,7 @@
38436
38594
  "id",
38437
38595
  "accept",
38438
38596
  "action",
38597
+ "listIgnore",
38439
38598
  "beforeUpload",
38440
38599
  "customRequest",
38441
38600
  "data",
@@ -38477,6 +38636,7 @@
38477
38636
  "accept",
38478
38637
  "action",
38479
38638
  "beforeUpload",
38639
+ "listIgnore",
38480
38640
  "name",
38481
38641
  "headers",
38482
38642
  "isCropper",
@@ -38503,6 +38663,7 @@
38503
38663
  "multiple",
38504
38664
  "maxCount",
38505
38665
  "beforeUpload",
38666
+ "listIgnore",
38506
38667
  "name",
38507
38668
  "previewFile",
38508
38669
  "allowClear",
@@ -38724,7 +38885,8 @@
38724
38885
  "style": formItemProps.value.titleStyles
38725
38886
  }, [vue.createVNode(FormTitle, {
38726
38887
  "title": props.item.title,
38727
- "tooltip": props.item.tooltip
38888
+ "tooltip": props.item.tooltip,
38889
+ "readonly": mergeReadonly.value
38728
38890
  }, null)]), vue.createVNode("div", {
38729
38891
  "class": `${prefixCls}-item-title-extra`
38730
38892
  }, [vue.createVNode(RenderVNode$1, {