pro-design-vue 1.2.20 → 1.2.21

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 (57) hide show
  1. package/dist/index.css +1 -1
  2. package/dist/index.full.js +203 -51
  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 +204 -52
  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/form/src/components/FormItem.mjs +2 -1
  19. package/es/packages/components/form/src/components/FormItem.mjs.map +1 -1
  20. package/es/packages/components/form/src/components/FormTitle.mjs +8 -2
  21. package/es/packages/components/form/src/components/FormTitle.mjs.map +1 -1
  22. package/es/packages/components/form/src/fields/FieldUploadButton.mjs +104 -26
  23. package/es/packages/components/form/src/fields/FieldUploadButton.mjs.map +1 -1
  24. package/es/packages/components/form/src/fields/FieldUploadDragger.mjs +88 -25
  25. package/es/packages/components/form/src/fields/FieldUploadDragger.mjs.map +1 -1
  26. package/es/packages/components/form/src/utils/fieldPropsMap.mjs +4 -0
  27. package/es/packages/components/form/src/utils/fieldPropsMap.mjs.map +1 -1
  28. package/es/version.d.ts +1 -1
  29. package/es/version.mjs +1 -1
  30. package/es/version.mjs.map +1 -1
  31. package/lib/components/form/src/components/FormGroup.d.ts +1 -0
  32. package/lib/components/form/src/components/FormList.d.ts +1 -0
  33. package/lib/components/form/src/components/FormListContainer.d.ts +1 -0
  34. package/lib/components/form/src/components/FormListItem.d.ts +1 -0
  35. package/lib/components/form/src/components/FormSet.d.ts +1 -0
  36. package/lib/components/form/src/components/FormTitle.d.ts +10 -0
  37. package/lib/components/form/src/fields/FieldUploadButton.d.ts +27 -4
  38. package/lib/components/form/src/fields/FieldUploadDragger.d.ts +43 -19
  39. package/lib/components/form/src/type.d.ts +1 -0
  40. package/lib/index.d.ts +1 -0
  41. package/lib/packages/components/form/src/components/FormItem.js +2 -1
  42. package/lib/packages/components/form/src/components/FormItem.js.map +1 -1
  43. package/lib/packages/components/form/src/components/FormTitle.js +8 -2
  44. package/lib/packages/components/form/src/components/FormTitle.js.map +1 -1
  45. package/lib/packages/components/form/src/fields/FieldUploadButton.js +102 -24
  46. package/lib/packages/components/form/src/fields/FieldUploadButton.js.map +1 -1
  47. package/lib/packages/components/form/src/fields/FieldUploadDragger.js +86 -23
  48. package/lib/packages/components/form/src/fields/FieldUploadDragger.js.map +1 -1
  49. package/lib/packages/components/form/src/utils/fieldPropsMap.js +4 -0
  50. package/lib/packages/components/form/src/utils/fieldPropsMap.js.map +1 -1
  51. package/lib/version.d.ts +1 -1
  52. package/lib/version.js +1 -1
  53. package/lib/version.js.map +1 -1
  54. package/package.json +1 -1
  55. package/theme-chalk/index.css +1 -1
  56. package/theme-chalk/pro-form.css +1 -1
  57. 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.21 */
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.21";
36
36
 
37
37
  const makeInstaller = (components = []) => {
38
38
  const install = (app) => {
@@ -16126,7 +16126,7 @@
16126
16126
  type: String,
16127
16127
  default: "file"
16128
16128
  },
16129
- max: {
16129
+ maxCount: {
16130
16130
  type: Number,
16131
16131
  default: void 0
16132
16132
  },
@@ -16144,25 +16144,31 @@
16144
16144
  },
16145
16145
  listType: {
16146
16146
  type: String,
16147
- default: "picture"
16148
- }
16147
+ default: "picture-card"
16148
+ },
16149
+ listIgnore: {
16150
+ type: Boolean,
16151
+ default: true
16152
+ },
16153
+ showUploadList: {
16154
+ type: [Boolean, Object],
16155
+ default: true
16156
+ },
16157
+ customRequest: Function,
16158
+ beforeUpload: Function
16149
16159
  },
16150
16160
  setup(props, {
16151
16161
  attrs
16152
16162
  }) {
16153
16163
  const intl = useIntl();
16154
16164
  const {
16165
+ prefixCls,
16155
16166
  formData
16156
16167
  } = useInjectForm();
16157
16168
  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
- });
16169
+ const fileList = vue.ref([]);
16170
+ const formItemContext = antDesignVue.Form.useInjectFormItemContext();
16171
+ const baseClassName = vue.computed(() => `${prefixCls}-upload`);
16166
16172
  const isPictureCard = vue.computed(() => props.listType === "picture-card");
