@opentinyvue/vue-file-upload 2.21.0

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.
package/lib/mobile.js ADDED
@@ -0,0 +1,177 @@
1
+ import { renderless, api } from '@opentinyvue/vue-renderless/file-upload/vue';
2
+ import { defineComponent, props, setup } from '@opentinyvue/vue-common';
3
+ import UploadList from '@opentinyvue/vue-upload-list';
4
+ import Upload from '@opentinyvue/vue-upload';
5
+ import Progress from '@opentinyvue/vue-progress';
6
+ import Modal from '@opentinyvue/vue-modal';
7
+ import { iconUpload } from '@opentinyvue/vue-icon';
8
+ import '@opentinyvue/vue-theme-mobile/file-upload/index.css';
9
+ import '@opentinyvue/vue-theme-mobile/upload-list/index.css';
10
+ import '@opentinyvue/vue-theme-mobile/upload-dragger/index.css';
11
+ import '@opentinyvue/vue-theme-mobile/upload/index.css';
12
+
13
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
14
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
15
+ if (render) {
16
+ options.render = render;
17
+ options.staticRenderFns = staticRenderFns;
18
+ options._compiled = true;
19
+ }
20
+ var hook;
21
+ if (injectStyles) {
22
+ hook = injectStyles;
23
+ }
24
+ if (hook) {
25
+ if (options.functional) {
26
+ options._injectStyles = hook;
27
+ var originalRender = options.render;
28
+ options.render = function renderWithStyleInjection(h, context) {
29
+ hook.call(context);
30
+ return originalRender(h, context);
31
+ };
32
+ } else {
33
+ var existing = options.beforeCreate;
34
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
35
+ }
36
+ }
37
+ return {
38
+ exports: scriptExports,
39
+ options
40
+ };
41
+ }
42
+
43
+ function _extends() {
44
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
45
+ for (var e = 1; e < arguments.length; e++) {
46
+ var t = arguments[e];
47
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
48
+ }
49
+ return n;
50
+ }, _extends.apply(null, arguments);
51
+ }
52
+ var __vue2_script = defineComponent({
53
+ inheritAttrs: false,
54
+ props: [].concat(props, ["size", "action", "drag", "headers", "data", "multiple", "name", "withCredentials", "showFileList", "accept", "type", "beforeUpload", "beforeRemove", "fileList", "autoUpload", "listType", "httpRequest", "disabled", "limit", "fileIconList", "display", "fileTitle", "headerShow", "successStatistics", "uploadIcon", "edm"]),
55
+ setup: function setup$1(props2, context) {
56
+ return setup({
57
+ props: props2,
58
+ context,
59
+ renderless,
60
+ api,
61
+ extendOptions: {
62
+ Modal
63
+ }
64
+ });
65
+ },
66
+ components: {
67
+ Progress,
68
+ UploadList,
69
+ Upload,
70
+ IconUpload: iconUpload()
71
+ },
72
+ render: function render() {
73
+ var _this = this;
74
+ var h = arguments[0];
75
+ var _this$state$listeners = this.state.listeners, _this$state$listeners2 = _this$state$listeners.exceed, exceed = _this$state$listeners2 === void 0 ? function() {
76
+ } : _this$state$listeners2, _this$state$listeners3 = _this$state$listeners.preview, preview = _this$state$listeners3 === void 0 ? function() {
77
+ } : _this$state$listeners3;
78
+ var fileTitle = this.fileTitle, headerShow = this.headerShow, successStatistics = this.successStatistics, uploadIcon = this.uploadIcon;
79
+ var uploadList;
80
+ var uploaArr = this.state.uploadFiles;
81
+ var successNum = 0;
82
+ var pictureArr = [];
83
+ uploaArr && uploaArr.map(function(item) {
84
+ if (_this.listType === "picture-card" && item.url) {
85
+ pictureArr.push(item.url);
86
+ }
87
+ if (item.status === "success") {
88
+ successNum += 1;
89
+ }
90
+ });
91
+ if (this.showFileList) {
92
+ var listData = {
93
+ props: {
94
+ disabled: this.state.uploadDisabled,
95
+ listType: this.listType,
96
+ files: this.state.uploadFiles,
97
+ filesIcon: this.fileIconList,
98
+ display: this.display,
99
+ srcList: pictureArr,
100
+ handlePreview: preview
101
+ },
102
+ on: {
103
+ remove: this.handleRemove
104
+ }
105
+ };
106
+ uploadList = h(UploadList, _extends({}, listData), function(props2) {
107
+ if (_this.slots.file) {
108
+ return _this.slots.file({
109
+ file: props2.file
110
+ });
111
+ }
112
+ });
113
+ }
114
+ var uploadData = {
115
+ props: {
116
+ type: this.type,
117
+ drag: this.drag,
118
+ action: this.state.url,
119
+ multiple: this.multiple,
120
+ withCredentials: this.withCredentials,
121
+ headers: this.headers,
122
+ name: this.name,
123
+ data: this.data,
124
+ accept: this.accept,
125
+ fileList: this.state.uploadFiles,
126
+ autoUpload: this.autoUpload,
127
+ listType: this.listType,
128
+ disabled: this.state.uploadDisabled,
129
+ limit: this.limit,
130
+ onExceed: exceed,
131
+ onStart: this.handleStart,
132
+ onProgress: this.handleProgress,
133
+ onSuccess: this.handleSuccess,
134
+ onError: this.handleError,
135
+ onPreview: preview,
136
+ httpRequest: this.state.httpRequest,
137
+ size: this.size
138
+ },
139
+ ref: "upload-inner"
140
+ };
141
+ var trigger = this.slots.trigger && this.slots.trigger() || this.slots.default();
142
+ var uploadComponent = !headerShow || this.listType === "picture-card" ? h(Upload, _extends({}, uploadData), trigger) : "";
143
+ var header = h("div", {
144
+ "class": "tiny-mobile-file-upload__header"
145
+ }, [h("div", {
146
+ "class": "tiny-mobile-file-upload__header-title"
147
+ }, [fileTitle]), h("div", {
148
+ "class": "tiny-mobile-file-upload__header-upload"
149
+ }, [successStatistics ? h("span", {
150
+ "class": "upload-status"
151
+ }, [successNum, "/", uploaArr.length]) : "", this.listType !== "picture-card" && uploadIcon ? h("span", {
152
+ "class": "upload-icon"
153
+ }, [h(Upload, _extends({}, uploadData), trigger || h("icon-upload"))]) : ""])]);
154
+ return h("div", {
155
+ "class": ["tiny-mobile-file-upload", this.$attrs.class],
156
+ "ref": "fileUpload"
157
+ }, [headerShow ? header : "", h("div", {
158
+ "class": {
159
+ "tiny-mobile-file-upload__wrap": true,
160
+ "is-card": this.listType === "picture-card"
161
+ }
162
+ }, [this.listType === "picture-card" ? uploadList : "", this.slots.trigger ? [uploadComponent, this.slots.default && this.slots.default()] : uploadComponent, this.slots.tip && this.slots.tip(), this.listType !== "picture-card" ? uploadList : ""])]);
163
+ }
164
+ });
165
+ var __vue2_render, __vue2_staticRenderFns;
166
+ var __cssModules = {};
167
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, __vue2_render, __vue2_staticRenderFns, false, __vue2_injectStyles);
168
+ function __vue2_injectStyles(context) {
169
+ for (var o in __cssModules) {
170
+ this[o] = __cssModules[o];
171
+ }
172
+ }
173
+ var mobile = /* @__PURE__ */ function() {
174
+ return __component__.exports;
175
+ }();
176
+
177
+ export { mobile as default };