upload2.mjs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import { ajaxUpload } from './ajax.mjs';
  2. import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
  3. import { mutable } from '../../../utils/typescript.mjs';
  4. import { NOOP } from '@vue/shared';
  5. const uploadListTypes = ["text", "picture", "picture-card"];
  6. let fileId = 1;
  7. const genFileId = () => Date.now() + fileId++;
  8. const uploadBaseProps = buildProps({
  9. action: {
  10. type: String,
  11. default: "#"
  12. },
  13. headers: {
  14. type: definePropType(Object)
  15. },
  16. method: {
  17. type: String,
  18. default: "post"
  19. },
  20. data: {
  21. type: definePropType([Object, Function, Promise]),
  22. default: () => mutable({})
  23. },
  24. multiple: Boolean,
  25. name: {
  26. type: String,
  27. default: "file"
  28. },
  29. drag: Boolean,
  30. withCredentials: Boolean,
  31. showFileList: {
  32. type: Boolean,
  33. default: true
  34. },
  35. accept: {
  36. type: String,
  37. default: ""
  38. },
  39. fileList: {
  40. type: definePropType(Array),
  41. default: () => mutable([])
  42. },
  43. autoUpload: {
  44. type: Boolean,
  45. default: true
  46. },
  47. listType: {
  48. type: String,
  49. values: uploadListTypes,
  50. default: "text"
  51. },
  52. httpRequest: {
  53. type: definePropType(Function),
  54. default: ajaxUpload
  55. },
  56. disabled: Boolean,
  57. limit: Number
  58. });
  59. const uploadProps = buildProps({
  60. ...uploadBaseProps,
  61. beforeUpload: {
  62. type: definePropType(Function),
  63. default: NOOP
  64. },
  65. beforeRemove: {
  66. type: definePropType(Function)
  67. },
  68. onRemove: {
  69. type: definePropType(Function),
  70. default: NOOP
  71. },
  72. onChange: {
  73. type: definePropType(Function),
  74. default: NOOP
  75. },
  76. onPreview: {
  77. type: definePropType(Function),
  78. default: NOOP
  79. },
  80. onSuccess: {
  81. type: definePropType(Function),
  82. default: NOOP
  83. },
  84. onProgress: {
  85. type: definePropType(Function),
  86. default: NOOP
  87. },
  88. onError: {
  89. type: definePropType(Function),
  90. default: NOOP
  91. },
  92. onExceed: {
  93. type: definePropType(Function),
  94. default: NOOP
  95. },
  96. crossorigin: {
  97. type: definePropType(String)
  98. }
  99. });
  100. export { genFileId, uploadBaseProps, uploadListTypes, uploadProps };
  101. //# sourceMappingURL=upload2.mjs.map