16167
16173
  const slotsGetter = vue.computed(() => {
16168
16174
  const temp = {};
@@ -16203,22 +16209,94 @@
16203
16209
  }
16204
16210
  return props.title || intl.getMessage("upload.button", "\u5355\u51FB\u4E0A\u4F20");
16205
16211
  });
16206
- const onChange = (info) => {
16212
+ const beforeUpload = async (file, fileList2) => {
16207
16213
  var _a;
16208
- (_a = props.onChange) == null ? void 0 : _a.call(props, info.fileList, info);
16214
+ const result = await ((_a = props.beforeUpload) == null ? void 0 : _a.call(props, file, fileList2));
16215
+ if (!result && props.listIgnore) {
16216
+ return antDesignVue.Upload.LIST_IGNORE;
16217
+ }
16218
+ return result;
16209
16219
  };
16210
- return () => vue.createVNode(antDesignVue.Upload, vue.mergeProps({
16211
- "fileList": value.value
16212
- }, attrs, {
16213
- "listType": props.listType,
16220
+ const customRequest = async (option) => {
16221
+ var _a, _b, _c;
16222
+ const formData2 = new FormData();
16223
+ formData2.append(props.name, option.file);
16224
+ const onUploadProgress = (e) => {
16225
+ var _a2;
16226
+ if (e.total > 0) {
16227
+ e.percent = e.loaded / e.total * 100;
16228
+ }
16229
+ (_a2 = option == null ? void 0 : option.onProgress) == null ? void 0 : _a2.call(option, e);
16230
+ };
16231
+ const {
16232
+ success,
16233
+ error,
16234
+ data
16235
+ } = (_a = await props.customRequest(formData2, onUploadProgress)) != null ? _a : {};
16236
+ if (success) {
16237
+ (_b = option.onSuccess) == null ? void 0 : _b.call(option, data);
16238
+ formItemContext.onFieldChange();
16239
+ } else {
16240
+ (_c = option.onError) == null ? void 0 : _c.call(option, error, data);
16241
+ }
16242
+ };
16243
+ const uploadProps = vue.computed(() => {
16244
+ const newProps = {
16245
+ ...attrs
16246
+ };
16247
+ if (props.customRequest) {
16248
+ newProps.customRequest = customRequest;
16249
+ }
16250
+ if (props.beforeUpload) {
16251
+ newProps.beforeUpload = beforeUpload;
16252
+ }
16253
+ return newProps;
16254
+ });
16255
+ vue.watch(() => props.value, (newValue) => {
16256
+ var _a;
16257
+ fileList.value = [...newValue == null ? void 0 : newValue.map((item) => ({
16258
+ ...item,
16259
+ name: item.name || item.url
16260
+ }))];
16261
+ if (!((_a = fileList.value) == null ? void 0 : _a.length)) {
16262
+ formItemContext.onFieldChange();
16263
+ }
16264
+ });
16265
+ const onUploadChange = (info) => {
16266
+ var _a;
16267
+ (_a = props.onChange) == null ? void 0 : _a.call(props, info.fileList.map((item) => {
16268
+ var _a2, _b, _c;
16269
+ return {
16270
+ ...item,
16271
+ name: item.name || ((_a2 = item.response) == null ? void 0 : _a2.name) || item.url || ((_b = item.response) == null ? void 0 : _b.url),
16272
+ url: ((_c = item.response) == null ? void 0 : _c.url) || item.url
16273
+ };
16274
+ }), info.file);
16275
+ };
16276
+ return () => vue.createVNode(antDesignVue.Upload, vue.mergeProps(uploadProps.value, {
16277
+ "class": {
16278
+ [`${baseClassName.value}-readonly`]: props.readonly
16279
+ },
16280
+ "fileList": fileList.value,
16281
+ "onUpdate:fileList": ($event) => fileList.value = $event,
16214
16282
  "name": props.name,
16215
- "onChange": onChange
16283
+ "maxCount": props.maxCount,
16284
+ "listType": props.listType,
16285
+ "showUploadList": props.readonly || props.showUploadList,
16286
+ "disabled": props.readonly || props.disabled,
16287
+ "style": attrs == null ? void 0 : attrs.style,
16288
+ "onChange": onUploadChange
16216
16289
  }), {
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
- }))],
16290
+ default: () => {
16291
+ var _a;
16292
+ 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", {
16293
+ "style": "margin-top: 8px"
16294
+ }, [vue.createTextVNode(" "), title.value])]) : vue.createVNode(antDesignVue.Button, vue.mergeProps({
16295
+ "disabled": props.disabled
16296
+ }, props.buttonProps), {
16297
+ default: () => [icon.value, title.value]
16298
+ })];
16299
+ },
16222
16300
  ...slotsGetter.value
16223
16301
  });
16224
16302
  }
@@ -16274,29 +16352,30 @@
16274
16352
  fileList: {
16275
16353
  type: Array,
16276
16354
  default: void 0
16277
- }
16355
+ },
16356
+ listIgnore: {
16357
+ type: Boolean,
16358
+ default: true
16359
+ },
16360
+ showUploadList: {
16361
+ type: [Boolean, Object],
16362
+ default: true
16363
+ },
16364
+ customRequest: Function,
16365
+ beforeUpload: Function
16278
16366
  },
16279
16367
  setup(props, {
16280
16368
  attrs
16281
16369
  }) {
16282
- const {
16283
- token
16284
- } = antDesignVue.theme.useToken();
16285
16370
  const {
16286
16371
  prefixCls,
16287
16372
  formData
16288
16373
  } = useInjectForm();
16289
16374
  const intl = useIntl();
16290
16375
  const formSlotsContext = useInjectSlots$1();
16291
- const value = vue.computed(() => {
16292
- var _a;
16293
- return (_a = props.fileList) != null ? _a : props.value;
16294
- });
16376
+ const fileList = vue.ref([]);
16377
+ const formItemContext = antDesignVue.Form.useInjectFormItemContext();
16295
16378
  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
16379
  const slotsGetter = vue.computed(() => {
16301
16380
  const temp = {};
16302
16381
  SLOT_NAMES$1.forEach((name) => {
@@ -16345,24 +16424,86 @@
16345
16424
  }
16346
16425
  return props.description || intl.getMessage("upload.dragger.hint", "\u652F\u6301\u5355\u6B21\u6216\u6279\u91CF\u4E0A\u4F20");
16347
16426
  });
16348
- const onChange = (info) => {
16427
+ const beforeUpload = async (file, fileList2) => {
16349
16428
  var _a;
16350
- (_a = props.onChange) == null ? void 0 : _a.call(props, info.fileList, info);
16429
+ const result = await ((_a = props.beforeUpload) == null ? void 0 : _a.call(props, file, fileList2));
16430
+ if (!result && props.listIgnore) {
16431
+ return antDesignVue.Upload.LIST_IGNORE;
16432
+ }
16433
+ return result;
16351
16434
  };
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
16435
+ const customRequest = async (option) => {
16436
+ var _a, _b, _c;
16437
+ const formData2 = new FormData();
16438
+ formData2.append(props.name, option.file);
16439
+ const onUploadProgress = (e) => {
16440
+ var _a2;
16441
+ if (e.total > 0) {
16442
+ e.percent = e.loaded / e.total * 100;
16443
+ }
16444
+ (_a2 = option == null ? void 0 : option.onProgress) == null ? void 0 : _a2.call(option, e);
16445
+ };
16446
+ const {
16447
+ success,
16448
+ error,
16449
+ data
16450
+ } = (_a = await props.customRequest(formData2, onUploadProgress)) != null ? _a : {};
16451
+ if (success) {
16452
+ (_b = option.onSuccess) == null ? void 0 : _b.call(option, data);
16453
+ formItemContext.onFieldChange();
16454
+ } else {
16455
+ (_c = option.onError) == null ? void 0 : _c.call(option, error, data);
16456
+ }
16457
+ };
16458
+ const uploadProps = vue.computed(() => {
16459
+ const newProps = {
16460
+ ...attrs
16461
+ };
16462
+ if (props.customRequest) {
16463
+ newProps.customRequest = customRequest;
16464
+ }
16465
+ if (props.beforeUpload) {
16466
+ newProps.beforeUpload = beforeUpload;
16467
+ }
16468
+ return newProps;
16469
+ });
16470
+ vue.watch(() => props.value, (newValue) => {
16471
+ var _a;
16472
+ fileList.value = [...newValue == null ? void 0 : newValue.map((item) => ({
16473
+ ...item,
16474
+ name: item.name || item.url
16475
+ }))];
16476
+ if (!((_a = fileList.value) == null ? void 0 : _a.length)) {
16477
+ formItemContext.onFieldChange();
16478
+ }
16479
+ });
16480
+ const onUploadChange = (info) => {
16481
+ var _a;
16482
+ (_a = props.onChange) == null ? void 0 : _a.call(props, info.fileList.map((item) => {
16483
+ var _a2, _b, _c;
16484
+ return {
16485
+ ...item,
16486
+ name: item.name || ((_a2 = item.response) == null ? void 0 : _a2.name) || item.url || ((_b = item.response) == null ? void 0 : _b.url),
16487
+ url: ((_c = item.response) == null ? void 0 : _c.url) || item.url
16488
+ };
16489
+ }), info.file);
16490
+ };
16491
+ return () => vue.createVNode(antDesignVue.Upload.Dragger, vue.mergeProps(uploadProps.value, {
16492
+ "class": {
16493
+ [`${baseClassName.value}-readonly`]: props.readonly
16359
16494
  },
16360
- "onChange": onChange
16495
+ "fileList": fileList.value,
16496
+ "onUpdate:fileList": ($event) => fileList.value = $event,
16497
+ "name": props.name,
16498
+ "showUploadList": props.readonly || props.showUploadList,
16499
+ "disabled": props.readonly || props.disabled,
16500
+ "style": attrs == null ? void 0 : attrs.style,
16501
+ "onChange": onUploadChange
16361
16502
  }), {
16362
16503
  default: () => [vue.createVNode("p", {
16363
16504
  "class": `${baseClassName.value}-drag-icon`,
16364
16505
  "style": {
16365
- color: token.value.colorPrimary
16506
+ color: "hsl(var(--pro-primary))"
16366
16507
  }
16367
16508
  }, [icon.value]), vue.createVNode("p", {
16368
16509
  "class": `${baseClassName.value}-text`
@@ -36787,6 +36928,10 @@
36787
36928
  tooltip: {
36788
36929
  type: [String, Boolean],
36789
36930
  default: ""
36931
+ },
36932
+ readonly: {
36933
+ type: Boolean,
36934
+ default: false
36790
36935
  }
36791
36936
  },
36792
36937
  setup(props) {
@@ -36801,7 +36946,8 @@
36801
36946
  }, [vue.createVNode(RenderVNode$1, {
36802
36947
  "vnode": title.value,
36803
36948
  "props": {
36804
- formData: formData.value
36949
+ formData: formData.value,
36950
+ readonly: props.readonly
36805
36951
  }
36806
36952
  }, null)]), props.tooltip && vue.createVNode(antDesignVue.Tooltip, null, {
36807
36953
  default: () => [vue.createVNode(QuestionCircleOutlined, {
@@ -36811,7 +36957,8 @@
36811
36957
  title: () => props.tooltip === true ? vue.createVNode(RenderVNode$1, {
36812
36958
  "vnode": title.value,
36813
36959
  "props": {
36814
- formData: formData.value
36960
+ formData: formData.value,
36961
+ readonly: props.readonly
36815
36962
  }
36816
36963
  }, null) : props.tooltip
36817
36964
  })]);
@@ -38403,6 +38550,7 @@
38403
38550
  "data",
38404
38551
  "directory",
38405
38552
  "disabled",
38553
+ "listIgnore",
38406
38554
  "downloadIcon",
38407
38555
  "fileList",
38408
38556
  "headers",
@@ -38436,6 +38584,7 @@
38436
38584
  "id",
38437
38585
  "accept",
38438
38586
  "action",
38587
+ "listIgnore",
38439
38588
  "beforeUpload",
38440
38589
  "customRequest",
38441
38590
  "data",
@@ -38477,6 +38626,7 @@
38477
38626
  "accept",
38478
38627
  "action",
38479
38628
  "beforeUpload",
38629
+ "listIgnore",
38480
38630
  "name",
38481
38631
  "headers",
38482
38632
  "isCropper",
@@ -38503,6 +38653,7 @@
38503
38653
  "multiple",
38504
38654
  "maxCount",
38505
38655
  "beforeUpload",
38656
+ "listIgnore",
38506
38657
  "name",
38507
38658
  "previewFile",
38508
38659
  "allowClear",
@@ -38724,7 +38875,8 @@
38724
38875
  "style": formItemProps.value.titleStyles
38725
38876
  }, [vue.createVNode(FormTitle, {
38726
38877
  "title": props.item.title,
38727
- "tooltip": props.item.tooltip
38878
+ "tooltip": props.item.tooltip,
38879
+ "readonly": mergeReadonly.value
38728
38880
  }, null)]), vue.createVNode("div", {
38729
38881
  "class": `${prefixCls}-item-title-extra`
38730
38882
  }, [vue.createVNode(RenderVNode$1, {